diff options
-rw-r--r-- | gallerycommon/src/com/android/gallery3d/common/ApiHelper.java | 3 | ||||
-rw-r--r-- | src/com/android/gallery3d/util/HelpUtils.java | 12 |
2 files changed, 14 insertions, 1 deletions
diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index 3150442c7..6ae1bab2f 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -160,6 +160,9 @@ public class ApiHelper { public static final boolean HAS_SURFACE_TEXTURE_RECORDING = Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN; + + public static final boolean HAS_MENU_ITEM_SHOW_AS_ACTION = + Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB; private static boolean hasField(Class<?> klass, String fieldName) { try { diff --git a/src/com/android/gallery3d/util/HelpUtils.java b/src/com/android/gallery3d/util/HelpUtils.java index 2f02642fa..a029b3c26 100644 --- a/src/com/android/gallery3d/util/HelpUtils.java +++ b/src/com/android/gallery3d/util/HelpUtils.java @@ -16,6 +16,7 @@ package com.android.gallery3d.util; +import android.annotation.TargetApi; import android.content.Context; import android.content.Intent; import android.content.pm.PackageInfo; @@ -25,6 +26,8 @@ import android.text.TextUtils; import android.util.Log; import android.view.MenuItem; +import com.android.gallery3d.common.ApiHelper; + import java.util.Locale; /** @@ -96,7 +99,7 @@ public class HelpUtils { // Set the intent to the help menu item, show the help menu item in the overflow // menu, and make it visible. helpMenuItem.setIntent(intent); - helpMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); + setMenuItemShowAsAction(helpMenuItem); helpMenuItem.setVisible(true); // return that the help menu item is visible (i.e., true) @@ -104,6 +107,13 @@ public class HelpUtils { } } + @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) + private static void setMenuItemShowAsAction(MenuItem menuItem) { + if (ApiHelper.HAS_MENU_ITEM_SHOW_AS_ACTION) { + menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); + } + } + /** * Adds two query parameters into the Uri, namely the language code and the version code * of the app's package as gotten via the context. |