From 4148f17616173a0bb475ed3b09ed90fc17540cc6 Mon Sep 17 00:00:00 2001 From: Lifu Tang Date: Wed, 23 Sep 2015 14:16:13 -0700 Subject: [PATCH] Explicitly ask for option menu in Fragments If a Fragment needs option menu, it has to ask for it explicitly by calling setHasOptionsMenu(true). If a preference screen contains help URL, this method is called automatically in the base class. However, if a preference screen doesn't have help URL, this method will not be called. So any other extra option menu will not be added correctly. Typically we won't be able to see this bug. Because on standard Nexus builds, all settings screen have their own help URL. But on AOSP build, as help URL is empty by default, if the vendor doesn't modify the resource to provide their own help URL, we'll end up missing some of the option menus. Bug: 24241310 Change-Id: Iaabc91a1d102e21254b518ec23459025efbdcc84 --- .../settings/accessibility/ToggleFeaturePreferenceFragment.java | 2 +- src/com/android/settings/location/LocationSettings.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java index d04c03fb21e..34882ae9c5b 100644 --- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java +++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java @@ -98,7 +98,7 @@ public abstract class ToggleFeaturePreferenceFragment @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - + setHasOptionsMenu(true); installActionBarToggleSwitch(); } diff --git a/src/com/android/settings/location/LocationSettings.java b/src/com/android/settings/location/LocationSettings.java index 2628c7fe605..10913715e62 100644 --- a/src/com/android/settings/location/LocationSettings.java +++ b/src/com/android/settings/location/LocationSettings.java @@ -117,6 +117,7 @@ public class LocationSettings extends LocationSettingsBase final SettingsActivity activity = (SettingsActivity) getActivity(); mUm = (UserManager) activity.getSystemService(Context.USER_SERVICE); + setHasOptionsMenu(true); mSwitchBar = activity.getSwitchBar(); mSwitch = mSwitchBar.getSwitch(); mSwitchBar.show();