Merge "Add summary text to Lock screen preferences." into oc-dev

This commit is contained in:
TreeHugger Robot
2017-04-07 20:03:35 +00:00
committed by Android (Google) Code Review
8 changed files with 47 additions and 12 deletions

View File

@@ -60,6 +60,7 @@ import com.android.settings.enterprise.EnterprisePrivacyPreferenceController;
import com.android.settings.enterprise.ManageDeviceAdminPreferenceController;
import com.android.settings.fingerprint.FingerprintSettings;
import com.android.settings.location.LocationPreferenceController;
import com.android.settings.notification.LockScreenNotificationPreferenceController;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
@@ -103,6 +104,8 @@ public class SecuritySettings extends SettingsPreferenceFragment
@VisibleForTesting
static final String KEY_MANAGE_TRUST_AGENTS = "manage_trust_agents";
private static final String KEY_UNIFICATION = "unification";
@VisibleForTesting
static final String KEY_LOCKSCREEN_PREFERENCES = "lockscreen_preferences";
private static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST = 123;
private static final int CHANGE_TRUST_AGENT_SETTINGS = 126;
@@ -169,6 +172,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
private LocationPreferenceController mLocationcontroller;
private ManageDeviceAdminPreferenceController mManageDeviceAdminPreferenceController;
private EnterprisePrivacyPreferenceController mEnterprisePrivacyPreferenceController;
private LockScreenNotificationPreferenceController mLockScreenNotificationPreferenceController;
@Override
public int getMetricsCategory() {
@@ -210,6 +214,8 @@ public class SecuritySettings extends SettingsPreferenceFragment
= new ManageDeviceAdminPreferenceController(activity);
mEnterprisePrivacyPreferenceController
= new EnterprisePrivacyPreferenceController(activity, null /* lifecycle */);
mLockScreenNotificationPreferenceController
= new LockScreenNotificationPreferenceController(activity);
}
private static int getResIdForLockUnlockScreen(Context context,
@@ -317,6 +323,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
if (securityCategory != null) {
maybeAddFingerprintPreference(securityCategory, UserHandle.myUserId());
numberOfTrustAgent = addTrustAgentSettings(securityCategory);
setLockscreenPreferencesSummary(securityCategory);
}
mVisiblePatternProfile =
@@ -423,6 +430,15 @@ public class SecuritySettings extends SettingsPreferenceFragment
}
}
@VisibleForTesting
void setLockscreenPreferencesSummary(PreferenceGroup group) {
final Preference lockscreenPreferences = group.findPreference(KEY_LOCKSCREEN_PREFERENCES);
if (lockscreenPreferences != null) {
lockscreenPreferences.setSummary(
mLockScreenNotificationPreferenceController.getSummaryResource());
}
}
/*
* Sets the preference as disabled by admin if PASSWORD_QUALITY_MANAGED is set.
* The preference must be a RestrictedPreference.

View File

@@ -267,16 +267,20 @@ public class LockScreenNotificationPreferenceController extends PreferenceContro
}
}
public int getSummaryResource() {
final boolean enabled = getLockscreenNotificationsEnabled(UserHandle.myUserId());
final boolean allowPrivate = !mSecure
|| getLockscreenAllowPrivateNotifications(UserHandle.myUserId());
return !enabled ? R.string.lock_screen_notifications_summary_disable :
allowPrivate ? R.string.lock_screen_notifications_summary_show :
R.string.lock_screen_notifications_summary_hide;
}
private void updateLockscreenNotifications() {
if (mLockscreen == null) {
return;
}
final boolean enabled = getLockscreenNotificationsEnabled(UserHandle.myUserId());
final boolean allowPrivate = !mSecure
|| getLockscreenAllowPrivateNotifications(UserHandle.myUserId());
mLockscreenSelectedValue = !enabled ? R.string.lock_screen_notifications_summary_disable :
allowPrivate ? R.string.lock_screen_notifications_summary_show :
R.string.lock_screen_notifications_summary_hide;
mLockscreenSelectedValue = getSummaryResource();
mLockscreen.setValue(Integer.toString(mLockscreenSelectedValue));
}