use of com.android.settings.RestrictedListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ShowOnLockScreenNotificationPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
RestrictedListPreference pref = (RestrictedListPreference) preference;
pref.clearRestrictedItems();
ArrayList<CharSequence> entries = new ArrayList<>();
ArrayList<CharSequence> values = new ArrayList<>();
String showAllEntry = mContext.getString(R.string.lock_screen_notifs_show_all);
String showAllEntryValue = Integer.toString(R.string.lock_screen_notifs_show_all);
entries.add(showAllEntry);
values.add(showAllEntryValue);
setRestrictedIfNotificationFeaturesDisabled(pref, showAllEntry, showAllEntryValue, KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
String alertingEntry = mContext.getString(R.string.lock_screen_notifs_show_alerting);
String alertingEntryValue = Integer.toString(R.string.lock_screen_notifs_show_alerting);
entries.add(alertingEntry);
values.add(alertingEntryValue);
setRestrictedIfNotificationFeaturesDisabled(pref, alertingEntry, alertingEntryValue, KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
entries.add(mContext.getString(R.string.lock_screen_notifs_show_none));
values.add(Integer.toString(R.string.lock_screen_notifs_show_none));
pref.setEntries(entries.toArray(new CharSequence[entries.size()]));
pref.setEntryValues(values.toArray(new CharSequence[values.size()]));
if (!adminAllowsNotifications() || !getLockscreenNotificationsEnabled()) {
pref.setValue(Integer.toString(R.string.lock_screen_notifs_show_none));
} else if (!getLockscreenSilentNotificationsEnabled()) {
pref.setValue(Integer.toString(R.string.lock_screen_notifs_show_alerting));
} else {
pref.setValue(Integer.toString(R.string.lock_screen_notifs_show_all));
}
pref.setOnPreferenceChangeListener(this);
refreshSummary(preference);
}
use of com.android.settings.RestrictedListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class VisibilityPreferenceController method updateState.
public void updateState(Preference preference) {
if (mChannel != null && mAppRow != null) {
RestrictedListPreference pref = (RestrictedListPreference) preference;
ArrayList<CharSequence> entries = new ArrayList<>();
ArrayList<CharSequence> values = new ArrayList<>();
pref.clearRestrictedItems();
if (getLockscreenNotificationsEnabled() && getLockscreenAllowPrivateNotifications()) {
final String summaryShowEntry = mContext.getString(R.string.lock_screen_notifications_summary_show);
final String summaryShowEntryValue = Integer.toString(NotificationManager.VISIBILITY_NO_OVERRIDE);
entries.add(summaryShowEntry);
values.add(summaryShowEntryValue);
setRestrictedIfNotificationFeaturesDisabled(pref, summaryShowEntry, summaryShowEntryValue, DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS | DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS);
}
if (getLockscreenNotificationsEnabled()) {
final String summaryHideEntry = mContext.getString(R.string.lock_screen_notifications_summary_hide);
final String summaryHideEntryValue = Integer.toString(Notification.VISIBILITY_PRIVATE);
entries.add(summaryHideEntry);
values.add(summaryHideEntryValue);
setRestrictedIfNotificationFeaturesDisabled(pref, summaryHideEntry, summaryHideEntryValue, DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
}
entries.add(mContext.getString(R.string.lock_screen_notifications_summary_disable));
values.add(Integer.toString(Notification.VISIBILITY_SECRET));
pref.setEntries(entries.toArray(new CharSequence[entries.size()]));
pref.setEntryValues(values.toArray(new CharSequence[values.size()]));
if (mChannel.getLockscreenVisibility() == NotificationListenerService.Ranking.VISIBILITY_NO_OVERRIDE) {
pref.setValue(Integer.toString(getGlobalVisibility()));
} else {
pref.setValue(Integer.toString(mChannel.getLockscreenVisibility()));
}
pref.setSummary("%s");
}
}
use of com.android.settings.RestrictedListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SoundTimeoutPreferenceController method updateState.
public void updateState(Preference preference) {
if (mAppRow != null) {
RestrictedListPreference pref = (RestrictedListPreference) preference;
pref.setDisabledByAdmin(mAdmin);
pref.setSummary("%s");
pref.setValue(Long.toString(mAppRow.soundTimeout));
}
}
use of com.android.settings.RestrictedListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class VisibilityPreferenceControllerTest method testUpdateState_noGlobalRestriction.
@Test
public void testUpdateState_noGlobalRestriction() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
mController.onResume(appRow, channel, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
ArgumentCaptor<CharSequence[]> argumentCaptor = ArgumentCaptor.forClass(CharSequence[].class);
verify(pref, times(1)).setEntryValues(argumentCaptor.capture());
List<String> values = toStringList(argumentCaptor.getValue());
assertEquals(3, values.size());
assertTrue(values.contains(String.valueOf(VISIBILITY_NO_OVERRIDE)));
assertTrue(values.contains(String.valueOf(VISIBILITY_PRIVATE)));
assertTrue(values.contains(String.valueOf(Notification.VISIBILITY_SECRET)));
}
use of com.android.settings.RestrictedListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class VisibilityPreferenceControllerTest method testOnPreferenceChange_noOverride.
@Test
public void testOnPreferenceChange_noOverride() {
Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", 4);
channel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
mController.onResume(appRow, channel, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
mController.onPreferenceChange(pref, String.valueOf(VISIBILITY_PRIVATE));
assertEquals(VISIBILITY_NO_OVERRIDE, channel.getLockscreenVisibility());
verify(mBackend, times(1)).updateChannel(any(), anyInt(), any());
}
Aggregations