Search in sources :

Example 96 with CheckBoxPreference

use of android.preference.CheckBoxPreference in project android_packages_apps_Settings by LineageOS.

the class LanguageSettings method onCreateIMM.

private void onCreateIMM() {
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    mInputMethodProperties = imm.getInputMethodList();
    mLastInputMethodId = Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
    PreferenceGroup textCategory = (PreferenceGroup) findPreference("text_category");
    int N = (mInputMethodProperties == null ? 0 : mInputMethodProperties.size());
    for (int i = 0; i < N; ++i) {
        InputMethodInfo property = mInputMethodProperties.get(i);
        String prefKey = property.getId();
        CharSequence label = property.loadLabel(getPackageManager());
        boolean systemIME = isSystemIme(property);
        // Don't show the toggle if it's the only keyboard in the system, or it's a system IME.
        if (mHaveHardKeyboard || (N > 1 && !systemIME)) {
            CheckBoxPreference chkbxPref = new CheckBoxPreference(this);
            chkbxPref.setKey(prefKey);
            chkbxPref.setTitle(label);
            textCategory.addPreference(chkbxPref);
            mCheckboxes.add(chkbxPref);
        }
        // If setting activity is available, add a setting screen entry.
        if (null != property.getSettingsActivity()) {
            PreferenceScreen prefScreen = new PreferenceScreen(this, null);
            String settingsActivity = property.getSettingsActivity();
            if (settingsActivity.lastIndexOf("/") < 0) {
                settingsActivity = property.getPackageName() + "/" + settingsActivity;
            }
            prefScreen.setKey(settingsActivity);
            prefScreen.setTitle(label);
            if (N == 1) {
                prefScreen.setSummary(getString(R.string.onscreen_keyboard_settings_summary));
            } else {
                CharSequence settingsLabel = getResources().getString(R.string.input_methods_settings_label_format, label);
                prefScreen.setSummary(settingsLabel);
            }
            textCategory.addPreference(prefScreen);
        }
    }
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) CheckBoxPreference(android.preference.CheckBoxPreference) InputMethodManager(android.view.inputmethod.InputMethodManager) PreferenceGroup(android.preference.PreferenceGroup) InputMethodInfo(android.view.inputmethod.InputMethodInfo)

Example 97 with CheckBoxPreference

use of android.preference.CheckBoxPreference in project android_packages_apps_Settings by LineageOS.

the class LanguageSettings method onResume.

@Override
protected void onResume() {
    super.onResume();
    final HashSet<String> enabled = new HashSet<String>();
    String enabledStr = Settings.Secure.getString(getContentResolver(), Settings.Secure.ENABLED_INPUT_METHODS);
    if (enabledStr != null) {
        final TextUtils.SimpleStringSplitter splitter = mStringColonSplitter;
        splitter.setString(enabledStr);
        while (splitter.hasNext()) {
            enabled.add(splitter.next());
        }
    }
    // Update the statuses of the Check Boxes.
    int N = mInputMethodProperties.size();
    for (int i = 0; i < N; ++i) {
        final String id = mInputMethodProperties.get(i).getId();
        CheckBoxPreference pref = (CheckBoxPreference) findPreference(mInputMethodProperties.get(i).getId());
        if (pref != null) {
            pref.setChecked(enabled.contains(id));
        }
    }
    mLastTickedInputMethodId = null;
    if (mLanguagePref != null) {
        Configuration conf = getResources().getConfiguration();
        String locale = conf.locale.getDisplayName(conf.locale);
        if (locale != null && locale.length() > 1) {
            locale = Character.toUpperCase(locale.charAt(0)) + locale.substring(1);
            mLanguagePref.setSummary(locale);
        }
    }
}
Also used : Configuration(android.content.res.Configuration) CheckBoxPreference(android.preference.CheckBoxPreference) TextUtils(android.text.TextUtils) HashSet(java.util.HashSet)

Example 98 with CheckBoxPreference

use of android.preference.CheckBoxPreference in project android_packages_apps_Settings by LineageOS.

