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

Commit f487cb9e authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

DO NOT MERGE Always show custom zen vis eff option

+ dnd string edits

Change-Id: I2fcbe6c527b40610f997efacb08049c07b3a6dd7
Bug: 79538038
Bug: 78447976
Test: ZenModeViseffectsCustomPreferenceControllerTest
parent 204dcfdb
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -7928,6 +7928,9 @@
    <!-- [CHAR LIMIT=20] Zen mode settings: Calls option -->
    <string name="zen_mode_calls">Calls</string>
    <!-- [CHAR LIMIT=40] Zen mode settings: Allow calls toggle title -->
    <string name="zen_mode_calls_title">Allow calls</string>
    <!-- [CHAR LIMIT=20] Zen mode settings: Calls screen footer -->
    <string name="zen_mode_calls_footer">When Do Not Disturb is on, incoming calls are blocked. You can adjust settings to allow your friends, family, or other contacts to reach you.</string>
@@ -7943,6 +7946,9 @@
    <!-- [CHAR LIMIT=20] Zen mode settings: Messages option -->
    <string name="zen_mode_messages">Messages</string>
    <!-- [CHAR LIMIT=40] Zen mode settings: Allow messages toggle title -->
    <string name="zen_mode_messages_title">Allow messages</string>
    <!-- [CHAR LIMIT=50] Zen mode settings: All messages summary -->
    <string name="zen_mode_all_messages">Messages</string>
@@ -7982,9 +7988,15 @@
    <!-- [CHAR LIMIT=50] Zen mode settings: Reminders option -->
    <string name="zen_mode_reminders">Reminders</string>
    <!-- [CHAR LIMIT=70] Zen mode settings: Allow reminders toggle title -->
    <string name="zen_mode_reminders_title">Allow reminders</string>
    <!-- [CHAR LIMIT=50] Zen mode settings: Events option -->
    <string name="zen_mode_events">Events</string>
    <!-- [CHAR LIMIT=70] Zen mode settings: Allow events toggle title -->
    <string name="zen_mode_events_title">Allow events</string>
    <!-- [CHAR LIMIT=50] Zen mode settings: All callers summary -->
    <string name="zen_mode_all_callers">anyone</string>
@@ -7997,8 +8009,11 @@
    <!-- [CHAR LIMIT=50] Zen mode settings: Repeat callers option -->
    <string name="zen_mode_repeat_callers">Repeat callers</string>
    <!-- [CHAR LIMIT=70] Zen mode settings: Allow repeat callers toggle title -->
    <string name="zen_mode_repeat_callers_title">Allow repeat callers</string>
    <!-- [CHAR LIMIT=50] Zen mode settings: calls summary -->
    <string name="zen_mode_calls_summary_one">From <xliff:g id="caller type" example="contacts">%1$s</xliff:g> only</string>
    <string name="zen_mode_calls_summary_one">From <xliff:g id="caller type" example="contacts">%1$s</xliff:g></string>
    <!-- [CHAR LIMIT=50] Zen mode settings: calls summary -->
    <string name="zen_mode_calls_summary_two">From <xliff:g id="caller type" example="starred contacts">%1$s</xliff:g> and <xliff:g id="callert tpye" example="repeat callers">%2$s</xliff:g></string>
+2 −2
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@
      <!-- Calls -->
      <ListPreference
          android:key="zen_mode_calls"
          android:title="@string/zen_mode_calls"
          android:title="@string/zen_mode_calls_title"
          android:entries="@array/zen_mode_contacts_entries"
          android:entryValues="@array/zen_mode_contacts_values"/>

@@ -36,7 +36,7 @@
      <!-- Repeat callers -->
      <SwitchPreference
          android:key="zen_mode_repeat_callers"
          android:title="@string/zen_mode_repeat_callers" />
          android:title="@string/zen_mode_repeat_callers_title" />
   </PreferenceCategory>

   <com.android.settingslib.widget.FooterPreference/>
+3 −3
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@
      <!-- Messages -->
      <ListPreference
          android:key="zen_mode_messages"
          android:title="@string/zen_mode_messages"
          android:title="@string/zen_mode_messages_title"
          android:entries="@array/zen_mode_contacts_entries"
          android:entryValues="@array/zen_mode_contacts_values"/>

@@ -36,12 +36,12 @@
      <!-- Reminders -->
      <SwitchPreference
          android:key="zen_mode_reminders"
          android:title="@string/zen_mode_reminders"/>
          android:title="@string/zen_mode_reminders_title"/>

      <!-- Events -->
      <SwitchPreference
          android:key="zen_mode_events"
          android:title="@string/zen_mode_events"/>
          android:title="@string/zen_mode_events_title"/>
   </PreferenceCategory>

   <com.android.settingslib.widget.FooterPreference />
