add biweekly repetition
This commit is contained in:
parent
5d78020e05
commit
b8a4cccbd5
11 changed files with 19 additions and 8 deletions
|
@ -9,6 +9,7 @@ public class Constants {
|
|||
|
||||
public static final int DAY = 86400;
|
||||
public static final int WEEK = 604800;
|
||||
public static final int BIWEEK = 1209600;
|
||||
public static final int MONTH = 2592000; // exact value not taken into account, Joda is used for adding months and years
|
||||
public static final int YEAR = 31536000;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public class Utils {
|
|||
public static void scheduleNextEvent(Context context, Event event) {
|
||||
int startTS = event.getStartTS() - event.getReminderMinutes() * 60;
|
||||
int newTS = startTS;
|
||||
if (event.getRepeatInterval() == Constants.DAY || event.getRepeatInterval() == Constants.WEEK) {
|
||||
if (event.getRepeatInterval() == Constants.DAY || event.getRepeatInterval() == Constants.WEEK || event.getRepeatInterval() == Constants.BIWEEK) {
|
||||
while (startTS < System.currentTimeMillis() / 1000 + 5) {
|
||||
startTS += event.getRepeatInterval();
|
||||
}
|
||||
|
|
|
@ -169,9 +169,9 @@ class DBHelper(context: Context, callback: DBOperationsListener?) : SQLiteOpenHe
|
|||
val dayEnd = ts + dayExclusive
|
||||
val dateTime = Formatter.getDateTimeFromTS(ts)
|
||||
|
||||
// get daily and weekly events
|
||||
var selection = "($COL_REPEAT_INTERVAL = ${Constants.DAY} OR $COL_REPEAT_INTERVAL = ${Constants.WEEK}) AND " +
|
||||
"($dayEnd - $COL_REPEAT_START) % $COL_REPEAT_INTERVAL BETWEEN 0 AND $dayExclusive"
|
||||
// get daily, weekly and biweekly events
|
||||
var selection = "($COL_REPEAT_INTERVAL = ${Constants.DAY} OR $COL_REPEAT_INTERVAL = ${Constants.WEEK} OR " +
|
||||
"$COL_REPEAT_INTERVAL = ${Constants.BIWEEK}) AND ($dayEnd - $COL_REPEAT_START) % $COL_REPEAT_INTERVAL BETWEEN 0 AND $dayExclusive"
|
||||
newEvents.addAll(getEvents(selection, ts))
|
||||
|
||||
// get monthly events
|
||||
|
@ -207,6 +207,7 @@ class DBHelper(context: Context, callback: DBOperationsListener?) : SQLiteOpenHe
|
|||
newStart = when (e.repeatInterval) {
|
||||
Constants.DAY -> currStart.plusDays(periods)
|
||||
Constants.WEEK -> currStart.plusWeeks(periods)
|
||||
Constants.BIWEEK -> currStart.plusWeeks(periods * 2)
|
||||
Constants.MONTH -> currStart.plusMonths(periods)
|
||||
else -> currStart.plusYears(periods)
|
||||
}
|
||||
|
|
|
@ -119,8 +119,9 @@ class EventActivity : SimpleActivity(), DBHelper.DBOperationsListener {
|
|||
when (mEvent.repeatInterval) {
|
||||
Constants.DAY -> event_repetition.setSelection(1)
|
||||
Constants.WEEK -> event_repetition.setSelection(2)
|
||||
Constants.MONTH -> event_repetition.setSelection(3)
|
||||
Constants.YEAR -> event_repetition.setSelection(4)
|
||||
Constants.BIWEEK -> event_repetition.setSelection(3)
|
||||
Constants.MONTH -> event_repetition.setSelection(4)
|
||||
Constants.YEAR -> event_repetition.setSelection(5)
|
||||
else -> event_repetition.setSelection(0)
|
||||
}
|
||||
}
|
||||
|
@ -231,8 +232,9 @@ class EventActivity : SimpleActivity(), DBHelper.DBOperationsListener {
|
|||
when (event_repetition.selectedItemPosition) {
|
||||
1 -> return Constants.DAY
|
||||
2 -> return Constants.WEEK
|
||||
3 -> return Constants.MONTH
|
||||
4 -> return Constants.YEAR
|
||||
3 -> return Constants.BIWEEK
|
||||
4 -> return Constants.MONTH
|
||||
5 -> return Constants.YEAR
|
||||
else -> return 0
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
<string name="none">Keine</string>
|
||||
<string name="daily">Täglich</string>
|
||||
<string name="weekly">Wöchentlich</string>
|
||||
<string name="biweekly">Biweekly</string>
|
||||
<string name="monthly">Monatlich</string>
|
||||
<string name="yearly">Jährlich</string>
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
<string name="none">None</string>
|
||||
<string name="daily">Daily</string>
|
||||
<string name="weekly">Weekly</string>
|
||||
<string name="biweekly">Biweekly</string>
|
||||
<string name="monthly">Monthly</string>
|
||||
<string name="yearly">Yearly</string>
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
<string name="none">None</string>
|
||||
<string name="daily">Daily</string>
|
||||
<string name="weekly">Weekly</string>
|
||||
<string name="biweekly">Biweekly</string>
|
||||
<string name="monthly">Monthly</string>
|
||||
<string name="yearly">Yearly</string>
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
<string name="none">Nenhuma</string>
|
||||
<string name="daily">Diária</string>
|
||||
<string name="weekly">Semanal</string>
|
||||
<string name="biweekly">Biweekly</string>
|
||||
<string name="monthly">Mensal</string>
|
||||
<string name="yearly">Anual</string>
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
<string name="none">None</string>
|
||||
<string name="daily">Daily</string>
|
||||
<string name="weekly">Weekly</string>
|
||||
<string name="biweekly">Biweekly</string>
|
||||
<string name="monthly">Monthly</string>
|
||||
<string name="yearly">Yearly</string>
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<item>@string/none</item>
|
||||
<item>@string/daily</item>
|
||||
<item>@string/weekly</item>
|
||||
<item>@string/biweekly</item>
|
||||
<item>@string/monthly</item>
|
||||
<item>@string/yearly</item>
|
||||
</string-array>
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
<string name="none">None</string>
|
||||
<string name="daily">Daily</string>
|
||||
<string name="weekly">Weekly</string>
|
||||
<string name="biweekly">Biweekly</string>
|
||||
<string name="monthly">Monthly</string>
|
||||
<string name="yearly">Yearly</string>
|
||||
|
||||
|
|
Loading…
Reference in a new issue