Search in sources :

Example 6 with AutomaticZenRule

use of android.app.AutomaticZenRule in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ZenModeSettingsBase method addZenRule.

protected String addZenRule(AutomaticZenRule rule) {
    try {
        String id = NotificationManager.from(mContext).addAutomaticZenRule(rule);
        final AutomaticZenRule savedRule = NotificationManager.from(mContext).getAutomaticZenRule(id);
        maybeRefreshRules(savedRule != null, true);
        return id;
    } catch (Exception e) {
        return null;
    }
}
Also used : AutomaticZenRule(android.app.AutomaticZenRule)

Example 7 with AutomaticZenRule

use of android.app.AutomaticZenRule in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ZenModeAutomationSettings method updateControls.

private void updateControls() {
    final PreferenceScreen root = getPreferenceScreen();
    root.removeAll();
    final Map.Entry<String, AutomaticZenRule>[] sortedRules = sortedRules();
    for (Map.Entry<String, AutomaticZenRule> sortedRule : sortedRules) {
        ZenRulePreference pref = new ZenRulePreference(getPrefContext(), sortedRule);
        if (pref.appExists) {
            root.addPreference(pref);
        }
    }
    final Preference p = new Preference(getPrefContext());
    p.setIcon(R.drawable.ic_add);
    p.setTitle(R.string.zen_mode_add_rule);
    p.setPersistent(false);
    p.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            MetricsLogger.action(mContext, MetricsEvent.ACTION_ZEN_ADD_RULE);
            showAddRuleDialog();
            return true;
        }
    });
    root.addPreference(p);
}
Also used : OnPreferenceClickListener(android.support.v7.preference.Preference.OnPreferenceClickListener) AutomaticZenRule(android.app.AutomaticZenRule) PreferenceScreen(android.support.v7.preference.PreferenceScreen) Preference(android.support.v7.preference.Preference) Map(java.util.Map)

Aggregations

AutomaticZenRule (android.app.AutomaticZenRule)7 ServiceInfo (android.content.pm.ServiceInfo)5 ZenModeConfig (android.service.notification.ZenModeConfig)5 ZenRule (android.service.notification.ZenModeConfig.ZenRule)5 AndroidRuntimeException (android.util.AndroidRuntimeException)5 Preference (android.support.v7.preference.Preference)1 OnPreferenceClickListener (android.support.v7.preference.Preference.OnPreferenceClickListener)1 PreferenceScreen (android.support.v7.preference.PreferenceScreen)1 Map (java.util.Map)1