Updates to automatic rule pages in Settings

- Re-added metrics for zen behavior preference controllers
- Dialogs in zen mode settings are rotate-friendly
- Automatic rules are refreshed on update state
- User-created (and default) automatic rules are always priority only and user cannot change this
- Automatic rules redesigned to have headers

Test: make ROBOTEST_FILTER=ZenModeAutomaticRulesPreferenceControllerTest RunSettingsRoboTests -j40
Bug: 63077372
Fixes: 68324465
Fixes: 69057696
Change-Id: I163acef2715dd4e60bfc08207f0e22352c4c0e28
This commit is contained in:
Beverly
2017-11-20 17:33:01 -05:00
parent 91fff3093d
commit 323522171d
25 changed files with 829 additions and 405 deletions

View File

@@ -21,6 +21,7 @@ import android.content.Context;
import android.content.Intent;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settings.utils.ZenServiceListing;
@@ -28,19 +29,18 @@ public class ZenModeAddAutomaticRulePreferenceController extends
AbstractZenModeAutomaticRulePreferenceController implements
Preference.OnPreferenceClickListener {
private final String KEY_ADD_RULE;
protected static final String KEY = "zen_mode_add_automatic_rule";
private final ZenServiceListing mZenServiceListing;
public ZenModeAddAutomaticRulePreferenceController(Context context, String key,
Fragment parent, ZenServiceListing serviceListing) {
super(context, parent);
KEY_ADD_RULE = key;
public ZenModeAddAutomaticRulePreferenceController(Context context, Fragment parent,
ZenServiceListing serviceListing, Lifecycle lifecycle) {
super(context, KEY, parent, lifecycle);
mZenServiceListing = serviceListing;
}
@Override
public String getPreferenceKey() {
return KEY_ADD_RULE;
return KEY;
}
@Override
@@ -51,25 +51,30 @@ public class ZenModeAddAutomaticRulePreferenceController extends
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
Preference pref = screen.findPreference(KEY_ADD_RULE);
Preference pref = screen.findPreference(KEY);
pref.setPersistent(false);
pref.setOnPreferenceClickListener(this);
}
@Override
public boolean onPreferenceClick(Preference preference) {
new ZenRuleSelectionDialog(mContext, mZenServiceListing) {
@Override
public void onSystemRuleSelected(ZenRuleInfo ri) {
showNameRuleDialog(ri);
}
@Override
public void onExternalRuleSelected(ZenRuleInfo ri) {
Intent intent = new Intent().setComponent(ri.configurationActivity);
mParent.startActivity(intent);
}
}.show();
ZenRuleSelectionDialog.show(mContext, mParent, new RuleSelectionListener(),
mZenServiceListing);
return true;
}
public class RuleSelectionListener implements ZenRuleSelectionDialog.PositiveClickListener {
public RuleSelectionListener() {}
@Override
public void onSystemRuleSelected(ZenRuleInfo ri, Fragment parent) {
showNameRuleDialog(ri, parent);
}
@Override
public void onExternalRuleSelected(ZenRuleInfo ri, Fragment parent) {
Intent intent = new Intent().setComponent(ri.configurationActivity);
parent.startActivity(intent);
}
}
}