diff --git a/res/layout/enable_nls_dialog_content.xml b/res/layout/enable_nls_dialog_content.xml
new file mode 100644
index 00000000000..5e1dec98e59
--- /dev/null
+++ b/res/layout/enable_nls_dialog_content.xml
@@ -0,0 +1,167 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 49e1593e9ff..3994678a335 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -9392,10 +9392,17 @@
listener, displayed as a dialog message. [CHAR LIMIT=NONE] -->
%1$s 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.
\n\nThis will also give the app the ability to turn Do Not Disturb on or off and change related settings.
+ %1$s will be able to:
+ Read your notifications
+ It can read your notifications, including personal information such as contacts, messages, and photos.
+ Reply to messages
+ It can reply to messages and take action on buttons in notifications, including snoozing or dismissing notifications and answering calls.
+ Change settings
+ It can turn Do Not Disturb on or off and change related settings.
If you turn off notification access for %1$s, Do Not Disturb access may also be turned off.
diff --git a/src/com/android/settings/applications/specialaccess/notificationaccess/ScaryWarningDialogFragment.java b/src/com/android/settings/applications/specialaccess/notificationaccess/ScaryWarningDialogFragment.java
index 6613f96e7fb..b9ad2c3cb69 100644
--- a/src/com/android/settings/applications/specialaccess/notificationaccess/ScaryWarningDialogFragment.java
+++ b/src/com/android/settings/applications/specialaccess/notificationaccess/ScaryWarningDialogFragment.java
@@ -18,8 +18,15 @@ package com.android.settings.applications.specialaccess.notificationaccess;
import android.app.Dialog;
import android.app.settings.SettingsEnums;
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.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.fragment.app.Fragment;
@@ -55,25 +62,49 @@ public class ScaryWarningDialogFragment extends InstrumentedDialogFragment {
.getString(KEY_COMPONENT));
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())
- .setMessage(summary)
- .setTitle(title)
+ .setView(getDialogView(getContext(), label, parent, cn))
.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();
}
+
+ 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;
+ }
}
\ No newline at end of file