diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index e1c054a5..81e445cd 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -22,7 +22,7 @@ android {
minSdk = 24
targetSdk = 35
versionCode = 22
- versionName = "2.1-alpha16"
+ versionName = "2.1-alpha17"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
diff --git a/app/src/main/java/com/skyd/anivu/model/worker/download/DownloadTorrentWorker.kt b/app/src/main/java/com/skyd/anivu/model/worker/download/DownloadTorrentWorker.kt
index d14195fd..749dea73 100644
--- a/app/src/main/java/com/skyd/anivu/model/worker/download/DownloadTorrentWorker.kt
+++ b/app/src/main/java/com/skyd/anivu/model/worker/download/DownloadTorrentWorker.kt
@@ -10,7 +10,6 @@ import android.os.Build
import android.util.Log
import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
-import androidx.core.app.TaskStackBuilder
import androidx.core.net.toUri
import androidx.work.CoroutineWorker
import androidx.work.ExistingWorkPolicy
@@ -286,8 +285,7 @@ class DownloadTorrentWorker(context: Context, parameters: WorkerParameters) :
private fun createForegroundInfo(): ForegroundInfo {
val title = name.ifNullOfBlank { applicationContext.getString(R.string.downloading) }
// This PendingIntent can be used to cancel the worker
- val cancelIntent = WorkManager.getInstance(applicationContext)
- .createCancelPendingIntent(id)
+ val cancelIntent = WorkManager.getInstance(applicationContext).createCancelPendingIntent(id)
val contentIntent = PendingIntent.getActivity(
applicationContext,
0,
@@ -335,7 +333,9 @@ class DownloadTorrentWorker(context: Context, parameters: WorkerParameters) :
@RequiresApi(Build.VERSION_CODES.O)
private fun createChannel() {
val channel = NotificationChannel(
- CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_LOW
+ CHANNEL_ID,
+ applicationContext.getString(R.string.torrent_download_channel_name),
+ NotificationManager.IMPORTANCE_LOW,
)
notificationManager.createNotificationChannel(channel)
}
@@ -527,7 +527,6 @@ class DownloadTorrentWorker(context: Context, parameters: WorkerParameters) :
const val STATE = "state"
const val TORRENT_LINK_UUID = "torrentLinkUuid"
const val CHANNEL_ID = "downloadTorrent"
- const val CHANNEL_NAME = "downloadMessage"
private val coroutineScope = CoroutineScope(Dispatchers.IO)
diff --git a/app/src/main/java/com/skyd/anivu/ui/component/Toast.kt b/app/src/main/java/com/skyd/anivu/ui/component/Toast.kt
index a3959819..c8c27042 100644
--- a/app/src/main/java/com/skyd/anivu/ui/component/Toast.kt
+++ b/app/src/main/java/com/skyd/anivu/ui/component/Toast.kt
@@ -1,16 +1,26 @@
package com.skyd.anivu.ui.component
-import android.os.Handler
-import android.os.Looper
import android.widget.Toast
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
import com.skyd.anivu.appContext
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
-private var uiThreadHandler: Handler = Handler(Looper.getMainLooper())
+private val scope = CoroutineScope(Dispatchers.Main.immediate)
fun CharSequence.showToast(duration: Int = Toast.LENGTH_SHORT) {
- uiThreadHandler.post {
- val toast = Toast.makeText(appContext, this, duration)
+ scope.launch {
+ val toast = Toast.makeText(appContext, this@showToast, duration)
toast.duration = duration
toast.show()
}
}
+
+@Composable
+fun Toast(vararg keys: Any?, text: CharSequence, duration: Int = Toast.LENGTH_SHORT) {
+ LaunchedEffect(*keys) {
+ text.showToast(duration)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/skyd/anivu/ui/screen/article/ArticleScreen.kt b/app/src/main/java/com/skyd/anivu/ui/screen/article/ArticleScreen.kt
index 351be0c5..bc3c26d4 100644
--- a/app/src/main/java/com/skyd/anivu/ui/screen/article/ArticleScreen.kt
+++ b/app/src/main/java/com/skyd/anivu/ui/screen/article/ArticleScreen.kt
@@ -20,6 +20,8 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyGridState
import androidx.compose.foundation.lazy.grid.rememberLazyGridState
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.ArrowUpward
import androidx.compose.material.icons.outlined.Refresh
@@ -380,6 +382,9 @@ private fun ArticleList(
key = { _, item -> (item as ArticleWithFeed).articleWithEnclosure.article.articleId },
)
} else {
- EmptyPlaceholder(contentPadding = contentPadding)
+ EmptyPlaceholder(
+ modifier = Modifier.verticalScroll(rememberScrollState()),
+ contentPadding = contentPadding,
+ )
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/skyd/anivu/ui/screen/download/DownloadItem.kt b/app/src/main/java/com/skyd/anivu/ui/screen/download/DownloadItem.kt
index b6bdc012..8aa5a003 100644
--- a/app/src/main/java/com/skyd/anivu/ui/screen/download/DownloadItem.kt
+++ b/app/src/main/java/com/skyd/anivu/ui/screen/download/DownloadItem.kt
@@ -104,9 +104,7 @@ fun DownloadItem(
}
}
- Column(
- modifier = Modifier.padding(16.dp)
- ) {
+ Column(modifier = Modifier.padding(16.dp)) {
Text(
text = data.name,
style = MaterialTheme.typography.bodyMedium,
@@ -198,7 +196,8 @@ fun DownloadItem(
ProgressIndicator(
modifier = Modifier
.padding(top = 6.dp)
- .fillMaxWidth(), data = data
+ .fillMaxWidth(),
+ data = data,
)
}
}
@@ -209,8 +208,6 @@ private fun ProgressIndicator(
data: DownloadInfoBean
) {
when (data.downloadState) {
- DownloadInfoBean.DownloadState.Seeding,
- DownloadInfoBean.DownloadState.SeedingPaused,
DownloadInfoBean.DownloadState.Downloading,
DownloadInfoBean.DownloadState.StorageMovedFailed,
DownloadInfoBean.DownloadState.ErrorPaused,
@@ -219,6 +216,8 @@ private fun ProgressIndicator(
}
DownloadInfoBean.DownloadState.Init -> LinearProgressIndicator(modifier = modifier)
+ DownloadInfoBean.DownloadState.Seeding,
+ DownloadInfoBean.DownloadState.SeedingPaused,
DownloadInfoBean.DownloadState.Completed -> LinearProgressIndicator(
modifier = modifier,
progress = { 1f },
diff --git a/app/src/main/java/com/skyd/anivu/ui/screen/feed/FeedScreen.kt b/app/src/main/java/com/skyd/anivu/ui/screen/feed/FeedScreen.kt
index e8cd4311..d295f402 100644
--- a/app/src/main/java/com/skyd/anivu/ui/screen/feed/FeedScreen.kt
+++ b/app/src/main/java/com/skyd/anivu/ui/screen/feed/FeedScreen.kt
@@ -83,6 +83,7 @@ import com.skyd.anivu.ui.component.AniVuIconButton
import com.skyd.anivu.ui.component.AniVuTopBar
import com.skyd.anivu.ui.component.AniVuTopBarStyle
import com.skyd.anivu.ui.component.ClipboardTextField
+import com.skyd.anivu.ui.component.Toast
import com.skyd.anivu.ui.component.dialog.AniVuDialog
import com.skyd.anivu.ui.component.dialog.TextFieldDialog
import com.skyd.anivu.ui.component.dialog.WaitingDialog
@@ -285,32 +286,17 @@ private fun FeedList(
is FeedEvent.AddFeedResultEvent.Failed ->
snackbarHostState.showSnackbarWithLaunchedEffect(message = event.msg, key1 = event)
- is FeedEvent.EditFeedResultEvent.Failed ->
- snackbarHostState.showSnackbarWithLaunchedEffect(message = event.msg, key1 = event)
-
is FeedEvent.InitFeetListResultEvent.Failed ->
snackbarHostState.showSnackbarWithLaunchedEffect(message = event.msg, key1 = event)
- is FeedEvent.RemoveFeedResultEvent.Failed ->
- snackbarHostState.showSnackbarWithLaunchedEffect(message = event.msg, key1 = event)
-
- is FeedEvent.RefreshFeedResultEvent.Failed ->
- snackbarHostState.showSnackbarWithLaunchedEffect(message = event.msg, key1 = event)
-
- is FeedEvent.CreateGroupResultEvent.Failed ->
- snackbarHostState.showSnackbarWithLaunchedEffect(message = event.msg, key1 = event)
-
- is FeedEvent.MoveFeedsToGroupResultEvent.Failed ->
- snackbarHostState.showSnackbarWithLaunchedEffect(message = event.msg, key1 = event)
-
- is FeedEvent.DeleteGroupResultEvent.Failed ->
- snackbarHostState.showSnackbarWithLaunchedEffect(message = event.msg, key1 = event)
-
- is FeedEvent.EditGroupResultEvent.Failed ->
- snackbarHostState.showSnackbarWithLaunchedEffect(message = event.msg, key1 = event)
-
- is FeedEvent.ReadAllResultEvent.Failed ->
- snackbarHostState.showSnackbarWithLaunchedEffect(message = event.msg, key1 = event)
+ is FeedEvent.EditFeedResultEvent.Failed -> Toast(event, text = event.msg)
+ is FeedEvent.RemoveFeedResultEvent.Failed -> Toast(event, text = event.msg)
+ is FeedEvent.RefreshFeedResultEvent.Failed -> Toast(event, text = event.msg)
+ is FeedEvent.CreateGroupResultEvent.Failed -> Toast(event, text = event.msg)
+ is FeedEvent.MoveFeedsToGroupResultEvent.Failed -> Toast(event, text = event.msg)
+ is FeedEvent.DeleteGroupResultEvent.Failed -> Toast(event, text = event.msg)
+ is FeedEvent.EditGroupResultEvent.Failed -> Toast(event, text = event.msg)
+ is FeedEvent.ReadAllResultEvent.Failed -> Toast(event, text = event.msg)
is FeedEvent.EditFeedResultEvent.Success -> LaunchedEffect(event) {
if (openEditFeedDialog != null) openEditFeedDialog = event.feed
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index 29534d1a..cba6f274 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -313,6 +313,7 @@
缓存
最大前向缓存大小
最大保留缓存大小
+ 下载任务
- 已读 %d 项
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index f1d7d1e3..3451e3a3 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -320,6 +320,7 @@
Cache
Max cache size
Max back cache size
+ Download task
- Read %d item
- Read %d items