Search in sources :

Example 31 with PreferenceCategory

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

the class ChannelListPreferenceController method updateFullList.

/**
 * Update the preferences group to match the
 * @param groupPrefsList
 * @param channelGroups
 */
void updateFullList(@NonNull PreferenceCategory groupPrefsList, @NonNull List<NotificationChannelGroup> channelGroups) {
    if (channelGroups.isEmpty()) {
        if (groupPrefsList.getPreferenceCount() == 1 && KEY_ZERO_CATEGORIES.equals(groupPrefsList.getPreference(0).getKey())) {
            // Ensure the titles are correct for the current language, but otherwise leave alone
            PreferenceGroup groupCategory = (PreferenceGroup) groupPrefsList.getPreference(0);
            groupCategory.setTitle(R.string.notification_channels);
            groupCategory.getPreference(0).setTitle(R.string.no_channels);
        } else {
            // Clear any contents and create the 'zero-categories' group.
            groupPrefsList.removeAll();
            PreferenceCategory groupCategory = new PreferenceCategory(mContext);
            groupCategory.setTitle(R.string.notification_channels);
            groupCategory.setKey(KEY_ZERO_CATEGORIES);
            groupPrefsList.addPreference(groupCategory);
            Preference empty = new Preference(mContext);
            empty.setTitle(R.string.no_channels);
            empty.setEnabled(false);
            groupCategory.addPreference(empty);
        }
    } else {
        updateGroupList(groupPrefsList, channelGroups);
    }
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) SwitchPreference(androidx.preference.SwitchPreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Preference(androidx.preference.Preference) PrimarySwitchPreference(com.android.settings.widget.PrimarySwitchPreference) PreferenceGroup(androidx.preference.PreferenceGroup)

Example 32 with PreferenceCategory

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

the class NetworkProviderSettingsTest method getConnectedWifiPreferenceCategory_internetWiFi_getConnectedAccessPoints.

@Test
public void getConnectedWifiPreferenceCategory_internetWiFi_getConnectedAccessPoints() {
    doReturn(InternetUpdater.INTERNET_WIFI).when(mInternetUpdater).getInternetType();
    final PreferenceCategory pc = mNetworkProviderSettings.getConnectedWifiPreferenceCategory();
    assertThat(pc.getKey()).isEqualTo(NetworkProviderSettings.PREF_KEY_CONNECTED_ACCESS_POINTS);
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) Test(org.junit.Test)

Example 33 with PreferenceCategory

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

the class NetworkProviderSettingsTest method getConnectedWifiPreferenceCategory_internetCellular_getFirstAccessPoints.

@Test
public void getConnectedWifiPreferenceCategory_internetCellular_getFirstAccessPoints() {
    doReturn(InternetUpdater.INTERNET_CELLULAR).when(mInternetUpdater).getInternetType();
    final PreferenceCategory pc = mNetworkProviderSettings.getConnectedWifiPreferenceCategory();
    assertThat(pc.getKey()).isEqualTo(NetworkProviderSettings.PREF_KEY_FIRST_ACCESS_POINTS);
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) Test(org.junit.Test)

Example 34 with PreferenceCategory

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

the class AccessibilitySettings method initializeAllPreferences.

private void initializeAllPreferences() {
    for (int i = 0; i < CATEGORIES.length; i++) {
        PreferenceCategory prefCategory = findPreference(CATEGORIES[i]);
        mCategoryToPrefCategoryMap.put(CATEGORIES[i], prefCategory);
    }
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory)

Example 35 with PreferenceCategory

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

the class AccessibilitySettings method initializePreBundledServicesMapFromArray.

private void initializePreBundledServicesMapFromArray(String categoryKey, int key) {
    String[] services = getResources().getStringArray(key);
    PreferenceCategory category = mCategoryToPrefCategoryMap.get(categoryKey);
    for (int i = 0; i < services.length; i++) {
        ComponentName component = ComponentName.unflattenFromString(services[i]);
        mPreBundledServiceComponentToCategoryMap.put(component, category);
    }
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) ComponentName(android.content.ComponentName)

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