Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 538cc35a authored by shaoweishen's avatar shaoweishen Committed by Shaowei Shen
Browse files

[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
parent 086c8b79
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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"/>
            <LinearLayout
                android:id="@+id/input_setting_keys_custom_value_option"
+13 −8
Original line number Diff line number Diff line
@@ -4713,6 +4713,11 @@
    <string name="input_setting_keys_custom_title">Custom</string>
    <!-- Option subtitle for the input setting keys threshold dialog for custom value. [CHAR LIMIT=35] -->
    <string name="input_setting_keys_custom_value">custom value</string>
    <!-- Content description for the bounce key threshold dialog for custom value seekbar. [CHAR LIMIT=35] -->
    <string name="input_setting_bounce_keys_seekbar_desc">Bounce key threshold time</string>
    <!-- Content description for the slow key threshold dialog for custom value seekbar. [CHAR LIMIT=35] -->
    <string name="input_setting_slow_keys_seekbar_desc">Slow key threshold time</string>
    <!-- Title for the 'Slow keys' preference switch. [CHAR LIMIT=35] -->
    <string name="slow_keys">Slow keys</string>
@@ -4748,17 +4753,17 @@
    <!-- page title for Mouse key main page. [CHAR LIMIT=NONE] -->
    <string name="mouse_key_main_page_title">Mouse keys for <xliff:g id="keyboard name" example="my keyboard">%s</xliff:g></string>
    <!-- Summary text for Mouse keys directional image. [CHAR LIMIT=NONE] -->
    <string name="mouse_keys_directional_summary">Use the \<xliff:g id="directional_label" example="7,8,9,u,o,j,k,l">%s</xliff:g>\ keys to move the mouse pointer</string>
    <string name="mouse_keys_directional_summary">Use the \"<xliff:g id="directional_label" example="7,8,9,u,o,j,k,l">%s</xliff:g>\" keys to move the mouse pointer</string>
    <!-- Summary text for Mouse keys click image. [CHAR LIMIT=NONE] -->
    <string name="mouse_keys_click_summary">Use the \<xliff:g id="click_label" example="i">%s</xliff:g>\ key to click the primary mouse button</string>
    <string name="mouse_keys_click_summary">Use the \"<xliff:g id="click_label" example="i">%s</xliff:g>\" key to click the primary mouse button</string>
    <!-- Summary text for Mouse keys press hold image. [CHAR LIMIT=NONE] -->
    <string name="mouse_keys_press_hold_summary">Use the \<xliff:g id="press_hold_label" example="m">%s</xliff:g>\ key to press &amp; hold the primary mouse button</string>
    <string name="mouse_keys_press_hold_summary">Use the \"<xliff:g id="press_hold_label" example="m">%s</xliff:g>\" key to press &amp; hold the primary mouse button</string>
    <!-- Summary text for Mouse keys release image. [CHAR LIMIT=NONE] -->
    <string name="mouse_keys_release_summary">Use the \<xliff:g id="release_label" example=",">%s</xliff:g>\ key to release the primary mouse button</string>
    <string name="mouse_keys_release_summary">Use the \"<xliff:g id="release_label" example=",">%s</xliff:g>\" key to release the primary mouse button</string>
    <!-- Summary text for Mouse keys toggle scroll image. [CHAR LIMIT=NONE] -->
    <string name="mouse_keys_toggle_scroll_summary">Use the \<xliff:g id="release_label_1" example=".">%1$s</xliff:g>\ key to toggle scroll mode. This will make the \<xliff:g id="release_label_2" example="8, k, o, u">%2$s</xliff:g>\ keys scroll the view top, down, left or right</string>
    <string name="mouse_keys_toggle_scroll_summary">Use the \"<xliff:g id="release_label_1" example=".">%1$s</xliff:g>\" key to toggle scroll mode. This will make the \"<xliff:g id="release_label_2" example="8, k, o, u">%2$s</xliff:g>\" keys scroll the view top, down, left or right</string>
    <!-- Summary text for Mouse keys click secondary button image. [CHAR LIMIT=NONE] -->
    <string name="mouse_keys_release2_summary">Use the \<xliff:g id="release_2_label" example="/">%s</xliff:g>\ key to click the secondary mouse button</string>
    <string name="mouse_keys_release2_summary">Use the \"<xliff:g id="release_2_label" example="/">%s</xliff:g>\" key to click the secondary mouse button</string>
    <!-- Title for the button to trigger the 'keyboard shortcuts helper' dialog. [CHAR LIMIT=35] -->
    <string name="keyboard_shortcuts_helper">View keyboard shortcuts</string>
@@ -4778,7 +4783,7 @@
    <!-- Title for the button to trigger the 'mouse settings' page if connect with a mouse. [CHAR LIMIT=35] -->
    <string name="mouse_settings">Mouse</string>
    <!-- Summary text for mouse setting page. [CHAR LIMIT=35] -->
    <string name="mouse_settings_summary">Pointer speed, swap buttons, button customisation</string>
    <string name="mouse_settings_summary">Pointer speed, swap buttons, button customization</string>
    <!-- Summary text for the 'trackpad settings' page. [CHAR LIMIT=100] -->
    <string name="trackpad_settings_summary">Pointer speed, gestures</string>
@@ -4803,7 +4808,7 @@
    <!-- Title text for 'Pointer speed'. [CHAR LIMIT=35] -->
    <string name="trackpad_pointer_speed">Cursor speed</string>
    <!-- Title text for 'Three finger tap' touchpad preference. This preference allows the user to select an action that will trigger when they tap three fingers on a touchpad. [CHAR LIMIT=60] -->
    <string name="three_finger_tap_preference_title">Customise 3-finger tap</string>
    <string name="three_finger_tap_preference_title">Customize 3-finger tap</string>
    <!-- Title for the 'Touchpad acceleration' preference switch, which dynamically adjusts cursor movement based on speed. [CHAR LIMIT=60] -->
    <string name="touchpad_acceleration_title">Touchpad acceleration</string>
    <!-- Summary text for the 'Touchpad acceleration' preference switch indicating to users that when this switch is enabled, faster movements with your fingers will move the cursor farther. [CHAR LIMIT=NONE] -->
+2 −0
Original line number Diff line number Diff line
@@ -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;
    }
+15 −4
Original line number Diff line number Diff line
@@ -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,
+2 −0
Original line number Diff line number Diff line
@@ -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;
    }