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

@@ -750,8 +750,6 @@
<string name="encryption_and_credential_settings_summary">Phone encrypted</string> <string name="encryption_and_credential_settings_summary">Phone encrypted</string>
<!-- Security Settings screen setting option title for the item to take you to the lock screen preference screen [CHAR LIMIT=60] --> <!-- Security Settings screen setting option title for the item to take you to the lock screen preference screen [CHAR LIMIT=60] -->
<string name="lockscreen_settings_title">Lock screen preferences</string> <string name="lockscreen_settings_title">Lock screen preferences</string>
<!-- Security Settings screen setting option summary for the item to take you to the lock screen preference screen -->
<string name="lockscreen_settings_summary">Show all notification content</string>
<!-- Main Settings screen setting option summary text for the item tot ake you to the security and location screen --> <!-- Main Settings screen setting option summary text for the item tot ake you to the security and location screen -->
<string name="security_settings_summary">Set My Location, screen unlock, SIM card lock, credential storage lock</string> <string name="security_settings_summary">Set My Location, screen unlock, SIM card lock, credential storage lock</string>

View File

@@ -31,7 +31,6 @@
<Preference android:key="lockscreen_preferences" <Preference android:key="lockscreen_preferences"
android:title="@string/lockscreen_settings_title" android:title="@string/lockscreen_settings_title"
android:summary="@string/lockscreen_settings_summary"
android:fragment="com.android.settings.security.LockscreenDashboardFragment"/> android:fragment="com.android.settings.security.LockscreenDashboardFragment"/>
</PreferenceCategory> </PreferenceCategory>

View File

@@ -30,7 +30,6 @@
<Preference android:key="lockscreen_preferences" <Preference android:key="lockscreen_preferences"
android:title="@string/lockscreen_settings_title" android:title="@string/lockscreen_settings_title"
android:summary="@string/lockscreen_settings_summary"
android:fragment="com.android.settings.security.LockscreenDashboardFragment"/> android:fragment="com.android.settings.security.LockscreenDashboardFragment"/>
</PreferenceCategory> </PreferenceCategory>

View File

@@ -30,7 +30,6 @@
<Preference android:key="lockscreen_preferences" <Preference android:key="lockscreen_preferences"
android:title="@string/lockscreen_settings_title" android:title="@string/lockscreen_settings_title"
android:summary="@string/lockscreen_settings_summary"
android:fragment="com.android.settings.security.LockscreenDashboardFragment"/> android:fragment="com.android.settings.security.LockscreenDashboardFragment"/>
</PreferenceCategory> </PreferenceCategory>

View File

@@ -30,7 +30,6 @@
<Preference android:key="lockscreen_preferences" <Preference android:key="lockscreen_preferences"
android:title="@string/lockscreen_settings_title" android:title="@string/lockscreen_settings_title"
android:summary="@string/lockscreen_settings_summary"
android:fragment="com.android.settings.security.LockscreenDashboardFragment"/> android:fragment="com.android.settings.security.LockscreenDashboardFragment"/>
</PreferenceCategory> </PreferenceCategory>

View File

