Give feedback about current update setting
This commit is contained in:
parent
4e7d34e55d
commit
308a26b14b
|
@ -30,10 +30,15 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import de.danoeh.antennapod.CrashReportWriter;
|
import de.danoeh.antennapod.CrashReportWriter;
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
|
@ -411,6 +416,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
|
||||||
|
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
checkItemVisibility();
|
checkItemVisibility();
|
||||||
|
setUpdateIntervalText();
|
||||||
setParallelDownloadsText(UserPreferences.getParallelDownloads());
|
setParallelDownloadsText(UserPreferences.getParallelDownloads());
|
||||||
setEpisodeCacheSizeText(UserPreferences.getEpisodeCacheSize());
|
setEpisodeCacheSizeText(UserPreferences.getEpisodeCacheSize());
|
||||||
setDataFolderText();
|
setDataFolderText();
|
||||||
|
@ -553,6 +559,32 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setUpdateIntervalText() {
|
||||||
|
Context context = ui.getActivity().getApplicationContext();
|
||||||
|
String val;
|
||||||
|
long interval = UserPreferences.getUpdateInterval();
|
||||||
|
if(interval > 0) {
|
||||||
|
int hours = (int) TimeUnit.MILLISECONDS.toHours(interval);
|
||||||
|
String hoursStr = context.getResources().getQuantityString(R.plurals.time_hours_quantified, hours, hours);
|
||||||
|
val = String.format(context.getString(R.string.pref_autoUpdateIntervallOrTime_every), hoursStr);
|
||||||
|
} else {
|
||||||
|
int[] timeOfDay = UserPreferences.getUpdateTimeOfDay();
|
||||||
|
if(timeOfDay.length == 2) {
|
||||||
|
Calendar cal = new GregorianCalendar();
|
||||||
|
cal.set(Calendar.HOUR_OF_DAY, timeOfDay[0]);
|
||||||
|
cal.set(Calendar.MINUTE, timeOfDay[1]);
|
||||||
|
String timeOfDayStr = DateFormat.getTimeFormat(context).format(cal.getTime());
|
||||||
|
val = String.format(context.getString(R.string.pref_autoUpdateIntervallOrTime_at),
|
||||||
|
timeOfDayStr);
|
||||||
|
} else {
|
||||||
|
val = context.getString(R.string.pref_smart_mark_as_played_disabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String summary = context.getString(R.string.pref_autoUpdateIntervallOrTime_sum) + "\n"
|
||||||
|
+ String.format(context.getString(R.string.pref_current_value), val);
|
||||||
|
ui.findPreference(UserPreferences.PREF_UPDATE_INTERVAL).setSummary(summary);
|
||||||
|
}
|
||||||
|
|
||||||
private void setParallelDownloadsText(int downloads) {
|
private void setParallelDownloadsText(int downloads) {
|
||||||
final Resources res = ui.getActivity().getResources();
|
final Resources res = ui.getActivity().getResources();
|
||||||
|
|
||||||
|
@ -772,10 +804,17 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
|
||||||
builder.setTitle(context.getString(R.string.pref_autoUpdateIntervallOrTime_Interval));
|
builder.setTitle(context.getString(R.string.pref_autoUpdateIntervallOrTime_Interval));
|
||||||
final String[] values = context.getResources().getStringArray(R.array.update_intervall_values);
|
final String[] values = context.getResources().getStringArray(R.array.update_intervall_values);
|
||||||
final String[] entries = getUpdateIntervalEntries(values);
|
final String[] entries = getUpdateIntervalEntries(values);
|
||||||
builder.setSingleChoiceItems(entries, -1, (dialog1, which) -> {
|
long currInterval = UserPreferences.getUpdateInterval();
|
||||||
|
int checkedItem = -1;
|
||||||
|
if(currInterval > 0) {
|
||||||
|
String currIntervalStr = String.valueOf(TimeUnit.MILLISECONDS.toHours(currInterval));
|
||||||
|
checkedItem = ArrayUtils.indexOf(values, currIntervalStr);
|
||||||
|
}
|
||||||
|
builder.setSingleChoiceItems(entries, checkedItem, (dialog1, which) -> {
|
||||||
int hours = Integer.valueOf(values[which]);
|
int hours = Integer.valueOf(values[which]);
|
||||||
UserPreferences.setUpdateInterval(hours);
|
UserPreferences.setUpdateInterval(hours);
|
||||||
dialog1.dismiss();
|
dialog1.dismiss();
|
||||||
|
setUpdateIntervalText();
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(context.getString(R.string.cancel_label), null);
|
builder.setNegativeButton(context.getString(R.string.cancel_label), null);
|
||||||
builder.show();
|
builder.show();
|
||||||
|
@ -794,6 +833,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
|
||||||
if (view.getTag() == null) { // onTimeSet() may get called twice!
|
if (view.getTag() == null) { // onTimeSet() may get called twice!
|
||||||
view.setTag("TAGGED");
|
view.setTag("TAGGED");
|
||||||
UserPreferences.setUpdateTimeOfDay(selectedHourOfDay, selectedMinute);
|
UserPreferences.setUpdateTimeOfDay(selectedHourOfDay, selectedMinute);
|
||||||
|
setUpdateIntervalText();
|
||||||
}
|
}
|
||||||
}, hourOfDay, minute, DateFormat.is24HourFormat(context));
|
}, hourOfDay, minute, DateFormat.is24HourFormat(context));
|
||||||
timePickerDialog.setTitle(context.getString(R.string.pref_autoUpdateIntervallOrTime_TimeOfDay));
|
timePickerDialog.setTitle(context.getString(R.string.pref_autoUpdateIntervallOrTime_TimeOfDay));
|
||||||
|
@ -803,6 +843,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
|
||||||
@Override
|
@Override
|
||||||
public void onNeutral(MaterialDialog dialog) {
|
public void onNeutral(MaterialDialog dialog) {
|
||||||
UserPreferences.setUpdateInterval(0);
|
UserPreferences.setUpdateInterval(0);
|
||||||
|
setUpdateIntervalText();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.forceStacking(true);
|
builder.forceStacking(true);
|
||||||
|
|
|
@ -297,6 +297,8 @@
|
||||||
<string name="pref_autoUpdateIntervallOrTime_Disable">Disable</string>
|
<string name="pref_autoUpdateIntervallOrTime_Disable">Disable</string>
|
||||||
<string name="pref_autoUpdateIntervallOrTime_Interval">Set Interval</string>
|
<string name="pref_autoUpdateIntervallOrTime_Interval">Set Interval</string>
|
||||||
<string name="pref_autoUpdateIntervallOrTime_TimeOfDay">Set Time of Day</string>
|
<string name="pref_autoUpdateIntervallOrTime_TimeOfDay">Set Time of Day</string>
|
||||||
|
<string name="pref_autoUpdateIntervallOrTime_every">every %1$s</string>
|
||||||
|
<string name="pref_autoUpdateIntervallOrTime_at">at %1$s</string>
|
||||||
<string name="pref_downloadMediaOnWifiOnly_sum">Download media files only over WiFi</string>
|
<string name="pref_downloadMediaOnWifiOnly_sum">Download media files only over WiFi</string>
|
||||||
<string name="pref_followQueue_title">Continuous Playback</string>
|
<string name="pref_followQueue_title">Continuous Playback</string>
|
||||||
<string name="pref_downloadMediaOnWifiOnly_title">WiFi media download</string>
|
<string name="pref_downloadMediaOnWifiOnly_title">WiFi media download</string>
|
||||||
|
@ -372,6 +374,7 @@
|
||||||
<string name="experimental_pref">Experimental</string>
|
<string name="experimental_pref">Experimental</string>
|
||||||
<string name="pref_sonic_title">Sonic media player</string>
|
<string name="pref_sonic_title">Sonic media player</string>
|
||||||
<string name="pref_sonic_message">Use built-in sonic media player as a replacement for Prestissimo</string>
|
<string name="pref_sonic_message">Use built-in sonic media player as a replacement for Prestissimo</string>
|
||||||
|
<string name="pref_current_value">Current value: %1$s</string>
|
||||||
|
|
||||||
<!-- Auto-Flattr dialog -->
|
<!-- Auto-Flattr dialog -->
|
||||||
<string name="auto_flattr_enable">Enable automatic flattring</string>
|
<string name="auto_flattr_enable">Enable automatic flattring</string>
|
||||||
|
|
Loading…
Reference in New Issue