Loading packages/SettingsLib/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -1117,6 +1117,8 @@ <string name="zen_mode_duration_settings_title">Duration</string> <!-- Do not disturb: Duration option to always prompt for the duration of dnd --> <string name="zen_mode_duration_always_prompt_title">Ask every time</string> <!-- Do not disturb: Duration option to always have DND on until it is manually turned off [CHAR LIMIT=60] --> <string name="zen_mode_forever">Until you turn off</string> <!-- time label for event have that happened very recently [CHAR LIMIT=60] --> <string name="time_unit_just_now">Just now</string> Loading packages/SettingsLib/src/com/android/settingslib/notification/ZenDurationDialog.java +9 −6 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.settingslib.notification; import android.app.ActivityManager; import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; Loading @@ -42,6 +41,7 @@ import com.android.settingslib.R; import java.util.Arrays; import androidx.annotation.VisibleForTesting; import androidx.appcompat.app.AlertDialog; public class ZenDurationDialog { private static final int[] MINUTE_BUCKETS = ZenModeConfig.MINUTE_BUCKETS; Loading @@ -67,12 +67,17 @@ public class ZenDurationDialog { } public Dialog createDialog() { final AlertDialog.Builder builder = new AlertDialog.Builder(mContext); setupDialog(builder); return builder.create(); } public void setupDialog(AlertDialog.Builder builder) { int zenDuration = Settings.Secure.getInt( mContext.getContentResolver(), Settings.Secure.ZEN_DURATION, Settings.Secure.ZEN_DURATION_FOREVER); final AlertDialog.Builder builder = new AlertDialog.Builder(mContext) .setTitle(R.string.zen_mode_duration_settings_title) builder.setTitle(R.string.zen_mode_duration_settings_title) .setNegativeButton(R.string.cancel, null) .setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() { Loading @@ -85,7 +90,6 @@ public class ZenDurationDialog { View contentView = getContentView(); setupRadioButtons(zenDuration); builder.setView(contentView); return builder.create(); } @VisibleForTesting Loading Loading @@ -270,8 +274,7 @@ public class ZenDurationDialog { String radioContentText = ""; switch (rowIndex) { case FOREVER_CONDITION_INDEX: radioContentText = mContext.getString( com.android.internal.R.string.zen_mode_forever); radioContentText = mContext.getString(R.string.zen_mode_forever); break; case COUNTDOWN_CONDITION_INDEX: Condition condition = ZenModeConfig.toTimeCondition(mContext, Loading packages/SettingsLib/tests/robotests/src/com/android/settingslib/notification/ZenDurationDialogTest.java +13 −8 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import android.app.AlertDialog; import android.app.Activity; import android.app.Fragment; import android.app.NotificationManager; import android.content.Context; Loading @@ -40,6 +40,8 @@ import android.view.LayoutInflater; import android.view.View; import android.widget.Button; import androidx.appcompat.app.AlertDialog; import com.android.settingslib.SettingsLibRobolectricTestRunner; import org.junit.Before; Loading @@ -47,6 +49,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.Robolectric; import org.robolectric.RuntimeEnvironment; @RunWith(SettingsLibRobolectricTestRunner.class) Loading @@ -58,6 +61,7 @@ public class ZenDurationDialogTest { private Condition mCountdownCondition; private Condition mAlarmCondition; private ContentResolver mContentResolver; private AlertDialog.Builder mBuilder; @Before public void setup() { Loading @@ -68,13 +72,14 @@ public class ZenDurationDialogTest { mController = spy(new ZenDurationDialog(mContext)); mController.mLayoutInflater = mLayoutInflater; mController.getContentView(); mBuilder = new AlertDialog.Builder(mContext); } @Test public void testAlwaysPrompt() { Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION, Settings.Global.ZEN_DURATION_PROMPT); mController.createDialog(); mController.setupDialog(mBuilder); assertFalse(mController.getConditionTagAt(ZenDurationDialog.FOREVER_CONDITION_INDEX).rb .isChecked()); Loading @@ -88,7 +93,7 @@ public class ZenDurationDialogTest { public void testForever() { Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION, Settings.Secure.ZEN_DURATION_FOREVER); mController.createDialog(); mController.setupDialog(mBuilder); assertTrue(mController.getConditionTagAt(ZenDurationDialog.FOREVER_CONDITION_INDEX).rb .isChecked()); Loading @@ -101,7 +106,7 @@ public class ZenDurationDialogTest { @Test public void testSpecificDuration() { Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION, 45); mController.createDialog(); mController.setupDialog(mBuilder); assertFalse(mController.getConditionTagAt(ZenDurationDialog.FOREVER_CONDITION_INDEX).rb .isChecked()); Loading @@ -117,7 +122,7 @@ public class ZenDurationDialogTest { Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION, Settings.Secure.ZEN_DURATION_FOREVER); AlertDialog dialog = (AlertDialog) mController.createDialog(); mController.setupDialog(mBuilder); mController.getConditionTagAt(ZenDurationDialog.ALWAYS_ASK_CONDITION_INDEX).rb.setChecked( true); mController.updateZenDuration(Settings.Secure.ZEN_DURATION_FOREVER); Loading @@ -131,7 +136,7 @@ public class ZenDurationDialogTest { Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION, Settings.Secure.ZEN_DURATION_PROMPT); AlertDialog dialog = (AlertDialog) mController.createDialog(); mController.setupDialog(mBuilder); mController.getConditionTagAt(ZenDurationDialog.FOREVER_CONDITION_INDEX).rb.setChecked( true); mController.updateZenDuration(Settings.Secure.ZEN_DURATION_PROMPT); Loading @@ -145,7 +150,7 @@ public class ZenDurationDialogTest { Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION, Settings.Secure.ZEN_DURATION_PROMPT); AlertDialog dialog = (AlertDialog) mController.createDialog(); mController.setupDialog(mBuilder); mController.getConditionTagAt(ZenDurationDialog.COUNTDOWN_CONDITION_INDEX).rb.setChecked( true); mController.updateZenDuration(Settings.Secure.ZEN_DURATION_PROMPT); Loading @@ -160,7 +165,7 @@ public class ZenDurationDialogTest { Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION, Settings.Secure.ZEN_DURATION_PROMPT); AlertDialog dialog = (AlertDialog) mController.createDialog(); mController.setupDialog(mBuilder); // click time button starts at 60 minutes // - 1 hour to MAX_BUCKET_MINUTES (12 hours), increments by 1 hour // - 0-60 minutes increments by 15 minutes Loading Loading
packages/SettingsLib/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -1117,6 +1117,8 @@ <string name="zen_mode_duration_settings_title">Duration</string> <!-- Do not disturb: Duration option to always prompt for the duration of dnd --> <string name="zen_mode_duration_always_prompt_title">Ask every time</string> <!-- Do not disturb: Duration option to always have DND on until it is manually turned off [CHAR LIMIT=60] --> <string name="zen_mode_forever">Until you turn off</string> <!-- time label for event have that happened very recently [CHAR LIMIT=60] --> <string name="time_unit_just_now">Just now</string> Loading
packages/SettingsLib/src/com/android/settingslib/notification/ZenDurationDialog.java +9 −6 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.settingslib.notification; import android.app.ActivityManager; import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; Loading @@ -42,6 +41,7 @@ import com.android.settingslib.R; import java.util.Arrays; import androidx.annotation.VisibleForTesting; import androidx.appcompat.app.AlertDialog; public class ZenDurationDialog { private static final int[] MINUTE_BUCKETS = ZenModeConfig.MINUTE_BUCKETS; Loading @@ -67,12 +67,17 @@ public class ZenDurationDialog { } public Dialog createDialog() { final AlertDialog.Builder builder = new AlertDialog.Builder(mContext); setupDialog(builder); return builder.create(); } public void setupDialog(AlertDialog.Builder builder) { int zenDuration = Settings.Secure.getInt( mContext.getContentResolver(), Settings.Secure.ZEN_DURATION, Settings.Secure.ZEN_DURATION_FOREVER); final AlertDialog.Builder builder = new AlertDialog.Builder(mContext) .setTitle(R.string.zen_mode_duration_settings_title) builder.setTitle(R.string.zen_mode_duration_settings_title) .setNegativeButton(R.string.cancel, null) .setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() { Loading @@ -85,7 +90,6 @@ public class ZenDurationDialog { View contentView = getContentView(); setupRadioButtons(zenDuration); builder.setView(contentView); return builder.create(); } @VisibleForTesting Loading Loading @@ -270,8 +274,7 @@ public class ZenDurationDialog { String radioContentText = ""; switch (rowIndex) { case FOREVER_CONDITION_INDEX: radioContentText = mContext.getString( com.android.internal.R.string.zen_mode_forever); radioContentText = mContext.getString(R.string.zen_mode_forever); break; case COUNTDOWN_CONDITION_INDEX: Condition condition = ZenModeConfig.toTimeCondition(mContext, Loading
packages/SettingsLib/tests/robotests/src/com/android/settingslib/notification/ZenDurationDialogTest.java +13 −8 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import android.app.AlertDialog; import android.app.Activity; import android.app.Fragment; import android.app.NotificationManager; import android.content.Context; Loading @@ -40,6 +40,8 @@ import android.view.LayoutInflater; import android.view.View; import android.widget.Button; import androidx.appcompat.app.AlertDialog; import com.android.settingslib.SettingsLibRobolectricTestRunner; import org.junit.Before; Loading @@ -47,6 +49,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.Robolectric; import org.robolectric.RuntimeEnvironment; @RunWith(SettingsLibRobolectricTestRunner.class) Loading @@ -58,6 +61,7 @@ public class ZenDurationDialogTest { private Condition mCountdownCondition; private Condition mAlarmCondition; private ContentResolver mContentResolver; private AlertDialog.Builder mBuilder; @Before public void setup() { Loading @@ -68,13 +72,14 @@ public class ZenDurationDialogTest { mController = spy(new ZenDurationDialog(mContext)); mController.mLayoutInflater = mLayoutInflater; mController.getContentView(); mBuilder = new AlertDialog.Builder(mContext); } @Test public void testAlwaysPrompt() { Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION, Settings.Global.ZEN_DURATION_PROMPT); mController.createDialog(); mController.setupDialog(mBuilder); assertFalse(mController.getConditionTagAt(ZenDurationDialog.FOREVER_CONDITION_INDEX).rb .isChecked()); Loading @@ -88,7 +93,7 @@ public class ZenDurationDialogTest { public void testForever() { Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION, Settings.Secure.ZEN_DURATION_FOREVER); mController.createDialog(); mController.setupDialog(mBuilder); assertTrue(mController.getConditionTagAt(ZenDurationDialog.FOREVER_CONDITION_INDEX).rb .isChecked()); Loading @@ -101,7 +106,7 @@ public class ZenDurationDialogTest { @Test public void testSpecificDuration() { Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION, 45); mController.createDialog(); mController.setupDialog(mBuilder); assertFalse(mController.getConditionTagAt(ZenDurationDialog.FOREVER_CONDITION_INDEX).rb .isChecked()); Loading @@ -117,7 +122,7 @@ public class ZenDurationDialogTest { Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION, Settings.Secure.ZEN_DURATION_FOREVER); AlertDialog dialog = (AlertDialog) mController.createDialog(); mController.setupDialog(mBuilder); mController.getConditionTagAt(ZenDurationDialog.ALWAYS_ASK_CONDITION_INDEX).rb.setChecked( true); mController.updateZenDuration(Settings.Secure.ZEN_DURATION_FOREVER); Loading @@ -131,7 +136,7 @@ public class ZenDurationDialogTest { Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION, Settings.Secure.ZEN_DURATION_PROMPT); AlertDialog dialog = (AlertDialog) mController.createDialog(); mController.setupDialog(mBuilder); mController.getConditionTagAt(ZenDurationDialog.FOREVER_CONDITION_INDEX).rb.setChecked( true); mController.updateZenDuration(Settings.Secure.ZEN_DURATION_PROMPT); Loading @@ -145,7 +150,7 @@ public class ZenDurationDialogTest { Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION, Settings.Secure.ZEN_DURATION_PROMPT); AlertDialog dialog = (AlertDialog) mController.createDialog(); mController.setupDialog(mBuilder); mController.getConditionTagAt(ZenDurationDialog.COUNTDOWN_CONDITION_INDEX).rb.setChecked( true); mController.updateZenDuration(Settings.Secure.ZEN_DURATION_PROMPT); Loading @@ -160,7 +165,7 @@ public class ZenDurationDialogTest { Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION, Settings.Secure.ZEN_DURATION_PROMPT); AlertDialog dialog = (AlertDialog) mController.createDialog(); mController.setupDialog(mBuilder); // click time button starts at 60 minutes // - 1 hour to MAX_BUCKET_MINUTES (12 hours), increments by 1 hour // - 0-60 minutes increments by 15 minutes Loading