Add a new feature flag for the expand button in support lib.

- check the feature flag to determine whether to use the existing
progressive disclosure mixin or use the expand button in the support
library.
- add corresponding preference xml files that add the new preference
group attribute to use with the expand button in the support lib.

Bug: 63985174
Test: make RunSettingsRoboTests
Change-Id: Ida6eb6182a8066ad1413b7f6142512345fd914d0
This commit is contained in:
Doris Ling
2017-09-14 18:54:48 -07:00
parent fe18f8e876
commit 6f60cddc9e
14 changed files with 570 additions and 11 deletions

View File

@@ -73,7 +73,8 @@ public class DisplaySettings extends DashboardFragment {
@Override
protected int getPreferenceScreenResId() {
return R.xml.display_settings;
return mProgressiveDisclosureMixin.isEnabled()
? R.xml.display_settings : R.xml.display_settings_new_advance_button;
}
@Override

View File

@@ -60,7 +60,8 @@ public class AppAndNotificationDashboardFragment extends DashboardFragment {
@Override
protected int getPreferenceScreenResId() {
return R.xml.app_and_notification;
return mProgressiveDisclosureMixin.isEnabled()
? R.xml.app_and_notification : R.xml.app_and_notification_new_advance_button;
}
@Override

View File

@@ -24,6 +24,7 @@ import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;
import android.util.FeatureFlagUtils;
import android.util.Log;
import com.android.internal.logging.nano.MetricsProto;
@@ -42,6 +43,8 @@ import java.util.List;
public class ProgressiveDisclosureMixin implements Preference.OnPreferenceClickListener,
LifecycleObserver, OnCreate, OnSaveInstanceState {
@VisibleForTesting
static final String FEATURE_FLAG_NEW_ADVANCE_BUTTON = "new_settings_advance_button";
private static final String TAG = "ProgressiveDisclosure";
private static final String STATE_USER_EXPANDED = "state_user_expanded";
private static final int DEFAULT_TILE_LIMIT = 300;
@@ -102,11 +105,17 @@ public class ProgressiveDisclosureMixin implements Preference.OnPreferenceClickL
return false;
}
public boolean isEnabled() {
return !FeatureFlagUtils.isEnabled(FEATURE_FLAG_NEW_ADVANCE_BUTTON);
}
/**
* Sets the threshold to start collapsing preferences when there are too many.
*/
public void setTileLimit(int limit) {
mTileLimit = limit;
if (isEnabled()) {
mTileLimit = limit;
}
}
/**

View File

@@ -86,7 +86,8 @@ public class LanguageAndInputSettings extends DashboardFragment {
@Override
protected int getPreferenceScreenResId() {
return R.xml.language_and_input;
return mProgressiveDisclosureMixin.isEnabled()
? R.xml.language_and_input : R.xml.language_and_input_new_advance_button;
}
@Override

View File

@@ -109,7 +109,8 @@ public class SoundSettings extends DashboardFragment {
@Override
protected int getPreferenceScreenResId() {
return R.xml.sound_settings;
return mProgressiveDisclosureMixin.isEnabled()
? R.xml.sound_settings : R.xml.sound_settings_new_advance_button;
}
@Override