diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 3f842b6..1819164 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -38,7 +38,7 @@ android { applicationId = "cn.super12138.todo" minSdk = 24 targetSdk = 36 - versionCode = 976 + versionCode = 978 versionName = "2.3.3" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/kotlin/cn/super12138/todo/ui/pages/editor/TodoEditorPage.kt b/app/src/main/kotlin/cn/super12138/todo/ui/pages/editor/TodoEditorPage.kt index 36abd1b..b6e0686 100644 --- a/app/src/main/kotlin/cn/super12138/todo/ui/pages/editor/TodoEditorPage.kt +++ b/app/src/main/kotlin/cn/super12138/todo/ui/pages/editor/TodoEditorPage.kt @@ -79,7 +79,7 @@ fun SharedTransitionScope.TodoEditPage( animatedVisibilityScope = LocalNavAnimatedContentScope.current, resizeMode = SharedTransitionScope.ResizeMode.RemeasureToBounds ), - //TODO: 没想好加不加 .skipToLookaheadSize(), + //TODO: 没想好加不加 .skipToLookaheadSize(), onSave = onSave, onDelete = onDelete, onNavigateUp = onNavigateUp diff --git a/app/src/main/kotlin/cn/super12138/todo/ui/pages/editor/components/TodoDueDateChooser.kt b/app/src/main/kotlin/cn/super12138/todo/ui/pages/editor/components/TodoDueDateChooser.kt index c4e9372..b3818c5 100644 --- a/app/src/main/kotlin/cn/super12138/todo/ui/pages/editor/components/TodoDueDateChooser.kt +++ b/app/src/main/kotlin/cn/super12138/todo/ui/pages/editor/components/TodoDueDateChooser.kt @@ -52,7 +52,7 @@ fun TodoDueDateChooser( TextField( value = value.toLocalDateString(), onValueChange = {}, - label = { Text("截止日期(可选)") }, + label = { Text(stringResource(R.string.label_due_date)) }, readOnly = true, interactionSource = interactionSource, modifier = modifier diff --git a/app/src/main/kotlin/cn/super12138/todo/ui/pages/editor/state/EditorState.kt b/app/src/main/kotlin/cn/super12138/todo/ui/pages/editor/state/EditorState.kt index 0d6f109..d5a2ade 100644 --- a/app/src/main/kotlin/cn/super12138/todo/ui/pages/editor/state/EditorState.kt +++ b/app/src/main/kotlin/cn/super12138/todo/ui/pages/editor/state/EditorState.kt @@ -41,8 +41,8 @@ class EditorState(val initialTodo: TodoEntity? = null) { fun setErrorIfNotValid(): Boolean { isErrorContent = toDoContent.trim().isEmpty() if (selectedCategoryIndex == -1 && categoryContent.trim().isEmpty()) { - isErrorCategory = true - categorySupportingText = R.string.error_no_content_entered + isErrorCategory = true + categorySupportingText = R.string.error_no_content_entered } else { isErrorCategory = false } diff --git a/app/src/main/kotlin/cn/super12138/todo/ui/pages/overview/OverviewPage.kt b/app/src/main/kotlin/cn/super12138/todo/ui/pages/overview/OverviewPage.kt index 074fa73..a5efe53 100644 --- a/app/src/main/kotlin/cn/super12138/todo/ui/pages/overview/OverviewPage.kt +++ b/app/src/main/kotlin/cn/super12138/todo/ui/pages/overview/OverviewPage.kt @@ -20,7 +20,7 @@ import cn.super12138.todo.ui.components.TopAppBarScaffold import cn.super12138.todo.ui.pages.overview.components.RoundedCornerCardLarge import cn.super12138.todo.ui.pages.overview.components.UpcomingTaskCard import cn.super12138.todo.ui.viewmodels.MainViewModel -import java.util.Calendar +import cn.super12138.todo.utils.SystemUtils @OptIn(ExperimentalMaterial3ExpressiveApi::class) @Composable @@ -28,25 +28,16 @@ fun OverviewPage( viewModel: MainViewModel, modifier: Modifier = Modifier ) { - val today = Calendar.getInstance().apply { - // 将时间设置为当天的开始(00:00:00.000) - // 兼容API24 - set(Calendar.HOUR_OF_DAY, 0) - set(Calendar.MINUTE, 0) - set(Calendar.SECOND, 0) - set(Calendar.MILLISECOND, 0) - } - val toDos by viewModel.sortedTodos.collectAsState(initial = emptyList()) val totalTasks by remember { derivedStateOf { toDos.size } } val completedTasks by remember { derivedStateOf { toDos.count { it.isCompleted } } } val nextWeekTodo by remember { derivedStateOf { - val now = System.currentTimeMillis() - val weekFromNow = now + 7L * 24 * 60 * 60 * 1000 + val today = SystemUtils.getToday() + val weekFromToday = today + 7L * 24 * 60 * 60 * 1000 toDos.filter { todo -> val due = todo.dueDate ?: return@filter false - due >= today.timeInMillis && due < weekFromNow + due in today.. when { - days.days == 1.days -> "明天" - days.days > 1.days && days.days < 7.days -> "${days}天后" - days.days in 7.days..<30.days -> "${days / 7}周后" - days.days in 30.days..<365.days -> "${days / 30}个月后" - days.days >= 365.days -> "${days / 365}年后" - else -> "今天" + days.days == 1.days -> context.getString(R.string.time_tomorrow) + days.days > 1.days && days.days < 7.days -> context.getString( + R.string.time_in_days, + days.toInt() + ) + + days.days in 7.days..<30.days -> context.getString( + R.string.time_in_weeks, + (days / 7).toInt() + ) + + days.days in 30.days..<365.days -> context.getString( + R.string.time_in_months, + (days / 30).toInt() + ) + + days.days >= 365.days -> context.getString(R.string.time_in_years, (days / 365).toInt()) + else -> context.getString(R.string.time_today) } } } \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_apps.xml b/app/src/main/res/drawable/ic_apps.xml index 5ce94da..9d4b035 100644 --- a/app/src/main/res/drawable/ic_apps.xml +++ b/app/src/main/res/drawable/ic_apps.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="960" android:viewportHeight="960"> - + diff --git a/app/src/main/res/drawable/ic_check_circle.xml b/app/src/main/res/drawable/ic_check_circle.xml index c069f11..a1aed34 100644 --- a/app/src/main/res/drawable/ic_check_circle.xml +++ b/app/src/main/res/drawable/ic_check_circle.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="960" android:viewportHeight="960"> - + diff --git a/app/src/main/res/drawable/ic_dashboard.xml b/app/src/main/res/drawable/ic_dashboard.xml index d0f22d1..b642a20 100644 --- a/app/src/main/res/drawable/ic_dashboard.xml +++ b/app/src/main/res/drawable/ic_dashboard.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="960" android:viewportHeight="960"> - + diff --git a/app/src/main/res/drawable/ic_dashboard_filled.xml b/app/src/main/res/drawable/ic_dashboard_filled.xml index 009c2a1..3dc8e73 100644 --- a/app/src/main/res/drawable/ic_dashboard_filled.xml +++ b/app/src/main/res/drawable/ic_dashboard_filled.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="960" android:viewportHeight="960"> - + diff --git a/app/src/main/res/drawable/ic_pending.xml b/app/src/main/res/drawable/ic_pending.xml index 8cb30cf..46ef86f 100644 --- a/app/src/main/res/drawable/ic_pending.xml +++ b/app/src/main/res/drawable/ic_pending.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="960" android:viewportHeight="960"> - + diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index ccd827b..f169f29 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -119,4 +119,14 @@ 尽量使用简短的分类名称 清除 临近的任务 + 今天 + 明天 + %d 天后 + %d 周后 + %d 个月后 + %d 年后 + 截止日期(可选) + 总任务 + 已完成 + 未完成 \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d09da55..9aecf2c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -119,5 +119,15 @@ Overview Keep category names concise Clear - Upcoming Task + Upcoming + Today + Tomorrow + in %d d + in %d w + in %d mo + in %d y + Due Date (Optional) + All + Completed + Pending \ No newline at end of file