Progressive disclosure on selected UIs: app, display
Bug: 32255863 Test: RunSettingsRoboTests Change-Id: I1651433ba30a2b5f880095e07b5e2ed9c4e308b9
This commit is contained in:
@@ -61,6 +61,12 @@ public class DisplaySettings extends DashboardFragment {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
mProgressiveDisclosureMixin.setTileLimit(4);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getCategoryKey() {
|
||||
return CategoryKey.CATEGORY_DISPLAY;
|
||||
|
@@ -16,7 +16,6 @@
|
||||
package com.android.settings.applications;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
@@ -36,11 +35,6 @@ public class AdvancedAppSettings extends DashboardFragment {
|
||||
|
||||
static final String TAG = "AdvancedAppSettings";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getCategoryKey() {
|
||||
return CategoryKey.CATEGORY_APPS_DEFAULT;
|
||||
|
@@ -39,6 +39,12 @@ public class AppAndNotificationDashboardFragment extends DashboardFragment {
|
||||
return MetricsProto.MetricsEvent.SETTINGS_APP_NOTIF_CATEGORY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
mProgressiveDisclosureMixin.setTileLimit(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getCategoryKey() {
|
||||
return CategoryKey.CATEGORY_APPS;
|
||||
|
@@ -268,6 +268,7 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
||||
|
||||
// Add resource based tiles.
|
||||
displayResourceTiles();
|
||||
mProgressiveDisclosureMixin.collapse(getPreferenceScreen());
|
||||
|
||||
refreshDashboardTiles(TAG);
|
||||
}
|
||||
|
@@ -47,6 +47,7 @@ public class ExpandPreference extends Preference {
|
||||
|
||||
private void init() {
|
||||
setLayoutResource(R.layout.expand_preference);
|
||||
setIcon(R.drawable.ic_arrow_down_24dp);
|
||||
setTitle(R.string.wifi_more);
|
||||
setOrder(999);
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@ import android.support.v7.preference.PreferenceScreen;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settings.core.lifecycle.events.OnCreate;
|
||||
import com.android.settings.core.lifecycle.events.OnSaveInstanceState;
|
||||
@@ -40,18 +41,19 @@ public class ProgressiveDisclosureMixin implements Preference.OnPreferenceClickL
|
||||
private static final String STATE_USER_EXPANDED = "state_user_expanded";
|
||||
private static final int DEFAULT_TILE_LIMIT = 300;
|
||||
|
||||
private int mTileLimit = DEFAULT_TILE_LIMIT;
|
||||
|
||||
private final Context mContext;
|
||||
private final DashboardFeatureProvider mDashboardFeatureProvider;
|
||||
// Collapsed preference sorted by order.
|
||||
private final List<Preference> mCollapsedPrefs = new ArrayList<>();
|
||||
private final ExpandPreference mExpandButton;
|
||||
private /* final */ ExpandPreference mExpandButton;
|
||||
private final PreferenceFragment mFragment;
|
||||
|
||||
private int mTileLimit = DEFAULT_TILE_LIMIT;
|
||||
private boolean mUserExpanded;
|
||||
|
||||
public ProgressiveDisclosureMixin(Context context,
|
||||
DashboardFeatureProvider dashboardFeatureProvider, PreferenceFragment fragment) {
|
||||
mContext = context;
|
||||
mFragment = fragment;
|
||||
mExpandButton = new ExpandPreference(context);
|
||||
mExpandButton.setOnPreferenceClickListener(this);
|
||||
@@ -181,6 +183,8 @@ public class ProgressiveDisclosureMixin implements Preference.OnPreferenceClickL
|
||||
if (mCollapsedPrefs.isEmpty()) {
|
||||
// Removed last element, remove expand button too.
|
||||
screen.removePreference(mExpandButton);
|
||||
} else {
|
||||
updateExpandButtonSummary();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -216,10 +220,28 @@ public class ProgressiveDisclosureMixin implements Preference.OnPreferenceClickL
|
||||
insertionIndex = insertionIndex * -1 - 1;
|
||||
}
|
||||
mCollapsedPrefs.add(insertionIndex, preference);
|
||||
updateExpandButtonSummary();
|
||||
}
|
||||
|
||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||
List<Preference> getCollapsedPrefs() {
|
||||
return mCollapsedPrefs;
|
||||
}
|
||||
|
||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||
void updateExpandButtonSummary() {
|
||||
final int size = mCollapsedPrefs.size();
|
||||
if (size == 0) {
|
||||
mExpandButton.setSummary(null);
|
||||
} else if (size == 1) {
|
||||
mExpandButton.setSummary(mCollapsedPrefs.get(0).getTitle());
|
||||
} else {
|
||||
CharSequence summary = mCollapsedPrefs.get(0).getTitle();
|
||||
for (int i = 1; i < size; i++) {
|
||||
summary = mContext.getString(R.string.join_many_items_middle, summary,
|
||||
mCollapsedPrefs.get(i).getTitle());
|
||||
}
|
||||
mExpandButton.setSummary(summary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user