Search in sources :

Example 31 with PreferenceCategory

use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.

the class DataPlanUsageSummary method addDataPlanSection.

private void addDataPlanSection(int defaultSubId) {
    Context context = getPrefContext();
    addPreferencesFromResource(R.xml.data_plan_usage);
    PreferenceScreen screen = getPreferenceScreen();
    screen.setTitle(context.getString(R.string.data_usage_summary_title));
    PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference(KEY_DATA_PLAN_USAGE);
    screen.addPreference(preferenceCategory);
    Preference dataPlansSyncTimePreference = new Preference(context);
    dataPlansSyncTimePreference.setLayoutResource(R.layout.data_plans_sync_time_preference);
    dataPlansSyncTimePreference.setTitle(MockDataPlanUsage.SYNC_TIME);
    preferenceCategory.addPreference(dataPlansSyncTimePreference);
    mDataPlanSummaryPreferenceList = new ArrayList<>(MockDataPlanUsage.DATA_PLAN_USAGES.length);
    for (int i = 0; i < MockDataPlanUsage.DATA_PLAN_USAGES.length; i++) {
        DataPlanSummaryPreference dataPlanSummaryPreference = new DataPlanSummaryPreference(context);
        dataPlanSummaryPreference.setKey(KEY_STATUS_HEADER + (i + 1));
        mDataPlanSummaryPreferenceList.add(dataPlanSummaryPreference);
        preferenceCategory.addPreference(dataPlanSummaryPreference);
    }
    Preference preference = new Preference(context);
    preference.setLayoutResource(R.layout.manage_data_plans_preference);
    preferenceCategory.addPreference(preference);
    setPreferenceScreen(screen);
    mLimitPreference = findPreference(KEY_LIMIT_SUMMARY);
    List<SubscriptionInfo> subscriptions = services.mSubscriptionManager.getActiveSubscriptionInfoList();
    if (subscriptions == null || subscriptions.isEmpty()) {
        addMobileSection(defaultSubId);
    }
    for (int i = 0, subscriptionsSize = subscriptions != null ? subscriptions.size() : 0; i < subscriptionsSize; i++) {
        SubscriptionInfo subInfo = subscriptions.get(i);
        if (subscriptionsSize > 1) {
            addMobileSection(subInfo.getSubscriptionId(), subInfo);
        } else {
            addMobileSection(subInfo.getSubscriptionId());
        }
    }
}
Also used : Context(android.content.Context) PreferenceScreen(android.support.v7.preference.PreferenceScreen) PreferenceCategory(android.support.v7.preference.PreferenceCategory) Preference(android.support.v7.preference.Preference) SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 32 with PreferenceCategory

use of android.support.v7.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.managed_device_admin_title);
            } else {
                category.setTitle(R.string.personal_device_admin_title);
            }
            category.setOrder(i);
            createPreferences(prefContext, category, mApps.get(i));
        }
    }
}
Also used : Context(android.content.Context) PreferenceScreen(android.support.v7.preference.PreferenceScreen) PreferenceCategory(android.support.v7.preference.PreferenceCategory) UserInfo(android.content.pm.UserInfo)

Example 33 with PreferenceCategory

use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.

the class PhysicalKeyboardFragment method onLoadFinishedInternal.

private void onLoadFinishedInternal(final int loaderId, @NonNull final List<Keyboards> keyboardsList) {
    if (!mLoaderIDs.remove(loaderId)) {
        // Already destroyed loader.  Ignore.
        return;
    }
    Collections.sort(keyboardsList);
    final PreferenceScreen preferenceScreen = getPreferenceScreen();
    preferenceScreen.removeAll();
    for (Keyboards keyboards : keyboardsList) {
        final PreferenceCategory category = new PreferenceCategory(getPrefContext(), null);
        category.setTitle(keyboards.mDeviceInfo.mDeviceName);
        category.setOrder(0);
        preferenceScreen.addPreference(category);
        for (Keyboards.KeyboardInfo info : keyboards.mKeyboardInfoList) {
            mTempKeyboardInfoList.clear();
            final InputMethodInfo imi = info.mImi;
            final InputMethodSubtype imSubtype = info.mImSubtype;
            if (imi != null) {
                KeyboardInfoPreference pref = new KeyboardInfoPreference(getPrefContext(), info);
                pref.setOnPreferenceClickListener(preference -> {
                    showKeyboardLayoutScreen(keyboards.mDeviceInfo.mDeviceIdentifier, imi, imSubtype);
                    return true;
                });
                mTempKeyboardInfoList.add(pref);
                Collections.sort(mTempKeyboardInfoList);
            }
            for (KeyboardInfoPreference pref : mTempKeyboardInfoList) {
                category.addPreference(pref);
            }
        }
    }
    mTempKeyboardInfoList.clear();
    mKeyboardAssistanceCategory.setOrder(1);
    preferenceScreen.addPreference(mKeyboardAssistanceCategory);
    updateShowVirtualKeyboardSwitch();
}
Also used : InputMethodSubtype(android.view.inputmethod.InputMethodSubtype) PreferenceScreen(android.support.v7.preference.PreferenceScreen) PreferenceCategory(android.support.v7.preference.PreferenceCategory) InputMethodInfo(android.view.inputmethod.InputMethodInfo)

