diff --git a/res/xml/accessibility_text_reading_options.xml b/res/xml/accessibility_text_reading_options.xml
index 795c4ffb9fc..8eed107d60a 100644
--- a/res/xml/accessibility_text_reading_options.xml
+++ b/res/xml/accessibility_text_reading_options.xml
@@ -25,7 +25,7 @@
android:key="preview"
android:selectable="false"/>
-
- mSizeData;
- private static final String KEY_SAVED_QS_TOOLTIP_RESHOW = "qs_tooltip_reshow";
private boolean mSeekByTouch;
private Optional mInteractionListener = Optional.empty();
- private LabeledSeekBarPreference mSeekBarPreference;
+ private AccessibilitySeekBarPreference mSeekBarPreference;
private int mLastProgress;
- private boolean mNeedsQSTooltipReshow = false;
- private AccessibilityQuickSettingsTooltipWindow mTooltipWindow;
private final Handler mHandler;
private String[] mStateLabels = null;
@@ -101,30 +96,21 @@ abstract class PreviewSizeSeekBarController extends BasePreferenceController imp
}
@Override
- public void onCreate(Bundle savedInstanceState) {
- // Restore the tooltip.
- if (savedInstanceState != null
- && savedInstanceState.containsKey(KEY_SAVED_QS_TOOLTIP_RESHOW)) {
- mNeedsQSTooltipReshow = savedInstanceState.getBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW);
+ public void onStart() {
+ if (mSeekBarPreference.getNeedsQSTooltipReshow()) {
+ mHandler.post(this::showQuickSettingsTooltipIfNeeded);
}
}
+ @Override
+ public void onStop() {
+ // all the messages/callbacks will be removed.
+ mHandler.removeCallbacksAndMessages(null);
+ }
+
@Override
public void onDestroy() {
- // remove runnables in the queue.
- mHandler.removeCallbacksAndMessages(null);
- final boolean isTooltipWindowShowing = mTooltipWindow != null && mTooltipWindow.isShowing();
- if (isTooltipWindowShowing) {
- mTooltipWindow.dismiss();
- }
- }
-
- @Override
- public void onSaveInstanceState(Bundle outState) {
- final boolean isTooltipWindowShowing = mTooltipWindow != null && mTooltipWindow.isShowing();
- if (mNeedsQSTooltipReshow || isTooltipWindowShowing) {
- outState.putBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW, /* value= */ true);
- }
+ mSeekBarPreference.dismissTooltip();
}
void setInteractionListener(ProgressInteractionListener interactionListener) {
@@ -148,9 +134,6 @@ abstract class PreviewSizeSeekBarController extends BasePreferenceController imp
mSeekBarPreference.setProgress(initialIndex);
mSeekBarPreference.setContinuousUpdates(true);
mSeekBarPreference.setOnSeekBarChangeListener(mSeekBarChangeListener);
- if (mNeedsQSTooltipReshow) {
- mHandler.post(this::showQuickSettingsTooltipIfNeeded);
- }
setSeekbarStateDescription(mSeekBarPreference.getProgress());
}
@@ -216,7 +199,8 @@ abstract class PreviewSizeSeekBarController extends BasePreferenceController imp
return;
}
- if (!mNeedsQSTooltipReshow && AccessibilityQuickSettingUtils.hasValueInSharedPreferences(
+ if (!mSeekBarPreference.getNeedsQSTooltipReshow()
+ && AccessibilityQuickSettingUtils.hasValueInSharedPreferences(
mContext, tileComponentName)) {
// Returns if quick settings tooltip only show once.
return;
@@ -228,14 +212,15 @@ abstract class PreviewSizeSeekBarController extends BasePreferenceController imp
// 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(),
+ final AccessibilityQuickSettingsTooltipWindow tooltipWindow =
+ mSeekBarPreference.createTooltipWindow();
+ tooltipWindow.setup(getTileTooltipContent(),
R.drawable.accessibility_auto_added_qs_tooltip_illustration);
- mTooltipWindow.showAtTopCenter(mSeekBarPreference.getSeekbar());
+ tooltipWindow.showAtTopCenter(mSeekBarPreference.getSeekbar());
}
AccessibilityQuickSettingUtils.optInValueToSharedPreferences(mContext,
tileComponentName);
- mNeedsQSTooltipReshow = false;
+ mSeekBarPreference.setNeedsQSTooltipReshow(false);
}
/** Returns the accessibility Quick Settings tile component name. */
diff --git a/src/com/android/settings/accessibility/TextReadingPreviewController.java b/src/com/android/settings/accessibility/TextReadingPreviewController.java
index a983105cfad..99f1f3fa0c3 100644
--- a/src/com/android/settings/accessibility/TextReadingPreviewController.java
+++ b/src/com/android/settings/accessibility/TextReadingPreviewController.java
@@ -33,7 +33,6 @@ import com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoi
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.instrumentation.SettingsStatsLog;
import com.android.settings.display.PreviewPagerAdapter;
-import com.android.settings.widget.LabeledSeekBarPreference;
import java.util.Objects;
@@ -58,8 +57,8 @@ class TextReadingPreviewController extends BasePreferenceController implements
private int mLastDisplayProgress;
private long mLastCommitTime;
private TextReadingPreviewPreference mPreviewPreference;
- private LabeledSeekBarPreference mFontSizePreference;
- private LabeledSeekBarPreference mDisplaySizePreference;
+ private AccessibilitySeekBarPreference mFontSizePreference;
+ private AccessibilitySeekBarPreference mDisplaySizePreference;
@EntryPoint
private int mEntryPoint;
diff --git a/tests/robotests/src/com/android/settings/accessibility/PreviewSizeSeekBarControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/PreviewSizeSeekBarControllerTest.java
index 05273fc050d..ba9eaa5871e 100644
--- a/tests/robotests/src/com/android/settings/accessibility/PreviewSizeSeekBarControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/PreviewSizeSeekBarControllerTest.java
@@ -29,7 +29,6 @@ import static org.mockito.Mockito.when;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
-import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.PopupWindow;
import android.widget.SeekBar;
@@ -44,7 +43,6 @@ import androidx.test.ext.junit.rules.ActivityScenarioRule;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.testutils.shadow.ShadowFragment;
-import com.android.settings.widget.LabeledSeekBarPreference;
import com.android.settingslib.testutils.shadow.ShadowInteractionJankMonitor;
import com.google.android.setupcompat.util.WizardManagerHelper;
@@ -77,7 +75,7 @@ public class PreviewSizeSeekBarControllerTest {
private Activity mContext;
private PreviewSizeSeekBarController mSeekBarController;
private FontSizeData mFontSizeData;
- private LabeledSeekBarPreference mSeekBarPreference;
+ private AccessibilitySeekBarPreference mSeekBarPreference;
private PreferenceScreen mPreferenceScreen;
private TestFragment mFragment;
@@ -109,7 +107,7 @@ public class PreviewSizeSeekBarControllerTest {
mPreferenceScreen = spy(new PreferenceScreen(mContext, /* attrs= */ null));
when(mPreferenceScreen.getPreferenceManager()).thenReturn(mPreferenceManager);
doReturn(mPreferenceScreen).when(mFragment).getPreferenceScreen();
- mSeekBarPreference = spy(new LabeledSeekBarPreference(mContext, /* attrs= */ null));
+ mSeekBarPreference = spy(new AccessibilitySeekBarPreference(mContext, /* attrs= */ null));
mSeekBarPreference.setKey(FONT_SIZE_KEY);
LayoutInflater inflater = LayoutInflater.from(mContext);
@@ -246,12 +244,11 @@ public class PreviewSizeSeekBarControllerTest {
@Test
@Config(shadows = ShadowFragment.class)
- public void restoreValueFromSavedInstanceState_showTooltipView() {
- final Bundle savedInstanceState = new Bundle();
- savedInstanceState.putBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW, /* value= */ true);
- mSeekBarController.onCreate(savedInstanceState);
+ public void enabledNeedsQSTooltipReshow_showTooltipView() {
+ mSeekBarPreference.setNeedsQSTooltipReshow(true);
mSeekBarController.displayPreference(mPreferenceScreen);
+ mSeekBarController.onStart();
ShadowLooper.idleMainLooper();
assertThat(getLatestPopupWindow().isShowing()).isTrue();
diff --git a/tests/robotests/src/com/android/settings/accessibility/TextReadingPreviewControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/TextReadingPreviewControllerTest.java
index f768e42f2e6..375952f725c 100644
--- a/tests/robotests/src/com/android/settings/accessibility/TextReadingPreviewControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/TextReadingPreviewControllerTest.java
@@ -28,7 +28,6 @@ import androidx.test.core.app.ApplicationProvider;
import com.android.settings.display.PreviewPagerAdapter;
import com.android.settings.testutils.shadow.ShadowInteractionJankMonitor;
-import com.android.settings.widget.LabeledSeekBarPreference;
import org.junit.Before;
import org.junit.Test;
@@ -54,8 +53,8 @@ public class TextReadingPreviewControllerTest {
private final Context mContext = ApplicationProvider.getApplicationContext();
private TextReadingPreviewController mPreviewController;
private TextReadingPreviewPreference mPreviewPreference;
- private LabeledSeekBarPreference mFontSizePreference;
- private LabeledSeekBarPreference mDisplaySizePreference;
+ private AccessibilitySeekBarPreference mFontSizePreference;
+ private AccessibilitySeekBarPreference mDisplaySizePreference;
@Mock
private DisplaySizeData mDisplaySizeData;
@@ -73,8 +72,8 @@ public class TextReadingPreviewControllerTest {
mPreviewPreference = spy(new TextReadingPreviewPreference(mContext, /* attr= */ null));
mPreviewController = new TextReadingPreviewController(mContext, PREVIEW_KEY, fontSizeData,
mDisplaySizeData);
- mFontSizePreference = new LabeledSeekBarPreference(mContext, /* attr= */ null);
- mDisplaySizePreference = new LabeledSeekBarPreference(mContext, /* attr= */ null);
+ mFontSizePreference = new AccessibilitySeekBarPreference(mContext, /* attr= */ null);
+ mDisplaySizePreference = new AccessibilitySeekBarPreference(mContext, /* attr= */ null);
}
@Test