[Physical Keyboard] Update Input Setting Dialog
1. update button style to use custom one 2. use scrollview so it won't be truncated in shorter screen Bug:389973784 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: I57765e88751b6090606d56bbe2335813ef7fd2fc
This commit is contained in:
@@ -15,122 +15,161 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<ScrollView
|
||||||
android:layout_width="match_parent"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_height="match_parent"
|
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||||
android:gravity="center_horizontal"
|
android:id="@+id/input_keys_dialog_scroll_view"
|
||||||
android:orientation="vertical">
|
android:gravity="center_horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
<TextView
|
android:layout_height="match_parent">
|
||||||
android:id="@+id/input_setting_keys_dialog_title"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:textSize="20sp"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
|
||||||
android:fontFamily="@*android:string/config_headlineFontFamilyMedium"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/input_setting_keys_dialog_subtitle"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginHorizontal="26dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<RadioGroup
|
|
||||||
android:id="@+id/input_setting_keys_value_group"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="20dp"
|
|
||||||
android:layout_marginTop="16dp">
|
|
||||||
|
|
||||||
<RadioButton
|
|
||||||
android:id="@+id/input_setting_keys_value_200"
|
|
||||||
android:text="@string/input_setting_keys_dialog_option_200"
|
|
||||||
android:paddingStart="12dp"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:layout_gravity="start|center_vertical"
|
|
||||||
android:background="@null"/>
|
|
||||||
<RadioButton
|
|
||||||
android:id="@+id/input_setting_keys_value_400"
|
|
||||||
android:text="@string/input_setting_keys_dialog_option_400"
|
|
||||||
android:paddingStart="12dp"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:layout_gravity="start|center_vertical"
|
|
||||||
android:layout_marginTop="6dp"
|
|
||||||
android:background="@null"/>
|
|
||||||
<RadioButton
|
|
||||||
android:id="@+id/input_setting_keys_value_600"
|
|
||||||
android:text="@string/input_setting_keys_dialog_option_600"
|
|
||||||
android:paddingStart="12dp"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:layout_gravity="start|center_vertical"
|
|
||||||
android:layout_marginTop="6dp"
|
|
||||||
android:background="@null"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:id="@+id/modifier_key_fragment_container"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/input_setting_keys_dialog_title"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginVertical="6dp">
|
android:layout_marginTop="16dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:fontFamily="@*android:string/config_headlineFontFamilyMedium"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/input_setting_keys_dialog_subtitle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="26dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
android:id="@+id/input_setting_keys_value_group"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="20dp"
|
||||||
|
android:layout_marginTop="16dp">
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/input_setting_keys_value_custom"
|
android:id="@+id/input_setting_keys_value_200"
|
||||||
|
android:text="@string/input_setting_keys_dialog_option_200"
|
||||||
android:paddingStart="12dp"
|
android:paddingStart="12dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="start|center_vertical"
|
||||||
android:contentDescription="@string/input_setting_keys_custom_title"
|
|
||||||
android:background="@null"/>
|
android:background="@null"/>
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/input_setting_keys_value_400"
|
||||||
|
android:text="@string/input_setting_keys_dialog_option_400"
|
||||||
|
android:paddingStart="12dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_gravity="start|center_vertical"
|
||||||
|
android:layout_marginTop="6dp"
|
||||||
|
android:background="@null"/>
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/input_setting_keys_value_600"
|
||||||
|
android:text="@string/input_setting_keys_dialog_option_600"
|
||||||
|
android:paddingStart="12dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_gravity="start|center_vertical"
|
||||||
|
android:layout_marginTop="6dp"
|
||||||
|
android:background="@null"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/input_setting_keys_custom_value_option"
|
android:orientation="horizontal"
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="48dp"
|
android:layout_marginVertical="6dp">
|
||||||
android:layout_gravity="center_vertical"
|
<RadioButton
|
||||||
android:gravity="center_vertical"
|
android:id="@+id/input_setting_keys_value_custom"
|
||||||
android:paddingEnd="16dp">
|
android:paddingStart="12dp"
|
||||||
<TextView
|
android:layout_width="wrap_content"
|
||||||
android:id="@+id/input_setting_keys_value_custom_title"
|
android:layout_height="48dp"
|
||||||
android:text="@string/input_setting_keys_custom_title"
|
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"/>
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/input_setting_keys_value_custom_value"
|
|
||||||
android:text="@string/input_setting_keys_custom_value"
|
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginTop="8dp"
|
android:contentDescription="@string/input_setting_keys_custom_title"
|
||||||
android:visibility="gone"/>
|
android:background="@null"/>
|
||||||
<SeekBar
|
<LinearLayout
|
||||||
android:id="@+id/input_setting_keys_value_custom_slider"
|
android:id="@+id/input_setting_keys_custom_value_option"
|
||||||
android:paddingStart="8dp"
|
android:orientation="vertical"
|
||||||
android:paddingEnd="36dp"
|
|
||||||
android:min="1"
|
|
||||||
android:max="50"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="48dp"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:progressBackgroundTint="@color/input_dialog_slider_progress_background"
|
android:gravity="center_vertical"
|
||||||
android:progressTint="@color/input_dialog_slider_progress"
|
android:paddingEnd="16dp">
|
||||||
android:thumbTint="@color/input_dialog_slider_progress"
|
<TextView
|
||||||
android:layout_marginTop="8dp"
|
android:id="@+id/input_setting_keys_value_custom_title"
|
||||||
android:visibility="gone"/>
|
android:text="@string/input_setting_keys_custom_title"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/input_setting_keys_value_custom_value"
|
||||||
|
android:text="@string/input_setting_keys_custom_value"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
<SeekBar
|
||||||
|
android:id="@+id/input_setting_keys_value_custom_slider"
|
||||||
|
android:paddingStart="8dp"
|
||||||
|
android:paddingEnd="36dp"
|
||||||
|
android:min="1"
|
||||||
|
android:max="50"
|
||||||
|
android:progressBackgroundTint="@color/input_dialog_slider_progress_background"
|
||||||
|
android:progressTint="@color/input_dialog_slider_progress"
|
||||||
|
android:thumbTint="@color/input_dialog_slider_progress"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</RadioGroup>
|
||||||
</RadioGroup>
|
|
||||||
|
|
||||||
</LinearLayout>
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="12dp"
|
||||||
|
android:layout_marginEnd="12dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:layout_marginBottom="6dp">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/cancel_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="6dp"
|
||||||
|
android:layout_marginBottom="6dp"
|
||||||
|
android:paddingVertical="14dp"
|
||||||
|
android:layout_toStartOf="@+id/done_button"
|
||||||
|
style="@style/SettingsLibActionButton"
|
||||||
|
android:text="@string/cancel"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/done_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="6dp"
|
||||||
|
android:layout_marginBottom="6dp"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:paddingVertical="14dp"
|
||||||
|
style="@style/SettingsLibActionButton"
|
||||||
|
android:text="@string/done"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
@@ -25,6 +25,7 @@ import android.os.Bundle;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
import android.widget.RadioGroup;
|
import android.widget.RadioGroup;
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
@@ -78,36 +79,41 @@ public abstract class KeyboardAccessibilityKeysDialogFragment extends DialogFrag
|
|||||||
R.layout.dialog_keyboard_a11y_input_setting_keys, null);
|
R.layout.dialog_keyboard_a11y_input_setting_keys, null);
|
||||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity);
|
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity);
|
||||||
dialogBuilder.setView(dialoglayout);
|
dialogBuilder.setView(dialoglayout);
|
||||||
dialogBuilder.setPositiveButton(android.R.string.ok,
|
Button doneButton = dialoglayout.findViewById(R.id.done_button);
|
||||||
(dialog, which) -> {
|
doneButton.setOnClickListener(v -> {
|
||||||
RadioGroup radioGroup =
|
RadioGroup radioGroup =
|
||||||
dialoglayout.findViewById(
|
dialoglayout.findViewById(
|
||||||
R.id.input_setting_keys_value_group);
|
R.id.input_setting_keys_value_group);
|
||||||
SeekBar seekbar = dialoglayout.findViewById(
|
SeekBar seekbar = dialoglayout.findViewById(
|
||||||
R.id.input_setting_keys_value_custom_slider);
|
R.id.input_setting_keys_value_custom_slider);
|
||||||
RadioButton customRadioButton = dialoglayout.findViewById(
|
RadioButton customRadioButton = dialoglayout.findViewById(
|
||||||
R.id.input_setting_keys_value_custom);
|
R.id.input_setting_keys_value_custom);
|
||||||
int threshold;
|
int threshold;
|
||||||
if (customRadioButton.isChecked()) {
|
if (customRadioButton.isChecked()) {
|
||||||
threshold = seekbar.getProgress() * CUSTOM_PROGRESS_INTERVAL;
|
threshold = seekbar.getProgress() * CUSTOM_PROGRESS_INTERVAL;
|
||||||
} else {
|
} else {
|
||||||
int checkedRadioButtonId = radioGroup.getCheckedRadioButtonId();
|
int checkedRadioButtonId = radioGroup.getCheckedRadioButtonId();
|
||||||
if (checkedRadioButtonId == R.id.input_setting_keys_value_600) {
|
if (checkedRadioButtonId == R.id.input_setting_keys_value_600) {
|
||||||
threshold = 600;
|
threshold = 600;
|
||||||
} else if (checkedRadioButtonId
|
} else if (checkedRadioButtonId
|
||||||
== R.id.input_setting_keys_value_400) {
|
== R.id.input_setting_keys_value_400) {
|
||||||
threshold = 400;
|
threshold = 400;
|
||||||
} else if (checkedRadioButtonId
|
} else if (checkedRadioButtonId
|
||||||
== R.id.input_setting_keys_value_200) {
|
== R.id.input_setting_keys_value_200) {
|
||||||
threshold = 200;
|
threshold = 200;
|
||||||
} else {
|
} else {
|
||||||
threshold = 0;
|
threshold = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateInputSettingKeysValue(threshold);
|
updateInputSettingKeysValue(threshold);
|
||||||
onCustomValueUpdated(threshold);
|
onCustomValueUpdated(threshold);
|
||||||
})
|
dismiss();
|
||||||
.setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.dismiss());
|
});
|
||||||
|
|
||||||
|
Button cancelButton = dialoglayout.findViewById(R.id.cancel_button);
|
||||||
|
cancelButton.setOnClickListener(v -> {
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
AlertDialog accessibilityKeyDialog = dialogBuilder.create();
|
AlertDialog accessibilityKeyDialog = dialogBuilder.create();
|
||||||
accessibilityKeyDialog.setOnShowListener(dialog -> {
|
accessibilityKeyDialog.setOnShowListener(dialog -> {
|
||||||
RadioGroup cannedValueRadioGroup = accessibilityKeyDialog.findViewById(
|
RadioGroup cannedValueRadioGroup = accessibilityKeyDialog.findViewById(
|
||||||
@@ -162,8 +168,21 @@ public abstract class KeyboardAccessibilityKeysDialogFragment extends DialogFrag
|
|||||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
initStateBasedOnThreshold(cannedValueRadioGroup, customRadioButton, customValueTextView,
|
if (cannedValueRadioGroup.getCheckedRadioButtonId() == -1
|
||||||
customProgressBar);
|
&& !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();
|
final Window window = accessibilityKeyDialog.getWindow();
|
||||||
|
@@ -24,6 +24,7 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.hardware.input.InputSettings;
|
import android.hardware.input.InputSettings;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.RadioGroup;
|
import android.widget.RadioGroup;
|
||||||
|
|
||||||
import androidx.fragment.app.testing.FragmentScenario;
|
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 radioGroup = mAlertDialog.findViewById(R.id.input_setting_keys_value_group);
|
||||||
radioGroup.check(R.id.input_setting_keys_value_200);
|
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();
|
ShadowLooper.idleMainLooper();
|
||||||
|
|
||||||
assertThat(mAlertDialog.isShowing()).isFalse();
|
assertThat(mAlertDialog.isShowing()).isFalse();
|
||||||
|
@@ -24,6 +24,7 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.hardware.input.InputSettings;
|
import android.hardware.input.InputSettings;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.RadioGroup;
|
import android.widget.RadioGroup;
|
||||||
|
|
||||||
import androidx.fragment.app.testing.FragmentScenario;
|
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 radioGroup = mAlertDialog.findViewById(R.id.input_setting_keys_value_group);
|
||||||
radioGroup.check(R.id.input_setting_keys_value_200);
|
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();
|
ShadowLooper.idleMainLooper();
|
||||||
|
|
||||||
assertThat(mAlertDialog.isShowing()).isFalse();
|
assertThat(mAlertDialog.isShowing()).isFalse();
|
||||||
|
Reference in New Issue
Block a user