Use some more KTX and Compat stuff (#3933)

* Use more KTX extensions

* Update Android Studio

* Use more Compat classes

(cherry picked from commit 60755d0c26c55e8fa90406a973c00e0871c04723)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt
#	app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt
#	app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt
#	app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt
This commit is contained in:
Taco 2020-10-12 16:46:25 -04:00 committed by Jobobby04
parent 543e089982
commit 8722c1806e
31 changed files with 85 additions and 135 deletions

View File

@ -4,9 +4,9 @@ import android.app.Service
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.IBinder
import android.os.PowerManager
import androidx.core.content.ContextCompat
import androidx.core.net.toUri
import com.hippo.unifile.UniFile
import eu.kanade.tachiyomi.data.backup.full.FullBackupManager
@ -56,11 +56,7 @@ class BackupCreateService : Service() {
putExtra(BackupConst.EXTRA_FLAGS, flags)
putExtra(BackupConst.EXTRA_TYPE, type)
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
context.startService(intent)
} else {
context.startForegroundService(intent)
}
ContextCompat.startForegroundService(context, intent)
}
}
}

View File

@ -4,9 +4,9 @@ import android.app.Service
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.IBinder
import android.os.PowerManager
import androidx.core.content.ContextCompat
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.backup.full.FullBackupRestore
import eu.kanade.tachiyomi.data.backup.legacy.LegacyBackupRestore
@ -48,11 +48,7 @@ class BackupRestoreService : Service() {
putExtra(BackupConst.EXTRA_TYPE, mode)
online?.let { putExtra(BackupConst.EXTRA_TYPE, it) }
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
context.startService(intent)
} else {
context.startForegroundService(intent)
}
ContextCompat.startForegroundService(context, intent)
}
}

View File

