From e000a21064102f1e2e2433e34339a04eaf1d65c8 Mon Sep 17 00:00:00 2001 From: Lais Andrade Date: Tue, 22 Feb 2022 18:42:41 +0000 Subject: [PATCH 1/5] Enable touch feedback settings when the phone is in silent mode Allow users to change this settings when the phone is in silent mode, if they prefer to make all interactions as silent as possible in that context. Fix: 165478128 Test: [Alarm|HapticFeedback|Media]Vibration[Intensity|Toggle]PreferenceControllerTest Change-Id: I68f90559b2bf8088f22397412c149e2a4b91cf13 --- ...FeedbackIntensityPreferenceController.java | 6 ----- ...tionIntensityPreferenceControllerTest.java | 27 ++++++++++++++++++- ...brationTogglePreferenceControllerTest.java | 27 ++++++++++++++++++- ...backIntensityPreferenceControllerTest.java | 12 +++------ ...eedbackTogglePreferenceControllerTest.java | 13 +++------ ...tionIntensityPreferenceControllerTest.java | 27 ++++++++++++++++++- ...brationTogglePreferenceControllerTest.java | 27 ++++++++++++++++++- 7 files changed, 110 insertions(+), 29 deletions(-) diff --git a/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceController.java b/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceController.java index 05dc7840155..98fd5f2315c 100644 --- a/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceController.java +++ b/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceController.java @@ -37,12 +37,6 @@ public class HapticFeedbackIntensityPreferenceController VibrationAttributes.USAGE_TOUCH); } - @Override - public boolean isRestrictedByRingerModeSilent() { - // Touch feedback is disabled when the phone is in silent mode. - return true; - } - @Override public int readIntensity() { final int hapticFeedbackEnabled = Settings.System.getInt(mContentResolver, diff --git a/tests/robotests/src/com/android/settings/accessibility/AlarmVibrationIntensityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AlarmVibrationIntensityPreferenceControllerTest.java index 22e2b8a3e15..44d2e867556 100644 --- a/tests/robotests/src/com/android/settings/accessibility/AlarmVibrationIntensityPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/AlarmVibrationIntensityPreferenceControllerTest.java @@ -18,9 +18,11 @@ package com.android.settings.accessibility; import static com.google.common.truth.Truth.assertThat; +import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import android.content.Context; +import android.media.AudioManager; import android.os.VibrationAttributes; import android.os.Vibrator; import android.provider.Settings; @@ -45,6 +47,7 @@ public class AlarmVibrationIntensityPreferenceControllerTest { private static final String PREFERENCE_KEY = "preference_key"; @Mock private PreferenceScreen mScreen; + @Mock private AudioManager mAudioManager; private Lifecycle mLifecycle; private Context mContext; @@ -56,7 +59,9 @@ public class AlarmVibrationIntensityPreferenceControllerTest { public void setUp() { MockitoAnnotations.initMocks(this); mLifecycle = new Lifecycle(() -> mLifecycle); - mContext = ApplicationProvider.getApplicationContext(); + mContext = spy(ApplicationProvider.getApplicationContext()); + when(mContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager); + when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL); mVibrator = mContext.getSystemService(Vibrator.class); mController = new AlarmVibrationIntensityPreferenceController(mContext, PREFERENCE_KEY, Vibrator.VIBRATION_INTENSITY_HIGH); @@ -87,6 +92,26 @@ public class AlarmVibrationIntensityPreferenceControllerTest { mVibrator.getDefaultVibrationIntensity(VibrationAttributes.USAGE_ALARM)); } + @Test + public void updateState_ringerModeUpdates_shouldNotAffectSettings() { + updateSetting(Settings.System.ALARM_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW); + + when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL); + mController.updateState(mPreference); + assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW); + assertThat(mPreference.isEnabled()).isTrue(); + + when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_SILENT); + mController.updateState(mPreference); + assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW); + assertThat(mPreference.isEnabled()).isTrue(); + + when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE); + mController.updateState(mPreference); + assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW); + assertThat(mPreference.isEnabled()).isTrue(); + } + @Test public void updateState_shouldDisplayIntensityInSliderPosition() { updateSetting(Settings.System.ALARM_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH); diff --git a/tests/robotests/src/com/android/settings/accessibility/AlarmVibrationTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AlarmVibrationTogglePreferenceControllerTest.java index 82d65f76b32..48599ac81f4 100644 --- a/tests/robotests/src/com/android/settings/accessibility/AlarmVibrationTogglePreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/AlarmVibrationTogglePreferenceControllerTest.java @@ -18,9 +18,11 @@ package com.android.settings.accessibility; import static com.google.common.truth.Truth.assertThat; +import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import android.content.Context; +import android.media.AudioManager; import android.os.VibrationAttributes; import android.os.Vibrator; import android.provider.Settings; @@ -45,6 +47,7 @@ public class AlarmVibrationTogglePreferenceControllerTest { private static final String PREFERENCE_KEY = "preference_key"; @Mock private PreferenceScreen mScreen; + @Mock AudioManager mAudioManager; private Lifecycle mLifecycle; private Context mContext; @@ -56,7 +59,9 @@ public class AlarmVibrationTogglePreferenceControllerTest { public void setUp() { MockitoAnnotations.initMocks(this); mLifecycle = new Lifecycle(() -> mLifecycle); - mContext = ApplicationProvider.getApplicationContext(); + mContext = spy(ApplicationProvider.getApplicationContext()); + when(mContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager); + when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL); mVibrator = mContext.getSystemService(Vibrator.class); mController = new AlarmVibrationTogglePreferenceController(mContext, PREFERENCE_KEY); mLifecycle.addObserver(mController); @@ -83,6 +88,26 @@ public class AlarmVibrationTogglePreferenceControllerTest { assertThat(mPreference.isChecked()).isTrue(); } + @Test + public void updateState_ringerModeUpdates_shouldNotAffectSettings() { + updateSetting(Settings.System.ALARM_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW); + + when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL); + mController.updateState(mPreference); + assertThat(mPreference.isChecked()).isTrue(); + assertThat(mPreference.isEnabled()).isTrue(); + + when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_SILENT); + mController.updateState(mPreference); + assertThat(mPreference.isChecked()).isTrue(); + assertThat(mPreference.isEnabled()).isTrue(); + + when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE); + mController.updateState(mPreference); + assertThat(mPreference.isChecked()).isTrue(); + assertThat(mPreference.isEnabled()).isTrue(); + } + @Test public void updateState_shouldDisplayOnOffState() { updateSetting(Settings.System.ALARM_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH); diff --git a/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceControllerTest.java index 9d87c93c1df..344a25f50e5 100644 --- a/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceControllerTest.java @@ -94,28 +94,22 @@ public class HapticFeedbackIntensityPreferenceControllerTest { } @Test - public void updateState_ringerModeUpdates_shouldPreserveSettingAndDisplaySummary() { + public void updateState_ringerModeUpdates_shouldNotAffectSettings() { updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW); when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL); mController.updateState(mPreference); assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW); - assertThat(mPreference.getSummary()).isNull(); assertThat(mPreference.isEnabled()).isTrue(); when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_SILENT); mController.updateState(mPreference); - assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF); - // TODO(b/136805769): summary is broken in SeekBarPreference, enable this once fixed -// assertThat(mPreference.getSummary()).isNotNull(); -// assertThat(mPreference.getSummary().toString()).isEqualTo(mContext.getString( -// R.string.accessibility_vibration_setting_disabled_for_silent_mode_summary)); - assertThat(mPreference.isEnabled()).isFalse(); + assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW); + assertThat(mPreference.isEnabled()).isTrue(); when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE); mController.updateState(mPreference); assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW); - assertThat(mPreference.getSummary()).isNull(); assertThat(mPreference.isEnabled()).isTrue(); } diff --git a/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackTogglePreferenceControllerTest.java index 3e8aeac6b59..77aede2d38b 100644 --- a/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackTogglePreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackTogglePreferenceControllerTest.java @@ -31,7 +31,6 @@ import androidx.preference.PreferenceScreen; import androidx.preference.SwitchPreference; import androidx.test.core.app.ApplicationProvider; -import com.android.settings.R; import com.android.settings.core.BasePreferenceController; import com.android.settingslib.core.lifecycle.Lifecycle; @@ -90,29 +89,23 @@ public class HapticFeedbackTogglePreferenceControllerTest { assertThat(mPreference.isChecked()).isTrue(); } - @Test - public void updateState_ringerModeUpdates_shouldPreserveSettingAndDisplaySummary() { + public void updateState_ringerModeUpdates_shouldNotAffectSettings() { updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW); when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL); mController.updateState(mPreference); assertThat(mPreference.isChecked()).isTrue(); - assertThat(mPreference.getSummary()).isNull(); assertThat(mPreference.isEnabled()).isTrue(); when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_SILENT); mController.updateState(mPreference); - assertThat(mPreference.isChecked()).isFalse(); - assertThat(mPreference.getSummary()).isNotNull(); - assertThat(mPreference.getSummary().toString()).isEqualTo(mContext.getString( - R.string.accessibility_vibration_setting_disabled_for_silent_mode_summary)); - assertThat(mPreference.isEnabled()).isFalse(); + assertThat(mPreference.isChecked()).isTrue(); + assertThat(mPreference.isEnabled()).isTrue(); when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE); mController.updateState(mPreference); assertThat(mPreference.isChecked()).isTrue(); - assertThat(mPreference.getSummary()).isNull(); assertThat(mPreference.isEnabled()).isTrue(); } diff --git a/tests/robotests/src/com/android/settings/accessibility/MediaVibrationIntensityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/MediaVibrationIntensityPreferenceControllerTest.java index 0a9f242810f..3a4b43a8914 100644 --- a/tests/robotests/src/com/android/settings/accessibility/MediaVibrationIntensityPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/MediaVibrationIntensityPreferenceControllerTest.java @@ -18,9 +18,11 @@ package com.android.settings.accessibility; import static com.google.common.truth.Truth.assertThat; +import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import android.content.Context; +import android.media.AudioManager; import android.os.VibrationAttributes; import android.os.Vibrator; import android.provider.Settings; @@ -46,6 +48,7 @@ public class MediaVibrationIntensityPreferenceControllerTest { private static final String PREFERENCE_KEY = "preference_key"; @Mock private PreferenceScreen mScreen; + @Mock private AudioManager mAudioManager; private Lifecycle mLifecycle; private Context mContext; @@ -57,7 +60,9 @@ public class MediaVibrationIntensityPreferenceControllerTest { public void setUp() { MockitoAnnotations.initMocks(this); mLifecycle = new Lifecycle(() -> mLifecycle); - mContext = ApplicationProvider.getApplicationContext(); + mContext = spy(ApplicationProvider.getApplicationContext()); + when(mContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager); + when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL); mVibrator = mContext.getSystemService(Vibrator.class); mController = new MediaVibrationIntensityPreferenceController(mContext, PREFERENCE_KEY, Vibrator.VIBRATION_INTENSITY_HIGH); @@ -88,6 +93,26 @@ public class MediaVibrationIntensityPreferenceControllerTest { mVibrator.getDefaultVibrationIntensity(VibrationAttributes.USAGE_MEDIA)); } + @Test + public void updateState_ringerModeUpdates_shouldNotAffectSettings() { + updateSetting(Settings.System.MEDIA_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW); + + when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL); + mController.updateState(mPreference); + assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW); + assertThat(mPreference.isEnabled()).isTrue(); + + when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_SILENT); + mController.updateState(mPreference); + assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW); + assertThat(mPreference.isEnabled()).isTrue(); + + when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE); + mController.updateState(mPreference); + assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW); + assertThat(mPreference.isEnabled()).isTrue(); + } + @Test public void updateState_shouldDisplayIntensityInSliderPosition() { updateSetting(Settings.System.MEDIA_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH); diff --git a/tests/robotests/src/com/android/settings/accessibility/MediaVibrationTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/MediaVibrationTogglePreferenceControllerTest.java index 7923cca948a..49a7b7b0c03 100644 --- a/tests/robotests/src/com/android/settings/accessibility/MediaVibrationTogglePreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/MediaVibrationTogglePreferenceControllerTest.java @@ -18,9 +18,11 @@ package com.android.settings.accessibility; import static com.google.common.truth.Truth.assertThat; +import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import android.content.Context; +import android.media.AudioManager; import android.os.VibrationAttributes; import android.os.Vibrator; import android.provider.Settings; @@ -46,6 +48,7 @@ public class MediaVibrationTogglePreferenceControllerTest { private static final String PREFERENCE_KEY = "preference_key"; @Mock private PreferenceScreen mScreen; + @Mock AudioManager mAudioManager; private Lifecycle mLifecycle; private Context mContext; @@ -57,7 +60,9 @@ public class MediaVibrationTogglePreferenceControllerTest { public void setUp() { MockitoAnnotations.initMocks(this); mLifecycle = new Lifecycle(() -> mLifecycle); - mContext = ApplicationProvider.getApplicationContext(); + mContext = spy(ApplicationProvider.getApplicationContext()); + when(mContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager); + when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL); mVibrator = mContext.getSystemService(Vibrator.class); mController = new MediaVibrationTogglePreferenceController(mContext, PREFERENCE_KEY); mLifecycle.addObserver(mController); @@ -84,6 +89,26 @@ public class MediaVibrationTogglePreferenceControllerTest { assertThat(mPreference.isChecked()).isTrue(); } + @Test + public void updateState_ringerModeUpdates_shouldNotAffectSettings() { + updateSetting(Settings.System.MEDIA_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW); + + when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL); + mController.updateState(mPreference); + assertThat(mPreference.isChecked()).isTrue(); + assertThat(mPreference.isEnabled()).isTrue(); + + when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_SILENT); + mController.updateState(mPreference); + assertThat(mPreference.isChecked()).isTrue(); + assertThat(mPreference.isEnabled()).isTrue(); + + when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE); + mController.updateState(mPreference); + assertThat(mPreference.isChecked()).isTrue(); + assertThat(mPreference.isEnabled()).isTrue(); + } + @Test public void updateState_shouldDisplayOnOffState() { updateSetting(Settings.System.MEDIA_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH); From 4871b2cf6ad99bdd05ef687d01a5fdaae39991be Mon Sep 17 00:00:00 2001 From: Evan Laird Date: Mon, 10 Jan 2022 19:44:18 +0000 Subject: [PATCH 2/5] Add setting for showing the vibrate icon in status bar Test: manual Bug: 220144337 Change-Id: I2d389d71dd9402353b058039464495a1d33ef0e9 --- res/values/strings.xml | 3 ++ res/xml/other_sound_settings.xml | 5 +++ res/xml/sound_settings.xml | 6 +++ .../settings/notification/SoundSettings.java | 4 ++ .../VibrateIconPreferenceController.java | 42 +++++++++++++++++++ 5 files changed, 60 insertions(+) create mode 100644 src/com/android/settings/notification/VibrateIconPreferenceController.java diff --git a/res/values/strings.xml b/res/values/strings.xml index 9d868cbe4ea..815fff240e7 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -8470,6 +8470,9 @@ Touch sounds + + Always show icon when in vibrate mode + Dock speaker plays diff --git a/res/xml/other_sound_settings.xml b/res/xml/other_sound_settings.xml index d8396a4b644..056551f4e29 100644 --- a/res/xml/other_sound_settings.xml +++ b/res/xml/other_sound_settings.xml @@ -44,6 +44,11 @@ android:key="touch_sounds" android:title="@string/touch_sounds_title" /> + + + + + + Date: Fri, 25 Feb 2022 13:37:33 -0500 Subject: [PATCH 3/5] Change dream icon color to be the same as the text color. Bug: 220120729 Test: locally on device Change-Id: I60de6ba18c0ee46fa1e578e8a7b4c68206024913 --- src/com/android/settings/dream/DreamAdapter.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/com/android/settings/dream/DreamAdapter.java b/src/com/android/settings/dream/DreamAdapter.java index 154181dca4a..44f77e3aabd 100644 --- a/src/com/android/settings/dream/DreamAdapter.java +++ b/src/com/android/settings/dream/DreamAdapter.java @@ -32,7 +32,6 @@ import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.android.settings.R; -import com.android.settingslib.Utils; import java.util.List; @@ -41,7 +40,8 @@ import java.util.List; */ public class DreamAdapter extends RecyclerView.Adapter { private final List mItemList; - private final @LayoutRes int mLayoutRes; + @LayoutRes + private final int mLayoutRes; private int mLastSelectedPos = -1; /** @@ -90,8 +90,8 @@ public class DreamAdapter extends RecyclerView.Adapter ? mContext.getDrawable(R.drawable.ic_dream_check_circle) : item.getIcon(); if (icon instanceof VectorDrawable) { - icon.setTint(Utils.getColorAttrDefaultColor(mContext, - com.android.internal.R.attr.colorAccentPrimaryVariant)); + icon.setTintList( + mContext.getColorStateList(R.color.dream_card_text_color_state_list)); } final int iconSize = mContext.getResources().getDimensionPixelSize( R.dimen.dream_item_icon_size); From 017545c6d1faddcf7f43da3a6e085e5fb46bfd8c Mon Sep 17 00:00:00 2001 From: Joe Bolinger Date: Fri, 25 Feb 2022 21:42:36 +0000 Subject: [PATCH 4/5] Persist state of no thanks button. Fix: 207724636 Test: manual (scroll to bottom and rotate device) Change-Id: I5ef486dc49abd22387b5f6edf67eedaacc9ded4a --- .../settings/biometrics/BiometricEnrollIntroduction.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java index 5085172022f..e3607601840 100644 --- a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java +++ b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java @@ -56,6 +56,7 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase private static final String TAG = "BiometricEnrollIntroduction"; private static final String KEY_CONFIRMING_CREDENTIALS = "confirming_credentials"; + private static final String KEY_SCROLLED_TO_BOTTOM = "scrolled"; private UserManager mUserManager; private boolean mHasPassword; @@ -64,6 +65,7 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase protected boolean mConfirmingCredentials; protected boolean mNextClicked; private boolean mParentalConsentRequired; + private boolean mHasScrolledToBottom = false; @Nullable private PorterDuffColorFilter mIconColorFilter; @@ -152,6 +154,7 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase if (savedInstanceState != null) { mConfirmingCredentials = savedInstanceState.getBoolean(KEY_CONFIRMING_CREDENTIALS); + mHasScrolledToBottom = savedInstanceState.getBoolean(KEY_SCROLLED_TO_BOTTOM); } Intent intent = getIntent(); @@ -196,14 +199,14 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase mFooterBarMixin = layout.getMixin(FooterBarMixin.class); mFooterBarMixin.setPrimaryButton(getPrimaryFooterButton()); mFooterBarMixin.setSecondaryButton(getSecondaryFooterButton(), true /* usePrimaryStyle */); - mFooterBarMixin.getSecondaryButton().setVisibility(View.INVISIBLE); + mFooterBarMixin.getSecondaryButton().setVisibility( + mHasScrolledToBottom ? View.VISIBLE : View.INVISIBLE); final RequireScrollMixin requireScrollMixin = layout.getMixin(RequireScrollMixin.class); requireScrollMixin.requireScrollWithButton(this, getPrimaryFooterButton(), getMoreButtonTextRes(), this::onNextButtonClick); requireScrollMixin.setOnRequireScrollStateChangedListener( scrollNeeded -> { - boolean enrollmentCompleted = checkMaxEnrolled() != 0; if (!enrollmentCompleted) { // Update text of primary button from "More" to "Agree". @@ -216,6 +219,7 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase // Show secondary button once scroll is completed. if (!scrollNeeded) { getSecondaryFooterButton().setVisibility(View.VISIBLE); + mHasScrolledToBottom = true; } }); } @@ -241,6 +245,7 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putBoolean(KEY_CONFIRMING_CREDENTIALS, mConfirmingCredentials); + outState.putBoolean(KEY_SCROLLED_TO_BOTTOM, mHasScrolledToBottom); } @Override From f26a246f5afad84207a28bd8cbb9fc5652ef5b61 Mon Sep 17 00:00:00 2001 From: Yuri Lin Date: Thu, 24 Feb 2022 20:25:59 +0000 Subject: [PATCH 5/5] Revert "Rename Do Not Disturb -> Priority Mode" Revert submission 16632971-yl-prioritymode Reason for revert: We're not launching this change with T, so this will revert all the relevant string changes. Reverted Changes: I5eff72db8:Rename Do Not Disturb -> Priority Mode Ie7a9e35e6:Rename Do Not Disturb -> Priority Mode I7bb74d2fd:Rename Do Not Disturb -> Priority Mode Id17942024:Rename Do Not Disturb -> Priority Mode Ib8efd7289:Rename Do Not Disturb -> Priority Mode Ia1b77f9ee:Rename Do Not Disturb -> Priority Mode Bug: 190180868 Test: TH Change-Id: I7516c97809c7968f999d7caa8885f0cb5cdc844f Merged-In: I7516c97809c7968f999d7caa8885f0cb5cdc844f --- res/values/strings.xml | 300 +++++++++--------- ...BypassingAppsPreferenceControllerTest.java | 4 +- 2 files changed, 152 insertions(+), 152 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 4d793486bbe..3363f929c25 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -8308,7 +8308,7 @@ upgrade, android - dnd, schedule, notifications, block, silence, vibrate, sleep, work, focus, sound, mute, day, weekday, weekend, weeknight, event, do not disturb + dnd, schedule, notifications, block, silence, vibrate, sleep, work, focus, sound, mute, day, weekday, weekend, weeknight, event screen, lock time, timeout, lockscreen @@ -8390,7 +8390,7 @@ Ring & notification volume at %1$s - Volume, vibration, Priority mode + Volume, vibration, Do Not Disturb Ringer set to vibrate @@ -8500,8 +8500,8 @@ Automatically caption media - - + + {count, plural, =0 {None} =1 {1 schedule set} @@ -8509,8 +8509,8 @@ } - - Priority mode + + Do Not Disturb Only get notified by important people and apps @@ -8518,11 +8518,11 @@ Limit interruptions - - Turn on Priority mode + + Turn on Do Not Disturb - - Alarms and media sounds + + Alarms and media sounds can interrupt Schedules @@ -8548,11 +8548,11 @@ Silence phone at certain times - - Set Priority mode rules + + Set Do Not Disturb rules - - Turn on Priority mode automatically + + Schedule Use schedule @@ -8560,8 +8560,8 @@ %1$s: %2$s - - Allow sounds when Priority mode is on + + Allow interruptions that make sound Block visual disturbances @@ -8569,10 +8569,10 @@ Allow visual signals - - Display options for low-priority notifications - - When Priority mode is on + + Display options for hidden notifications + + When Do Not Disturb is on No sound from notifications @@ -8583,20 +8583,20 @@ No visuals or sound from notifications You won\u2019t see or hear notifications - - Your phone won\u2019t show, vibrate or make sound for new or existing notifications. Keep in mind, critical notifications for phone activity and status will still appear.\n\nWhen you turn off Priority mode, find missed notifications by swiping down from the top of your screen. + + Your phone won\u2019t show, vibrate or make sound for new or existing notifications. Keep in mind, critical notifications for phone activity and status will still appear.\n\nWhen you turn off Do Not Disturb, find missed notifications by swiping down from the top of your screen. Custom Enable custom setting Remove custom setting - - No sound from notifications - - Partially hidden - - No visuals or sound from notifications + + No sound from notifications + + Partially hidden + + No visuals or sound from notifications Custom restrictions @@ -8647,26 +8647,26 @@ Turn on - - Turn on + + Turn on now - - Turn off + + Turn off now - - Priority mode is on until %s + + Do Not Disturb is on until %s - - Priority mode will stay on until you turn it off + + Do Not Disturb will stay on until you turn it off - - Priority mode was automatically turned on by a schedule (%s) + + Do Not Disturb was automatically turned on by a schedule (%s) - - Priority mode was automatically turned on by an app (%s) + + Do Not Disturb was automatically turned on by an app (%s) - - Priority mode is on for %s with custom settings. + + Do Not Disturb is on for %s with custom settings. View custom settings @@ -8677,11 +8677,11 @@ %1$s. %2$s - - On / %1$s + + On / %1$s - - On + + On Ask every time @@ -8714,25 +8714,25 @@ } - - Notifications that can reach you - - People - - Apps - - Alarms & other notifications - - Schedules - - Duration for Quick Settings - + What can interrupt Do Not Disturb + + People + + Apps + + Alarms & other interruptions + + Schedules + + Duration for Quick Settings + - Advanced + General - - When Priority mode is on, sound and vibration will be muted, except for the items you allow above. + + When Do Not Disturb is on, sound and vibration will be muted, except for the items you allow above. Custom settings @@ -8747,8 +8747,8 @@ Messages, events & reminders - - When Priority mode is on, messages, reminders, and events will be muted, except for the items you allow above. You can adjust messages settings to allow your friends, family, or other contacts to reach you. + + When Do Not Disturb is on, messages, reminders, and events will be muted, except for the items you allow above. You can adjust messages settings to allow your friends, family, or other contacts to reach you. Done @@ -8764,8 +8764,8 @@ (Current setting) - - Change Priority mode notification settings? + + Change Do Not Disturb notification settings? Your phone can do more to help you focus.\n\nUpdate settings to:\n\n- Hide notifications completely\n\n- Allow calls from starred contacts and repeat callers @@ -9191,7 +9191,7 @@ Bubble priority conversations - Priority conversations show at the top of the pull-down shade. You can also set them to bubble when Priority mode is on. + Priority conversations show at the top of the pull-down shade. You can also set them to bubble and interrupt Do Not Disturb. Priority and modified conversations will appear here @@ -9335,12 +9335,12 @@ %1$s? - + Enhanced notifications replaced Android Adaptive Notifications in Android 12. This feature shows suggested actions and replies, and organizes your notifications. \n\nEnhanced notifications can access notification content, including personal information like contact names and messages. This feature can also dismiss or respond to notifications, - such as answering phone calls, and control Priority mode. + such as answering phone calls, and control Do Not Disturb. - + %1$s will be able to read all notifications, including personal information such as contact names, photos, and the text of messages you receive. This app will also be able to snooze or dismiss notifications or take action on buttons in notifications, including answering phone calls. - \n\nThis will also give the app the ability to turn Priority mode on or off and change related settings. + \n\nThis will also give the app the ability to turn Do Not Disturb on or off and change related settings. %1$s will be able to: Read your notifications @@ -9361,9 +9361,9 @@ Reply to messages It can reply to messages and take action on buttons in notifications, including snoozing or dismissing notifications and answering calls. Change settings - It can turn Priority mode on or off and change related settings. - - If you turn off notification access for %1$s, Priority mode access may also be turned off. + It can turn Do Not Disturb on or off and change related settings. + + If you turn off notification access for %1$s, Do Not Disturb access may also be turned off. Turn off Cancel @@ -9526,14 +9526,14 @@ The placeholder would be the app name (e.g. Calendar). [CHAR LIMIT=NONE]--> Tap to get the app - - Priority mode access + + Do Not Disturb access - - Allow Priority mode + + Allow Do Not Disturb - - No installed apps have requested Priority mode access + + No installed apps have requested Do Not Disturb access Loading apps\u2026 @@ -9606,11 +9606,11 @@ Show notification dot - - Override Priority mode + + Override Do Not Disturb - - Let these notifications continue to notify you when Priority mode is on + + Let these notifications continue to interrupt when Do Not Disturb is on Lock screen @@ -9661,7 +9661,7 @@ Schedule name already in use - Add a schedule + Add more Add event schedule @@ -9684,26 +9684,26 @@ Unknown - - These settings can\'t be changed right now. An app (%1$s) has automatically turned on Priority mode with custom behavior." + + These settings can\'t be changed right now. An app (%1$s) has automatically turned on Do Not Disturb with custom behavior." - - These settings can\'t be changed right now. An app has automatically turned on Priority mode with custom behavior." + + These settings can\'t be changed right now. An app has automatically turned on Do Not Disturb with custom behavior." - - These settings can\'t be changed right now. Priority mode was manually turned on with custom behavior." + + These settings can\'t be changed right now. Do Not Disturb was manually turned on with custom behavior." Time - Automatic rule set to turn on Priority mode during specified times + Automatic rule set to turn on Do Not Disturb during specified times Event - Automatic rule set to turn on Priority mode during specified events + Automatic rule set to turn on Do Not Disturb during specified events During events for @@ -9751,13 +9751,13 @@ Every day - Use alarm as the end time + Alarm can override end time - Schedule turns off when next alarm rings + Schedule turns off when an alarm rings - Customized Priority mode behavior + Do Not Disturb behavior Use default settings @@ -9796,7 +9796,7 @@ - Who can reach you + Who can interrupt Even if messaging or calling apps can\u0027t notify you, people you choose here can still reach you through those apps @@ -9808,7 +9808,7 @@ calls - Who can call you + Calls that can interrupt To make sure allowed calls make sound, check that device is set to ring @@ -9837,7 +9837,7 @@ Messages - Who can message you + Messages that can interrupt To make sure allowed messages make sound, check that device is set to ring @@ -9864,12 +9864,12 @@ Some people or conversations - - From starred contacts and repeat callers - - From contacts and repeat callers - - From repeat callers only + + From starred contacts and repeat callers + + From contacts and repeat callers + + From repeat callers only None @@ -9923,14 +9923,14 @@ Allow apps to override - - Apps that can notify you - - Choose more apps - - None - - No apps can notify you + + Apps that can interrupt + + Select more apps + + No apps selected + + No apps can interrupt Add apps Some notifications - - If calling or messaging apps can\u0027t notify you, people you choose in Priority mode settings can still reach you through those apps - - + + Selected people can still reach you, even if you don\u2019t allow apps to interrupt + + {count, plural, offset:2 - =0 {None} - =1 {{app_1}} - =2 {{app_1} and {app_2}} - =3 {{app_1}, {app_2}, and {app_3}} - other {{app_1}, {app_2}, and # more} + =0 {No apps can interrupt} + =1 {{app_1} can interrupt} + =2 {{app_1} and {app_2} can interrupt} + =3 {{app_1}, {app_2}, and {app_3} can interrupt} + other {{app_1}, {app_2}, and # more can interrupt} } @@ -9957,30 +9957,30 @@ All notifications Some notifications - - Notifications that can reach you + + Notifications that can interrupt Allow all notifications - + {count, plural, offset:2 - =0 {None} - =1 {{sound_category_1}} - =2 {{sound_category_1} and {sound_category_2}} - =3 {{sound_category_1}, {sound_category_2}, and {sound_category_3}} - other {{sound_category_1}, {sound_category_2}, and # more} + =0 {Nothing can interrupt} + =1 {{sound_category_1} can interrupt} + =2 {{sound_category_1} and {sound_category_2} can interrupt} + =3 {{sound_category_1}, {sound_category_2}, and {sound_category_3} can interrupt} + other {{sound_category_1}, {sound_category_2}, and # more can interrupt} } - - None + + Nothing can interrupt - None + No one can interrupt - Some people can reach you + Some people can interrupt - Anyone can reach you + All people can interrupt Repeat callers @@ -10039,13 +10039,13 @@ When the screen is on - Let notifications silenced by Priority mode pop on screen and show a status bar icon + Let notifications silenced by Do Not Disturb pop on screen and show a status bar icon When the screen is off - Let notifications silenced by Priority mode turn on the screen and blink the light + Let notifications silenced by Do Not Disturb turn on the screen and blink the light - Let notifications silenced by Priority mode turn on the screen + Let notifications silenced by Do Not Disturb turn on the screen @@ -10298,8 +10298,8 @@ Sensitive content not on lock screen Not on lock screen - - Priority mode overridden + + Do Not Disturb overridden \u00A0/\u00A0 @@ -10376,7 +10376,7 @@ Categories: Turned off - Categories: Overrides Priority mode + Categories: Overrides Do Not Disturb Advanced @@ -10820,18 +10820,18 @@ No data used - Allow access to Priority mode for %1$s? + Allow access to Do Not Disturb for %1$s? - The app will be able to turn on/off Priority mode and make changes to related settings. + The app will be able to turn on/off Do Not Disturb and make changes to related settings. Must stay turned on because notification access is on - Revoke access to Priority mode for %1$s? + Revoke access to Do Not Disturb for %1$s? - All Priority mode rules created by this app will be removed. + All Do Not Disturb rules created by this app will be removed. Don\u2019t optimize @@ -11104,8 +11104,8 @@ Networks unavailable - - Priority mode is on + + Do Not Disturb is on Phone muted @@ -12339,8 +12339,8 @@ - - Update Priority mode + + Update Do Not Disturb Pause notifications to stay focused diff --git a/tests/robotests/src/com/android/settings/notification/zen/ZenModeBypassingAppsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/zen/ZenModeBypassingAppsPreferenceControllerTest.java index 8f31b0a3599..460ae2dee32 100644 --- a/tests/robotests/src/com/android/settings/notification/zen/ZenModeBypassingAppsPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/zen/ZenModeBypassingAppsPreferenceControllerTest.java @@ -185,7 +185,7 @@ public class ZenModeBypassingAppsPreferenceControllerTest { // only channel bypassing DND is a conversation (which will be showed on the // conversations page instead of the apps page) assertThat(mController.mPreference.isEnabled()).isTrue(); - assertThat(mController.getSummary().contains("None")).isTrue(); + assertThat(mController.getSummary().contains("No apps")).isTrue(); } @Test @@ -246,7 +246,7 @@ public class ZenModeBypassingAppsPreferenceControllerTest { // THEN the preference is enabled and summary is updated assertThat(mController.mPreference.isEnabled()).isTrue(); - assertThat(mController.getSummary().contains("None")).isTrue(); + assertThat(mController.getSummary().contains("No apps")).isTrue(); } @Test