diff --git a/.travis.yml b/.travis.yml index edfc5a7c0f..4d33cff050 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: android android: components: - build-tools-29.0.2 - - android-28 + - android-29 - extra-android-m2repository - extra-google-m2repository - extra-android-support @@ -11,7 +11,7 @@ android: licenses: - android-sdk-license-.+ before_install: -- yes | sdkmanager "platforms;android-28" # workaround for accepting the license +- yes | sdkmanager "platforms;android-29" # workaround for accepting the license - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then openssl aes-256-cbc -K $encrypted_e56be693d4fd_key -iv $encrypted_e56be693d4fd_iv -in "$PWD/.travis/secrets.tar.enc" -out secrets.tar -d; tar xf secrets.tar; diff --git a/app/build.gradle b/app/build.gradle index 53b39b8765..e37db38362 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -29,14 +29,14 @@ ext { } android { - compileSdkVersion 28 + compileSdkVersion 29 buildToolsVersion '29.0.2' publishNonDefault true defaultConfig { applicationId "eu.kanade.tachiyomi" minSdkVersion 21 - targetSdkVersion 28 + targetSdkVersion 29 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" versionCode 41 versionName "0.8.4" diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt index db6866e289..87701c20d9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt @@ -189,7 +189,7 @@ class BackupRestoreService : Service() { return Observable.just(Unit) .map { - val reader = JsonReader(contentResolver.openInputStream(uri).bufferedReader()) + val reader = JsonReader(contentResolver.openInputStream(uri)!!.bufferedReader()) val json = JsonParser().parse(reader).asJsonObject // Get parser version diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt index ab386b1330..1b992850a8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt @@ -22,7 +22,7 @@ class LibraryUpdateJob : Job() { val preferences = Injekt.get() val interval = prefInterval ?: preferences.libraryUpdateInterval().getOrDefault() if (interval > 0) { - val restrictions = preferences.libraryUpdateRestriction() + val restrictions = preferences.libraryUpdateRestriction()!! val acRestriction = "ac" in restrictions val wifiRestriction = if ("wifi" in restrictions) JobRequest.NetworkType.UNMETERED @@ -44,4 +44,4 @@ class LibraryUpdateJob : Job() { JobManager.instance().cancelAllForTag(TAG) } } -} \ No newline at end of file +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/DialogController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/DialogController.kt index 7d59b864c9..fafdbe1605 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/DialogController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/DialogController.kt @@ -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) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index dd95147fd3..e3e8edc274 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -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) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt index 7410e788e3..221eae06ae 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt @@ -512,7 +512,7 @@ class MangaInfoController : NucleusController(), 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) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchAdapter.kt index 930651270d..9fde89cd3c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchAdapter.kt @@ -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) } } } -} \ No newline at end of file +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/DownloadPageLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/DownloadPageLoader.kt index 6a207502af..d3d7953be9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/DownloadPageLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/DownloadPageLoader.kt @@ -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 } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt index 536721c8cb..2f31da321c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt @@ -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 { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt index 42c19f7baa..51e313e3c9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt @@ -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()) diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/LocaleHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/util/LocaleHelper.kt index 94a8e3a6ef..a9ec6b25d3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/LocaleHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/LocaleHelper.kt @@ -4,7 +4,6 @@ import android.app.Application import android.content.Context import android.content.res.Configuration import android.os.Build -import android.os.LocaleList import android.view.ContextThemeWrapper import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferencesHelper @@ -43,7 +42,7 @@ object LocaleHelper { * * @param pref the string value stored in preferences. */ - fun getLocaleFromString(pref: String): Locale? { + fun getLocaleFromString(pref: String?): Locale? { if (pref.isNullOrEmpty()) { return null } @@ -138,7 +137,7 @@ object LocaleHelper { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { newConfig.locale = locale } else { - newConfig.locales = LocaleList(locale) + newConfig.setLocale(locale) } return newConfig }