Make Lockscreen Notification Content work for profiles

The settings for the Notification Content is user-dependent
and the correct values are used in the lock screen.

Bug: 26709332
Change-Id: I7acf94014771dacc2841da336bed645fdb948541
This commit is contained in:
Clara Bayarri
2016-01-25 17:21:24 +00:00
parent 0c7bce8222
commit f6077f4757
8 changed files with 58 additions and 17 deletions

View File

@@ -24,6 +24,7 @@
android:paddingEnd="?attr/side_margin">
<TextView
android:id="@+id/message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/redaction_vertical_margins"

View File

@@ -5829,6 +5829,26 @@
<!-- Security > Choose PIN/PW/Pattern > Notification redaction interstitial: Title for the screen asking the user how they want their notifications to appear when the device is locked [CHAR LIMIT=30] -->
<string name="lock_screen_notifications_interstitial_title">Notifications</string>
<!-- Configure Notifications: Value for lockscreen notifications: all information will be
shown in profile notifications shown on a secure lock screen
[CHAR LIMIT=50] -->
<string name="lock_screen_notifications_summary_show_profile">Show all profile notification content</string>
<!-- Configure Notifications: Value for lockscreen notifications: sensitive information will be
hidden or redacted from profile notifications shown on a secure lock screen
[CHAR LIMIT=50] -->
<string name="lock_screen_notifications_summary_hide_profile">Hide sensitive profile notification content</string>
<!-- Configure Notifications: Value for lockscreen notifications: profile notifications will not appear on a secure lock screen
[CHAR LIMIT=50] -->
<string name="lock_screen_notifications_summary_disable_profile">Don\u2019t show profile notifications at all</string>
<!-- Security > Choose PIN/PW/Pattern > Notification redaction interstitial: Message asking the user how they want their profile notifications to appear when the device is locked [CHAR LIMIT=NONE] -->
<string name="lock_screen_notifications_interstitial_message_profile">When your device is locked, how do you want profile notifications to show?</string>
<!-- Security > Choose PIN/PW/Pattern > Notification redaction interstitial: Title for the screen asking the user how they want their profile notifications to appear when the device is locked [CHAR LIMIT=30] -->
<string name="lock_screen_notifications_interstitial_title_profile">Profile notifications</string>
<!-- Notification Settings: Title for the option managing notifications per application. [CHAR LIMIT=30] -->
<string name="app_notifications_title">Notifications</string>

View File

