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

@@ -28,29 +28,27 @@ import com.android.settings.search.Indexable;
import com.android.settings.utils.ManagedServiceSettings;
import com.android.settings.utils.ZenServiceListing;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import java.util.ArrayList;
import java.util.List;
public class ZenModeAutomationSettings extends ZenModeSettingsBase {
private static final String KEY_ADD_RULE = "zen_mode_add_automatic_rule";
private static final String KEY_AUTOMATIC_RULES = "zen_mode_automatic_rules";
protected static final ManagedServiceSettings.Config CONFIG = getConditionProviderConfig();
protected final ManagedServiceSettings.Config CONFIG = getConditionProviderConfig();
@Override
protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
ZenServiceListing serviceListing = new ZenServiceListing(getContext(), CONFIG);
serviceListing.reloadApprovedServices();
return buildPreferenceControllers(context, this, serviceListing);
return buildPreferenceControllers(context, this, serviceListing, getLifecycle());
}
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
Fragment parent, ZenServiceListing serviceListing) {
Fragment parent, ZenServiceListing serviceListing, Lifecycle lifecycle) {
List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(new ZenModeAddAutomaticRulePreferenceController(context, KEY_ADD_RULE,
parent, serviceListing));
controllers.add(new ZenModeAutomaticRulesPreferenceController(context,
KEY_AUTOMATIC_RULES, parent));
controllers.add(new ZenModeAddAutomaticRulePreferenceController(context, parent,
serviceListing, lifecycle));
controllers.add(new ZenModeAutomaticRulesPreferenceController(context, parent, lifecycle));
return controllers;
}
@@ -94,15 +92,15 @@ public class ZenModeAutomationSettings extends ZenModeSettingsBase {
@Override
public List<String> getNonIndexableKeys(Context context) {
final List<String> keys = super.getNonIndexableKeys(context);
keys.add(KEY_ADD_RULE);
keys.add(KEY_AUTOMATIC_RULES);
keys.add(ZenModeAddAutomaticRulePreferenceController.KEY);
keys.add(ZenModeAutomaticRulesPreferenceController.KEY);
return keys;
}
@Override
public List<AbstractPreferenceController> getPreferenceControllers(
Context context) {
return buildPreferenceControllers(context, null, null);
return buildPreferenceControllers(context, null, null, null);
}
};
}