From 3220c46bcc518dfb5a2c9a4a4395c5edfec95f00 Mon Sep 17 00:00:00 2001 From: Maggie Date: Tue, 19 Dec 2017 17:02:20 -0800 Subject: [PATCH] Set initialExpandedChildrenCount dynamically in location settings In location settings, we want "Advanced" button show up right after "App level permissions". But with different numbers of "recent location requests" apps, the Preferences hidden under Advanced could change. To fix this issue, we fetch the list of apps with "recent location requests" in LocationSettings.onCreate(), and set initialExpandedChildrenCount for location PreferenceScreen to the apps count. Bug: 70350519 Test: Manual Change-Id: I4c4b6bdfa916213494a29e8ae8b5f33476411c88 --- res/xml/location_settings.xml | 31 +++++++++---------- .../settings/location/LocationSettings.java | 10 ++++++ 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml index 96fe9051a43..f8ac192473f 100644 --- a/res/xml/location_settings.xml +++ b/res/xml/location_settings.xml @@ -20,19 +20,9 @@ android:title="@string/location_settings_title" settings:keywords="@string/keywords_location"> - - - - + - + + + diff --git a/src/com/android/settings/location/LocationSettings.java b/src/com/android/settings/location/LocationSettings.java index 333042132d4..1279d677c50 100644 --- a/src/com/android/settings/location/LocationSettings.java +++ b/src/com/android/settings/location/LocationSettings.java @@ -72,6 +72,16 @@ public class LocationSettings extends DashboardFragment { private LocationSwitchBarController mSwitchBarController; + @Override + public void onCreate(Bundle icicle) { + super.onCreate(icicle); + final RecentLocationApps recentLocationApps = new RecentLocationApps(getActivity()); + int locationRequestsApps = recentLocationApps.getAppList().size(); + int locationRequestsPrefs = locationRequestsApps == 0 ? 1 : locationRequestsApps; + getPreferenceScreen().setInitialExpandedChildrenCount(locationRequestsPrefs + 2); + } + + @Override public int getMetricsCategory() { return MetricsEvent.LOCATION;