use of android.preference.Preference.OnPreferenceClickListener in project android by nextcloud.
the class Preferences method setupHelpPreference.
private void setupHelpPreference(PreferenceCategory preferenceCategoryMore) {
boolean helpEnabled = getResources().getBoolean(R.bool.help_enabled);
Preference pHelp = findPreference("help");
if (pHelp != null) {
if (helpEnabled) {
pHelp.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
String helpWeb = getString(R.string.url_help);
if (helpWeb != null && helpWeb.length() > 0) {
Uri uriUrl = Uri.parse(helpWeb);
Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
startActivity(intent);
}
return true;
}
});
} else {
preferenceCategoryMore.removePreference(pHelp);
}
}
}
use of android.preference.Preference.OnPreferenceClickListener in project android by nextcloud.
the class Preferences method loadExternalSettingLinks.
private void loadExternalSettingLinks(PreferenceCategory preferenceCategory) {
if (getBaseContext().getResources().getBoolean(R.bool.show_external_links)) {
ExternalLinksProvider externalLinksProvider = new ExternalLinksProvider(getContentResolver());
for (final ExternalLink link : externalLinksProvider.getExternalLink(ExternalLinkType.SETTINGS)) {
// only add if it does not exist, in case activity is re-used
if (findPreference(link.id.toString()) == null) {
Preference p = new Preference(this);
p.setTitle(link.name);
p.setKey(link.id.toString());
p.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent externalWebViewIntent = new Intent(getApplicationContext(), ExternalSiteWebView.class);
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_TITLE, link.name);
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_URL, link.url);
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_SHOW_SIDEBAR, false);
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_MENU_ITEM_ID, link.id);
startActivity(externalWebViewIntent);
return true;
}
});
preferenceCategory.addPreference(p);
}
}
}
}
use of android.preference.Preference.OnPreferenceClickListener in project android by nextcloud.
the class Preferences method setupRecommendPreference.
private void setupRecommendPreference(PreferenceCategory preferenceCategoryMore) {
boolean recommendEnabled = getResources().getBoolean(R.bool.recommend_enabled);
Preference pRecommend = findPreference("recommend");
if (pRecommend != null) {
if (recommendEnabled) {
pRecommend.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
String appName = getString(R.string.app_name);
String downloadUrlGooglePlayStore = getString(R.string.url_app_download);
String downloadUrlFDroid = getString(R.string.fdroid_link);
String downloadUrls = String.format(getString(R.string.recommend_urls), downloadUrlGooglePlayStore, downloadUrlFDroid);
String recommendSubject = String.format(getString(R.string.recommend_subject), appName);
String recommendText = String.format(getString(R.string.recommend_text), appName, downloadUrls);
intent.putExtra(Intent.EXTRA_SUBJECT, recommendSubject);
intent.putExtra(Intent.EXTRA_TEXT, recommendText);
startActivity(intent);
return true;
}
});
} else {
preferenceCategoryMore.removePreference(pRecommend);
}
}
}
use of android.preference.Preference.OnPreferenceClickListener in project Osmand by osmandapp.
the class SettingsOsmEditingActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
((OsmandApplication) getApplication()).applyTheme(this);
super.onCreate(savedInstanceState);
getToolbar().setTitle(R.string.osm_settings);
@SuppressWarnings("deprecation") PreferenceScreen grp = getPreferenceScreen();
DialogPreference loginDialogPreference = new OsmLoginDataDialogPreference(this, null);
grp.addPreference(loginDialogPreference);
CheckBoxPreference poiEdit = createCheckBoxPreference(settings.OFFLINE_EDITION, R.string.offline_edition, R.string.offline_edition_descr);
grp.addPreference(poiEdit);
Preference pref = new Preference(this);
pref.setTitle(R.string.local_openstreetmap_settings);
pref.setSummary(R.string.local_openstreetmap_settings_descr);
pref.setKey("local_openstreetmap_points");
pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
final Intent favorites = new Intent(SettingsOsmEditingActivity.this, appCustomization.getFavoritesActivity());
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
getMyApplication().getSettings().FAVORITES_TAB.set(R.string.osm_edits);
startActivity(favorites);
return true;
}
});
grp.addPreference(pref);
}
use of android.preference.Preference.OnPreferenceClickListener in project sentinel-android by Samourai-Wallet.
the class SettingsActivity method onCreate.
/**
* Called when the activity is first created.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(R.string.app_name);
addPreferencesFromResource(R.xml.settings);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Preference aboutPref = (Preference) findPreference("about");
aboutPref.setSummary("Sentinel," + " " + getResources().getString(R.string.version_name));
aboutPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
new AlertDialog.Builder(SettingsActivity.this).setIcon(R.drawable.ic_launcher).setTitle(R.string.app_name).setMessage("Sentinel," + " " + getResources().getString(R.string.version_name)).setCancelable(false).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
;
}
}).show();
return true;
}
});
Preference explorersPref = (Preference) findPreference("explorer");
explorersPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
getBlockExplorer();
return true;
}
});
Preference fiatPref = (Preference) findPreference("fiat");
fiatPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
getExchange();
return true;
}
});
final CheckBoxPreference cbPref1 = (CheckBoxPreference) findPreference("pin");
final CheckBoxPreference cbPref2 = (CheckBoxPreference) findPreference("scramblePin");
final CheckBoxPreference cbPref3 = (CheckBoxPreference) findPreference("haptic");
if (!cbPref1.isChecked()) {
cbPref2.setChecked(false);
cbPref2.setEnabled(false);
cbPref3.setChecked(false);
cbPref3.setEnabled(false);
}
cbPref1.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (cbPref1.isChecked()) {
PrefsUtil.getInstance(SettingsActivity.this).setValue(PrefsUtil.PIN_HASH, "");
cbPref2.setChecked(false);
cbPref2.setEnabled(false);
cbPref3.setChecked(false);
cbPref3.setEnabled(false);
PrefsUtil.getInstance(SettingsActivity.this).setValue(PrefsUtil.SCRAMBLE_PIN, false);
} else {
cbPref2.setEnabled(true);
cbPref3.setEnabled(true);
Intent intent = new Intent(SettingsActivity.this, PinEntryActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("create", true);
startActivity(intent);
}
return true;
}
});
cbPref2.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (cbPref2.isChecked()) {
PrefsUtil.getInstance(SettingsActivity.this).setValue(PrefsUtil.SCRAMBLE_PIN, false);
} else {
PrefsUtil.getInstance(SettingsActivity.this).setValue(PrefsUtil.SCRAMBLE_PIN, true);
}
return true;
}
});
cbPref3.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (cbPref3.isChecked()) {
PrefsUtil.getInstance(SettingsActivity.this).setValue(PrefsUtil.HAPTIC_PIN, false);
} else {
PrefsUtil.getInstance(SettingsActivity.this).setValue(PrefsUtil.HAPTIC_PIN, true);
}
return true;
}
});
Preference exportPref = (Preference) findPreference("export");
exportPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
AppUtil.getInstance(SettingsActivity.this).doBackup();
return true;
}
});
Preference restorePref = (Preference) findPreference("restore");
restorePref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
AppUtil.getInstance(SettingsActivity.this).doRestore();
return true;
}
});
}
Aggregations