@@ -399,7 +399,7 @@ public class ChooseLockPassword extends SettingsActivity {
}
protected Intent getRedactionInterstitialIntent(Context context) {
return RedactionInterstitial.createStartIntent(context);
return RedactionInterstitial.createStartIntent(context, mUserId);
}
protected void updateStage(Stage stage) {

View File

@@ -465,7 +465,7 @@ public class ChooseLockPattern extends SettingsActivity {
}
protected Intent getRedactionInterstitialIntent(Context context) {
return RedactionInterstitial.createStartIntent(context);
return RedactionInterstitial.createStartIntent(context, mUserId);
}
public void handleLeftButton() {

View File

@@ -21,6 +21,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.UserHandle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -39,7 +40,7 @@ import com.android.setupwizardlib.view.NavigationBar;
public class SetupRedactionInterstitial extends RedactionInterstitial {
public static Intent createStartIntent(Context ctx) {
Intent startIntent = RedactionInterstitial.createStartIntent(ctx);
Intent startIntent = RedactionInterstitial.createStartIntent(ctx, UserHandle.myUserId());
if (startIntent != null) {
startIntent.setClass(ctx, SetupRedactionInterstitial.class);
startIntent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)

View File

@@ -304,7 +304,7 @@ public class FingerprintSettings extends SubSettings {
TextView v = (TextView) LayoutInflater.from(view.getContext()).inflate(
R.layout.fingerprint_settings_footer, null);
EnforcedAdmin admin = RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
getActivity(), DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT);
getActivity(), DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT, mUserId);
v.setText(LearnMoreSpan.linkify(getText(admin != null
? R.string.security_settings_fingerprint_enroll_disclaimer_lockscreen_disabled
: R.string.security_settings_fingerprint_enroll_disclaimer),

View File

@@ -192,7 +192,7 @@ public class ConfigureNotificationSettings extends SettingsPreferenceFragment {
private void setRestrictedIfNotificationFeaturesDisabled(CharSequence entry,
CharSequence entryValue, int keyguardNotificationFeatures) {
EnforcedAdmin admin = RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
mContext, keyguardNotificationFeatures);
mContext, keyguardNotificationFeatures, UserHandle.myUserId());
if (admin != null) {
RestrictedItem item = new RestrictedItem(entry, entryValue, admin);
mLockscreen.addRestrictedItem(item);

View File

@@ -19,18 +19,21 @@ package com.android.settings.notification;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.UserManager;
import android.provider.Settings;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.RestrictedRadioButton;
import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
import com.android.settingslib.RestrictedLockUtils;
import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS;
@@ -57,14 +60,17 @@ public class RedactionInterstitial extends SettingsActivity {
* @return An intent to launch the activity is if is available, @null if the activity is not
* available to be launched.
*/
public static Intent createStartIntent(Context ctx) {
public static Intent createStartIntent(Context ctx, int userId) {
return new Intent(ctx, RedactionInterstitial.class)
.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, true)
.putExtra(EXTRA_PREFS_SET_BACK_TEXT, (String) null)
.putExtra(EXTRA_PREFS_SET_NEXT_TEXT, ctx.getString(
R.string.app_notifications_dialog_done))
.putExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID,
R.string.lock_screen_notifications_interstitial_title);
Utils.isManagedProfile(UserManager.get(ctx), userId)
? R.string.lock_screen_notifications_interstitial_title_profile
: R.string.lock_screen_notifications_interstitial_title)
.putExtra(Intent.EXTRA_USER_ID, userId);
}
public static class RedactionInterstitialFragment extends SettingsPreferenceFragment
@@ -73,6 +79,7 @@ public class RedactionInterstitial extends SettingsActivity {
private RadioGroup mRadioGroup;
private RestrictedRadioButton mShowAllButton;
private RestrictedRadioButton mRedactSensitiveButton;
private int mUserId;
@Override
protected int getMetricsCategory() {
@@ -90,9 +97,21 @@ public class RedactionInterstitial extends SettingsActivity {
super.onViewCreated(view, savedInstanceState);
mRadioGroup = (RadioGroup) view.findViewById(R.id.radio_group);
mShowAllButton = (RestrictedRadioButton) view.findViewById(R.id.show_all);
mRedactSensitiveButton = (RestrictedRadioButton) view.findViewById(R.id.redact_sensitive);
mRedactSensitiveButton =
(RestrictedRadioButton) view.findViewById(R.id.redact_sensitive);
mRadioGroup.setOnCheckedChangeListener(this);
mUserId = Utils.getUserIdFromBundle(
getContext(), getActivity().getIntent().getExtras());
if (Utils.isManagedProfile(UserManager.get(getContext()), mUserId)) {
((TextView) view.findViewById(R.id.message))
.setText(R.string.lock_screen_notifications_interstitial_message_profile);
mShowAllButton.setText(R.string.lock_screen_notifications_summary_show_profile);
mRedactSensitiveButton
.setText(R.string.lock_screen_notifications_summary_hide_profile);
((RadioButton) view.findViewById(R.id.hide_all))
.setText(R.string.lock_screen_notifications_summary_disable_profile);
}
}
@Override
@@ -111,15 +130,15 @@ public class RedactionInterstitial extends SettingsActivity {
private void checkNotificationFeaturesAndSetDisabled(RestrictedRadioButton button,
int keyguardNotifications) {
EnforcedAdmin admin = RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
getActivity(), keyguardNotifications);
getActivity(), keyguardNotifications, mUserId);
button.setDisabledByAdmin(admin);
}
private void loadFromSettings() {
final boolean enabled = Settings.Secure.getInt(getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0;
final boolean show = Settings.Secure.getInt(getContentResolver(),
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1) != 0;
final boolean enabled = Settings.Secure.getIntForUser(getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0, mUserId) != 0;
final boolean show = Settings.Secure.getIntForUser(getContentResolver(),
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1, mUserId) != 0;
int checkedButtonId = R.id.hide_all;
if (enabled) {
@@ -138,10 +157,10 @@ public class RedactionInterstitial extends SettingsActivity {
final boolean show = (checkedId == R.id.show_all);
final boolean enabled = (checkedId != R.id.hide_all);
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, show ? 1 : 0);
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, enabled ? 1 : 0);
Settings.Secure.putIntForUser(getContentResolver(),
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, show ? 1 : 0, mUserId);
Settings.Secure.putIntForUser(getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, enabled ? 1 : 0, mUserId);
}
}
}