Support accessibility shorcut secondary action (3/n)
Combine the UI with both shortcut preference and edit dialog. This CL only contains UI and related connections. Related logic implementation will be added in next CL. Since the drawable resources are not ready, put the mock drawables as temporary. Once the drawbles are provided by UX, create a CL to replace the related resources. Bug: 142530063 Bug: 142531156 Test: Maunal Change-Id: I21e4c6e99c2d1731c15d7c9553594160b8809eb5
This commit is contained in:
BIN
res/drawable/accessibility_shortcut_type_hardware.png
Normal file
BIN
res/drawable/accessibility_shortcut_type_hardware.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
BIN
res/drawable/accessibility_shortcut_type_software.png
Normal file
BIN
res/drawable/accessibility_shortcut_type_software.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
BIN
res/drawable/accessibility_shortcut_type_software_gesture.png
Normal file
BIN
res/drawable/accessibility_shortcut_type_software_gesture.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
BIN
res/drawable/accessibility_shortcut_type_triple_tap.png
Normal file
BIN
res/drawable/accessibility_shortcut_type_triple_tap.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.7 KiB |
@@ -60,7 +60,7 @@
|
|||||||
android:paddingBottom="16dp">
|
android:paddingBottom="16dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+android:id/title"
|
android:id="@android:id/title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
@@ -68,7 +68,7 @@
|
|||||||
android:ellipsize="marquee" />
|
android:ellipsize="marquee" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+android:id/summary"
|
android:id="@android:id/summary"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+android:id/title"
|
android:layout_below="@+android:id/title"
|
||||||
|
@@ -4784,6 +4784,16 @@
|
|||||||
<string name="accessibility_tutorial_dialog_message_gesture_settings_with_talkback">To turn an accessibility service on or off, swipe up from the bottom of the screen with three fingers.\n\nTo switch between services, swipe up with three fingers and hold.</string>
|
<string name="accessibility_tutorial_dialog_message_gesture_settings_with_talkback">To turn an accessibility service on or off, swipe up from the bottom of the screen with three fingers.\n\nTo switch between services, swipe up with three fingers and hold.</string>
|
||||||
<!-- Button for the Accessibility tutorial dialog to dismiss the dialog when user clicks it. [CHAR LIMIT=10] -->
|
<!-- Button for the Accessibility tutorial dialog to dismiss the dialog when user clicks it. [CHAR LIMIT=10] -->
|
||||||
<string name="accessibility_tutorial_dialog_button">Got it</string>
|
<string name="accessibility_tutorial_dialog_button">Got it</string>
|
||||||
|
<!-- Title for accessibility shortcut preference for accessibility apps. [CHAR LIMIT=40] -->
|
||||||
|
<string name="accessibility_shortcut_title">Use shortcut to open</string>
|
||||||
|
<!-- Title for accessibility shortcut preference for magnification. [CHAR LIMIT=40] -->
|
||||||
|
<string name="accessibility_magnification_shortcut_title">Use shortcut to magnify</string>
|
||||||
|
<!-- Title for Accessibility edit shortcut dialog. [CHAR LIMIT=40] -->
|
||||||
|
<string name="accessibility_shortcut_edit_dialog_title">Shortcut to open <xliff:g id="service" example="Select to Speak">%1$s</xliff:g></string>
|
||||||
|
<!-- Title for Accessibility edit shortcut dialog in Magnify. [CHAR LIMIT=40] -->
|
||||||
|
<string name="accessibility_shortcut_edit_dialog_title_magnification">Shortcut to magnify</string>
|
||||||
|
<!-- Title for Accessibility edit shortcut dialog in Color correction. [CHAR LIMIT=40] -->
|
||||||
|
<string name="accessibility_shortcut_edit_dialog_title_daltonizer">Shortcut to open Color correction</string>
|
||||||
<!-- Title for software shortcut in Accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
|
<!-- Title for software shortcut in Accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
|
||||||
<string name="accessibility_shortcut_edit_dialog_title_software">Accessibility Button</string>
|
<string name="accessibility_shortcut_edit_dialog_title_software">Accessibility Button</string>
|
||||||
<!-- Title for software shortcut in gesture mode in Accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
|
<!-- Title for software shortcut in gesture mode in Accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
|
||||||
|
@@ -170,7 +170,8 @@ public class AccessibilityEditDialogUtils {
|
|||||||
final String summary = context.getString(
|
final String summary = context.getString(
|
||||||
R.string.accessibility_shortcut_edit_dialog_summary_hardware);
|
R.string.accessibility_shortcut_edit_dialog_summary_hardware);
|
||||||
setupShortcutWidget(dialogView, title, summary,
|
setupShortcutWidget(dialogView, title, summary,
|
||||||
R.drawable.illustration_accessibility_button);
|
R.drawable.accessibility_shortcut_type_hardware);
|
||||||
|
// TODO(b/142531156): Use vector drawable instead of temporal png file to avoid distorted.
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initMagnifyShortcut(Context context, View view) {
|
private static void initMagnifyShortcut(Context context, View view) {
|
||||||
@@ -180,7 +181,8 @@ public class AccessibilityEditDialogUtils {
|
|||||||
final String summary = context.getString(
|
final String summary = context.getString(
|
||||||
R.string.accessibility_shortcut_edit_dialog_summary_triple_tap);
|
R.string.accessibility_shortcut_edit_dialog_summary_triple_tap);
|
||||||
setupShortcutWidget(dialogView, title, summary,
|
setupShortcutWidget(dialogView, title, summary,
|
||||||
R.drawable.illustration_accessibility_button);
|
R.drawable.accessibility_shortcut_type_triple_tap);
|
||||||
|
// TODO(b/142531156): Use vector drawable instead of temporal png file to avoid distorted.
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initAdvancedWidget(View view) {
|
private static void initAdvancedWidget(View view) {
|
||||||
@@ -213,8 +215,9 @@ public class AccessibilityEditDialogUtils {
|
|||||||
|
|
||||||
private static int retrieveImageResId(Context context) {
|
private static int retrieveImageResId(Context context) {
|
||||||
return isGestureNavigateEnabled(context)
|
return isGestureNavigateEnabled(context)
|
||||||
? R.drawable.illustration_accessibility_button
|
? R.drawable.accessibility_shortcut_type_software_gesture
|
||||||
: R.drawable.illustration_accessibility_button;
|
: R.drawable.accessibility_shortcut_type_software;
|
||||||
|
// TODO(b/142531156): Use vector drawable instead of temporal png file to avoid distorted.
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SpannableString getSummaryStringWithIcon(Context context, int lineHeight) {
|
private static SpannableString getSummaryStringWithIcon(Context context, int lineHeight) {
|
||||||
|
@@ -37,10 +37,15 @@ import android.os.UserHandle;
|
|||||||
import android.os.storage.StorageManager;
|
import android.os.storage.StorageManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.view.accessibility.AccessibilityManager;
|
import android.view.accessibility.AccessibilityManager;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.internal.widget.LockPatternUtils;
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -57,11 +62,33 @@ public class ToggleAccessibilityServicePreferenceFragment extends ToggleFeatureP
|
|||||||
private static final int DIALOG_ID_ENABLE_WARNING = 1;
|
private static final int DIALOG_ID_ENABLE_WARNING = 1;
|
||||||
private static final int DIALOG_ID_DISABLE_WARNING = 2;
|
private static final int DIALOG_ID_DISABLE_WARNING = 2;
|
||||||
private static final int DIALOG_ID_LAUNCH_ACCESSIBILITY_TUTORIAL = 3;
|
private static final int DIALOG_ID_LAUNCH_ACCESSIBILITY_TUTORIAL = 3;
|
||||||
|
private static final int DIALOG_ID_EDIT_SHORTCUT = 4;
|
||||||
|
|
||||||
public static final int ACTIVITY_REQUEST_CONFIRM_CREDENTIAL_FOR_WEAKER_ENCRYPTION = 1;
|
public static final int ACTIVITY_REQUEST_CONFIRM_CREDENTIAL_FOR_WEAKER_ENCRYPTION = 1;
|
||||||
|
|
||||||
|
private CharSequence mDialogTitle;
|
||||||
|
|
||||||
private LockPatternUtils mLockPatternUtils;
|
private LockPatternUtils mLockPatternUtils;
|
||||||
|
|
||||||
|
private final DialogInterface.OnClickListener mDialogListener =
|
||||||
|
(DialogInterface dialog, int id) -> {
|
||||||
|
if (id == DialogInterface.BUTTON_POSITIVE) {
|
||||||
|
// TODO(b/142531156): Save the shortcut type preference.
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private final View.OnClickListener mSettingButtonListener = (View view) -> showDialog(
|
||||||
|
DIALOG_ID_EDIT_SHORTCUT);
|
||||||
|
|
||||||
|
private final View.OnClickListener mCheckBoxListener = (View view) -> {
|
||||||
|
CheckBox checkBox = (CheckBox) view;
|
||||||
|
if (checkBox.isChecked()) {
|
||||||
|
// TODO(b/142530063): Enable shortcut when checkbox is checked.
|
||||||
|
} else {
|
||||||
|
// TODO(b/142530063): Disable shortcut when checkbox is unchecked.
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private final SettingsContentObserver mSettingsContentObserver =
|
private final SettingsContentObserver mSettingsContentObserver =
|
||||||
new SettingsContentObserver(new Handler()) {
|
new SettingsContentObserver(new Handler()) {
|
||||||
@Override
|
@Override
|
||||||
@@ -126,6 +153,13 @@ public class ToggleAccessibilityServicePreferenceFragment extends ToggleFeatureP
|
|||||||
mLockPatternUtils = new LockPatternUtils(getActivity());
|
mLockPatternUtils = new LockPatternUtils(getActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
initShortcutPreference();
|
||||||
|
return super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
mSettingsContentObserver.register(getContentResolver());
|
mSettingsContentObserver.register(getContentResolver());
|
||||||
@@ -195,6 +229,13 @@ public class ToggleAccessibilityServicePreferenceFragment extends ToggleFeatureP
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case DIALOG_ID_EDIT_SHORTCUT: {
|
||||||
|
final CharSequence dialogTitle = getActivity().getString(
|
||||||
|
R.string.accessibility_shortcut_edit_dialog_title, mDialogTitle);
|
||||||
|
mDialog = AccessibilityEditDialogUtils.showEditShortcutDialog(getActivity(),
|
||||||
|
dialogTitle, mDialogListener);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
@@ -204,10 +245,21 @@ public class ToggleAccessibilityServicePreferenceFragment extends ToggleFeatureP
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDialogMetricsCategory(int dialogId) {
|
public int getDialogMetricsCategory(int dialogId) {
|
||||||
if (dialogId == DIALOG_ID_ENABLE_WARNING) {
|
switch (dialogId) {
|
||||||
|
case DIALOG_ID_ENABLE_WARNING:
|
||||||
return SettingsEnums.DIALOG_ACCESSIBILITY_SERVICE_ENABLE;
|
return SettingsEnums.DIALOG_ACCESSIBILITY_SERVICE_ENABLE;
|
||||||
} else {
|
case DIALOG_ID_DISABLE_WARNING:
|
||||||
return SettingsEnums.DIALOG_ACCESSIBILITY_SERVICE_DISABLE;
|
return SettingsEnums.DIALOG_ACCESSIBILITY_SERVICE_DISABLE;
|
||||||
|
case DIALOG_ID_LAUNCH_ACCESSIBILITY_TUTORIAL:
|
||||||
|
return isGestureNavigateEnabled()
|
||||||
|
? SettingsEnums.DIALOG_ACCESSIBILITY_SERVICE_DISABLE
|
||||||
|
: SettingsEnums.DIALOG_ACCESSIBILITY_SERVICE_DISABLE;
|
||||||
|
// TODO(b/142531156): Create a settings enum to replace it.
|
||||||
|
case DIALOG_ID_EDIT_SHORTCUT:
|
||||||
|
return SettingsEnums.DIALOG_ACCESSIBILITY_SERVICE_ENABLE;
|
||||||
|
// TODO(b/142531156): Create a settings enum to replace it.
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,6 +272,21 @@ public class ToggleAccessibilityServicePreferenceFragment extends ToggleFeatureP
|
|||||||
switchBar.setSwitchBarText(switchBarText, switchBarText);
|
switchBar.setSwitchBarText(switchBarText, switchBarText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initShortcutPreference() {
|
||||||
|
final PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||||
|
final ShortcutPreference shortcutPreference = new ShortcutPreference(
|
||||||
|
preferenceScreen.getContext(), null);
|
||||||
|
// Put the shortcutPreference before settingsPreference.
|
||||||
|
shortcutPreference.setOrder(-1);
|
||||||
|
shortcutPreference.setTitle(R.string.accessibility_shortcut_title);
|
||||||
|
// TODO(b/142530063): Check the new setting key to decide which summary should be shown.
|
||||||
|
// TODO(b/142530063): Check if gesture mode is on to decide which summary should be shown.
|
||||||
|
// TODO(b/142530063): Check the new key to decide whether checkbox should be checked.
|
||||||
|
shortcutPreference.setSettingButtonListener(mSettingButtonListener);
|
||||||
|
shortcutPreference.setCheckBoxListener(mCheckBoxListener);
|
||||||
|
preferenceScreen.addPreference(shortcutPreference);
|
||||||
|
}
|
||||||
|
|
||||||
private void updateSwitchBarToggleSwitch() {
|
private void updateSwitchBarToggleSwitch() {
|
||||||
final boolean checked = AccessibilityUtils.getEnabledServicesFromSettings(getActivity())
|
final boolean checked = AccessibilityUtils.getEnabledServicesFromSettings(getActivity())
|
||||||
.contains(mComponentName);
|
.contains(mComponentName);
|
||||||
@@ -350,5 +417,9 @@ public class ToggleAccessibilityServicePreferenceFragment extends ToggleFeatureP
|
|||||||
|
|
||||||
// Settings html description.
|
// Settings html description.
|
||||||
mHtmlDescription = arguments.getCharSequence(AccessibilitySettings.EXTRA_HTML_DESCRIPTION);
|
mHtmlDescription = arguments.getCharSequence(AccessibilitySettings.EXTRA_HTML_DESCRIPTION);
|
||||||
|
|
||||||
|
// Get Accessibility service name.
|
||||||
|
mDialogTitle = getAccessibilityServiceInfo().getResolveInfo().loadLabel(
|
||||||
|
getPackageManager());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,13 +16,21 @@
|
|||||||
|
|
||||||
package com.android.settings.accessibility;
|
package com.android.settings.accessibility;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.CheckBox;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
@@ -30,6 +38,7 @@ import com.android.settings.widget.SwitchBar;
|
|||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
import com.android.settingslib.search.SearchIndexable;
|
import com.android.settingslib.search.SearchIndexable;
|
||||||
|
import com.android.settingslib.widget.RadioButtonPreference;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -42,6 +51,8 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
|||||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||||
new BaseSearchIndexProvider(R.xml.accessibility_daltonizer_settings);
|
new BaseSearchIndexProvider(R.xml.accessibility_daltonizer_settings);
|
||||||
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED;
|
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED;
|
||||||
|
private static final String RADIOPREFERENCE_KEY = "daltonizer_mode_deuteranomaly";
|
||||||
|
private static final int DIALOG_ID_EDIT_SHORTCUT = 1;
|
||||||
private static final List<AbstractPreferenceController> sControllers = new ArrayList<>();
|
private static final List<AbstractPreferenceController> sControllers = new ArrayList<>();
|
||||||
|
|
||||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
||||||
@@ -59,6 +70,27 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
|||||||
return sControllers;
|
return sControllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final DialogInterface.OnClickListener mDialogListener =
|
||||||
|
(DialogInterface dialog, int id) -> {
|
||||||
|
if (id == DialogInterface.BUTTON_POSITIVE) {
|
||||||
|
// TODO(b/142531156): Save the shortcut type preference.
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private final View.OnClickListener mSettingButtonListener =
|
||||||
|
(View view) -> showDialog(DIALOG_ID_EDIT_SHORTCUT);
|
||||||
|
|
||||||
|
private final View.OnClickListener mCheckBoxListener = (View view) -> {
|
||||||
|
CheckBox checkBox = (CheckBox) view;
|
||||||
|
if (checkBox.isChecked()) {
|
||||||
|
// TODO(b/142530063): Enable shortcut when checkbox is checked.
|
||||||
|
} else {
|
||||||
|
// TODO(b/142530063): Disable shortcut when checkbox is unchecked.
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private Dialog mDialog;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(Preference preference) {
|
public void onCheckedChanged(Preference preference) {
|
||||||
for (AbstractPreferenceController controller : sControllers) {
|
for (AbstractPreferenceController controller : sControllers) {
|
||||||
@@ -66,6 +98,13 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
initShortcutPreference();
|
||||||
|
return super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@@ -86,11 +125,32 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(int dialogId) {
|
||||||
|
if (dialogId == DIALOG_ID_EDIT_SHORTCUT) {
|
||||||
|
final CharSequence dialogTitle = getActivity().getString(
|
||||||
|
R.string.accessibility_shortcut_edit_dialog_title_daltonizer);
|
||||||
|
mDialog = AccessibilityEditDialogUtils.showEditShortcutDialog(getActivity(),
|
||||||
|
dialogTitle, mDialogListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mDialog;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return SettingsEnums.ACCESSIBILITY_TOGGLE_DALTONIZER;
|
return SettingsEnums.ACCESSIBILITY_TOGGLE_DALTONIZER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDialogMetricsCategory(int dialogId) {
|
||||||
|
if (dialogId == DIALOG_ID_EDIT_SHORTCUT) {
|
||||||
|
return SettingsEnums.ACCESSIBILITY_TOGGLE_DALTONIZER;
|
||||||
|
// TODO(b/142531156): Create a settings enum to replace it.
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHelpResource() {
|
public int getHelpResource() {
|
||||||
return R.string.help_url_color_correction;
|
return R.string.help_url_color_correction;
|
||||||
@@ -131,4 +191,20 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
|||||||
Settings.Secure.getInt(getContentResolver(), ENABLED, 0) == 1);
|
Settings.Secure.getInt(getContentResolver(), ENABLED, 0) == 1);
|
||||||
mSwitchBar.addOnSwitchChangeListener(this);
|
mSwitchBar.addOnSwitchChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initShortcutPreference() {
|
||||||
|
final PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||||
|
final ShortcutPreference shortcutPreference = new ShortcutPreference(
|
||||||
|
preferenceScreen.getContext(), null);
|
||||||
|
final RadioButtonPreference radioButtonPreference = findPreference(RADIOPREFERENCE_KEY);
|
||||||
|
// Put the shortcutPreference before radioButtonPreference.
|
||||||
|
shortcutPreference.setOrder(radioButtonPreference.getOrder() - 1);
|
||||||
|
shortcutPreference.setTitle(R.string.accessibility_shortcut_title);
|
||||||
|
// TODO(b/142530063): Check the new setting key to decide which summary should be shown.
|
||||||
|
// TODO(b/142530063): Check if gesture mode is on to decide which summary should be shown.
|
||||||
|
// TODO(b/142530063): Check the new key to decide whether checkbox should be checked.
|
||||||
|
shortcutPreference.setSettingButtonListener(mSettingButtonListener);
|
||||||
|
shortcutPreference.setCheckBoxListener(mCheckBoxListener);
|
||||||
|
preferenceScreen.addPreference(shortcutPreference);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,6 +22,7 @@ import android.app.Dialog;
|
|||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
@@ -32,8 +33,12 @@ import android.os.Bundle;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
import android.widget.CheckBox;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.RelativeLayout.LayoutParams;
|
import android.widget.RelativeLayout.LayoutParams;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
@@ -51,6 +56,26 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
|
|
||||||
private static final int DIALOG_ID_GESTURE_NAVIGATION_TUTORIAL = 1;
|
private static final int DIALOG_ID_GESTURE_NAVIGATION_TUTORIAL = 1;
|
||||||
private static final int DIALOG_ID_ACCESSIBILITY_BUTTON_TUTORIAL = 2;
|
private static final int DIALOG_ID_ACCESSIBILITY_BUTTON_TUTORIAL = 2;
|
||||||
|
private static final int DIALOG_ID_EDIT_SHORTCUT = 3;
|
||||||
|
|
||||||
|
private final DialogInterface.OnClickListener mDialogListener =
|
||||||
|
(DialogInterface dialog, int id) -> {
|
||||||
|
if (id == DialogInterface.BUTTON_POSITIVE) {
|
||||||
|
// TODO(b/142531156): Save the shortcut type preference.
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private final View.OnClickListener mSettingButtonListener =
|
||||||
|
(View view) -> showDialog(DIALOG_ID_EDIT_SHORTCUT);
|
||||||
|
|
||||||
|
private final View.OnClickListener mCheckBoxListener = (View view) -> {
|
||||||
|
CheckBox checkBox = (CheckBox) view;
|
||||||
|
if (checkBox.isChecked()) {
|
||||||
|
// TODO(b/142530063): Enable shortcut when checkbox is checked.
|
||||||
|
} else {
|
||||||
|
// TODO(b/142530063): Disable shortcut when checkbox is unchecked.
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private Dialog mDialog;
|
private Dialog mDialog;
|
||||||
|
|
||||||
@@ -159,6 +184,13 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
preferenceScreen.addPreference(mConfigWarningPreference);
|
preferenceScreen.addPreference(mConfigWarningPreference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
initShortcutPreference();
|
||||||
|
return super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@@ -182,6 +214,12 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
mDialog = AccessibilityGestureNavigationTutorial
|
mDialog = AccessibilityGestureNavigationTutorial
|
||||||
.showAccessibilityButtonTutorialDialog(getActivity());
|
.showAccessibilityButtonTutorialDialog(getActivity());
|
||||||
break;
|
break;
|
||||||
|
case DIALOG_ID_EDIT_SHORTCUT:
|
||||||
|
final CharSequence dialogTitle = getActivity().getString(
|
||||||
|
R.string.accessibility_shortcut_edit_dialog_title_magnification);
|
||||||
|
mDialog = AccessibilityEditDialogUtils.showMagnificationEditShortcutDialog(
|
||||||
|
getActivity(), dialogTitle, mDialogListener);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
@@ -202,6 +240,9 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
return SettingsEnums.DIALOG_TOGGLE_SCREEN_MAGNIFICATION_GESTURE_NAVIGATION;
|
return SettingsEnums.DIALOG_TOGGLE_SCREEN_MAGNIFICATION_GESTURE_NAVIGATION;
|
||||||
case DIALOG_ID_ACCESSIBILITY_BUTTON_TUTORIAL:
|
case DIALOG_ID_ACCESSIBILITY_BUTTON_TUTORIAL:
|
||||||
return SettingsEnums.DIALOG_TOGGLE_SCREEN_MAGNIFICATION_ACCESSIBILITY_BUTTON;
|
return SettingsEnums.DIALOG_TOGGLE_SCREEN_MAGNIFICATION_ACCESSIBILITY_BUTTON;
|
||||||
|
case DIALOG_ID_EDIT_SHORTCUT:
|
||||||
|
return SettingsEnums.DIALOG_TOGGLE_SCREEN_MAGNIFICATION_ACCESSIBILITY_BUTTON;
|
||||||
|
// TODO(b/142531156): Create a settings enum to replace it.
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -277,6 +318,21 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initShortcutPreference() {
|
||||||
|
final PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||||
|
final ShortcutPreference shortcutPreference = new ShortcutPreference(
|
||||||
|
preferenceScreen.getContext(), null);
|
||||||
|
// Put the shortcutPreference before videoPreference.
|
||||||
|
shortcutPreference.setOrder(mVideoPreference.getOrder() - 1);
|
||||||
|
shortcutPreference.setTitle(R.string.accessibility_magnification_shortcut_title);
|
||||||
|
// TODO(b/142530063): Check the new setting key to decide which summary should be shown.
|
||||||
|
// TODO(b/142530063): Check if gesture mode is on to decide which summary should be shown.
|
||||||
|
// TODO(b/142530063): Check the new key to decide whether checkbox should be checked.
|
||||||
|
shortcutPreference.setSettingButtonListener(mSettingButtonListener);
|
||||||
|
shortcutPreference.setCheckBoxListener(mCheckBoxListener);
|
||||||
|
preferenceScreen.addPreference(shortcutPreference);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isGestureNavigateEnabled() {
|
private boolean isGestureNavigateEnabled() {
|
||||||
return getContext().getResources().getInteger(
|
return getContext().getResources().getInteger(
|
||||||
com.android.internal.R.integer.config_navBarInteractionMode)
|
com.android.internal.R.integer.config_navBarInteractionMode)
|
||||||
|
Reference in New Issue
Block a user