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

Commit 28c44ebf authored by Sudheer Shanka's avatar Sudheer Shanka Committed by android-build-merger
Browse files

Merge "Add policy transparency to app notification settings on lockscreen." into nyc-dev

am: 938501cf

* commit '938501cf':
  Add policy transparency to app notification settings on lockscreen.

Change-Id: I7d9b313218cce94d6711d4ffa5df9a3c99d391c0
parents 29b86d10 938501cf
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2016 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
  -->
<FrameLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    <view android:id="@+id/spinner"
            class="com.android.settings.notification.RestrictedDropDownPreference$ReselectionSpinner"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:visibility="invisible" />

    <include layout="@layout/preference_material" />

</FrameLayout>
 No newline at end of file
+36 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center_vertical">
    <TextView android:id="@android:id/text1"
            style="?android:attr/spinnerDropDownItemStyle"
            android:singleLine="true"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="?android:attr/listPreferredItemHeightSmall"
            android:ellipsize="marquee" />
    <ImageView android:id="@+id/restricted_icon"
            android:layout_width="@dimen/restricted_icon_size"
            android:layout_height="@dimen/restricted_icon_size"
            android:src="@drawable/ic_info"
            android:baselineAlignBottom="true"
            android:layout_marginEnd="@dimen/restricted_icon_padding"
            android:gravity="end|center_vertical"
            android:visibility="gone" />
</LinearLayout>
 No newline at end of file
+2 −3
Original line number Diff line number Diff line
@@ -17,8 +17,7 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
        android:title="@string/app_notifications_title"
        android:key="app_notification_settings"
        settings:keywords="@string/keywords_date_and_time">
        android:key="app_notification_settings">

    <!-- Importance -->
    <!-- Block -->
@@ -43,7 +42,7 @@
            android:order="4"/>

    <!-- Visibility Override -->
    <DropDownPreference
    <com.android.settings.notification.RestrictedDropDownPreference
            android:key="visibility_override"
            android:title="@string/app_notification_visibility_override_title"
            android:order="5" />
+1 −2
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import android.content.pm.UserInfo;
import android.os.Bundle;
import android.os.UserHandle;
import android.service.notification.NotificationListenerService.Ranking;
import android.support.v7.preference.DropDownPreference;
import android.util.ArrayMap;
import android.util.Log;

@@ -76,7 +75,7 @@ public class AppNotificationSettings extends NotificationSettingsBase {
        mPriority =
                (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BYPASS_DND);
        mVisibilityOverride =
                (DropDownPreference) getPreferenceScreen().findPreference(
                (RestrictedDropDownPreference) getPreferenceScreen().findPreference(
                        KEY_VISIBILITY_OVERRIDE);
        mBlock = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BLOCK);
        mSilent = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_SILENT);
+31 −6
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;

import android.app.Notification;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
@@ -33,7 +34,6 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.service.notification.NotificationListenerService.Ranking;
import android.support.v7.preference.DropDownPreference;
import android.support.v7.preference.Preference;
import android.text.TextUtils;
import android.util.Log;
@@ -41,6 +41,7 @@ import android.widget.Toast;

import java.util.ArrayList;

import static com.android.settings.notification.RestrictedDropDownPreference.RestrictedItem;
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;

abstract public class NotificationSettingsBase extends SettingsPreferenceFragment {
@@ -65,7 +66,7 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
    protected PackageInfo mPkgInfo;
    protected ImportanceSeekBarPreference mImportance;
    protected RestrictedSwitchPreference mPriority;
    protected DropDownPreference mVisibilityOverride;
    protected RestrictedDropDownPreference mVisibilityOverride;
    protected RestrictedSwitchPreference mBlock;
    protected RestrictedSwitchPreference mSilent;
    protected EnforcedAdmin mSuspendedAppsAdmin;
@@ -148,6 +149,9 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
        if (mSilent != null) {
            mSilent.setDisabledByAdmin(mSuspendedAppsAdmin);
        }
        if (mVisibilityOverride != null) {
            mVisibilityOverride.setDisabledByAdmin(mSuspendedAppsAdmin);
        }
    }

    protected void setupImportancePrefs(boolean isSystemApp, int importance, boolean banned) {
@@ -216,13 +220,24 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
        ArrayList<CharSequence> entries = new ArrayList<>();
        ArrayList<CharSequence> values = new ArrayList<>();

        mVisibilityOverride.clearRestrictedItems();
        if (getLockscreenNotificationsEnabled() && getLockscreenAllowPrivateNotifications()) {
            entries.add(getString(R.string.lock_screen_notifications_summary_show));
            values.add(Integer.toString(Ranking.VISIBILITY_NO_OVERRIDE));
            final String summaryShowEntry =
                    getString(R.string.lock_screen_notifications_summary_show);
            final String summaryShowEntryValue = Integer.toString(Ranking.VISIBILITY_NO_OVERRIDE);
            entries.add(summaryShowEntry);
            values.add(summaryShowEntryValue);
            setRestrictedIfNotificationFeaturesDisabled(summaryShowEntry, summaryShowEntryValue,
                    DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS
                            | DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS);
        }

        entries.add(getString(R.string.lock_screen_notifications_summary_hide));
        values.add(Integer.toString(Notification.VISIBILITY_PRIVATE));
        final String summaryHideEntry = getString(R.string.lock_screen_notifications_summary_hide);
        final String summaryHideEntryValue = Integer.toString(Notification.VISIBILITY_PRIVATE);
        entries.add(summaryHideEntry);
        values.add(summaryHideEntryValue);
        setRestrictedIfNotificationFeaturesDisabled(summaryHideEntry, summaryHideEntryValue,
                DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
        entries.add(getString(R.string.lock_screen_notifications_summary_disable));
        values.add(Integer.toString(Notification.VISIBILITY_SECRET));
        mVisibilityOverride.setEntries(entries.toArray(new CharSequence[entries.size()]));
@@ -248,6 +263,16 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
        });
    }

    private void setRestrictedIfNotificationFeaturesDisabled(CharSequence entry,
            CharSequence entryValue, int keyguardNotificationFeatures) {
        EnforcedAdmin admin = RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
                mContext, keyguardNotificationFeatures, mUserId);
        if (admin != null) {
            RestrictedItem item = new RestrictedItem(entry, entryValue, admin);
            mVisibilityOverride.addRestrictedItem(item);
        }
    }

    private int getGlobalVisibility() {
        int globalVis = Ranking.VISIBILITY_NO_OVERRIDE;
        if (!getLockscreenNotificationsEnabled()) {
Loading