Example 34 with PreferenceCategory

use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.

the class LocationSettings method addLocationServices.

/**
 * Add the settings injected by external apps into the "App Settings" category. Hides the
 * category if there are no injected settings.
 *
 * Reloads the settings whenever receives
 * {@link SettingInjectorService#ACTION_INJECTED_SETTING_CHANGED}.
 */
private void addLocationServices(Context context, PreferenceScreen root, boolean lockdownOnLocationAccess) {
    PreferenceCategory categoryLocationServices = (PreferenceCategory) root.findPreference(KEY_LOCATION_SERVICES);
    injector = new SettingsInjector(context);
    // If location access is locked down by device policy then we only show injected settings
    // for the primary profile.
    final Context prefContext = categoryLocationServices.getContext();
    final List<Preference> locationServices = injector.getInjectedSettings(prefContext, lockdownOnLocationAccess ? UserHandle.myUserId() : UserHandle.USER_CURRENT);
    mReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            if (Log.isLoggable(TAG, Log.DEBUG)) {
                Log.d(TAG, "Received settings change intent: " + intent);
            }
            injector.reloadStatusMessages();
        }
    };
    IntentFilter filter = new IntentFilter();
    filter.addAction(SettingInjectorService.ACTION_INJECTED_SETTING_CHANGED);
    context.registerReceiver(mReceiver, filter);
    if (locationServices.size() > 0) {
        addPreferencesSorted(locationServices, categoryLocationServices);
    } else {
        // If there's no item to display, remove the whole category.
        root.removePreference(categoryLocationServices);
    }
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) PreferenceCategory(android.support.v7.preference.PreferenceCategory) DimmableIconPreference(com.android.settings.DimmableIconPreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Preference(android.support.v7.preference.Preference) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver)

Example 35 with PreferenceCategory

use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.

the class AppNotificationSettings method populateSingleChannelPrefs.

private void populateSingleChannelPrefs(PreferenceCategory groupCategory, final NotificationChannel channel) {
    MasterSwitchPreference channelPref = new MasterSwitchPreference(getPrefContext());
    channelPref.setSwitchEnabled(mSuspendedAppsAdmin == null && isChannelBlockable(mAppRow.systemApp, channel) && isChannelConfigurable(channel));
    channelPref.setKey(channel.getId());
    channelPref.setTitle(channel.getName());
    channelPref.setChecked(channel.getImportance() != IMPORTANCE_NONE);
    channelPref.setSummary(getImportanceSummary(channel));
    Bundle channelArgs = new Bundle();
    channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, mUid);
    channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mPkg);
    channelArgs.putString(Settings.EXTRA_CHANNEL_ID, channel.getId());
    Intent channelIntent = Utils.onBuildStartFragmentIntent(getActivity(), ChannelNotificationSettings.class.getName(), channelArgs, null, R.string.notification_channel_title, null, false, getMetricsCategory());
    channelPref.setIntent(channelIntent);
    channelPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object o) {
            boolean value = (Boolean) o;
            int importance = value ? IMPORTANCE_LOW : IMPORTANCE_NONE;
            channel.setImportance(importance);
            channel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
            channelPref.setSummary(getImportanceSummary(channel));
            mBackend.updateChannel(mPkg, mUid, channel);
            return true;
        }
    });
    groupCategory.addPreference(channelPref);
}
Also used : MasterSwitchPreference(com.android.settings.widget.MasterSwitchPreference) LayoutPreference(com.android.settings.applications.LayoutPreference) ColorSelectPreference(org.omnirom.omnigears.preference.ColorSelectPreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) SeekBarPreference(org.omnirom.omnigears.preference.SeekBarPreference) MasterSwitchPreference(com.android.settings.widget.MasterSwitchPreference) FooterPreference(com.android.settingslib.widget.FooterPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) Bundle(android.os.Bundle) Intent(android.content.Intent)

Aggregations

PreferenceCategory (android.support.v7.preference.PreferenceCategory)166 Preference (android.support.v7.preference.Preference)105 PreferenceScreen (android.support.v7.preference.PreferenceScreen)75 Intent (android.content.Intent)35 Context (android.content.Context)34 SwitchPreference (android.support.v14.preference.SwitchPreference)31 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)27 ArrayList (java.util.ArrayList)24 ComponentName (android.content.ComponentName)22 ListPreference (android.support.v7.preference.ListPreference)18 Bundle (android.os.Bundle)16 PreferenceGroup (android.support.v7.preference.PreferenceGroup)14 DimmableIconPreference (com.android.settings.DimmableIconPreference)14 ContentResolver (android.content.ContentResolver)13 LayoutPreference (com.android.settings.applications.LayoutPreference)13 PreferenceManager (android.support.v7.preference.PreferenceManager)12 MasterSwitchPreference (com.android.settings.widget.MasterSwitchPreference)12 FooterPreference (com.android.settingslib.widget.FooterPreference)12 Test (org.junit.Test)12 Activity (android.app.Activity)9