mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
add biweekly repetition
This commit is contained in:
@@ -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;
|
||||||
|
|
||||||
|
@@ -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();
|
||||||
}
|
}
|
||||||
|
@@ -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)
|
||||||
}
|
}
|
||||||
|
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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>
|
||||||
|
|
||||||
|
@@ -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>
|
||||||
|
|
||||||
|
@@ -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>
|
||||||
|
|
||||||
|
@@ -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>
|
||||||
|
|
||||||
|
@@ -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>
|
||||||
|
|
||||||
|
@@ -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>
|
||||||
|
@@ -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>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user