Change disable accessibility service dialog layout
Bug: 140307087 Test: Visual Change-Id: I78d573f121e2f799a8395fcd2d21ee48a5fffb23
This commit is contained in:
@@ -1,71 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
~ Copyright (C) 2019 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.
|
|
||||||
~ You may obtain a copy of the License at
|
|
||||||
~
|
|
||||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
~
|
|
||||||
~ Unless required by applicable law or agreed to in writing, software
|
|
||||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
~ See the License for the specific language governing permissions and
|
|
||||||
~ limitations under the License
|
|
||||||
-->
|
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:textDirection="locale"
|
|
||||||
android:scrollbarStyle="outsideOverlay"
|
|
||||||
android:gravity="top">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:theme="@style/Theme.AlertDialog"
|
|
||||||
style="@style/AccessibilityDialog">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:paddingTop="32dp"
|
|
||||||
android:paddingLeft="24dp"
|
|
||||||
android:paddingRight="24dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/permissionDialog_disable_title"
|
|
||||||
style="@style/AccessibilityDialogTitle" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/permissionDialog_disable_message"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/accessibility_service_warning_description"
|
|
||||||
style="@style/AccessibilityDialogDescription" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
<!-- Buttons on bottom of dialog -->
|
|
||||||
<LinearLayout
|
|
||||||
style="@style/AccessibilityDialogButtonList">
|
|
||||||
|
|
||||||
<Space
|
|
||||||
style="@style/AccessibilityDialogButtonBarSpace"/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/permission_disable_stop_button"
|
|
||||||
android:text="@string/accessibility_dialog_button_stop"
|
|
||||||
style="@style/AccessibilityDialogButton" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/permission_disable_cancel_button"
|
|
||||||
android:text="@string/accessibility_dialog_button_cancel"
|
|
||||||
style="@style/AccessibilityDialogButton" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</ScrollView>
|
|
@@ -22,6 +22,7 @@ import android.accessibilityservice.AccessibilityServiceInfo;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.storage.StorageManager;
|
import android.os.storage.StorageManager;
|
||||||
import android.text.BidiFormatter;
|
import android.text.BidiFormatter;
|
||||||
@@ -77,10 +78,16 @@ public class AccessibilityServiceWarning {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Dialog createDisableDialog(Activity parentActivity,
|
public static Dialog createDisableDialog(Activity parentActivity,
|
||||||
AccessibilityServiceInfo info, View.OnClickListener listener) {
|
AccessibilityServiceInfo info, DialogInterface.OnClickListener listener) {
|
||||||
final AlertDialog ad = new AlertDialog.Builder(parentActivity)
|
final AlertDialog ad = new AlertDialog.Builder(parentActivity)
|
||||||
.setView(createDisableDialogContentView(parentActivity, info, listener))
|
.setTitle(parentActivity.getString(R.string.disable_service_title,
|
||||||
|
info.getResolveInfo().loadLabel(parentActivity.getPackageManager())))
|
||||||
|
.setMessage(parentActivity.getString(R.string.disable_service_message,
|
||||||
|
parentActivity.getString(R.string.accessibility_dialog_button_stop),
|
||||||
|
getServiceName(parentActivity, info)))
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
|
.setPositiveButton(R.string.accessibility_dialog_button_stop, listener)
|
||||||
|
.setNegativeButton(R.string.accessibility_dialog_button_cancel, listener)
|
||||||
.create();
|
.create();
|
||||||
|
|
||||||
return ad;
|
return ad;
|
||||||
@@ -148,33 +155,6 @@ public class AccessibilityServiceWarning {
|
|||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static View createDisableDialogContentView(Context context,
|
|
||||||
AccessibilityServiceInfo info, View.OnClickListener listener) {
|
|
||||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(
|
|
||||||
Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
|
|
||||||
View content = inflater.inflate(R.layout.disable_accessibility_service_dialog_content,
|
|
||||||
null);
|
|
||||||
|
|
||||||
TextView permissionDialogTitle = content.findViewById(R.id.permissionDialog_disable_title);
|
|
||||||
permissionDialogTitle.setText(context.getString(R.string.disable_service_title,
|
|
||||||
getServiceName(context, info)));
|
|
||||||
TextView permissionDialogMessage = content
|
|
||||||
.findViewById(R.id.permissionDialog_disable_message);
|
|
||||||
permissionDialogMessage.setText(context.getString(R.string.disable_service_message,
|
|
||||||
context.getString(R.string.accessibility_dialog_button_stop),
|
|
||||||
getServiceName(context, info)));
|
|
||||||
|
|
||||||
Button permissionAllowButton = content.findViewById(
|
|
||||||
R.id.permission_disable_stop_button);
|
|
||||||
Button permissionDenyButton = content.findViewById(
|
|
||||||
R.id.permission_disable_cancel_button);
|
|
||||||
permissionAllowButton.setOnClickListener(listener);
|
|
||||||
permissionDenyButton.setOnClickListener(listener);
|
|
||||||
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the service name and bidi wrap it to protect from bidi side effects.
|
// Get the service name and bidi wrap it to protect from bidi side effects.
|
||||||
private static CharSequence getServiceName(Context context, AccessibilityServiceInfo info) {
|
private static CharSequence getServiceName(Context context, AccessibilityServiceInfo info) {
|
||||||
final Locale locale = context.getResources().getConfiguration().getLocales().get(0);
|
final Locale locale = context.getResources().getConfiguration().getLocales().get(0);
|
||||||
|
@@ -25,6 +25,7 @@ import android.app.admin.DevicePolicyManager;
|
|||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.content.pm.ServiceInfo;
|
import android.content.pm.ServiceInfo;
|
||||||
@@ -49,8 +50,7 @@ import com.android.settingslib.accessibility.AccessibilityUtils;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ToggleAccessibilityServicePreferenceFragment
|
public class ToggleAccessibilityServicePreferenceFragment extends ToggleFeaturePreferenceFragment {
|
||||||
extends ToggleFeaturePreferenceFragment implements View.OnClickListener {
|
|
||||||
|
|
||||||
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;
|
||||||
@@ -72,6 +72,42 @@ public class ToggleAccessibilityServicePreferenceFragment
|
|||||||
|
|
||||||
private Dialog mDialog;
|
private Dialog mDialog;
|
||||||
|
|
||||||
|
private final View.OnClickListener mViewOnClickListener =
|
||||||
|
(View view) -> {
|
||||||
|
if (view.getId() == R.id.permission_enable_allow_button) {
|
||||||
|
if (isFullDiskEncrypted()) {
|
||||||
|
String title = createConfirmCredentialReasonMessage();
|
||||||
|
Intent intent = ConfirmDeviceCredentialActivity.createIntent(title, null);
|
||||||
|
startActivityForResult(intent,
|
||||||
|
ACTIVITY_REQUEST_CONFIRM_CREDENTIAL_FOR_WEAKER_ENCRYPTION);
|
||||||
|
} else {
|
||||||
|
handleConfirmServiceEnabled(true);
|
||||||
|
if (isServiceSupportAccessibilityButton()) {
|
||||||
|
showDialog(DIALOG_ID_LAUNCH_ACCESSIBILITY_TUTORIAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (view.getId() == R.id.permission_enable_deny_button) {
|
||||||
|
handleConfirmServiceEnabled(false);
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
mDialog.dismiss();
|
||||||
|
};
|
||||||
|
|
||||||
|
private final DialogInterface.OnClickListener mDialogInterfaceOnClickListener =
|
||||||
|
(DialogInterface dialog, int which) -> {
|
||||||
|
switch (which) {
|
||||||
|
case DialogInterface.BUTTON_POSITIVE:
|
||||||
|
handleConfirmServiceEnabled(false);
|
||||||
|
break;
|
||||||
|
case DialogInterface.BUTTON_NEGATIVE:
|
||||||
|
handleConfirmServiceEnabled(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return SettingsEnums.ACCESSIBILITY_SERVICE;
|
return SettingsEnums.ACCESSIBILITY_SERVICE;
|
||||||
@@ -137,7 +173,7 @@ public class ToggleAccessibilityServicePreferenceFragment
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
mDialog = AccessibilityServiceWarning
|
mDialog = AccessibilityServiceWarning
|
||||||
.createCapabilitiesDialog(getActivity(), info, this);
|
.createCapabilitiesDialog(getActivity(), info, mViewOnClickListener);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DIALOG_ID_DISABLE_WARNING: {
|
case DIALOG_ID_DISABLE_WARNING: {
|
||||||
@@ -146,7 +182,7 @@ public class ToggleAccessibilityServicePreferenceFragment
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
mDialog = AccessibilityServiceWarning
|
mDialog = AccessibilityServiceWarning
|
||||||
.createDisableDialog(getActivity(), info, this);
|
.createDisableDialog(getActivity(), info, mDialogInterfaceOnClickListener);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DIALOG_ID_LAUNCH_ACCESSIBILITY_TUTORIAL: {
|
case DIALOG_ID_LAUNCH_ACCESSIBILITY_TUTORIAL: {
|
||||||
@@ -210,32 +246,6 @@ public class ToggleAccessibilityServicePreferenceFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
if (view.getId() == R.id.permission_enable_allow_button) {
|
|
||||||
if (isFullDiskEncrypted()) {
|
|
||||||
String title = createConfirmCredentialReasonMessage();
|
|
||||||
Intent intent = ConfirmDeviceCredentialActivity.createIntent(title, null);
|
|
||||||
startActivityForResult(intent,
|
|
||||||
ACTIVITY_REQUEST_CONFIRM_CREDENTIAL_FOR_WEAKER_ENCRYPTION);
|
|
||||||
} else {
|
|
||||||
handleConfirmServiceEnabled(true);
|
|
||||||
if (isServiceSupportAccessibilityButton()) {
|
|
||||||
showDialog(DIALOG_ID_LAUNCH_ACCESSIBILITY_TUTORIAL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (view.getId() == R.id.permission_enable_deny_button) {
|
|
||||||
handleConfirmServiceEnabled(false);
|
|
||||||
} else if (view.getId() == R.id.permission_disable_stop_button) {
|
|
||||||
handleConfirmServiceEnabled(false);
|
|
||||||
} else if (view.getId() == R.id.permission_disable_cancel_button) {
|
|
||||||
handleConfirmServiceEnabled(true);
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
}
|
|
||||||
mDialog.dismiss();
|
|
||||||
}
|
|
||||||
|
|
||||||
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