diff options
author | Martin Fietz <Martin.Fietz@gmail.com> | 2015-09-09 19:55:23 +0200 |
---|---|---|
committer | Martin Fietz <Martin.Fietz@gmail.com> | 2015-09-09 19:55:23 +0200 |
commit | e323f067f3a0852a042d081e4abc8f523c2c01ea (patch) | |
tree | 20dd82533a80dd217a12d230aa524a6c86f4f284 | |
parent | 98a0b46bed65b6489923be7364bb9894901ae6fc (diff) | |
download | AntennaPod-e323f067f3a0852a042d081e4abc8f523c2c01ea.zip |
Fix cropped buttons of update interval/time of day dialog
-rw-r--r-- | app/build.gradle | 2 | ||||
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java | 100 |
2 files changed, 49 insertions, 53 deletions
diff --git a/app/build.gradle b/app/build.gradle index 90d0c108e..f28bb4375 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,6 +25,8 @@ dependencies { compile 'de.greenrobot:eventbus:2.4.0' compile 'io.reactivex:rxandroid:1.0.1' compile 'com.joanzapata.iconify:android-iconify-fontawesome:2.0.3' + compile 'com.afollestad:material-dialogs:0.7.8.0' + compile project(':core') compile project(':library:drag-sort-listview') diff --git a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java index 4d4b2be63..3c9bf464c 100644 --- a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java +++ b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java @@ -20,9 +20,10 @@ import android.text.TextWatcher; import android.text.format.DateFormat; import android.util.Log; import android.widget.EditText; -import android.widget.TimePicker; import android.widget.Toast; +import com.afollestad.materialdialogs.MaterialDialog; + import java.io.File; import java.util.ArrayList; import java.util.Arrays; @@ -586,17 +587,15 @@ public class PreferenceController { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.drawer_preferences); - builder.setMultiChoiceItems(navTitles, checked, new DialogInterface.OnMultiChoiceClickListener() { - @Override - public void onClick(DialogInterface dialog, int which, boolean isChecked) { - if (isChecked) { - hiddenDrawerItems.remove(NAV_DRAWER_TAGS[which]); - } else { - hiddenDrawerItems.add(NAV_DRAWER_TAGS[which]); - } + builder.setMultiChoiceItems(navTitles, checked, (dialog, which, isChecked) -> { + if (isChecked) { + hiddenDrawerItems.remove(NAV_DRAWER_TAGS[which]); + } else { + hiddenDrawerItems.add(NAV_DRAWER_TAGS[which]); } }); - builder.setPositiveButton(R.string.confirm_label, new DialogInterface.OnClickListener() { + builder.setPositiveButton(R.string.confirm_label, new DialogInterface + .OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { UserPreferences.setHiddenDrawerItems(context, hiddenDrawerItems); @@ -609,69 +608,64 @@ public class PreferenceController { private void showUpdateIntervalTimePreferencesDialog() { final Context context = ui.getActivity(); - AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder.setTitle(R.string.pref_autoUpdateIntervallOrTime_title); - builder.setMessage(R.string.pref_autoUpdateIntervallOrTime_message); - builder.setNegativeButton(R.string.pref_autoUpdateIntervallOrTime_Disable, new DialogInterface.OnClickListener() { + 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.callback(new MaterialDialog.ButtonCallback() { @Override - public void onClick(DialogInterface dialog, int which) { - UserPreferences.setUpdateInterval(0); - } - }); - builder.setNeutralButton(R.string.pref_autoUpdateIntervallOrTime_Interval, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { + public void onPositive(MaterialDialog dialog) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(context.getString(R.string.pref_autoUpdateIntervallOrTime_Interval)); final String[] values = context.getResources().getStringArray(R.array.update_intervall_values); final String[] entries = getUpdateIntervalEntries(values); - builder.setSingleChoiceItems(entries, -1, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - int hours = Integer.valueOf(values[which]); - UserPreferences.setUpdateInterval(hours); - dialog.dismiss(); - } + builder.setSingleChoiceItems(entries, -1, (dialog1, which) -> { + int hours = Integer.valueOf(values[which]); + UserPreferences.setUpdateInterval(hours); + dialog1.dismiss(); }); builder.setNegativeButton(context.getString(R.string.cancel_label), null); builder.show(); } - }); - builder.setPositiveButton(R.string.pref_autoUpdateIntervallOrTime_TimeOfDay, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int 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, new TimePickerDialog.OnTimeSetListener() { - @Override - public void onTimeSet(TimePicker view, int hourOfDay, int minute) { - if (view.getTag() == null) { // onTimeSet() may get called twice! - view.setTag("TAGGED"); - UserPreferences.setUpdateTimeOfDay(hourOfDay, minute); - } + + @Override + public void onNegative(MaterialDialog dialog) { + 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); } }, hourOfDay, minute, DateFormat.is24HourFormat(context)); - timePickerDialog.setTitle(context.getString(R.string.pref_autoUpdateIntervallOrTime_TimeOfDay)); - timePickerDialog.show(); - } - } + timePickerDialog.setTitle(context.getString(R.string.pref_autoUpdateIntervallOrTime_TimeOfDay)); + timePickerDialog.show(); + } - ); + @Override + public void onNeutral(MaterialDialog dialog) { + UserPreferences.setUpdateInterval(0); + } + }); + builder.forceStacking(true); builder.show(); } - public static interface PreferenceUI { + public interface PreferenceUI { /** * Finds a preference based on its key. */ - public Preference findPreference(CharSequence key); + Preference findPreference(CharSequence key); - public Activity getActivity(); + Activity getActivity(); } } |