Bug 1030113 - Regression: Menu breaks on Firefox 29+ on tablets with hardware menu. r=mfinkle, a=lmandel
authorChenxia Liu <liuche@mozilla.com>
Mon, 07 Jul 2014 15:19:53 -0700
changeset 207942 c66e5fd06de37b45bd36f8115d86c15c716ed8f6
parent 207941 42d2d6edaddcf91634232b5330db1f44c8023016
child 207943 10b0cd0433a6b1efaeb2f8a03719017f22a4e564
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, lmandel
bugs1030113
milestone32.0a2
Bug 1030113 - Regression: Menu breaks on Firefox 29+ on tablets with hardware menu. r=mfinkle, a=lmandel
mobile/android/base/preferences/GeckoPreferenceFragment.java
mobile/android/base/resources/menu-v11/preferences_search_menu.xml
--- a/mobile/android/base/preferences/GeckoPreferenceFragment.java
+++ b/mobile/android/base/preferences/GeckoPreferenceFragment.java
@@ -1,16 +1,15 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.preferences;
 
-import java.lang.reflect.Field;
 import java.util.Locale;
 
 import org.mozilla.gecko.BrowserLocaleManager;
 import org.mozilla.gecko.GeckoSharedPrefs;
 import org.mozilla.gecko.LocaleManager;
 import org.mozilla.gecko.PrefsHelper;
 import org.mozilla.gecko.R;
 
@@ -22,17 +21,16 @@ import android.content.res.Resources;
 import android.os.Build;
 import android.os.Bundle;
 import android.preference.PreferenceActivity;
 import android.preference.PreferenceFragment;
 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)
  * as well as initializing Gecko prefs when a fragment is shown.
 */
 public class GeckoPreferenceFragment extends PreferenceFragment {
 
     @Override
@@ -193,34 +191,9 @@ public class GeckoPreferenceFragment ext
 
     @Override
     public void onDestroy() {
         super.onDestroy();
         if (mPrefsRequestId > 0) {
             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.");
-        }
-    }
-}
+}
\ No newline at end of file
--- a/mobile/android/base/resources/menu-v11/preferences_search_menu.xml
+++ b/mobile/android/base/resources/menu-v11/preferences_search_menu.xml
@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - 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>