protected void save() { preferences.activateAccelerometer(true); preferences.activateCamera(true); preferences.activateMicrophone(true); setPhoneNumber(); boolean videoMonitoringActive = ((SwitchPreference) findPreference(mActivity.getResources().getString(R.string.video_active_preference_key))).isChecked(); preferences.setActivateVideoMonitoring(videoMonitoringActive); preferences.setSignalUsername(((EditTextPreference) findPreference(PreferenceManager.REGISTER_SIGNAL)).getText()); boolean remoteAccessActive = ((SwitchPreferenceCompat) findPreference(PreferenceManager.REMOTE_ACCESS_ACTIVE)).isChecked(); preferences.activateRemoteAccess(remoteAccessActive); String password = ((EditTextPreference) findPreference(PreferenceManager.REMOTE_ACCESS_CRED)).getText(); if (checkValidStrings(password, preferences.getRemoteAccessCredential()) && (TextUtils.isEmpty(preferences.getRemoteAccessCredential()) || !password.trim().equals(preferences.getRemoteAccessCredential().trim()))) { preferences.setRemoteAccessCredential(password.trim()); app.stopServer(); app.startServer(); } preferences.setVoiceVerification(false); boolean heartbeatMonitorActive = ((SwitchPreferenceCompat) findPreference(PreferenceManager.HEARTBEAT_MONITOR_ACTIVE)).isChecked(); preferences.activateHeartbeat(heartbeatMonitorActive); mActivity.setResult(AppCompatActivity.RESULT_OK); mActivity.finish(); }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private static int getActionBarHeightCompat(AppCompatActivity actionBarActivity) { TypedValue tv = new TypedValue(); Resources.Theme activityTheme = actionBarActivity.getTheme(); boolean resolved = false; if (activityTheme != null) { resolved = activityTheme.resolveAttribute( android.R.attr.actionBarSize, tv, true); } return resolved ? actionBarActivity.getResources() .getDimensionPixelSize(tv.resourceId) : 40; }
private void initTorrentSortingDialog(final AlertDialog dialog) { Spinner sp = dialog.findViewById(R.id.dialog_sort_by); RadioGroup group = dialog.findViewById(R.id.dialog_sort_direction); if (sp != null && group != null) { String[] columns = activity.getResources().getStringArray(R.array.sort_torrent_values); String column = pref.getString(getString(R.string.pref_key_sort_torrent_by), SettingsManager.Default.sortTorrentBy); String direction = pref.getString(getString(R.string.pref_key_sort_torrent_direction), SettingsManager.Default.sortTorrentDirection); ArrayAdapter<String> adapter = new ArrayAdapter<>(activity, R.layout.spinner_item_dropdown, getResources().getStringArray(R.array.sort_torrent_by)); sp.setAdapter(adapter); sp.setSelection(Arrays.asList(columns).indexOf(column)); if (TorrentSorting.Direction.fromValue(direction) == TorrentSorting.Direction.ASC) group.check(R.id.dialog_sort_by_ascending); else group.check(R.id.dialog_sort_by_descending); } }
Spinner sp = v.findViewById(R.id.dialog_sort_by); RadioGroup group = v.findViewById(R.id.dialog_sort_direction); String[] columns = activity.getResources().getStringArray(R.array.sort_torrent_values);
static void showLog(AppCompatActivity context) { WhatsNew log = WhatsNew.newInstance( new WhatsNewItem("Settings", "A lot of PDF rendering settings have been added.", R.drawable.thumbs_icon), new WhatsNewItem("F-Droid", "Pdf Viewer Plus is now on F-Droid!", R.drawable.star_icon), new WhatsNewItem("Menu", "Brand new menu that holds all the options.", R.drawable.thumbs_icon)); log.setTitleColor(ContextCompat.getColor(context, R.color.colorAccent)); log.setTitleText(context.getResources().getString(R.string.appChangelog)); log.setButtonText(context.getResources().getString(R.string.buttonLog)); log.setButtonBackground(ContextCompat.getColor(context, R.color.colorPrimary)); log.setButtonTextColor(ContextCompat.getColor(context, R.color.colorAccent)); log.setItemTitleColor(ContextCompat.getColor(context, R.color.colorAccent)); log.setItemContentColor(Color.parseColor("#808080")); log.show(context.getSupportFragmentManager(), "Log"); }