Loading res/values/strings.xml +1 −1 Original line number Diff line number Diff line Loading @@ -13460,7 +13460,7 @@ <!-- Label of the color option show in the summary of screen flash preference. [CHAR LIMIT=60] --> <string name="screen_flash_color_violet">Violet</string> <!-- Button to save the selection in screen flash color selection dialog. [CHAR LIMIT=20] --> <string name="color_selector_dialog_done">Done</string> <string name="color_selector_dialog_save">Save</string> <!-- Button to close the dialog without saving in screen flash color selection dialog. [CHAR LIMIT=20] --> <string name="color_selector_dialog_cancel">Cancel</string> src/com/android/settings/accessibility/FlashNotificationsPreviewPreferenceController.java +1 −1 Original line number Diff line number Diff line Loading @@ -110,7 +110,7 @@ public class FlashNotificationsPreviewPreferenceController extends if (preference == null) { return; } preference.setEnabled(FlashNotificationsUtil.getFlashNotificationsState(mContext) preference.setVisible(FlashNotificationsUtil.getFlashNotificationsState(mContext) != FlashNotificationsUtil.State.OFF); } } src/com/android/settings/accessibility/ScreenFlashNotificationColorDialogFragment.java +2 −3 Original line number Diff line number Diff line Loading @@ -65,8 +65,7 @@ public class ScreenFlashNotificationColorDialogFragment extends DialogFragment i final ScreenFlashNotificationColorDialogFragment result = new ScreenFlashNotificationColorDialogFragment(); result.mCurrentColor = initialColor; result.mConsumer = colorConsumer != null ? colorConsumer : i -> { }; result.mConsumer = colorConsumer != null ? colorConsumer : i -> {}; return result; } Loading @@ -89,7 +88,7 @@ public class ScreenFlashNotificationColorDialogFragment extends DialogFragment i .setNeutralButton(R.string.flash_notifications_preview, null) .setNegativeButton(R.string.color_selector_dialog_cancel, (dialog, which) -> { }) .setPositiveButton(R.string.color_selector_dialog_done, (dialog, which) -> { .setPositiveButton(R.string.color_selector_dialog_save, (dialog, which) -> { mCurrentColor = colorSelectorLayout.getCheckedColor(DEFAULT_SCREEN_FLASH_COLOR); mConsumer.accept(mCurrentColor); }) Loading tests/robotests/src/com/android/settings/accessibility/FlashNotificationsPreviewPreferenceControllerTest.java +23 −14 Original line number Diff line number Diff line Loading @@ -67,22 +67,23 @@ public class FlashNotificationsPreviewPreferenceControllerTest { public MockitoRule mMockitoRule = MockitoJUnit.rule(); @Spy private final Context mContext = ApplicationProvider.getApplicationContext(); @Spy private ContentResolver mContentResolver = mContext.getContentResolver(); @Mock private PreferenceScreen mPreferenceScreen; @Mock private Preference mPreference; @Spy private ContentResolver mContentResolver = mContext.getContentResolver(); private FlashNotificationsPreviewPreferenceController mController; @Before public void setUp() { MockitoAnnotations.initMocks(this); when(mPreferenceScreen.findPreference(PREFERENCE_KEY)).thenReturn(mPreference); when(mPreference.getKey()).thenReturn(PREFERENCE_KEY); when(mContext.getContentResolver()).thenReturn(mContentResolver); mPreference = new Preference(mContext); mPreference.setKey(PREFERENCE_KEY); when(mPreferenceScreen.findPreference(PREFERENCE_KEY)).thenReturn(mPreference); mController = new FlashNotificationsPreviewPreferenceController(mContext, PREFERENCE_KEY); } Loading @@ -97,40 +98,45 @@ public class FlashNotificationsPreviewPreferenceControllerTest { } @Test public void testDisplayPreference_torchPresent_cameraOff_screenOff_verifyDisabled() { public void testDisplayPreference_torchPresent_cameraOff_screenOff_notVisible() { setFlashNotificationsState(FlashNotificationsUtil.State.OFF); mController.displayPreference(mPreferenceScreen); verify(mPreference).setEnabled(eq(false)); assertThat(mPreference.isVisible()).isFalse(); } @Test public void testDisplayPreference_torchPresent_cameraOn_screenOff_verifyEnabled() { public void testDisplayPreference_torchPresent_cameraOn_screenOff_isVisible() { setFlashNotificationsState(FlashNotificationsUtil.State.CAMERA); mController.displayPreference(mPreferenceScreen); verify(mPreference).setEnabled(eq(true)); assertThat(mPreference.isVisible()).isTrue(); } @Test public void testDisplayPreference_torchPresent_cameraOff_screenOn_verifyEnabled() { public void testDisplayPreference_torchPresent_cameraOff_screenOn_isVisible() { setFlashNotificationsState(FlashNotificationsUtil.State.SCREEN); mController.displayPreference(mPreferenceScreen); verify(mPreference).setEnabled(eq(true)); assertThat(mPreference.isVisible()).isTrue(); } @Test public void testDisplayPreference_torchPresent_cameraOn_screenOn_verifyEnabled() { public void testDisplayPreference_torchPresent_cameraOn_screenOn_isVisible() { setFlashNotificationsState(FlashNotificationsUtil.State.CAMERA_SCREEN); mController.displayPreference(mPreferenceScreen); verify(mPreference).setEnabled(eq(true)); assertThat(mPreference.isVisible()).isTrue(); } @Test public void testHandlePreferenceTreeClick_invalidPreference() { mController.handlePreferenceTreeClick(mock(Preference.class)); verify(mContext, never()).sendBroadcastAsUser(any(), any()); } Loading Loading @@ -160,6 +166,7 @@ public class FlashNotificationsPreviewPreferenceControllerTest { @Test public void onStateChanged_onResume_cameraUri_verifyRegister() { mController.onStateChanged(mock(LifecycleOwner.class), Lifecycle.Event.ON_RESUME); verify(mContentResolver).registerContentObserver( eq(Settings.System.getUriFor(Settings.System.CAMERA_FLASH_NOTIFICATION)), anyBoolean(), eq(mController.mContentObserver)); Loading @@ -168,6 +175,7 @@ public class FlashNotificationsPreviewPreferenceControllerTest { @Test public void onStateChanged_onResume_screenUri_verifyRegister() { mController.onStateChanged(mock(LifecycleOwner.class), Lifecycle.Event.ON_RESUME); verify(mContentResolver).registerContentObserver( eq(Settings.System.getUriFor(Settings.System.SCREEN_FLASH_NOTIFICATION)), anyBoolean(), eq(mController.mContentObserver)); Loading @@ -176,6 +184,7 @@ public class FlashNotificationsPreviewPreferenceControllerTest { @Test public void onStateChanged_onPause_verifyUnregister() { mController.onStateChanged(mock(LifecycleOwner.class), Lifecycle.Event.ON_PAUSE); verify(mContentResolver).unregisterContentObserver(eq(mController.mContentObserver)); } } Loading
res/values/strings.xml +1 −1 Original line number Diff line number Diff line Loading @@ -13460,7 +13460,7 @@ <!-- Label of the color option show in the summary of screen flash preference. [CHAR LIMIT=60] --> <string name="screen_flash_color_violet">Violet</string> <!-- Button to save the selection in screen flash color selection dialog. [CHAR LIMIT=20] --> <string name="color_selector_dialog_done">Done</string> <string name="color_selector_dialog_save">Save</string> <!-- Button to close the dialog without saving in screen flash color selection dialog. [CHAR LIMIT=20] --> <string name="color_selector_dialog_cancel">Cancel</string>
src/com/android/settings/accessibility/FlashNotificationsPreviewPreferenceController.java +1 −1 Original line number Diff line number Diff line Loading @@ -110,7 +110,7 @@ public class FlashNotificationsPreviewPreferenceController extends if (preference == null) { return; } preference.setEnabled(FlashNotificationsUtil.getFlashNotificationsState(mContext) preference.setVisible(FlashNotificationsUtil.getFlashNotificationsState(mContext) != FlashNotificationsUtil.State.OFF); } }
src/com/android/settings/accessibility/ScreenFlashNotificationColorDialogFragment.java +2 −3 Original line number Diff line number Diff line Loading @@ -65,8 +65,7 @@ public class ScreenFlashNotificationColorDialogFragment extends DialogFragment i final ScreenFlashNotificationColorDialogFragment result = new ScreenFlashNotificationColorDialogFragment(); result.mCurrentColor = initialColor; result.mConsumer = colorConsumer != null ? colorConsumer : i -> { }; result.mConsumer = colorConsumer != null ? colorConsumer : i -> {}; return result; } Loading @@ -89,7 +88,7 @@ public class ScreenFlashNotificationColorDialogFragment extends DialogFragment i .setNeutralButton(R.string.flash_notifications_preview, null) .setNegativeButton(R.string.color_selector_dialog_cancel, (dialog, which) -> { }) .setPositiveButton(R.string.color_selector_dialog_done, (dialog, which) -> { .setPositiveButton(R.string.color_selector_dialog_save, (dialog, which) -> { mCurrentColor = colorSelectorLayout.getCheckedColor(DEFAULT_SCREEN_FLASH_COLOR); mConsumer.accept(mCurrentColor); }) Loading
tests/robotests/src/com/android/settings/accessibility/FlashNotificationsPreviewPreferenceControllerTest.java +23 −14 Original line number Diff line number Diff line Loading @@ -67,22 +67,23 @@ public class FlashNotificationsPreviewPreferenceControllerTest { public MockitoRule mMockitoRule = MockitoJUnit.rule(); @Spy private final Context mContext = ApplicationProvider.getApplicationContext(); @Spy private ContentResolver mContentResolver = mContext.getContentResolver(); @Mock private PreferenceScreen mPreferenceScreen; @Mock private Preference mPreference; @Spy private ContentResolver mContentResolver = mContext.getContentResolver(); private FlashNotificationsPreviewPreferenceController mController; @Before public void setUp() { MockitoAnnotations.initMocks(this); when(mPreferenceScreen.findPreference(PREFERENCE_KEY)).thenReturn(mPreference); when(mPreference.getKey()).thenReturn(PREFERENCE_KEY); when(mContext.getContentResolver()).thenReturn(mContentResolver); mPreference = new Preference(mContext); mPreference.setKey(PREFERENCE_KEY); when(mPreferenceScreen.findPreference(PREFERENCE_KEY)).thenReturn(mPreference); mController = new FlashNotificationsPreviewPreferenceController(mContext, PREFERENCE_KEY); } Loading @@ -97,40 +98,45 @@ public class FlashNotificationsPreviewPreferenceControllerTest { } @Test public void testDisplayPreference_torchPresent_cameraOff_screenOff_verifyDisabled() { public void testDisplayPreference_torchPresent_cameraOff_screenOff_notVisible() { setFlashNotificationsState(FlashNotificationsUtil.State.OFF); mController.displayPreference(mPreferenceScreen); verify(mPreference).setEnabled(eq(false)); assertThat(mPreference.isVisible()).isFalse(); } @Test public void testDisplayPreference_torchPresent_cameraOn_screenOff_verifyEnabled() { public void testDisplayPreference_torchPresent_cameraOn_screenOff_isVisible() { setFlashNotificationsState(FlashNotificationsUtil.State.CAMERA); mController.displayPreference(mPreferenceScreen); verify(mPreference).setEnabled(eq(true)); assertThat(mPreference.isVisible()).isTrue(); } @Test public void testDisplayPreference_torchPresent_cameraOff_screenOn_verifyEnabled() { public void testDisplayPreference_torchPresent_cameraOff_screenOn_isVisible() { setFlashNotificationsState(FlashNotificationsUtil.State.SCREEN); mController.displayPreference(mPreferenceScreen); verify(mPreference).setEnabled(eq(true)); assertThat(mPreference.isVisible()).isTrue(); } @Test public void testDisplayPreference_torchPresent_cameraOn_screenOn_verifyEnabled() { public void testDisplayPreference_torchPresent_cameraOn_screenOn_isVisible() { setFlashNotificationsState(FlashNotificationsUtil.State.CAMERA_SCREEN); mController.displayPreference(mPreferenceScreen); verify(mPreference).setEnabled(eq(true)); assertThat(mPreference.isVisible()).isTrue(); } @Test public void testHandlePreferenceTreeClick_invalidPreference() { mController.handlePreferenceTreeClick(mock(Preference.class)); verify(mContext, never()).sendBroadcastAsUser(any(), any()); } Loading Loading @@ -160,6 +166,7 @@ public class FlashNotificationsPreviewPreferenceControllerTest { @Test public void onStateChanged_onResume_cameraUri_verifyRegister() { mController.onStateChanged(mock(LifecycleOwner.class), Lifecycle.Event.ON_RESUME); verify(mContentResolver).registerContentObserver( eq(Settings.System.getUriFor(Settings.System.CAMERA_FLASH_NOTIFICATION)), anyBoolean(), eq(mController.mContentObserver)); Loading @@ -168,6 +175,7 @@ public class FlashNotificationsPreviewPreferenceControllerTest { @Test public void onStateChanged_onResume_screenUri_verifyRegister() { mController.onStateChanged(mock(LifecycleOwner.class), Lifecycle.Event.ON_RESUME); verify(mContentResolver).registerContentObserver( eq(Settings.System.getUriFor(Settings.System.SCREEN_FLASH_NOTIFICATION)), anyBoolean(), eq(mController.mContentObserver)); Loading @@ -176,6 +184,7 @@ public class FlashNotificationsPreviewPreferenceControllerTest { @Test public void onStateChanged_onPause_verifyUnregister() { mController.onStateChanged(mock(LifecycleOwner.class), Lifecycle.Event.ON_PAUSE); verify(mContentResolver).unregisterContentObserver(eq(mController.mContentObserver)); } }