diff --git a/core/src/main/java/com/example/util/simpletimetracker/core/interactor/GetCurrentRecordsDurationInteractor.kt b/core/src/main/java/com/example/util/simpletimetracker/core/interactor/GetCurrentRecordsDurationInteractor.kt index 6c9513e0..0a09147d 100644 --- a/core/src/main/java/com/example/util/simpletimetracker/core/interactor/GetCurrentRecordsDurationInteractor.kt +++ b/core/src/main/java/com/example/util/simpletimetracker/core/interactor/GetCurrentRecordsDurationInteractor.kt @@ -25,6 +25,10 @@ class GetCurrentRecordsDurationInteractor @Inject constructor( return getRangeCurrent(runningRecord, getRange(RangeLength.Week)) } + suspend fun getMonthlyCurrent(runningRecord: RunningRecord): Long { + return getRangeCurrent(runningRecord, getRange(RangeLength.Month)) + } + suspend fun getRangeCurrent( runningRecord: RunningRecord, range: Range diff --git a/core/src/main/java/com/example/util/simpletimetracker/core/mapper/GoalTimeMapper.kt b/core/src/main/java/com/example/util/simpletimetracker/core/mapper/GoalTimeMapper.kt index 70b6f1c7..ccd4cbc6 100644 --- a/core/src/main/java/com/example/util/simpletimetracker/core/mapper/GoalTimeMapper.kt +++ b/core/src/main/java/com/example/util/simpletimetracker/core/mapper/GoalTimeMapper.kt @@ -25,6 +25,7 @@ class GoalTimeMapper @Inject constructor( is GoalTimeType.Session -> R.string.change_record_type_session_goal_time is GoalTimeType.Day -> R.string.change_record_type_daily_goal_time is GoalTimeType.Week -> R.string.change_record_type_weekly_goal_time + is GoalTimeType.Month -> R.string.change_record_type_monthly_goal_time }.let(resourceRepo::getString).lowercase() val durationLeft = goalTime * 1000 - current diff --git a/core/src/main/java/com/example/util/simpletimetracker/core/utils/TestUtils.kt b/core/src/main/java/com/example/util/simpletimetracker/core/utils/TestUtils.kt index bcb8cfdd..913c7d09 100644 --- a/core/src/main/java/com/example/util/simpletimetracker/core/utils/TestUtils.kt +++ b/core/src/main/java/com/example/util/simpletimetracker/core/utils/TestUtils.kt @@ -68,6 +68,7 @@ class TestUtils @Inject constructor( goalTime: Long? = null, dailyGoalTime: Long? = null, weeklyGoalTime: Long? = null, + monthlyGoalTime: Long? = null, archived: Boolean = false, categories: List = emptyList(), ) = runBlocking { @@ -91,6 +92,7 @@ class TestUtils @Inject constructor( goalTime = goalTime.orZero(), dailyGoalTime = dailyGoalTime.orZero(), weeklyGoalTime = weeklyGoalTime.orZero(), + monthlyGoalTime = monthlyGoalTime.orZero(), ) val typeId = recordTypeInteractor.add(data) diff --git a/core/src/main/res/values-de/strings.xml b/core/src/main/res/values-de/strings.xml index de77bf60..787387f2 100644 --- a/core/src/main/res/values-de/strings.xml +++ b/core/src/main/res/values-de/strings.xml @@ -124,6 +124,7 @@ Session @string/range_day @string/range_week + @string/range_month Filter entfernt diff --git a/core/src/main/res/values-es/strings.xml b/core/src/main/res/values-es/strings.xml index cb39a9ae..66a6de09 100644 --- a/core/src/main/res/values-es/strings.xml +++ b/core/src/main/res/values-es/strings.xml @@ -124,6 +124,7 @@ Sesión @string/range_day @string/range_week + @string/range_month Filtro eliminado diff --git a/core/src/main/res/values-fr/strings.xml b/core/src/main/res/values-fr/strings.xml index 21566bef..7540d1b7 100644 --- a/core/src/main/res/values-fr/strings.xml +++ b/core/src/main/res/values-fr/strings.xml @@ -124,6 +124,7 @@ Session @string/range_day @string/range_week + @string/range_month Filtre supprimé diff --git a/core/src/main/res/values-hi/strings.xml b/core/src/main/res/values-hi/strings.xml index f5f3fdcd..d5ff74cb 100644 --- a/core/src/main/res/values-hi/strings.xml +++ b/core/src/main/res/values-hi/strings.xml @@ -124,6 +124,7 @@ सत्र @string/range_day @string/range_week + @string/range_month फ़िल्टर हटा दिया गया diff --git a/core/src/main/res/values-in/strings.xml b/core/src/main/res/values-in/strings.xml index 16e4c739..959f7110 100644 --- a/core/src/main/res/values-in/strings.xml +++ b/core/src/main/res/values-in/strings.xml @@ -124,6 +124,7 @@ Sidang @string/range_day @string/range_week + @string/range_month Filter dihapus diff --git a/core/src/main/res/values-it/strings.xml b/core/src/main/res/values-it/strings.xml index 26f21015..4d389af1 100644 --- a/core/src/main/res/values-it/strings.xml +++ b/core/src/main/res/values-it/strings.xml @@ -124,6 +124,7 @@ Sessione @string/range_day @string/range_week + @string/range_month Filtro rimosso diff --git a/core/src/main/res/values-ja/strings.xml b/core/src/main/res/values-ja/strings.xml index b2260550..99a873cd 100644 --- a/core/src/main/res/values-ja/strings.xml +++ b/core/src/main/res/values-ja/strings.xml @@ -124,6 +124,7 @@ セッション @string/range_day @string/range_week + @string/range_month フィルターを取り外しました diff --git a/core/src/main/res/values-nl/strings.xml b/core/src/main/res/values-nl/strings.xml index 45e7774d..474f4eb8 100644 --- a/core/src/main/res/values-nl/strings.xml +++ b/core/src/main/res/values-nl/strings.xml @@ -124,6 +124,7 @@ Sessie @string/range_day @string/range_week + @string/range_month Filter verwijderd diff --git a/core/src/main/res/values-pt/strings.xml b/core/src/main/res/values-pt/strings.xml index f3eecf47..a8406d14 100644 --- a/core/src/main/res/values-pt/strings.xml +++ b/core/src/main/res/values-pt/strings.xml @@ -124,6 +124,7 @@ Sessão @string/range_day @string/range_week + @string/range_month Filtro removido diff --git a/core/src/main/res/values-ru/strings.xml b/core/src/main/res/values-ru/strings.xml index 3ec3e98a..6bd630e6 100644 --- a/core/src/main/res/values-ru/strings.xml +++ b/core/src/main/res/values-ru/strings.xml @@ -124,6 +124,7 @@ Сессия @string/range_day @string/range_week + @string/range_month Фильтр удален diff --git a/core/src/main/res/values-sv/strings.xml b/core/src/main/res/values-sv/strings.xml index ccfe1750..97e15de2 100644 --- a/core/src/main/res/values-sv/strings.xml +++ b/core/src/main/res/values-sv/strings.xml @@ -124,6 +124,7 @@ Session @string/range_day @string/range_week + @string/range_month Filter borttaget diff --git a/core/src/main/res/values-tr/strings.xml b/core/src/main/res/values-tr/strings.xml index 81e94f9f..73f48ff3 100644 --- a/core/src/main/res/values-tr/strings.xml +++ b/core/src/main/res/values-tr/strings.xml @@ -124,6 +124,7 @@ Dönem @string/range_day @string/range_week + @string/range_month Filtre kaldırıldı diff --git a/core/src/main/res/values-uk/strings.xml b/core/src/main/res/values-uk/strings.xml index 10bc4fd7..60f92078 100644 --- a/core/src/main/res/values-uk/strings.xml +++ b/core/src/main/res/values-uk/strings.xml @@ -124,6 +124,7 @@ Сесія @string/range_day @string/range_week + @string/range_month Фільтр видалений diff --git a/core/src/main/res/values-zh/strings.xml b/core/src/main/res/values-zh/strings.xml index 1b5e00a5..8d75991f 100644 --- a/core/src/main/res/values-zh/strings.xml +++ b/core/src/main/res/values-zh/strings.xml @@ -124,6 +124,7 @@ 会议 @string/range_day @string/range_week + @string/range_month 过滤器已移除 diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 9bc869a3..dff71059 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -124,6 +124,7 @@ Session @string/range_day @string/range_week + @string/range_month Filter removed diff --git a/data_local/schemas/com.example.util.simpletimetracker.data_local.database.AppDatabase/11.json b/data_local/schemas/com.example.util.simpletimetracker.data_local.database.AppDatabase/11.json new file mode 100644 index 00000000..27143fcb --- /dev/null +++ b/data_local/schemas/com.example.util.simpletimetracker.data_local.database.AppDatabase/11.json @@ -0,0 +1,401 @@ +{ + "formatVersion": 1, + "database": { + "version": 11, + "identityHash": "7d377034493d2db6a2d6347d00bdbecb", + "entities": [ + { + "tableName": "records", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `type_id` INTEGER NOT NULL, `time_started` INTEGER NOT NULL, `time_ended` INTEGER NOT NULL, `comment` TEXT NOT NULL, `tag_id` INTEGER NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "typeId", + "columnName": "type_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "timeStarted", + "columnName": "time_started", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "timeEnded", + "columnName": "time_ended", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "comment", + "columnName": "comment", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "tagId", + "columnName": "tag_id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "recordTypes", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `icon` TEXT NOT NULL, `color` INTEGER NOT NULL, `color_int` TEXT NOT NULL, `hidden` INTEGER NOT NULL, `goal_time` INTEGER NOT NULL, `daily_goal_time` INTEGER NOT NULL, `weekly_goal_time` INTEGER NOT NULL, `monthly_goal_time` INTEGER NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "icon", + "columnName": "icon", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "color", + "columnName": "color", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "colorInt", + "columnName": "color_int", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "hidden", + "columnName": "hidden", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "goalTime", + "columnName": "goal_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "dailyGoalTime", + "columnName": "daily_goal_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "weeklyGoalTime", + "columnName": "weekly_goal_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "monthlyGoalTime", + "columnName": "monthly_goal_time", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "runningRecords", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `time_started` INTEGER NOT NULL, `comment` TEXT NOT NULL, `tag_id` INTEGER NOT NULL, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "timeStarted", + "columnName": "time_started", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "comment", + "columnName": "comment", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "tagId", + "columnName": "tag_id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": false + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "categories", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `color` INTEGER NOT NULL, `color_int` TEXT NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "color", + "columnName": "color", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "colorInt", + "columnName": "color_int", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "recordTypeCategory", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`record_type_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, PRIMARY KEY(`record_type_id`, `category_id`))", + "fields": [ + { + "fieldPath": "recordTypeId", + "columnName": "record_type_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "categoryId", + "columnName": "category_id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "record_type_id", + "category_id" + ], + "autoGenerate": false + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "recordTags", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `type_id` INTEGER NOT NULL, `name` TEXT NOT NULL, `color` INTEGER NOT NULL, `color_int` TEXT NOT NULL, `archived` INTEGER NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "typeId", + "columnName": "type_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "color", + "columnName": "color", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "colorInt", + "columnName": "color_int", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "archived", + "columnName": "archived", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "recordToRecordTag", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`record_id` INTEGER NOT NULL, `record_tag_id` INTEGER NOT NULL, PRIMARY KEY(`record_id`, `record_tag_id`))", + "fields": [ + { + "fieldPath": "recordId", + "columnName": "record_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "recordTagId", + "columnName": "record_tag_id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "record_id", + "record_tag_id" + ], + "autoGenerate": false + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "runningRecordToRecordTag", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`running_record_id` INTEGER NOT NULL, `record_tag_id` INTEGER NOT NULL, PRIMARY KEY(`running_record_id`, `record_tag_id`))", + "fields": [ + { + "fieldPath": "runningRecordId", + "columnName": "running_record_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "recordTagId", + "columnName": "record_tag_id", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "running_record_id", + "record_tag_id" + ], + "autoGenerate": false + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "activityFilters", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `selectedIds` TEXT NOT NULL, `type` INTEGER NOT NULL, `name` TEXT NOT NULL, `color` INTEGER NOT NULL, `color_int` TEXT NOT NULL, `selected` INTEGER NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "selectedIds", + "columnName": "selectedIds", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "color", + "columnName": "color", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "colorInt", + "columnName": "color_int", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "selected", + "columnName": "selected", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [], + "foreignKeys": [] + } + ], + "views": [], + "setupQueries": [ + "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '7d377034493d2db6a2d6347d00bdbecb')" + ] + } +} \ No newline at end of file diff --git a/data_local/src/main/java/com/example/util/simpletimetracker/data_local/database/AppDatabase.kt b/data_local/src/main/java/com/example/util/simpletimetracker/data_local/database/AppDatabase.kt index a1ba065b..6e581d43 100644 --- a/data_local/src/main/java/com/example/util/simpletimetracker/data_local/database/AppDatabase.kt +++ b/data_local/src/main/java/com/example/util/simpletimetracker/data_local/database/AppDatabase.kt @@ -24,7 +24,7 @@ import com.example.util.simpletimetracker.data_local.model.RunningRecordToRecord RunningRecordToRecordTagDBO::class, ActivityFilterDBO::class, ], - version = 10, + version = 11, exportSchema = true, ) abstract class AppDatabase : RoomDatabase() { diff --git a/data_local/src/main/java/com/example/util/simpletimetracker/data_local/database/AppDatabaseMigrations.kt b/data_local/src/main/java/com/example/util/simpletimetracker/data_local/database/AppDatabaseMigrations.kt index 54734691..06fd9898 100644 --- a/data_local/src/main/java/com/example/util/simpletimetracker/data_local/database/AppDatabaseMigrations.kt +++ b/data_local/src/main/java/com/example/util/simpletimetracker/data_local/database/AppDatabaseMigrations.kt @@ -119,5 +119,13 @@ class AppDatabaseMigrations { ) } } + + val migration_10_11 = object : Migration(10, 11) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL( + "ALTER TABLE recordTypes ADD COLUMN monthly_goal_time INTEGER NOT NULL DEFAULT 0" + ) + } + } } } \ No newline at end of file diff --git a/data_local/src/main/java/com/example/util/simpletimetracker/data_local/di/DataLocalModule.kt b/data_local/src/main/java/com/example/util/simpletimetracker/data_local/di/DataLocalModule.kt index 5d4e80fc..5a9a09e1 100644 --- a/data_local/src/main/java/com/example/util/simpletimetracker/data_local/di/DataLocalModule.kt +++ b/data_local/src/main/java/com/example/util/simpletimetracker/data_local/di/DataLocalModule.kt @@ -48,6 +48,7 @@ class DataLocalModule { AppDatabaseMigrations.migration_7_8, AppDatabaseMigrations.migration_8_9, AppDatabaseMigrations.migration_9_10, + AppDatabaseMigrations.migration_10_11, ) .build() } diff --git a/data_local/src/main/java/com/example/util/simpletimetracker/data_local/mapper/RecordTypeDataLocalMapper.kt b/data_local/src/main/java/com/example/util/simpletimetracker/data_local/mapper/RecordTypeDataLocalMapper.kt index 381179a4..cf1d303c 100644 --- a/data_local/src/main/java/com/example/util/simpletimetracker/data_local/mapper/RecordTypeDataLocalMapper.kt +++ b/data_local/src/main/java/com/example/util/simpletimetracker/data_local/mapper/RecordTypeDataLocalMapper.kt @@ -20,6 +20,7 @@ class RecordTypeDataLocalMapper @Inject constructor() { goalTime = dbo.goalTime, dailyGoalTime = dbo.dailyGoalTime, weeklyGoalTime = dbo.weeklyGoalTime, + monthlyGoalTime = dbo.monthlyGoalTime, ) } @@ -34,6 +35,7 @@ class RecordTypeDataLocalMapper @Inject constructor() { goalTime = domain.goalTime, dailyGoalTime = domain.dailyGoalTime, weeklyGoalTime = domain.weeklyGoalTime, + monthlyGoalTime = domain.monthlyGoalTime, ) } } \ No newline at end of file diff --git a/data_local/src/main/java/com/example/util/simpletimetracker/data_local/model/RecordTypeDBO.kt b/data_local/src/main/java/com/example/util/simpletimetracker/data_local/model/RecordTypeDBO.kt index c31addd8..4fb2cf4d 100644 --- a/data_local/src/main/java/com/example/util/simpletimetracker/data_local/model/RecordTypeDBO.kt +++ b/data_local/src/main/java/com/example/util/simpletimetracker/data_local/model/RecordTypeDBO.kt @@ -37,4 +37,8 @@ data class RecordTypeDBO( // Seconds. @ColumnInfo(name = "weekly_goal_time") val weeklyGoalTime: Long, + + // Seconds. + @ColumnInfo(name = "monthly_goal_time") + val monthlyGoalTime: Long, ) \ No newline at end of file diff --git a/data_local/src/main/java/com/example/util/simpletimetracker/data_local/resolver/BackupRepoImpl.kt b/data_local/src/main/java/com/example/util/simpletimetracker/data_local/resolver/BackupRepoImpl.kt index 90cd8c71..9101d98d 100644 --- a/data_local/src/main/java/com/example/util/simpletimetracker/data_local/resolver/BackupRepoImpl.kt +++ b/data_local/src/main/java/com/example/util/simpletimetracker/data_local/resolver/BackupRepoImpl.kt @@ -200,7 +200,7 @@ class BackupRepoImpl @Inject constructor( private fun toBackupString(recordType: RecordType): String { return String.format( - "$ROW_RECORD_TYPE\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", + "$ROW_RECORD_TYPE\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", recordType.id.toString(), recordType.name.clean(), recordType.icon, @@ -210,6 +210,7 @@ class BackupRepoImpl @Inject constructor( recordType.color.colorInt, recordType.dailyGoalTime.toString(), recordType.weeklyGoalTime.toString(), + recordType.monthlyGoalTime.toString(), ) } @@ -294,6 +295,7 @@ class BackupRepoImpl @Inject constructor( goalTime = parts.getOrNull(6)?.toLongOrNull().orZero(), dailyGoalTime = parts.getOrNull(8)?.toLongOrNull().orZero(), weeklyGoalTime = parts.getOrNull(9)?.toLongOrNull().orZero(), + monthlyGoalTime = parts.getOrNull(10)?.toLongOrNull().orZero(), ) } diff --git a/domain/src/main/java/com/example/util/simpletimetracker/domain/model/GoalTimeType.kt b/domain/src/main/java/com/example/util/simpletimetracker/domain/model/GoalTimeType.kt index 0af9e3db..b04bd55f 100644 --- a/domain/src/main/java/com/example/util/simpletimetracker/domain/model/GoalTimeType.kt +++ b/domain/src/main/java/com/example/util/simpletimetracker/domain/model/GoalTimeType.kt @@ -4,4 +4,5 @@ sealed interface GoalTimeType { object Session : GoalTimeType object Day : GoalTimeType object Week : GoalTimeType + object Month : GoalTimeType } \ No newline at end of file diff --git a/domain/src/main/java/com/example/util/simpletimetracker/domain/model/RecordType.kt b/domain/src/main/java/com/example/util/simpletimetracker/domain/model/RecordType.kt index 69e418dd..d8f47016 100644 --- a/domain/src/main/java/com/example/util/simpletimetracker/domain/model/RecordType.kt +++ b/domain/src/main/java/com/example/util/simpletimetracker/domain/model/RecordType.kt @@ -9,4 +9,5 @@ data class RecordType( val goalTime: Long, // Seconds. val dailyGoalTime: Long, // Seconds. val weeklyGoalTime: Long, // Seconds. + val monthlyGoalTime: Long, // Seconds. ) \ No newline at end of file diff --git a/features/feature_change_record_type/src/main/java/com/example/util/simpletimetracker/feature_change_record_type/view/ChangeRecordTypeFragment.kt b/features/feature_change_record_type/src/main/java/com/example/util/simpletimetracker/feature_change_record_type/view/ChangeRecordTypeFragment.kt index 7cf5b405..7ec160bd 100644 --- a/features/feature_change_record_type/src/main/java/com/example/util/simpletimetracker/feature_change_record_type/view/ChangeRecordTypeFragment.kt +++ b/features/feature_change_record_type/src/main/java/com/example/util/simpletimetracker/feature_change_record_type/view/ChangeRecordTypeFragment.kt @@ -187,6 +187,7 @@ class ChangeRecordTypeFragment : groupChangeRecordTypeSessionGoalTime.setOnClick(viewModel::onSessionGoalTimeClick) groupChangeRecordTypeDailyGoalTime.setOnClick(viewModel::onDailyGoalTimeClick) groupChangeRecordTypeWeeklyGoalTime.setOnClick(viewModel::onWeeklyGoalTimeClick) + groupChangeRecordTypeMonthlyGoalTime.setOnClick(viewModel::onMonthlyGoalTimeClick) btnChangeRecordTypeSave.setOnClick(viewModel::onSaveClick) btnChangeRecordTypeDelete.setOnClick(viewModel::onDeleteClick) btnChangeRecordTypeIconSwitch.listener = { @@ -221,6 +222,7 @@ class ChangeRecordTypeFragment : sessionGoalTimeViewData.observe(tvChangeRecordTypeSessionGoalTime::setText) dailyGoalTimeViewData.observe(tvChangeRecordTypeDailyGoalTime::setText) weeklyGoalTimeViewData.observe(tvChangeRecordTypeWeeklyGoalTime::setText) + monthlyGoalTimeViewData.observe(tvChangeRecordTypeMonthlyGoalTime::setText) chooserState.observe(::updateChooserState) keyboardVisibility.observe { visible -> if (visible) showKeyboard(etChangeRecordTypeName) else hideKeyboard() diff --git a/features/feature_change_record_type/src/main/java/com/example/util/simpletimetracker/feature_change_record_type/viewModel/ChangeRecordTypeViewModel.kt b/features/feature_change_record_type/src/main/java/com/example/util/simpletimetracker/feature_change_record_type/viewModel/ChangeRecordTypeViewModel.kt index 9c638a88..b9e68d5f 100644 --- a/features/feature_change_record_type/src/main/java/com/example/util/simpletimetracker/feature_change_record_type/viewModel/ChangeRecordTypeViewModel.kt +++ b/features/feature_change_record_type/src/main/java/com/example/util/simpletimetracker/feature_change_record_type/viewModel/ChangeRecordTypeViewModel.kt @@ -133,6 +133,14 @@ class ChangeRecordTypeViewModel @Inject constructor( initial } } + val monthlyGoalTimeViewData: LiveData by lazy { + MutableLiveData().let { initial -> + viewModelScope.launch { + initial.value = loadMonthlyGoalTimeViewData() + } + initial + } + } val chooserState: LiveData = MutableLiveData( ChangeRecordTypeChooserState( current = ChangeRecordTypeChooserState.State.Closed, @@ -156,6 +164,7 @@ class ChangeRecordTypeViewModel @Inject constructor( private var newGoalTime: Long = 0L private var newDailyGoalTime: Long = 0L private var newWeeklyGoalTime: Long = 0L + private var newMonthlyGoalTime: Long = 0L fun onVisible() = viewModelScope.launch { initializeSelectedCategories() @@ -334,6 +343,15 @@ class ChangeRecordTypeViewModel @Inject constructor( ) } + fun onMonthlyGoalTimeClick() { + router.navigate( + DurationDialogParams( + tag = MONTHLY_GOAL_TIME_DIALOG_TAG, + duration = newMonthlyGoalTime + ) + ) + } + fun onDurationSet(tag: String?, duration: Long, anchor: Any) { when (tag) { SESSION_GOAL_TIME_DIALOG_TAG -> viewModelScope.launch { @@ -351,6 +369,11 @@ class ChangeRecordTypeViewModel @Inject constructor( updateWeeklyGoalTimeViewData() checkExactAlarmPermissionInteractor.execute(anchor) } + MONTHLY_GOAL_TIME_DIALOG_TAG -> viewModelScope.launch { + newMonthlyGoalTime = duration + updateMonthlyGoalTimeViewData() + checkExactAlarmPermissionInteractor.execute(anchor) + } } } @@ -368,6 +391,10 @@ class ChangeRecordTypeViewModel @Inject constructor( newWeeklyGoalTime = 0 updateWeeklyGoalTimeViewData() } + MONTHLY_GOAL_TIME_DIALOG_TAG -> viewModelScope.launch { + newMonthlyGoalTime = 0 + updateMonthlyGoalTimeViewData() + } } } @@ -480,6 +507,7 @@ class ChangeRecordTypeViewModel @Inject constructor( goalTime = newGoalTime, dailyGoalTime = newDailyGoalTime, weeklyGoalTime = newWeeklyGoalTime, + monthlyGoalTime = newMonthlyGoalTime, ) return recordTypeInteractor.add(recordType) @@ -502,11 +530,13 @@ class ChangeRecordTypeViewModel @Inject constructor( newGoalTime = it.goalTime newDailyGoalTime = it.dailyGoalTime newWeeklyGoalTime = it.weeklyGoalTime + newMonthlyGoalTime = it.monthlyGoalTime updateIcons() updateColors() updateSessionGoalTimeViewData() updateDailyGoalTimeViewData() updateWeeklyGoalTimeViewData() + updateMonthlyGoalTimeViewData() } } @@ -533,6 +563,7 @@ class ChangeRecordTypeViewModel @Inject constructor( goalTime = 0, dailyGoalTime = 0, weeklyGoalTime = 0, + monthlyGoalTime = 0, ).let { recordTypeViewDataMapper.map(it, isDarkTheme) } } @@ -615,6 +646,15 @@ class ChangeRecordTypeViewModel @Inject constructor( return newWeeklyGoalTime.let(changeRecordTypeMapper::toGoalTimeViewData) } + private fun updateMonthlyGoalTimeViewData() { + val data = loadMonthlyGoalTimeViewData() + monthlyGoalTimeViewData.set(data) + } + + private fun loadMonthlyGoalTimeViewData(): String { + return newMonthlyGoalTime.let(changeRecordTypeMapper::toGoalTimeViewData) + } + private fun updateIconScrollPosition(position: Int) { iconsScrollPosition.set(ChangeRecordTypeScrollViewData.ScrollTo(position)) } @@ -628,5 +668,6 @@ class ChangeRecordTypeViewModel @Inject constructor( private const val SESSION_GOAL_TIME_DIALOG_TAG = "session_goal_time_dialog_tag" private const val DAILY_GOAL_TIME_DIALOG_TAG = "daily_goal_time_dialog_tag" private const val WEEKLY_GOAL_TIME_DIALOG_TAG = "weekly_goal_time_dialog_tag" + private const val MONTHLY_GOAL_TIME_DIALOG_TAG = "monthly_goal_time_dialog_tag" } } diff --git a/features/feature_change_record_type/src/main/res/layout/change_record_type_fragment.xml b/features/feature_change_record_type/src/main/res/layout/change_record_type_fragment.xml index 440556a2..8371b716 100644 --- a/features/feature_change_record_type/src/main/res/layout/change_record_type_fragment.xml +++ b/features/feature_change_record_type/src/main/res/layout/change_record_type_fragment.xml @@ -264,7 +264,7 @@ android:visibility="gone" app:layout_constraintBottom_toTopOf="@id/btnChangeRecordTypeSave" app:layout_constraintTop_toBottomOf="@id/containerChangeRecordTypeMain" - tools:visibility="visible"> + tools:visibility="gone"> + + + + + + + + + + diff --git a/features/feature_change_running_record/src/main/java/com/example/util/simpletimetracker/feature_change_running_record/interactor/ChangeRunningRecordViewDataInteractor.kt b/features/feature_change_running_record/src/main/java/com/example/util/simpletimetracker/feature_change_running_record/interactor/ChangeRunningRecordViewDataInteractor.kt index a1278942..45037f0f 100644 --- a/features/feature_change_running_record/src/main/java/com/example/util/simpletimetracker/feature_change_running_record/interactor/ChangeRunningRecordViewDataInteractor.kt +++ b/features/feature_change_running_record/src/main/java/com/example/util/simpletimetracker/feature_change_running_record/interactor/ChangeRunningRecordViewDataInteractor.kt @@ -35,11 +35,17 @@ class ChangeRunningRecordViewDataInteractor @Inject constructor( } else { 0L } + val monthlyCurrent = if (type?.monthlyGoalTime.orZero() > 0L) { + getCurrentRecordsDurationInteractor.getMonthlyCurrent(record) + } else { + 0L + } return changeRunningRecordViewDataMapper.map( runningRecord = record, dailyCurrent = dailyCurrent, weeklyCurrent = weeklyCurrent, + monthlyCurrent = monthlyCurrent, recordType = type, recordTags = tags, isDarkTheme = isDarkTheme, diff --git a/features/feature_change_running_record/src/main/java/com/example/util/simpletimetracker/feature_change_running_record/mapper/ChangeRunningRecordViewDataMapper.kt b/features/feature_change_running_record/src/main/java/com/example/util/simpletimetracker/feature_change_running_record/mapper/ChangeRunningRecordViewDataMapper.kt index e4ef1e2e..0a5450db 100644 --- a/features/feature_change_running_record/src/main/java/com/example/util/simpletimetracker/feature_change_running_record/mapper/ChangeRunningRecordViewDataMapper.kt +++ b/features/feature_change_running_record/src/main/java/com/example/util/simpletimetracker/feature_change_running_record/mapper/ChangeRunningRecordViewDataMapper.kt @@ -26,6 +26,7 @@ class ChangeRunningRecordViewDataMapper @Inject constructor( runningRecord: RunningRecord, dailyCurrent: Long, weeklyCurrent: Long, + monthlyCurrent: Long, recordType: RecordType?, recordTags: List, isDarkTheme: Boolean, @@ -76,6 +77,11 @@ class ChangeRunningRecordViewDataMapper @Inject constructor( current = weeklyCurrent, type = GoalTimeType.Week, ), + goalTime4 = goalTimeMapper.map( + goalTime = recordType?.monthlyGoalTime.orZero(), + current = monthlyCurrent, + type = GoalTimeType.Month, + ), iconId = recordType?.icon.orEmpty() .let(iconMapper::mapIcon), color = recordType?.color diff --git a/features/feature_change_running_record/src/main/java/com/example/util/simpletimetracker/feature_change_running_record/view/ChangeRunningRecordFragment.kt b/features/feature_change_running_record/src/main/java/com/example/util/simpletimetracker/feature_change_running_record/view/ChangeRunningRecordFragment.kt index 8209b90a..cf663ef7 100644 --- a/features/feature_change_running_record/src/main/java/com/example/util/simpletimetracker/feature_change_running_record/view/ChangeRunningRecordFragment.kt +++ b/features/feature_change_running_record/src/main/java/com/example/util/simpletimetracker/feature_change_running_record/view/ChangeRunningRecordFragment.kt @@ -110,6 +110,7 @@ class ChangeRunningRecordFragment : goalTime = goalTime.toViewData(), goalTime2 = goalTime2.toViewData(), goalTime3 = goalTime3.toViewData(), + goalTime4 = goalTime4.toViewData(), iconId = iconId.toViewData(), color = color, comment = comment @@ -130,6 +131,8 @@ class ChangeRunningRecordFragment : itemGoalTime2Complete = item.goalTime2.complete itemGoalTime3 = item.goalTime3.text itemGoalTime3Complete = item.goalTime3.complete + itemGoalTime4 = item.goalTime4.text + itemGoalTime4Complete = item.goalTime4.complete itemComment = item.comment } tvChangeRecordTimeStarted.text = item.dateTimeStarted diff --git a/features/feature_change_running_record/src/main/java/com/example/util/simpletimetracker/feature_change_running_record/viewData/ChangeRunningRecordViewData.kt b/features/feature_change_running_record/src/main/java/com/example/util/simpletimetracker/feature_change_running_record/viewData/ChangeRunningRecordViewData.kt index 2bdfc569..d9c48457 100644 --- a/features/feature_change_running_record/src/main/java/com/example/util/simpletimetracker/feature_change_running_record/viewData/ChangeRunningRecordViewData.kt +++ b/features/feature_change_running_record/src/main/java/com/example/util/simpletimetracker/feature_change_running_record/viewData/ChangeRunningRecordViewData.kt @@ -13,6 +13,7 @@ data class ChangeRunningRecordViewData( var goalTime: GoalTimeViewData, var goalTime2: GoalTimeViewData, var goalTime3: GoalTimeViewData, + var goalTime4: GoalTimeViewData, val iconId: RecordTypeIcon, @ColorInt val color: Int, val comment: String diff --git a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/goalTime/controller/NotificationGoalTimeBroadcastController.kt b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/goalTime/controller/NotificationGoalTimeBroadcastController.kt index f6c70689..e645c6fd 100644 --- a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/goalTime/controller/NotificationGoalTimeBroadcastController.kt +++ b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/goalTime/controller/NotificationGoalTimeBroadcastController.kt @@ -15,6 +15,7 @@ class NotificationGoalTimeBroadcastController @Inject constructor( } fun onRangeEndReminder() { + // TODO reschedule only from this range (day, week, etc) reschedule() } diff --git a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/goalTime/interactor/NotificationGoalTimeInteractorImpl.kt b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/goalTime/interactor/NotificationGoalTimeInteractorImpl.kt index 047f3c31..cc67246d 100644 --- a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/goalTime/interactor/NotificationGoalTimeInteractorImpl.kt +++ b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/goalTime/interactor/NotificationGoalTimeInteractorImpl.kt @@ -51,6 +51,7 @@ class NotificationGoalTimeInteractorImpl @Inject constructor( listOf( GoalTimeType.Day, GoalTimeType.Week, + GoalTimeType.Month, ).forEach(rangeEndScheduler::cancelSchedule) // Session @@ -82,13 +83,25 @@ class NotificationGoalTimeInteractorImpl @Inject constructor( rangeEndScheduler.schedule(range.timeEnded, GoalTimeType.Week) } } + + // Monthly + val monthlyGoalTime = recordType.monthlyGoalTime * 1000 + if (monthlyGoalTime > 0) { + val range = getCurrentRecordsDurationInteractor.getRange(RangeLength.Month) + val monthlyCurrent = getCurrentRecordsDurationInteractor.getRangeCurrent(runningRecord, range) + if (monthlyGoalTime > monthlyCurrent) { + scheduler.schedule(monthlyGoalTime - monthlyCurrent, typeId, GoalTimeType.Month) + rangeEndScheduler.schedule(range.timeEnded, GoalTimeType.Month) + } + } } override fun cancel(typeId: Long) { listOf( GoalTimeType.Session, GoalTimeType.Day, - GoalTimeType.Week + GoalTimeType.Week, + GoalTimeType.Month, ).forEach { scheduler.cancelSchedule(typeId, it) manager.hide(typeId, it) @@ -104,11 +117,13 @@ class NotificationGoalTimeInteractorImpl @Inject constructor( is GoalTimeType.Session -> recordType.goalTime is GoalTimeType.Day -> recordType.dailyGoalTime is GoalTimeType.Week -> recordType.weeklyGoalTime + is GoalTimeType.Month -> recordType.monthlyGoalTime }.let(timeMapper::formatDuration) val goalTimeTypeString = when (goalTimeType) { is GoalTimeType.Session -> R.string.change_record_type_session_goal_time is GoalTimeType.Day -> R.string.change_record_type_daily_goal_time is GoalTimeType.Week -> R.string.change_record_type_weekly_goal_time + is GoalTimeType.Month -> R.string.change_record_type_monthly_goal_time }.let(resourceRepo::getString).let { " ($it)" } NotificationGoalTimeParams( diff --git a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/goalTime/manager/NotificationGoalTimeManager.kt b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/goalTime/manager/NotificationGoalTimeManager.kt index f509ffea..dc20fb50 100644 --- a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/goalTime/manager/NotificationGoalTimeManager.kt +++ b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/goalTime/manager/NotificationGoalTimeManager.kt @@ -63,6 +63,7 @@ class NotificationGoalTimeManager @Inject constructor( is GoalTimeType.Session -> "" // back support for previous versions, keep same tag is GoalTimeType.Day -> "day" is GoalTimeType.Week -> "week" + is GoalTimeType.Month -> "month" } } diff --git a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/goalTime/scheduler/NotificationGoalTimeScheduler.kt b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/goalTime/scheduler/NotificationGoalTimeScheduler.kt index 2317a43b..8c97f077 100644 --- a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/goalTime/scheduler/NotificationGoalTimeScheduler.kt +++ b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/goalTime/scheduler/NotificationGoalTimeScheduler.kt @@ -30,6 +30,7 @@ class NotificationGoalTimeScheduler @Inject constructor( is GoalTimeType.Session -> NotificationReceiver.ACTION_GOAL_TIME_REMINDER_SESSION is GoalTimeType.Day -> NotificationReceiver.ACTION_GOAL_TIME_REMINDER_DAILY is GoalTimeType.Week -> NotificationReceiver.ACTION_GOAL_TIME_REMINDER_WEEKLY + is GoalTimeType.Month -> NotificationReceiver.ACTION_GOAL_TIME_REMINDER_MONTHLY } putExtra(NotificationReceiver.EXTRA_GOAL_TIME_TYPE_ID, typeId) } diff --git a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/goalTime/scheduler/NotificationRangeEndScheduler.kt b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/goalTime/scheduler/NotificationRangeEndScheduler.kt index 87373345..fe81b7de 100644 --- a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/goalTime/scheduler/NotificationRangeEndScheduler.kt +++ b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/goalTime/scheduler/NotificationRangeEndScheduler.kt @@ -29,6 +29,7 @@ class NotificationRangeEndScheduler @Inject constructor( is GoalTimeType.Session -> return null // No need to reschedule. is GoalTimeType.Day -> NotificationReceiver.ACTION_GOAL_TIME_REMINDER_DAY_END is GoalTimeType.Week -> NotificationReceiver.ACTION_GOAL_TIME_REMINDER_WEEK_END + is GoalTimeType.Month -> NotificationReceiver.ACTION_GOAL_TIME_REMINDER_MONTH_END } } diff --git a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recevier/NotificationReceiver.kt b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recevier/NotificationReceiver.kt index de57b458..a4e574ca 100644 --- a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recevier/NotificationReceiver.kt +++ b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recevier/NotificationReceiver.kt @@ -39,18 +39,21 @@ class NotificationReceiver : BroadcastReceiver() { ACTION_GOAL_TIME_REMINDER_SESSION, ACTION_GOAL_TIME_REMINDER_DAILY, ACTION_GOAL_TIME_REMINDER_WEEKLY, + ACTION_GOAL_TIME_REMINDER_MONTHLY, -> { val typeId = intent.getLongExtra(EXTRA_GOAL_TIME_TYPE_ID, 0) val goalTimeType = when (action) { ACTION_GOAL_TIME_REMINDER_SESSION -> GoalTimeType.Session ACTION_GOAL_TIME_REMINDER_DAILY -> GoalTimeType.Day ACTION_GOAL_TIME_REMINDER_WEEKLY -> GoalTimeType.Week + ACTION_GOAL_TIME_REMINDER_MONTHLY -> GoalTimeType.Month else -> GoalTimeType.Session } goalTimeController.onGoalTimeReminder(typeId, goalTimeType) } ACTION_GOAL_TIME_REMINDER_DAY_END, ACTION_GOAL_TIME_REMINDER_WEEK_END, + ACTION_GOAL_TIME_REMINDER_MONTH_END, -> { goalTimeController.onRangeEndReminder() } @@ -92,10 +95,14 @@ class NotificationReceiver : BroadcastReceiver() { "com.razeeman.util.simpletimetracker.ACTION_GOAL_TIME_REMINDER_DAILY" const val ACTION_GOAL_TIME_REMINDER_WEEKLY = "com.razeeman.util.simpletimetracker.ACTION_GOAL_TIME_REMINDER_WEEKLY" + const val ACTION_GOAL_TIME_REMINDER_MONTHLY = + "com.razeeman.util.simpletimetracker.ACTION_GOAL_TIME_REMINDER_MONTHLY" const val ACTION_GOAL_TIME_REMINDER_DAY_END = "com.razeeman.util.simpletimetracker.ACTION_GOAL_TIME_REMINDER_DAY_END" const val ACTION_GOAL_TIME_REMINDER_WEEK_END = "com.razeeman.util.simpletimetracker.ACTION_GOAL_TIME_REMINDER_WEEK_END" + const val ACTION_GOAL_TIME_REMINDER_MONTH_END = + "com.razeeman.util.simpletimetracker.ACTION_GOAL_TIME_REMINDER_MONTH_END" const val EXTRA_GOAL_TIME_TYPE_ID = "extra_goal_time_type_id" diff --git a/features/feature_running_records/src/main/java/com/example/util/simpletimetracker/feature_running_records/adapter/RunningRecordAdapterDelegate.kt b/features/feature_running_records/src/main/java/com/example/util/simpletimetracker/feature_running_records/adapter/RunningRecordAdapterDelegate.kt index 84bfb0bf..0fd2376d 100644 --- a/features/feature_running_records/src/main/java/com/example/util/simpletimetracker/feature_running_records/adapter/RunningRecordAdapterDelegate.kt +++ b/features/feature_running_records/src/main/java/com/example/util/simpletimetracker/feature_running_records/adapter/RunningRecordAdapterDelegate.kt @@ -47,6 +47,10 @@ fun createRunningRecordAdapterDelegate( itemGoalTime3 = item.goalTime3.text itemGoalTime3Complete = item.goalTime3.complete } + if (rebind || updates.contains(ViewData.UPDATE_GOAL_TIME4).orFalse()) { + itemGoalTime4 = item.goalTime4.text + itemGoalTime4Complete = item.goalTime4.complete + } if (rebind || updates.contains(ViewData.UPDATE_ICON).orFalse()) { itemIcon = item.iconId } diff --git a/features/feature_running_records/src/main/java/com/example/util/simpletimetracker/feature_running_records/interactor/RunningRecordsViewDataInteractor.kt b/features/feature_running_records/src/main/java/com/example/util/simpletimetracker/feature_running_records/interactor/RunningRecordsViewDataInteractor.kt index 640b009a..06b2430d 100644 --- a/features/feature_running_records/src/main/java/com/example/util/simpletimetracker/feature_running_records/interactor/RunningRecordsViewDataInteractor.kt +++ b/features/feature_running_records/src/main/java/com/example/util/simpletimetracker/feature_running_records/interactor/RunningRecordsViewDataInteractor.kt @@ -54,11 +54,17 @@ class RunningRecordsViewDataInteractor @Inject constructor( } else { 0L } + val monthlyCurrent = if (recordType.monthlyGoalTime > 0L) { + getCurrentRecordsDurationInteractor.getMonthlyCurrent(runningRecord) + } else { + 0L + } mapper.map( runningRecord = runningRecord, dailyCurrent = dailyCurrent, weeklyCurrent = weeklyCurrent, + monthlyCurrent = monthlyCurrent, recordType = recordType, recordTags = recordTags.filter { it.id in runningRecord.tagIds }, isDarkTheme = isDarkTheme, diff --git a/features/feature_running_records/src/main/java/com/example/util/simpletimetracker/feature_running_records/mapper/RunningRecordViewDataMapper.kt b/features/feature_running_records/src/main/java/com/example/util/simpletimetracker/feature_running_records/mapper/RunningRecordViewDataMapper.kt index 6f95d547..fc4d2514 100644 --- a/features/feature_running_records/src/main/java/com/example/util/simpletimetracker/feature_running_records/mapper/RunningRecordViewDataMapper.kt +++ b/features/feature_running_records/src/main/java/com/example/util/simpletimetracker/feature_running_records/mapper/RunningRecordViewDataMapper.kt @@ -35,6 +35,7 @@ class RunningRecordViewDataMapper @Inject constructor( runningRecord: RunningRecord, dailyCurrent: Long, weeklyCurrent: Long, + monthlyCurrent: Long, recordType: RecordType, recordTags: List, isDarkTheme: Boolean, @@ -78,6 +79,11 @@ class RunningRecordViewDataMapper @Inject constructor( current = weeklyCurrent, type = GoalTimeType.Week, ), + goalTime4 = goalTimeMapper.map( + goalTime = recordType.monthlyGoalTime, + current = monthlyCurrent, + type = GoalTimeType.Month, + ), iconId = recordType.icon .let(iconMapper::mapIcon), color = recordType.color diff --git a/features/feature_running_records/src/main/java/com/example/util/simpletimetracker/feature_running_records/viewData/RunningRecordViewData.kt b/features/feature_running_records/src/main/java/com/example/util/simpletimetracker/feature_running_records/viewData/RunningRecordViewData.kt index 3913cc9e..68061a45 100644 --- a/features/feature_running_records/src/main/java/com/example/util/simpletimetracker/feature_running_records/viewData/RunningRecordViewData.kt +++ b/features/feature_running_records/src/main/java/com/example/util/simpletimetracker/feature_running_records/viewData/RunningRecordViewData.kt @@ -14,6 +14,7 @@ data class RunningRecordViewData( val goalTime: GoalTimeViewData, val goalTime2: GoalTimeViewData, val goalTime3: GoalTimeViewData, + val goalTime4: GoalTimeViewData, val iconId: RecordTypeIcon, @ColorInt val color: Int, val comment: String, @@ -35,6 +36,7 @@ data class RunningRecordViewData( if (this.goalTime != other.goalTime) updates.add(UPDATE_GOAL_TIME) if (this.goalTime2 != other.goalTime2) updates.add(UPDATE_GOAL_TIME2) if (this.goalTime3 != other.goalTime3) updates.add(UPDATE_GOAL_TIME3) + if (this.goalTime4 != other.goalTime4) updates.add(UPDATE_GOAL_TIME4) if (this.comment != other.comment) updates.add(UPDATE_COMMENT) return updates.takeIf { it.isNotEmpty() } @@ -49,7 +51,8 @@ data class RunningRecordViewData( const val UPDATE_GOAL_TIME = 6 const val UPDATE_GOAL_TIME2 = 7 const val UPDATE_GOAL_TIME3 = 8 - const val UPDATE_COMMENT = 9 - const val UPDATE_TAG_NAME = 10 + const val UPDATE_GOAL_TIME4 = 9 + const val UPDATE_COMMENT = 10 + const val UPDATE_TAG_NAME = 11 } } \ No newline at end of file diff --git a/features/feature_running_records/src/main/java/com/example/util/simpletimetracker/feature_running_records/viewModel/RunningRecordsViewModel.kt b/features/feature_running_records/src/main/java/com/example/util/simpletimetracker/feature_running_records/viewModel/RunningRecordsViewModel.kt index 8a489570..91cc90bc 100644 --- a/features/feature_running_records/src/main/java/com/example/util/simpletimetracker/feature_running_records/viewModel/RunningRecordsViewModel.kt +++ b/features/feature_running_records/src/main/java/com/example/util/simpletimetracker/feature_running_records/viewModel/RunningRecordsViewModel.kt @@ -110,6 +110,7 @@ class RunningRecordsViewModel @Inject constructor( goalTime = item.goalTime.toParams(), goalTime2 = item.goalTime2.toParams(), goalTime3 = item.goalTime3.toParams(), + goalTime4 = item.goalTime4.toParams(), iconId = item.iconId.toParams(), color = item.color, comment = item.comment diff --git a/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/interactor/StatisticsDetailChartInteractor.kt b/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/interactor/StatisticsDetailChartInteractor.kt index 9b7a5270..49f28d8f 100644 --- a/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/interactor/StatisticsDetailChartInteractor.kt +++ b/features/feature_statistics_detail/src/main/java/com/example/util/simpletimetracker/feature_statistics_detail/interactor/StatisticsDetailChartInteractor.kt @@ -99,9 +99,8 @@ class StatisticsDetailChartInteractor @Inject constructor( return when (appliedChartGrouping) { ChartGrouping.DAILY -> type.dailyGoalTime ChartGrouping.WEEKLY -> type.weeklyGoalTime - ChartGrouping.MONTHLY, - ChartGrouping.YEARLY, - -> 0 + ChartGrouping.MONTHLY -> type.monthlyGoalTime + ChartGrouping.YEARLY -> 0 } * 1000 } diff --git a/features/feature_views/src/main/java/com/example/util/simpletimetracker/feature_views/RunningRecordView.kt b/features/feature_views/src/main/java/com/example/util/simpletimetracker/feature_views/RunningRecordView.kt index 4611032a..2bbf839a 100644 --- a/features/feature_views/src/main/java/com/example/util/simpletimetracker/feature_views/RunningRecordView.kt +++ b/features/feature_views/src/main/java/com/example/util/simpletimetracker/feature_views/RunningRecordView.kt @@ -107,6 +107,19 @@ class RunningRecordView @JvmOverloads constructor( field = value } + var itemGoalTime4: String = "" + set(value) { + binding.tvRunningRecordItemGoalTime4.text = value + binding.tvRunningRecordItemGoalTime4.visible = value.isNotEmpty() + field = value + } + + var itemGoalTime4Complete: Boolean = false + set(value) { + binding.ivRunningRecordItemGoalTimeCheck4.visible = value + field = value + } + var itemComment: String = "" set(value) { binding.tvRunningRecordItemComment.text = value diff --git a/features/feature_views/src/main/res/layout/record_running_view_layout.xml b/features/feature_views/src/main/res/layout/record_running_view_layout.xml index ccfe49f8..76640e4f 100644 --- a/features/feature_views/src/main/res/layout/record_running_view_layout.xml +++ b/features/feature_views/src/main/res/layout/record_running_view_layout.xml @@ -129,7 +129,7 @@ android:layout_marginEnd="4dp" android:textColor="?appLightTextColor" android:visibility="gone" - app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintBottom_toTopOf="@id/tvRunningRecordItemGoalTime4" app:layout_constraintEnd_toStartOf="@id/ivRunningRecordItemGoalTimeCheck3" app:layout_constraintTop_toBottomOf="@+id/tvRunningRecordItemGoalTime2" app:layout_goneMarginEnd="8dp" @@ -148,12 +148,38 @@ app:layout_constraintTop_toTopOf="@id/tvRunningRecordItemGoalTime3" tools:visibility="visible" /> + + + + + app:constraint_referenced_ids="tvRunningRecordItemTimer, tvRunningRecordItemGoalTime, tvRunningRecordItemGoalTime2, tvRunningRecordItemGoalTime3, tvRunningRecordItemGoalTime4" />