Java Code Examples for android.preference.Preference#setIntent()
The following examples show how to use
android.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: UserDictionaryList.java From Android-Keyboard with Apache License 2.0 | 6 votes |
/** * Create a single User Dictionary Preference object, with its parameters set. * @param localeString The locale for which this user dictionary is for. * @return The corresponding preference. */ protected Preference createUserDictionaryPreference(@Nullable final String localeString) { final Preference newPref = new Preference(getActivity()); final Intent intent = new Intent(USER_DICTIONARY_SETTINGS_INTENT_ACTION); if (null == localeString) { newPref.setTitle(Locale.getDefault().getDisplayName()); } else { if (localeString.isEmpty()) { newPref.setTitle(getString(R.string.user_dict_settings_all_languages)); } else { newPref.setTitle( LocaleUtils.constructLocaleFromString(localeString).getDisplayName()); } intent.putExtra("locale", localeString); newPref.getExtras().putString("locale", localeString); } newPref.setIntent(intent); newPref.setFragment(UserDictionarySettings.class.getName()); return newPref; }
Example 2
Source File: Preferences.java From Androzic with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PreferenceScreen root = getPreferenceManager().createPreferenceScreen(getActivity()); root.setTitle(R.string.pref_plugins_title); setPreferenceScreen(root); Androzic application = (Androzic) getActivity().getApplication(); Map<String, Intent> plugins = application.getPluginsPreferences(); for (String plugin : plugins.keySet()) { Preference preference = new Preference(getActivity()); preference.setTitle(plugin); preference.setIntent(plugins.get(plugin)); root.addPreference(preference); } }
Example 3
Source File: UserDictionaryList.java From Indic-Keyboard with Apache License 2.0 | 6 votes |
/** * Create a single User Dictionary Preference object, with its parameters set. * @param localeString The locale for which this user dictionary is for. * @return The corresponding preference. */ protected Preference createUserDictionaryPreference(@Nullable final String localeString) { final Preference newPref = new Preference(getActivity()); final Intent intent = new Intent(USER_DICTIONARY_SETTINGS_INTENT_ACTION); if (null == localeString) { newPref.setTitle(Locale.getDefault().getDisplayName()); } else { if (localeString.isEmpty()) { newPref.setTitle(getString(R.string.user_dict_settings_all_languages)); } else { newPref.setTitle( LocaleUtils.constructLocaleFromString(localeString).getDisplayName()); } intent.putExtra("locale", localeString); newPref.getExtras().putString("locale", localeString); } newPref.setIntent(intent); newPref.setFragment(UserDictionarySettings.class.getName()); return newPref; }
Example 4
Source File: ChansFragment.java From Dashchan with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ChanManager manager = ChanManager.getInstance(); int color = ResourceUtils.getColor(getActivity(), R.attr.drawerIconColor); for (String chanName : manager.getAvailableChanNames()) { Preference preference = makeButton(null, ChanConfiguration.get(chanName).getTitle(), null, false); Drawable drawable = manager.getIcon(chanName, color); if (drawable != null) { preference.setIcon(drawable); } Intent intent = new Intent(getActivity(), PreferencesActivity.class); intent.putExtra(PreferencesActivity.EXTRA_SHOW_FRAGMENT, ChanFragment.class.getName()); intent.putExtra(PreferencesActivity.EXTRA_NO_HEADERS, true); intent.putExtra(C.EXTRA_CHAN_NAME, chanName); preference.setIntent(intent); } }
Example 5
Source File: ManagedPreferenceDelegate.java From 365browser with Apache License 2.0 | 6 votes |
/** * Initializes the Preference based on the state of any policies that may affect it, * e.g. by showing a managed icon or disabling clicks on the preference. * * This should be called once, before the preference is displayed. */ public void initPreference(Preference preference) { if (isPreferenceControlledByPolicy(preference)) { preference.setIcon(ManagedPreferencesUtils.getManagedByEnterpriseIconId()); } else if (isPreferenceControlledByCustodian(preference)) { preference.setIcon(R.drawable.ic_account_child_grey600_36dp); } if (isPreferenceClickDisabledByPolicy(preference)) { // Disable the views and prevent the Preference from mucking with the enabled state. preference.setShouldDisableView(false); // Prevent default click behavior. preference.setFragment(null); preference.setIntent(null); preference.setOnPreferenceClickListener(null); } }
Example 6
Source File: SwitchAccessPreferenceActivity.java From talkback with Apache License 2.0 | 6 votes |
private void assignTtsSettingsIntentOrRemovePref() { PreferenceScreen preferenceScreen = (PreferenceScreen) findPreference(R.string.pref_key_category_switch_access_speech_sound_vibration); Preference ttsSettingsPreference = findPreference(R.string.pref_key_switch_access_tts_settings); if (preferenceScreen == null || ttsSettingsPreference == null) { return; } Intent ttsSettingsIntent = new Intent(TTS_SETTINGS_INTENT); ttsSettingsIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (canHandleIntent(ttsSettingsIntent)) { ttsSettingsPreference.setIntent(ttsSettingsIntent); } else { // We should remove the preference if there is no TTS Settings intent filter in settings // app. preferenceScreen.removePreference(ttsSettingsPreference); } }
Example 7
Source File: ManagedPreferenceDelegate.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Initializes the Preference based on the state of any policies that may affect it, * e.g. by showing a managed icon or disabling clicks on the preference. * * This should be called once, before the preference is displayed. */ public void initPreference(Preference preference) { if (isPreferenceControlledByPolicy(preference)) { preference.setIcon(ManagedPreferencesUtils.getManagedByEnterpriseIconId()); if (isPreferenceClickDisabledByPolicy(preference)) { // Disable the views and prevent the Preference from mucking with the enabled state. preference.setShouldDisableView(false); // Prevent default click behavior. preference.setFragment(null); preference.setIntent(null); preference.setOnPreferenceClickListener(null); } } }
Example 8
Source File: ManagedPreferenceDelegate.java From delion with Apache License 2.0 | 6 votes |
/** * Initializes the Preference based on the state of any policies that may affect it, * e.g. by showing a managed icon or disabling clicks on the preference. * * This should be called once, before the preference is displayed. */ public void initPreference(Preference preference) { if (isPreferenceControlledByPolicy(preference)) { preference.setIcon(ManagedPreferencesUtils.getManagedByEnterpriseIconId()); if (isPreferenceClickDisabledByPolicy(preference)) { // Disable the views and prevent the Preference from mucking with the enabled state. preference.setShouldDisableView(false); // Prevent default click behavior. preference.setFragment(null); preference.setIntent(null); preference.setOnPreferenceClickListener(null); } } }
Example 9
Source File: InputMethodSettingsImpl.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 6 votes |
/** * Initialize internal states of this object. * * @param context the context for this application. * @param prefScreen a PreferenceScreen of PreferenceActivity or PreferenceFragment. * @return true if this application is an IME and has two or more subtypes, false otherwise. */ public boolean init(final Context context, final PreferenceScreen prefScreen) { mImm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); mImi = getMyImi(context, mImm); if (mImi == null || mImi.getSubtypeCount() <= 1) { return false; } final Intent intent = new Intent(Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS); intent.putExtra(Settings.EXTRA_INPUT_METHOD_ID, mImi.getId()); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP); mSubtypeEnablerPreference = new Preference(context); mSubtypeEnablerPreference.setIntent(intent); prefScreen.addPreference(mSubtypeEnablerPreference); updateSubtypeEnabler(); return true; }
Example 10
Source File: UserDictionaryList.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 6 votes |
/** * Create a single User Dictionary Preference object, with its parameters set. * @param localeString The locale for which this user dictionary is for. * @return The corresponding preference. */ protected Preference createUserDictionaryPreference(@Nullable final String localeString) { final Preference newPref = new Preference(getActivity()); final Intent intent = new Intent(USER_DICTIONARY_SETTINGS_INTENT_ACTION); if (null == localeString) { newPref.setTitle(Locale.getDefault().getDisplayName()); } else { if (localeString.isEmpty()) { newPref.setTitle(getString(R.string.user_dict_settings_all_languages)); } else { newPref.setTitle( LocaleUtils.constructLocaleFromString(localeString).getDisplayName()); } intent.putExtra("locale", localeString); newPref.getExtras().putString("locale", localeString); } newPref.setIntent(intent); newPref.setFragment(UserDictionarySettings.class.getName()); return newPref; }
Example 11
Source File: InputMethodSettingsImpl.java From Android-Keyboard with Apache License 2.0 | 6 votes |
/** * Initialize internal states of this object. * @param context the context for this application. * @param prefScreen a PreferenceScreen of PreferenceActivity or PreferenceFragment. * @return true if this application is an IME and has two or more subtypes, false otherwise. */ public boolean init(final Context context, final PreferenceScreen prefScreen) { mImm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); mImi = getMyImi(context, mImm); if (mImi == null || mImi.getSubtypeCount() <= 1) { return false; } final Intent intent = new Intent(Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS); intent.putExtra(Settings.EXTRA_INPUT_METHOD_ID, mImi.getId()); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP); mSubtypeEnablerPreference = new Preference(context); mSubtypeEnablerPreference.setIntent(intent); prefScreen.addPreference(mSubtypeEnablerPreference); updateSubtypeEnabler(); return true; }
Example 12
Source File: UserDictionaryList.java From openboard with GNU General Public License v3.0 | 6 votes |
/** * Create a single User Dictionary Preference object, with its parameters set. * @param localeString The locale for which this user dictionary is for. * @return The corresponding preference. */ protected Preference createUserDictionaryPreference(@Nullable final String localeString) { final Preference newPref = new Preference(getActivity()); final Intent intent = new Intent(USER_DICTIONARY_SETTINGS_INTENT_ACTION); if (null == localeString) { newPref.setTitle(Locale.getDefault().getDisplayName()); } else { if (localeString.isEmpty()) { newPref.setTitle(getString(R.string.user_dict_settings_all_languages)); } else { newPref.setTitle( LocaleUtils.constructLocaleFromString(localeString).getDisplayName()); } intent.putExtra("locale", localeString); newPref.getExtras().putString("locale", localeString); } newPref.setIntent(intent); newPref.setFragment(UserDictionarySettings.class.getName()); return newPref; }
Example 13
Source File: BrailleBackPreferencesActivity.java From brailleback with Apache License 2.0 | 5 votes |
/** * Assigns the appropriate intent to the key bindings preference. */ private void assignKeyBindingsIntent() { Preference pref = findPreferenceByResId(R.string.pref_key_bindings_key); final Intent intent = new Intent(this, KeyBindingsActivity.class); pref.setIntent(intent); }
Example 14
Source File: SettingsFragment.java From science-journal with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Context context = getActivity(); AppAccount appAccount = WhistlePunkApplication.getAccount(context, getArguments(), KEY_ACCOUNT_KEY); int type = getArguments().getInt(KEY_TYPE); if (type == SettingsActivity.TYPE_ABOUT) { // TODO(lizlooney): Does the about box have any account-based settings? If so, we need to // call // getPreferenceManager().setSharedPreferencesName(appAccount.getSharedPreferencesName()); addPreferencesFromResource(R.xml.about); Preference licensePreference = findPreference(KEY_OPEN_SOURCE); licensePreference.setIntent( WhistlePunkApplication.getAppServices(context).getLicenseProvider().getIntent(context)); loadVersion(context); } else if (type == SettingsActivity.TYPE_SETTINGS) { // Use the SharedPreferences for the account. getPreferenceManager().setSharedPreferencesName(appAccount.getSharedPreferencesName()); addPreferencesFromResource(R.xml.settings); } else { throw new IllegalStateException("SettingsFragment type " + type + " is unknown."); } }
Example 15
Source File: ActivitySettings.java From FineGeotag with GNU General Public License v3.0 | 5 votes |
@Override protected void onResume() { super.onResume(); getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); SharedPreferences prefs = getPreferenceScreen().getSharedPreferences(); // Get preferences Preference pref_check = findPreference(PREF_CHECK); Preference pref_version = findPreference(PREF_VERSION); // Set summaries onSharedPreferenceChanged(prefs, PREF_ENABLED); onSharedPreferenceChanged(prefs, PREF_TOAST); onSharedPreferenceChanged(prefs, PREF_ALTITUDE); onSharedPreferenceChanged(prefs, PREF_ACCURACY); onSharedPreferenceChanged(prefs, PREF_TIMEOUT); onSharedPreferenceChanged(prefs, PREF_KNOWN); // Location settings Intent locationSettingsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); if (getPackageManager().queryIntentActivities(locationSettingsIntent, 0).size() > 0) pref_check.setIntent(locationSettingsIntent); else pref_check.setEnabled(false); // Version Intent playStoreIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName())); if (getPackageManager().queryIntentActivities(playStoreIntent, 0).size() > 0) pref_version.setIntent(playStoreIntent); try { PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); pref_version.setSummary( pInfo.versionName + "/" + pInfo.versionCode + "\n" + getString(R.string.msg_geocoder) + " " + getString(Geocoder.isPresent() ? R.string.msg_yes : R.string.msg_no)); } catch (PackageManager.NameNotFoundException ignored) { } }
Example 16
Source File: PreferencesImport.java From callmeter with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") @Override protected void onProgressUpdate(final File... values) { for (File f : values) { // add file to list PreferencesImport context = PreferencesImport.this; Preference p = new Preference(context); p.setTitle(f.getName()); p.setSummary(f.getAbsolutePath()); Intent i = new Intent(context, Preferences.class); i.setData(Uri.parse("file://" + f.getAbsolutePath())); p.setIntent(i); ((PreferenceGroup) context.findPreference("import_rules_files")).addPreference(p); } }
Example 17
Source File: SwitchAccessPreferenceActivity.java From talkback with Apache License 2.0 | 4 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); PreferenceSettingsUtils.addPreferencesFromResource(this, R.xml.switch_access_preferences); /* Switch Access setup wizard button */ final Preference beginSwitchAccessSetupPref = findPreference(R.string.pref_begin_switchaccess_setup_key); beginSwitchAccessSetupPref.setOnPreferenceClickListener( preference -> { Context context = getActivity(); Intent intent = new Intent(context, SetupWizardActivity.class); getActivity().startActivity(intent); return true; }); assignTtsSettingsIntentOrRemovePref(); // Configure Auto-scan summaries configureDelayPrefSummary( R.string.pref_key_auto_scan_time_delay, R.string.pref_auto_scan_time_delay_default_value, false); configureDelayPrefSummary( R.string.pref_key_start_scan_delay, R.string.pref_start_scan_delay_default_value, true); configureIntPrefSummary( R.string.pref_key_point_scan_and_autoscan_loop_count, R.string.pref_point_scan_and_autoscan_loop_count_default, R.plurals.label_num_scanning_loops_format, 1); configureDelayPrefSummary( R.string.pref_key_switch_access_spoken_feedback_maximum_time_per_item, R.integer.pref_maximum_time_per_item_default_value_seconds, false); // Configure Point scan summaries configurePrefSummary( R.string.pref_key_point_scan_line_speed, R.string.pref_point_scan_line_speed_default, R.plurals.line_speed_summary_format, false); PreferenceScreen pointScanScreen = (PreferenceScreen) findPreference(R.string.pref_category_point_scan_key); configureDelayPrefSummary( pointScanScreen.findPreference(getString(R.string.pref_key_start_scan_delay)), R.string.pref_start_scan_delay_default_value, true); configureIntPrefSummary( pointScanScreen.findPreference( getString(R.string.pref_key_point_scan_and_autoscan_loop_count)), R.string.pref_point_scan_and_autoscan_loop_count_default, R.plurals.label_num_scanning_loops_format, 1); // Configure debounce time summary configureDelayPrefSummary( R.string.pref_key_debounce_time, R.string.pref_debounce_time_default, true); adjustAutoSelectPref(); adjustHighlightingPrefs(); adjustKeysForScanning(); adjustPointScanPrefs(); adjustLinearScanEverywherePrefs(); adjustAutoscanPrefs(); adjustSpokenFeedbackPrefs(); // Add listener to "Help & feedback" preference. Preference helpAndFeedbackPreference = findPreference(R.string.pref_help_feedback_key); helpAndFeedbackPreference.setOnPreferenceClickListener( preference -> { HelpUtils.launchHelp(getActivity()); SwitchAccessLogger analytics = SwitchAccessLogger.getInstanceIfExists(); if (analytics != null) { analytics.onScreenShown(SCREEN_NAME_HELP_AND_FEEDBACK); } return true; }); // Add an action to open the privacy policy Preference privacyPolicyPreference = findPreference(R.string.pref_key_privacy_policy); Uri privacyPolicyUri = Uri.parse(PRIVACY_POLICY_URL); Intent privacyPolicyIntent = new Intent(Intent.ACTION_VIEW, privacyPolicyUri); privacyPolicyPreference.setIntent(privacyPolicyIntent); // Add a preference change listener, so we can adjust preferences when they are changed from // both inside and outside the preference activity. SwitchAccessPreferenceUtils.registerSwitchAccessPreferenceChangedListener( getActivity(), this); }
Example 18
Source File: GenericPrefs.java From CSipSimple with GNU General Public License v3.0 | 4 votes |
private void setPreferenceScreenType(Class<?> classObj, String key, int type) { Preference pf = findPreference(key); Intent it = new Intent(this, classObj); it.putExtra(PrefsLogic.EXTRA_PREFERENCE_TYPE, type); pf.setIntent(it); }