diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 5aa190d..b8a899b 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -20,7 +20,7 @@ android { minSdk = 24 targetSdk = 34 // 版本号为x.y.z则versionCode为x*1000000+y*10000+z*100+debug版本号(开发需要时迭代, 两位数) - versionCode = 1_00_00_001 + versionCode = 1_00_00_002 versionName = "1.0.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/kotlin/indi/dmzz_yyhyy/lightnovelreader/data/userdata/UserData.kt b/app/src/main/kotlin/indi/dmzz_yyhyy/lightnovelreader/data/userdata/UserData.kt index 130b50b..b492f04 100644 --- a/app/src/main/kotlin/indi/dmzz_yyhyy/lightnovelreader/data/userdata/UserData.kt +++ b/app/src/main/kotlin/indi/dmzz_yyhyy/lightnovelreader/data/userdata/UserData.kt @@ -25,7 +25,6 @@ abstract class UserData ( abstract fun get(): T? abstract fun getFlow(): Flow fun getFlowWithDefault(default: T): Flow = getFlow().map { it ?: default } - .map { println("${this.path}: $it");it } /** * 此函数为阻塞函数,请务必不要在初始化阶段或主线程上调用 */ diff --git a/app/src/main/kotlin/indi/dmzz_yyhyy/lightnovelreader/ui/book/content/ContentScreen.kt b/app/src/main/kotlin/indi/dmzz_yyhyy/lightnovelreader/ui/book/content/ContentScreen.kt index 5606804..7f64576 100644 --- a/app/src/main/kotlin/indi/dmzz_yyhyy/lightnovelreader/ui/book/content/ContentScreen.kt +++ b/app/src/main/kotlin/indi/dmzz_yyhyy/lightnovelreader/ui/book/content/ContentScreen.kt @@ -177,6 +177,7 @@ fun Content( onPauseOrDispose { isRunning = false viewModel.updateTotalReadingTime(bookId, totalReadingTime) + totalReadingTime = 0 } } LaunchedEffect(viewModel.settingState.keepScreenOn) { @@ -188,6 +189,10 @@ fun Content( LaunchedEffect(isRunning) { while (isRunning) { totalReadingTime += 1 + if (totalReadingTime > 300) { + viewModel.updateTotalReadingTime(bookId, totalReadingTime) + totalReadingTime = 0 + } delay(1000) } } diff --git a/app/src/main/kotlin/indi/dmzz_yyhyy/lightnovelreader/ui/book/content/ContentViewModel.kt b/app/src/main/kotlin/indi/dmzz_yyhyy/lightnovelreader/ui/book/content/ContentViewModel.kt index fd36f6e..35433be 100644 --- a/app/src/main/kotlin/indi/dmzz_yyhyy/lightnovelreader/ui/book/content/ContentViewModel.kt +++ b/app/src/main/kotlin/indi/dmzz_yyhyy/lightnovelreader/ui/book/content/ContentViewModel.kt @@ -127,6 +127,8 @@ class ContentViewModel @Inject constructor( } fun updateTotalReadingTime(bookId: Int, totalReadingTime: Int) { + println("wasdsfafdasfasdf") + println(totalReadingTime) viewModelScope.launch(Dispatchers.IO) { bookRepository.updateUserReadingData(bookId) { it.copy( diff --git a/app/src/main/kotlin/indi/dmzz_yyhyy/lightnovelreader/ui/components/Dialog.kt b/app/src/main/kotlin/indi/dmzz_yyhyy/lightnovelreader/ui/components/Dialog.kt index 102f783..19481e6 100644 --- a/app/src/main/kotlin/indi/dmzz_yyhyy/lightnovelreader/ui/components/Dialog.kt +++ b/app/src/main/kotlin/indi/dmzz_yyhyy/lightnovelreader/ui/components/Dialog.kt @@ -376,7 +376,7 @@ fun ExportDialog( title = "书架", supportingText = "包括书架及书本信息", checked = mutableExportContext.bookshelf, - onCheckedChange = { mutableExportContext.bookshelf = it;println(it) } + onCheckedChange = { mutableExportContext.bookshelf = it } ) HorizontalDivider(Modifier.padding(horizontal = 14.dp)) CheckBoxListItem( diff --git a/app/src/main/kotlin/indi/dmzz_yyhyy/lightnovelreader/utils/TimeFormer.kt b/app/src/main/kotlin/indi/dmzz_yyhyy/lightnovelreader/utils/TimeFormer.kt index a8b27af..a35ae17 100644 --- a/app/src/main/kotlin/indi/dmzz_yyhyy/lightnovelreader/utils/TimeFormer.kt +++ b/app/src/main/kotlin/indi/dmzz_yyhyy/lightnovelreader/utils/TimeFormer.kt @@ -3,22 +3,39 @@ package indi.dmzz_yyhyy.lightnovelreader.utils import android.annotation.SuppressLint import java.time.LocalDateTime import java.time.format.DateTimeFormatter +import java.util.* @SuppressLint("NewApi") fun formTime(time: LocalDateTime): String { val now = LocalDateTime.now() + val yearDiff = now.year - time.year + val monthDiff = now.monthValue - time.monthValue val dayDiff = now.dayOfYear - time.dayOfYear val hourDiff = now.hour - time.hour val minuteDiff = now.minute - time.minute return when { time == LocalDateTime.MIN -> "从未" - time.isAfter(now) -> { - val formatter = DateTimeFormatter.ofPattern("MM/dd HH:mm") - time.format(formatter) - } - time.year < now.year -> "去年" + yearDiff > 1 -> + if (Locale.getDefault().language.equals(Locale.CHINESE.language)) + DateTimeFormatter + .ofPattern("uuuu年 MMM d日", Locale.CHINESE) + .format(time) + else + DateTimeFormatter + .ofPattern("d MMM uuuu", Locale.ENGLISH) + .format(time) + yearDiff == 1 -> "去年" + (dayDiff > 3 || monthDiff > 1) -> + if (Locale.getDefault().language.equals(Locale.CHINESE.language)) + DateTimeFormatter + .ofPattern("MMM d日", Locale.CHINESE) + .format(time) + else + DateTimeFormatter + .ofPattern("d MMM", Locale.ENGLISH) + .format(time) dayDiff in 1..3 -> { val prefix = when (dayDiff) { 1 -> "昨天" @@ -33,8 +50,8 @@ fun formTime(time: LocalDateTime): String { } } hourDiff in 1..24 -> "$hourDiff 小时前" - minuteDiff == 0 -> "刚刚" minuteDiff in 1 until 60 -> "$minuteDiff 分钟前" - else -> "很久之前" + minuteDiff == 0 -> "刚刚" + else -> "很久以前" } } \ No newline at end of file