the class LanguageSettings method onCreate.

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.language_settings);
    if (getAssets().getLocales().length == 1) {
        getPreferenceScreen().removePreference(findPreference("language_category"));
    } else {
        mLanguagePref = findPreference(KEY_PHONE_LANGUAGE);
    }
    Configuration config = getResources().getConfiguration();
    if (config.keyboard != Configuration.KEYBOARD_QWERTY) {
        getPreferenceScreen().removePreference(getPreferenceScreen().findPreference("hardkeyboard_category"));
    } else {
        mHaveHardKeyboard = true;
    }
    mCheckboxes = new ArrayList<CheckBoxPreference>();
    onCreateIMM();
}
Also used : Configuration(android.content.res.Configuration) CheckBoxPreference(android.preference.CheckBoxPreference)

Example 99 with CheckBoxPreference

use of android.preference.CheckBoxPreference in project android_packages_apps_Settings by LineageOS.

the class DateTimeSettings method onResume.

@Override
protected void onResume() {
    super.onResume();
    getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
    ((CheckBoxPreference) mTime24Pref).setChecked(is24Hour());
    // Register for time ticks and other reasons for time change
    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_TIME_TICK);
    filter.addAction(Intent.ACTION_TIME_CHANGED);
    filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
    registerReceiver(mIntentReceiver, filter, null, null);
    updateTimeAndDateDisplay();
}
Also used : IntentFilter(android.content.IntentFilter) CheckBoxPreference(android.preference.CheckBoxPreference)

Example 100 with CheckBoxPreference

use of android.preference.CheckBoxPreference in project android_packages_apps_Settings by LineageOS.

the class AccessibilitySettings method addAccessibilitServicePreferences.

/**
 * Adds {@link CheckBoxPreference} for enabling or disabling an accessibility services.
 */
private void addAccessibilitServicePreferences() {
    AccessibilityManager accessibilityManager = (AccessibilityManager) getSystemService(Service.ACCESSIBILITY_SERVICE);
    List<ServiceInfo> installedServices = accessibilityManager.getAccessibilityServiceList();
    mAccessibilityServicesCategory = (PreferenceGroup) findPreference(ACCESSIBILITY_SERVICES_CATEGORY);
    if (installedServices.isEmpty()) {
        getPreferenceScreen().removePreference(mAccessibilityServicesCategory);
        mAccessibilityServicesCategory = null;
        return;
    }
    for (int i = 0, count = installedServices.size(); i < count; ++i) {
        ServiceInfo serviceInfo = installedServices.get(i);
        String key = serviceInfo.packageName + "/" + serviceInfo.name;
        mAccessibilityServices.put(key, serviceInfo);
        CheckBoxPreference preference = new CheckBoxPreference(this);
        preference.setKey(key);
        preference.setTitle(serviceInfo.loadLabel(getPackageManager()));
        mAccessibilityServicesCategory.addPreference(preference);
    }
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) AccessibilityManager(android.view.accessibility.AccessibilityManager) CheckBoxPreference(android.preference.CheckBoxPreference)

Aggregations

CheckBoxPreference (android.preference.CheckBoxPreference)138 Preference (android.preference.Preference)70 ListPreference (android.preference.ListPreference)53 Intent (android.content.Intent)28 SharedPreferences (android.content.SharedPreferences)23 EditTextPreference (android.preference.EditTextPreference)23 PreferenceCategory (android.preference.PreferenceCategory)22 PreferenceScreen (android.preference.PreferenceScreen)22 ArrayList (java.util.ArrayList)17 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)13 DialogInterface (android.content.DialogInterface)11 Context (android.content.Context)10 PackageManager (android.content.pm.PackageManager)10 SuppressLint (android.annotation.SuppressLint)8 Bundle (android.os.Bundle)7 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)7 PreferenceManager (android.preference.PreferenceManager)7 File (java.io.File)7 AlertDialog (android.app.AlertDialog)6 Uri (android.net.Uri)6