mirror of
https://codeberg.org/timelimit/opentimelimit-android.git
synced 2025-10-03 17:59:46 +02:00
Add deleting old used time items
This commit is contained in:
parent
114b798eaa
commit
fe56e19075
4 changed files with 118 additions and 5 deletions
|
@ -118,6 +118,10 @@ class BackgroundTaskLogic(val appLogic: AppLogic) {
|
|||
private var usedTimeUpdateHelper: UsedTimeItemBatchUpdateHelper? = null
|
||||
private var previousMainLogicExecutionTime = 0
|
||||
private var previousMainLoopEndTime = 0L
|
||||
private val dayChangeTracker = DayChangeTracker(
|
||||
timeApi = appLogic.timeApi,
|
||||
longDuration = 1000 * 60 * 10 /* 10 minutes */
|
||||
)
|
||||
|
||||
private val appTitleCache = QueryAppTitleCache(appLogic.platformIntegration)
|
||||
|
||||
|
@ -149,6 +153,18 @@ class BackgroundTaskLogic(val appLogic: AppLogic) {
|
|||
try {
|
||||
// get the current time
|
||||
val nowTimestamp = appLogic.timeApi.getCurrentTimeInMillis()
|
||||
val nowTimezone = TimeZone.getTimeZone(deviceUserEntry.timeZone)
|
||||
|
||||
val nowDate = DateInTimezone.newInstance(nowTimestamp, nowTimezone)
|
||||
val minuteOfWeek = getMinuteOfWeek(nowTimestamp, nowTimezone)
|
||||
|
||||
// eventually remove old used time data
|
||||
if (dayChangeTracker.reportDayChange(nowDate.dayOfEpoch) == DayChangeTracker.DayChange.NowSinceLongerTime) {
|
||||
UsedTimeDeleter.deleteOldUsedTimeItems(
|
||||
database = appLogic.database,
|
||||
date = nowDate
|
||||
)
|
||||
}
|
||||
|
||||
// get the categories
|
||||
val categories = childCategories.get(deviceUserEntry.id).waitForNonNullValue()
|
||||
|
@ -206,11 +222,6 @@ class BackgroundTaskLogic(val appLogic: AppLogic) {
|
|||
))
|
||||
appLogic.platformIntegration.showAppLockScreen(foregroundAppPackageName)
|
||||
} else {
|
||||
val nowTimezone = TimeZone.getTimeZone(deviceUserEntry.timeZone)
|
||||
|
||||
val nowDate = DateInTimezone.newInstance(nowTimestamp, nowTimezone)
|
||||
val minuteOfWeek = getMinuteOfWeek(nowTimestamp, nowTimezone)
|
||||
|
||||
// disable time limits temporarily feature
|
||||
if (nowTimestamp < deviceUserEntry.disableLimitsUntil) {
|
||||
appLogic.platformIntegration.setAppStatusMessage(AppStatusMessage(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue