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);
}
}
}
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);
}
}
}
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();
}
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();
}
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);
}
}
Aggregations