mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-17 14:37:29 +01:00
Update to SDK 29 (Android 10) (#2468)
This commit is contained in:
@@ -38,7 +38,7 @@ abstract class DialogController : RestoreViewOnCreateController {
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup, savedViewState: Bundle?): View {
|
||||
dialog = onCreateDialog(savedViewState)
|
||||
dialog!!.ownerActivity = activity
|
||||
dialog!!.setOwnerActivity(activity!!)
|
||||
dialog!!.setOnDismissListener { dismissDialog() }
|
||||
if (savedViewState != null) {
|
||||
val dialogState = savedViewState.getBundle(SAVED_DIALOG_STATE_TAG)
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.content.res.Configuration
|
||||
import android.graphics.Color
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import androidx.core.graphics.drawable.DrawableCompat
|
||||
@@ -498,9 +499,9 @@ class LibraryController(
|
||||
|
||||
try {
|
||||
// Get the file's input stream from the incoming Intent
|
||||
activity.contentResolver.openInputStream(data.data).use {
|
||||
activity.contentResolver.openInputStream(data.data ?: Uri.EMPTY).use {
|
||||
// Update cover to selected file, show error if something went wrong
|
||||
if (presenter.editCoverWithStream(it, manga)) {
|
||||
if (it != null && presenter.editCoverWithStream(it, manga)) {
|
||||
// TODO refresh cover
|
||||
} else {
|
||||
activity.toast(R.string.notification_cover_update_failed)
|
||||
|
||||
@@ -512,7 +512,7 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
val view = view ?: return
|
||||
|
||||
val clipboard = activity.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
clipboard.primaryClip = ClipData.newPlainText(label, content)
|
||||
clipboard.setPrimaryClip(ClipData.newPlainText(label, content))
|
||||
|
||||
activity.toast(view.context.getString(R.string.copied_to_clipboard, content.truncateCenter(20)),
|
||||
Toast.LENGTH_SHORT)
|
||||
|
||||
@@ -19,7 +19,7 @@ class TrackSearchAdapter(context: Context)
|
||||
override fun getView(position: Int, view: View?, parent: ViewGroup): View {
|
||||
var v = view
|
||||
// Get the data item for this position
|
||||
val track = getItem(position)
|
||||
val track = getItem(position)!!
|
||||
// Check if an existing view is being reused, otherwise inflate the view
|
||||
val holder: TrackSearchHolder // view lookup cache stored in tag
|
||||
if (v == null) {
|
||||
@@ -76,4 +76,4 @@ class TrackSearchAdapter(context: Context)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package eu.kanade.tachiyomi.ui.reader.loader
|
||||
|
||||
import android.app.Application
|
||||
import android.net.Uri
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
@@ -33,7 +34,7 @@ class DownloadPageLoader(
|
||||
.map { pages ->
|
||||
pages.map { page ->
|
||||
ReaderPage(page.index, page.url, page.imageUrl) {
|
||||
context.contentResolver.openInputStream(page.uri)
|
||||
context.contentResolver.openInputStream(page.uri ?: Uri.EMPTY)!!
|
||||
}.apply {
|
||||
status = Page.READY
|
||||
}
|
||||
|
||||
@@ -148,7 +148,9 @@ class SettingsBackupController : SettingsController() {
|
||||
val flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or
|
||||
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||
|
||||
activity.contentResolver.takePersistableUriPermission(uri, flags)
|
||||
if (uri != null) {
|
||||
activity.contentResolver.takePersistableUriPermission(uri, flags)
|
||||
}
|
||||
|
||||
// Set backup Uri
|
||||
preferences.backupsDirectory().set(uri.toString())
|
||||
@@ -160,7 +162,10 @@ class SettingsBackupController : SettingsController() {
|
||||
val flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or
|
||||
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||
|
||||
activity.contentResolver.takePersistableUriPermission(uri, flags)
|
||||
if (uri != null) {
|
||||
activity.contentResolver.takePersistableUriPermission(uri, flags)
|
||||
}
|
||||
|
||||
val file = UniFile.fromUri(activity, uri)
|
||||
|
||||
CreatingBackupDialog().showDialog(router, TAG_CREATING_BACKUP_DIALOG)
|
||||
@@ -168,7 +173,9 @@ class SettingsBackupController : SettingsController() {
|
||||
}
|
||||
CODE_BACKUP_RESTORE -> if (data != null && resultCode == Activity.RESULT_OK) {
|
||||
val uri = data.data
|
||||
RestoreBackupDialog(uri).showDialog(router)
|
||||
if (uri != null) {
|
||||
RestoreBackupDialog(uri).showDialog(router)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -283,7 +290,7 @@ class SettingsBackupController : SettingsController() {
|
||||
val context = applicationContext
|
||||
if (context != null) {
|
||||
RestoringBackupDialog().showDialog(router, TAG_RESTORING_BACKUP_DIALOG)
|
||||
BackupRestoreService.start(context, args.getParcelable(KEY_URI))
|
||||
BackupRestoreService.start(context, args.getParcelable(KEY_URI)!!)
|
||||
}
|
||||
}
|
||||
.build()
|
||||
@@ -357,7 +364,7 @@ class SettingsBackupController : SettingsController() {
|
||||
.negativeText(R.string.action_open_log)
|
||||
.onNegative { _, _ ->
|
||||
val context = applicationContext ?: return@onNegative
|
||||
if (!path.isEmpty()) {
|
||||
if (!path.isNullOrEmpty()) {
|
||||
val destFile = File(path, file)
|
||||
val uri = destFile.getUriCompat(context)
|
||||
val sendIntent = Intent(Intent.ACTION_VIEW).apply {
|
||||
|
||||
@@ -112,8 +112,10 @@ class SettingsDownloadController : SettingsController() {
|
||||
val flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or
|
||||
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||
|
||||
@Suppress("NewApi")
|
||||
context.contentResolver.takePersistableUriPermission(uri, flags)
|
||||
if (uri != null) {
|
||||
@Suppress("NewApi")
|
||||
context.contentResolver.takePersistableUriPermission(uri, flags)
|
||||
}
|
||||
|
||||
val file = UniFile.fromUri(context, uri)
|
||||
preferences.downloadsDirectory().set(file.uri.toString())
|
||||
|
||||
Reference in New Issue
Block a user