From b66f6b67c886936b008d0736e678d383b7e67387 Mon Sep 17 00:00:00 2001 From: Candice Lo Date: Sat, 17 Jun 2023 07:20:14 +0000 Subject: [PATCH 1/2] Doing null check before generating Font Size tooltip Since the lifecycle of controller is independent of that of preference, we do null check on the seekbar to avoid generating tooltip from the seekbar when it is not ready. The fix is a temporary solution for the issue and we would like to move the logic of tooltip to systemUI to match the general view's lifecycle in the future. Bug: 279549685 Test: manually - check the tooltip won't be shown and also won't cause exception after rotating the phone. (The seekbar view has not been created if it is out of screen.) Test: manually - attach video to the bug Test: make RunSettingsRoboTests ROBOTEST_FILTER=PreviewSizeSeekBarControllerTest Change-Id: I50111f0cc59cad4401ab67b06cd62e9067e8ed76 --- .../PreviewSizeSeekBarController.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/com/android/settings/accessibility/PreviewSizeSeekBarController.java b/src/com/android/settings/accessibility/PreviewSizeSeekBarController.java index 9603739ee6b..6bd87475e31 100644 --- a/src/com/android/settings/accessibility/PreviewSizeSeekBarController.java +++ b/src/com/android/settings/accessibility/PreviewSizeSeekBarController.java @@ -213,11 +213,19 @@ abstract class PreviewSizeSeekBarController extends BasePreferenceController imp return; } - mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(mContext); - mTooltipWindow.setup(getTileTooltipContent(), - R.drawable.accessibility_auto_added_qs_tooltip_illustration); - mTooltipWindow.showAtTopCenter(mSeekBarPreference.getSeekbar()); - AccessibilityQuickSettingUtils.optInValueToSharedPreferences(mContext, tileComponentName); + // TODO (287728819): Move tooltip showing to SystemUI + // Since the lifecycle of controller is independent of that of the preference, doing + // null check on seekbar is a temporary solution for the case that seekbar view + // is not ready when we would like to show the tooltip. If the seekbar is not ready, + // we give up showing the tooltip and also do not reshow it in the future. + if (mSeekBarPreference.getSeekbar() != null) { + mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(mContext); + mTooltipWindow.setup(getTileTooltipContent(), + R.drawable.accessibility_auto_added_qs_tooltip_illustration); + mTooltipWindow.showAtTopCenter(mSeekBarPreference.getSeekbar()); + } + AccessibilityQuickSettingUtils.optInValueToSharedPreferences(mContext, + tileComponentName); mNeedsQSTooltipReshow = false; } From 48999d3808d53bd99139f3932bf6cdc2c28d8cd8 Mon Sep 17 00:00:00 2001 From: Candice Lo Date: Sat, 17 Jun 2023 09:23:39 +0000 Subject: [PATCH 2/2] Doing null check before generating Extra Dim tooltip Since the lifecycle of controller is independent of that of preference, we do null check on the switch to avoid generating tooltip from the switch when it is not ready. The fix is a temporary solution for the issue and we would like to move the logic of tooltip to systemUI to match the general view's lifecycle in the future. Bug: 286810561 Test: manually - check the tooltip won't be shown and also won't cause exception after rotating the phone. (The switch view has not been created if it is out of screen.) Test: manually - attach video to the bug Test: make RunSettingsRoboTests ROBOTEST_FILTER=AccessibilityQuickSettingsPrimarySwitchPreferenceControllerTest Change-Id: I75d810e4b85baf06d57a3e31797a55daac791b79 --- ...SettingsPrimarySwitchPreferenceController.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/com/android/settings/accessibility/AccessibilityQuickSettingsPrimarySwitchPreferenceController.java b/src/com/android/settings/accessibility/AccessibilityQuickSettingsPrimarySwitchPreferenceController.java index 47073638122..e82cd96e851 100644 --- a/src/com/android/settings/accessibility/AccessibilityQuickSettingsPrimarySwitchPreferenceController.java +++ b/src/com/android/settings/accessibility/AccessibilityQuickSettingsPrimarySwitchPreferenceController.java @@ -130,10 +130,17 @@ public abstract class AccessibilityQuickSettingsPrimarySwitchPreferenceControlle return; } - mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(mContext); - mTooltipWindow.setup(getTileTooltipContent(), - R.drawable.accessibility_auto_added_qs_tooltip_illustration); - mTooltipWindow.showAtTopCenter(mPreference.getSwitch()); + // TODO (287728819): Move tooltip showing to SystemUI + // Since the lifecycle of controller is independent of that of the preference, doing + // null check on switch is a temporary solution for the case that switch view + // is not ready when we would like to show the tooltip. If the switch is not ready, + // we give up showing the tooltip and also do not reshow it in the future. + if (mPreference.getSwitch() != null) { + mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(mContext); + mTooltipWindow.setup(getTileTooltipContent(), + R.drawable.accessibility_auto_added_qs_tooltip_illustration); + mTooltipWindow.showAtTopCenter(mPreference.getSwitch()); + } AccessibilityQuickSettingUtils.optInValueToSharedPreferences(mContext, tileComponentName); mNeedsQSTooltipReshow = false; }