Bug 1030113 - Regression: Menu breaks on Firefox 29+ on tablets with hardware menu. r=mfinkle

This commit is contained in:
Chenxia Liu 2014-07-07 15:19:53 -07:00
parent 2800dbbdc9
commit 3a914bc7d1
2 changed files with 5 additions and 32 deletions

View File

@ -5,7 +5,6 @@
package org.mozilla.gecko.preferences;
import java.lang.reflect.Field;
import java.util.Locale;
import org.mozilla.gecko.BrowserLocaleManager;
@ -27,7 +26,6 @@ import android.preference.PreferenceScreen;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.ViewConfiguration;
/* A simple implementation of PreferenceFragment for large screen devices
* This will strip category headers (so that they aren't shown to the user twice)
@ -198,29 +196,4 @@ public class GeckoPreferenceFragment extends PreferenceFragment {
PrefsHelper.removeObserver(mPrefsRequestId);
}
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
showOverflowMenu(activity);
}
/*
* Force the overflow 3-dot menu to be displayed if it isn't already displayed.
*
* This is an ugly hack for 4.0+ Android devices that don't have a dedicated menu button
* because Android does not provide a public API to display the ActionBar overflow menu.
*/
private void showOverflowMenu(Activity activity) {
try {
ViewConfiguration config = ViewConfiguration.get(activity);
Field menuOverflow = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
if (menuOverflow != null) {
menuOverflow.setAccessible(true);
menuOverflow.setBoolean(config, false);
}
} catch (Exception e) {
Log.d(LOGTAG, "Failed to force overflow menu, ignoring.");
}
}
}
}

View File

@ -4,8 +4,8 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/restore_defaults"
android:title="@string/pref_search_restore_defaults" />
<item android:id="@+id/restore_defaults"
android:drawable="@drawable/menu"
android:showAsAction="never"
android:title="@string/pref_search_restore_defaults" />
</menu>