Skip to content

Commit ecac42e

Browse files
committed
Added autoBackup constants
1 parent 938c050 commit ecac42e

File tree

1 file changed

+21
-0
lines changed
  • app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers

1 file changed

+21
-0
lines changed

app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/Constants.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.simplemobiletools.notes.pro.helpers
22

33
import android.graphics.Color
4+
import org.joda.time.DateTime
45

56
const val NOTE_ID = "note_id"
67
const val OPEN_NOTE_ID = "open_note_id"
@@ -39,6 +40,26 @@ const val FONT_SIZE_PERCENTAGE = "font_size_percentage"
3940
const val EXPORT_MIME_TYPE = "text/plain"
4041
const val ADD_NEW_CHECKLIST_ITEMS_TOP = "add_new_checklist_items_top"
4142

43+
// auto backups
44+
const val AUTOMATIC_BACKUP_REQUEST_CODE = 10001
45+
const val AUTO_BACKUP_INTERVAL_IN_DAYS = 1
46+
47+
// 6 am is the hardcoded automatic backup time, intervals shorter than 1 day are not yet supported.
48+
fun getNextAutoBackupTime(): DateTime {
49+
val now = DateTime.now()
50+
val sixHour = now.withHourOfDay(6)
51+
return if (now.millis < sixHour.millis) {
52+
sixHour
53+
} else {
54+
sixHour.plusDays(AUTO_BACKUP_INTERVAL_IN_DAYS)
55+
}
56+
}
57+
58+
fun getPreviousAutoBackupTime(): DateTime {
59+
val nextBackupTime = getNextAutoBackupTime()
60+
return nextBackupTime.minusDays(AUTO_BACKUP_INTERVAL_IN_DAYS)
61+
}
62+
4263
// gravity
4364
const val GRAVITY_START = 0
4465
const val GRAVITY_CENTER = 1

0 commit comments

Comments
 (0)