From 538cc35aed8cc22879e7673d6c63d3eddf739c2f Mon Sep 17 00:00:00 2001 From: shaoweishen Date: Tue, 21 Jan 2025 08:10:13 +0000 Subject: [PATCH] [Physical Keyboard] Fix bugs for input keys dialog set content description on custom radio button and seekbar. fix typo Bug: 374229004 Bug: 374229189 Bug: 374229597 Bug: 389973787 Flag: com.android.settings.keyboard.keyboard_and_touchpad_a11y_new_page_enabled Test: atest packages/apps/Settings/tests/robotests/src/com/android/settings/inputmethod/ Change-Id: I3df4b1558c2bad73d9411a0160725d7a35590cc3 --- ...ialog_keyboard_a11y_input_setting_keys.xml | 1 + res/values/strings.xml | 21 ++++++++++++------- ...AccessibilityBounceKeysDialogFragment.java | 2 ++ ...yboardAccessibilityKeysDialogFragment.java | 19 +++++++++++++---- ...rdAccessibilitySlowKeysDialogFragment.java | 2 ++ 5 files changed, 33 insertions(+), 12 deletions(-) diff --git a/res/layout/dialog_keyboard_a11y_input_setting_keys.xml b/res/layout/dialog_keyboard_a11y_input_setting_keys.xml index d826fee96fd..01f247cdf66 100644 --- a/res/layout/dialog_keyboard_a11y_input_setting_keys.xml +++ b/res/layout/dialog_keyboard_a11y_input_setting_keys.xml @@ -88,6 +88,7 @@ android:layout_width="wrap_content" android:layout_height="48dp" android:layout_gravity="center_vertical" + android:contentDescription="@string/input_setting_keys_custom_title" android:background="@null"/> Custom custom value + + Bounce key threshold time + + Slow key threshold time + Slow keys @@ -4748,17 +4753,17 @@ Mouse keys for %s - Use the \“%s\” keys to move the mouse pointer + Use the \"%s\" keys to move the mouse pointer - Use the \“%s\” key to click the primary mouse button + Use the \"%s\" key to click the primary mouse button - Use the \“%s\” key to press & hold the primary mouse button + Use the \"%s\" key to press & hold the primary mouse button - Use the \“%s\” key to release the primary mouse button + Use the \"%s\" key to release the primary mouse button - Use the \“%1$s\” key to toggle scroll mode. This will make the \“%2$s\” keys scroll the view top, down, left or right + Use the \"%1$s\" key to toggle scroll mode. This will make the \"%2$s\" keys scroll the view top, down, left or right - Use the \“%s\” key to click the secondary mouse button + Use the \"%s\" key to click the secondary mouse button View keyboard shortcuts @@ -4778,7 +4783,7 @@ Mouse - Pointer speed, swap buttons, button customisation + Pointer speed, swap buttons, button customization Pointer speed, gestures @@ -4803,7 +4808,7 @@ Cursor speed - Customise 3-finger tap + Customize 3-finger tap Touchpad acceleration diff --git a/src/com/android/settings/inputmethod/KeyboardAccessibilityBounceKeysDialogFragment.java b/src/com/android/settings/inputmethod/KeyboardAccessibilityBounceKeysDialogFragment.java index 2dc90de84b1..5e5bd0661ed 100644 --- a/src/com/android/settings/inputmethod/KeyboardAccessibilityBounceKeysDialogFragment.java +++ b/src/com/android/settings/inputmethod/KeyboardAccessibilityBounceKeysDialogFragment.java @@ -32,6 +32,8 @@ public class KeyboardAccessibilityBounceKeysDialogFragment extends Bundle bundle = new Bundle(); bundle.putInt(EXTRA_TITLE_RES, R.string.bounce_keys_dialog_title); bundle.putInt(EXTRA_SUBTITLE_RES, R.string.bounce_keys_dialog_subtitle); + bundle.putInt(EXTRA_SEEKBAR_CONTENT_DESCRIPTION, + R.string.input_setting_bounce_keys_seekbar_desc); result.setArguments(bundle); return result; } diff --git a/src/com/android/settings/inputmethod/KeyboardAccessibilityKeysDialogFragment.java b/src/com/android/settings/inputmethod/KeyboardAccessibilityKeysDialogFragment.java index bba47a72fd7..252ce54768a 100644 --- a/src/com/android/settings/inputmethod/KeyboardAccessibilityKeysDialogFragment.java +++ b/src/com/android/settings/inputmethod/KeyboardAccessibilityKeysDialogFragment.java @@ -38,6 +38,7 @@ import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; import org.jspecify.annotations.Nullable; +import java.util.Locale; import java.util.concurrent.TimeUnit; public abstract class KeyboardAccessibilityKeysDialogFragment extends DialogFragment { @@ -45,6 +46,8 @@ public abstract class KeyboardAccessibilityKeysDialogFragment extends DialogFrag private static final long MILLISECOND_IN_SECONDS = TimeUnit.SECONDS.toMillis(1); protected static final String EXTRA_TITLE_RES = "extra_title_res"; protected static final String EXTRA_SUBTITLE_RES = "extra_subtitle_res"; + protected static final String EXTRA_SEEKBAR_CONTENT_DESCRIPTION = + "extra_seekbar_content_description_res"; protected final MetricsFeatureProvider mMetricsFeatureProvider; @@ -67,6 +70,7 @@ public abstract class KeyboardAccessibilityKeysDialogFragment extends DialogFrag super.onCreateDialog(savedInstanceState); int titleRes = getArguments().getInt(EXTRA_TITLE_RES); int subtitleRes = getArguments().getInt(EXTRA_SUBTITLE_RES); + int seekbarContentDescriptionRes = getArguments().getInt(EXTRA_SEEKBAR_CONTENT_DESCRIPTION); Activity activity = getActivity(); View dialoglayout = @@ -121,6 +125,10 @@ public abstract class KeyboardAccessibilityKeysDialogFragment extends DialogFrag titleTextView.setText(titleRes); subTitleTextView.setText(subtitleRes); + if (seekbarContentDescriptionRes != 0) { + customProgressBar.setContentDescription( + getContext().getString(seekbarContentDescriptionRes)); + } customProgressBar.incrementProgressBy(CUSTOM_PROGRESS_INTERVAL); customProgressBar.setProgress(1); View customValueView = accessibilityKeyDialog.findViewById( @@ -141,7 +149,9 @@ public abstract class KeyboardAccessibilityKeysDialogFragment extends DialogFrag customProgressBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { - customValueTextView.setText(progressToThresholdInSecond(progress)); + String threshold = progressToThresholdInSecond(progress); + customValueTextView.setText(threshold); + customProgressBar.setContentDescription(threshold); } @Override @@ -162,9 +172,10 @@ public abstract class KeyboardAccessibilityKeysDialogFragment extends DialogFrag return accessibilityKeyDialog; } - private static String progressToThresholdInSecond(int progress) { - return String.valueOf((double) progress * CUSTOM_PROGRESS_INTERVAL - / MILLISECOND_IN_SECONDS); + private String progressToThresholdInSecond(int progress) { + return (double) progress * CUSTOM_PROGRESS_INTERVAL + / MILLISECOND_IN_SECONDS + " " + TimeUnit.SECONDS.name().toLowerCase( + Locale.getDefault()); } private void initStateBasedOnThreshold(RadioGroup cannedValueRadioGroup, diff --git a/src/com/android/settings/inputmethod/KeyboardAccessibilitySlowKeysDialogFragment.java b/src/com/android/settings/inputmethod/KeyboardAccessibilitySlowKeysDialogFragment.java index fa3b6858cd5..e411d7ab5b6 100644 --- a/src/com/android/settings/inputmethod/KeyboardAccessibilitySlowKeysDialogFragment.java +++ b/src/com/android/settings/inputmethod/KeyboardAccessibilitySlowKeysDialogFragment.java @@ -32,6 +32,8 @@ public class KeyboardAccessibilitySlowKeysDialogFragment extends Bundle bundle = new Bundle(); bundle.putInt(EXTRA_TITLE_RES, R.string.slow_keys); bundle.putInt(EXTRA_SUBTITLE_RES, R.string.slow_keys_summary); + bundle.putInt(EXTRA_SEEKBAR_CONTENT_DESCRIPTION, + R.string.input_setting_slow_keys_seekbar_desc); result.setArguments(bundle); return result; }