diff options
Diffstat (limited to 'navit/android')
-rw-r--r-- | navit/android/src/org/navitproject/navit/Navit.java | 10 | ||||
-rw-r--r-- | navit/android/src/org/navitproject/navit/NavitGraphics.java | 20 |
2 files changed, 30 insertions, 0 deletions
diff --git a/navit/android/src/org/navitproject/navit/Navit.java b/navit/android/src/org/navitproject/navit/Navit.java index 90fcbe5eb..5449a3431 100644 --- a/navit/android/src/org/navitproject/navit/Navit.java +++ b/navit/android/src/org/navitproject/navit/Navit.java @@ -590,6 +590,16 @@ public class Navit extends Activity break;
}
}
+
+ /**
+ * @brief Shows the Options menu.
+ *
+ * Calling this method has the same effect as pressing the hardware Menu button, where present, or touching
+ * the overflow button in the Action bar.
+ */
+ public void showMenu() {
+ openOptionsMenu();
+ }
void setDestination(float latitude, float longitude, String address) {
Toast.makeText( getApplicationContext(),getString(R.string.address_search_set_destination) + "\n" + address, Toast.LENGTH_LONG).show(); //TRANS
diff --git a/navit/android/src/org/navitproject/navit/NavitGraphics.java b/navit/android/src/org/navitproject/navit/NavitGraphics.java index 728b49878..08f4fbe3e 100644 --- a/navit/android/src/org/navitproject/navit/NavitGraphics.java +++ b/navit/android/src/org/navitproject/navit/NavitGraphics.java @@ -32,6 +32,7 @@ import android.graphics.Paint; import android.graphics.Path; import android.graphics.PointF; import android.graphics.Rect; +import android.os.Build; import android.os.Handler; import android.os.Message; import android.util.FloatMath; @@ -41,6 +42,7 @@ import android.view.KeyEvent; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; +import android.view.ViewConfiguration; import android.view.inputmethod.InputMethodManager; import android.widget.RelativeLayout; @@ -792,6 +794,24 @@ public class NavitGraphics private int SizeChangedCallbackID, ButtonCallbackID, MotionCallbackID, KeypressCallbackID; // private int count; + /** + * @brief Returns whether the device has a hardware menu button. + * + * Only Android versions starting with ICS (API version 14) support the API call to detect the presence of a + * Menu button. On earlier Android versions, the following assumptions will be made: On API levels up to 10, + * this method will always return {@code true}, as these Android versions relied on devices having a physical + * Menu button. On API levels 11 through 13 (Honeycomb releases), this method will always return + * {@code false}, as Honeycomb was a tablet-only release and did not require devices to have a Menu button. + */ + public boolean hasMenuButton() { + if (Build.VERSION.SDK_INT <= 10) + return true; + else if (Build.VERSION.SDK_INT <= 13) + return false; + else + return ViewConfiguration.get(activity.getApplication()).hasPermanentMenuKey(); + } + public void setSizeChangedCallback(int id) { SizeChangedCallbackID = id; |