Search in sources :

Example 6 with RestrictedListPreference

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);
}
Also used : ArrayList(java.util.ArrayList) RestrictedListPreference(com.android.settings.RestrictedListPreference)

Example 7 with RestrictedListPreference

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");
    }
}
Also used : ArrayList(java.util.ArrayList) RestrictedListPreference(com.android.settings.RestrictedListPreference)

Example 8 with RestrictedListPreference

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));
    }
}
Also used : RestrictedListPreference(com.android.settings.RestrictedListPreference)

Example 9 with RestrictedListPreference

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)));
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedListPreference(com.android.settings.RestrictedListPreference) Test(org.junit.Test)

Example 10 with RestrictedListPreference

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());
}
Also used : NotificationChannel(android.app.NotificationChannel) RestrictedListPreference(com.android.settings.RestrictedListPreference) Test(org.junit.Test)

Aggregations

RestrictedListPreference (com.android.settings.RestrictedListPreference)14 NotificationChannel (android.app.NotificationChannel)10 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)4 UserInfo (android.content.pm.UserInfo)3 ComponentName (android.content.ComponentName)2 Before (org.junit.Before)1