Upgrade targetSdk to 34
This commit is contained in:
@@ -98,11 +98,11 @@ class DownloadsActivity : BaseActivity<ActivityDownloadsBinding>(),
|
||||
}
|
||||
|
||||
override fun onPauseClick(item: DownloadItemModel) {
|
||||
sendBroadcast(PausingReceiver.getPauseIntent(item.id))
|
||||
sendBroadcast(PausingReceiver.getPauseIntent(this, item.id))
|
||||
}
|
||||
|
||||
override fun onResumeClick(item: DownloadItemModel) {
|
||||
sendBroadcast(PausingReceiver.getResumeIntent(item.id))
|
||||
sendBroadcast(PausingReceiver.getResumeIntent(this, item.id))
|
||||
}
|
||||
|
||||
override fun onSelectionChanged(controller: ListSelectionController, count: Int) {
|
||||
|
||||
@@ -2,6 +2,8 @@ package org.koitharu.kotatsu.download.ui.worker
|
||||
|
||||
import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import android.content.pm.ServiceInfo
|
||||
import android.os.Build
|
||||
import android.webkit.MimeTypeMap
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.hilt.work.HiltWorker
|
||||
@@ -130,10 +132,18 @@ class DownloadWorker @AssistedInject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getForegroundInfo() = ForegroundInfo(
|
||||
id.hashCode(),
|
||||
notificationFactory.create(lastPublishedState),
|
||||
)
|
||||
override suspend fun getForegroundInfo() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
ForegroundInfo(
|
||||
id.hashCode(),
|
||||
notificationFactory.create(lastPublishedState),
|
||||
ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC,
|
||||
)
|
||||
} else {
|
||||
ForegroundInfo(
|
||||
id.hashCode(),
|
||||
notificationFactory.create(lastPublishedState),
|
||||
)
|
||||
}
|
||||
|
||||
private suspend fun downloadMangaImpl(
|
||||
includedIds: LongArray?,
|
||||
@@ -389,12 +399,12 @@ class DownloadWorker @AssistedInject constructor(
|
||||
}
|
||||
|
||||
fun pause(id: UUID) {
|
||||
val intent = PausingReceiver.getPauseIntent(id)
|
||||
val intent = PausingReceiver.getPauseIntent(context, id)
|
||||
context.sendBroadcast(intent)
|
||||
}
|
||||
|
||||
fun resume(id: UUID) {
|
||||
val intent = PausingReceiver.getResumeIntent(id)
|
||||
val intent = PausingReceiver.getResumeIntent(context, id)
|
||||
context.sendBroadcast(intent)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,18 +40,20 @@ class PausingReceiver(
|
||||
addDataPath(id.toString(), PatternMatcher.PATTERN_SIMPLE_GLOB)
|
||||
}
|
||||
|
||||
fun getPauseIntent(id: UUID) = Intent(ACTION_PAUSE)
|
||||
fun getPauseIntent(context: Context, id: UUID) = Intent(ACTION_PAUSE)
|
||||
.setData(Uri.parse("$SCHEME://$id"))
|
||||
.setPackage(context.packageName)
|
||||
.putExtra(EXTRA_UUID, id.toString())
|
||||
|
||||
fun getResumeIntent(id: UUID) = Intent(ACTION_RESUME)
|
||||
fun getResumeIntent(context: Context, id: UUID) = Intent(ACTION_RESUME)
|
||||
.setData(Uri.parse("$SCHEME://$id"))
|
||||
.setPackage(context.packageName)
|
||||
.putExtra(EXTRA_UUID, id.toString())
|
||||
|
||||
fun createPausePendingIntent(context: Context, id: UUID) = PendingIntentCompat.getBroadcast(
|
||||
context,
|
||||
0,
|
||||
getPauseIntent(id),
|
||||
getPauseIntent(context, id),
|
||||
0,
|
||||
false,
|
||||
)
|
||||
@@ -59,7 +61,7 @@ class PausingReceiver(
|
||||
fun createResumePendingIntent(context: Context, id: UUID) = PendingIntentCompat.getBroadcast(
|
||||
context,
|
||||
0,
|
||||
getResumeIntent(id),
|
||||
getResumeIntent(context, id),
|
||||
0,
|
||||
false,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user