com.yarolegovich.mp.MaterialStandardPreference Java Examples
The following examples show how to use
com.yarolegovich.mp.MaterialStandardPreference.
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: PreferenceActivity.java From DNSHero with GNU General Public License v3.0 | 6 votes |
@Override protected void buildPreferences(@NonNull Context context) { if (!Prefs.isSetEmpty(PK.FAVORITES)) { final MaterialStandardPreference remove = new MaterialStandardPreference(context); remove.setTitle(R.string.removeFavorite); remove.setSummary(R.string.removeFavorite_summary); remove.setOnClickListener(v -> showRemoveDialog(context)); addPreference(remove); } MaterialStandardPreference clear = new MaterialStandardPreference(context); clear.setTitle(R.string.clearFavorites); clear.setSummary(R.string.clearFavorites_summary); clear.setOnClickListener(v -> { Prefs.putSet(PK.FAVORITES, new HashSet<>()); onBackPressed(); }); addPreference(clear); }
Example #2
Source File: PreferenceActivity.java From Aria2App with GNU General Public License v3.0 | 6 votes |
@Override protected void buildPreferences(@NonNull Context context) { MaterialStandardPreference importProfiles = new MaterialStandardPreference(context); importProfiles.setTitle(R.string.importProfiles); importProfiles.setSummary(R.string.importProfiles_summary); addPreference(importProfiles); importProfiles.setOnClickListener(v -> { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("*/*"); try { startActivityForResult(Intent.createChooser(intent, "Select a file"), IMPORT_PROFILES_CODE); } catch (ActivityNotFoundException ex) { showToast(Toaster.build().message(R.string.noFilemanager)); } }); MaterialStandardPreference exportProfiles = new MaterialStandardPreference(context); exportProfiles.setTitle(R.string.exportProfiles); exportProfiles.setSummary(R.string.exportProfiles_summary); addPreference(exportProfiles); exportProfiles.setOnClickListener(v -> doExport()); }
Example #3
Source File: PreferenceActivity.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 6 votes |
@Override protected void buildPreferences(@NonNull Context context) { MaterialCheckboxPreference nightMode = new MaterialCheckboxPreference.Builder(context) .defaultValue(PK.NIGHT_MODE.fallback()) .key(PK.NIGHT_MODE.key()) .build(); nightMode.setTitle(R.string.prefs_nightMode); nightMode.setSummary(R.string.prefs_nightMode_summary); addPreference(nightMode); if (!Prefs.isSetEmpty(PK.BLOCKED_USERS)) { MaterialStandardPreference unblock = new MaterialStandardPreference(context); unblock.setTitle(R.string.unblockUser); unblock.setSummary(R.string.unblockUser_summary); unblock.setOnClickListener(v -> showUnblockDialog(context)); addPreference(unblock); } }
Example #4
Source File: BasePreferenceActivity.java From CommonUtils with Apache License 2.0 | 5 votes |
@Override protected void buildPreferences(@NonNull Context context) { for (Translators.Item item : Translators.load(context)) { MaterialStandardPreference pref = new MaterialStandardPreference(context); pref.setTitle(item.name); pref.setSummary(item.languages); pref.setOnClickListener(v -> openLink(context, item.link)); addPreference(pref); } }
Example #5
Source File: PreferenceActivity.java From Aria2App with GNU General Public License v3.0 | 4 votes |
@Override protected void buildPreferences(@NonNull Context context) { MaterialCheckboxPreference nightMode = new MaterialCheckboxPreference.Builder(context) .defaultValue(PK.NIGHT_MODE.fallback()) .key(PK.NIGHT_MODE.key()) .build(); nightMode.setTitle(R.string.prefs_nightMode); nightMode.setSummary(R.string.prefs_nightMode_summary); nightMode.setIcon(R.drawable.baseline_opacity_24); addPreference(nightMode); MaterialCheckboxPreference hideMetadata = new MaterialCheckboxPreference.Builder(context) .defaultValue(PK.A2_HIDE_METADATA.fallback()) .key(PK.A2_HIDE_METADATA.key()) .build(); hideMetadata.setTitle(R.string.prefs_hideMetadata); hideMetadata.setSummary(R.string.prefs_hideMetadata_summary); hideMetadata.setIcon(R.drawable.baseline_link_24); addPreference(hideMetadata); MaterialSeekBarPreference updateRate = new MaterialSeekBarPreference.Builder(context) .minValue(1).maxValue(10).showValue(true) .key(PK.A2_UPDATE_INTERVAL.key()) .defaultValue(PK.A2_UPDATE_INTERVAL.fallback()) .build(); updateRate.setTitle(R.string.prefs_updateRate); updateRate.setSummary(R.string.prefs_updateRate_summary); updateRate.setIcon(R.drawable.baseline_update_24); addPreference(updateRate); MaterialSeekBarPreference networkTimeout = new MaterialSeekBarPreference.Builder(context) .minValue(1).maxValue(60).showValue(true) .key(PK.A2_NETWORK_TIMEOUT.key()) .defaultValue(PK.A2_NETWORK_TIMEOUT.fallback()) .build(); networkTimeout.setTitle(R.string.prefs_networkTimeout); networkTimeout.setSummary(R.string.prefs_networkTimeout_summary); networkTimeout.setIcon(R.drawable.baseline_network_check_24); addPreference(networkTimeout); MaterialMultiChoicePreference customDownloadInfo = new MaterialMultiChoicePreference.Builder(context) .entryValues(CustomDownloadInfo.Info.stringValues()) .entries(CustomDownloadInfo.Info.formalValues(context)) .defaultValue(CustomDownloadInfo.Info.DOWNLOAD_SPEED.name(), CustomDownloadInfo.Info.REMAINING_TIME.name()) .showValueMode(AbsMaterialTextValuePreference.SHOW_ON_BOTTOM) .key(PK.A2_CUSTOM_INFO.key()) .build(); customDownloadInfo.setTitle(R.string.prefs_downloadDisplayInfo); customDownloadInfo.setSummary(R.string.prefs_downloadDisplayInfo_summary); customDownloadInfo.setIcon(R.drawable.baseline_info_outline_24); addPreference(customDownloadInfo); MaterialCheckboxPreference versionCheck = new MaterialCheckboxPreference.Builder(context) .key(PK.A2_CHECK_VERSION.key()) .defaultValue(PK.A2_CHECK_VERSION.fallback()) .build(); versionCheck.setTitle(R.string.prefs_versionCheck); versionCheck.setSummary(R.string.prefs_versionCheck_summary); versionCheck.setIcon(R.drawable.baseline_verified_user_24); addPreference(versionCheck); MaterialCheckboxPreference bestTrackers = new MaterialCheckboxPreference.Builder(context) .key(PK.A2_ADD_BEST_TRACKERS.key()) .defaultValue(PK.A2_ADD_BEST_TRACKERS.fallback()) .build(); bestTrackers.setTitle(R.string.prefs_addBestTrackers); bestTrackers.setSummary(R.string.prefs_addBestTrackers_summary); bestTrackers.setIcon(R.drawable.baseline_track_changes_24); addPreference(bestTrackers); MaterialCheckboxPreference skipWebViewDialog = new MaterialCheckboxPreference.Builder(context) .key(PK.A2_SKIP_WEBVIEW_DIALOG.key()) .defaultValue(PK.A2_SKIP_WEBVIEW_DIALOG.fallback()) .build(); skipWebViewDialog.setTitle(R.string.prefs_skipWebViewDialog); skipWebViewDialog.setSummary(R.string.prefs_skipWebViewDialog_summary); // skipWebViewDialog.setIcon(R.drawable.baseline_track_changes_24); addPreference(skipWebViewDialog); if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)) { MaterialStandardPreference webviewShortcut = new MaterialStandardPreference(context); webviewShortcut.setTitle(R.string.addWebViewShortcutToHomePage); webviewShortcut.setSummary(R.string.addWebViewShortcutToHomePage_summary); webviewShortcut.setIcon(R.drawable.baseline_language_24); addPreference(webviewShortcut); webviewShortcut.setOnClickListener(v -> { ShortcutInfoCompat shortcutInfo = new ShortcutInfoCompat.Builder(context, "#1") .setIntent(new Intent(context, LoadingActivity.class) .setAction(LoadingActivity.SHORTCUT_WEB_VIEW)) .setShortLabel(getString(R.string.webView) + " - " + getString(R.string.app_name)) .setIcon(IconCompat.createWithResource(context, R.drawable.baseline_language_colored_24)) .build(); ShortcutManagerCompat.requestPinShortcut(context, shortcutInfo, null); }); } }
Example #6
Source File: PreferenceActivity.java From Aria2App with GNU General Public License v3.0 | 4 votes |
@Override protected void buildPreferences(@NonNull Context context) { MaterialCheckboxPreference external = new MaterialCheckboxPreference.Builder(context) .key(PK.DD_USE_EXTERNAL.key()) .defaultValue(PK.DD_USE_EXTERNAL.fallback()) .build(); external.setTitle(R.string.prefs_ddUseExternal); external.setSummary(R.string.prefs_ddUseExternal_summary); external.setIcon(R.drawable.baseline_share_24); addPreference(external); MaterialStandardPreference downloadPath = new MaterialStandardPreference.Builder(context) .key(PK.DD_DOWNLOAD_PATH.key()) .defaultValue(PK.DD_DOWNLOAD_PATH.fallback()) .build(); downloadPath.setTitle(R.string.prefs_ddDownloadPath); downloadPath.setSummary(R.string.prefs_ddDownloadPath_summary); downloadPath.setIcon(R.drawable.baseline_folder_24); downloadPath.addPreferenceClickListener(v -> { try { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); startActivityForResult(intent, DOWNLOAD_PATH_CODE); } catch (ActivityNotFoundException ex) { showToast(Toaster.build().message(R.string.noFilemanager)); } }); addPreference(downloadPath); MaterialSeekBarPreference concurrentDownloads = new MaterialSeekBarPreference.Builder(context) .minValue(1).maxValue(10).showValue(true) .key(PK.DD_MAX_SIMULTANEOUS_DOWNLOADS.key()) .defaultValue(PK.DD_MAX_SIMULTANEOUS_DOWNLOADS.fallback()) .build(); concurrentDownloads.setTitle(R.string.prefs_ddMaxSimultaneousDownloads); concurrentDownloads.setSummary(R.string.prefs_ddMaxSimultaneousDownloads_summary); concurrentDownloads.setIcon(R.drawable.baseline_download_24); addPreference(concurrentDownloads); MaterialCheckboxPreference resume = new MaterialCheckboxPreference.Builder(context) .key(PK.DD_RESUME.key()) .defaultValue(PK.DD_RESUME.fallback()) .build(); resume.setTitle(R.string.prefs_ddResume); resume.setSummary(R.string.prefs_ddResume_summary); resume.setIcon(R.drawable.baseline_pause_24); addPreference(resume); addController(external, false, downloadPath, concurrentDownloads, resume); }