add biweekly repetition

This commit is contained in:
tibbi
2016-10-14 23:40:00 +02:00
parent 5d78020e05
commit b8a4cccbd5
11 changed files with 19 additions and 8 deletions

View File

@@ -9,6 +9,7 @@ public class Constants {
public static final int DAY = 86400; public static final int DAY = 86400;
public static final int WEEK = 604800; 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 MONTH = 2592000; // exact value not taken into account, Joda is used for adding months and years
public static final int YEAR = 31536000; public static final int YEAR = 31536000;

View File

@@ -30,7 +30,7 @@ public class Utils {
public static void scheduleNextEvent(Context context, Event event) { public static void scheduleNextEvent(Context context, Event event) {
int startTS = event.getStartTS() - event.getReminderMinutes() * 60; int startTS = event.getStartTS() - event.getReminderMinutes() * 60;
int newTS = startTS; 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) { while (startTS < System.currentTimeMillis() / 1000 + 5) {
startTS += event.getRepeatInterval(); startTS += event.getRepeatInterval();
} }

View File

@@ -169,9 +169,9 @@ class DBHelper(context: Context, callback: DBOperationsListener?) : SQLiteOpenHe
val dayEnd = ts + dayExclusive val dayEnd = ts + dayExclusive
val dateTime = Formatter.getDateTimeFromTS(ts) val dateTime = Formatter.getDateTimeFromTS(ts)
// get daily and weekly events // get daily, weekly and biweekly events
var selection = "($COL_REPEAT_INTERVAL = ${Constants.DAY} OR $COL_REPEAT_INTERVAL = ${Constants.WEEK}) AND " + var selection = "($COL_REPEAT_INTERVAL = ${Constants.DAY} OR $COL_REPEAT_INTERVAL = ${Constants.WEEK} OR " +
"($dayEnd - $COL_REPEAT_START) % $COL_REPEAT_INTERVAL BETWEEN 0 AND $dayExclusive" "$COL_REPEAT_INTERVAL = ${Constants.BIWEEK}) AND ($dayEnd - $COL_REPEAT_START) % $COL_REPEAT_INTERVAL BETWEEN 0 AND $dayExclusive"
newEvents.addAll(getEvents(selection, ts)) newEvents.addAll(getEvents(selection, ts))
// get monthly events // get monthly events
@@ -207,6 +207,7 @@ class DBHelper(context: Context, callback: DBOperationsListener?) : SQLiteOpenHe
newStart = when (e.repeatInterval) { newStart = when (e.repeatInterval) {
Constants.DAY -> currStart.plusDays(periods) Constants.DAY -> currStart.plusDays(periods)
Constants.WEEK -> currStart.plusWeeks(periods) Constants.WEEK -> currStart.plusWeeks(periods)
Constants.BIWEEK -> currStart.plusWeeks(periods * 2)
Constants.MONTH -> currStart.plusMonths(periods) Constants.MONTH -> currStart.plusMonths(periods)
else -> currStart.plusYears(periods) else -> currStart.plusYears(periods)
} }

View File

@@ -119,8 +119,9 @@ class EventActivity : SimpleActivity(), DBHelper.DBOperationsListener {
when (mEvent.repeatInterval) { when (mEvent.repeatInterval) {
Constants.DAY -> event_repetition.setSelection(1) Constants.DAY -> event_repetition.setSelection(1)
Constants.WEEK -> event_repetition.setSelection(2) Constants.WEEK -> event_repetition.setSelection(2)
Constants.MONTH -> event_repetition.setSelection(3) Constants.BIWEEK -> event_repetition.setSelection(3)
Constants.YEAR -> event_repetition.setSelection(4) Constants.MONTH -> event_repetition.setSelection(4)
Constants.YEAR -> event_repetition.setSelection(5)
else -> event_repetition.setSelection(0) else -> event_repetition.setSelection(0)
} }
} }
@@ -231,8 +232,9 @@ class EventActivity : SimpleActivity(), DBHelper.DBOperationsListener {
when (event_repetition.selectedItemPosition) { when (event_repetition.selectedItemPosition) {
1 -> return Constants.DAY 1 -> return Constants.DAY
2 -> return Constants.WEEK 2 -> return Constants.WEEK
3 -> return Constants.MONTH 3 -> return Constants.BIWEEK
4 -> return Constants.YEAR 4 -> return Constants.MONTH
5 -> return Constants.YEAR
else -> return 0 else -> return 0
} }
} }

View File

@@ -25,6 +25,7 @@
<string name="none">Keine</string> <string name="none">Keine</string>
<string name="daily">Täglich</string> <string name="daily">Täglich</string>
<string name="weekly">Wöchentlich</string> <string name="weekly">Wöchentlich</string>
<string name="biweekly">Biweekly</string>
<string name="monthly">Monatlich</string> <string name="monthly">Monatlich</string>
<string name="yearly">Jährlich</string> <string name="yearly">Jährlich</string>

View File

@@ -25,6 +25,7 @@
<string name="none">None</string> <string name="none">None</string>
<string name="daily">Daily</string> <string name="daily">Daily</string>
<string name="weekly">Weekly</string> <string name="weekly">Weekly</string>
<string name="biweekly">Biweekly</string>
<string name="monthly">Monthly</string> <string name="monthly">Monthly</string>
<string name="yearly">Yearly</string> <string name="yearly">Yearly</string>

View File

@@ -25,6 +25,7 @@
<string name="none">None</string> <string name="none">None</string>
<string name="daily">Daily</string> <string name="daily">Daily</string>
<string name="weekly">Weekly</string> <string name="weekly">Weekly</string>
<string name="biweekly">Biweekly</string>
<string name="monthly">Monthly</string> <string name="monthly">Monthly</string>
<string name="yearly">Yearly</string> <string name="yearly">Yearly</string>

View File

@@ -25,6 +25,7 @@
<string name="none">Nenhuma</string> <string name="none">Nenhuma</string>
<string name="daily">Diária</string> <string name="daily">Diária</string>
<string name="weekly">Semanal</string> <string name="weekly">Semanal</string>
<string name="biweekly">Biweekly</string>
<string name="monthly">Mensal</string> <string name="monthly">Mensal</string>
<string name="yearly">Anual</string> <string name="yearly">Anual</string>

View File

@@ -25,6 +25,7 @@
<string name="none">None</string> <string name="none">None</string>
<string name="daily">Daily</string> <string name="daily">Daily</string>
<string name="weekly">Weekly</string> <string name="weekly">Weekly</string>
<string name="biweekly">Biweekly</string>
<string name="monthly">Monthly</string> <string name="monthly">Monthly</string>
<string name="yearly">Yearly</string> <string name="yearly">Yearly</string>

View File

@@ -10,6 +10,7 @@
<item>@string/none</item> <item>@string/none</item>
<item>@string/daily</item> <item>@string/daily</item>
<item>@string/weekly</item> <item>@string/weekly</item>
<item>@string/biweekly</item>
<item>@string/monthly</item> <item>@string/monthly</item>
<item>@string/yearly</item> <item>@string/yearly</item>
</string-array> </string-array>

View File

@@ -25,6 +25,7 @@
<string name="none">None</string> <string name="none">None</string>
<string name="daily">Daily</string> <string name="daily">Daily</string>
<string name="weekly">Weekly</string> <string name="weekly">Weekly</string>
<string name="biweekly">Biweekly</string>
<string name="monthly">Monthly</string> <string name="monthly">Monthly</string>
<string name="yearly">Yearly</string> <string name="yearly">Yearly</string>