Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 45ed311e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add edit and delete buttons to zen rules"

parents ca32293e 48903cce
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -7142,6 +7142,9 @@
    <!--  Do not disturb: Delete text button presented in a dialog to confirm the user would like to delete the selected DND rules. [CHAR LIMIT=30] -->
    <string name="zen_mode_schedule_delete">Delete</string>
    <!--  Do not disturb: Edit label for button that allows user to edit the dnd schedule name. [CHAR LIMIT=30] -->
    <string name="zen_mode_rule_name_edit">Edit</string>
    <!--  Do not disturb: Title for the zen mode automatic rules page in settings. [CHAR LIMIT=30] -->
    <string name="zen_mode_automation_settings_page_title">Schedules</string>
@@ -7912,7 +7915,7 @@
        <item quantity="other"><xliff:g id="num_people" example="3">%d</xliff:g> others</item>
    </plurals>
    <!-- [CHAR LIMIT=20] Zen mode settings: Messages option -->
    <!-- [CHAR LIMIT=40] Zen mode settings: Messages option -->
    <string name="zen_mode_messages">Allow text messages</string>
    <!-- Do not disturb settings, messages, events and reminders footer [CHAR LIMIT=NONE]-->
+6 −1
Original line number Diff line number Diff line
@@ -17,12 +17,17 @@

<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    android:key="zen_mode_event_rule_settings"
    android:title="@string/zen_mode_automatic_rule_settings_page_title">

    <com.android.settingslib.widget.LayoutPreference
        android:key="pref_app_header"
        android:layout="@layout/settings_entity_header" />
        android:layout="@layout/settings_entity_header"
        settings:allowDividerBelow="true" />

    <com.android.settingslib.widget.ActionButtonsPreference
        android:key="zen_action_buttons" />

    <com.android.settingslib.widget.LayoutPreference
        android:key="zen_automatic_rule_switch"
+6 −1
Original line number Diff line number Diff line
@@ -17,12 +17,17 @@

<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    android:key="zen_mode_schedule_rule_settings"
    android:title="@string/zen_mode_automatic_rule_settings_page_title">

    <com.android.settingslib.widget.LayoutPreference
        android:key="pref_app_header"
        android:layout="@layout/settings_entity_header" />
        android:layout="@layout/settings_entity_header"
        settings:allowDividerBelow="true"/>

    <com.android.settingslib.widget.ActionButtonsPreference
        android:key="zen_action_buttons"/>

    <com.android.settingslib.widget.LayoutPreference
        android:key="zen_automatic_rule_switch"
+0 −24
Original line number Diff line number Diff line
@@ -76,14 +76,6 @@ public class ZenAutomaticRuleHeaderPreferenceController extends AbstractZenModeP
                mController = EntityHeaderController
                        .newInstance(mFragment.getActivity(), mFragment,
                                pref.findViewById(R.id.entity_header));

                mController.setEditListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        ZenRuleNameDialog.show(mFragment, mRule.getName(), null,
                                new RuleNameChangeListener());
                    }
                });
            }

            pref = mController.setIcon(getIcon())
@@ -123,20 +115,4 @@ public class ZenAutomaticRuleHeaderPreferenceController extends AbstractZenModeP
        mRule = rule;
        mId = id;
    }

    public class RuleNameChangeListener implements ZenRuleNameDialog.PositiveClickListener {
        public RuleNameChangeListener() {}

        @Override
        public void onOk(String ruleName, Fragment parent) {
            if (TextUtils.equals(ruleName, mRule.getName())) {
                return;
            }
            mMetricsFeatureProvider.action(mContext,
                    MetricsProto.MetricsEvent.ACTION_ZEN_MODE_RULE_NAME_CHANGE_OK);
            mRule.setName(ruleName);
            mRule.setModified(true);
            mBackend.updateZenRule(mId, mRule);
        }
    }
}
+12 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.app.AlertDialog;
import android.app.AutomaticZenRule;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.provider.SearchIndexableResource;
import android.service.notification.ConditionProviderService;
import android.view.Menu;
@@ -44,11 +45,22 @@ import java.util.Map;

@SearchIndexable
public class ZenModeAutomationSettings extends ZenModeSettingsBase {
    public static final String DELETE = "DELETE_RULE";
    protected final ManagedServiceSettings.Config CONFIG = getConditionProviderConfig();
    private CharSequence[] mDeleteDialogRuleNames;
    private String[] mDeleteDialogRuleIds;
    private boolean[] mDeleteDialogChecked;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        Bundle bundle = getArguments();
        if (bundle != null && bundle.containsKey(DELETE)) {
            mBackend.removeZenRule(bundle.getString(DELETE));
            bundle.remove(DELETE);
        }
    }

    @Override
    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
        ZenServiceListing serviceListing = new ZenServiceListing(getContext(), CONFIG);
Loading