Loading src/com/android/settings/SettingsPreferenceFragment.java +10 −13 Original line number Diff line number Diff line Loading @@ -135,19 +135,7 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF if (icicle != null) { mPreferenceHighlighted = icicle.getBoolean(SAVE_HIGHLIGHTED_KEY); } final Bundle arguments = getArguments(); // Check if we should keep the preferences expanded. if (arguments != null) { final String highlightKey = arguments.getString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY); if (!TextUtils.isEmpty(highlightKey)) { final PreferenceScreen screen = getPreferenceScreen(); if (screen != null) { screen.setInitialExpandedChildrenCount(Integer.MAX_VALUE); } } } HighlightablePreferenceGroupAdapter.adjustInitialExpandedChildCount(this /* host */); } @Override Loading Loading @@ -264,6 +252,15 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF } } /** * Returns initial expanded child count. * <p/> * Only override this method if the initial expanded child must be determined at run time. */ public int getInitialExpandedChildCount() { return 0; } protected void onDataSetChanged() { highlightPreferenceIfNeeded(); updateEmptyView(); Loading src/com/android/settings/deviceinfo/DeviceInfoSettings.java +6 −19 Original line number Diff line number Diff line Loading @@ -20,14 +20,12 @@ import android.app.Activity; import android.app.Fragment; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.provider.SearchIndexableResource; import android.support.annotation.VisibleForTesting; import android.telephony.TelephonyManager; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.settings.R; import com.android.settings.SettingsActivity; import com.android.settings.dashboard.DashboardFragment; import com.android.settings.dashboard.SummaryLoader; import com.android.settings.deviceinfo.firmwareversion.FirmwareVersionPreferenceController; Loading Loading @@ -64,23 +62,12 @@ public class DeviceInfoSettings extends DashboardFragment implements Indexable { } @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); final Bundle arguments = getArguments(); // Do not override initial expand children count if we come from // search (EXTRA_FRAGMENT_ARG_KEY is set) - we need to display every if entry point // is search. if (arguments == null || !arguments.containsKey(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY)) { // Increase the number of children when the device contains more than 1 sim. public int getInitialExpandedChildCount() { final TelephonyManager telephonyManager = (TelephonyManager) getContext() .getSystemService(Context.TELEPHONY_SERVICE); final int numberOfChildren = Math.max(SIM_PREFERENCES_COUNT, return Math.max(SIM_PREFERENCES_COUNT, SIM_PREFERENCES_COUNT * telephonyManager.getPhoneCount()) + NON_SIM_PREFERENCES_COUNT; getPreferenceScreen().setInitialExpandedChildrenCount(numberOfChildren); } } @Override Loading src/com/android/settings/location/LocationSettings.java +4 −6 Original line number Diff line number Diff line Loading @@ -67,15 +67,13 @@ public class LocationSettings extends DashboardFragment { private LocationSwitchBarController mSwitchBarController; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); public int getInitialExpandedChildCount() { final RecentLocationApps recentLocationApps = new RecentLocationApps(getActivity()); int locationRequestsApps = recentLocationApps.getAppList().size(); int locationRequestsPrefs = locationRequestsApps == 0 ? 1 : locationRequestsApps; getPreferenceScreen().setInitialExpandedChildrenCount(locationRequestsPrefs + 2); final int locationRequestsApps = recentLocationApps.getAppList().size(); final int locationRequestsPrefs = locationRequestsApps == 0 ? 1 : locationRequestsApps; return locationRequestsPrefs + 2; } @Override public int getMetricsCategory() { return MetricsEvent.LOCATION; Loading src/com/android/settings/widget/HighlightablePreferenceGroupAdapter.java +38 −0 Original line number Diff line number Diff line Loading @@ -16,10 +16,14 @@ package com.android.settings.widget; import static com.android.settings.SettingsActivity.EXTRA_FRAGMENT_ARG_KEY; import android.content.Context; import android.os.Bundle; import android.support.annotation.VisibleForTesting; import android.support.v7.preference.PreferenceGroup; import android.support.v7.preference.PreferenceGroupAdapter; import android.support.v7.preference.PreferenceScreen; import android.support.v7.preference.PreferenceViewHolder; import android.support.v7.widget.RecyclerView; import android.text.TextUtils; Loading @@ -27,6 +31,7 @@ import android.util.TypedValue; import android.view.View; import com.android.settings.R; import com.android.settings.SettingsPreferenceFragment; public class HighlightablePreferenceGroupAdapter extends PreferenceGroupAdapter { Loading @@ -41,6 +46,39 @@ public class HighlightablePreferenceGroupAdapter extends PreferenceGroupAdapter private boolean mHighlightRequested; private int mHighlightPosition = RecyclerView.NO_POSITION; /** * Tries to override initial expanded child count. * <p/> * Initial expanded child count will be ignored if: * 1. fragment contains request to highlight a particular row. * 2. count value is invalid. */ public static void adjustInitialExpandedChildCount(SettingsPreferenceFragment host) { if (host == null) { return; } final PreferenceScreen screen = host.getPreferenceScreen(); if (screen == null) { return; } final Bundle arguments = host.getArguments(); if (arguments != null) { final String highlightKey = arguments.getString(EXTRA_FRAGMENT_ARG_KEY); if (!TextUtils.isEmpty(highlightKey)) { // Has highlight row - expand everything screen.setInitialExpandedChildrenCount(Integer.MAX_VALUE); return; } } final int initialCount = host.getInitialExpandedChildCount(); if (initialCount <= 0) { return; } screen.setInitialExpandedChildrenCount(initialCount); } public HighlightablePreferenceGroupAdapter(PreferenceGroup preferenceGroup, String key, boolean highlightRequested) { super(preferenceGroup); Loading src/com/android/settings/wifi/ConfigureWifiSettings.java +2 −5 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.NetworkScoreManager; import android.net.wifi.WifiManager; import android.os.Bundle; import android.provider.SearchIndexableResource; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; Loading @@ -44,7 +43,6 @@ public class ConfigureWifiSettings extends DashboardFragment { private static final String TAG = "ConfigureWifiSettings"; public static final String KEY_WIFI_CONFIGURE = "wifi_configure_settings_screen"; public static final String KEY_IP_ADDRESS = "current_ip_address"; private WifiWakeupPreferenceController mWifiWakeupPreferenceController; Loading @@ -61,13 +59,12 @@ public class ConfigureWifiSettings extends DashboardFragment { } @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); public int getInitialExpandedChildCount() { int tileLimit = 2; if (mUseOpenWifiPreferenceController.isAvailable()) { tileLimit++; } getPreferenceScreen().setInitialExpandedChildrenCount(tileLimit); return tileLimit; } @Override Loading Loading
src/com/android/settings/SettingsPreferenceFragment.java +10 −13 Original line number Diff line number Diff line Loading @@ -135,19 +135,7 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF if (icicle != null) { mPreferenceHighlighted = icicle.getBoolean(SAVE_HIGHLIGHTED_KEY); } final Bundle arguments = getArguments(); // Check if we should keep the preferences expanded. if (arguments != null) { final String highlightKey = arguments.getString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY); if (!TextUtils.isEmpty(highlightKey)) { final PreferenceScreen screen = getPreferenceScreen(); if (screen != null) { screen.setInitialExpandedChildrenCount(Integer.MAX_VALUE); } } } HighlightablePreferenceGroupAdapter.adjustInitialExpandedChildCount(this /* host */); } @Override Loading Loading @@ -264,6 +252,15 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF } } /** * Returns initial expanded child count. * <p/> * Only override this method if the initial expanded child must be determined at run time. */ public int getInitialExpandedChildCount() { return 0; } protected void onDataSetChanged() { highlightPreferenceIfNeeded(); updateEmptyView(); Loading
src/com/android/settings/deviceinfo/DeviceInfoSettings.java +6 −19 Original line number Diff line number Diff line Loading @@ -20,14 +20,12 @@ import android.app.Activity; import android.app.Fragment; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.provider.SearchIndexableResource; import android.support.annotation.VisibleForTesting; import android.telephony.TelephonyManager; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.settings.R; import com.android.settings.SettingsActivity; import com.android.settings.dashboard.DashboardFragment; import com.android.settings.dashboard.SummaryLoader; import com.android.settings.deviceinfo.firmwareversion.FirmwareVersionPreferenceController; Loading Loading @@ -64,23 +62,12 @@ public class DeviceInfoSettings extends DashboardFragment implements Indexable { } @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); final Bundle arguments = getArguments(); // Do not override initial expand children count if we come from // search (EXTRA_FRAGMENT_ARG_KEY is set) - we need to display every if entry point // is search. if (arguments == null || !arguments.containsKey(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY)) { // Increase the number of children when the device contains more than 1 sim. public int getInitialExpandedChildCount() { final TelephonyManager telephonyManager = (TelephonyManager) getContext() .getSystemService(Context.TELEPHONY_SERVICE); final int numberOfChildren = Math.max(SIM_PREFERENCES_COUNT, return Math.max(SIM_PREFERENCES_COUNT, SIM_PREFERENCES_COUNT * telephonyManager.getPhoneCount()) + NON_SIM_PREFERENCES_COUNT; getPreferenceScreen().setInitialExpandedChildrenCount(numberOfChildren); } } @Override Loading
src/com/android/settings/location/LocationSettings.java +4 −6 Original line number Diff line number Diff line Loading @@ -67,15 +67,13 @@ public class LocationSettings extends DashboardFragment { private LocationSwitchBarController mSwitchBarController; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); public int getInitialExpandedChildCount() { final RecentLocationApps recentLocationApps = new RecentLocationApps(getActivity()); int locationRequestsApps = recentLocationApps.getAppList().size(); int locationRequestsPrefs = locationRequestsApps == 0 ? 1 : locationRequestsApps; getPreferenceScreen().setInitialExpandedChildrenCount(locationRequestsPrefs + 2); final int locationRequestsApps = recentLocationApps.getAppList().size(); final int locationRequestsPrefs = locationRequestsApps == 0 ? 1 : locationRequestsApps; return locationRequestsPrefs + 2; } @Override public int getMetricsCategory() { return MetricsEvent.LOCATION; Loading
src/com/android/settings/widget/HighlightablePreferenceGroupAdapter.java +38 −0 Original line number Diff line number Diff line Loading @@ -16,10 +16,14 @@ package com.android.settings.widget; import static com.android.settings.SettingsActivity.EXTRA_FRAGMENT_ARG_KEY; import android.content.Context; import android.os.Bundle; import android.support.annotation.VisibleForTesting; import android.support.v7.preference.PreferenceGroup; import android.support.v7.preference.PreferenceGroupAdapter; import android.support.v7.preference.PreferenceScreen; import android.support.v7.preference.PreferenceViewHolder; import android.support.v7.widget.RecyclerView; import android.text.TextUtils; Loading @@ -27,6 +31,7 @@ import android.util.TypedValue; import android.view.View; import com.android.settings.R; import com.android.settings.SettingsPreferenceFragment; public class HighlightablePreferenceGroupAdapter extends PreferenceGroupAdapter { Loading @@ -41,6 +46,39 @@ public class HighlightablePreferenceGroupAdapter extends PreferenceGroupAdapter private boolean mHighlightRequested; private int mHighlightPosition = RecyclerView.NO_POSITION; /** * Tries to override initial expanded child count. * <p/> * Initial expanded child count will be ignored if: * 1. fragment contains request to highlight a particular row. * 2. count value is invalid. */ public static void adjustInitialExpandedChildCount(SettingsPreferenceFragment host) { if (host == null) { return; } final PreferenceScreen screen = host.getPreferenceScreen(); if (screen == null) { return; } final Bundle arguments = host.getArguments(); if (arguments != null) { final String highlightKey = arguments.getString(EXTRA_FRAGMENT_ARG_KEY); if (!TextUtils.isEmpty(highlightKey)) { // Has highlight row - expand everything screen.setInitialExpandedChildrenCount(Integer.MAX_VALUE); return; } } final int initialCount = host.getInitialExpandedChildCount(); if (initialCount <= 0) { return; } screen.setInitialExpandedChildrenCount(initialCount); } public HighlightablePreferenceGroupAdapter(PreferenceGroup preferenceGroup, String key, boolean highlightRequested) { super(preferenceGroup); Loading
src/com/android/settings/wifi/ConfigureWifiSettings.java +2 −5 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.NetworkScoreManager; import android.net.wifi.WifiManager; import android.os.Bundle; import android.provider.SearchIndexableResource; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; Loading @@ -44,7 +43,6 @@ public class ConfigureWifiSettings extends DashboardFragment { private static final String TAG = "ConfigureWifiSettings"; public static final String KEY_WIFI_CONFIGURE = "wifi_configure_settings_screen"; public static final String KEY_IP_ADDRESS = "current_ip_address"; private WifiWakeupPreferenceController mWifiWakeupPreferenceController; Loading @@ -61,13 +59,12 @@ public class ConfigureWifiSettings extends DashboardFragment { } @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); public int getInitialExpandedChildCount() { int tileLimit = 2; if (mUseOpenWifiPreferenceController.isAvailable()) { tileLimit++; } getPreferenceScreen().setInitialExpandedChildrenCount(tileLimit); return tileLimit; } @Override Loading