Fix certain Accessibility Settings subpages use wrong resources

Root cause: Portrait mode does not always respect the sw600dp qualifier and instead uses the phone (default) resources.
Solution: Using the product to customize the tablet and phone cases is better way than using the configuration qualifier.

Bug: 269130587
Test: Manual testing
Change-Id: I90cc44f1e9bccf8950a4d89f70119ba5e3c0bfdc
This commit is contained in:
menghanli
2023-02-14 17:13:36 +08:00
parent 44b02abb2a
commit bea25c7513
55 changed files with 108 additions and 41 deletions

View File

@@ -692,4 +692,19 @@
<!-- Whether auto data switching on secondary SIM enables cross-SIM calling on both SIMs. -->
<bool name="config_auto_data_switch_enables_cross_sim_calling">false</bool>
<!-- The illustration for those screen are not in one of below type. This file should be a video in JSON format. -->
<item name="a11y_timeout_banner" type="raw" product="default">@raw/accessibility_timeout_banner</item>
<item name="a11y_timeout_banner" type="raw" product="tablet">@raw/accessibility_timeout_banner_tablet</item>
<item name="a11y_shortcut_type_triple_tap" type="raw" product="default">@raw/accessibility_shortcut_type_triple_tap</item>
<item name="a11y_shortcut_type_triple_tap" type="raw" product="tablet">@raw/accessibility_shortcut_type_triple_tap_tablet</item>
<item name="a11y_color_inversion_banner" type="raw" product="default">@raw/accessibility_color_inversion_banner</item>
<item name="a11y_color_inversion_banner" type="raw" product="tablet">@raw/accessibility_color_inversion_banner_tablet</item>
<item name="a11y_magnification_banner" type="raw" product="default">@raw/accessibility_magnification_banner</item>
<item name="a11y_magnification_banner" type="raw" product="tablet">@raw/accessibility_magnification_banner_tablet</item>
<item name="a11y_extra_dim_banner" type="raw" product="default">@raw/extra_dim_banner</item>
<item name="a11y_extra_dim_banner" type="raw" product="tablet">@raw/extra_dim_banner_tablet</item>
</resources>

58
res/values/drawables.xml Normal file
View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2023 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<drawable name="a11y_shortcut_type_software_gesture_talkback" product="default">@drawable/accessibility_shortcut_type_software_gesture_talkback</drawable>
<drawable name="a11y_shortcut_type_software_gesture_talkback" product="tablet">@drawable/accessibility_shortcut_type_software_gesture_talkback_tablet</drawable>
<drawable name="a11y_button_preview_base" product="default">@drawable/accessibility_button_preview_base</drawable>
<drawable name="a11y_button_preview_base" product="tablet">@drawable/accessibility_button_preview_base_tablet</drawable>
<drawable name="a11y_button_preview_large_floating_menu" product="default">@drawable/accessibility_button_preview_large_floating_menu</drawable>
<drawable name="a11y_button_preview_large_floating_menu" product="tablet">@drawable/accessibility_button_preview_large_floating_menu_tablet</drawable>
<drawable name="a11y_button_preview_small_floating_menu" product="default">@drawable/accessibility_button_preview_small_floating_menu</drawable>
<drawable name="a11y_button_preview_small_floating_menu" product="tablet">@drawable/accessibility_button_preview_small_floating_menu_tablet</drawable>
<drawable name="a11y_button_preview_three_finger" product="default">@drawable/accessibility_button_preview_three_finger</drawable>
<drawable name="a11y_button_preview_three_finger" product="tablet">@drawable/accessibility_button_preview_three_finger_tablet</drawable>
<drawable name="a11y_button_preview_two_finger" product="default">@drawable/accessibility_button_preview_two_finger</drawable>
<drawable name="a11y_button_preview_two_finger" product="tablet">@drawable/accessibility_button_preview_two_finger_tablet</drawable>
<drawable name="a11y_captioning_banner" product="default">@drawable/accessibility_captioning_banner</drawable>
<drawable name="a11y_captioning_banner" product="tablet">@drawable/accessibility_captioning_banner_tablet</drawable>
<drawable name="a11y_shortcut_type_hardware" product="default">@drawable/accessibility_shortcut_type_hardware</drawable>
<drawable name="a11y_shortcut_type_hardware" product="tablet">@drawable/accessibility_shortcut_type_hardware_tablet</drawable>
<drawable name="a11y_shortcut_type_software" product="default">@drawable/accessibility_shortcut_type_software</drawable>
<drawable name="a11y_shortcut_type_software" product="tablet">@drawable/accessibility_shortcut_type_software_tablet</drawable>
<drawable name="a11y_shortcut_type_software_floating" product="default">@drawable/accessibility_shortcut_type_software_floating</drawable>
<drawable name="a11y_shortcut_type_software_floating" product="tablet">@drawable/accessibility_shortcut_type_software_floating_tablet</drawable>
<drawable name="a11y_shortcut_type_software_gesture" product="default">@drawable/accessibility_shortcut_type_software_gesture</drawable>
<drawable name="a11y_shortcut_type_software_gesture" product="tablet">@drawable/accessibility_shortcut_type_software_gesture_tablet</drawable>
<drawable name="a11y_magnification_mode_fullscreen" product="default">@drawable/accessibility_magnification_mode_fullscreen</drawable>
<drawable name="a11y_magnification_mode_fullscreen" product="tablet">@drawable/accessibility_magnification_mode_fullscreen_tablet</drawable>
<drawable name="a11y_magnification_mode_switch" product="default">@drawable/accessibility_magnification_mode_switch</drawable>
<drawable name="a11y_magnification_mode_switch" product="tablet">@drawable/accessibility_magnification_mode_switch_tablet</drawable>
<drawable name="a11y_magnification_mode_window" product="default">@drawable/accessibility_magnification_mode_window</drawable>
<drawable name="a11y_magnification_mode_window" product="tablet">@drawable/accessibility_magnification_mode_window_tablet</drawable>
</resources>

