Disabled state UI of Flash Notifications preview button

When both the camera flash and screen flash toggles are turned off, tapping on the preview button will have no effect and may confuse users. To avoid this, the appearance of the preview button should be updated to clearly indicated that its current state is disabled. This wil help users better understand the situation and prevent confusion.

Bug: 276494146
Test: checks the UI manually
Test: make RunSettingsRoboTests ROBOTEST_FILTER=FlashNotificationsPreviewPreferenceTest
Change-Id: I55b11188fde6e551921a9b0f7c89daa20a8b766b
This commit is contained in:
Angela Wang
2023-05-04 08:54:35 +00:00
parent 3f16621b86
commit 53a8cc0326
8 changed files with 185 additions and 33 deletions

View File

@@ -55,7 +55,7 @@ public class FlashNotificationsPreviewPreferenceController extends
new Handler(Looper.getMainLooper())) {
@Override
public void onChange(boolean selfChange, @Nullable Uri uri) {
onSettingChanged();
updateState(mPreference);
}
};
@@ -73,7 +73,7 @@ public class FlashNotificationsPreviewPreferenceController extends
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = screen.findPreference(getPreferenceKey());
onSettingChanged();
updateState(mPreference);
}
@Override
@@ -103,10 +103,13 @@ public class FlashNotificationsPreviewPreferenceController extends
}
}
private void onSettingChanged() {
if (mPreference == null) return;
mPreference.setEnabled(FlashNotificationsUtil.getFlashNotificationsState(mContext)
@Override
public void updateState(Preference preference) {
super.updateState(preference);
if (preference == null) {
return;
}
preference.setEnabled(FlashNotificationsUtil.getFlashNotificationsState(mContext)
!= FlashNotificationsUtil.State.OFF);
}
}