+4 −57
Original line number Diff line number Diff line
@@ -16,22 +16,15 @@

package com.android.settings.notification;

import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.ACTION_ZEN_SHOW_CUSTOM;

import android.content.Context;
import android.os.Bundle;
import android.provider.SearchIndexableResource;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.widget.FooterPreference;

@@ -40,65 +33,19 @@ import java.util.List;

public class ZenModeRestrictNotificationsSettings extends ZenModeSettingsBase implements Indexable {

    protected static final int APP_MENU_SHOW_CUSTOM = 1;
    protected boolean mShowMenuSelected;

    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        menu.add(0, APP_MENU_SHOW_CUSTOM, 0, R.string.zen_mode_restrict_notifications_enable_custom)
                .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() == APP_MENU_SHOW_CUSTOM) {
            final FeatureFactory featureFactory = FeatureFactory.getFactory(mContext);
            MetricsFeatureProvider metrics = featureFactory.getMetricsFeatureProvider();

            mShowMenuSelected = !mShowMenuSelected;

            ZenModeVisEffectsCustomPreferenceController custom =
                    use(ZenModeVisEffectsCustomPreferenceController.class);
            custom.setShownByMenu(mShowMenuSelected);
            custom.displayPreference(getPreferenceScreen());

            if (mShowMenuSelected) {
                metrics.action(mContext, ACTION_ZEN_SHOW_CUSTOM, true);
            } else {
                metrics.action(mContext, ACTION_ZEN_SHOW_CUSTOM, false);
            }

            return true;
        }
        return false;
    }

    @Override
    public void onPrepareOptionsMenu(Menu menu) {
        if (mShowMenuSelected) {
            menu.findItem(APP_MENU_SHOW_CUSTOM)
                    .setTitle(R.string.zen_mode_restrict_notifications_disable_custom);
        } else {
            menu.findItem(APP_MENU_SHOW_CUSTOM)
                    .setTitle(R.string.zen_mode_restrict_notifications_enable_custom);
        }

        if (mShowMenuSelected && use(ZenModeVisEffectsCustomPreferenceController.class)
                .areCustomOptionsSelected()) {
            menu.findItem(APP_MENU_SHOW_CUSTOM).setEnabled(false);
        } else {
            menu.findItem(APP_MENU_SHOW_CUSTOM).setEnabled(true);
        }
    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
        return buildPreferenceControllers(context, getLifecycle());
    }

    @Override
    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
        return buildPreferenceControllers(context, getLifecycle());
    public int getHelpResource() {
        return R.string.help_uri_interruptions;
    }

    private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
+14 −10
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.app.FragmentManager;
import android.app.NotificationManager;
import android.app.NotificationManager.Policy;
import android.content.Context;
import android.icu.text.ListFormatter;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.service.notification.ZenModeConfig;
@@ -166,17 +167,20 @@ public class ZenModeSettings extends ZenModeSettingsBase {
                return mContext.getString(R.string.join_two_items, enabledCategories.get(0),
                        enabledCategories.get(1).toLowerCase());
            } else if (numCategories == 3){
                String secondaryText = mContext.getString(R.string.join_two_unrelated_items,
                        enabledCategories.get(0), enabledCategories.get(1).toLowerCase());
                return mContext.getString(R.string.join_many_items_last, secondaryText,
                        enabledCategories.get(2).toLowerCase());
                final List<String> summaries = new ArrayList<>();
                summaries.add(enabledCategories.get(0));
                summaries.add(enabledCategories.get(1).toLowerCase());
                summaries.add(enabledCategories.get(2).toLowerCase());

                return ListFormatter.getInstance().format(summaries);
            } else {
                String secondaryText = mContext.getString(R.string.join_many_items_middle,
                        enabledCategories.get(0), enabledCategories.get(1).toLowerCase());
                secondaryText = mContext.getString(R.string.join_many_items_middle, secondaryText,
                        enabledCategories.get(2).toLowerCase());
                return mContext.getString(R.string.join_many_items_last, secondaryText,
                        mContext.getString(R.string.zen_mode_other_options));
                final List<String> summaries = new ArrayList<>();
                summaries.add(enabledCategories.get(0));
                summaries.add(enabledCategories.get(1).toLowerCase());
                summaries.add(enabledCategories.get(2).toLowerCase());
                summaries.add(mContext.getString(R.string.zen_mode_other_options));

                return ListFormatter.getInstance().format(summaries);
            }
        }

Loading