diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 4f648af..b7c1227 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -35,7 +35,7 @@ android { applicationId = "cn.super12138.todo" minSdk = 24 targetSdk = 36 - versionCode = 742 + versionCode = 748 versionName = "2.1.2" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/kotlin/cn/super12138/todo/constants/Constants.kt b/app/src/main/kotlin/cn/super12138/todo/constants/Constants.kt index 616a5d0..8745294 100644 --- a/app/src/main/kotlin/cn/super12138/todo/constants/Constants.kt +++ b/app/src/main/kotlin/cn/super12138/todo/constants/Constants.kt @@ -5,8 +5,8 @@ object Constants { const val GITHUB_REPO = "https://github.com/Super12138/ToDo/" const val KEY_TODO_FAB_TRANSITION = "todo_fab" - const val KEY_TODO_CONTENT_TRANSITION = "todo_content" - const val KEY_TODO_CATEGORY_TRANSITION = "todo_category" + // const val KEY_TODO_CONTENT_TRANSITION = "todo_content" + // const val KEY_TODO_CATEGORY_TRANSITION = "todo_category" const val DB_NAME = "todo" const val DB_TABLE_NAME = "todo" diff --git a/app/src/main/kotlin/cn/super12138/todo/logic/database/TodoDatabase.kt b/app/src/main/kotlin/cn/super12138/todo/logic/database/TodoDatabase.kt index 3dfcdc7..d6569d9 100644 --- a/app/src/main/kotlin/cn/super12138/todo/logic/database/TodoDatabase.kt +++ b/app/src/main/kotlin/cn/super12138/todo/logic/database/TodoDatabase.kt @@ -41,9 +41,9 @@ abstract class TodoDatabase : RoomDatabase() { private val MIGRATION_3_4 = object : Migration(3, 4) { override fun migrate(db: SupportSQLiteDatabase) { // 创建一个新表,其中不含有subject,并且有一个新的category字段(由custom_subject迁移而来) - db.execSQL("CREATE TABLE IF NOT EXISTS todo_new (content TEXT NOT NULL, category TEXT NOT NULL DEFAULT 'Default Value', completed INTEGER NOT NULL, priority REAL NOT NULL, id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)") + db.execSQL("CREATE TABLE IF NOT EXISTS todo_new (content TEXT NOT NULL, category TEXT NOT NULL DEFAULT '', completed INTEGER NOT NULL, priority REAL NOT NULL, id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)") // 将旧表中的数据迁移到新表中 - db.execSQL("INSERT INTO todo_new (content, category, completed, priority, id) SELECT content, COALESCE(NULLIF(custom_subject, ''), 'Default Value') AS category, completed, priority, id FROM todo") + db.execSQL("INSERT INTO todo_new (content, category, completed, priority, id) SELECT content, COALESCE(NULLIF(custom_subject, ''), '') AS category, completed, priority, id FROM todo") // 删除旧表 db.execSQL("DROP TABLE todo") // 重命名新表 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 d94901a..1747f01 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 @@ -78,7 +78,7 @@ fun TodoEditorPage( id = index, name = category ) - } + ChipItem(id = -1, name = "自定义") + } + ChipItem(id = -1, name = stringResource(R.string.label_customization)) var defaultIndex by remember { mutableIntStateOf(-1) } LaunchedEffect(originalCategories, toDo) { @@ -167,14 +167,19 @@ fun TodoEditorPage( .fillMaxSize() ) { item { - with(sharedTransitionScope) { - TodoContentTextField( - value = uiState.toDoContent, - onValueChange = { uiState.toDoContent = it }, - isError = uiState.isErrorContent, - modifier = Modifier.fillMaxWidth() - ) - } + // with(sharedTransitionScope) { + TodoContentTextField( + value = uiState.toDoContent, + onValueChange = { uiState.toDoContent = it }, + isError = uiState.isErrorContent, + modifier = Modifier + .fillMaxWidth() + /*.sharedBounds( + sharedContentState = rememberSharedContentState("${Constants.KEY_TODO_CONTENT_TRANSITION}_${toDo?.id}"), + animatedVisibilityScope = animatedVisibilityScope + )*/ + ) + // } } item { @@ -196,14 +201,19 @@ fun TodoEditorPage( enter = fadeIn() + expandVertically(), exit = fadeOut() + shrinkVertically() ) { - with(sharedTransitionScope) { - TodoCategoryTextField( - value = uiState.categoryContent, - onValueChange = { uiState.categoryContent = it }, - isError = uiState.isErrorCategory, - modifier = Modifier.fillMaxWidth() - ) - } + // with(sharedTransitionScope) { + TodoCategoryTextField( + value = uiState.categoryContent, + onValueChange = { uiState.categoryContent = it }, + isError = uiState.isErrorCategory, + modifier = Modifier + .fillMaxWidth() + /*.sharedBounds( + sharedContentState = rememberSharedContentState("${Constants.KEY_TODO_CATEGORY_TRANSITION}_${toDo?.id}"), + animatedVisibilityScope = animatedVisibilityScope + )*/ + ) + // } } } diff --git a/app/src/main/kotlin/cn/super12138/todo/ui/pages/main/MainPage.kt b/app/src/main/kotlin/cn/super12138/todo/ui/pages/main/MainPage.kt index 859b7bf..92fb5bd 100644 --- a/app/src/main/kotlin/cn/super12138/todo/ui/pages/main/MainPage.kt +++ b/app/src/main/kotlin/cn/super12138/todo/ui/pages/main/MainPage.kt @@ -160,8 +160,8 @@ fun MainPage( } }, selectedTodoIds = selectedTodoIds, - sharedTransitionScope = sharedTransitionScope, - animatedVisibilityScope = animatedVisibilityScope, + // sharedTransitionScope = sharedTransitionScope, + // animatedVisibilityScope = animatedVisibilityScope, modifier = Modifier .weight(3f) .fillMaxSize() @@ -203,8 +203,8 @@ fun MainPage( } }, selectedTodoIds = selectedTodoIds, - sharedTransitionScope = sharedTransitionScope, - animatedVisibilityScope = animatedVisibilityScope, + // sharedTransitionScope = sharedTransitionScope, + // animatedVisibilityScope = animatedVisibilityScope, modifier = Modifier .weight(3f) .fillMaxSize() diff --git a/app/src/main/kotlin/cn/super12138/todo/ui/pages/main/ManagerFragment.kt b/app/src/main/kotlin/cn/super12138/todo/ui/pages/main/ManagerFragment.kt index 0c57b44..0449b24 100644 --- a/app/src/main/kotlin/cn/super12138/todo/ui/pages/main/ManagerFragment.kt +++ b/app/src/main/kotlin/cn/super12138/todo/ui/pages/main/ManagerFragment.kt @@ -1,8 +1,6 @@ package cn.super12138.todo.ui.pages.main -import androidx.compose.animation.AnimatedVisibilityScope import androidx.compose.animation.ExperimentalSharedTransitionApi -import androidx.compose.animation.SharedTransitionScope import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding @@ -33,8 +31,8 @@ fun ManagerFragment( onItemLongClick: (TodoEntity) -> Unit = {}, onItemChecked: (TodoEntity) -> Unit = {}, selectedTodoIds: List, - sharedTransitionScope: SharedTransitionScope, - animatedVisibilityScope: AnimatedVisibilityScope + // sharedTransitionScope: SharedTransitionScope, + // animatedVisibilityScope: AnimatedVisibilityScope ) { LazyColumnCustomScrollBar( state = state, @@ -64,7 +62,7 @@ fun ManagerFragment( key = { it.id } ) { item -> TodoCard( - id = item.id, + // id = item.id, content = item.content, category = item.category, completed = item.isCompleted, @@ -73,8 +71,8 @@ fun ManagerFragment( onCardClick = { onItemClick(item) }, onCardLongClick = { onItemLongClick(item) }, onChecked = { onItemChecked(item) }, - sharedTransitionScope = sharedTransitionScope, - animatedVisibilityScope = animatedVisibilityScope, + // sharedTransitionScope = sharedTransitionScope, + // animatedVisibilityScope = animatedVisibilityScope, modifier = Modifier .padding(vertical = 5.dp) .animateItem() // TODO: 设置动画时间 diff --git a/app/src/main/kotlin/cn/super12138/todo/ui/pages/main/components/TodoCard.kt b/app/src/main/kotlin/cn/super12138/todo/ui/pages/main/components/TodoCard.kt index 2c35b61..079ed00 100644 --- a/app/src/main/kotlin/cn/super12138/todo/ui/pages/main/components/TodoCard.kt +++ b/app/src/main/kotlin/cn/super12138/todo/ui/pages/main/components/TodoCard.kt @@ -1,9 +1,7 @@ package cn.super12138.todo.ui.pages.main.components import androidx.compose.animation.AnimatedVisibility -import androidx.compose.animation.AnimatedVisibilityScope import androidx.compose.animation.ExperimentalSharedTransitionApi -import androidx.compose.animation.SharedTransitionScope import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background import androidx.compose.foundation.basicMarquee @@ -38,7 +36,6 @@ import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import cn.super12138.todo.R -import cn.super12138.todo.constants.Constants import cn.super12138.todo.logic.model.Priority import cn.super12138.todo.ui.TodoDefaults import cn.super12138.todo.utils.VibrationUtils @@ -47,7 +44,7 @@ import cn.super12138.todo.utils.VibrationUtils @Composable fun TodoCard( modifier: Modifier = Modifier, - id: Int, + // id: Int, content: String, category: String, completed: Boolean, @@ -56,8 +53,8 @@ fun TodoCard( onCardClick: () -> Unit = {}, onCardLongClick: () -> Unit = {}, onChecked: () -> Unit = {}, - sharedTransitionScope: SharedTransitionScope, - animatedVisibilityScope: AnimatedVisibilityScope + // sharedTransitionScope: SharedTransitionScope, + // animatedVisibilityScope: AnimatedVisibilityScope ) { val view = LocalView.current val context = LocalContext.current @@ -122,7 +119,7 @@ fun TodoCard( } } ) { - with(sharedTransitionScope) { + // with(sharedTransitionScope) { Text( text = content, style = MaterialTheme.typography.titleLarge, @@ -130,27 +127,27 @@ fun TodoCard( overflow = TextOverflow.Ellipsis, textDecoration = if (completed) TextDecoration.LineThrough else TextDecoration.None, modifier = Modifier - .sharedBounds( + /*.sharedBounds( sharedContentState = rememberSharedContentState("${Constants.KEY_TODO_CONTENT_TRANSITION}_$id"), animatedVisibilityScope = animatedVisibilityScope - ) + )*/ .basicMarquee() // TODO: 后续评估性能影响 ) - } + // } } - with(sharedTransitionScope) { + // with(sharedTransitionScope) { Text( - text = category, + text = category.ifEmpty { stringResource(R.string.tip_default_category) }, style = MaterialTheme.typography.labelMedium, textDecoration = if (completed) TextDecoration.LineThrough else TextDecoration.None, maxLines = 1, - modifier = Modifier.sharedBounds( + /*modifier = Modifier.sharedBounds( sharedContentState = rememberSharedContentState("${Constants.KEY_TODO_CATEGORY_TRANSITION}_$id"), animatedVisibilityScope = animatedVisibilityScope - ) + )*/ ) - } + // } } AnimatedVisibility(!selected && !completed) { diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 04fba0a..3fa491f 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -110,4 +110,6 @@ 当前暂无自定义分类,你可以在设置中添加分类 当前暂无自定义分类 + 默认分类,请修改 + 自定义 \ 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 67dcd2b..1806a66 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -111,4 +111,6 @@ There are currently no custom categories. You can add categories in the settings. There are no custom categories at the moment. + Default Category, please modify + Customization \ No newline at end of file