Merge "Migrate AccessibilityButtonChooserActivity into dialog folder and renaming." into rvc-dev
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2017 The Android Open Source Project
|
* Copyright (C) 2020 The Android Open Source Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.android.internal.app;
|
package com.android.internal.accessibility.dialog;
|
||||||
|
|
||||||
import static android.view.accessibility.AccessibilityManager.ACCESSIBILITY_BUTTON;
|
import static android.view.accessibility.AccessibilityManager.ACCESSIBILITY_BUTTON;
|
||||||
import static android.view.accessibility.AccessibilityManager.ACCESSIBILITY_SHORTCUT_KEY;
|
import static android.view.accessibility.AccessibilityManager.ACCESSIBILITY_SHORTCUT_KEY;
|
||||||
@@ -79,9 +79,10 @@ import java.util.List;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity used to display and persist a service or feature target for the Accessibility button.
|
* Activity used to display various targets related to accessibility service, accessibility
|
||||||
|
* activity or white listing feature for volume key shortcut.
|
||||||
*/
|
*/
|
||||||
public class AccessibilityButtonChooserActivity extends Activity {
|
public class AccessibilityShortcutChooserActivity extends Activity {
|
||||||
@ShortcutType
|
@ShortcutType
|
||||||
private static int sShortcutType;
|
private static int sShortcutType;
|
||||||
@UserShortcutType
|
@UserShortcutType
|
||||||
@@ -355,17 +356,18 @@ public class AccessibilityButtonChooserActivity extends Activity {
|
|||||||
ViewHolder holder;
|
ViewHolder holder;
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = LayoutInflater.from(context).inflate(
|
convertView = LayoutInflater.from(context).inflate(
|
||||||
R.layout.accessibility_button_chooser_item, parent, /* attachToRoot= */
|
R.layout.accessibility_shortcut_chooser_item, parent, /* attachToRoot= */
|
||||||
false);
|
false);
|
||||||
holder = new ViewHolder();
|
holder = new ViewHolder();
|
||||||
holder.mItemView = convertView;
|
holder.mItemView = convertView;
|
||||||
holder.mCheckBox = convertView.findViewById(
|
holder.mCheckBox = convertView.findViewById(
|
||||||
R.id.accessibility_button_target_checkbox);
|
R.id.accessibility_shortcut_target_checkbox);
|
||||||
holder.mIconView = convertView.findViewById(R.id.accessibility_button_target_icon);
|
holder.mIconView = convertView.findViewById(
|
||||||
|
R.id.accessibility_shortcut_target_icon);
|
||||||
holder.mLabelView = convertView.findViewById(
|
holder.mLabelView = convertView.findViewById(
|
||||||
R.id.accessibility_button_target_label);
|
R.id.accessibility_shortcut_target_label);
|
||||||
holder.mSwitchItem = convertView.findViewById(
|
holder.mSwitchItem = convertView.findViewById(
|
||||||
R.id.accessibility_button_target_switch_item);
|
R.id.accessibility_shortcut_target_switch_item);
|
||||||
convertView.setTag(holder);
|
convertView.setTag(holder);
|
||||||
} else {
|
} else {
|
||||||
holder = (ViewHolder) convertView.getTag();
|
holder = (ViewHolder) convertView.getTag();
|
||||||
@@ -19,6 +19,7 @@ import static com.android.internal.accessibility.common.ShortcutConstants.Access
|
|||||||
import static com.android.internal.accessibility.common.ShortcutConstants.SERVICES_SEPARATOR;
|
import static com.android.internal.accessibility.common.ShortcutConstants.SERVICES_SEPARATOR;
|
||||||
|
|
||||||
import android.accessibilityservice.AccessibilityServiceInfo;
|
import android.accessibilityservice.AccessibilityServiceInfo;
|
||||||
|
import android.annotation.NonNull;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@@ -115,7 +116,7 @@ public final class AccessibilityUtils {
|
|||||||
* @return int from {@link AccessibilityFragmentType}.
|
* @return int from {@link AccessibilityFragmentType}.
|
||||||
*/
|
*/
|
||||||
public static @AccessibilityFragmentType int getAccessibilityServiceFragmentType(
|
public static @AccessibilityFragmentType int getAccessibilityServiceFragmentType(
|
||||||
AccessibilityServiceInfo accessibilityServiceInfo) {
|
@NonNull AccessibilityServiceInfo accessibilityServiceInfo) {
|
||||||
final int targetSdk = accessibilityServiceInfo.getResolveInfo()
|
final int targetSdk = accessibilityServiceInfo.getResolveInfo()
|
||||||
.serviceInfo.applicationInfo.targetSdkVersion;
|
.serviceInfo.applicationInfo.targetSdkVersion;
|
||||||
final boolean requestA11yButton = (accessibilityServiceInfo.flags
|
final boolean requestA11yButton = (accessibilityServiceInfo.flags
|
||||||
|
|||||||
@@ -39,21 +39,21 @@ public final class ShortcutUtils {
|
|||||||
new TextUtils.SimpleStringSplitter(SERVICES_SEPARATOR);
|
new TextUtils.SimpleStringSplitter(SERVICES_SEPARATOR);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opts in component name into colon-separated {@link UserShortcutType}
|
* Opts in component id into colon-separated {@link UserShortcutType}
|
||||||
* key's string in Settings.
|
* key's string from Settings.
|
||||||
*
|
*
|
||||||
* @param context The current context.
|
* @param context The current context.
|
||||||
* @param shortcutType The preferred shortcut type user selected.
|
* @param shortcutType The preferred shortcut type user selected.
|
||||||
* @param componentId The component id that need to be opted out from Settings.
|
* @param componentId The component id that need to be opted in Settings.
|
||||||
*/
|
*/
|
||||||
public static void optInValueToSettings(Context context, @UserShortcutType int shortcutType,
|
public static void optInValueToSettings(Context context, @UserShortcutType int shortcutType,
|
||||||
String componentId) {
|
@NonNull String componentId) {
|
||||||
final StringJoiner joiner = new StringJoiner(String.valueOf(SERVICES_SEPARATOR));
|
final StringJoiner joiner = new StringJoiner(String.valueOf(SERVICES_SEPARATOR));
|
||||||
final String targetKey = convertToKey(shortcutType);
|
final String targetKey = convertToKey(shortcutType);
|
||||||
final String targetString = Settings.Secure.getString(context.getContentResolver(),
|
final String targetString = Settings.Secure.getString(context.getContentResolver(),
|
||||||
targetKey);
|
targetKey);
|
||||||
|
|
||||||
if (hasValueInSettings(context, shortcutType, componentId)) {
|
if (isComponentIdExistingInSettings(context, shortcutType, componentId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,14 +66,15 @@ public final class ShortcutUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opts out component name into colon-separated {@code shortcutType} key's string in Settings.
|
* Opts out of component id into colon-separated {@link UserShortcutType} key's string from
|
||||||
|
* Settings.
|
||||||
*
|
*
|
||||||
* @param context The current context.
|
* @param context The current context.
|
||||||
* @param shortcutType The preferred shortcut type user selected.
|
* @param shortcutType The preferred shortcut type user selected.
|
||||||
* @param componentId The component id that need to be opted out from Settings.
|
* @param componentId The component id that need to be opted out of Settings.
|
||||||
*/
|
*/
|
||||||
public static void optOutValueFromSettings(
|
public static void optOutValueFromSettings(
|
||||||
Context context, @UserShortcutType int shortcutType, String componentId) {
|
Context context, @UserShortcutType int shortcutType, @NonNull String componentId) {
|
||||||
final StringJoiner joiner = new StringJoiner(String.valueOf(SERVICES_SEPARATOR));
|
final StringJoiner joiner = new StringJoiner(String.valueOf(SERVICES_SEPARATOR));
|
||||||
final String targetsKey = convertToKey(shortcutType);
|
final String targetsKey = convertToKey(shortcutType);
|
||||||
final String targetsValue = Settings.Secure.getString(context.getContentResolver(),
|
final String targetsValue = Settings.Secure.getString(context.getContentResolver(),
|
||||||
@@ -96,36 +97,38 @@ public final class ShortcutUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if component name existed in one of {@code shortcutTypes} string in Settings.
|
* Returns if component id existed in one of {@link UserShortcutType} string from Settings.
|
||||||
*
|
*
|
||||||
* @param context The current context.
|
* @param context The current context.
|
||||||
* @param shortcutTypes A combination of {@link UserShortcutType}.
|
* @param shortcutTypes A combination of {@link UserShortcutType}.
|
||||||
* @param componentId The component name that need to be checked existed in Settings.
|
* @param componentId The component id that need to be checked existed in Settings.
|
||||||
* @return {@code true} if componentName existed in Settings.
|
* @return {@code true} if component id existed in Settings.
|
||||||
*/
|
*/
|
||||||
public static boolean hasValuesInSettings(Context context, int shortcutTypes,
|
public static boolean hasValuesInSettings(Context context, @UserShortcutType int shortcutTypes,
|
||||||
@NonNull String componentId) {
|
@NonNull String componentId) {
|
||||||
boolean exist = false;
|
boolean exist = false;
|
||||||
if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
|
if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
|
||||||
exist = hasValueInSettings(context, UserShortcutType.SOFTWARE, componentId);
|
exist = isComponentIdExistingInSettings(context, UserShortcutType.SOFTWARE,
|
||||||
|
componentId);
|
||||||
}
|
}
|
||||||
if (((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE)) {
|
if (((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE)) {
|
||||||
exist |= hasValueInSettings(context, UserShortcutType.HARDWARE, componentId);
|
exist |= isComponentIdExistingInSettings(context, UserShortcutType.HARDWARE,
|
||||||
|
componentId);
|
||||||
}
|
}
|
||||||
return exist;
|
return exist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if component name existed in Settings.
|
* Returns if component id existed in Settings.
|
||||||
*
|
*
|
||||||
* @param context The current context.
|
* @param context The current context.
|
||||||
* @param shortcutType The preferred shortcut type user selected.
|
* @param shortcutType The preferred shortcut type user selected.
|
||||||
* @param componentId The component id that need to be checked existed in Settings.
|
* @param componentId The component id that need to be checked existed in Settings.
|
||||||
* @return {@code true} if componentName existed in Settings.
|
* @return {@code true} if component id existed in Settings.
|
||||||
*/
|
*/
|
||||||
public static boolean hasValueInSettings(Context context, @UserShortcutType int shortcutType,
|
public static boolean isComponentIdExistingInSettings(Context context,
|
||||||
@NonNull String componentId) {
|
@UserShortcutType int shortcutType, @NonNull String componentId) {
|
||||||
final String targetKey = convertToKey(shortcutType);
|
final String targetKey = convertToKey(shortcutType);
|
||||||
final String targetString = Settings.Secure.getString(context.getContentResolver(),
|
final String targetString = Settings.Secure.getString(context.getContentResolver(),
|
||||||
targetKey);
|
targetKey);
|
||||||
@@ -146,7 +149,7 @@ public final class ShortcutUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts {@link UserShortcutType} to key in Settings.
|
* Converts {@link UserShortcutType} to {@link Settings.Secure} key.
|
||||||
*
|
*
|
||||||
* @param type The shortcut type.
|
* @param type The shortcut type.
|
||||||
* @return Mapping key in Settings.
|
* @return Mapping key in Settings.
|
||||||
@@ -169,7 +172,7 @@ public final class ShortcutUtils {
|
|||||||
* Converts {@link ShortcutType} to {@link UserShortcutType}.
|
* Converts {@link ShortcutType} to {@link UserShortcutType}.
|
||||||
*
|
*
|
||||||
* @param type The shortcut type.
|
* @param type The shortcut type.
|
||||||
* @return {@link UserShortcutType}.
|
* @return Mapping type from {@link UserShortcutType}.
|
||||||
*/
|
*/
|
||||||
public static @UserShortcutType int convertToUserType(@ShortcutType int type) {
|
public static @UserShortcutType int convertToUserType(@ShortcutType int type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|||||||
@@ -5060,7 +5060,7 @@
|
|||||||
<category android:name="android.intent.category.VOICE" />
|
<category android:name="android.intent.category.VOICE" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="com.android.internal.app.AccessibilityButtonChooserActivity"
|
<activity android:name="com.android.internal.accessibility.dialog.AccessibilityShortcutChooserActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:theme="@style/Theme.DeviceDefault.Dialog.Alert.DayNight"
|
android:theme="@style/Theme.DeviceDefault.Dialog.Alert.DayNight"
|
||||||
android:finishOnCloseSystemDialogs="true"
|
android:finishOnCloseSystemDialogs="true"
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
android:padding="16dp">
|
android:padding="16dp">
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/accessibility_button_target_checkbox"
|
android:id="@+id/accessibility_shortcut_target_checkbox"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingStart="16dp"
|
android:paddingStart="16dp"
|
||||||
@@ -34,13 +34,13 @@
|
|||||||
android:visibility="gone"/>
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/accessibility_button_target_icon"
|
android:id="@+id/accessibility_shortcut_target_icon"
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:scaleType="fitCenter"/>
|
android:scaleType="fitCenter"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/accessibility_button_target_label"
|
android:id="@+id/accessibility_shortcut_target_label"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
android:fontFamily="sans-serif-medium"/>
|
android:fontFamily="sans-serif-medium"/>
|
||||||
|
|
||||||
<Switch
|
<Switch
|
||||||
android:id="@+id/accessibility_button_target_switch_item"
|
android:id="@+id/accessibility_shortcut_target_switch_item"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@null"
|
android:background="@null"
|
||||||
@@ -3232,12 +3232,13 @@
|
|||||||
<java-symbol type="string" name="accessibility_enable_service_title" />
|
<java-symbol type="string" name="accessibility_enable_service_title" />
|
||||||
<java-symbol type="string" name="accessibility_enable_service_encryption_warning" />
|
<java-symbol type="string" name="accessibility_enable_service_encryption_warning" />
|
||||||
|
|
||||||
|
<java-symbol type="layout" name="accessibility_shortcut_chooser_item" />
|
||||||
|
<java-symbol type="id" name="accessibility_shortcut_target_checkbox" />
|
||||||
|
<java-symbol type="id" name="accessibility_shortcut_target_icon" />
|
||||||
|
<java-symbol type="id" name="accessibility_shortcut_target_label" />
|
||||||
|
<java-symbol type="id" name="accessibility_shortcut_target_switch_item" />
|
||||||
|
|
||||||
<!-- Accessibility Button -->
|
<!-- Accessibility Button -->
|
||||||
<java-symbol type="layout" name="accessibility_button_chooser_item" />
|
|
||||||
<java-symbol type="id" name="accessibility_button_target_checkbox" />
|
|
||||||
<java-symbol type="id" name="accessibility_button_target_icon" />
|
|
||||||
<java-symbol type="id" name="accessibility_button_target_label" />
|
|
||||||
<java-symbol type="id" name="accessibility_button_target_switch_item" />
|
|
||||||
<java-symbol type="string" name="accessibility_magnification_chooser_text" />
|
<java-symbol type="string" name="accessibility_magnification_chooser_text" />
|
||||||
<java-symbol type="string" name="edit_accessibility_shortcut_menu_button" />
|
<java-symbol type="string" name="edit_accessibility_shortcut_menu_button" />
|
||||||
<java-symbol type="string" name="done_accessibility_shortcut_menu_button" />
|
<java-symbol type="string" name="done_accessibility_shortcut_menu_button" />
|
||||||
|
|||||||
Reference in New Issue
Block a user