diff --git a/app/src/main/java/org/koitharu/kotatsu/ui/settings/AppUpdateService.kt b/app/src/main/java/org/koitharu/kotatsu/ui/settings/AppUpdateService.kt
index dcc563c7b..a9e523500 100644
--- a/app/src/main/java/org/koitharu/kotatsu/ui/settings/AppUpdateService.kt
+++ b/app/src/main/java/org/koitharu/kotatsu/ui/settings/AppUpdateService.kt
@@ -9,6 +9,7 @@ import android.graphics.BitmapFactory
import android.net.Uri
import android.os.Build
import androidx.core.app.NotificationCompat
+import androidx.core.content.ContextCompat
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@@ -80,8 +81,18 @@ class AppUpdateService : BaseService() {
PendingIntent.FLAG_CANCEL_CURRENT
)
)
+ builder.addAction(
+ R.drawable.ic_download, getString(R.string.download),
+ PendingIntent.getActivity(
+ this,
+ NOTIFICATION_ID + 1,
+ Intent(Intent.ACTION_VIEW, Uri.parse(newVersion.apkUrl)),
+ PendingIntent.FLAG_CANCEL_CURRENT
+ )
+ )
builder.setSmallIcon(R.drawable.ic_stat_update)
builder.setAutoCancel(true)
+ builder.setColor(ContextCompat.getColor(this, R.color.blue_primary_dark))
builder.setLargeIcon(BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher))
manager.notify(NOTIFICATION_ID, builder.build())
}
@@ -92,8 +103,12 @@ class AppUpdateService : BaseService() {
private const val CHANNEL_ID = "update"
private val PERIOD = TimeUnit.HOURS.toMillis(6)
- fun start(context: Context) =
- context.startService(Intent(context, AppUpdateService::class.java))
+ fun start(context: Context) {
+ try {
+ context.startService(Intent(context, AppUpdateService::class.java))
+ } catch (_: IllegalStateException) {
+ }
+ }
fun startIfRequired(context: Context) {
val settings = AppSettings(context)
diff --git a/app/src/main/res/drawable/ic_download.xml b/app/src/main/res/drawable/ic_download.xml
new file mode 100644
index 000000000..8bd663095
--- /dev/null
+++ b/app/src/main/res/drawable/ic_download.xml
@@ -0,0 +1,12 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index be9f73f97..a075f69fe 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -115,4 +115,5 @@
Включено %1$d из %2$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 1081697f4..210e5791c 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -116,4 +116,5 @@
Enabled %1$d from %2$d
New chapters
Notify about updates of manga you are reading
+ Download
\ No newline at end of file