Merge "Revert "Revert "Update styling of NLS dialog"""
This commit is contained in:
committed by
Android (Google) Code Review
commit
59f749e112
167
res/layout/enable_nls_dialog_content.xml
Normal file
167
res/layout/enable_nls_dialog_content.xml
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2021 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:paddingLeft="24dp"
|
||||||
|
android:paddingRight="24dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/app_icon"
|
||||||
|
style="@style/AccessibilityDialogServiceIcon" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
style="@style/AccessibilityDialogTitle" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/prompt"
|
||||||
|
android:text="@string/nls_warning_prompt"
|
||||||
|
style="@style/AccessibilityDialogDescription" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginBottom="24dp" >
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/read_icon"
|
||||||
|
android:src="@drawable/ic_visibility_18dp"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
style="@style/AccessibilityDialogIcon" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/read_title"
|
||||||
|
android:text="@string/nls_feature_read_title"
|
||||||
|
style="@style/AccessibilityDialogPermissionTitle" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/read_description"
|
||||||
|
android:text="@string/nls_feature_read_summary"
|
||||||
|
style="@style/AccessibilityDialogPermissionDescription" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginBottom="24dp" >
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/reply_icon"
|
||||||
|
android:src="@drawable/ic_promote_conversation"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
style="@style/AccessibilityDialogIcon" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/reply_title"
|
||||||
|
android:text="@string/nls_feature_reply_title"
|
||||||
|
style="@style/AccessibilityDialogPermissionTitle" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/reply_description"
|
||||||
|
android:text="@string/nls_feature_reply_summary"
|
||||||
|
style="@style/AccessibilityDialogPermissionDescription" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginBottom="24dp" >
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/settings_icon"
|
||||||
|
android:src="@drawable/ic_do_not_disturb_on_24dp"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
style="@style/AccessibilityDialogIcon" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/settings_title"
|
||||||
|
android:text="@string/nls_feature_settings_title"
|
||||||
|
style="@style/AccessibilityDialogPermissionTitle" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/settings_description"
|
||||||
|
android:text="@string/nls_feature_settings_summary"
|
||||||
|
style="@style/AccessibilityDialogPermissionDescription" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Buttons on bottom of dialog -->
|
||||||
|
<LinearLayout
|
||||||
|
style="@style/AccessibilityDialogButtonList">
|
||||||
|
|
||||||
|
<Space
|
||||||
|
style="@style/AccessibilityDialogButtonBarSpace"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/allow_button"
|
||||||
|
android:text="@string/accessibility_dialog_button_allow"
|
||||||
|
style="@style/AccessibilityDialogButton" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/deny_button"
|
||||||
|
android:text="@string/accessibility_dialog_button_deny"
|
||||||
|
style="@style/AccessibilityDialogButton" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
@@ -9392,10 +9392,17 @@
|
|||||||
listener, displayed as a dialog message. [CHAR LIMIT=NONE] -->
|
listener, displayed as a dialog message. [CHAR LIMIT=NONE] -->
|
||||||
<string name="notification_listener_security_warning_summary">
|
<string name="notification_listener_security_warning_summary">
|
||||||
<xliff:g id="notification_listener_name">%1$s</xliff:g> will be able to read all notifications,
|
<xliff:g id="notification_listener_name">%1$s</xliff:g> will be able to read all notifications,
|
||||||
including personal information such as contact names and the text of messages you receive.
|
including personal information such as contact names, photos, and the text of messages you receive.
|
||||||
This app will also be able to snooze or dismiss notifications or take action on buttons in notifications, including answering phone calls.
|
This app will also be able to snooze or dismiss notifications or take action on buttons in notifications, including answering phone calls.
|
||||||
\n\nThis will also give the app the ability to turn Do Not Disturb on or off and change related settings.
|
\n\nThis will also give the app the ability to turn Do Not Disturb on or off and change related settings.
|
||||||
</string>
|
</string>
|
||||||
|
<string name="nls_warning_prompt"><xliff:g id="notification_listener_name">%1$s</xliff:g> will be able to:</string>
|
||||||
|
<string name="nls_feature_read_title">Read your notifications</string>
|
||||||
|
<string name="nls_feature_read_summary">It can read your notifications, including personal information such as contacts, messages, and photos.</string>
|
||||||
|
<string name="nls_feature_reply_title">Reply to messages</string>
|
||||||
|
<string name="nls_feature_reply_summary">It can reply to messages and take action on buttons in notifications, including snoozing or dismissing notifications and answering calls.</string>
|
||||||
|
<string name="nls_feature_settings_title">Change settings</string>
|
||||||
|
<string name="nls_feature_settings_summary">It can turn Do Not Disturb on or off and change related settings.</string>
|
||||||
<string name="notification_listener_disable_warning_summary">
|
<string name="notification_listener_disable_warning_summary">
|
||||||
If you turn off notification access for <xliff:g id="notification_listener_name">%1$s</xliff:g>, Do Not Disturb access may also be turned off.
|
If you turn off notification access for <xliff:g id="notification_listener_name">%1$s</xliff:g>, Do Not Disturb access may also be turned off.
|
||||||
</string>
|
</string>
|
||||||
|
@@ -18,8 +18,15 @@ package com.android.settings.applications.specialaccess.notificationaccess;
|
|||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.DialogInterface;
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
@@ -55,25 +62,49 @@ public class ScaryWarningDialogFragment extends InstrumentedDialogFragment {
|
|||||||
.getString(KEY_COMPONENT));
|
.getString(KEY_COMPONENT));
|
||||||
NotificationAccessDetails parent = (NotificationAccessDetails) getTargetFragment();
|
NotificationAccessDetails parent = (NotificationAccessDetails) getTargetFragment();
|
||||||
|
|
||||||
final String title = getResources().getString(
|
|
||||||
R.string.notification_listener_security_warning_title, label);
|
|
||||||
final String summary = getResources().getString(
|
|
||||||
R.string.notification_listener_security_warning_summary, label);
|
|
||||||
return new AlertDialog.Builder(getContext())
|
return new AlertDialog.Builder(getContext())
|
||||||
.setMessage(summary)
|
.setView(getDialogView(getContext(), label, parent, cn))
|
||||||
.setTitle(title)
|
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setPositiveButton(R.string.allow,
|
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
parent.enable(cn);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(R.string.deny,
|
|
||||||
(dialog, id) -> {
|
|
||||||
// pass
|
|
||||||
})
|
|
||||||
.create();
|
.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private View getDialogView(Context context, CharSequence label,
|
||||||
|
NotificationAccessDetails parent, ComponentName cn) {
|
||||||
|
LayoutInflater inflater = (LayoutInflater) context.getSystemService(
|
||||||
|
Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
|
||||||
|
View content = inflater.inflate(R.layout.enable_nls_dialog_content, null);
|
||||||
|
|
||||||
|
Drawable icon = null;
|
||||||
|
try {
|
||||||
|
icon = context.getPackageManager().getApplicationIcon(cn.getPackageName());
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageView appIcon = content.findViewById(R.id.app_icon);
|
||||||
|
if (icon != null) {
|
||||||
|
appIcon.setImageDrawable(icon);
|
||||||
|
} else {
|
||||||
|
appIcon.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
final String title = context.getResources().getString(
|
||||||
|
R.string.notification_listener_security_warning_title, label);
|
||||||
|
((TextView) content.findViewById(R.id.title)).setText(title);
|
||||||
|
|
||||||
|
final String prompt = context.getResources().getString(
|
||||||
|
R.string.nls_warning_prompt, label);
|
||||||
|
((TextView) content.findViewById(R.id.prompt)).setText(prompt);
|
||||||
|
|
||||||
|
Button allowButton = content.findViewById(R.id.allow_button);
|
||||||
|
allowButton.setOnClickListener((view) -> {
|
||||||
|
parent.enable(cn);
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
|
Button denyButton = content.findViewById(R.id.deny_button);
|
||||||
|
denyButton.setOnClickListener((view) -> {
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
|
return content;
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user