Update zen onboarding ui
am: 29ba3601b0
Change-Id: I2c1769f683dd464c96e758b61bd5e47b4a538c44
This commit is contained in:
@@ -742,7 +742,7 @@
|
|||||||
android:name=".notification.ZenOnboardingActivity"
|
android:name=".notification.ZenOnboardingActivity"
|
||||||
android:label="@string/zen_onboarding_dnd_visual_disturbances_header"
|
android:label="@string/zen_onboarding_dnd_visual_disturbances_header"
|
||||||
android:icon="@drawable/ic_settings_notifications"
|
android:icon="@drawable/ic_settings_notifications"
|
||||||
android:theme="@style/Theme.Settings.NoActionBar"
|
android:theme="@*android:style/Theme.DeviceDefault.Settings.Dialog.NoActionBar"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:taskAffinity="com.android.settings"
|
android:taskAffinity="com.android.settings"
|
||||||
android:parentActivityName="Settings">
|
android:parentActivityName="Settings">
|
||||||
|
@@ -16,152 +16,49 @@
|
|||||||
-->
|
-->
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="320dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:padding="20dp">
|
android:padding="20dp">
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/header_icon"
|
|
||||||
android:layout_width="32dp"
|
|
||||||
android:layout_height="32dp"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:src="@drawable/ic_zen"
|
|
||||||
android:tint="?android:attr/colorAccent"/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/header"
|
android:id="@+id/header"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/header_icon"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_marginTop="12dp"
|
|
||||||
android:text="@string/zen_onboarding_dnd_visual_disturbances_header"
|
android:text="@string/zen_onboarding_dnd_visual_disturbances_header"
|
||||||
android:textAppearance="@android:style/TextAppearance.Material.Headline" />
|
android:textAppearance="@android:style/TextAppearance.Material.DialogWindowTitle" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/feature_description"
|
android:id="@+id/feature_description"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/header"
|
android:layout_below="@+id/header"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_marginTop="24dp"
|
||||||
android:textAlignment="center"
|
|
||||||
android:layout_marginTop="14dp"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||||
android:text="@string/zen_onboarding_dnd_visual_disturbances_description" />
|
android:text="@string/zen_onboarding_dnd_visual_disturbances_description" />
|
||||||
|
|
||||||
<LinearLayout
|
<RelativeLayout
|
||||||
android:id="@+id/screen_off"
|
android:id="@+id/buttons"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/feature_description"
|
android:layout_below="@+id/feature_description"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_marginTop="35dp">
|
||||||
android:layout_marginTop="35dp"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<CheckBox
|
<Button
|
||||||
android:id="@+id/screen_off_option"
|
android:id="@+id/no"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingHorizontal="8dp"
|
android:text="@string/zen_onboarding_no_update"
|
||||||
android:onClick="logClick" />
|
android:layout_toStartOf="@+id/ok"
|
||||||
|
style="@style/TextAppearance.ZenOnboardingButton"
|
||||||
<LinearLayout
|
android:onClick="close" />
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/screen_off_title"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/zen_onboarding_screen_off_title"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceListItem" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/screen_off_summary"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/zen_onboarding_screen_off_summary" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/screen_on"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/screen_off"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<CheckBox
|
|
||||||
android:id="@+id/screen_on_option"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingHorizontal="8dp"
|
|
||||||
android:onClick="logClick" />
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/screen_on_title"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/zen_onboarding_screen_on_title"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceListItem" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/screen_on_summary"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/zen_onboarding_screen_on_summary" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/further_customize"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/screen_on"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
|
||||||
android:text="@string/zen_onboarding_more_options" />
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/further_customize"
|
|
||||||
android:layout_marginTop="35dp"
|
|
||||||
android:id="@+id/buttons">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/settings"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_centerInParent="true"
|
|
||||||
android:text="@string/zen_onboarding_settings"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
|
||||||
android:textColor="?android:attr/colorControlActivated"
|
|
||||||
android:onClick="launchSettings" />
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/ok"
|
android:id="@+id/ok"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_centerInParent="true"
|
|
||||||
android:text="@string/zen_onboarding_ok"
|
android:text="@string/zen_onboarding_ok"
|
||||||
style="@style/ActionPrimaryButton"
|
style="@style/TextAppearance.ZenOnboardingButton"
|
||||||
android:onClick="save" />
|
android:onClick="save" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
@@ -7360,14 +7360,26 @@
|
|||||||
<item quantity="other"><xliff:g id="on_count" example="3">%d</xliff:g> rules can turn on automatically</item>
|
<item quantity="other"><xliff:g id="on_count" example="3">%d</xliff:g> rules can turn on automatically</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
|
|
||||||
<string name="zen_onboarding_ok">Ok</string>
|
<!-- Do not disturb onboarding dialog, accept new settings [CHAR LIMIT=30]-->
|
||||||
|
<string name="zen_onboarding_ok">Update</string>
|
||||||
|
<!-- Do not disturb onboarding dialog, do not accept new settings [CHAR LIMIT=30]-->
|
||||||
|
<string name="zen_onboarding_no_update">Don\'t update</string>
|
||||||
|
<!-- Do not disturb onboarding dialog, description of new settings [CHAR LIMIT=NONE]-->
|
||||||
|
<string name="zen_onboarding_dnd_visual_disturbances_description">Your phone mutes sounds & vibrations\n\nUpdate settings to also:\n\n- Hide notifications\n\n- Only show calls from starred contacts</string>
|
||||||
|
<!-- Do not disturb onboarding dialog, header prompt for settings [CHAR LIMIT=80]-->
|
||||||
|
<string name="zen_onboarding_dnd_visual_disturbances_header">Update your Do Not Disturb settings?</string>
|
||||||
|
|
||||||
|
<!-- obsolete -->
|
||||||
<string name="zen_onboarding_settings">Settings</string>
|
<string name="zen_onboarding_settings">Settings</string>
|
||||||
|
<!-- obsolete -->
|
||||||
<string name="zen_onboarding_more_options">You can further customize this in Settings.</string>
|
<string name="zen_onboarding_more_options">You can further customize this in Settings.</string>
|
||||||
|
<!-- obsolete -->
|
||||||
<string name="zen_onboarding_screen_on_title">Block when the screen is on</string>
|
<string name="zen_onboarding_screen_on_title">Block when the screen is on</string>
|
||||||
|
<!-- obsolete -->
|
||||||
<string name="zen_onboarding_screen_off_title">Block when the screen is off</string>
|
<string name="zen_onboarding_screen_off_title">Block when the screen is off</string>
|
||||||
<string name="zen_onboarding_dnd_visual_disturbances_description">Do Not Disturb can do more than block unwanted sounds - it can block visuals too. This may be helpful if you\'re trying to sleep, focus, or limit time spent on your phone.</string>
|
<!-- obsolete -->
|
||||||
<string name="zen_onboarding_dnd_visual_disturbances_header">Block sounds and visuals</string>
|
|
||||||
<string name="zen_onboarding_screen_off_summary">Don\'t turn on the screen or wake for notifications</string>
|
<string name="zen_onboarding_screen_off_summary">Don\'t turn on the screen or wake for notifications</string>
|
||||||
|
<!-- obsolete -->
|
||||||
<string name="zen_onboarding_screen_on_summary">Don\'t show notifications at all, except for basic phone activity and status</string>
|
<string name="zen_onboarding_screen_on_summary">Don\'t show notifications at all, except for basic phone activity and status</string>
|
||||||
|
|
||||||
<!-- Work Sounds: Work sound settings section header. [CHAR LIMIT=50] -->
|
<!-- Work Sounds: Work sound settings section header. [CHAR LIMIT=50] -->
|
||||||
|
@@ -432,6 +432,17 @@
|
|||||||
<item name="android:ellipsize">marquee</item>
|
<item name="android:ellipsize">marquee</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="TextAppearance.ZenOnboardingButton">
|
||||||
|
<item name="android:fontFamily">sans-serif-medium</item>
|
||||||
|
<item name="android:textSize">14sp</item>
|
||||||
|
<item name="android:textColor">?android:attr/colorAccent</item>
|
||||||
|
<item name="android:background">@drawable/btn_borderless_rect</item>
|
||||||
|
<item name="android:gravity">center</item>
|
||||||
|
<item name="android:focusable">true</item>
|
||||||
|
<item name="android:paddingStart">8dp</item>
|
||||||
|
<item name="android:paddingEnd">8dp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="ActionPrimaryButton" parent="android:Widget.DeviceDefault.Button.Colored"/>
|
<style name="ActionPrimaryButton" parent="android:Widget.DeviceDefault.Button.Colored"/>
|
||||||
|
|
||||||
<style name="ActionSecondaryButton" parent="android:Widget.DeviceDefault.Button"/>
|
<style name="ActionSecondaryButton" parent="android:Widget.DeviceDefault.Button"/>
|
||||||
|
@@ -33,8 +33,6 @@ public class ZenOnboardingActivity extends Activity {
|
|||||||
|
|
||||||
private NotificationManager mNm;
|
private NotificationManager mNm;
|
||||||
private MetricsLogger mMetrics;
|
private MetricsLogger mMetrics;
|
||||||
CheckBox mScreenOn;
|
|
||||||
CheckBox mScreenOff;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -48,10 +46,6 @@ public class ZenOnboardingActivity extends Activity {
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected void setupUI() {
|
protected void setupUI() {
|
||||||
setContentView(R.layout.zen_onboarding);
|
setContentView(R.layout.zen_onboarding);
|
||||||
mScreenOn = findViewById(R.id.screen_on_option);
|
|
||||||
mScreenOff = findViewById(R.id.screen_off_option);
|
|
||||||
mScreenOn.setChecked(true);
|
|
||||||
mScreenOff.setChecked(true);
|
|
||||||
|
|
||||||
mMetrics.visible(MetricsEvent.SETTINGS_ZEN_ONBOARDING);
|
mMetrics.visible(MetricsEvent.SETTINGS_ZEN_ONBOARDING);
|
||||||
}
|
}
|
||||||
@@ -66,39 +60,19 @@ public class ZenOnboardingActivity extends Activity {
|
|||||||
mMetrics = ml;
|
mMetrics = ml;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logClick(View view) {
|
public void close(View button) {
|
||||||
CheckBox checkbox = (CheckBox) view;
|
mMetrics.action(MetricsEvent.ACTION_ZEN_ONBOARDING_KEEP_CURRENT_SETTINGS);
|
||||||
switch (checkbox.getId()) {
|
finishAndRemoveTask();
|
||||||
case R.id.screen_on_option:
|
|
||||||
mMetrics.action(MetricsEvent.ACTION_ZEN_ONBOARDING_SCREEN_ON, checkbox.isChecked());
|
|
||||||
break;
|
|
||||||
case R.id.screen_off_option:
|
|
||||||
mMetrics.action(MetricsEvent.ACTION_ZEN_ONBOARDING_SCREEN_OFF,
|
|
||||||
checkbox.isChecked());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void launchSettings(View button) {
|
|
||||||
mMetrics.action(MetricsEvent.ACTION_ZEN_ONBOARDING_SETTINGS);
|
|
||||||
Intent settings = new Intent(Settings.ZEN_MODE_BLOCKED_EFFECTS_SETTINGS);
|
|
||||||
settings.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
|
||||||
startActivity(settings);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(View button) {
|
public void save(View button) {
|
||||||
mMetrics.action(MetricsEvent.ACTION_ZEN_ONBOARDING_OK);
|
mMetrics.action(MetricsEvent.ACTION_ZEN_ONBOARDING_OK);
|
||||||
NotificationManager.Policy policy = mNm.getNotificationPolicy();
|
NotificationManager.Policy policy = mNm.getNotificationPolicy();
|
||||||
int currentEffects = policy.suppressedVisualEffects;
|
|
||||||
|
|
||||||
currentEffects = NotificationManager.Policy.toggleScreenOnEffectsSuppressed(
|
|
||||||
currentEffects, mScreenOn != null && mScreenOn.isChecked());
|
|
||||||
currentEffects = NotificationManager.Policy.toggleScreenOffEffectsSuppressed(
|
|
||||||
currentEffects, mScreenOff != null && mScreenOff.isChecked());
|
|
||||||
|
|
||||||
NotificationManager.Policy newPolicy = new NotificationManager.Policy(
|
NotificationManager.Policy newPolicy = new NotificationManager.Policy(
|
||||||
policy.priorityCategories, policy.priorityCallSenders,
|
policy.priorityCategories, NotificationManager.Policy.PRIORITY_SENDERS_STARRED,
|
||||||
policy.priorityMessageSenders, currentEffects);
|
policy.priorityMessageSenders,
|
||||||
|
NotificationManager.Policy.getAllSuppressedVisualEffects());
|
||||||
mNm.setNotificationPolicy(newPolicy);
|
mNm.setNotificationPolicy(newPolicy);
|
||||||
|
|
||||||
finishAndRemoveTask();
|
finishAndRemoveTask();
|
||||||
|
@@ -30,6 +30,8 @@ import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_STATUS_BA
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@@ -59,9 +61,6 @@ public class ZenOnboardingActivityTest {
|
|||||||
@Mock
|
@Mock
|
||||||
NotificationManager mNm;
|
NotificationManager mNm;
|
||||||
|
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
|
||||||
private Context mContext;
|
|
||||||
|
|
||||||
ZenOnboardingActivity mActivity;
|
ZenOnboardingActivity mActivity;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@@ -83,44 +82,10 @@ public class ZenOnboardingActivityTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void toggleCheckBoxRecordsEvents_screenOn() {
|
public void save() {
|
||||||
mActivity.findViewById(R.id.screen_on_option).performClick();
|
Policy policy = new Policy(PRIORITY_CATEGORY_ALARMS, 0, 0, SUPPRESSED_EFFECT_SCREEN_ON);
|
||||||
|
|
||||||
verify(mMetricsLogger).action(MetricsEvent.ACTION_ZEN_ONBOARDING_SCREEN_ON, false);
|
|
||||||
|
|
||||||
mActivity.findViewById(R.id.screen_on_option).performClick();
|
|
||||||
|
|
||||||
verify(mMetricsLogger).action(MetricsEvent.ACTION_ZEN_ONBOARDING_SCREEN_ON, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void toggleCheckBoxRecordsEvents_screenOff() {
|
|
||||||
mActivity.findViewById(R.id.screen_off_option).performClick();
|
|
||||||
|
|
||||||
verify(mMetricsLogger).action(MetricsEvent.ACTION_ZEN_ONBOARDING_SCREEN_OFF, false);
|
|
||||||
|
|
||||||
mActivity.findViewById(R.id.screen_off_option).performClick();
|
|
||||||
|
|
||||||
verify(mMetricsLogger).action(MetricsEvent.ACTION_ZEN_ONBOARDING_SCREEN_OFF, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void save_screenOn() {
|
|
||||||
Policy policy = new Policy(
|
|
||||||
PRIORITY_CATEGORY_ALARMS, 0, 0,
|
|
||||||
SUPPRESSED_EFFECT_SCREEN_ON
|
|
||||||
| SUPPRESSED_EFFECT_SCREEN_OFF
|
|
||||||
| SUPPRESSED_EFFECT_FULL_SCREEN_INTENT
|
|
||||||
| SUPPRESSED_EFFECT_LIGHTS
|
|
||||||
| SUPPRESSED_EFFECT_PEEK
|
|
||||||
| SUPPRESSED_EFFECT_STATUS_BAR
|
|
||||||
| SUPPRESSED_EFFECT_BADGE
|
|
||||||
| SUPPRESSED_EFFECT_AMBIENT
|
|
||||||
| SUPPRESSED_EFFECT_NOTIFICATION_LIST);
|
|
||||||
when(mNm.getNotificationPolicy()).thenReturn(policy);
|
when(mNm.getNotificationPolicy()).thenReturn(policy);
|
||||||
|
|
||||||
mActivity.findViewById(R.id.screen_off_option).performClick();
|
|
||||||
|
|
||||||
mActivity.save(null);
|
mActivity.save(null);
|
||||||
|
|
||||||
verify(mMetricsLogger).action(MetricsEvent.ACTION_ZEN_ONBOARDING_OK);
|
verify(mMetricsLogger).action(MetricsEvent.ACTION_ZEN_ONBOARDING_OK);
|
||||||
@@ -130,14 +95,14 @@ public class ZenOnboardingActivityTest {
|
|||||||
|
|
||||||
Policy actual = captor.getValue();
|
Policy actual = captor.getValue();
|
||||||
assertThat(actual.priorityCategories).isEqualTo(PRIORITY_CATEGORY_ALARMS);
|
assertThat(actual.priorityCategories).isEqualTo(PRIORITY_CATEGORY_ALARMS);
|
||||||
|
assertThat(actual.priorityCallSenders).isEqualTo(Policy.PRIORITY_SENDERS_STARRED);
|
||||||
|
assertThat(actual.priorityMessageSenders).isEqualTo(Policy.PRIORITY_SENDERS_ANY);
|
||||||
assertThat(actual.suppressedVisualEffects).isEqualTo(
|
assertThat(actual.suppressedVisualEffects).isEqualTo(
|
||||||
SUPPRESSED_EFFECT_SCREEN_ON | SUPPRESSED_EFFECT_NOTIFICATION_LIST
|
Policy.getAllSuppressedVisualEffects());
|
||||||
| SUPPRESSED_EFFECT_BADGE | SUPPRESSED_EFFECT_STATUS_BAR
|
|
||||||
| SUPPRESSED_EFFECT_PEEK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void save_screenOff() {
|
public void close() {
|
||||||
Policy policy = new Policy(
|
Policy policy = new Policy(
|
||||||
PRIORITY_CATEGORY_ALARMS, PRIORITY_SENDERS_ANY, 0,
|
PRIORITY_CATEGORY_ALARMS, PRIORITY_SENDERS_ANY, 0,
|
||||||
SUPPRESSED_EFFECT_SCREEN_ON
|
SUPPRESSED_EFFECT_SCREEN_ON
|
||||||
@@ -151,72 +116,10 @@ public class ZenOnboardingActivityTest {
|
|||||||
| SUPPRESSED_EFFECT_NOTIFICATION_LIST);
|
| SUPPRESSED_EFFECT_NOTIFICATION_LIST);
|
||||||
when(mNm.getNotificationPolicy()).thenReturn(policy);
|
when(mNm.getNotificationPolicy()).thenReturn(policy);
|
||||||
|
|
||||||
mActivity.findViewById(R.id.screen_on_option).performClick();
|
mActivity.close(null);
|
||||||
|
|
||||||
mActivity.save(null);
|
verify(mMetricsLogger).action(MetricsEvent.ACTION_ZEN_ONBOARDING_KEEP_CURRENT_SETTINGS);
|
||||||
|
|
||||||
verify(mMetricsLogger).action(MetricsEvent.ACTION_ZEN_ONBOARDING_OK);
|
verify(mNm, never()).setNotificationPolicy(any());
|
||||||
|
|
||||||
ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class);
|
|
||||||
verify(mNm).setNotificationPolicy(captor.capture());
|
|
||||||
|
|
||||||
Policy actual = captor.getValue();
|
|
||||||
assertThat(actual.priorityCallSenders).isEqualTo(PRIORITY_SENDERS_ANY);
|
|
||||||
assertThat(actual.suppressedVisualEffects).isEqualTo(
|
|
||||||
SUPPRESSED_EFFECT_SCREEN_OFF | SUPPRESSED_EFFECT_FULL_SCREEN_INTENT
|
|
||||||
| SUPPRESSED_EFFECT_LIGHTS | SUPPRESSED_EFFECT_AMBIENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void save_none() {
|
|
||||||
Policy policy = new Policy(0, 0, 0,
|
|
||||||
SUPPRESSED_EFFECT_SCREEN_ON
|
|
||||||
| SUPPRESSED_EFFECT_SCREEN_OFF
|
|
||||||
| SUPPRESSED_EFFECT_FULL_SCREEN_INTENT
|
|
||||||
| SUPPRESSED_EFFECT_LIGHTS
|
|
||||||
| SUPPRESSED_EFFECT_PEEK
|
|
||||||
| SUPPRESSED_EFFECT_STATUS_BAR
|
|
||||||
| SUPPRESSED_EFFECT_BADGE
|
|
||||||
| SUPPRESSED_EFFECT_AMBIENT
|
|
||||||
| SUPPRESSED_EFFECT_NOTIFICATION_LIST);
|
|
||||||
when(mNm.getNotificationPolicy()).thenReturn(policy);
|
|
||||||
|
|
||||||
mActivity.findViewById(R.id.screen_on_option).performClick();
|
|
||||||
mActivity.findViewById(R.id.screen_off_option).performClick();
|
|
||||||
|
|
||||||
mActivity.save(null);
|
|
||||||
|
|
||||||
verify(mMetricsLogger).action(MetricsEvent.ACTION_ZEN_ONBOARDING_OK);
|
|
||||||
|
|
||||||
ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class);
|
|
||||||
verify(mNm).setNotificationPolicy(captor.capture());
|
|
||||||
|
|
||||||
Policy actual = captor.getValue();
|
|
||||||
assertThat(actual.suppressedVisualEffects).isEqualTo(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void save_all() {
|
|
||||||
Policy policy = new Policy(0, 0, 0, 0);
|
|
||||||
when(mNm.getNotificationPolicy()).thenReturn(policy);
|
|
||||||
|
|
||||||
mActivity.save(null);
|
|
||||||
|
|
||||||
verify(mMetricsLogger).action(MetricsEvent.ACTION_ZEN_ONBOARDING_OK);
|
|
||||||
|
|
||||||
ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class);
|
|
||||||
verify(mNm).setNotificationPolicy(captor.capture());
|
|
||||||
|
|
||||||
Policy actual = captor.getValue();
|
|
||||||
assertThat(actual.suppressedVisualEffects).isEqualTo(
|
|
||||||
SUPPRESSED_EFFECT_SCREEN_ON
|
|
||||||
| SUPPRESSED_EFFECT_SCREEN_OFF
|
|
||||||
| SUPPRESSED_EFFECT_FULL_SCREEN_INTENT
|
|
||||||
| SUPPRESSED_EFFECT_LIGHTS
|
|
||||||
| SUPPRESSED_EFFECT_PEEK
|
|
||||||
| SUPPRESSED_EFFECT_STATUS_BAR
|
|
||||||
| SUPPRESSED_EFFECT_BADGE
|
|
||||||
| SUPPRESSED_EFFECT_AMBIENT
|
|
||||||
| SUPPRESSED_EFFECT_NOTIFICATION_LIST);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user