Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 31dc1fd8 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Add NLS specific screens for notification listener approval

Fixes: 141689199
Fixes: 143639217
Test: atest

Change-Id: I4ead087e0015ad33d6be4f9357de50a4298b3347
parent 2c3ba517
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -2412,6 +2412,17 @@
                       android:value="com.android.settings.notification.NotificationAccessSettings" />
        </activity>

        <activity
            android:name="Settings$NotificationAccessDetailsActivity"
            android:label="@string/manage_notification_access_title" >
            <intent-filter android:priority="1">
                <action android:name="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                       android:value="com.android.settings.applications.specialaccess.notificationaccess.NotificationAccessDetails" />
        </activity>

        <activity
            android:name="Settings$NotificationAssistantSettingsActivity"
            android:label="@string/notification_assistant_title"
+3 −0
Original line number Diff line number Diff line
@@ -8069,6 +8069,9 @@
    <!-- String to show in the list of notification listeners, when none is installed -->
    <string name="no_notification_listeners">No installed apps have requested notification access.</string>
    <!-- Button title that grants 'notification access' permission to an app [CHAR_LIMIT=60]-->
    <string name="notification_access_detail_switch">Allow notification access</string>
    <!-- Title for a warning message about security implications of enabling a notification
      assistant, displayed as a dialog message. [CHAR LIMIT=NONE] -->
    <string name="notification_assistant_security_warning_title">Allow notification access for
+27 −0
Original line number Diff line number Diff line
<?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.
  -->

<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:key="notification_access_permission_detail_settings"
    android:title="@string/manage_notification_access_title">

    <SwitchPreference
        android:key="notification_access_switch"
        android:title="@string/notification_access_detail_switch"/>

</PreferenceScreen>
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ public class Settings extends SettingsActivity {
    public static class NotificationStationActivity extends SettingsActivity { /* empty */ }
    public static class UserSettingsActivity extends SettingsActivity { /* empty */ }
    public static class NotificationAccessSettingsActivity extends SettingsActivity { /* empty */ }
    public static class NotificationAccessDetailsActivity extends SettingsActivity { /* empty */ }
    public static class VrListenersSettingsActivity extends SettingsActivity { /* empty */ }
    public static class PictureInPictureSettingsActivity extends SettingsActivity { /* empty */ }
    public static class AppPictureInPictureSettingsActivity extends SettingsActivity { /* empty */ }
+75 −0
Original line number Diff line number Diff line
/*
 * 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.
 */
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.os.Bundle;

import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;

import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;

public class FriendlyWarningDialogFragment extends InstrumentedDialogFragment {
    static final String KEY_COMPONENT = "c";
    static final String KEY_LABEL = "l";

    public FriendlyWarningDialogFragment setServiceInfo(ComponentName cn, CharSequence label,
            Fragment target) {
        Bundle args = new Bundle();
        args.putString(KEY_COMPONENT, cn.flattenToString());
        args.putCharSequence(KEY_LABEL, label);
        setArguments(args);
        setTargetFragment(target, 0);
        return this;
    }

    @Override
    public int getMetricsCategory() {
        return SettingsEnums.DIALOG_DISABLE_NOTIFICATION_ACCESS;
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        final Bundle args = getArguments();
        final CharSequence label = args.getCharSequence(KEY_LABEL);
        final ComponentName cn = ComponentName.unflattenFromString(args
                .getString(KEY_COMPONENT));
        NotificationAccessDetails parent = (NotificationAccessDetails) getTargetFragment();

        final String summary = getResources().getString(
                R.string.notification_listener_disable_warning_summary, label);
        return new AlertDialog.Builder(getContext())
                .setMessage(summary)
                .setCancelable(true)
                .setPositiveButton(R.string.notification_listener_disable_warning_confirm,
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                parent.disable(cn);
                            }
                        })
                .setNegativeButton(R.string.notification_listener_disable_warning_cancel,
                        (dialog, id) -> {
                            // pass
                        })
                .create();
    }
}
Loading