diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 34c57bb7b..ca5b1e976 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -354,6 +354,7 @@
+
diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt
index 98f255c72..37aea552d 100644
--- a/app/src/main/java/io/legado/app/App.kt
+++ b/app/src/main/java/io/legado/app/App.kt
@@ -156,7 +156,7 @@ class App : MultiDexApplication() {
//用唯一的ID创建渠道对象
val downloadChannel = NotificationChannel(
channelIdDownload,
- getString(R.string.offline_cache),
+ getString(R.string.action_download),
NotificationManager.IMPORTANCE_LOW
)
//初始化channel
diff --git a/app/src/main/java/io/legado/app/service/CheckSourceService.kt b/app/src/main/java/io/legado/app/service/CheckSourceService.kt
index e6cbb5966..09900d0d0 100644
--- a/app/src/main/java/io/legado/app/service/CheckSourceService.kt
+++ b/app/src/main/java/io/legado/app/service/CheckSourceService.kt
@@ -24,6 +24,21 @@ class CheckSourceService : BaseService() {
private val allIds = ArrayList()
private val checkedIds = ArrayList()
private var processIndex = 0
+ private val notificationBuilder by lazy {
+ NotificationCompat.Builder(this, AppConst.channelIdReadAloud)
+ .setSmallIcon(R.drawable.ic_network_check)
+ .setOngoing(true)
+ .setContentTitle(getString(R.string.check_book_source))
+ .setContentIntent(
+ IntentHelp.activityPendingIntent(this, "activity")
+ )
+ .addAction(
+ R.drawable.ic_stop_black_24dp,
+ getString(R.string.cancel),
+ IntentHelp.servicePendingIntent(this, IntentAction.stop)
+ )
+ .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
+ }
override fun onCreate() {
super.onCreate()
@@ -105,23 +120,9 @@ class CheckSourceService : BaseService() {
* 更新通知
*/
private fun updateNotification(state: Int, msg: String) {
- val builder = NotificationCompat.Builder(this, AppConst.channelIdReadAloud)
- .setSmallIcon(R.drawable.ic_network_check)
- .setOngoing(true)
- .setContentTitle(getString(R.string.check_book_source))
- .setContentText(msg)
- .setContentIntent(
- IntentHelp.activityPendingIntent(this, "activity")
- )
- .addAction(
- R.drawable.ic_stop_black_24dp,
- getString(R.string.cancel),
- IntentHelp.servicePendingIntent(this, IntentAction.stop)
- )
- builder.setProgress(allIds.size, state, false)
- builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
- val notification = builder.build()
- startForeground(112202, notification)
+ notificationBuilder.setContentText(msg)
+ notificationBuilder.setProgress(allIds.size, state, false)
+ startForeground(112202, notificationBuilder.build())
}
}
\ No newline at end of file
diff --git a/app/src/main/java/io/legado/app/service/DownloadService.kt b/app/src/main/java/io/legado/app/service/DownloadService.kt
new file mode 100644
index 000000000..7a77bb7a5
--- /dev/null
+++ b/app/src/main/java/io/legado/app/service/DownloadService.kt
@@ -0,0 +1,46 @@
+package io.legado.app.service
+
+import android.content.Intent
+import androidx.core.app.NotificationCompat
+import io.legado.app.R
+import io.legado.app.base.BaseService
+import io.legado.app.constant.AppConst
+import io.legado.app.constant.IntentAction
+import io.legado.app.help.IntentHelp
+
+class DownloadService : BaseService() {
+
+ private val notificationBuilder by lazy {
+ val builder = NotificationCompat.Builder(this, AppConst.channelIdDownload)
+ .setSmallIcon(R.drawable.ic_download)
+ .setOngoing(true)
+ .setContentTitle(getString(R.string.action_download))
+ builder.addAction(
+ R.drawable.ic_stop_black_24dp,
+ getString(R.string.cancel),
+ IntentHelp.servicePendingIntent(this, IntentAction.stop)
+ )
+ builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
+ }
+
+ override fun onCreate() {
+ super.onCreate()
+ updateNotification("准备下载")
+ }
+
+ override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
+ when (intent?.action) {
+
+ }
+ return super.onStartCommand(intent, flags, startId)
+ }
+
+ /**
+ * 更新通知
+ */
+ private fun updateNotification(content: String) {
+ notificationBuilder.setContentText(content)
+ val notification = notificationBuilder.build()
+ startForeground(AppConst.notificationIdDownload, notification)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
index 59422c186..07f959719 100644
--- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
@@ -24,9 +24,6 @@ import io.legado.app.constant.AppPattern
import io.legado.app.data.entities.BookSource
import io.legado.app.help.IntentDataHelp
import io.legado.app.lib.dialogs.*
-import io.legado.app.lib.dialogs.alert
-import io.legado.app.lib.dialogs.noButton
-import io.legado.app.lib.dialogs.okButton
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.primaryTextColor
import io.legado.app.service.help.CheckSource
@@ -47,7 +44,6 @@ import kotlinx.android.synthetic.main.view_search.*
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.startActivityForResult
import org.jetbrains.anko.toast
-
import java.io.File
import java.text.Collator
@@ -212,7 +208,6 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity
else -> data.reversed()
}
}
- recycler_view.scrollToPosition(0)
val diffResult = DiffUtil
.calculateDiff(DiffCallBack(ArrayList(adapter.getItems()), sourceList))
adapter.setItems(sourceList, diffResult)