@@ -60,6 +60,7 @@ import com.android.settings.enterprise.EnterprisePrivacyPreferenceController;
import com.android.settings.enterprise.ManageDeviceAdminPreferenceController; import com.android.settings.enterprise.ManageDeviceAdminPreferenceController;
import com.android.settings.fingerprint.FingerprintSettings; import com.android.settings.fingerprint.FingerprintSettings;
import com.android.settings.location.LocationPreferenceController; import com.android.settings.location.LocationPreferenceController;
import com.android.settings.notification.LockScreenNotificationPreferenceController;
import com.android.settings.overlay.FeatureFactory; import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable; import com.android.settings.search.Indexable;
@@ -103,6 +104,8 @@ public class SecuritySettings extends SettingsPreferenceFragment
@VisibleForTesting @VisibleForTesting
static final String KEY_MANAGE_TRUST_AGENTS = "manage_trust_agents"; static final String KEY_MANAGE_TRUST_AGENTS = "manage_trust_agents";
private static final String KEY_UNIFICATION = "unification"; 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 SET_OR_CHANGE_LOCK_METHOD_REQUEST = 123;
private static final int CHANGE_TRUST_AGENT_SETTINGS = 126; private static final int CHANGE_TRUST_AGENT_SETTINGS = 126;
@@ -169,6 +172,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
private LocationPreferenceController mLocationcontroller; private LocationPreferenceController mLocationcontroller;
private ManageDeviceAdminPreferenceController mManageDeviceAdminPreferenceController; private ManageDeviceAdminPreferenceController mManageDeviceAdminPreferenceController;
private EnterprisePrivacyPreferenceController mEnterprisePrivacyPreferenceController; private EnterprisePrivacyPreferenceController mEnterprisePrivacyPreferenceController;
private LockScreenNotificationPreferenceController mLockScreenNotificationPreferenceController;
@Override @Override
public int getMetricsCategory() { public int getMetricsCategory() {
@@ -210,6 +214,8 @@ public class SecuritySettings extends SettingsPreferenceFragment
= new ManageDeviceAdminPreferenceController(activity); = new ManageDeviceAdminPreferenceController(activity);
mEnterprisePrivacyPreferenceController mEnterprisePrivacyPreferenceController
= new EnterprisePrivacyPreferenceController(activity, null /* lifecycle */); = new EnterprisePrivacyPreferenceController(activity, null /* lifecycle */);
mLockScreenNotificationPreferenceController
= new LockScreenNotificationPreferenceController(activity);
} }
private static int getResIdForLockUnlockScreen(Context context, private static int getResIdForLockUnlockScreen(Context context,
@@ -317,6 +323,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
if (securityCategory != null) { if (securityCategory != null) {
maybeAddFingerprintPreference(securityCategory, UserHandle.myUserId()); maybeAddFingerprintPreference(securityCategory, UserHandle.myUserId());
numberOfTrustAgent = addTrustAgentSettings(securityCategory); numberOfTrustAgent = addTrustAgentSettings(securityCategory);
setLockscreenPreferencesSummary(securityCategory);
} }
mVisiblePatternProfile = 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. * Sets the preference as disabled by admin if PASSWORD_QUALITY_MANAGED is set.
* The preference must be a RestrictedPreference. * 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() { private void updateLockscreenNotifications() {
if (mLockscreen == null) { if (mLockscreen == null) {
return; return;
} }
final boolean enabled = getLockscreenNotificationsEnabled(UserHandle.myUserId()); mLockscreenSelectedValue = getSummaryResource();
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;
mLockscreen.setValue(Integer.toString(mLockscreenSelectedValue)); mLockscreen.setValue(Integer.toString(mLockscreenSelectedValue));
} }

View File

@@ -24,10 +24,12 @@ import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle; import android.os.Bundle;
import android.provider.Settings; import android.provider.Settings;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceScreen; import android.support.v7.preference.PreferenceScreen;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
import com.android.settings.dashboard.SummaryLoader; import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.notification.LockScreenNotificationPreferenceController;
import com.android.settings.testutils.FakeFeatureFactory; import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.shadow.ShadowSecureSettings; import com.android.settings.testutils.shadow.ShadowSecureSettings;
import com.android.settingslib.drawer.DashboardCategory; import com.android.settingslib.drawer.DashboardCategory;
@@ -47,6 +49,7 @@ import org.robolectric.shadows.ShadowApplication;
import org.robolectric.util.ReflectionHelpers; import org.robolectric.util.ReflectionHelpers;
import java.util.Map; import java.util.Map;
import org.robolectric.util.ReflectionHelpers;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
@@ -186,4 +189,22 @@ public class SecuritySettingsTest {
verify(preference).setSummary(context.getResources().getQuantityString( verify(preference).setSummary(context.getResources().getQuantityString(
R.plurals.manage_trust_agents_summary_on, 2, 2)); R.plurals.manage_trust_agents_summary_on, 2, 2));
} }
@Test
public void testSetLockscreenPreferencesSummary_shouldSetSummaryFromLockScreenNotification() {
final Preference preference = mock(Preference.class);
final PreferenceGroup group = mock(PreferenceGroup.class);
when(group.findPreference(SecuritySettings.KEY_LOCKSCREEN_PREFERENCES))
.thenReturn(preference);
final LockScreenNotificationPreferenceController controller =
mock(LockScreenNotificationPreferenceController.class);
final SecuritySettings securitySettings = new SecuritySettings();
ReflectionHelpers.setField(securitySettings,
"mLockScreenNotificationPreferenceController", controller);
when(controller.getSummaryResource()).thenReturn(1234);
securitySettings.setLockscreenPreferencesSummary(group);
verify(preference).setSummary(1234);
}
} }