Search in sources :

Example 41 with PreferenceCategory

use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.

the class LocationInjectedServicesForWorkPreferenceController method injectLocationServices.

@Override
protected void injectLocationServices(PreferenceScreen screen) {
    final PreferenceCategory categoryLocationServices = screen.findPreference(getPreferenceKey());
    final Map<Integer, List<Preference>> prefs = getLocationServices();
    for (Map.Entry<Integer, List<Preference>> entry : prefs.entrySet()) {
        for (Preference pref : entry.getValue()) {
            if (pref instanceof RestrictedAppPreference) {
                ((RestrictedAppPreference) pref).checkRestrictionAndSetDisabled();
            }
        }
        if (entry.getKey() != UserHandle.myUserId()) {
            LocationSettings.addPreferencesSorted(entry.getValue(), categoryLocationServices);
        }
    }
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) RestrictedAppPreference(com.android.settings.widget.RestrictedAppPreference) Preference(androidx.preference.Preference) List(java.util.List) RestrictedAppPreference(com.android.settings.widget.RestrictedAppPreference) Map(java.util.Map)

Example 42 with PreferenceCategory

use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.

the class AppBubbleListPreferenceControllerTest method clickConversationPref_updatesChannel.

@Test
public void clickConversationPref_updatesChannel() {
    NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
    appRow.bubblePreference = BUBBLE_PREFERENCE_ALL;
    appRow.pkg = "PKG";
    mController.onResume(appRow, null, null, null, null, null, null);
    mController.mPreference = new PreferenceCategory(mContext);
    ConversationChannelWrapper ccw = mConvoList.getList().get(0);
    AppBubbleListPreferenceController.ConversationPreference pref = (AppBubbleListPreferenceController.ConversationPreference) mController.createConversationPref(ccw);
    pref.onClick(null);
    verify(ccw.getNotificationChannel()).setAllowBubbles(DEFAULT_ALLOW_BUBBLE);
    verify(mBackend).updateChannel(anyString(), anyInt(), any(NotificationChannel.class));
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationBackend(com.android.settings.notification.NotificationBackend) PreferenceCategory(androidx.preference.PreferenceCategory) ConversationChannelWrapper(android.service.notification.ConversationChannelWrapper) AppBubbleListPreferenceController(com.android.settings.notification.AppBubbleListPreferenceController) Test(org.junit.Test)

Example 43 with PreferenceCategory

use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.

the class EnterpriseSetDefaultAppsListPreferenceController method updateUi.

private void updateUi() {
    final Context prefContext = mParent.getPreferenceManager().getContext();
    final PreferenceScreen screen = mParent.getPreferenceScreen();
    if (screen == null) {
        return;
    }
    if (!mEnterprisePrivacyFeatureProvider.isInCompMode() && mUsers.size() == 1) {
        createPreferences(prefContext, screen, mApps.get(0));
    } else {
        for (int i = 0; i < mUsers.size(); i++) {
            final UserInfo userInfo = mUsers.get(i);
            final PreferenceCategory category = new PreferenceCategory(prefContext);
            screen.addPreference(category);
            if (userInfo.isManagedProfile()) {
                category.setTitle(R.string.category_work);
            } else {
                category.setTitle(R.string.category_personal);
            }
            category.setOrder(i);
            createPreferences(prefContext, category, mApps.get(i));
        }
    }
}
Also used : Context(android.content.Context) PreferenceScreen(androidx.preference.PreferenceScreen) PreferenceCategory(androidx.preference.PreferenceCategory) UserInfo(android.content.pm.UserInfo)

Example 44 with PreferenceCategory

use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.

the class AllConversationsPreferenceController method updateState.

@Override
public void updateState(Preference preference) {
    PreferenceCategory pref = (PreferenceCategory) preference;
    // Load conversations
    mConversations = mBackend.getConversations(false).getList();
    Collections.sort(mConversations, mConversationComparator);
    populateList(mConversations, pref);
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory)

Example 45 with PreferenceCategory

use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.

the class UsbDetailsTranscodeMtpControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    mPreferenceManager = new PreferenceManager(mContext);
    mScreen = mPreferenceManager.createPreferenceScreen(mContext);
    when(mFragment.getActivity()).thenReturn(mActivity);
    when(mActivity.getApplicationContext()).thenReturn(mContext);
    when(mFragment.getContext()).thenReturn(mContext);
    when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
    when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
    mUnderTest = new UsbDetailsTranscodeMtpController(mContext, mFragment, mUsbBackend);
    mPreference = new PreferenceCategory(mContext);
    mPreference.setKey(mUnderTest.getPreferenceKey());
    mScreen.addPreference(mPreference);
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Aggregations

PreferenceCategory (androidx.preference.PreferenceCategory)111 Preference (androidx.preference.Preference)38 PreferenceManager (androidx.preference.PreferenceManager)24 Before (org.junit.Before)24 PreferenceScreen (androidx.preference.PreferenceScreen)22 Test (org.junit.Test)19 SwitchPreference (androidx.preference.SwitchPreference)13 NotificationChannel (android.app.NotificationChannel)11 ArrayList (java.util.ArrayList)11 NotificationChannelGroup (android.app.NotificationChannelGroup)9 ShortcutInfo (android.content.pm.ShortcutInfo)9 Context (android.content.Context)8 ConversationChannel (android.app.people.ConversationChannel)7 View (android.view.View)7 PreferenceViewHolder (androidx.preference.PreferenceViewHolder)7 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)7 ListPreference (androidx.preference.ListPreference)6 ComponentName (android.content.ComponentName)5 ContentResolver (android.content.ContentResolver)5 Bundle (android.os.Bundle)5