OSDN Git Service

Always show custom zen vis eff option
authorBeverly <beverlyt@google.com>
Mon, 14 May 2018 18:12:38 +0000 (14:12 -0400)
committerBeverly Tai <beverlyt@google.com>
Mon, 14 May 2018 19:03:40 +0000 (19:03 +0000)
Cherry-picked from pi-dev ag/4044915
+ dnd string edits

Change-Id: I2fcbe6c527b40610f997efacb08049c07b3a6dd7
Fixes: 79538038
Bug: 78447976
Test: ZenModeViseffectsCustomPreferenceControllerTes

res/values/strings.xml
res/xml/zen_mode_calls_settings.xml
res/xml/zen_mode_msg_event_reminder_settings.xml
src/com/android/settings/notification/ZenModeRestrictNotificationsSettings.java
src/com/android/settings/notification/ZenModeSettings.java
src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceController.java
tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java
tests/robotests/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceControllerTest.java

index 7a11dc6..165126f 100644 (file)
     <!-- [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>
 
     <!-- [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>
 
     <!-- [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>
 
     <!-- [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>
index dd6fcc5..2da022c 100644 (file)
@@ -26,7 +26,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"/>
 
@@ -37,7 +37,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/>
index d12fc62..8fc6b47 100644 (file)
@@ -26,7 +26,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"/>
 
       <!-- 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 />
index a2a0ba7..737c646 100644 (file)
 
 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.search.SearchIndexable;
 import com.android.settingslib.widget.FooterPreference;
@@ -42,65 +35,19 @@ import java.util.List;
 @SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
 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,
index 3fb5a4b..240ab68 100644 (file)
@@ -170,7 +170,7 @@ public class ZenModeSettings extends ZenModeSettingsBase {
             } else if (numCategories == 2) {
                 return mContext.getString(R.string.join_two_items, enabledCategories.get(0),
                         enabledCategories.get(1).toLowerCase());
-            } else if (numCategories == 3) {
+            } else if (numCategories == 3){
                 final List<String> summaries = new ArrayList<>();
                 summaries.add(enabledCategories.get(0));
                 summaries.add(enabledCategories.get(1).toLowerCase());
index 5baf0fa..5dd99f6 100644 (file)
@@ -30,7 +30,6 @@ import com.android.settingslib.core.lifecycle.Lifecycle;
 public class ZenModeVisEffectsCustomPreferenceController
         extends AbstractZenModePreferenceController {
 
-    protected boolean mShowMenuSelected;
     protected static final int INTERRUPTIVE_EFFECTS = Policy.SUPPRESSED_EFFECT_AMBIENT
             | Policy.SUPPRESSED_EFFECT_PEEK
             | Policy.SUPPRESSED_EFFECT_LIGHTS
@@ -43,11 +42,7 @@ public class ZenModeVisEffectsCustomPreferenceController
 
     @Override
     public boolean isAvailable() {
-        if (mShowMenuSelected) {
-            return true;
-        }
-
-        return areCustomOptionsSelected();
+        return true;
     }
 
     @Override
@@ -67,10 +62,6 @@ public class ZenModeVisEffectsCustomPreferenceController
         });
     }
 
-    protected void setShownByMenu(boolean shown) {
-        mShowMenuSelected = shown;
-    }
-
     protected boolean areCustomOptionsSelected() {
         boolean allEffectsSuppressed =
                 Policy.areAllVisualEffectsSuppressed(mBackend.mPolicy.suppressedVisualEffects);
index 5b2782f..39e9271 100644 (file)
@@ -134,13 +134,13 @@ public class ZenModeSettingsTest {
     public void testGetCallsSettingSummary_contacts() {
         Policy policy = new Policy(Policy.PRIORITY_CATEGORY_ALARMS | Policy.PRIORITY_CATEGORY_CALLS,
                 Policy.PRIORITY_SENDERS_CONTACTS, 0, 0);
-        assertThat(mBuilder.getCallsSettingSummary(policy)).isEqualTo("From contacts only");
+        assertThat(mBuilder.getCallsSettingSummary(policy)).isEqualTo("From contacts");
     }
 
     @Test
     public void testGetCallsSettingSummary_repeatCallers() {
         Policy policy = new Policy(Policy.PRIORITY_CATEGORY_REPEAT_CALLERS, 0, 0, 0);
-        assertThat(mBuilder.getCallsSettingSummary(policy)).isEqualTo("From repeat callers only");
+        assertThat(mBuilder.getCallsSettingSummary(policy)).isEqualTo("From repeat callers");
     }
 
     @Test
index f3d92d1..4544622 100644 (file)
@@ -88,23 +88,14 @@ public class ZenModeVisEffectsCustomPreferenceControllerTest {
     }
 
     @Test
-    public void isAvailable_menuOff_noVisEffects() {
+    public void isAvailable_noVisEffects() {
         mBackend.mPolicy = new NotificationManager.Policy(0, 0, 0, 0);
-        mController.mShowMenuSelected = false;
-        assertThat(mController.isAvailable()).isFalse();
-    }
-
-    @Test
-    public void isAvailable_menuOn_noVisEffects() {
-        mBackend.mPolicy = new NotificationManager.Policy(0, 0, 0, 0);
-        mController.mShowMenuSelected = true;
         assertThat(mController.isAvailable()).isTrue();
     }
 
     @Test
-    public void isAvailable_menuOn_visEffects() {
+    public void isAvailable_visEffects() {
         mBackend.mPolicy = new NotificationManager.Policy(0, 0, 0, 1);
-        mController.mShowMenuSelected = false;
         assertThat(mController.isAvailable()).isTrue();
     }