Do not show advanced dropdown if only one setting
Change-Id: I56eff1198636d0f0b95f4aa58eb90efc346c3f65 Fixes: 69402845 Test: make RunSettingsRoboTests -j40
This commit is contained in:
@@ -16,8 +16,12 @@
|
||||
package com.android.settings.system;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceGroup;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
@@ -40,6 +44,17 @@ public class SystemDashboardFragment extends DashboardFragment {
|
||||
|
||||
private static final String KEY_RESET = "reset_dashboard";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
||||
final PreferenceScreen screen = getPreferenceScreen();
|
||||
// We do not want to display an advanced button if only one setting is hidden
|
||||
if (getVisiblePreferenceCount(screen) == screen.getInitialExpandedChildrenCount() + 1) {
|
||||
screen.setInitialExpandedChildrenCount(Integer.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.SETTINGS_SYSTEM_CATEGORY;
|
||||
@@ -74,6 +89,19 @@ public class SystemDashboardFragment extends DashboardFragment {
|
||||
return controllers;
|
||||
}
|
||||
|
||||
private int getVisiblePreferenceCount(PreferenceGroup group) {
|
||||
int visibleCount = 0;
|
||||
for (int i = 0; i < group.getPreferenceCount(); i++) {
|
||||
final Preference preference = group.getPreference(i);
|
||||
if (preference instanceof PreferenceGroup) {
|
||||
visibleCount += getVisiblePreferenceCount((PreferenceGroup) preference);
|
||||
} else if (preference.isVisible()) {
|
||||
visibleCount++;
|
||||
}
|
||||
}
|
||||
return visibleCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* For Search.
|
||||
*/
|
||||
@@ -88,7 +116,8 @@ public class SystemDashboardFragment extends DashboardFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AbstractPreferenceController> getPreferenceControllers(Context context) {
|
||||
public List<AbstractPreferenceController> getPreferenceControllers(
|
||||
Context context) {
|
||||
return buildPreferenceControllers(context);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user