Java Code Examples for android.support.v7.preference.Preference#setIntent()
The following examples show how to use
android.support.v7.preference.Preference#setIntent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NGWSettingsFragment.java From android_maplibui with GNU Lesser General Public License v3.0 | 6 votes |
protected void addEditAccountAction( final IGISApplication application, final Account account, PreferenceGroup actionCategory) { Preference preferenceEdit = new Preference(mStyledContext); preferenceEdit.setTitle(R.string.edit_account); preferenceEdit.setSummary(R.string.edit_account_summary); String url = application.getAccountUrl(account); String login = application.getAccountLogin(account); Intent intent = new Intent(mStyledContext, NGWLoginActivity.class); intent.putExtra(NGWLoginActivity.FOR_NEW_ACCOUNT, false); intent.putExtra(NGWLoginActivity.ACCOUNT_URL_TEXT, url); intent.putExtra(NGWLoginActivity.ACCOUNT_LOGIN_TEXT, login); intent.putExtra(NGWLoginActivity.CHANGE_ACCOUNT_URL, false); intent.putExtra(NGWLoginActivity.CHANGE_ACCOUNT_LOGIN, true); preferenceEdit.setIntent(intent); actionCategory.addPreference(preferenceEdit); }
Example 2
Source File: SmsMmsPreferenceFragment.java From Silence with GNU General Public License v3.0 | 5 votes |
private void initializePlatformSpecificOptions() { PreferenceScreen preferenceScreen = getPreferenceScreen(); Preference defaultPreference = findPreference(KITKAT_DEFAULT_PREF); Preference allSmsPreference = findPreference(SilencePreferences.ALL_SMS_PREF); Preference allMmsPreference = findPreference(SilencePreferences.ALL_MMS_PREF); Preference manualMmsPreference = findPreference(MMS_PREF); if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) { if (allSmsPreference != null) preferenceScreen.removePreference(allSmsPreference); if (allMmsPreference != null) preferenceScreen.removePreference(allMmsPreference); if (Util.isDefaultSmsProvider(getActivity())) { defaultPreference.setIntent(new Intent(Settings.ACTION_WIRELESS_SETTINGS)); defaultPreference.setTitle(getString(R.string.ApplicationPreferencesActivity_sms_enabled)); defaultPreference.setSummary(getString(R.string.ApplicationPreferencesActivity_tap_to_change_your_default_sms_app)); } else { Intent intent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT); intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, getActivity().getPackageName()); defaultPreference.setIntent(intent); defaultPreference.setTitle(getString(R.string.ApplicationPreferencesActivity_sms_disabled)); defaultPreference.setSummary(getString(R.string.ApplicationPreferencesActivity_tap_to_make_silence_your_default_sms_app)); } } else if (defaultPreference != null) { preferenceScreen.removePreference(defaultPreference); } if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP && manualMmsPreference != null) { preferenceScreen.removePreference(manualMmsPreference); } }
Example 3
Source File: MoreInfoFragment.java From memetastic with GNU General Public License v3.0 | 4 votes |
@Override public synchronized void doUpdatePreferences() { super.doUpdatePreferences(); Context context = getContext(); if (context == null) { return; } Locale locale = Locale.getDefault(); String tmp; Preference pref; updateSummary(R.string.pref_key__more_info__project_license, getString(R.string.app_license_name)); // Basic app info if ((pref = findPreference(R.string.pref_key__more_info__app)) != null && pref.getSummary() == null) { pref.setIcon(R.drawable.ic_launcher); pref.setSummary(String.format(locale, "%s\nVersion v%s (%d)", _cu.getPackageIdReal(), _cu.getAppVersionName(), _cu.bcint("VERSION_CODE", 0))); } // Extract some build information and publish in summary if ((pref = findPreference(R.string.pref_key__more_info__copy_build_information)) != null && pref.getSummary() == null) { String summary = String.format(locale, "\n<b>Package:</b> %s\n<b>Version:</b> v%s (%d)", _cu.getPackageIdReal(), _cu.getAppVersionName(), _cu.bcint("VERSION_CODE", 0)); summary += (tmp = _cu.bcstr("FLAVOR", "")).isEmpty() ? "" : ("\n<b>Flavor:</b> " + tmp.replace("flavor", "")); summary += (tmp = _cu.bcstr("BUILD_TYPE", "")).isEmpty() ? "" : (" (" + tmp + ")"); summary += (tmp = _cu.bcstr("BUILD_DATE", "")).isEmpty() ? "" : ("\n<b>Build date:</b> " + tmp); summary += (tmp = _cu.getAppInstallationSource()).isEmpty() ? "" : ("\n<b>ISource:</b> " + tmp); summary += (tmp = _cu.bcstr("GITHASH", "")).isEmpty() ? "" : ("\n<b>VCS Hash:</b> " + tmp); pref.setSummary(_cu.htmlToSpanned(summary.trim().replace("\n", "<br/>"))); } // Extract project team from raw ressource, where 1 person = 4 lines // 1) Name/Title, 2) Description/Summary, 3) Link/View-Intent, 4) Empty line if ((pref = findPreference(R.string.pref_key__more_info__project_team)) != null && ((PreferenceGroup) pref).getPreferenceCount() == 0) { String[] data = (_cu.readTextfileFromRawRes(R.raw.project_team, "", "").trim() + "\n\n").split("\n"); for (int i = 0; i + 2 < data.length; i += 4) { Preference person = new Preference(context); person.setTitle(data[i]); person.setSummary(data[i + 1]); person.setIcon(R.drawable.ic_person_black_24dp); try { Uri uri = Uri.parse(data[i + 2]); Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); person.setIntent(intent); } catch (Exception ignored) { } appendPreference(person, (PreferenceGroup) pref); } } if ((pref = findPreference(R.string.pref_key__more_info__help)) != null) { pref.setTitle(getString(R.string.help) + " / FAQ"); } }
Example 4
Source File: SettingsAboutFragment.java From openlauncher with Apache License 2.0 | 4 votes |
@Override public synchronized void doUpdatePreferences() { super.doUpdatePreferences(); Context context = getContext(); if (context == null) { return; } Locale locale = Locale.getDefault(); String tmp; Preference pref; updateSummary(R.string.pref_key__more_info__project_license, getString(R.string.app_license_name)); // Basic app info if ((pref = findPreference(R.string.pref_key__more_info__app)) != null && pref.getSummary() == null) { pref.setIcon(R.mipmap.ic_launcher); pref.setSummary(String.format(locale, "%s\nVersion v%s (%d)", _cu.getPackageIdReal(), _cu.getAppVersionName(), _cu.bcint("VERSION_CODE", 0))); } // Extract some build information and publish in summary if ((pref = findPreference(R.string.pref_key__more_info__copy_build_information)) != null && pref.getSummary() == null) { String summary = String.format(locale, "\n<b>Package:</b> %s\n<b>Version:</b> v%s (%d)", _cu.getPackageIdReal(), _cu.getAppVersionName(), _cu.bcint("VERSION_CODE", 0)); summary += (tmp = _cu.bcstr("FLAVOR", "")).isEmpty() ? "" : ("\n<b>Flavor:</b> " + tmp.replace("flavor", "")); summary += (tmp = _cu.bcstr("BUILD_TYPE", "")).isEmpty() ? "" : (" (" + tmp + ")"); summary += (tmp = _cu.bcstr("BUILD_DATE", "")).isEmpty() ? "" : ("\n<b>Build date:</b> " + tmp); summary += (tmp = _cu.getAppInstallationSource()).isEmpty() ? "" : ("\n<b>ISource:</b> " + tmp); summary += (tmp = _cu.bcstr("GITHASH", "")).isEmpty() ? "" : ("\n<b>VCS Hash:</b> " + tmp); pref.setSummary(_cu.htmlToSpanned(summary.trim().replace("\n", "<br/>"))); } // Extract project team from raw resource, where 1 person = 4 lines // 1) Name/Title, 2) Description/Summary, 3) Link/View-Intent, 4) Empty line if ((pref = findPreference(R.string.pref_key__more_info__project_team)) != null && ((PreferenceGroup) pref).getPreferenceCount() == 0) { String[] data = (_cu.readTextfileFromRawRes(R.raw.project, "", "").trim() + "\n\n").split("\n"); for (int i = 0; i + 2 < data.length; i += 4) { Preference person = new Preference(context); person.setTitle(data[i]); person.setSummary(data[i + 1]); person.setIcon(R.drawable.ic_person); try { Uri uri = Uri.parse(data[i + 2]); Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); person.setIntent(intent); } catch (Exception ignored) { } appendPreference(person, (PreferenceGroup) pref); } } }
Example 5
Source File: MoreInfoFragment.java From Stringlate with MIT License | 4 votes |
@Override public synchronized void doUpdatePreferences() { super.doUpdatePreferences(); Context context = getContext(); if (context == null) { return; } Locale locale = Locale.getDefault(); String tmp; Preference pref; updateSummary(R.string.pref_key__more_info__project_license, getString(R.string.app_license_name)); // Basic app info if ((pref = findPreference(R.string.pref_key__more_info__app)) != null && pref.getSummary() == null) { pref.setIcon(R.drawable.ic_launcher); pref.setSummary(String.format(locale, "%s\nVersion v%s (%d)", _cu.getPackageName(), _cu.getAppVersionName(), _cu.bcint("VERSION_CODE", 0))); } // Extract some build information and publish in summary if ((pref = findPreference(R.string.pref_key__more_info__copy_build_information)) != null && pref.getSummary() == null) { String summary = String.format(locale, "\n<b>Package:</b> %s\n<b>Version:</b> v%s (%d)", _cu.getPackageName(), _cu.getAppVersionName(), _cu.bcint("VERSION_CODE", 0)); summary += (tmp = _cu.bcstr("FLAVOR", "")).isEmpty() ? "" : ("\n<b>Flavor:</b> " + tmp.replace("flavor", "")); summary += (tmp = _cu.bcstr("BUILD_TYPE", "")).isEmpty() ? "" : (" (" + tmp + ")"); summary += (tmp = _cu.bcstr("BUILD_DATE", "")).isEmpty() ? "" : ("\n<b>Build date:</b> " + tmp); summary += (tmp = _cu.getAppInstallationSource()).isEmpty() ? "" : ("\n<b>ISource:</b> " + tmp); summary += (tmp = _cu.bcstr("GITHASH", "")).isEmpty() ? "" : ("\n<b>VCS Hash:</b> " + tmp); pref.setSummary(_cu.htmlToSpanned(summary.trim().replace("\n", "<br/>"))); } // Extract project team from raw ressource, where 1 person = 4 lines // 1) Name/Title, 2) Description/Summary, 3) Link/View-Intent, 4) Empty line if ((pref = findPreference(R.string.pref_key__more_info__project_team)) != null && ((PreferenceGroup) pref).getPreferenceCount() == 0) { String[] data = (_cu.readTextfileFromRawRes(R.raw.project_team, "", "").trim() + "\n\n").split("\n"); for (int i = 0; i + 2 < data.length; i += 4) { Preference person = new Preference(context); person.setTitle(data[i]); person.setSummary(data[i + 1]); person.setIcon(R.drawable.ic_person_black_24dp); try { Uri uri = Uri.parse(data[i + 2]); Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); person.setIntent(intent); } catch (Exception ignored) { } appendPreference(person, (PreferenceGroup) pref); } } }