Customized accessibility framework features quick setting tooltips content
- Lowercase for one-handed mode, color correction, color inversion, extra dim in quick settings tooltips if these words are not first words. Bug: 220655084 Test: make RunSettingsRoboTests ROBOTEST_FILTER=AccessibilityShortcutPreferenceFragmentTest ToggleFeaturePreferenceFragmentTest LaunchAccessibilityActivityPreferenceFragmentTest ToggleAccessibilityServicePreferenceFragmentTest Change-Id: I309ca48cecb80942112c9d5adde5857c062706c8
This commit is contained in:
@@ -5552,11 +5552,27 @@
|
||||
<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] -->
|
||||
<!-- Used in the accessibility service settings to show quick settings tooltip 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] -->
|
||||
<!-- Used in the accessibility service settings to show quick settings tooltip. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_service_qs_tooltips_content">You can also add <xliff:g id="accessibility_app_name" example="TalkBack">%1$s</xliff:g> to Quick Settings from the top of your screen</string>
|
||||
<!-- Used in the accessibility action for accessibility quick settings tooltips to dismiss. [CHAR LIMIT=NONE] -->
|
||||
<!-- Used in the color correction settings to show quick settings tooltip for auto-added feature. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_color_correction_auto_added_qs_tooltip_content">Color correction added to Quick Settings. Swipe down to turn it on or off anytime.</string>
|
||||
<!-- Used in the color correction settings to show quick settings tooltip. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_color_correction_qs_tooltip_content">You can also add color correction to Quick Settings from the top of your screen</string>
|
||||
<!-- Used in the color inversion settings to show quick settings tooltip for auto-added feature. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_color_inversion_auto_added_qs_tooltip_content">Color inversion added to Quick Settings. Swipe down to turn it on or off anytime.</string>
|
||||
<!-- Used in the color inversion settings to show quick settings tooltip. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_color_inversion_qs_tooltip_content">You can also add color inversion to Quick Settings from the top of your screen</string>
|
||||
<!-- Used in the reduce bright colors settings to show quick settings tooltip for auto-added feature. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_reduce_bright_colors_auto_added_qs_tooltip_content">Extra dim added to Quick Settings. Swipe down to turn it on or off anytime.</string>
|
||||
<!-- Used in the reduce bright colors settings to show quick settings tooltip. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_reduce_bright_colors_qs_tooltip_content">You can also add extra dim to Quick Settings from the top of your screen</string>
|
||||
<!-- Used in the One-hand mode color to show quick settings tooltip for auto-added feature. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_one_handed_mode_auto_added_qs_tooltip_content">One-handed mode added to Quick Settings. Swipe down to turn it on or off anytime.</string>
|
||||
<!-- Used in the One-hand mode settings to show quick settings tooltip. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_one_handed_mode_qs_tooltip_content">You can also add one-handed mode to Quick Settings from the top of your screen</string>
|
||||
<!-- Used in the accessibility action for accessibility quick settings tooltip 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] -->
|
||||
<string name="accessibility_daltonizer_about_intro_text" product="default">Adjust how colors display on your phone</string>
|
||||
|
@@ -80,7 +80,7 @@ public class AccessibilityQuickSettingsTooltipWindow extends PopupWindow {
|
||||
* @param text text to be displayed
|
||||
* @param imageResId the resource ID of the image drawable
|
||||
*/
|
||||
public void setup(String text, @DrawableRes int imageResId) {
|
||||
public void setup(CharSequence text, @DrawableRes int imageResId) {
|
||||
this.setup(text, imageResId, /* closeDelayTimeMillis= */ 0);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public class AccessibilityQuickSettingsTooltipWindow extends PopupWindow {
|
||||
* @param imageResId the resource ID of the image drawable
|
||||
* @param closeDelayTimeMillis how long the popup window be auto-closed
|
||||
*/
|
||||
public void setup(String text, @DrawableRes int imageResId, long closeDelayTimeMillis) {
|
||||
public void setup(CharSequence text, @DrawableRes int imageResId, long closeDelayTimeMillis) {
|
||||
this.mCloseDelayTimeMillis = closeDelayTimeMillis;
|
||||
|
||||
setBackgroundDrawable(new ColorDrawable(mContext.getColor(android.R.color.transparent)));
|
||||
|
@@ -83,8 +83,8 @@ public abstract class AccessibilityShortcutPreferenceFragment extends DashboardF
|
||||
/** Returns the accessibility tile component name. */
|
||||
protected abstract ComponentName getTileComponentName();
|
||||
|
||||
/** Returns the accessibility tile feature name. */
|
||||
protected abstract CharSequence getTileName();
|
||||
/** Returns the accessibility tile tooltip content. */
|
||||
protected abstract CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type);
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -148,7 +148,7 @@ public abstract class AccessibilityShortcutPreferenceFragment extends DashboardF
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
// Reshow tooltips when activity recreate, such as rotate device.
|
||||
// Reshow tooltip when activity recreate, such as rotate device.
|
||||
if (mNeedsQSTooltipReshow) {
|
||||
getView().post(this::showQuickSettingsTooltipIfNeeded);
|
||||
}
|
||||
@@ -499,21 +499,17 @@ public abstract class AccessibilityShortcutPreferenceFragment extends DashboardF
|
||||
return;
|
||||
}
|
||||
|
||||
final CharSequence tileName = getTileName();
|
||||
if (TextUtils.isEmpty(tileName)) {
|
||||
// Returns if no title of tile service assigned.
|
||||
final CharSequence content = getTileTooltipContent(mNeedsQSTooltipType);
|
||||
if (TextUtils.isEmpty(content)) {
|
||||
// Returns if no content of tile tooltip assigned.
|
||||
return;
|
||||
}
|
||||
|
||||
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 = mNeedsQSTooltipType == QuickSettingsTooltipType.GUIDE_TO_EDIT
|
||||
? R.drawable.accessibility_qs_tooltips_illustration
|
||||
: R.drawable.accessibility_auto_added_qs_tooltips_illustration;
|
||||
mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(getContext());
|
||||
mTooltipWindow.setup(title, imageResId);
|
||||
mTooltipWindow.setup(content, imageResId);
|
||||
mTooltipWindow.showAtTopCenter(getView());
|
||||
AccessibilityQuickSettingUtils.optInValueToSharedPreferences(getContext(),
|
||||
tileComponentName);
|
||||
|
@@ -41,6 +41,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -128,12 +129,21 @@ public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeature
|
||||
}
|
||||
|
||||
@Override
|
||||
CharSequence getTileName() {
|
||||
CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type) {
|
||||
final ComponentName componentName = getTileComponentName();
|
||||
if (componentName == null) {
|
||||
return null;
|
||||
}
|
||||
return loadTileLabel(getPrefContext(), componentName);
|
||||
|
||||
final CharSequence tileName = loadTileLabel(getPrefContext(), componentName);
|
||||
if (tileName == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final int titleResId = type == QuickSettingsTooltipType.GUIDE_TO_EDIT
|
||||
? R.string.accessibility_service_qs_tooltips_content
|
||||
: R.string.accessibility_service_auto_added_qs_tooltips_content;
|
||||
return getString(titleResId, tileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -47,6 +47,7 @@ import android.widget.Switch;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.accessibility.AccessibilityUtils;
|
||||
@@ -239,12 +240,21 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
||||
}
|
||||
|
||||
@Override
|
||||
CharSequence getTileName() {
|
||||
CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type) {
|
||||
final ComponentName componentName = getTileComponentName();
|
||||
if (componentName == null) {
|
||||
return null;
|
||||
}
|
||||
return loadTileLabel(getPrefContext(), componentName);
|
||||
|
||||
final CharSequence tileName = loadTileLabel(getPrefContext(), componentName);
|
||||
if (tileName == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final int titleResId = type == QuickSettingsTooltipType.GUIDE_TO_EDIT
|
||||
? R.string.accessibility_service_qs_tooltips_content
|
||||
: R.string.accessibility_service_auto_added_qs_tooltips_content;
|
||||
return getString(titleResId, tileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -144,8 +144,10 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
||||
}
|
||||
|
||||
@Override
|
||||
CharSequence getTileName() {
|
||||
return getText(R.string.accessibility_display_inversion_preference_title);
|
||||
CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type) {
|
||||
return getText(type == QuickSettingsTooltipType.GUIDE_TO_EDIT
|
||||
? R.string.accessibility_color_inversion_qs_tooltip_content
|
||||
: R.string.accessibility_color_inversion_auto_added_qs_tooltip_content);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -201,8 +201,10 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
||||
}
|
||||
|
||||
@Override
|
||||
CharSequence getTileName() {
|
||||
return getText(R.string.accessibility_display_daltonizer_preference_title);
|
||||
CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type) {
|
||||
return getText(type == QuickSettingsTooltipType.GUIDE_TO_EDIT
|
||||
? R.string.accessibility_color_correction_qs_tooltip_content
|
||||
: R.string.accessibility_color_correction_auto_added_qs_tooltip_content);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -222,7 +222,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
|
||||
updatePreferenceOrder();
|
||||
|
||||
// Reshow tooltips when activity recreate, such as rotate device.
|
||||
// Reshow tooltip when activity recreate, such as rotate device.
|
||||
if (mNeedsQSTooltipReshow) {
|
||||
getView().post(this::showQuickSettingsTooltipIfNeeded);
|
||||
}
|
||||
@@ -331,8 +331,8 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
/** Returns the accessibility tile component name. */
|
||||
abstract ComponentName getTileComponentName();
|
||||
|
||||
/** Returns the accessibility tile feature name. */
|
||||
abstract CharSequence getTileName();
|
||||
/** Returns the accessibility tile tooltip content. */
|
||||
abstract CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type);
|
||||
|
||||
protected void updateToggleServiceTitle(SettingsMainSwitchPreference switchPreference) {
|
||||
final CharSequence title =
|
||||
@@ -870,21 +870,17 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
return;
|
||||
}
|
||||
|
||||
final CharSequence tileName = getTileName();
|
||||
if (TextUtils.isEmpty(tileName)) {
|
||||
// Returns if no title of tile service assigned.
|
||||
final CharSequence content = getTileTooltipContent(mNeedsQSTooltipType);
|
||||
if (TextUtils.isEmpty(content)) {
|
||||
// Returns if no content of tile tooltip assigned.
|
||||
return;
|
||||
}
|
||||
|
||||
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 = mNeedsQSTooltipType == QuickSettingsTooltipType.GUIDE_TO_EDIT
|
||||
? R.drawable.accessibility_qs_tooltips_illustration
|
||||
: R.drawable.accessibility_auto_added_qs_tooltips_illustration;
|
||||
mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(getContext());
|
||||
mTooltipWindow.setup(title, imageResId);
|
||||
mTooltipWindow.setup(content, imageResId);
|
||||
mTooltipWindow.showAtTopCenter(getView());
|
||||
AccessibilityQuickSettingUtils.optInValueToSharedPreferences(getContext(),
|
||||
tileComponentName);
|
||||
|
@@ -184,8 +184,10 @@ public class ToggleReduceBrightColorsPreferenceFragment extends ToggleFeaturePre
|
||||
}
|
||||
|
||||
@Override
|
||||
CharSequence getTileName() {
|
||||
return getText(R.string.reduce_bright_colors_preference_title);
|
||||
CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type) {
|
||||
return getText(type == QuickSettingsTooltipType.GUIDE_TO_EDIT
|
||||
? R.string.accessibility_reduce_bright_colors_qs_tooltip_content
|
||||
: R.string.accessibility_reduce_bright_colors_auto_added_qs_tooltip_content);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -47,6 +47,7 @@ import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.DialogCreatable;
|
||||
import com.android.settings.R;
|
||||
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;
|
||||
|
||||
@@ -405,7 +406,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
||||
}
|
||||
|
||||
@Override
|
||||
CharSequence getTileName() {
|
||||
CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -131,8 +131,10 @@ public class OneHandedSettings extends AccessibilityShortcutPreferenceFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CharSequence getTileName() {
|
||||
return mFeatureName;
|
||||
protected CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type) {
|
||||
return type == QuickSettingsTooltipType.GUIDE_TO_EDIT
|
||||
? getText(R.string.accessibility_one_handed_mode_qs_tooltip_content)
|
||||
: getText(R.string.accessibility_one_handed_mode_auto_added_qs_tooltip_content);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -73,6 +73,8 @@ public class AccessibilityShortcutPreferenceFragmentTest {
|
||||
PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_CLASS_NAME);
|
||||
private static final ComponentName PLACEHOLDER_TILE_COMPONENT_NAME = new ComponentName(
|
||||
PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME);
|
||||
private static final String PLACEHOLDER_TILE_TOOLTIP_CONTENT =
|
||||
PLACEHOLDER_PACKAGE_NAME + "tooltip_content";
|
||||
private static final String PLACEHOLDER_DIALOG_TITLE = "title";
|
||||
|
||||
private static final String SOFTWARE_SHORTCUT_KEY =
|
||||
@@ -281,8 +283,8 @@ public class AccessibilityShortcutPreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CharSequence getTileName() {
|
||||
return PLACEHOLDER_PACKAGE_NAME;
|
||||
protected CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type) {
|
||||
return PLACEHOLDER_TILE_TOOLTIP_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -34,6 +34,9 @@ import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -44,8 +47,6 @@ import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.Shadows;
|
||||
import org.robolectric.shadows.ShadowPackageManager;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/** Tests for {@link LaunchAccessibilityActivityPreferenceFragment} */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class LaunchAccessibilityActivityPreferenceFragmentTest {
|
||||
@@ -83,53 +84,91 @@ public class LaunchAccessibilityActivityPreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTileName_noTileServiceAssigned_returnNull() {
|
||||
assertThat(mFragment.getTileName()).isNull();
|
||||
public void getTileTooltipContent_noTileServiceAssigned_returnNull() {
|
||||
final CharSequence tileTooltipContent =
|
||||
mFragment.getTileTooltipContent(QuickSettingsTooltipType.GUIDE_TO_EDIT);
|
||||
|
||||
assertThat(tileTooltipContent).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTileName_hasOneTileService_haveMatchString() {
|
||||
final Intent tileProbe = new Intent(TileService.ACTION_QS_TILE);
|
||||
final ResolveInfo info = new ResolveInfo();
|
||||
info.serviceInfo = new FakeServiceInfo();
|
||||
info.serviceInfo.packageName = PLACEHOLDER_PACKAGE_NAME;
|
||||
info.serviceInfo.name = PLACEHOLDER_TILE_CLASS_NAME;
|
||||
final ShadowPackageManager shadowPackageManager =
|
||||
Shadows.shadowOf(mContext.getPackageManager());
|
||||
shadowPackageManager.setResolveInfosForIntent(tileProbe, Arrays.asList(info));
|
||||
public void getTileTooltipContent_hasOneTileService_guideToEdit_haveMatchString() {
|
||||
setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME,
|
||||
PLACEHOLDER_TILE_NAME);
|
||||
|
||||
final CharSequence tileName = mFragment.getTileName();
|
||||
assertThat(tileName.toString()).isEqualTo(PLACEHOLDER_TILE_NAME);
|
||||
final CharSequence tileTooltipContent =
|
||||
mFragment.getTileTooltipContent(QuickSettingsTooltipType.GUIDE_TO_EDIT);
|
||||
final CharSequence tileName =
|
||||
mFragment.loadTileLabel(mContext, mFragment.getTileComponentName());
|
||||
assertThat(tileTooltipContent.toString()).isEqualTo(
|
||||
mContext.getString(R.string.accessibility_service_qs_tooltips_content, tileName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTileName_hasTwoTileServices_haveMatchString() {
|
||||
public void getTileTooltipContent_hasOneTileService_guideToDirectUse_haveMatchString() {
|
||||
setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME,
|
||||
PLACEHOLDER_TILE_NAME);
|
||||
|
||||
final CharSequence tileTooltipContent =
|
||||
mFragment.getTileTooltipContent(QuickSettingsTooltipType.GUIDE_TO_DIRECT_USE);
|
||||
final CharSequence tileName =
|
||||
mFragment.loadTileLabel(mContext, mFragment.getTileComponentName());
|
||||
assertThat(tileTooltipContent.toString()).isEqualTo(
|
||||
mContext.getString(
|
||||
R.string.accessibility_service_auto_added_qs_tooltips_content, tileName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTileTooltipContent_hasTwoTileServices_guideToEdit_haveMatchString() {
|
||||
setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME,
|
||||
PLACEHOLDER_TILE_NAME);
|
||||
setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME2,
|
||||
PLACEHOLDER_TILE_NAME2);
|
||||
|
||||
final CharSequence tileTooltipContent =
|
||||
mFragment.getTileTooltipContent(QuickSettingsTooltipType.GUIDE_TO_EDIT);
|
||||
final CharSequence tileName =
|
||||
mFragment.loadTileLabel(mContext, mFragment.getTileComponentName());
|
||||
assertThat(tileTooltipContent.toString()).isEqualTo(
|
||||
mContext.getString(R.string.accessibility_service_qs_tooltips_content, tileName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTileTooltipContent_hasTwoTileServices_guideToDirectUse_haveMatchString() {
|
||||
setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME,
|
||||
PLACEHOLDER_TILE_NAME);
|
||||
setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME2,
|
||||
PLACEHOLDER_TILE_NAME2);
|
||||
|
||||
final CharSequence tileTooltipContent =
|
||||
mFragment.getTileTooltipContent(QuickSettingsTooltipType.GUIDE_TO_DIRECT_USE);
|
||||
final CharSequence tileName =
|
||||
mFragment.loadTileLabel(mContext, mFragment.getTileComponentName());
|
||||
assertThat(tileTooltipContent.toString()).isEqualTo(
|
||||
mContext.getString(
|
||||
R.string.accessibility_service_auto_added_qs_tooltips_content, tileName));
|
||||
}
|
||||
|
||||
private void setupTileService(String packageName, String name, String tileName) {
|
||||
final Intent tileProbe = new Intent(TileService.ACTION_QS_TILE);
|
||||
final ResolveInfo info = new ResolveInfo();
|
||||
info.serviceInfo = new FakeServiceInfo();
|
||||
info.serviceInfo.packageName = PLACEHOLDER_PACKAGE_NAME;
|
||||
info.serviceInfo.name = PLACEHOLDER_TILE_CLASS_NAME;
|
||||
final ResolveInfo info2 = new ResolveInfo();
|
||||
info2.serviceInfo = new FakeServiceInfo2();
|
||||
info2.serviceInfo.packageName = PLACEHOLDER_PACKAGE_NAME;
|
||||
info2.serviceInfo.name = PLACEHOLDER_TILE_CLASS_NAME2;
|
||||
info.serviceInfo = new FakeServiceInfo(packageName, name, tileName);
|
||||
final ShadowPackageManager shadowPackageManager =
|
||||
Shadows.shadowOf(mContext.getPackageManager());
|
||||
shadowPackageManager.setResolveInfosForIntent(tileProbe, Arrays.asList(info, info2));
|
||||
|
||||
final CharSequence tileName = mFragment.getTileName();
|
||||
assertThat(tileName.toString()).isEqualTo(PLACEHOLDER_TILE_NAME);
|
||||
shadowPackageManager.addResolveInfoForIntent(tileProbe, info);
|
||||
}
|
||||
|
||||
private static class FakeServiceInfo extends ServiceInfo {
|
||||
public String loadLabel(PackageManager mgr) {
|
||||
return PLACEHOLDER_TILE_NAME;
|
||||
}
|
||||
}
|
||||
private String mTileName;
|
||||
|
||||
FakeServiceInfo(String packageName, String name, String tileName) {
|
||||
this.packageName = packageName;
|
||||
this.name = name;
|
||||
mTileName = tileName;
|
||||
}
|
||||
|
||||
private static class FakeServiceInfo2 extends ServiceInfo {
|
||||
public String loadLabel(PackageManager mgr) {
|
||||
return PLACEHOLDER_TILE_NAME2;
|
||||
return mTileName;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -34,6 +34,9 @@ import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -44,8 +47,6 @@ import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.Shadows;
|
||||
import org.robolectric.shadows.ShadowPackageManager;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/** Tests for {@link ToggleAccessibilityServicePreferenceFragment} */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class ToggleAccessibilityServicePreferenceFragmentTest {
|
||||
@@ -83,53 +84,91 @@ public class ToggleAccessibilityServicePreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTileName_noTileServiceAssigned_returnNull() {
|
||||
assertThat(mFragment.getTileName()).isNull();
|
||||
public void getTileTooltipContent_noTileServiceAssigned_returnNull() {
|
||||
final CharSequence tileTooltipContent =
|
||||
mFragment.getTileTooltipContent(QuickSettingsTooltipType.GUIDE_TO_EDIT);
|
||||
|
||||
assertThat(tileTooltipContent).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTileName_hasOneTileService_haveMatchString() {
|
||||
final Intent tileProbe = new Intent(TileService.ACTION_QS_TILE);
|
||||
final ResolveInfo info = new ResolveInfo();
|
||||
info.serviceInfo = new FakeServiceInfo();
|
||||
info.serviceInfo.packageName = PLACEHOLDER_PACKAGE_NAME;
|
||||
info.serviceInfo.name = PLACEHOLDER_TILE_CLASS_NAME;
|
||||
final ShadowPackageManager shadowPackageManager =
|
||||
Shadows.shadowOf(mContext.getPackageManager());
|
||||
shadowPackageManager.setResolveInfosForIntent(tileProbe, Arrays.asList(info));
|
||||
public void getTileTooltipContent_hasOneTileService_guideToEdit_haveMatchString() {
|
||||
setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME,
|
||||
PLACEHOLDER_TILE_NAME);
|
||||
|
||||
final CharSequence tileName = mFragment.getTileName();
|
||||
assertThat(tileName.toString()).isEqualTo(PLACEHOLDER_TILE_NAME);
|
||||
final CharSequence tileTooltipContent =
|
||||
mFragment.getTileTooltipContent(QuickSettingsTooltipType.GUIDE_TO_EDIT);
|
||||
final CharSequence tileName =
|
||||
mFragment.loadTileLabel(mContext, mFragment.getTileComponentName());
|
||||
assertThat(tileTooltipContent.toString()).isEqualTo(
|
||||
mContext.getString(R.string.accessibility_service_qs_tooltips_content, tileName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTileName_hasTwoTileServices_haveMatchString() {
|
||||
public void getTileTooltipContent_hasOneTileService_guideToDirectUse_haveMatchString() {
|
||||
setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME,
|
||||
PLACEHOLDER_TILE_NAME);
|
||||
|
||||
final CharSequence tileTooltipContent =
|
||||
mFragment.getTileTooltipContent(QuickSettingsTooltipType.GUIDE_TO_DIRECT_USE);
|
||||
final CharSequence tileName =
|
||||
mFragment.loadTileLabel(mContext, mFragment.getTileComponentName());
|
||||
assertThat(tileTooltipContent.toString()).isEqualTo(
|
||||
mContext.getString(
|
||||
R.string.accessibility_service_auto_added_qs_tooltips_content, tileName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTileTooltipContent_hasTwoTileServices_guideToEdit_haveMatchString() {
|
||||
setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME,
|
||||
PLACEHOLDER_TILE_NAME);
|
||||
setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME2,
|
||||
PLACEHOLDER_TILE_NAME2);
|
||||
|
||||
final CharSequence tileTooltipContent =
|
||||
mFragment.getTileTooltipContent(QuickSettingsTooltipType.GUIDE_TO_EDIT);
|
||||
final CharSequence tileName =
|
||||
mFragment.loadTileLabel(mContext, mFragment.getTileComponentName());
|
||||
assertThat(tileTooltipContent.toString()).isEqualTo(
|
||||
mContext.getString(R.string.accessibility_service_qs_tooltips_content, tileName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTileTooltipContent_hasTwoTileServices_guideToDirectUse_haveMatchString() {
|
||||
setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME,
|
||||
PLACEHOLDER_TILE_NAME);
|
||||
setupTileService(PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME2,
|
||||
PLACEHOLDER_TILE_NAME2);
|
||||
|
||||
final CharSequence tileTooltipContent =
|
||||
mFragment.getTileTooltipContent(QuickSettingsTooltipType.GUIDE_TO_DIRECT_USE);
|
||||
final CharSequence tileName =
|
||||
mFragment.loadTileLabel(mContext, mFragment.getTileComponentName());
|
||||
assertThat(tileTooltipContent.toString()).isEqualTo(
|
||||
mContext.getString(
|
||||
R.string.accessibility_service_auto_added_qs_tooltips_content, tileName));
|
||||
}
|
||||
|
||||
private void setupTileService(String packageName, String name, String tileName) {
|
||||
final Intent tileProbe = new Intent(TileService.ACTION_QS_TILE);
|
||||
final ResolveInfo info = new ResolveInfo();
|
||||
info.serviceInfo = new FakeServiceInfo();
|
||||
info.serviceInfo.packageName = PLACEHOLDER_PACKAGE_NAME;
|
||||
info.serviceInfo.name = PLACEHOLDER_TILE_CLASS_NAME;
|
||||
final ResolveInfo info2 = new ResolveInfo();
|
||||
info2.serviceInfo = new FakeServiceInfo2();
|
||||
info2.serviceInfo.packageName = PLACEHOLDER_PACKAGE_NAME;
|
||||
info2.serviceInfo.name = PLACEHOLDER_TILE_CLASS_NAME2;
|
||||
info.serviceInfo = new FakeServiceInfo(packageName, name, tileName);
|
||||
final ShadowPackageManager shadowPackageManager =
|
||||
Shadows.shadowOf(mContext.getPackageManager());
|
||||
shadowPackageManager.setResolveInfosForIntent(tileProbe, Arrays.asList(info, info2));
|
||||
|
||||
final CharSequence tileName = mFragment.getTileName();
|
||||
assertThat(tileName.toString()).isEqualTo(PLACEHOLDER_TILE_NAME);
|
||||
shadowPackageManager.addResolveInfoForIntent(tileProbe, info);
|
||||
}
|
||||
|
||||
private static class FakeServiceInfo extends ServiceInfo {
|
||||
public String loadLabel(PackageManager mgr) {
|
||||
return PLACEHOLDER_TILE_NAME;
|
||||
}
|
||||
}
|
||||
private String mTileName;
|
||||
|
||||
FakeServiceInfo(String packageName, String name, String tileName) {
|
||||
this.packageName = packageName;
|
||||
this.name = name;
|
||||
mTileName = tileName;
|
||||
}
|
||||
|
||||
private static class FakeServiceInfo2 extends ServiceInfo {
|
||||
public String loadLabel(PackageManager mgr) {
|
||||
return PLACEHOLDER_TILE_NAME2;
|
||||
return mTileName;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -49,6 +49,7 @@ import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.R;
|
||||
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.testutils.shadow.ShadowFragment;
|
||||
import com.android.settingslib.widget.TopIntroPreference;
|
||||
@@ -77,8 +78,8 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
PLACEHOLDER_PACKAGE_NAME + "tile.placeholder";
|
||||
private static final ComponentName PLACEHOLDER_TILE_COMPONENT_NAME = new ComponentName(
|
||||
PLACEHOLDER_PACKAGE_NAME, PLACEHOLDER_TILE_CLASS_NAME);
|
||||
private static final String PLACEHOLDER_TILE_NAME =
|
||||
PLACEHOLDER_PACKAGE_NAME + "tile.placeholder";
|
||||
private static final String PLACEHOLDER_TILE_TOOLTIP_CONTENT =
|
||||
PLACEHOLDER_PACKAGE_NAME + "tooltip_content";
|
||||
private static final String PLACEHOLDER_DIALOG_TITLE = "title";
|
||||
private static final String DEFAULT_SUMMARY = "default summary";
|
||||
private static final String DEFAULT_DESCRIPTION = "default description";
|
||||
@@ -361,8 +362,8 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
CharSequence getTileName() {
|
||||
return PLACEHOLDER_TILE_NAME;
|
||||
protected CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type) {
|
||||
return PLACEHOLDER_TILE_TOOLTIP_CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user