Use some more KTX and Compat stuff (#3933)
* Use more KTX extensions * Update Android Studio * Use more Compat classes
This commit is contained in:
parent
a689e4e041
commit
60755d0c26
29 changed files with 68 additions and 108 deletions
|
@ -4,9 +4,9 @@ import android.app.Service
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import com.hippo.unifile.UniFile
|
import com.hippo.unifile.UniFile
|
||||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||||
|
@ -52,11 +52,7 @@ class BackupCreateService : Service() {
|
||||||
putExtra(BackupConst.EXTRA_URI, uri)
|
putExtra(BackupConst.EXTRA_URI, uri)
|
||||||
putExtra(BackupConst.EXTRA_FLAGS, flags)
|
putExtra(BackupConst.EXTRA_FLAGS, flags)
|
||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
ContextCompat.startForegroundService(context, intent)
|
||||||
context.startService(intent)
|
|
||||||
} else {
|
|
||||||
context.startForegroundService(intent)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import android.app.Service
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import com.github.salomonbrys.kotson.fromJson
|
import com.github.salomonbrys.kotson.fromJson
|
||||||
import com.google.gson.JsonArray
|
import com.google.gson.JsonArray
|
||||||
import com.google.gson.JsonElement
|
import com.google.gson.JsonElement
|
||||||
|
@ -74,11 +74,7 @@ class BackupRestoreService : Service() {
|
||||||
val intent = Intent(context, BackupRestoreService::class.java).apply {
|
val intent = Intent(context, BackupRestoreService::class.java).apply {
|
||||||
putExtra(BackupConst.EXTRA_URI, uri)
|
putExtra(BackupConst.EXTRA_URI, uri)
|
||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
ContextCompat.startForegroundService(context, intent)
|
||||||
context.startService(intent)
|
|
||||||
} else {
|
|
||||||
context.startForegroundService(intent)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@ import android.content.Intent
|
||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
import android.net.NetworkInfo.State.CONNECTED
|
import android.net.NetworkInfo.State.CONNECTED
|
||||||
import android.net.NetworkInfo.State.DISCONNECTED
|
import android.net.NetworkInfo.State.DISCONNECTED
|
||||||
import android.os.Build
|
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import com.github.pwittchen.reactivenetwork.library.Connectivity
|
import com.github.pwittchen.reactivenetwork.library.Connectivity
|
||||||
import com.github.pwittchen.reactivenetwork.library.ReactiveNetwork
|
import com.github.pwittchen.reactivenetwork.library.ReactiveNetwork
|
||||||
import com.jakewharton.rxrelay.BehaviorRelay
|
import com.jakewharton.rxrelay.BehaviorRelay
|
||||||
|
@ -47,11 +47,7 @@ class DownloadService : Service() {
|
||||||
*/
|
*/
|
||||||
fun start(context: Context) {
|
fun start(context: Context) {
|
||||||
val intent = Intent(context, DownloadService::class.java)
|
val intent = Intent(context, DownloadService::class.java)
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
ContextCompat.startForegroundService(context, intent)
|
||||||
context.startService(intent)
|
|
||||||
} else {
|
|
||||||
context.startForegroundService(intent)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,9 +3,9 @@ package eu.kanade.tachiyomi.data.library
|
||||||
import android.app.Service
|
import android.app.Service
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Build
|
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
|
@ -113,11 +113,7 @@ class LibraryUpdateService(
|
||||||
putExtra(KEY_TARGET, target)
|
putExtra(KEY_TARGET, target)
|
||||||
category?.let { putExtra(KEY_CATEGORY, it.id) }
|
category?.let { putExtra(KEY_CATEGORY, it.id) }
|
||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
ContextCompat.startForegroundService(context, intent)
|
||||||
context.startService(intent)
|
|
||||||
} else {
|
|
||||||
context.startForegroundService(intent)
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ class PreferencesHelper(val context: Context) {
|
||||||
|
|
||||||
fun showLibraryUpdateErrors() = prefs.getBoolean(Keys.showLibraryUpdateErrors, false)
|
fun showLibraryUpdateErrors() = prefs.getBoolean(Keys.showLibraryUpdateErrors, false)
|
||||||
|
|
||||||
fun clear() = prefs.edit().clear().apply()
|
fun clear() = prefs.edit { clear() }
|
||||||
|
|
||||||
fun themeMode() = flowPrefs.getEnum(Keys.themeMode, Values.ThemeMode.system)
|
fun themeMode() = flowPrefs.getEnum(Keys.themeMode, Values.ThemeMode.system)
|
||||||
|
|
||||||
|
@ -164,10 +164,10 @@ class PreferencesHelper(val context: Context) {
|
||||||
fun trackPassword(sync: TrackService) = prefs.getString(Keys.trackPassword(sync.id), "")
|
fun trackPassword(sync: TrackService) = prefs.getString(Keys.trackPassword(sync.id), "")
|
||||||
|
|
||||||
fun setTrackCredentials(sync: TrackService, username: String, password: String) {
|
fun setTrackCredentials(sync: TrackService, username: String, password: String) {
|
||||||
prefs.edit()
|
prefs.edit {
|
||||||
.putString(Keys.trackUsername(sync.id), username)
|
putString(Keys.trackUsername(sync.id), username)
|
||||||
.putString(Keys.trackPassword(sync.id), password)
|
putString(Keys.trackPassword(sync.id), password)
|
||||||
.apply()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun trackToken(sync: TrackService) = flowPrefs.getString(Keys.trackToken(sync.id), "")
|
fun trackToken(sync: TrackService) = flowPrefs.getString(Keys.trackToken(sync.id), "")
|
||||||
|
|
|
@ -4,9 +4,9 @@ import android.app.PendingIntent
|
||||||
import android.app.Service
|
import android.app.Service
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Build
|
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import eu.kanade.tachiyomi.BuildConfig
|
import eu.kanade.tachiyomi.BuildConfig
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||||
|
@ -152,11 +152,7 @@ class UpdaterService : Service() {
|
||||||
putExtra(EXTRA_DOWNLOAD_TITLE, title)
|
putExtra(EXTRA_DOWNLOAD_TITLE, title)
|
||||||
putExtra(EXTRA_DOWNLOAD_URL, url)
|
putExtra(EXTRA_DOWNLOAD_URL, url)
|
||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
ContextCompat.startForegroundService(context, intent)
|
||||||
context.startService(intent)
|
|
||||||
} else {
|
|
||||||
context.startForegroundService(intent)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ internal class ExtensionInstaller(private val context: Context) {
|
||||||
/**
|
/**
|
||||||
* The system's download manager
|
* The system's download manager
|
||||||
*/
|
*/
|
||||||
private val downloadManager = context.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
|
private val downloadManager = context.getSystemService<DownloadManager>()!!
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The broadcast receiver which listens to download completion events.
|
* The broadcast receiver which listens to download completion events.
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import com.bluelinelabs.conductor.Controller
|
import com.bluelinelabs.conductor.Controller
|
||||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||||
import com.bluelinelabs.conductor.ControllerChangeType
|
import com.bluelinelabs.conductor.ControllerChangeType
|
||||||
|
@ -31,9 +32,7 @@ class BrowseController :
|
||||||
TabbedController {
|
TabbedController {
|
||||||
|
|
||||||
constructor(toExtensions: Boolean = false) : super(
|
constructor(toExtensions: Boolean = false) : super(
|
||||||
Bundle().apply {
|
bundleOf(TO_EXTENSIONS_EXTRA to toExtensions)
|
||||||
putBoolean(TO_EXTENSIONS_EXTRA, toExtensions)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
|
|
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.browse.extension
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.bluelinelabs.conductor.Controller
|
import com.bluelinelabs.conductor.Controller
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
@ -11,10 +12,10 @@ class ExtensionTrustDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
|
||||||
where T : Controller, T : ExtensionTrustDialog.Listener {
|
where T : Controller, T : ExtensionTrustDialog.Listener {
|
||||||
|
|
||||||
constructor(target: T, signatureHash: String, pkgName: String) : this(
|
constructor(target: T, signatureHash: String, pkgName: String) : this(
|
||||||
Bundle().apply {
|
bundleOf(
|
||||||
putString(SIGNATURE_KEY, signatureHash)
|
SIGNATURE_KEY to signatureHash,
|
||||||
putString(PKGNAME_KEY, pkgName)
|
PKGNAME_KEY to pkgName
|
||||||
}
|
)
|
||||||
) {
|
) {
|
||||||
targetController = target
|
targetController = target
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.view.ContextThemeWrapper
|
import androidx.appcompat.view.ContextThemeWrapper
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceGroupAdapter
|
import androidx.preference.PreferenceGroupAdapter
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
|
@ -55,9 +56,7 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
|
||||||
private var preferenceScreen: PreferenceScreen? = null
|
private var preferenceScreen: PreferenceScreen? = null
|
||||||
|
|
||||||
constructor(pkgName: String) : this(
|
constructor(pkgName: String) : this(
|
||||||
Bundle().apply {
|
bundleOf(PKGNAME_KEY to pkgName)
|
||||||
putString(PKGNAME_KEY, pkgName)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.view.ContextThemeWrapper
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.preference.DialogPreference
|
import androidx.preference.DialogPreference
|
||||||
import androidx.preference.EditTextPreference
|
import androidx.preference.EditTextPreference
|
||||||
import androidx.preference.EditTextPreferenceDialogController
|
import androidx.preference.EditTextPreferenceDialogController
|
||||||
|
@ -41,9 +42,7 @@ class SourcePreferencesController(bundle: Bundle? = null) :
|
||||||
private var preferenceScreen: PreferenceScreen? = null
|
private var preferenceScreen: PreferenceScreen? = null
|
||||||
|
|
||||||
constructor(sourceId: Long) : this(
|
constructor(sourceId: Long) : this(
|
||||||
Bundle().apply {
|
bundleOf(SOURCE_ID to sourceId)
|
||||||
putLong(SOURCE_ID, sourceId)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.davidea.flexibleadapter.items.IFlexible
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
|
@ -19,10 +20,10 @@ class MigrationMangaController :
|
||||||
private var adapter: FlexibleAdapter<IFlexible<*>>? = null
|
private var adapter: FlexibleAdapter<IFlexible<*>>? = null
|
||||||
|
|
||||||
constructor(sourceId: Long, sourceName: String?) : super(
|
constructor(sourceId: Long, sourceName: String?) : super(
|
||||||
Bundle().apply {
|
bundleOf(
|
||||||
putLong(SOURCE_ID_EXTRA, sourceId)
|
SOURCE_ID_EXTRA to sourceId,
|
||||||
putString(SOURCE_NAME_EXTRA, sourceName)
|
SOURCE_NAME_EXTRA to sourceName
|
||||||
}
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
|
|
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.browse.source.latest
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController
|
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController
|
||||||
|
@ -13,9 +14,7 @@ import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourcePresenter
|
||||||
class LatestUpdatesController(bundle: Bundle) : BrowseSourceController(bundle) {
|
class LatestUpdatesController(bundle: Bundle) : BrowseSourceController(bundle) {
|
||||||
|
|
||||||
constructor(source: CatalogueSource) : this(
|
constructor(source: CatalogueSource) : this(
|
||||||
Bundle().apply {
|
bundleOf(SOURCE_ID_KEY to source.id)
|
||||||
putLong(SOURCE_ID_KEY, source.id)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun createPresenter(): BrowseSourcePresenter {
|
override fun createPresenter(): BrowseSourcePresenter {
|
||||||
|
|
|
@ -17,6 +17,7 @@ import androidx.appcompat.view.ActionMode
|
||||||
import androidx.core.graphics.blue
|
import androidx.core.graphics.blue
|
||||||
import androidx.core.graphics.green
|
import androidx.core.graphics.green
|
||||||
import androidx.core.graphics.red
|
import androidx.core.graphics.red
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.ConcatAdapter
|
import androidx.recyclerview.widget.ConcatAdapter
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
@ -98,10 +99,10 @@ class MangaController :
|
||||||
DeleteChaptersDialog.Listener {
|
DeleteChaptersDialog.Listener {
|
||||||
|
|
||||||
constructor(manga: Manga?, fromSource: Boolean = false) : super(
|
constructor(manga: Manga?, fromSource: Boolean = false) : super(
|
||||||
Bundle().apply {
|
bundleOf(
|
||||||
putLong(MANGA_EXTRA, manga?.id ?: 0)
|
MANGA_EXTRA to (manga?.id ?: 0),
|
||||||
putBoolean(FROM_SOURCE_EXTRA, fromSource)
|
FROM_SOURCE_EXTRA to fromSource
|
||||||
}
|
)
|
||||||
) {
|
) {
|
||||||
this.manga = manga
|
this.manga = manga
|
||||||
if (manga != null) {
|
if (manga != null) {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.manga.chapter
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.customview.customView
|
import com.afollestad.materialdialogs.customview.customView
|
||||||
import com.bluelinelabs.conductor.Controller
|
import com.bluelinelabs.conductor.Controller
|
||||||
|
@ -25,10 +26,8 @@ class DownloadCustomChaptersDialog<T> : DialogController
|
||||||
* @param maxChapters maximal number of chapters that user can download.
|
* @param maxChapters maximal number of chapters that user can download.
|
||||||
*/
|
*/
|
||||||
constructor(target: T, maxChapters: Int) : super(
|
constructor(target: T, maxChapters: Int) : super(
|
||||||
Bundle().apply {
|
|
||||||
// Add maximum number of chapters to download value to bundle.
|
// Add maximum number of chapters to download value to bundle.
|
||||||
putInt(KEY_ITEM_MAX, maxChapters)
|
bundleOf(KEY_ITEM_MAX to maxChapters)
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
targetController = target
|
targetController = target
|
||||||
this.maxChapters = maxChapters
|
this.maxChapters = maxChapters
|
||||||
|
|
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.manga.chapter
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.customview.customView
|
import com.afollestad.materialdialogs.customview.customView
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
@ -14,9 +15,7 @@ import eu.kanade.tachiyomi.widget.DialogCheckboxView
|
||||||
class SetChapterSettingsDialog(bundle: Bundle? = null) : DialogController(bundle) {
|
class SetChapterSettingsDialog(bundle: Bundle? = null) : DialogController(bundle) {
|
||||||
|
|
||||||
constructor(manga: Manga) : this(
|
constructor(manga: Manga) : this(
|
||||||
Bundle().apply {
|
bundleOf(MANGA_KEY to manga)
|
||||||
putSerializable(MANGA_KEY, manga)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.manga.track
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.widget.NumberPicker
|
import android.widget.NumberPicker
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.customview.customView
|
import com.afollestad.materialdialogs.customview.customView
|
||||||
import com.afollestad.materialdialogs.customview.getCustomView
|
import com.afollestad.materialdialogs.customview.getCustomView
|
||||||
|
@ -20,9 +21,7 @@ class SetTrackChaptersDialog<T> : DialogController
|
||||||
private val item: TrackItem
|
private val item: TrackItem
|
||||||
|
|
||||||
constructor(target: T, item: TrackItem) : super(
|
constructor(target: T, item: TrackItem) : super(
|
||||||
Bundle().apply {
|
bundleOf(KEY_ITEM_TRACK to item.track)
|
||||||
putSerializable(KEY_ITEM_TRACK, item.track)
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
targetController = target
|
targetController = target
|
||||||
this.item = item
|
this.item = item
|
||||||
|
|
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.manga.track
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.datetime.datePicker
|
import com.afollestad.materialdialogs.datetime.datePicker
|
||||||
import com.bluelinelabs.conductor.Controller
|
import com.bluelinelabs.conductor.Controller
|
||||||
|
@ -21,9 +22,7 @@ class SetTrackReadingDatesDialog<T> : DialogController
|
||||||
private val dateToUpdate: ReadingDate
|
private val dateToUpdate: ReadingDate
|
||||||
|
|
||||||
constructor(target: T, dateToUpdate: ReadingDate, item: TrackItem) : super(
|
constructor(target: T, dateToUpdate: ReadingDate, item: TrackItem) : super(
|
||||||
Bundle().apply {
|
bundleOf(KEY_ITEM_TRACK to item.track)
|
||||||
putSerializable(SetTrackReadingDatesDialog.KEY_ITEM_TRACK, item.track)
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
targetController = target
|
targetController = target
|
||||||
this.item = item
|
this.item = item
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.manga.track
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.widget.NumberPicker
|
import android.widget.NumberPicker
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.customview.customView
|
import com.afollestad.materialdialogs.customview.customView
|
||||||
import com.afollestad.materialdialogs.customview.getCustomView
|
import com.afollestad.materialdialogs.customview.getCustomView
|
||||||
|
@ -20,9 +21,7 @@ class SetTrackScoreDialog<T> : DialogController
|
||||||
private val item: TrackItem
|
private val item: TrackItem
|
||||||
|
|
||||||
constructor(target: T, item: TrackItem) : super(
|
constructor(target: T, item: TrackItem) : super(
|
||||||
Bundle().apply {
|
bundleOf(KEY_ITEM_TRACK to item.track)
|
||||||
putSerializable(KEY_ITEM_TRACK, item.track)
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
targetController = target
|
targetController = target
|
||||||
this.item = item
|
this.item = item
|
||||||
|
|
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.manga.track
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.list.listItemsSingleChoice
|
import com.afollestad.materialdialogs.list.listItemsSingleChoice
|
||||||
import com.bluelinelabs.conductor.Controller
|
import com.bluelinelabs.conductor.Controller
|
||||||
|
@ -18,9 +19,7 @@ class SetTrackStatusDialog<T> : DialogController
|
||||||
private val item: TrackItem
|
private val item: TrackItem
|
||||||
|
|
||||||
constructor(target: T, item: TrackItem) : super(
|
constructor(target: T, item: TrackItem) : super(
|
||||||
Bundle().apply {
|
bundleOf(KEY_ITEM_TRACK to item.track)
|
||||||
putSerializable(KEY_ITEM_TRACK, item.track)
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
targetController = target
|
targetController = target
|
||||||
this.item = item
|
this.item = item
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
|
@ -30,9 +31,7 @@ class TrackController :
|
||||||
SetTrackReadingDatesDialog.Listener {
|
SetTrackReadingDatesDialog.Listener {
|
||||||
|
|
||||||
constructor(manga: Manga?) : super(
|
constructor(manga: Manga?) : super(
|
||||||
Bundle().apply {
|
bundleOf(MANGA_EXTRA to (manga?.id ?: 0))
|
||||||
putLong(MANGA_EXTRA, manga?.id ?: 0)
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
this.manga = manga
|
this.manga = manga
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.manga.track
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.core.view.isInvisible
|
import androidx.core.view.isInvisible
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
|
@ -41,9 +42,7 @@ class TrackSearchDialog : DialogController {
|
||||||
get() = targetController as TrackController
|
get() = targetController as TrackController
|
||||||
|
|
||||||
constructor(target: TrackController, service: TrackService) : super(
|
constructor(target: TrackController, service: TrackService) : super(
|
||||||
Bundle().apply {
|
bundleOf(KEY_SERVICE to service.id)
|
||||||
putInt(KEY_SERVICE, service.id)
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
targetController = target
|
targetController = target
|
||||||
this.service = service
|
this.service = service
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.content.Intent
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.mikepenz.aboutlibraries.LibsBuilder
|
import com.mikepenz.aboutlibraries.LibsBuilder
|
||||||
|
@ -184,10 +185,7 @@ class AboutController : SettingsController() {
|
||||||
class NewUpdateDialogController(bundle: Bundle? = null) : DialogController(bundle) {
|
class NewUpdateDialogController(bundle: Bundle? = null) : DialogController(bundle) {
|
||||||
|
|
||||||
constructor(body: String, url: String) : this(
|
constructor(body: String, url: String) : this(
|
||||||
Bundle().apply {
|
bundleOf(BODY_KEY to body, URL_KEY to url)
|
||||||
putString(BODY_KEY, body)
|
|
||||||
putString(URL_KEY, url)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.list.listItemsMultiChoice
|
import com.afollestad.materialdialogs.list.listItemsMultiChoice
|
||||||
|
@ -251,9 +252,7 @@ class SettingsBackupController : SettingsController() {
|
||||||
|
|
||||||
class RestoreBackupDialog(bundle: Bundle? = null) : DialogController(bundle) {
|
class RestoreBackupDialog(bundle: Bundle? = null) : DialogController(bundle) {
|
||||||
constructor(uri: Uri) : this(
|
constructor(uri: Uri) : this(
|
||||||
Bundle().apply {
|
bundleOf(KEY_URI to uri)
|
||||||
putParcelable(KEY_URI, uri)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.setting.track
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||||
import eu.kanade.tachiyomi.data.track.TrackService
|
import eu.kanade.tachiyomi.data.track.TrackService
|
||||||
|
@ -28,7 +29,7 @@ class TrackLoginDialog(
|
||||||
constructor(service: TrackService) : this(service, null)
|
constructor(service: TrackService) : this(service, null)
|
||||||
|
|
||||||
constructor(service: TrackService, @StringRes usernameLabelRes: Int?) :
|
constructor(service: TrackService, @StringRes usernameLabelRes: Int?) :
|
||||||
this(R.string.login_title, service.name, usernameLabelRes, Bundle().apply { putInt("key", service.id) })
|
this(R.string.login_title, service.name, usernameLabelRes, bundleOf("key" to service.id))
|
||||||
|
|
||||||
override fun setCredentialsOnView(view: View) = with(view) {
|
override fun setCredentialsOnView(view: View) = with(view) {
|
||||||
username.setText(service.getUsername())
|
username.setText(service.getUsername())
|
||||||
|
|
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.setting.track
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||||
|
@ -15,7 +16,7 @@ class TrackLogoutDialog(bundle: Bundle? = null) : DialogController(bundle) {
|
||||||
|
|
||||||
private val service = Injekt.get<TrackManager>().getService(args.getInt("key"))!!
|
private val service = Injekt.get<TrackManager>().getService(args.getInt("key"))!!
|
||||||
|
|
||||||
constructor(service: TrackService) : this(Bundle().apply { putInt("key", service.id) })
|
constructor(service: TrackService) : this(bundleOf("key" to service.id))
|
||||||
|
|
||||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||||
return MaterialDialog(activity!!)
|
return MaterialDialog(activity!!)
|
||||||
|
|
|
@ -64,7 +64,7 @@ fun Context.toast(text: String?, duration: Int = Toast.LENGTH_SHORT) {
|
||||||
fun Context.copyToClipboard(label: String, content: String) {
|
fun Context.copyToClipboard(label: String, content: String) {
|
||||||
if (content.isBlank()) return
|
if (content.isBlank()) return
|
||||||
|
|
||||||
val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
val clipboard = getSystemService<ClipboardManager>()!!
|
||||||
clipboard.setPrimaryClip(ClipData.newPlainText(label, content))
|
clipboard.setPrimaryClip(ClipData.newPlainText(label, content))
|
||||||
|
|
||||||
toast(getString(R.string.copied_to_clipboard, content.truncateCenter(50)))
|
toast(getString(R.string.copied_to_clipboard, content.truncateCenter(50)))
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.content.Context
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.view.ContextThemeWrapper
|
import android.view.ContextThemeWrapper
|
||||||
|
import androidx.core.os.ConfigurationCompat
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.SourcePresenter
|
import eu.kanade.tachiyomi.ui.browse.source.SourcePresenter
|
||||||
|
@ -110,10 +111,10 @@ object LocaleHelper {
|
||||||
*/
|
*/
|
||||||
fun updateConfiguration(app: Application, config: Configuration, configChange: Boolean = false) {
|
fun updateConfiguration(app: Application, config: Configuration, configChange: Boolean = false) {
|
||||||
if (systemLocale == null) {
|
if (systemLocale == null) {
|
||||||
systemLocale = getConfigLocale(config)
|
systemLocale = ConfigurationCompat.getLocales(config)[0]
|
||||||
}
|
}
|
||||||
if (configChange) {
|
if (configChange) {
|
||||||
val configLocale = getConfigLocale(config)
|
val configLocale = ConfigurationCompat.getLocales(config)[0]
|
||||||
if (currentLocale == configLocale) {
|
if (currentLocale == configLocale) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -127,17 +128,6 @@ object LocaleHelper {
|
||||||
Locale.setDefault(currentLocale)
|
Locale.setDefault(currentLocale)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the locale applied in the given configuration.
|
|
||||||
*/
|
|
||||||
private fun getConfigLocale(config: Configuration): Locale {
|
|
||||||
return if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
|
||||||
config.locale
|
|
||||||
} else {
|
|
||||||
config.locales[0]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new configuration with the given locale applied.
|
* Returns a new configuration with the given locale applied.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
object BuildPluginsVersion {
|
object BuildPluginsVersion {
|
||||||
const val AGP = "4.0.1"
|
const val AGP = "4.0.2"
|
||||||
const val KOTLIN = "1.4.10"
|
const val KOTLIN = "1.4.10"
|
||||||
const val KOTLINTER = "3.0.2"
|
const val KOTLINTER = "3.0.2"
|
||||||
const val VERSIONS_PLUGIN = "0.33.0"
|
const val VERSIONS_PLUGIN = "0.33.0"
|
||||||
|
|
Reference in a new issue