diff --git a/res/layout/dialog_keyboard_a11y_input_setting_keys.xml b/res/layout/dialog_keyboard_a11y_input_setting_keys.xml
index addc3473276..bba1e2acff6 100644
--- a/res/layout/dialog_keyboard_a11y_input_setting_keys.xml
+++ b/res/layout/dialog_keyboard_a11y_input_setting_keys.xml
@@ -15,122 +15,161 @@
limitations under the License.
-->
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ android:layout_marginTop="16dp"
+ android:textSize="20sp"
+ android:gravity="center_horizontal"
+ android:textColor="?android:attr/textColorPrimary"
+ android:fontFamily="@*android:string/config_headlineFontFamilyMedium"
+ />
+
+
+
+
+
+
+
+
-
-
+
-
+
+ android:gravity="center_vertical"
+ android:paddingEnd="16dp">
+
+
+
+
-
-
+
-
\ No newline at end of file
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/android/settings/inputmethod/KeyboardAccessibilityKeysDialogFragment.java b/src/com/android/settings/inputmethod/KeyboardAccessibilityKeysDialogFragment.java
index 252ce54768a..97d5b24b5ef 100644
--- a/src/com/android/settings/inputmethod/KeyboardAccessibilityKeysDialogFragment.java
+++ b/src/com/android/settings/inputmethod/KeyboardAccessibilityKeysDialogFragment.java
@@ -25,6 +25,7 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
+import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.SeekBar;
@@ -78,36 +79,41 @@ public abstract class KeyboardAccessibilityKeysDialogFragment extends DialogFrag
R.layout.dialog_keyboard_a11y_input_setting_keys, null);
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity);
dialogBuilder.setView(dialoglayout);
- dialogBuilder.setPositiveButton(android.R.string.ok,
- (dialog, which) -> {
- RadioGroup radioGroup =
- dialoglayout.findViewById(
- R.id.input_setting_keys_value_group);
- SeekBar seekbar = dialoglayout.findViewById(
- R.id.input_setting_keys_value_custom_slider);
- RadioButton customRadioButton = dialoglayout.findViewById(
- R.id.input_setting_keys_value_custom);
- int threshold;
- if (customRadioButton.isChecked()) {
- threshold = seekbar.getProgress() * CUSTOM_PROGRESS_INTERVAL;
- } else {
- int checkedRadioButtonId = radioGroup.getCheckedRadioButtonId();
- if (checkedRadioButtonId == R.id.input_setting_keys_value_600) {
- threshold = 600;
- } else if (checkedRadioButtonId
- == R.id.input_setting_keys_value_400) {
- threshold = 400;
- } else if (checkedRadioButtonId
- == R.id.input_setting_keys_value_200) {
- threshold = 200;
- } else {
- threshold = 0;
- }
- }
- updateInputSettingKeysValue(threshold);
- onCustomValueUpdated(threshold);
- })
- .setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.dismiss());
+ Button doneButton = dialoglayout.findViewById(R.id.done_button);
+ doneButton.setOnClickListener(v -> {
+ RadioGroup radioGroup =
+ dialoglayout.findViewById(
+ R.id.input_setting_keys_value_group);
+ SeekBar seekbar = dialoglayout.findViewById(
+ R.id.input_setting_keys_value_custom_slider);
+ RadioButton customRadioButton = dialoglayout.findViewById(
+ R.id.input_setting_keys_value_custom);
+ int threshold;
+ if (customRadioButton.isChecked()) {
+ threshold = seekbar.getProgress() * CUSTOM_PROGRESS_INTERVAL;
+ } else {
+ int checkedRadioButtonId = radioGroup.getCheckedRadioButtonId();
+ if (checkedRadioButtonId == R.id.input_setting_keys_value_600) {
+ threshold = 600;
+ } else if (checkedRadioButtonId
+ == R.id.input_setting_keys_value_400) {
+ threshold = 400;
+ } else if (checkedRadioButtonId
+ == R.id.input_setting_keys_value_200) {
+ threshold = 200;
+ } else {
+ threshold = 0;
+ }
+ }
+ updateInputSettingKeysValue(threshold);
+ onCustomValueUpdated(threshold);
+ dismiss();
+ });
+
+ Button cancelButton = dialoglayout.findViewById(R.id.cancel_button);
+ cancelButton.setOnClickListener(v -> {
+ dismiss();
+ });
AlertDialog accessibilityKeyDialog = dialogBuilder.create();
accessibilityKeyDialog.setOnShowListener(dialog -> {
RadioGroup cannedValueRadioGroup = accessibilityKeyDialog.findViewById(
@@ -162,8 +168,21 @@ public abstract class KeyboardAccessibilityKeysDialogFragment extends DialogFrag
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
- initStateBasedOnThreshold(cannedValueRadioGroup, customRadioButton, customValueTextView,
- customProgressBar);
+ if (cannedValueRadioGroup.getCheckedRadioButtonId() == -1
+ && !customRadioButton.isChecked()) {
+ //if canned radio group and custom are not select, initial check state from input
+ // setting
+ initStateBasedOnThreshold(cannedValueRadioGroup, customRadioButton,
+ customValueTextView,
+ customProgressBar);
+ } else if (customRadioButton.isChecked()) {
+ cannedValueRadioGroup.clearCheck();
+ customRadioButton.setChecked(true);
+ customValueTextView.setVisibility(View.VISIBLE);
+ customValueTextView.setText(
+ progressToThresholdInSecond(customProgressBar.getProgress()));
+ customProgressBar.setVisibility(View.VISIBLE);
+ }
});
final Window window = accessibilityKeyDialog.getWindow();
diff --git a/tests/robotests/src/com/android/settings/inputmethod/KeyboardAccessibilityBounceKeysDialogFragmentTest.java b/tests/robotests/src/com/android/settings/inputmethod/KeyboardAccessibilityBounceKeysDialogFragmentTest.java
index 8e5f84e2191..04e4777308c 100644
--- a/tests/robotests/src/com/android/settings/inputmethod/KeyboardAccessibilityBounceKeysDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/inputmethod/KeyboardAccessibilityBounceKeysDialogFragmentTest.java
@@ -24,6 +24,7 @@ import static com.google.common.truth.Truth.assertThat;
import android.app.AlertDialog;
import android.hardware.input.InputSettings;
import android.os.Bundle;
+import android.widget.Button;
import android.widget.RadioGroup;
import androidx.fragment.app.testing.FragmentScenario;
@@ -70,7 +71,8 @@ public class KeyboardAccessibilityBounceKeysDialogFragmentTest {
RadioGroup radioGroup = mAlertDialog.findViewById(R.id.input_setting_keys_value_group);
radioGroup.check(R.id.input_setting_keys_value_200);
- mAlertDialog.getButton(AlertDialog.BUTTON_POSITIVE).performClick();
+ Button doneButton = mAlertDialog.findViewById(R.id.done_button);
+ doneButton.performClick();
ShadowLooper.idleMainLooper();
assertThat(mAlertDialog.isShowing()).isFalse();
diff --git a/tests/robotests/src/com/android/settings/inputmethod/KeyboardAccessibilitySlowKeysDialogFragmentTest.java b/tests/robotests/src/com/android/settings/inputmethod/KeyboardAccessibilitySlowKeysDialogFragmentTest.java
index 3a3010e7293..145207a08d0 100644
--- a/tests/robotests/src/com/android/settings/inputmethod/KeyboardAccessibilitySlowKeysDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/inputmethod/KeyboardAccessibilitySlowKeysDialogFragmentTest.java
@@ -24,6 +24,7 @@ import static com.google.common.truth.Truth.assertThat;
import android.app.AlertDialog;
import android.hardware.input.InputSettings;
import android.os.Bundle;
+import android.widget.Button;
import android.widget.RadioGroup;
import androidx.fragment.app.testing.FragmentScenario;
@@ -70,7 +71,8 @@ public class KeyboardAccessibilitySlowKeysDialogFragmentTest {
RadioGroup radioGroup = mAlertDialog.findViewById(R.id.input_setting_keys_value_group);
radioGroup.check(R.id.input_setting_keys_value_200);
- mAlertDialog.getButton(AlertDialog.BUTTON_POSITIVE).performClick();
+ Button doneButton = mAlertDialog.findViewById(R.id.done_button);
+ doneButton.performClick();
ShadowLooper.idleMainLooper();
assertThat(mAlertDialog.isShowing()).isFalse();