Show different tooltips for QS features auto-added and non-auto-added
There are 2 different kinds of auto-added / non-auto-added subtext in QS tooltips for framework features. Show animation in the settings page for full flow for non-framework services. Bug: 218968108 Test: make RunSettingsRoboTests ROBOTEST_FILTER=AccessibilityQuickSettingsTooltipWindowTest AccessibilityShortcutPreferenceFragmentTest Change-Id: I462cfcece959df8b9d97fab8e28337bceca9e25e
This commit is contained in:
@@ -23,10 +23,10 @@
|
||||
android:background="@drawable/accessibility_qs_tooltips_background">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/qs_illustration"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/accessibility_qs_tooltips_margin_top"
|
||||
android:src="@drawable/accessibility_qs_tooltips_illustration"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:contentDescription="@null" />
|
||||
|
||||
|
@@ -5523,8 +5523,10 @@
|
||||
<string name="accessibility_service_primary_switch_title">Use <xliff:g id="accessibility_app_name" example="TalkBack">%1$s</xliff:g></string>
|
||||
<!-- Used in the accessibility service settings to open the activity. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_service_primary_open_title">Open <xliff:g id="accessibility_app_name" example="TalkBack">%1$s</xliff:g></string>
|
||||
<!-- Used in the accessibility service settings to show quick settings tooltips for auto-added feature. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_service_auto_added_qs_tooltips_content"><xliff:g id="accessibility_app_name" example="TalkBack">%1$s</xliff:g> added to Quick Settings. Swipe down to turn it on or off anytime.</string>
|
||||
<!-- Used in the accessibility service settings to show quick settings tooltips. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_service_quick_settings_tooltips_content"><xliff:g id="accessibility_app_name" example="TalkBack">%1$s</xliff:g> added to Quick Settings. Swipe down to turn it on or off anytime.</string>
|
||||
<string name="accessibility_service_qs_tooltips_content">You can add a shortcut to <xliff:g id="accessibility_app_name" example="TalkBack">%1$s</xliff:g> by editing quick settings</string>
|
||||
<!-- Used in the accessibility action for accessibility quick settings tooltips to dismiss. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_quick_settings_tooltips_dismiss">Dismiss</string>
|
||||
<!-- Intro for color correction settings screen to control turning on/off the feature entirely. [CHAR LIMIT=NONE] -->
|
||||
|
@@ -27,10 +27,12 @@ import android.view.View;
|
||||
import android.view.View.AccessibilityDelegate;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settings.R;
|
||||
@@ -76,9 +78,10 @@ public class AccessibilityQuickSettingsTooltipWindow extends PopupWindow {
|
||||
* Sets up {@link #AccessibilityQuickSettingsTooltipWindow}'s layout and content.
|
||||
*
|
||||
* @param text text to be displayed
|
||||
* @param imageResId the resource ID of the image drawable
|
||||
*/
|
||||
public void setup(String text) {
|
||||
this.setup(text, /* closeDelayTimeMillis= */ 0);
|
||||
public void setup(String text, @DrawableRes int imageResId) {
|
||||
this.setup(text, imageResId, /* closeDelayTimeMillis= */ 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,9 +91,10 @@ public class AccessibilityQuickSettingsTooltipWindow extends PopupWindow {
|
||||
* close delay time is positive number. </p>
|
||||
*
|
||||
* @param text text to be displayed
|
||||
* @param imageResId the resource ID of the image drawable
|
||||
* @param closeDelayTimeMillis how long the popup window be auto-closed
|
||||
*/
|
||||
public void setup(String text, long closeDelayTimeMillis) {
|
||||
public void setup(String text, @DrawableRes int imageResId, long closeDelayTimeMillis) {
|
||||
this.mCloseDelayTimeMillis = closeDelayTimeMillis;
|
||||
|
||||
setBackgroundDrawable(new ColorDrawable(mContext.getColor(android.R.color.transparent)));
|
||||
@@ -101,6 +105,8 @@ public class AccessibilityQuickSettingsTooltipWindow extends PopupWindow {
|
||||
popupView.setAccessibilityDelegate(mAccessibilityDelegate);
|
||||
setContentView(popupView);
|
||||
|
||||
final ImageView imageView = getContentView().findViewById(R.id.qs_illustration);
|
||||
imageView.setImageResource(imageResId);
|
||||
final TextView textView = getContentView().findViewById(R.id.qs_content);
|
||||
textView.setText(text);
|
||||
setWidth(getWindowWidthWith(textView));
|
||||
|
@@ -18,6 +18,7 @@ package com.android.settings.accessibility;
|
||||
|
||||
import static com.android.settings.accessibility.AccessibilityDialogUtils.DialogEnums;
|
||||
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.Dialog;
|
||||
import android.app.settings.SettingsEnums;
|
||||
@@ -41,6 +42,7 @@ import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.utils.LocaleUtils;
|
||||
|
||||
@@ -70,6 +72,7 @@ public abstract class AccessibilityShortcutPreferenceFragment extends DashboardF
|
||||
private CheckBox mHardwareTypeCheckBox;
|
||||
private AccessibilityQuickSettingsTooltipWindow mTooltipWindow;
|
||||
private boolean mNeedsQSTooltipReshow = false;
|
||||
private int mNeedsQSTooltipType = QuickSettingsTooltipType.GUIDE_TO_EDIT;
|
||||
|
||||
/** Returns the accessibility component name. */
|
||||
protected abstract ComponentName getComponentName();
|
||||
@@ -96,6 +99,9 @@ public abstract class AccessibilityShortcutPreferenceFragment extends DashboardF
|
||||
if (savedInstanceState.containsKey(KEY_SAVED_QS_TOOLTIP_RESHOW)) {
|
||||
mNeedsQSTooltipReshow = savedInstanceState.getBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW);
|
||||
}
|
||||
if (savedInstanceState.containsKey(KEY_SAVED_QS_TOOLTIP_TYPE)) {
|
||||
mNeedsQSTooltipType = savedInstanceState.getInt(KEY_SAVED_QS_TOOLTIP_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
final int resId = getPreferenceScreenResId();
|
||||
@@ -176,6 +182,7 @@ public abstract class AccessibilityShortcutPreferenceFragment extends DashboardF
|
||||
}
|
||||
if (mTooltipWindow != null) {
|
||||
outState.putBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW, mTooltipWindow.isShowing());
|
||||
outState.putInt(KEY_SAVED_QS_TOOLTIP_TYPE, mNeedsQSTooltipType);
|
||||
}
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
@@ -198,7 +205,7 @@ public abstract class AccessibilityShortcutPreferenceFragment extends DashboardF
|
||||
case DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL:
|
||||
dialog = AccessibilityGestureNavigationTutorial
|
||||
.createAccessibilityTutorialDialog(getPrefContext(),
|
||||
getUserShortcutTypes());
|
||||
getUserShortcutTypes(), this::callOnTutorialDialogButtonClicked);
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
return dialog;
|
||||
default:
|
||||
@@ -296,6 +303,17 @@ public abstract class AccessibilityShortcutPreferenceFragment extends DashboardF
|
||||
getComponentName());
|
||||
};
|
||||
|
||||
/**
|
||||
* This method will be invoked when a button in the tutorial dialog is clicked.
|
||||
*
|
||||
* @param dialog The dialog that received the click
|
||||
* @param which The button that was clicked
|
||||
*/
|
||||
private void callOnTutorialDialogButtonClicked(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
showQuickSettingsTooltipIfNeeded();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be invoked when a button in the edit shortcut dialog is clicked.
|
||||
*
|
||||
@@ -308,12 +326,17 @@ public abstract class AccessibilityShortcutPreferenceFragment extends DashboardF
|
||||
}
|
||||
|
||||
final int value = getShortcutTypeCheckBoxValue();
|
||||
|
||||
saveNonEmptyUserShortcutType(value);
|
||||
AccessibilityUtil.optInAllValuesToSettings(getPrefContext(), value, getComponentName());
|
||||
AccessibilityUtil.optOutAllValuesFromSettings(getPrefContext(), ~value, getComponentName());
|
||||
mShortcutPreference.setChecked(value != AccessibilityUtil.UserShortcutType.EMPTY);
|
||||
final boolean shortcutAssigned = value != AccessibilityUtil.UserShortcutType.EMPTY;
|
||||
mShortcutPreference.setChecked(shortcutAssigned);
|
||||
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
|
||||
|
||||
// Show the quick setting tooltip if the shortcut assigned in the first time
|
||||
if (shortcutAssigned) {
|
||||
showQuickSettingsTooltipIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -452,7 +475,18 @@ public abstract class AccessibilityShortcutPreferenceFragment extends DashboardF
|
||||
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
|
||||
}
|
||||
|
||||
protected void showQuickSettingsTooltipIfNeeded() {
|
||||
/**
|
||||
* Shows the quick settings tooltip if the quick settings feature is assigned. The tooltip only
|
||||
* shows once.
|
||||
*
|
||||
* @param type The quick settings tooltip type
|
||||
*/
|
||||
protected void showQuickSettingsTooltipIfNeeded(@QuickSettingsTooltipType int type) {
|
||||
mNeedsQSTooltipType = type;
|
||||
showQuickSettingsTooltipIfNeeded();
|
||||
}
|
||||
|
||||
private void showQuickSettingsTooltipIfNeeded() {
|
||||
final ComponentName tileComponentName = getTileComponentName();
|
||||
if (tileComponentName == null) {
|
||||
// Returns if no tile service assigned.
|
||||
@@ -471,10 +505,13 @@ public abstract class AccessibilityShortcutPreferenceFragment extends DashboardF
|
||||
return;
|
||||
}
|
||||
|
||||
final String title =
|
||||
getString(R.string.accessibility_service_quick_settings_tooltips_content, tileName);
|
||||
final int titleResId = mNeedsQSTooltipType == QuickSettingsTooltipType.GUIDE_TO_EDIT
|
||||
? R.string.accessibility_service_qs_tooltips_content
|
||||
: R.string.accessibility_service_auto_added_qs_tooltips_content;
|
||||
final String title = getString(titleResId, tileName);
|
||||
final int imageResId = R.drawable.accessibility_qs_tooltips_illustration;
|
||||
mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(getContext());
|
||||
mTooltipWindow.setup(title);
|
||||
mTooltipWindow.setup(title, imageResId);
|
||||
mTooltipWindow.showAtTopCenter(getView());
|
||||
AccessibilityQuickSettingUtils.optInValueToSharedPreferences(getContext(),
|
||||
tileComponentName);
|
||||
|
@@ -46,7 +46,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
/** Provides utility methods to accessibility settings only. */
|
||||
final class AccessibilityUtil {
|
||||
public final class AccessibilityUtil {
|
||||
|
||||
private AccessibilityUtil(){}
|
||||
|
||||
@@ -105,6 +105,17 @@ final class AccessibilityUtil {
|
||||
int TRIPLETAP = 4; // 1 << 2
|
||||
}
|
||||
|
||||
/**
|
||||
* Denotes the quick setting tooltip type.
|
||||
*
|
||||
* {@code GUIDE_TO_EDIT} for QS tiles that need to be added by editing.
|
||||
* {@code GUIDE_TO_DIRECT_USE} for QS tiles that have been auto-added already.
|
||||
*/
|
||||
public @interface QuickSettingsTooltipType {
|
||||
int GUIDE_TO_EDIT = 0;
|
||||
int GUIDE_TO_DIRECT_USE = 1;
|
||||
}
|
||||
|
||||
/** Denotes the accessibility enabled status */
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface State {
|
||||
|
@@ -20,11 +20,9 @@ import static com.android.settings.accessibility.AccessibilityStatsLogUtils.logA
|
||||
|
||||
import android.accessibilityservice.AccessibilityShortcutInfo;
|
||||
import android.app.ActivityOptions;
|
||||
import android.app.Dialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.net.Uri;
|
||||
@@ -138,20 +136,6 @@ public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeature
|
||||
return loadTileLabel(getPrefContext(), componentName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(int dialogId) {
|
||||
switch (dialogId) {
|
||||
case AccessibilityDialogUtils.DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL:
|
||||
final Dialog dialog = AccessibilityGestureNavigationTutorial
|
||||
.createAccessibilityTutorialDialog(getPrefContext(),
|
||||
getUserShortcutTypes(), this::callOnTutorialDialogButtonClicked);
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
return dialog;
|
||||
default:
|
||||
return super.onCreateDialog(dialogId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
// Do not call super. We don't want to see the "Help & feedback" option on this page so as
|
||||
@@ -236,22 +220,4 @@ public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeature
|
||||
|
||||
return settingsIntent;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be invoked when a button in the tutorial dialog is clicked.
|
||||
*
|
||||
* @param dialog The dialog that received the click
|
||||
* @param which The button that was clicked
|
||||
*/
|
||||
private void callOnTutorialDialogButtonClicked(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
showQuickSettingsTooltipIfNeeded();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void callOnAlertDialogCheckboxClicked(DialogInterface dialog, int which) {
|
||||
super.callOnAlertDialogCheckboxClicked(dialog, which);
|
||||
showQuickSettingsTooltipIfNeeded(getShortcutTypeCheckBoxValue());
|
||||
}
|
||||
}
|
||||
|
@@ -206,12 +206,6 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
||||
.createDisableDialog(getPrefContext(), info,
|
||||
this::onDialogButtonFromDisableToggleClicked);
|
||||
return mWarningDialog;
|
||||
case DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL:
|
||||
final Dialog dialog = AccessibilityGestureNavigationTutorial
|
||||
.createAccessibilityTutorialDialog(getPrefContext(),
|
||||
getUserShortcutTypes(), this::callOnTutorialDialogButtonClicked);
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
return dialog;
|
||||
default:
|
||||
return super.onCreateDialog(dialogId);
|
||||
}
|
||||
@@ -496,23 +490,6 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
||||
mWarningDialog.dismiss();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be invoked when a button in the tutorial dialog is clicked.
|
||||
*
|
||||
* @param dialog The dialog that received the click
|
||||
* @param which The button that was clicked
|
||||
*/
|
||||
private void callOnTutorialDialogButtonClicked(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
showQuickSettingsTooltipIfNeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void callOnAlertDialogCheckboxClicked(DialogInterface dialog, int which) {
|
||||
super.callOnAlertDialogCheckboxClicked(dialog, which);
|
||||
showQuickSettingsTooltipIfNeeded(getShortcutTypeCheckBoxValue());
|
||||
}
|
||||
|
||||
void onDialogButtonFromShortcutClicked(View view) {
|
||||
final int viewId = view.getId();
|
||||
if (viewId == R.id.permission_enable_allow_button) {
|
||||
|
@@ -33,6 +33,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
|
||||
import com.android.settings.widget.SettingsMainSwitchPreference;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -50,7 +51,9 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
||||
|
||||
@Override
|
||||
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
|
||||
super.onPreferenceToggled(preferenceKey, enabled);
|
||||
if (enabled) {
|
||||
showQuickSettingsTooltipIfNeeded(QuickSettingsTooltipType.GUIDE_TO_DIRECT_USE);
|
||||
}
|
||||
logAccessibilityServiceEnabled(mComponentName, enabled);
|
||||
Settings.Secure.putInt(getContentResolver(), ENABLED, enabled ? ON : OFF);
|
||||
}
|
||||
|
@@ -35,6 +35,7 @@ import android.view.ViewGroup;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.widget.SettingsMainSwitchPreference;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
@@ -165,7 +166,9 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
||||
|
||||
@Override
|
||||
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
|
||||
super.onPreferenceToggled(preferenceKey, enabled);
|
||||
if (enabled) {
|
||||
showQuickSettingsTooltipIfNeeded(QuickSettingsTooltipType.GUIDE_TO_DIRECT_USE);
|
||||
}
|
||||
logAccessibilityServiceEnabled(mComponentName, enabled);
|
||||
Settings.Secure.putInt(getContentResolver(), ENABLED, enabled ? ON : OFF);
|
||||
}
|
||||
|
@@ -56,6 +56,7 @@ import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.accessibility.AccessibilityDialogUtils.DialogType;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
|
||||
import com.android.settings.utils.LocaleUtils;
|
||||
import com.android.settings.widget.SettingsMainSwitchBar;
|
||||
@@ -103,6 +104,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
|
||||
protected static final String KEY_SAVED_USER_SHORTCUT_TYPE = "shortcut_type";
|
||||
protected static final String KEY_SAVED_QS_TOOLTIP_RESHOW = "qs_tooltip_reshow";
|
||||
protected static final String KEY_SAVED_QS_TOOLTIP_TYPE = "qs_tooltip_type";
|
||||
protected static final String KEY_ANIMATED_IMAGE = "animated_image";
|
||||
|
||||
private TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
|
||||
@@ -113,6 +115,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
|
||||
private AccessibilityQuickSettingsTooltipWindow mTooltipWindow;
|
||||
private boolean mNeedsQSTooltipReshow = false;
|
||||
private int mNeedsQSTooltipType = QuickSettingsTooltipType.GUIDE_TO_EDIT;
|
||||
|
||||
public static final int NOT_SET = -1;
|
||||
// Save user's shortcutType value when savedInstance has value (e.g. device rotated).
|
||||
@@ -148,6 +151,9 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
if (savedInstanceState.containsKey(KEY_SAVED_QS_TOOLTIP_RESHOW)) {
|
||||
mNeedsQSTooltipReshow = savedInstanceState.getBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW);
|
||||
}
|
||||
if (savedInstanceState.containsKey(KEY_SAVED_QS_TOOLTIP_TYPE)) {
|
||||
mNeedsQSTooltipType = savedInstanceState.getInt(KEY_SAVED_QS_TOOLTIP_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
setupDefaultShortcutIfNecessary(getPrefContext());
|
||||
@@ -254,6 +260,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
}
|
||||
if (mTooltipWindow != null) {
|
||||
outState.putBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW, mTooltipWindow.isShowing());
|
||||
outState.putInt(KEY_SAVED_QS_TOOLTIP_TYPE, mNeedsQSTooltipType);
|
||||
}
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
@@ -274,7 +281,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
case DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL:
|
||||
mDialog = AccessibilityGestureNavigationTutorial
|
||||
.createAccessibilityTutorialDialog(getPrefContext(),
|
||||
getUserShortcutTypes());
|
||||
getUserShortcutTypes(), this::callOnTutorialDialogButtonClicked);
|
||||
mDialog.setCanceledOnTouchOutside(false);
|
||||
return mDialog;
|
||||
default:
|
||||
@@ -694,6 +701,17 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
null, LocaleUtils.getConcatenatedString(list));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be invoked when a button in the tutorial dialog is clicked.
|
||||
*
|
||||
* @param dialog The dialog that received the click
|
||||
* @param which The button that was clicked
|
||||
*/
|
||||
private void callOnTutorialDialogButtonClicked(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
showQuickSettingsTooltipIfNeeded();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be invoked when a button in the edit shortcut dialog is clicked.
|
||||
*
|
||||
@@ -706,12 +724,17 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
}
|
||||
|
||||
final int value = getShortcutTypeCheckBoxValue();
|
||||
|
||||
saveNonEmptyUserShortcutType(value);
|
||||
AccessibilityUtil.optInAllValuesToSettings(getPrefContext(), value, mComponentName);
|
||||
AccessibilityUtil.optOutAllValuesFromSettings(getPrefContext(), ~value, mComponentName);
|
||||
mShortcutPreference.setChecked(value != UserShortcutType.EMPTY);
|
||||
final boolean shortcutAssigned = value != UserShortcutType.EMPTY;
|
||||
mShortcutPreference.setChecked(shortcutAssigned);
|
||||
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
|
||||
|
||||
// Show the quick setting tooltip if the shortcut assigned in the first time
|
||||
if (shortcutAssigned) {
|
||||
showQuickSettingsTooltipIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateShortcutPreferenceData() {
|
||||
@@ -823,23 +846,17 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the quick settings tooltip if the quick settings service and the shortcut are assigned.
|
||||
* The tooltip only shows once.
|
||||
* Shows the quick settings tooltip if the quick settings feature is assigned. The tooltip only
|
||||
* shows once.
|
||||
*
|
||||
* @param shortcutType The shortcut type.
|
||||
* @param type The quick settings tooltip type
|
||||
*/
|
||||
protected void showQuickSettingsTooltipIfNeeded(@UserShortcutType int shortcutType) {
|
||||
if (shortcutType == AccessibilityUtil.UserShortcutType.EMPTY) {
|
||||
return;
|
||||
}
|
||||
protected void showQuickSettingsTooltipIfNeeded(@QuickSettingsTooltipType int type) {
|
||||
mNeedsQSTooltipType = type;
|
||||
showQuickSettingsTooltipIfNeeded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the quick settings tooltip if the quick settings service is assigned. The tooltip only
|
||||
* shows once.
|
||||
*/
|
||||
protected void showQuickSettingsTooltipIfNeeded() {
|
||||
private void showQuickSettingsTooltipIfNeeded() {
|
||||
final ComponentName tileComponentName = getTileComponentName();
|
||||
if (tileComponentName == null) {
|
||||
// Returns if no tile service assigned.
|
||||
@@ -858,10 +875,13 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
return;
|
||||
}
|
||||
|
||||
final String title =
|
||||
getString(R.string.accessibility_service_quick_settings_tooltips_content, tileName);
|
||||
final int titleResId = mNeedsQSTooltipType == QuickSettingsTooltipType.GUIDE_TO_EDIT
|
||||
? R.string.accessibility_service_qs_tooltips_content
|
||||
: R.string.accessibility_service_auto_added_qs_tooltips_content;
|
||||
final String title = getString(titleResId, tileName);
|
||||
final int imageResId = R.drawable.accessibility_qs_tooltips_illustration;
|
||||
mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(getContext());
|
||||
mTooltipWindow.setup(title);
|
||||
mTooltipWindow.setup(title, imageResId);
|
||||
mTooltipWindow.showAtTopCenter(getView());
|
||||
AccessibilityQuickSettingUtils.optInValueToSharedPreferences(getContext(),
|
||||
tileComponentName);
|
||||
|
@@ -36,6 +36,7 @@ import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.widget.SeekBarPreference;
|
||||
import com.android.settings.widget.SettingsMainSwitchPreference;
|
||||
@@ -147,7 +148,9 @@ public class ToggleReduceBrightColorsPreferenceFragment extends ToggleFeaturePre
|
||||
|
||||
@Override
|
||||
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
|
||||
super.onPreferenceToggled(preferenceKey, enabled);
|
||||
if (enabled) {
|
||||
showQuickSettingsTooltipIfNeeded(QuickSettingsTooltipType.GUIDE_TO_DIRECT_USE);
|
||||
}
|
||||
logAccessibilityServiceEnabled(mComponentName, enabled);
|
||||
mColorDisplayManager.setReduceBrightColorsActivated(enabled);
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ import android.os.UserHandle;
|
||||
import com.android.internal.accessibility.AccessibilityShortcutController;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.AccessibilityShortcutPreferenceFragment;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
|
||||
import com.android.settings.accessibility.ShortcutPreference;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.widget.IllustrationPreference;
|
||||
@@ -64,7 +65,7 @@ public class OneHandedSettings extends AccessibilityShortcutPreferenceFragment {
|
||||
mainSwitchPreference.addOnSwitchChangeListener((switchView, isChecked) -> {
|
||||
switchView.setChecked(isChecked);
|
||||
if (isChecked) {
|
||||
showQuickSettingsTooltipIfNeeded();
|
||||
showQuickSettingsTooltipIfNeeded(QuickSettingsTooltipType.GUIDE_TO_DIRECT_USE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -53,6 +53,7 @@ public class AccessibilityQuickSettingsTooltipWindowTest {
|
||||
private PopupWindow.OnDismissListener mMockOnDismissListener;
|
||||
|
||||
private static final String TEST_PACKAGE_NAME = "com.test.package";
|
||||
private static final int TEST_RES_ID = 1234;
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private AccessibilityQuickSettingsTooltipWindow mTooltipView;
|
||||
private View mView;
|
||||
@@ -66,8 +67,8 @@ public class AccessibilityQuickSettingsTooltipWindowTest {
|
||||
@Test
|
||||
public void initTooltipView_atMostAvailableTextWidth() {
|
||||
final String quickSettingsTooltipsContent = mContext.getString(
|
||||
R.string.accessibility_service_quick_settings_tooltips_content, TEST_PACKAGE_NAME);
|
||||
mTooltipView.setup(quickSettingsTooltipsContent);
|
||||
R.string.accessibility_service_qs_tooltips_content, TEST_PACKAGE_NAME);
|
||||
mTooltipView.setup(quickSettingsTooltipsContent, TEST_RES_ID);
|
||||
|
||||
final int getMaxWidth = mTooltipView.getAvailableWindowWidth();
|
||||
assertThat(mTooltipView.getWidth()).isAtMost(getMaxWidth);
|
||||
@@ -75,7 +76,7 @@ public class AccessibilityQuickSettingsTooltipWindowTest {
|
||||
|
||||
@Test
|
||||
public void showTooltipView_success() {
|
||||
mTooltipView.setup(TEST_PACKAGE_NAME);
|
||||
mTooltipView.setup(TEST_PACKAGE_NAME, TEST_RES_ID);
|
||||
assertThat(getLatestPopupWindow()).isNull();
|
||||
|
||||
mTooltipView.showAtTopCenter(mView);
|
||||
@@ -85,7 +86,7 @@ public class AccessibilityQuickSettingsTooltipWindowTest {
|
||||
|
||||
@Test
|
||||
public void accessibilityClickActionOnTooltipViewShown_shouldInvokeCallbackAndNotShowing() {
|
||||
mTooltipView.setup(TEST_PACKAGE_NAME);
|
||||
mTooltipView.setup(TEST_PACKAGE_NAME, TEST_RES_ID);
|
||||
mTooltipView.setOnDismissListener(mMockOnDismissListener);
|
||||
mTooltipView.showAtTopCenter(mView);
|
||||
|
||||
@@ -101,7 +102,7 @@ public class AccessibilityQuickSettingsTooltipWindowTest {
|
||||
|
||||
@Test
|
||||
public void dismiss_tooltipViewShown_shouldInvokeCallbackAndNotShowing() {
|
||||
mTooltipView.setup(TEST_PACKAGE_NAME);
|
||||
mTooltipView.setup(TEST_PACKAGE_NAME, TEST_RES_ID);
|
||||
mTooltipView.setOnDismissListener(mMockOnDismissListener);
|
||||
mTooltipView.showAtTopCenter(mView);
|
||||
|
||||
@@ -113,7 +114,7 @@ public class AccessibilityQuickSettingsTooltipWindowTest {
|
||||
|
||||
@Test
|
||||
public void waitAutoCloseDelayTime_tooltipViewShown_shouldInvokeCallbackAndNotShowing() {
|
||||
mTooltipView.setup(TEST_PACKAGE_NAME, /* closeDelayTimeMillis= */ 1);
|
||||
mTooltipView.setup(TEST_PACKAGE_NAME, TEST_RES_ID, /* closeDelayTimeMillis= */ 1);
|
||||
mTooltipView.setOnDismissListener(mMockOnDismissListener);
|
||||
mTooltipView.showAtTopCenter(mView);
|
||||
|
||||
|
@@ -18,6 +18,7 @@ package com.android.settings.accessibility;
|
||||
|
||||
import static com.android.settings.accessibility.AccessibilityShortcutPreferenceFragment.KEY_SAVED_QS_TOOLTIP_RESHOW;
|
||||
import static com.android.settings.accessibility.AccessibilityShortcutPreferenceFragment.KEY_SAVED_USER_SHORTCUT_TYPE;
|
||||
import static com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
|
||||
import static com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
@@ -204,7 +205,7 @@ public class AccessibilityShortcutPreferenceFragmentTest {
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
public void restoreValueFromSavedInstanceState_showTooltipView() {
|
||||
mContext.setTheme(R.style.Theme_AppCompat);
|
||||
mFragment.showQuickSettingsTooltipIfNeeded();
|
||||
mFragment.showQuickSettingsTooltipIfNeeded(QuickSettingsTooltipType.GUIDE_TO_EDIT);
|
||||
assertThat(getLatestPopupWindow().isShowing()).isTrue();
|
||||
|
||||
final Bundle savedInstanceState = new Bundle();
|
||||
|
Reference in New Issue
Block a user