use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class TetherSettings method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if (icicle != null) {
mTetherChoice = icicle.getInt(TETHER_CHOICE);
}
addPreferencesFromResource(R.xml.tether_prefs);
mDataSaverBackend = new DataSaverBackend(getContext());
mDataSaverEnabled = mDataSaverBackend.isDataSaverEnabled();
mDataSaverFooter = findPreference(DATA_SAVER_FOOTER);
setIfOnlyAvailableForAdmins(true);
if (isUiRestricted()) {
mUnavailable = true;
setPreferenceScreen(new PreferenceScreen(getPrefContext(), null));
return;
}
final Activity activity = getActivity();
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (adapter != null) {
adapter.getProfileProxy(activity.getApplicationContext(), mProfileServiceListener, BluetoothProfile.PAN);
}
mCreateNetwork = findPreference(WIFI_AP_SSID_AND_SECURITY);
boolean enableWifiApSettingsExt = getResources().getBoolean(R.bool.show_wifi_hotspot_settings);
boolean isWifiApEnabled = getResources().getBoolean(R.bool.hide_wifi_hotspot);
checkDefaultValue(getActivity());
if (enableWifiApSettingsExt) {
mEnableWifiAp = (HotspotPreference) findPreference(ENABLE_WIFI_AP_EXT);
getPreferenceScreen().removePreference(findPreference(ENABLE_WIFI_AP));
getPreferenceScreen().removePreference(mCreateNetwork);
Intent intent = new Intent();
intent.setAction("com.qti.ap.settings");
intent.setPackage("com.qualcomm.qti.extsettings");
mEnableWifiAp.setIntent(intent);
} else {
mEnableWifiAp = (SwitchPreference) findPreference(ENABLE_WIFI_AP);
getPreferenceScreen().removePreference(findPreference(ENABLE_WIFI_AP_EXT));
}
if (isWifiApEnabled) {
getPreferenceScreen().removePreference(mEnableWifiAp);
getPreferenceScreen().removePreference(mCreateNetwork);
}
if (getResources().getBoolean(R.bool.config_regional_hotspot_tether_help_enable)) {
mTetherHelp = (PreferenceScreen) findPreference(TETHERING_HELP);
} else {
getPreferenceScreen().removePreference(findPreference(TETHERING_HELP));
}
mUsbTether = (SwitchPreference) findPreference(USB_TETHER_SETTINGS);
mBluetoothTether = (SwitchPreference) findPreference(ENABLE_BLUETOOTH_TETHERING);
mHotspotInactivityTimeout = (ListPreference) findPreference(HOTSPOT_TIMEOUT);
mDataSaverBackend.addListener(this);
mCm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
mUsbRegexs = mCm.getTetherableUsbRegexs();
mWifiRegexs = mCm.getTetherableWifiRegexs();
mBluetoothRegexs = mCm.getTetherableBluetoothRegexs();
final boolean usbAvailable = mUsbRegexs.length != 0;
final boolean wifiAvailable = mWifiRegexs.length != 0;
final boolean bluetoothAvailable = mBluetoothRegexs.length != 0;
if (!usbAvailable || Utils.isMonkeyRunning()) {
getPreferenceScreen().removePreference(mUsbTether);
}
if (wifiAvailable && !Utils.isMonkeyRunning()) {
mWifiApEnabler = new WifiApEnabler(activity, mDataSaverBackend, mEnableWifiAp);
initWifiTethering();
} else {
getPreferenceScreen().removePreference(mEnableWifiAp);
getPreferenceScreen().removePreference(mCreateNetwork);
}
if (!bluetoothAvailable) {
getPreferenceScreen().removePreference(mBluetoothTether);
} else {
BluetoothPan pan = mBluetoothPan.get();
if (pan != null && pan.isTetheringOn()) {
mBluetoothTether.setChecked(true);
} else {
mBluetoothTether.setChecked(false);
}
}
mHotspotInactivityTimeout.setOnPreferenceChangeListener(this);
// Set initial state based on Data Saver mode.
onDataSaverChanged(mDataSaverBackend.isDataSaverEnabled());
}
use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class InputMethodAndLanguageSettings method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.language_settings);
final Activity activity = getActivity();
mImm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mInputMethodSettingValues = InputMethodSettingValuesWrapper.getInstance(activity);
try {
mDefaultInputMethodSelectorVisibility = Integer.valueOf(getString(R.string.input_method_selector_visibility_default_value));
} catch (NumberFormatException e) {
}
if (activity.getAssets().getLocales().length == 1) {
// No "Select language" pref if there's only one system locale available.
getPreferenceScreen().removePreference(findPreference(KEY_PHONE_LANGUAGE));
} else {
mLanguagePref = findPreference(KEY_PHONE_LANGUAGE);
}
if (SHOW_INPUT_METHOD_SWITCHER_SETTINGS) {
mShowInputMethodSelectorPref = (ListPreference) findPreference(KEY_INPUT_METHOD_SELECTOR);
mShowInputMethodSelectorPref.setOnPreferenceChangeListener(this);
// TODO: Update current input method name on summary
updateInputMethodSelectorSummary(loadInputMethodSelectorVisibility());
}
new VoiceInputOutputSettings(this).onCreate();
// Get references to dynamically constructed categories.
mHardKeyboardCategory = (PreferenceCategory) findPreference("hard_keyboard");
mKeyboardSettingsCategory = (PreferenceCategory) findPreference("keyboard_settings_category");
mGameControllerCategory = (PreferenceCategory) findPreference("game_controller_settings_category");
final Intent startingIntent = activity.getIntent();
// Filter out irrelevant features if invoked from IME settings button.
mShowsOnlyFullImeAndKeyboardList = Settings.ACTION_INPUT_METHOD_SETTINGS.equals(startingIntent.getAction());
if (mShowsOnlyFullImeAndKeyboardList) {
getPreferenceScreen().removeAll();
if (mHardKeyboardCategory != null) {
getPreferenceScreen().addPreference(mHardKeyboardCategory);
}
if (SHOW_INPUT_METHOD_SWITCHER_SETTINGS) {
getPreferenceScreen().addPreference(mShowInputMethodSelectorPref);
}
if (mKeyboardSettingsCategory != null) {
mKeyboardSettingsCategory.removeAll();
getPreferenceScreen().addPreference(mKeyboardSettingsCategory);
}
}
// Build hard keyboard and game controller preference categories.
mIm = (InputManager) activity.getSystemService(Context.INPUT_SERVICE);
updateInputDevices();
// Spell Checker
final Preference spellChecker = findPreference(KEY_SPELL_CHECKERS);
if (spellChecker != null) {
// Note: KEY_SPELL_CHECKERS preference is marked as persistent="false" in XML.
InputMethodAndSubtypeUtil.removeUnnecessaryNonPersistentPreference(spellChecker);
final Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClass(activity, SubSettings.class);
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT, SpellCheckersSettings.class.getName());
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, R.string.spellcheckers_settings_title);
spellChecker.setIntent(intent);
}
mHandler = new Handler();
mSettingsObserver = new SettingsObserver(mHandler, activity);
mDpm = (DevicePolicyManager) (getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE));
// If we've launched from the keyboard layout notification, go ahead and just show the
// keyboard layout dialog.
final InputDeviceIdentifier identifier = startingIntent.getParcelableExtra(Settings.EXTRA_INPUT_DEVICE_IDENTIFIER);
if (mShowsOnlyFullImeAndKeyboardList && identifier != null) {
showKeyboardLayoutDialog(identifier);
}
updateCurrentImeName();
}
use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class LockClockFonts method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.lock_clock_fonts);
final ContentResolver resolver = getActivity().getContentResolver();
PreferenceScreen prefs = getPreferenceScreen();
mLockClockFonts = (ListPreference) findPreference(LOCK_CLOCK_FONTS);
mLockClockFonts.setValue(String.valueOf(Settings.System.getInt(getContentResolver(), Settings.System.LOCK_CLOCK_FONTS, 0)));
mLockClockFonts.setSummary(mLockClockFonts.getEntry());
mLockClockFonts.setOnPreferenceChangeListener(this);
mDateFonts = (ListPreference) findPreference(LOCK_DATE_FONTS);
mDateFonts.setValue(String.valueOf(Settings.System.getInt(resolver, Settings.System.LOCK_DATE_FONTS, 8)));
mDateFonts.setSummary(mDateFonts.getEntry());
mDateFonts.setOnPreferenceChangeListener(this);
}
use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class GestureAnywhereSettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.gesture_anywhere);
mEnabledPref = (SwitchPreference) findPreference(KEY_ENABLED);
mEnabledPref.setChecked((Settings.System.getInt(getContentResolver(), Settings.System.GESTURE_ANYWHERE_ENABLED, 0) == 1));
mEnabledPref.setOnPreferenceChangeListener(this);
PreferenceScreen prefSet = getPreferenceScreen();
mPositionPref = (ListPreference) prefSet.findPreference(KEY_POSITION);
mPositionPref.setOnPreferenceChangeListener(this);
int position = Settings.System.getInt(getContentResolver(), Settings.System.GESTURE_ANYWHERE_POSITION, Gravity.LEFT);
mPositionPref.setValue(String.valueOf(position));
mTriggerWidthPref = (SeekBarPreference) findPreference(KEY_TRIGGER_WIDTH);
mTriggerWidthPref.setValue(Settings.System.getInt(getContentResolver(), Settings.System.GESTURE_ANYWHERE_TRIGGER_WIDTH, 20));
mTriggerWidthPref.setOnPreferenceChangeListener(this);
mTriggerTopPref = (SeekBarPreference) findPreference(KEY_TRIGGER_TOP);
mTriggerTopPref.setValue(Settings.System.getInt(getContentResolver(), Settings.System.GESTURE_ANYWHERE_TRIGGER_TOP, 0));
mTriggerTopPref.setOnPreferenceChangeListener(this);
mTriggerBottomPref = (SeekBarPreference) findPreference(KEY_TRIGGER_BOTTOM);
mTriggerBottomPref.setValue(Settings.System.getInt(getContentResolver(), Settings.System.GESTURE_ANYWHERE_TRIGGER_HEIGHT, 100));
mTriggerBottomPref.setOnPreferenceChangeListener(this);
Preference pref = findPreference(KEY_GESTURES);
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
startActivity(new Intent(getActivity(), GestureAnywhereBuilderActivity.class));
return true;
}
});
}
use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ButtonSettings method initActionList.
private ListPreference initActionList(String key, int value) {
ListPreference list = (ListPreference) getPreferenceScreen().findPreference(key);
if (list == null)
return null;
list.setValue(Integer.toString(value));
list.setSummary(list.getEntry());
list.setOnPreferenceChangeListener(this);
return list;
}
Aggregations