mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-12 20:19:05 +01:00
Use some more KTX and Compat stuff (#3933)
* Use more KTX extensions * Update Android Studio * Use more Compat classes
This commit is contained in:
@@ -4,6 +4,7 @@ import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.os.bundleOf
|
||||
import com.bluelinelabs.conductor.Controller
|
||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||
import com.bluelinelabs.conductor.ControllerChangeType
|
||||
@@ -31,9 +32,7 @@ class BrowseController :
|
||||
TabbedController {
|
||||
|
||||
constructor(toExtensions: Boolean = false) : super(
|
||||
Bundle().apply {
|
||||
putBoolean(TO_EXTENSIONS_EXTRA, toExtensions)
|
||||
}
|
||||
bundleOf(TO_EXTENSIONS_EXTRA to toExtensions)
|
||||
)
|
||||
|
||||
@Suppress("unused")
|
||||
|
||||
@@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.browse.extension
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import androidx.core.os.bundleOf
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.bluelinelabs.conductor.Controller
|
||||
import eu.kanade.tachiyomi.R
|
||||
@@ -11,10 +12,10 @@ class ExtensionTrustDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
|
||||
where T : Controller, T : ExtensionTrustDialog.Listener {
|
||||
|
||||
constructor(target: T, signatureHash: String, pkgName: String) : this(
|
||||
Bundle().apply {
|
||||
putString(SIGNATURE_KEY, signatureHash)
|
||||
putString(PKGNAME_KEY, pkgName)
|
||||
}
|
||||
bundleOf(
|
||||
SIGNATURE_KEY to signatureHash,
|
||||
PKGNAME_KEY to pkgName
|
||||
)
|
||||
) {
|
||||
targetController = target
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.view.ContextThemeWrapper
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceGroupAdapter
|
||||
import androidx.preference.PreferenceManager
|
||||
@@ -55,9 +56,7 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
|
||||
private var preferenceScreen: PreferenceScreen? = null
|
||||
|
||||
constructor(pkgName: String) : this(
|
||||
Bundle().apply {
|
||||
putString(PKGNAME_KEY, pkgName)
|
||||
}
|
||||
bundleOf(PKGNAME_KEY to pkgName)
|
||||
)
|
||||
|
||||
init {
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.view.ContextThemeWrapper
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.preference.DialogPreference
|
||||
import androidx.preference.EditTextPreference
|
||||
import androidx.preference.EditTextPreferenceDialogController
|
||||
@@ -41,9 +42,7 @@ class SourcePreferencesController(bundle: Bundle? = null) :
|
||||
private var preferenceScreen: PreferenceScreen? = null
|
||||
|
||||
constructor(sourceId: Long) : this(
|
||||
Bundle().apply {
|
||||
putLong(SOURCE_ID, sourceId)
|
||||
}
|
||||
bundleOf(SOURCE_ID to sourceId)
|
||||
)
|
||||
|
||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.davidea.flexibleadapter.items.IFlexible
|
||||
@@ -19,10 +20,10 @@ class MigrationMangaController :
|
||||
private var adapter: FlexibleAdapter<IFlexible<*>>? = null
|
||||
|
||||
constructor(sourceId: Long, sourceName: String?) : super(
|
||||
Bundle().apply {
|
||||
putLong(SOURCE_ID_EXTRA, sourceId)
|
||||
putString(SOURCE_NAME_EXTRA, sourceName)
|
||||
}
|
||||
bundleOf(
|
||||
SOURCE_ID_EXTRA to sourceId,
|
||||
SOURCE_NAME_EXTRA to sourceName
|
||||
)
|
||||
)
|
||||
|
||||
@Suppress("unused")
|
||||
|
||||
@@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.browse.source.latest
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import androidx.core.os.bundleOf
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
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) {
|
||||
|
||||
constructor(source: CatalogueSource) : this(
|
||||
Bundle().apply {
|
||||
putLong(SOURCE_ID_KEY, source.id)
|
||||
}
|
||||
bundleOf(SOURCE_ID_KEY to source.id)
|
||||
)
|
||||
|
||||
override fun createPresenter(): BrowseSourcePresenter {
|
||||
|
||||
@@ -17,6 +17,7 @@ import androidx.appcompat.view.ActionMode
|
||||
import androidx.core.graphics.blue
|
||||
import androidx.core.graphics.green
|
||||
import androidx.core.graphics.red
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.ConcatAdapter
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
@@ -98,10 +99,10 @@ class MangaController :
|
||||
DeleteChaptersDialog.Listener {
|
||||
|
||||
constructor(manga: Manga?, fromSource: Boolean = false) : super(
|
||||
Bundle().apply {
|
||||
putLong(MANGA_EXTRA, manga?.id ?: 0)
|
||||
putBoolean(FROM_SOURCE_EXTRA, fromSource)
|
||||
}
|
||||
bundleOf(
|
||||
MANGA_EXTRA to (manga?.id ?: 0),
|
||||
FROM_SOURCE_EXTRA to fromSource
|
||||
)
|
||||
) {
|
||||
this.manga = manga
|
||||
if (manga != null) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.manga.chapter
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import androidx.core.os.bundleOf
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.customview.customView
|
||||
import com.bluelinelabs.conductor.Controller
|
||||
@@ -25,10 +26,8 @@ class DownloadCustomChaptersDialog<T> : DialogController
|
||||
* @param maxChapters maximal number of chapters that user can download.
|
||||
*/
|
||||
constructor(target: T, maxChapters: Int) : super(
|
||||
Bundle().apply {
|
||||
// Add maximum number of chapters to download value to bundle.
|
||||
putInt(KEY_ITEM_MAX, maxChapters)
|
||||
}
|
||||
bundleOf(KEY_ITEM_MAX to maxChapters)
|
||||
) {
|
||||
targetController = target
|
||||
this.maxChapters = maxChapters
|
||||
|
||||
@@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.manga.chapter
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import androidx.core.os.bundleOf
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.customview.customView
|
||||
import eu.kanade.tachiyomi.R
|
||||
@@ -14,9 +15,7 @@ import eu.kanade.tachiyomi.widget.DialogCheckboxView
|
||||
class SetChapterSettingsDialog(bundle: Bundle? = null) : DialogController(bundle) {
|
||||
|
||||
constructor(manga: Manga) : this(
|
||||
Bundle().apply {
|
||||
putSerializable(MANGA_KEY, manga)
|
||||
}
|
||||
bundleOf(MANGA_KEY to manga)
|
||||
)
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
|
||||
@@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.manga.track
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.widget.NumberPicker
|
||||
import androidx.core.os.bundleOf
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.customview.customView
|
||||
import com.afollestad.materialdialogs.customview.getCustomView
|
||||
@@ -20,9 +21,7 @@ class SetTrackChaptersDialog<T> : DialogController
|
||||
private val item: TrackItem
|
||||
|
||||
constructor(target: T, item: TrackItem) : super(
|
||||
Bundle().apply {
|
||||
putSerializable(KEY_ITEM_TRACK, item.track)
|
||||
}
|
||||
bundleOf(KEY_ITEM_TRACK to item.track)
|
||||
) {
|
||||
targetController = target
|
||||
this.item = item
|
||||
|
||||
@@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.manga.track
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import androidx.core.os.bundleOf
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.datetime.datePicker
|
||||
import com.bluelinelabs.conductor.Controller
|
||||
@@ -21,9 +22,7 @@ class SetTrackReadingDatesDialog<T> : DialogController
|
||||
private val dateToUpdate: ReadingDate
|
||||
|
||||
constructor(target: T, dateToUpdate: ReadingDate, item: TrackItem) : super(
|
||||
Bundle().apply {
|
||||
putSerializable(SetTrackReadingDatesDialog.KEY_ITEM_TRACK, item.track)
|
||||
}
|
||||
bundleOf(KEY_ITEM_TRACK to item.track)
|
||||
) {
|
||||
targetController = target
|
||||
this.item = item
|
||||
|
||||
@@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.manga.track
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.widget.NumberPicker
|
||||
import androidx.core.os.bundleOf
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.customview.customView
|
||||
import com.afollestad.materialdialogs.customview.getCustomView
|
||||
@@ -20,9 +21,7 @@ class SetTrackScoreDialog<T> : DialogController
|
||||
private val item: TrackItem
|
||||
|
||||
constructor(target: T, item: TrackItem) : super(
|
||||
Bundle().apply {
|
||||
putSerializable(KEY_ITEM_TRACK, item.track)
|
||||
}
|
||||
bundleOf(KEY_ITEM_TRACK to item.track)
|
||||
) {
|
||||
targetController = target
|
||||
this.item = item
|
||||
|
||||
@@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.manga.track
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import androidx.core.os.bundleOf
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.list.listItemsSingleChoice
|
||||
import com.bluelinelabs.conductor.Controller
|
||||
@@ -18,9 +19,7 @@ class SetTrackStatusDialog<T> : DialogController
|
||||
private val item: TrackItem
|
||||
|
||||
constructor(target: T, item: TrackItem) : super(
|
||||
Bundle().apply {
|
||||
putSerializable(KEY_ITEM_TRACK, item.track)
|
||||
}
|
||||
bundleOf(KEY_ITEM_TRACK to item.track)
|
||||
) {
|
||||
targetController = target
|
||||
this.item = item
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.net.toUri
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
@@ -30,9 +31,7 @@ class TrackController :
|
||||
SetTrackReadingDatesDialog.Listener {
|
||||
|
||||
constructor(manga: Manga?) : super(
|
||||
Bundle().apply {
|
||||
putLong(MANGA_EXTRA, manga?.id ?: 0)
|
||||
}
|
||||
bundleOf(MANGA_EXTRA to (manga?.id ?: 0))
|
||||
) {
|
||||
this.manga = manga
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.manga.track
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
@@ -41,9 +42,7 @@ class TrackSearchDialog : DialogController {
|
||||
get() = targetController as TrackController
|
||||
|
||||
constructor(target: TrackController, service: TrackService) : super(
|
||||
Bundle().apply {
|
||||
putInt(KEY_SERVICE, service.id)
|
||||
}
|
||||
bundleOf(KEY_SERVICE to service.id)
|
||||
) {
|
||||
targetController = target
|
||||
this.service = service
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import androidx.core.net.toUri
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.preference.PreferenceScreen
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.mikepenz.aboutlibraries.LibsBuilder
|
||||
@@ -184,10 +185,7 @@ class AboutController : SettingsController() {
|
||||
class NewUpdateDialogController(bundle: Bundle? = null) : DialogController(bundle) {
|
||||
|
||||
constructor(body: String, url: String) : this(
|
||||
Bundle().apply {
|
||||
putString(BODY_KEY, body)
|
||||
putString(URL_KEY, url)
|
||||
}
|
||||
bundleOf(BODY_KEY to body, URL_KEY to url)
|
||||
)
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.core.net.toUri
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.preference.PreferenceScreen
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.list.listItemsMultiChoice
|
||||
@@ -251,9 +252,7 @@ class SettingsBackupController : SettingsController() {
|
||||
|
||||
class RestoreBackupDialog(bundle: Bundle? = null) : DialogController(bundle) {
|
||||
constructor(uri: Uri) : this(
|
||||
Bundle().apply {
|
||||
putParcelable(KEY_URI, uri)
|
||||
}
|
||||
bundleOf(KEY_URI to uri)
|
||||
)
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
|
||||
@@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.setting.track
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.core.os.bundleOf
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||
import eu.kanade.tachiyomi.data.track.TrackService
|
||||
@@ -28,7 +29,7 @@ class TrackLoginDialog(
|
||||
constructor(service: TrackService) : this(service, null)
|
||||
|
||||
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) {
|
||||
username.setText(service.getUsername())
|
||||
|
||||
@@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.setting.track
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import androidx.core.os.bundleOf
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import eu.kanade.tachiyomi.R
|
||||
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"))!!
|
||||
|
||||
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 {
|
||||
return MaterialDialog(activity!!)
|
||||
|
||||
Reference in New Issue
Block a user