/** * Create a dialog containing (parts of the) change log. * * @param full If this is {@code true} the full change log is displayed. Otherwise only changes * for versions newer than the last version are displayed. * @return A dialog containing the (partial) change log. */ protected Dialog getDialog(boolean full) { WebView wv = new WebView(mContext); // wv.setBackgroundColor(0); // transparent wv.loadDataWithBaseURL(null, getLog(full), "text/html", "UTF-8", null); MaterialDialog.Builder builder = new MaterialDialog.Builder(mContext); builder .title( mContext .getResources() .getString(full ? R.string.changelog_full_title : R.string.changelog_title)) .customView(wv, false) .positiveText(mContext.getResources().getString(R.string.changelog_ok_button)) .onPositive( new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { updateVersionInPreferences(); } }) .onNegative( new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { getFullLogDialog().show(); } }); if (!full) { // Show "More…" button if we're only displaying a partial change log. builder.negativeText(R.string.changelog_show_full); } return builder.build(); }
private void showUpdateIntervalTimePreferencesDialog() { final Context context = ui.getActivity(); MaterialDialog.Builder builder = new MaterialDialog.Builder(context); builder.title(R.string.pref_autoUpdateIntervallOrTime_title); builder.content(R.string.pref_autoUpdateIntervallOrTime_message); builder.positiveText(R.string.pref_autoUpdateIntervallOrTime_Interval); builder.negativeText(R.string.pref_autoUpdateIntervallOrTime_TimeOfDay); builder.neutralText(R.string.pref_autoUpdateIntervallOrTime_Disable); builder.onPositive( (dialog, which) -> { AlertDialog.Builder builder1 = new AlertDialog.Builder(context); builder1.setTitle(context.getString(R.string.pref_autoUpdateIntervallOrTime_Interval)); final String[] values = context.getResources().getStringArray(R.array.update_intervall_values); final String[] entries = getUpdateIntervalEntries(values); long currInterval = UserPreferences.getUpdateInterval(); int checkedItem = -1; if (currInterval > 0) { String currIntervalStr = String.valueOf(TimeUnit.MILLISECONDS.toHours(currInterval)); checkedItem = ArrayUtils.indexOf(values, currIntervalStr); } builder1.setSingleChoiceItems( entries, checkedItem, (dialog1, which1) -> { int hours = Integer.parseInt(values[which1]); UserPreferences.setUpdateInterval(hours); dialog1.dismiss(); setUpdateIntervalText(); }); builder1.setNegativeButton(context.getString(R.string.cancel_label), null); builder1.show(); }); builder.onNegative( (dialog, which) -> { int hourOfDay = 7, minute = 0; int[] updateTime = UserPreferences.getUpdateTimeOfDay(); if (updateTime.length == 2) { hourOfDay = updateTime[0]; minute = updateTime[1]; } TimePickerDialog timePickerDialog = new TimePickerDialog( context, (view, selectedHourOfDay, selectedMinute) -> { if (view.getTag() == null) { // onTimeSet() may get called twice! view.setTag("TAGGED"); UserPreferences.setUpdateTimeOfDay(selectedHourOfDay, selectedMinute); setUpdateIntervalText(); } }, hourOfDay, minute, DateFormat.is24HourFormat(context)); timePickerDialog.setTitle( context.getString(R.string.pref_autoUpdateIntervallOrTime_TimeOfDay)); timePickerDialog.show(); }); builder.onNeutral( (dialog, which) -> { UserPreferences.setUpdateInterval(0); setUpdateIntervalText(); }); builder.show(); }