@ -7,9 +7,9 @@ import android.content.Intent
import android.net.ConnectivityManager
import android.net.NetworkInfo.State.CONNECTED
import android.net.NetworkInfo.State.DISCONNECTED
import android.os.Build
import android.os.IBinder
import android.os.PowerManager
import androidx.core.content.ContextCompat
import com.github.pwittchen.reactivenetwork.library.Connectivity
import com.github.pwittchen.reactivenetwork.library.ReactiveNetwork
import com.jakewharton.rxrelay.BehaviorRelay
@ -47,11 +47,7 @@ class DownloadService : Service() {
*/
fun start(context: Context) {
val intent = Intent(context, DownloadService::class.java)
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
context.startService(intent)
} else {
context.startForegroundService(intent)
}
ContextCompat.startForegroundService(context, intent)
}
/**

View File

@ -3,9 +3,9 @@ package eu.kanade.tachiyomi.data.library
import android.app.Service
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.IBinder
import android.os.PowerManager
import androidx.core.content.ContextCompat
import com.elvishew.xlog.XLog
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.cache.CoverCache
@ -145,11 +145,7 @@ class LibraryUpdateService(
groupExtra?.let { putExtra(KEY_GROUP_EXTRA, it) }
// SY <--
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
context.startService(intent)
} else {
context.startForegroundService(intent)
}
ContextCompat.startForegroundService(context, intent)
return true
}

View File

@ -77,7 +77,7 @@ class PreferencesHelper(val context: Context) {
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)
@ -164,10 +164,10 @@ class PreferencesHelper(val context: Context) {
fun trackPassword(sync: TrackService) = prefs.getString(Keys.trackPassword(sync.id), "")
fun setTrackCredentials(sync: TrackService, username: String, password: String) {
prefs.edit()
.putString(Keys.trackUsername(sync.id), username)
.putString(Keys.trackPassword(sync.id), password)
.apply()
prefs.edit {
putString(Keys.trackUsername(sync.id), username)
putString(Keys.trackPassword(sync.id), password)
}
}
fun trackToken(sync: TrackService) = flowPrefs.getString(Keys.trackToken(sync.id), "")

View File

@ -4,9 +4,9 @@ import android.app.PendingIntent
import android.app.Service
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.IBinder
import android.os.PowerManager
import androidx.core.content.ContextCompat
import eu.kanade.tachiyomi.BuildConfig
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.notification.Notifications
@ -152,11 +152,7 @@ class UpdaterService : Service() {
putExtra(EXTRA_DOWNLOAD_TITLE, title)
putExtra(EXTRA_DOWNLOAD_URL, url)
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
context.startService(intent)
} else {
context.startForegroundService(intent)
}
ContextCompat.startForegroundService(context, intent)
}
}

View File

@ -29,7 +29,7 @@ internal class ExtensionInstaller(private val context: Context) {
/**
* 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.

View File

@ -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
@ -32,9 +33,7 @@ class BrowseController :
TabbedController {
constructor(toExtensions: Boolean = false) : super(
Bundle().apply {
putBoolean(TO_EXTENSIONS_EXTRA, toExtensions)
}
bundleOf(TO_EXTENSIONS_EXTRA to toExtensions)
)
@Suppress("unused")

View File

@ -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
}

View File

@ -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 {

View File

@ -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
@ -42,9 +43,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 {

View File

@ -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
@ -25,10 +26,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")

View File

@ -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 {

View File

@ -130,18 +130,7 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
swipe_refresh.refreshes()
.onEach {
// SY -->
if (LibraryUpdateService.start(
context,
if (controller.presenter.groupType == LibraryGroup.BY_DEFAULT) category else null,
group = controller.presenter.groupType,
groupExtra = when (controller.presenter.groupType) {
LibraryGroup.BY_DEFAULT -> null
LibraryGroup.BY_SOURCE -> category.name
LibraryGroup.BY_STATUS, LibraryGroup.BY_TRACK_STATUS -> category.id.toString()
else -> null
}
)
) {
if (LibraryUpdateService.start(context, if (controller.presenter.groupType == LibraryGroup.BY_DEFAULT) category else null, group = controller.presenter.groupType, groupExtra = getGroupExtra())) {
context.toast(
when {
controller.presenter.groupType == LibraryGroup.BY_DEFAULT ||
@ -385,6 +374,13 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
lastClickPosition = position
}
// SY -->
private fun getGroupExtra() = when (controller.presenter.groupType) {
LibraryGroup.BY_DEFAULT -> null
LibraryGroup.BY_SOURCE -> category.name
LibraryGroup.BY_STATUS, LibraryGroup.BY_TRACK_STATUS -> category.id.toString()
else -> null
}
override fun onItemReleased(position: Int) {
return
}

View File

@ -24,6 +24,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
@ -124,14 +125,14 @@ class MangaController :
DeleteChaptersDialog.Listener {
constructor(manga: Manga?, fromSource: Boolean = false, smartSearchConfig: SourceController.SmartSearchConfig? = null, update: 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,
// SY -->
putParcelable(SMART_SEARCH_CONFIG_EXTRA, smartSearchConfig)
putBoolean(UPDATE_EXTRA, update)
SMART_SEARCH_CONFIG_EXTRA to smartSearchConfig,
UPDATE_EXTRA to update
// SY <--
}
)
) {
this.manga = manga
if (manga != null) {
@ -362,11 +363,7 @@ class MangaController :
// Get coordinates and start animation
actionFab?.getCoordinates()?.let { coordinates ->
if (!binding.revealView.showRevealEffect(
coordinates.x,
coordinates.y,
revealAnimationListener
)
if (!binding.revealView.showRevealEffect(coordinates.x, coordinates.y, revealAnimationListener)
) {
openChapter(item.chapter)
}

View File

@ -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)
}
// Add maximum number of chapters to download value to bundle.
bundleOf(KEY_ITEM_MAX to maxChapters)
) {
targetController = target
this.maxChapters = maxChapters

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
@ -31,9 +32,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
}

View File

@ -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

View File

@ -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 {

View File

@ -253,11 +253,7 @@ class PagerPageHolder(
// SY -->
if (viewer.config.readerTheme >= 3) {
val imageView = initSubsamplingImageView()
if (page.bg != null && page.bgType == getBGType(
viewer.config.readerTheme,
context
)
) {
if (page.bg != null && page.bgType == getBGType(viewer.config.readerTheme, context)) {
imageView.setImage(ImageSource.inputStream(openStream!!))
imageView.background = page.bg
}

View File

@ -10,6 +10,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
@ -353,11 +354,11 @@ class SettingsBackupController : SettingsController() {
class RestoreBackupDialog(bundle: Bundle? = null) : DialogController(bundle) {
constructor(uri: Uri, type: Int, isOnline: Boolean) : this(
Bundle().apply {
putParcelable(KEY_URI, uri)
putInt(KEY_TYPE, type)
putBoolean(KEY_MODE, isOnline)
}
bundleOf(
KEY_URI to uri,
KEY_TYPE to type,
KEY_MODE to isOnline
)
)
override fun onCreateDialog(savedViewState: Bundle?): Dialog {

View File

@ -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())

View File

@ -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!!)

View File

@ -75,7 +75,7 @@ fun Context.toast(text: String?, duration: Int = Toast.LENGTH_SHORT) {
fun Context.copyToClipboard(label: String, content: String) {
if (content.isBlank()) return
val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
val clipboard = getSystemService<ClipboardManager>()!!
clipboard.setPrimaryClip(ClipData.newPlainText(label, content))
toast(getString(R.string.copied_to_clipboard, content.truncateCenter(50)))

View File

@ -5,6 +5,7 @@ import android.content.Context
import android.content.res.Configuration
import android.os.Build
import android.view.ContextThemeWrapper
import androidx.core.os.ConfigurationCompat
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.ui.browse.source.SourcePresenter
@ -115,10 +116,10 @@ object LocaleHelper {
*/
fun updateConfiguration(app: Application, config: Configuration, configChange: Boolean = false) {
if (systemLocale == null) {
systemLocale = getConfigLocale(config)
systemLocale = ConfigurationCompat.getLocales(config)[0]
}
if (configChange) {
val configLocale = getConfigLocale(config)
val configLocale = ConfigurationCompat.getLocales(config)[0]
if (currentLocale == configLocale) {
return
}
@ -132,17 +133,6 @@ object LocaleHelper {
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.
*/

View File

@ -1,5 +1,5 @@
object BuildPluginsVersion {
const val AGP = "4.0.1"
const val AGP = "4.1.0"
const val KOTLIN = "1.4.10"
const val KOTLINTER = "3.0.2"
const val VERSIONS_PLUGIN = "0.33.0"