Update to SDK 29 (Android 10) (#2468)

This commit is contained in:
arkon 2020-01-09 20:31:27 -05:00 committed by GitHub
parent f7669b6797
commit 83d5e458ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 34 additions and 24 deletions

View file

@ -3,7 +3,7 @@ language: android
android: android:
components: components:
- build-tools-29.0.2 - build-tools-29.0.2
- android-28 - android-29
- extra-android-m2repository - extra-android-m2repository
- extra-google-m2repository - extra-google-m2repository
- extra-android-support - extra-android-support
@ -11,7 +11,7 @@ android:
licenses: licenses:
- android-sdk-license-.+ - android-sdk-license-.+
before_install: 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 - 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; 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; tar xf secrets.tar;

View file

@ -29,14 +29,14 @@ ext {
} }
android { android {
compileSdkVersion 28 compileSdkVersion 29
buildToolsVersion '29.0.2' buildToolsVersion '29.0.2'
publishNonDefault true publishNonDefault true
defaultConfig { defaultConfig {
applicationId "eu.kanade.tachiyomi" applicationId "eu.kanade.tachiyomi"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 28 targetSdkVersion 29
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
versionCode 41 versionCode 41
versionName "0.8.4" versionName "0.8.4"

View file

@ -189,7 +189,7 @@ class BackupRestoreService : Service() {
return Observable.just(Unit) return Observable.just(Unit)
.map { .map {
val reader = JsonReader(contentResolver.openInputStream(uri).bufferedReader()) val reader = JsonReader(contentResolver.openInputStream(uri)!!.bufferedReader())
val json = JsonParser().parse(reader).asJsonObject val json = JsonParser().parse(reader).asJsonObject
// Get parser version // Get parser version

View file

@ -22,7 +22,7 @@ class LibraryUpdateJob : Job() {
val preferences = Injekt.get<PreferencesHelper>() val preferences = Injekt.get<PreferencesHelper>()
val interval = prefInterval ?: preferences.libraryUpdateInterval().getOrDefault() val interval = prefInterval ?: preferences.libraryUpdateInterval().getOrDefault()
if (interval > 0) { if (interval > 0) {
val restrictions = preferences.libraryUpdateRestriction() val restrictions = preferences.libraryUpdateRestriction()!!
val acRestriction = "ac" in restrictions val acRestriction = "ac" in restrictions
val wifiRestriction = if ("wifi" in restrictions) val wifiRestriction = if ("wifi" in restrictions)
JobRequest.NetworkType.UNMETERED JobRequest.NetworkType.UNMETERED

View file

@ -38,7 +38,7 @@ abstract class DialogController : RestoreViewOnCreateController {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup, savedViewState: Bundle?): View { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup, savedViewState: Bundle?): View {
dialog = onCreateDialog(savedViewState) dialog = onCreateDialog(savedViewState)
dialog!!.ownerActivity = activity dialog!!.setOwnerActivity(activity!!)
dialog!!.setOnDismissListener { dismissDialog() } dialog!!.setOnDismissListener { dismissDialog() }
if (savedViewState != null) { if (savedViewState != null) {
val dialogState = savedViewState.getBundle(SAVED_DIALOG_STATE_TAG) val dialogState = savedViewState.getBundle(SAVED_DIALOG_STATE_TAG)

View file

@ -4,6 +4,7 @@ import android.app.Activity
import android.content.Intent import android.content.Intent
import android.content.res.Configuration import android.content.res.Configuration
import android.graphics.Color import android.graphics.Color
import android.net.Uri
import android.os.Bundle import android.os.Bundle
import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout
import androidx.core.graphics.drawable.DrawableCompat import androidx.core.graphics.drawable.DrawableCompat
@ -498,9 +499,9 @@ class LibraryController(
try { try {
// Get the file's input stream from the incoming Intent // 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 // 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 // TODO refresh cover
} else { } else {
activity.toast(R.string.notification_cover_update_failed) activity.toast(R.string.notification_cover_update_failed)

View file

@ -512,7 +512,7 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
val view = view ?: return val view = view ?: return
val clipboard = activity.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager 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)), activity.toast(view.context.getString(R.string.copied_to_clipboard, content.truncateCenter(20)),
Toast.LENGTH_SHORT) Toast.LENGTH_SHORT)

View file

@ -19,7 +19,7 @@ class TrackSearchAdapter(context: Context)
override fun getView(position: Int, view: View?, parent: ViewGroup): View { override fun getView(position: Int, view: View?, parent: ViewGroup): View {
var v = view var v = view
// Get the data item for this position // 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 // Check if an existing view is being reused, otherwise inflate the view
val holder: TrackSearchHolder // view lookup cache stored in tag val holder: TrackSearchHolder // view lookup cache stored in tag
if (v == null) { if (v == null) {

View file

@ -1,6 +1,7 @@
package eu.kanade.tachiyomi.ui.reader.loader package eu.kanade.tachiyomi.ui.reader.loader
import android.app.Application import android.app.Application
import android.net.Uri
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.download.DownloadManager import eu.kanade.tachiyomi.data.download.DownloadManager
import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.Source
@ -33,7 +34,7 @@ class DownloadPageLoader(
.map { pages -> .map { pages ->
pages.map { page -> pages.map { page ->
ReaderPage(page.index, page.url, page.imageUrl) { ReaderPage(page.index, page.url, page.imageUrl) {
context.contentResolver.openInputStream(page.uri) context.contentResolver.openInputStream(page.uri ?: Uri.EMPTY)!!
}.apply { }.apply {
status = Page.READY status = Page.READY
} }

View file

@ -148,7 +148,9 @@ class SettingsBackupController : SettingsController() {
val flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or val flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or
Intent.FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION
if (uri != null) {
activity.contentResolver.takePersistableUriPermission(uri, flags) activity.contentResolver.takePersistableUriPermission(uri, flags)
}
// Set backup Uri // Set backup Uri
preferences.backupsDirectory().set(uri.toString()) preferences.backupsDirectory().set(uri.toString())
@ -160,7 +162,10 @@ class SettingsBackupController : SettingsController() {
val flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or val flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or
Intent.FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION
if (uri != null) {
activity.contentResolver.takePersistableUriPermission(uri, flags) activity.contentResolver.takePersistableUriPermission(uri, flags)
}
val file = UniFile.fromUri(activity, uri) val file = UniFile.fromUri(activity, uri)
CreatingBackupDialog().showDialog(router, TAG_CREATING_BACKUP_DIALOG) CreatingBackupDialog().showDialog(router, TAG_CREATING_BACKUP_DIALOG)
@ -168,10 +173,12 @@ class SettingsBackupController : SettingsController() {
} }
CODE_BACKUP_RESTORE -> if (data != null && resultCode == Activity.RESULT_OK) { CODE_BACKUP_RESTORE -> if (data != null && resultCode == Activity.RESULT_OK) {
val uri = data.data val uri = data.data
if (uri != null) {
RestoreBackupDialog(uri).showDialog(router) RestoreBackupDialog(uri).showDialog(router)
} }
} }
} }
}
fun createBackup(flags: Int) { fun createBackup(flags: Int) {
backupFlags = flags backupFlags = flags
@ -283,7 +290,7 @@ class SettingsBackupController : SettingsController() {
val context = applicationContext val context = applicationContext
if (context != null) { if (context != null) {
RestoringBackupDialog().showDialog(router, TAG_RESTORING_BACKUP_DIALOG) RestoringBackupDialog().showDialog(router, TAG_RESTORING_BACKUP_DIALOG)
BackupRestoreService.start(context, args.getParcelable(KEY_URI)) BackupRestoreService.start(context, args.getParcelable(KEY_URI)!!)
} }
} }
.build() .build()
@ -357,7 +364,7 @@ class SettingsBackupController : SettingsController() {
.negativeText(R.string.action_open_log) .negativeText(R.string.action_open_log)
.onNegative { _, _ -> .onNegative { _, _ ->
val context = applicationContext ?: return@onNegative val context = applicationContext ?: return@onNegative
if (!path.isEmpty()) { if (!path.isNullOrEmpty()) {
val destFile = File(path, file) val destFile = File(path, file)
val uri = destFile.getUriCompat(context) val uri = destFile.getUriCompat(context)
val sendIntent = Intent(Intent.ACTION_VIEW).apply { val sendIntent = Intent(Intent.ACTION_VIEW).apply {

View file

@ -112,8 +112,10 @@ class SettingsDownloadController : SettingsController() {
val flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or val flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or
Intent.FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION
if (uri != null) {
@Suppress("NewApi") @Suppress("NewApi")
context.contentResolver.takePersistableUriPermission(uri, flags) context.contentResolver.takePersistableUriPermission(uri, flags)
}
val file = UniFile.fromUri(context, uri) val file = UniFile.fromUri(context, uri)
preferences.downloadsDirectory().set(file.uri.toString()) preferences.downloadsDirectory().set(file.uri.toString())

View file

@ -4,7 +4,6 @@ import android.app.Application
import android.content.Context import android.content.Context
import android.content.res.Configuration import android.content.res.Configuration
import android.os.Build import android.os.Build
import android.os.LocaleList
import android.view.ContextThemeWrapper import android.view.ContextThemeWrapper
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
@ -43,7 +42,7 @@ object LocaleHelper {
* *
* @param pref the string value stored in preferences. * @param pref the string value stored in preferences.
*/ */
fun getLocaleFromString(pref: String): Locale? { fun getLocaleFromString(pref: String?): Locale? {
if (pref.isNullOrEmpty()) { if (pref.isNullOrEmpty()) {
return null return null
} }
@ -138,7 +137,7 @@ object LocaleHelper {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
newConfig.locale = locale newConfig.locale = locale
} else { } else {
newConfig.locales = LocaleList(locale) newConfig.setLocale(locale)
} }
return newConfig return newConfig
} }