use of android.preference.CheckBoxPreference in project Lightning-Browser by anthonycr.
the class DisplaySettingsFragment method initPrefs.
private void initPrefs() {
// mPreferences storage
mThemeOptions = this.getResources().getStringArray(R.array.themes);
mCurrentTheme = mPreferenceManager.getUseTheme();
mTheme = findPreference(SETTINGS_THEME);
Preference textSize = findPreference(SETTINGS_TEXTSIZE);
CheckBoxPreference cbStatus = (CheckBoxPreference) findPreference(SETTINGS_HIDESTATUSBAR);
CheckBoxPreference cbFullScreen = (CheckBoxPreference) findPreference(SETTINGS_FULLSCREEN);
CheckBoxPreference cbViewPort = (CheckBoxPreference) findPreference(SETTINGS_VIEWPORT);
CheckBoxPreference cbOverview = (CheckBoxPreference) findPreference(SETTINGS_OVERVIEWMODE);
CheckBoxPreference cbReflow = (CheckBoxPreference) findPreference(SETTINGS_REFLOW);
CheckBoxPreference cbBlackStatus = (CheckBoxPreference) findPreference(SETTINGS_BLACK_STATUS);
CheckBoxPreference cbDrawerTabs = (CheckBoxPreference) findPreference(SETTINGS_DRAWERTABS);
CheckBoxPreference cbSwapTabs = (CheckBoxPreference) findPreference(SETTINGS_SWAPTABS);
mTheme.setOnPreferenceClickListener(this);
textSize.setOnPreferenceClickListener(this);
cbStatus.setOnPreferenceChangeListener(this);
cbFullScreen.setOnPreferenceChangeListener(this);
cbViewPort.setOnPreferenceChangeListener(this);
cbOverview.setOnPreferenceChangeListener(this);
cbReflow.setOnPreferenceChangeListener(this);
cbBlackStatus.setOnPreferenceChangeListener(this);
cbDrawerTabs.setOnPreferenceChangeListener(this);
cbSwapTabs.setOnPreferenceChangeListener(this);
cbStatus.setChecked(mPreferenceManager.getHideStatusBarEnabled());
cbFullScreen.setChecked(mPreferenceManager.getFullScreenEnabled());
cbViewPort.setChecked(mPreferenceManager.getUseWideViewportEnabled());
cbOverview.setChecked(mPreferenceManager.getOverviewModeEnabled());
cbReflow.setChecked(mPreferenceManager.getTextReflowEnabled());
cbBlackStatus.setChecked(mPreferenceManager.getUseBlackStatusBar());
cbDrawerTabs.setChecked(mPreferenceManager.getShowTabsInDrawer(true));
cbSwapTabs.setChecked(mPreferenceManager.getBookmarksAndTabsSwapped());
mTheme.setSummary(mThemeOptions[mPreferenceManager.getUseTheme()]);
}
use of android.preference.CheckBoxPreference in project Lightning-Browser by anthonycr.
the class GeneralSettingsFragment method initPrefs.
private void initPrefs() {
proxy = findPreference(SETTINGS_PROXY);
useragent = findPreference(SETTINGS_USERAGENT);
downloadloc = findPreference(SETTINGS_DOWNLOAD);
home = findPreference(SETTINGS_HOME);
searchengine = findPreference(SETTINGS_SEARCHENGINE);
searchsSuggestions = findPreference(SETTINGS_SUGGESTIONS);
CheckBoxPreference cbFlash = (CheckBoxPreference) findPreference(SETTINGS_FLASH);
CheckBoxPreference cbAds = (CheckBoxPreference) findPreference(SETTINGS_ADS);
CheckBoxPreference cbImages = (CheckBoxPreference) findPreference(SETTINGS_IMAGES);
CheckBoxPreference cbJsScript = (CheckBoxPreference) findPreference(SETTINGS_JAVASCRIPT);
CheckBoxPreference cbColorMode = (CheckBoxPreference) findPreference(SETTINGS_COLORMODE);
proxy.setOnPreferenceClickListener(this);
useragent.setOnPreferenceClickListener(this);
downloadloc.setOnPreferenceClickListener(this);
home.setOnPreferenceClickListener(this);
searchsSuggestions.setOnPreferenceClickListener(this);
searchengine.setOnPreferenceClickListener(this);
cbFlash.setOnPreferenceChangeListener(this);
cbAds.setOnPreferenceChangeListener(this);
cbImages.setOnPreferenceChangeListener(this);
cbJsScript.setOnPreferenceChangeListener(this);
cbColorMode.setOnPreferenceChangeListener(this);
mAgentChoice = mPreferenceManager.getUserAgentChoice();
mHomepage = mPreferenceManager.getHomepage();
mDownloadLocation = mPreferenceManager.getDownloadDirectory();
mProxyChoices = getResources().getStringArray(R.array.proxy_choices_array);
int choice = mPreferenceManager.getProxyChoice();
if (choice == Constants.PROXY_MANUAL) {
proxy.setSummary(mPreferenceManager.getProxyHost() + ':' + mPreferenceManager.getProxyPort());
} else {
proxy.setSummary(mProxyChoices[choice]);
}
if (API >= Build.VERSION_CODES.KITKAT) {
mPreferenceManager.setFlashSupport(0);
}
setSearchEngineSummary(mPreferenceManager.getSearchChoice());
downloadloc.setSummary(mDownloadLocation);
switch(mPreferenceManager.getSearchSuggestionChoice()) {
case SUGGESTION_GOOGLE:
searchsSuggestions.setSummary(R.string.powered_by_google);
break;
case SUGGESTION_DUCK:
searchsSuggestions.setSummary(R.string.powered_by_duck);
break;
case SUGGESTION_BAIDU:
searchsSuggestions.setSummary(R.string.powered_by_baidu);
break;
case SUGGESTION_NONE:
searchsSuggestions.setSummary(R.string.search_suggestions_off);
break;
}
if (mHomepage.contains(Constants.SCHEME_HOMEPAGE)) {
home.setSummary(getResources().getString(R.string.action_homepage));
} else if (mHomepage.contains(Constants.SCHEME_BLANK)) {
home.setSummary(getResources().getString(R.string.action_blank));
} else if (mHomepage.contains(Constants.SCHEME_BOOKMARKS)) {
home.setSummary(getResources().getString(R.string.action_bookmarks));
} else {
home.setSummary(mHomepage);
}
switch(mAgentChoice) {
case 1:
useragent.setSummary(getResources().getString(R.string.agent_default));
break;
case 2:
useragent.setSummary(getResources().getString(R.string.agent_desktop));
break;
case 3:
useragent.setSummary(getResources().getString(R.string.agent_mobile));
break;
case 4:
useragent.setSummary(getResources().getString(R.string.agent_custom));
}
int flashNum = mPreferenceManager.getFlashSupport();
boolean imagesBool = mPreferenceManager.getBlockImagesEnabled();
boolean enableJSBool = mPreferenceManager.getJavaScriptEnabled();
cbAds.setEnabled(BuildConfig.FULL_VERSION);
if (API < Build.VERSION_CODES.KITKAT) {
cbFlash.setEnabled(true);
} else {
cbFlash.setEnabled(false);
cbFlash.setSummary(getResources().getString(R.string.flash_not_supported));
}
cbImages.setChecked(imagesBool);
cbJsScript.setChecked(enableJSBool);
cbFlash.setChecked(flashNum > 0);
cbAds.setChecked(BuildConfig.FULL_VERSION && mPreferenceManager.getAdBlockEnabled());
cbColorMode.setChecked(mPreferenceManager.getColorModeEnabled());
}
use of android.preference.CheckBoxPreference in project apps-android-commons by commons-app.
the class SettingsFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
// Update spinner to show selected value as summary
ListPreference licensePreference = (ListPreference) findPreference(Prefs.DEFAULT_LICENSE);
licensePreference.setSummary(getString(Utils.licenseNameFor(licensePreference.getValue())));
// Keep summary updated when changing value
licensePreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
preference.setSummary(getString(Utils.licenseNameFor((String) newValue)));
return true;
}
});
CheckBoxPreference themePreference = (CheckBoxPreference) findPreference("theme");
themePreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
getActivity().recreate();
return true;
}
});
final EditTextPreference uploadLimit = (EditTextPreference) findPreference("uploads");
final SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(CommonsApplication.getInstance());
int uploads = sharedPref.getInt(Prefs.UPLOADS_SHOWING, 100);
uploadLimit.setText(uploads + "");
uploadLimit.setSummary(uploads + "");
uploadLimit.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
int value = Integer.parseInt(newValue.toString());
final SharedPreferences.Editor editor = sharedPref.edit();
if (value > 500) {
new AlertDialog.Builder(getActivity()).setTitle(R.string.maximum_limit).setMessage(R.string.maximum_limit_alert).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
}).setIcon(android.R.drawable.ic_dialog_alert).show();
editor.putInt(Prefs.UPLOADS_SHOWING, 500);
editor.putBoolean(Prefs.IS_CONTRIBUTION_COUNT_CHANGED, true);
uploadLimit.setSummary(500 + "");
uploadLimit.setText(500 + "");
} else {
editor.putInt(Prefs.UPLOADS_SHOWING, Integer.parseInt(newValue.toString()));
editor.putBoolean(Prefs.IS_CONTRIBUTION_COUNT_CHANGED, true);
uploadLimit.setSummary(newValue.toString());
}
editor.apply();
return true;
}
});
}
use of android.preference.CheckBoxPreference in project aware-client by denzilferreira.
the class Aware_Client method onSharedPreferenceChanged.
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
String value = "";
Map<String, ?> keys = sharedPreferences.getAll();
if (keys.containsKey(key)) {
Object entry = keys.get(key);
if (entry instanceof Boolean)
value = String.valueOf(sharedPreferences.getBoolean(key, false));
else if (entry instanceof String)
value = String.valueOf(sharedPreferences.getString(key, "error"));
else if (entry instanceof Integer)
value = String.valueOf(sharedPreferences.getInt(key, 0));
}
Aware.setSetting(getApplicationContext(), key, value);
Preference pref = findPreference(key);
if (CheckBoxPreference.class.isInstance(pref)) {
CheckBoxPreference check = (CheckBoxPreference) findPreference(key);
check.setChecked(Aware.getSetting(getApplicationContext(), key).equals("true"));
// update the parent to show active/inactive
new SettingsSync().execute(pref);
// Start/Stop sensor
Aware.startAWARE(getApplicationContext());
}
if (EditTextPreference.class.isInstance(pref)) {
EditTextPreference text = (EditTextPreference) findPreference(key);
text.setText(Aware.getSetting(getApplicationContext(), key));
}
if (ListPreference.class.isInstance(pref)) {
ListPreference list = (ListPreference) findPreference(key);
list.setSummary(list.getEntry());
}
}
Aggregations