View File

@@ -26,7 +26,7 @@
<com.android.settingslib.widget.IllustrationPreference
android:key="accessibility_control_timeout_banner"
settings:lottie_rawRes="@raw/accessibility_timeout_banner"/>
settings:lottie_rawRes="@raw/a11y_timeout_banner"/>
<com.android.settingslib.widget.SelectorWithWidgetPreference
android:key="accessibility_control_timeout_default"

View File

@@ -27,7 +27,7 @@
<com.android.settingslib.widget.IllustrationPreference
android:key="captioning_preview"
android:selectable="false"
settings:lottie_rawRes="@drawable/accessibility_captioning_banner"
settings:lottie_rawRes="@drawable/a11y_captioning_banner"
settings:searchable="false" />
<com.android.settings.widget.SettingsMainSwitchPreference

View File

@@ -111,15 +111,15 @@ public class AccessibilityButtonPreviewPreferenceController extends BasePreferen
final int opacity = (int) (Settings.Secure.getFloat(mContentResolver,
Settings.Secure.ACCESSIBILITY_FLOATING_MENU_OPACITY, DEFAULT_OPACITY) * 100);
final int floatingMenuIconId = (size == SMALL_SIZE)
? R.drawable.accessibility_button_preview_small_floating_menu
: R.drawable.accessibility_button_preview_large_floating_menu;
? R.drawable.a11y_button_preview_small_floating_menu
: R.drawable.a11y_button_preview_large_floating_menu;
mIllustrationPreference.setImageDrawable(
getAccessibilityPreviewDrawable(floatingMenuIconId, opacity));
} else if (AccessibilityUtil.isGestureNavigateEnabled(mContext)) {
mIllustrationPreference.setImageDrawable(mContext.getDrawable(
AccessibilityUtil.isTouchExploreEnabled(mContext)
? R.drawable.accessibility_button_preview_three_finger
: R.drawable.accessibility_button_preview_two_finger));
? R.drawable.a11y_button_preview_three_finger
: R.drawable.a11y_button_preview_two_finger));
} else {
mIllustrationPreference.setImageDrawable(
mContext.getDrawable(R.drawable.accessibility_button_navigation));

View File

@@ -163,17 +163,18 @@ public class AccessibilityDialogUtils {
}
/**
* Updates the software shortcut in edit shortcut dialog.
* Updates the shortcut content in edit shortcut dialog.
*
* @param context A valid context
* @param editShortcutDialog Need to be a type of edit shortcut dialog
* @return True if the update is successful
*/
public static boolean updateSoftwareShortcutInDialog(Context context,
public static boolean updateShortcutInDialog(Context context,
Dialog editShortcutDialog) {
final View container = editShortcutDialog.findViewById(R.id.container_layout);
if (container != null) {
initSoftwareShortcut(context, container);
initHardwareShortcut(context, container);
return true;
}
return false;
@@ -340,7 +341,7 @@ public class AccessibilityDialogUtils {
final CharSequence summary = context.getText(
R.string.accessibility_shortcut_edit_dialog_summary_hardware);
setupShortcutWidget(dialogView, title, summary,
R.drawable.accessibility_shortcut_type_hardware);
R.drawable.a11y_shortcut_type_hardware);
}
private static void initMagnifyShortcut(Context context, View view) {
@@ -354,7 +355,7 @@ public class AccessibilityDialogUtils {
summary = MessageFormat.format(summary, arguments);
setupShortcutWidgetWithImageRawResource(context, dialogView, title, summary,
R.raw.accessibility_shortcut_type_triple_tap);
R.raw.a11y_shortcut_type_triple_tap);
}
private static void initAdvancedWidget(View view) {
@@ -409,13 +410,13 @@ public class AccessibilityDialogUtils {
private static int retrieveSoftwareShortcutImageResId(Context context) {
int resId;
if (AccessibilityUtil.isFloatingMenuEnabled(context)) {
resId = R.drawable.accessibility_shortcut_type_software_floating;
resId = R.drawable.a11y_shortcut_type_software_floating;
} else if (AccessibilityUtil.isGestureNavigateEnabled(context)) {
resId = AccessibilityUtil.isTouchExploreEnabled(context)
? R.drawable.accessibility_shortcut_type_software_gesture_talkback
: R.drawable.accessibility_shortcut_type_software_gesture;
? R.drawable.a11y_shortcut_type_software_gesture_talkback
: R.drawable.a11y_shortcut_type_software_gesture;
} else {
resId = R.drawable.accessibility_shortcut_type_software;
resId = R.drawable.a11y_shortcut_type_software;
}
return resId;
}

View File

@@ -392,7 +392,7 @@ public final class AccessibilityGestureNavigationTutorial {
final CharSequence title =
context.getText(R.string.accessibility_tutorial_dialog_title_volume);
final View image =
createIllustrationView(context, R.drawable.accessibility_shortcut_type_hardware);
createIllustrationView(context, R.drawable.a11y_shortcut_type_hardware);
final ImageView indicatorIcon =
createImageView(context, R.drawable.ic_accessibility_page_indicator);
final CharSequence instruction =
@@ -408,7 +408,7 @@ public final class AccessibilityGestureNavigationTutorial {
context.getText(R.string.accessibility_tutorial_dialog_title_triple);
final View image =
createIllustrationViewWithImageRawResource(context,
R.raw.accessibility_shortcut_type_triple_tap);
R.raw.a11y_shortcut_type_triple_tap);
final CharSequence instruction =
context.getText(R.string.accessibility_tutorial_dialog_message_triple);
final ImageView indicatorIcon =
@@ -440,13 +440,13 @@ public final class AccessibilityGestureNavigationTutorial {
private static View createSoftwareImage(Context context) {
int resId;
if (AccessibilityUtil.isFloatingMenuEnabled(context)) {
resId = R.drawable.accessibility_shortcut_type_software_floating;
resId = R.drawable.a11y_shortcut_type_software_floating;
} else if (AccessibilityUtil.isGestureNavigateEnabled(context)) {
resId = AccessibilityUtil.isTouchExploreEnabled(context)
? R.drawable.accessibility_shortcut_type_software_gesture_talkback
: R.drawable.accessibility_shortcut_type_software_gesture;
? R.drawable.a11y_shortcut_type_software_gesture_talkback
: R.drawable.a11y_shortcut_type_software_gesture;
} else {
resId = R.drawable.accessibility_shortcut_type_software;
resId = R.drawable.a11y_shortcut_type_software;
}
return createIllustrationView(context, resId);
}

View File

@@ -53,7 +53,7 @@ public class AccessibilityLayerDrawable extends LayerDrawable {
*/
public static AccessibilityLayerDrawable createLayerDrawable(Context context, int resId,
int opacity) {
final Drawable bg = context.getDrawable(R.drawable.accessibility_button_preview_base);
final Drawable bg = context.getDrawable(R.drawable.a11y_button_preview_base);
final AccessibilityLayerDrawable basicDrawable = new AccessibilityLayerDrawable(
new Drawable[]{bg, null});

View File

@@ -88,15 +88,15 @@ public class MagnificationModePreferenceController extends BasePreferenceControl
private void initModeInfos() {
mModeInfos.add(new MagnificationModeInfo(mContext.getText(
R.string.accessibility_magnification_mode_dialog_option_full_screen), null,
R.drawable.ic_illustration_fullscreen, MagnificationMode.FULLSCREEN));
R.drawable.a11y_magnification_mode_fullscreen, MagnificationMode.FULLSCREEN));
mModeInfos.add(new MagnificationModeInfo(
mContext.getText(R.string.accessibility_magnification_mode_dialog_option_window),
null, R.drawable.ic_illustration_window, MagnificationMode.WINDOW));
null, R.drawable.a11y_magnification_mode_window, MagnificationMode.WINDOW));
mModeInfos.add(new MagnificationModeInfo(
mContext.getText(R.string.accessibility_magnification_mode_dialog_option_switch),
mContext.getText(
R.string.accessibility_magnification_area_settings_mode_switch_summary),
R.drawable.ic_illustration_switch, MagnificationMode.ALL));
R.drawable.a11y_magnification_mode_switch, MagnificationMode.ALL));
}
@Override

View File

@@ -68,7 +68,7 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
mTopIntroTitle = getText(R.string.accessibility_display_inversion_preference_intro_text);
mImageUri = new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
.authority(getPrefContext().getPackageName())
.appendPath(String.valueOf(R.raw.accessibility_color_inversion_banner))
.appendPath(String.valueOf(R.raw.a11y_color_inversion_banner))
.build();
final View view = super.onCreateView(inflater, container, savedInstanceState);
updateFooterPreference();

View File

@@ -831,14 +831,7 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
if (mDialog == null || !mDialog.isShowing()) {
return;
}
// Content in software shortcut need to be adjusted depend on the accessibility button
// mode status which can be changed in background.
final boolean valueChanged = mSavedAccessibilityFloatingMenuEnabled
!= AccessibilityUtil.isFloatingMenuEnabled(getContext());
if (valueChanged) {
AccessibilityDialogUtils.updateSoftwareShortcutInDialog(getContext(), mDialog);
}
AccessibilityDialogUtils.updateShortcutInDialog(getContext(), mDialog);
}
@VisibleForTesting

View File

@@ -75,7 +75,7 @@ public class ToggleReduceBrightColorsPreferenceFragment extends ToggleFeaturePre
Bundle savedInstanceState) {
mImageUri = new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
.authority(getPrefContext().getPackageName())
.appendPath(String.valueOf(R.raw.extra_dim_banner))
.appendPath(String.valueOf(R.raw.a11y_extra_dim_banner))
.build();
mComponentName = REDUCE_BRIGHT_COLORS_COMPONENT_NAME;
mPackageName = getText(R.string.reduce_bright_colors_preference_title);

View File

@@ -96,7 +96,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
mPackageName = getString(R.string.accessibility_screen_magnification_title);
mImageUri = new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
.authority(getPrefContext().getPackageName())
.appendPath(String.valueOf(R.raw.accessibility_magnification_banner))
.appendPath(String.valueOf(R.raw.a11y_magnification_banner))
.build();
mTouchExplorationStateChangeListener = isTouchExplorationEnabled -> {
removeDialog(DialogEnums.EDIT_SHORTCUT);

View File

@@ -92,7 +92,7 @@ public class AccessibilityButtonPreviewPreferenceControllerTest {
final Drawable smallFloatingMenuWithTenOpacityDrawable =
AccessibilityLayerDrawable.createLayerDrawable(mContext,
R.drawable.accessibility_button_preview_small_floating_menu, 10);
R.drawable.a11y_button_preview_small_floating_menu, 10);
assertThat(
mController.mIllustrationPreference.getImageDrawable().getConstantState())
.isEqualTo(smallFloatingMenuWithTenOpacityDrawable.getConstantState());

View File

@@ -43,20 +43,20 @@ public class AccessibilityDialogUtilsTest {
}
@Test
public void updateSoftwareShortcutInDialog_correctDialogType_success() {
public void updateShortcutInDialog_correctDialogType_success() {
final AlertDialog dialog = AccessibilityDialogUtils.showEditShortcutDialog(
mContext, AccessibilityDialogUtils.DialogType.EDIT_SHORTCUT_GENERIC, "Title",
null);
assertThat(
AccessibilityDialogUtils.updateSoftwareShortcutInDialog(mContext, dialog)).isTrue();
AccessibilityDialogUtils.updateShortcutInDialog(mContext, dialog)).isTrue();
}
@Test
public void updateSoftwareShortcutInDialog_useNotSupportedDialog_fail() {
public void updateShortcutInDialog_useNotSupportedDialog_fail() {
final AlertDialog dialog = new AlertDialog.Builder(mContext).setTitle("Title").show();
assertThat(AccessibilityDialogUtils.updateSoftwareShortcutInDialog(mContext,
assertThat(AccessibilityDialogUtils.updateShortcutInDialog(mContext,
dialog)).isFalse();
}

View File

@@ -43,7 +43,7 @@ public class AccessibilityLayerDrawableTest {
@Test
public void createLayerDrawable_configCorrect() {
final Drawable expected1stDrawable = mContext.getDrawable(
R.drawable.accessibility_button_preview_base);
R.drawable.a11y_button_preview_base);
final Drawable expected2ndDrawable = mContext.getDrawable(TEST_RES_ID);
final AccessibilityLayerDrawable actualDrawable =