Fix no show quick settings tutorial after device rotates

Root cause: Render apps below the cutout area to make the fragment recreate multiple times when the device rotates. The tutorial status is not stored correctly and try to show the tutorial when activity is finishing.
Solution: Avoid showing the tutorial when the activity is finishing and store correct tutorial status after recreate.

Bug: 239578655
Test: Manual testing
Change-Id: I3ff12e23eb971f61280ebc89014b086dc348d734
This commit is contained in:
menghanli
2022-08-19 11:08:13 +08:00
parent 5171a38fe2
commit 057c5dc8ed
4 changed files with 33 additions and 14 deletions

View File

@@ -20,6 +20,7 @@ import static com.android.settings.accessibility.AccessibilityDialogUtils.Dialog
import static com.android.settings.accessibility.ToggleFeaturePreferenceFragment.KEY_GENERAL_CATEGORY;
import static com.android.settings.accessibility.ToggleFeaturePreferenceFragment.KEY_SAVED_QS_TOOLTIP_TYPE;
import android.app.Activity;
import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.content.ComponentName;
@@ -150,7 +151,12 @@ public abstract class AccessibilityShortcutPreferenceFragment extends DashboardF
// Reshow tooltip when activity recreate, such as rotate device.
if (mNeedsQSTooltipReshow) {
getView().post(this::showQuickSettingsTooltipIfNeeded);
view.post(() -> {
final Activity activity = getActivity();
if (activity != null && !activity.isFinishing()) {
showQuickSettingsTooltipIfNeeded();
}
});
}
}
@@ -180,8 +186,9 @@ public abstract class AccessibilityShortcutPreferenceFragment extends DashboardF
if (value != NOT_SET) {
outState.putInt(KEY_SAVED_USER_SHORTCUT_TYPE, value);
}
if (mTooltipWindow != null) {
outState.putBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW, mTooltipWindow.isShowing());
final boolean isTooltipWindowShowing = mTooltipWindow != null && mTooltipWindow.isShowing();
if (mNeedsQSTooltipReshow || isTooltipWindowShowing) {
outState.putBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW, /* value= */ true);
outState.putInt(KEY_SAVED_QS_TOOLTIP_TYPE, mNeedsQSTooltipType);
}
super.onSaveInstanceState(outState);