summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorPETER LIANG <peterliang@google.com>2020-04-14 08:56:55 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-04-14 08:56:55 +0000
commit40dff7cd014c720809ac385a8fe76983e0c7127e (patch)
tree0972f02a5c3b7144e5dc617537cb8d8dd5dda981 /core/java
parent3002b11fb6691bc7c734ed9e880efb64d63854c7 (diff)
parent8b7c9dada1a389118f0efb495684b4a0370db23e (diff)
Merge "Migrate AccessibilityButtonChooserActivity into dialog folder and renaming." into rvc-dev
Diffstat (limited to 'core/java')
-rw-r--r--core/java/com/android/internal/accessibility/dialog/AccessibilityShortcutChooserActivity.java (renamed from core/java/com/android/internal/app/AccessibilityButtonChooserActivity.java)20
-rw-r--r--core/java/com/android/internal/accessibility/util/AccessibilityUtils.java3
-rw-r--r--core/java/com/android/internal/accessibility/util/ShortcutUtils.java43
3 files changed, 36 insertions, 30 deletions
diff --git a/core/java/com/android/internal/app/AccessibilityButtonChooserActivity.java b/core/java/com/android/internal/accessibility/dialog/AccessibilityShortcutChooserActivity.java
index 4f98a6354ea3..9338c3c87217 100644
--- a/core/java/com/android/internal/app/AccessibilityButtonChooserActivity.java
+++ b/core/java/com/android/internal/accessibility/dialog/AccessibilityShortcutChooserActivity.java
@@ -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");
* 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
* 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_SHORTCUT_KEY;
@@ -79,9 +79,10 @@ import java.util.List;
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
private static int sShortcutType;
@UserShortcutType
@@ -355,17 +356,18 @@ public class AccessibilityButtonChooserActivity extends Activity {
ViewHolder holder;
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(
- R.layout.accessibility_button_chooser_item, parent, /* attachToRoot= */
+ R.layout.accessibility_shortcut_chooser_item, parent, /* attachToRoot= */
false);
holder = new ViewHolder();
holder.mItemView = convertView;
holder.mCheckBox = convertView.findViewById(
- R.id.accessibility_button_target_checkbox);
- holder.mIconView = convertView.findViewById(R.id.accessibility_button_target_icon);
+ R.id.accessibility_shortcut_target_checkbox);
+ holder.mIconView = convertView.findViewById(
+ R.id.accessibility_shortcut_target_icon);
holder.mLabelView = convertView.findViewById(
- R.id.accessibility_button_target_label);
+ R.id.accessibility_shortcut_target_label);
holder.mSwitchItem = convertView.findViewById(
- R.id.accessibility_button_target_switch_item);
+ R.id.accessibility_shortcut_target_switch_item);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
diff --git a/core/java/com/android/internal/accessibility/util/AccessibilityUtils.java b/core/java/com/android/internal/accessibility/util/AccessibilityUtils.java
index bcbd6abc252c..a92a50d4d832 100644
--- a/core/java/com/android/internal/accessibility/util/AccessibilityUtils.java
+++ b/core/java/com/android/internal/accessibility/util/AccessibilityUtils.java
@@ -19,6 +19,7 @@ import static com.android.internal.accessibility.common.ShortcutConstants.Access
import static com.android.internal.accessibility.common.ShortcutConstants.SERVICES_SEPARATOR;
import android.accessibilityservice.AccessibilityServiceInfo;
+import android.annotation.NonNull;
import android.content.ComponentName;
import android.content.Context;
import android.os.Build;
@@ -115,7 +116,7 @@ public final class AccessibilityUtils {
* @return int from {@link AccessibilityFragmentType}.
*/
public static @AccessibilityFragmentType int getAccessibilityServiceFragmentType(
- AccessibilityServiceInfo accessibilityServiceInfo) {
+ @NonNull AccessibilityServiceInfo accessibilityServiceInfo) {
final int targetSdk = accessibilityServiceInfo.getResolveInfo()
.serviceInfo.applicationInfo.targetSdkVersion;
final boolean requestA11yButton = (accessibilityServiceInfo.flags
diff --git a/core/java/com/android/internal/accessibility/util/ShortcutUtils.java b/core/java/com/android/internal/accessibility/util/ShortcutUtils.java
index 717e78078b1c..7ec80ecdb2a9 100644
--- a/core/java/com/android/internal/accessibility/util/ShortcutUtils.java
+++ b/core/java/com/android/internal/accessibility/util/ShortcutUtils.java
@@ -39,21 +39,21 @@ public final class ShortcutUtils {
new TextUtils.SimpleStringSplitter(SERVICES_SEPARATOR);
/**
- * Opts in component name into colon-separated {@link UserShortcutType}
- * key's string in Settings.
+ * Opts in component id into colon-separated {@link UserShortcutType}
+ * key's string from Settings.
*
* @param context The current context.
* @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,
- String componentId) {
+ @NonNull String componentId) {
final StringJoiner joiner = new StringJoiner(String.valueOf(SERVICES_SEPARATOR));
final String targetKey = convertToKey(shortcutType);
final String targetString = Settings.Secure.getString(context.getContentResolver(),
targetKey);
- if (hasValueInSettings(context, shortcutType, componentId)) {
+ if (isComponentIdExistingInSettings(context, shortcutType, componentId)) {
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 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(
- 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 String targetsKey = convertToKey(shortcutType);
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 shortcutTypes A combination of {@link UserShortcutType}.
- * @param componentId The component name that need to be checked existed in Settings.
- * @return {@code true} if componentName existed in Settings.
+ * @param componentId The component id that need to be checked 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) {
boolean exist = false;
if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
- exist = hasValueInSettings(context, UserShortcutType.SOFTWARE, componentId);
+ exist = isComponentIdExistingInSettings(context, UserShortcutType.SOFTWARE,
+ componentId);
}
if (((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE)) {
- exist |= hasValueInSettings(context, UserShortcutType.HARDWARE, componentId);
+ exist |= isComponentIdExistingInSettings(context, UserShortcutType.HARDWARE,
+ componentId);
}
return exist;
}
/**
- * Returns if component name existed in Settings.
+ * Returns if component id existed in Settings.
*
* @param context The current context.
* @param shortcutType The preferred shortcut type user selected.
* @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,
- @NonNull String componentId) {
+ public static boolean isComponentIdExistingInSettings(Context context,
+ @UserShortcutType int shortcutType, @NonNull String componentId) {
final String targetKey = convertToKey(shortcutType);
final String targetString = Settings.Secure.getString(context.getContentResolver(),
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.
* @return Mapping key in Settings.
@@ -169,7 +172,7 @@ public final class ShortcutUtils {
* Converts {@link ShortcutType} to {@link UserShortcutType}.
*
* @param type The shortcut type.
- * @return {@link UserShortcutType}.
+ * @return Mapping type from {@link UserShortcutType}.
*/
public static @UserShortcutType int convertToUserType(@ShortcutType int type) {
switch (type) {