Add choice of 7 days to settings for dynamic playlists (#616)

* Add choice of N days to settings for dynamic playlists (#3)

* Code review
This commit is contained in:
soncaokim 2018-12-03 22:45:47 +01:00 committed by Eugene
commit f7cbfb38d9
4 changed files with 21 additions and 0 deletions

View file

@ -29,6 +29,18 @@ public class CalendarUtil {
}
/**
* Returns the time elapsed so far last N days in milliseconds.
*
* @return Time elapsed since N days in milliseconds.
*/
public long getElapsedDays(int numDays) {
long elapsed = getElapsedToday();
elapsed += numDays * MS_PER_DAY;
return elapsed;
}
/**
* Returns the time elapsed so far this week in milliseconds.
*
* @return Time elapsed this week in milliseconds.

View file

@ -290,6 +290,10 @@ public final class PreferenceUtil {
interval = calendarUtil.getElapsedWeek();
break;
case "past_seven_days":
interval = calendarUtil.getElapsedDays(7);
break;
case "past_three_months":
interval = calendarUtil.getElapsedMonths(3);
break;

View file

@ -106,6 +106,7 @@
<string name="never">Never</string>
<string name="today">Today</string>
<string name="this_week">This week</string>
<string name="past_seven_days">Past 7 days</string>
<string name="this_month">This month</string>
<string name="past_three_months">Past 3 months</string>
<string name="this_year">This year</string>

View file

@ -27,6 +27,7 @@
<string-array name="pref_playlists_recently_played_interval_titles">
<item>@string/today</item>
<item>@string/this_week</item>
<item>@string/past_seven_days</item>
<item>@string/this_month</item>
<item>@string/past_three_months</item>
<item>@string/this_year</item>
@ -35,6 +36,7 @@
<string-array name="pref_playlists_recently_played_interval_values">
<item>today</item>
<item>this_week</item>
<item>past_seven_days</item>
<item>this_month</item>
<item>past_three_months</item>
<item>this_year</item>
@ -43,6 +45,7 @@
<string-array name="pref_playlists_last_added_interval_titles">
<item>@string/today</item>
<item>@string/this_week</item>
<item>@string/past_seven_days</item>
<item>@string/this_month</item>
<item>@string/past_three_months</item>
<item>@string/this_year</item>
@ -51,6 +54,7 @@
<string-array name="pref_playlists_last_added_interval_values">
<item>today</item>
<item>this_week</item>
<item>past_seven_days</item>
<item>this_month</item>
<item>past_three_months</item>
<item>this_year</item>