Skip to content

Commit

Permalink
Update AndroidX dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelvcaetano committed Jan 6, 2024
1 parent 587e3c8 commit 0ac5cf2
Show file tree
Hide file tree
Showing 19 changed files with 64 additions and 51 deletions.
12 changes: 6 additions & 6 deletions app/src/main/java/me/magnum/melonds/MelonDSApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ class MelonDSApplication : Application(), Configuration.Provider {
migrator.performMigrations()
}

override fun getWorkManagerConfiguration(): Configuration {
return Configuration.Builder()
.setWorkerFactory(workerFactory)
.build()
}

override fun onTerminate() {
super.onTerminate()
themeObserverDisposable?.dispose()
MelonDSAndroidInterface.cleanup()
}

override val workManagerConfiguration: Configuration get() {
return Configuration.Builder()
.setWorkerFactory(workerFactory)
.build()
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/me/magnum/melonds/MelonEmulator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ object MelonEmulator {

fun bootFirmware(): FirmwareLoadResult {
val loadResult = bootFirmwareInternal()
return FirmwareLoadResult.values()[loadResult]
return FirmwareLoadResult.entries[loadResult]
}

private external fun loadRomInternal(romPath: String, sramPath: String, loadGbaRom: Boolean, gbaRomPath: String?, gbaSramPath: String?): Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase

class Migration1to2 : Migration(1, 2) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE game ADD COLUMN game_checksum TEXT")
database.execSQL("CREATE INDEX index_game_game_checksum ON game(game_checksum)")
override fun migrate(db: SupportSQLiteDatabase) {
db.execSQL("ALTER TABLE game ADD COLUMN game_checksum TEXT")
db.execSQL("CREATE INDEX index_game_game_checksum ON game(game_checksum)")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ import androidx.camera.core.CameraSelector
import androidx.camera.core.ImageAnalysis
import androidx.camera.core.ImageInfo
import androidx.camera.core.ImageProxy.PlaneProxy
import androidx.camera.core.resolutionselector.AspectRatioStrategy
import androidx.camera.core.resolutionselector.ResolutionSelector
import androidx.camera.core.resolutionselector.ResolutionStrategy
import androidx.camera.lifecycle.ProcessCameraProvider
import androidx.core.content.ContextCompat
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.cancel
import kotlinx.coroutines.launch
import me.magnum.melonds.common.PermissionHandler
import me.magnum.melonds.common.camera.DSiCameraSource
import me.magnum.melonds.common.camera.CameraType
import me.magnum.melonds.common.camera.DSiCameraSource
import me.magnum.melonds.impl.emulator.LifecycleOwnerProvider
import java.nio.ByteBuffer
import java.util.Arrays
Expand Down Expand Up @@ -81,7 +84,12 @@ class PhysicalDSiCameraSource(
val cameraProvider = future.get()

val analyzer = ImageAnalysis.Builder()
.setTargetResolution(Size(640, 480))
.setResolutionSelector(
ResolutionSelector.Builder()
.setAspectRatioStrategy(AspectRatioStrategy.RATIO_4_3_FALLBACK_AUTO_STRATEGY)
.setResolutionStrategy(ResolutionStrategy(Size(640, 480), ResolutionStrategy.FALLBACK_RULE_CLOSEST_HIGHER))
.build()
)
.setOutputImageFormat(ImageAnalysis.OUTPUT_IMAGE_FORMAT_YUV_420_888)
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class BackgroundParcelable : Parcelable {
private constructor(parcel: Parcel) {
val id = parcel.readString()?.let { UUID.fromString(it) }
val name = parcel.readString() ?: throw NullPointerException("Missing name string")
val orientation = Orientation.values()[parcel.readInt()]
val orientation = Orientation.entries[parcel.readInt()]
val uri = parcel.readString()!!.toUri()
background = Background(id, name, orientation, uri)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class RomConfigParcelable : Parcelable {

private constructor(parcel: Parcel) {
romConfig = RomConfig()
romConfig.runtimeConsoleType = RuntimeConsoleType.values()[parcel.readInt()]
romConfig.runtimeMicSource = RuntimeMicSource.values()[parcel.readInt()]
romConfig.runtimeConsoleType = RuntimeConsoleType.entries[parcel.readInt()]
romConfig.runtimeMicSource = RuntimeMicSource.entries[parcel.readInt()]
romConfig.layoutId = parcel.readString()?.let { UUID.fromString(it) }
romConfig.loadGbaCart = parcel.readInt() == 1
romConfig.gbaCartPath = parcel.readString()?.toUri()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class BackgroundsViewModel @Inject constructor(
init {
val initialBackgroundId = savedStateHandle.get<String?>(BackgroundsActivity.KEY_INITIAL_BACKGROUND_ID)?.let { UUID.fromString(it) }
currentSelectedBackground = MutableLiveData(initialBackgroundId)
backgroundOrientationFilter = savedStateHandle.get<Int>(BackgroundsActivity.KEY_ORIENTATION_FILTER).let { Orientation.values()[it ?: throw NullPointerException()] }
backgroundOrientationFilter = savedStateHandle.get<Int>(BackgroundsActivity.KEY_ORIENTATION_FILTER).let { Orientation.entries[it ?: throw NullPointerException()] }

backgroundsRepository.getBackgrounds()
.subscribeOn(schedulers.backgroundThreadScheduler)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,12 @@ class EmulatorViewModel @Inject constructor(
if (showPauseMenu) {
val pauseOptions = when (_emulatorState.value) {
is EmulatorState.RunningRom -> {
RomPauseMenuOption.values().filter {
RomPauseMenuOption.entries.filter {
filterRomPauseMenuOption(it)
}
}
is EmulatorState.RunningFirmware -> {
FirmwarePauseMenuOption.values().toList()
FirmwarePauseMenuOption.entries
}
else -> null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ class LayoutBackgroundsDialog : DialogFragment() {

if (savedInstanceState != null) {
currentPortraitBackgroundId = savedInstanceState.getString(KEY_PORTRAIT_BACKGROUND_ID, null)?.let { UUID.fromString(it) }
currentPortraitBackgroundMode = BackgroundMode.values()[savedInstanceState.getInt(KEY_PORTRAIT_BACKGROUND_MODE, 0)]
currentPortraitBackgroundMode = BackgroundMode.entries[savedInstanceState.getInt(KEY_PORTRAIT_BACKGROUND_MODE, 0)]
currentLandscapeBackgroundId = savedInstanceState.getString(KEY_LANDSCAPE_BACKGROUND_ID, null)?.let { UUID.fromString(it) }
currentLandscapeBackgroundMode = BackgroundMode.values()[savedInstanceState.getInt(KEY_LANDSCAPE_BACKGROUND_MODE, 0)]
currentLandscapeBackgroundMode = BackgroundMode.entries[savedInstanceState.getInt(KEY_LANDSCAPE_BACKGROUND_MODE, 0)]
} else {
currentPortraitBackgroundId = arguments?.getString(KEY_PORTRAIT_BACKGROUND_ID, null)?.let { UUID.fromString(it) }
currentPortraitBackgroundMode = BackgroundMode.values()[arguments?.getInt(KEY_PORTRAIT_BACKGROUND_MODE, 0) ?: 0]
currentPortraitBackgroundMode = BackgroundMode.entries[arguments?.getInt(KEY_PORTRAIT_BACKGROUND_MODE, 0) ?: 0]
currentLandscapeBackgroundId = arguments?.getString(KEY_LANDSCAPE_BACKGROUND_ID, null)?.let { UUID.fromString(it) }
currentLandscapeBackgroundMode = BackgroundMode.values()[arguments?.getInt(KEY_LANDSCAPE_BACKGROUND_MODE, 0) ?: 0]
currentLandscapeBackgroundMode = BackgroundMode.entries[arguments?.getInt(KEY_LANDSCAPE_BACKGROUND_MODE, 0) ?: 0]
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class LayoutEditorActivity : AppCompatActivity() {
private fun openButtonsMenu() {
hideBottomControls()
val instantiatedComponents = binding.viewLayoutEditor.getInstantiatedComponents()
val componentsToShow = LayoutComponent.values().filterNot { instantiatedComponents.contains(it) }
val componentsToShow = LayoutComponent.entries.filterNot { instantiatedComponents.contains(it) }

val dialogBuilder = AlertDialog.Builder(this)
.setTitle(R.string.choose_component)
Expand All @@ -322,7 +322,7 @@ class LayoutEditorActivity : AppCompatActivity() {
}

private fun openMenu() {
val values = MenuOption.values()
val values = MenuOption.entries
val options = Array(values.size) { i -> getString(values[i].stringRes) }

AlertDialog.Builder(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ class LayoutPropertiesDialog : DialogFragment() {

if (savedInstanceState != null) {
layoutName = savedInstanceState.getString(KEY_LAYOUT_NAME)
layoutOrientation = LayoutConfiguration.LayoutOrientation.values()[savedInstanceState.getInt(KEY_LAYOUT_ORIENTATION)]
layoutOrientation = LayoutConfiguration.LayoutOrientation.entries[savedInstanceState.getInt(KEY_LAYOUT_ORIENTATION)]
useCustomOpacity = savedInstanceState.getBoolean(KEY_CUSTOM_OPACITY)
layoutOpacity = savedInstanceState.getInt(KEY_LAYOUT_OPACITY)
} else {
layoutName = arguments?.getString(KEY_LAYOUT_NAME)
layoutOrientation = LayoutConfiguration.LayoutOrientation.values()[arguments?.getInt(KEY_LAYOUT_ORIENTATION) ?: 0]
layoutOrientation = LayoutConfiguration.LayoutOrientation.entries[arguments?.getInt(KEY_LAYOUT_ORIENTATION) ?: 0]
useCustomOpacity = arguments?.getBoolean(KEY_CUSTOM_OPACITY) ?: true
layoutOpacity = arguments?.getInt(KEY_LAYOUT_OPACITY) ?: 0
}
Expand All @@ -82,8 +82,8 @@ class LayoutPropertiesDialog : DialogFragment() {
binding.layoutOrientation.setOnClickListener {
AlertDialog.Builder(requireContext())
.setTitle(R.string.layout_orientation)
.setSingleChoiceItems(R.array.layout_orientation_options, LayoutConfiguration.LayoutOrientation.values().indexOf(layoutOrientation)) { dialog, which ->
val newOrientation = LayoutConfiguration.LayoutOrientation.values()[which]
.setSingleChoiceItems(R.array.layout_orientation_options, LayoutConfiguration.LayoutOrientation.entries.indexOf(layoutOrientation)) { dialog, which ->
val newOrientation = LayoutConfiguration.LayoutOrientation.entries[which]
setLayoutOrientation(newOrientation)
dialog.dismiss()
}
Expand Down Expand Up @@ -136,7 +136,7 @@ class LayoutPropertiesDialog : DialogFragment() {

private fun setLayoutOrientation(orientation: LayoutConfiguration.LayoutOrientation) {
val orientationNames = requireContext().resources.getStringArray(R.array.layout_orientation_options)
binding.textOrientation.text = orientationNames[LayoutConfiguration.LayoutOrientation.values().indexOf(orientation)]
binding.textOrientation.text = orientationNames[LayoutConfiguration.LayoutOrientation.entries.indexOf(orientation)]
layoutOrientation = orientation
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private fun Content(
items = consoleOptions.toList(),
selectedItemIndex = romConfig.runtimeConsoleType.ordinal,
onItemSelected = {
onConfigUpdate(RomConfigUpdateEvent.RuntimeConsoleUpdate(RuntimeConsoleType.values()[it]))
onConfigUpdate(RomConfigUpdateEvent.RuntimeConsoleUpdate(RuntimeConsoleType.entries[it]))
}
)

Expand All @@ -83,7 +83,7 @@ private fun Content(
items = micSourceOptions.toList(),
selectedItemIndex = romConfig.runtimeMicSource.ordinal,
onItemSelected = {
onConfigUpdate(RomConfigUpdateEvent.RuntimeMicSourceUpdate(RuntimeMicSource.values()[it]))
onConfigUpdate(RomConfigUpdateEvent.RuntimeMicSourceUpdate(RuntimeMicSource.entries[it]))
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ fun RomScreen(
onRetroAchievementsRetryLoad: () -> Unit,
onViewAchievement: (RAAchievement) -> Unit,
) {
val pagerState = rememberPagerState(RomDetailsTab.CONFIG.tabIndex)
val pagerState = rememberPagerState(
initialPage = RomDetailsTab.CONFIG.tabIndex,
pageCount = { RomDetailsTab.entries.size },
)
val coroutineScope = rememberCoroutineScope()

Column(modifier) {
Expand All @@ -49,7 +52,6 @@ fun RomScreen(
}
HorizontalPager(
modifier = Modifier.fillMaxWidth().weight(1f),
pageCount = RomDetailsTab.values().size,
state = pagerState,
) {
when (it) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ fun RomHeaderUi(
@Composable
private fun PreviewRomHeaderUi() {
MelonTheme {
val pagerState = rememberPagerState(RomDetailsTab.CONFIG.tabIndex)
val pagerState = rememberPagerState(
initialPage = RomDetailsTab.CONFIG.tabIndex,
pageCount = { RomDetailsTab.entries.size },
)
val coroutineScope = rememberCoroutineScope()

RomHeaderUi(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class RomConfigDialog : DialogFragment() {
AlertDialog.Builder(requireContext())
.setTitle(R.string.label_rom_config_console)
.setSingleChoiceItems(R.array.game_runtime_console_type_options, romConfig.runtimeConsoleType.ordinal) { dialog, which ->
val newConsoleType = RuntimeConsoleType.values()[which]
val newConsoleType = RuntimeConsoleType.entries[which]
onRuntimeConsoleTypeSelected(newConsoleType)
dialog.dismiss()
}
Expand All @@ -119,7 +119,7 @@ class RomConfigDialog : DialogFragment() {
AlertDialog.Builder(requireContext())
.setTitle(R.string.microphone_source)
.setSingleChoiceItems(R.array.game_runtime_mic_source_options, romConfig.runtimeMicSource.ordinal) { dialog, which ->
val newMicSource = RuntimeMicSource.values()[which]
val newMicSource = RuntimeMicSource.entries[which]
// Request mic permission if required
if (newMicSource == RuntimeMicSource.DEVICE && !requireContext().isMicrophonePermissionGranted()) {
microphonePermissionLauncher.launch(Manifest.permission.RECORD_AUDIO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class BiosDirectoryPickerPreference(context: Context, attrs: AttributeSet?) : St
return

val attrArray = context.theme.obtainStyledAttributes(attrs, R.styleable.BiosDirectoryPickerPreference, 0, 0)
consoleType = ConsoleType.values()[attrArray.getIntOrThrow(R.styleable.BiosDirectoryPickerPreference_consoleType)]
consoleType = ConsoleType.entries[attrArray.getIntOrThrow(R.styleable.BiosDirectoryPickerPreference_consoleType)]

attrArray.recycle()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class FirmwareColourPickerPreference(context: Context, attrs: AttributeSet?) : P
}

private fun updateSelectedColour(selectedColour: Int) {
val firmwareColour = FirmwareColour.values()[selectedColour]
val firmwareColour = FirmwareColour.entries[selectedColour]
colorMapper[firmwareColour]?.let {
val colourWithAlpha = (0xFF000000 or it.toLong())
viewSelectedColour.setBackgroundColor(colourWithAlpha.toInt())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ open class StoragePickerPreference(context: Context, attrs: AttributeSet?) : Pre
val attr = attrArray.getIndex(i)
when (attr) {
R.styleable.DirectoryPickerPreference_selection -> multiSelection = attrArray.getInt(R.styleable.DirectoryPickerPreference_selection, 0) == 1
R.styleable.DirectoryPickerPreference_type -> selectionType = SelectionType.values()[attrArray.getInt(R.styleable.DirectoryPickerPreference_type, 0)]
R.styleable.DirectoryPickerPreference_permissions -> permissions = Permission.values()[attrArray.getInt(R.styleable.DirectoryPickerPreference_permissions, 0)]
R.styleable.DirectoryPickerPreference_type -> selectionType = SelectionType.entries[attrArray.getInt(R.styleable.DirectoryPickerPreference_type, 0)]
R.styleable.DirectoryPickerPreference_permissions -> permissions = Permission.entries[attrArray.getInt(R.styleable.DirectoryPickerPreference_permissions, 0)]
R.styleable.DirectoryPickerPreference_persistPermissions -> persistPermissions = attrArray.getBoolean(R.styleable.DirectoryPickerPreference_persistPermissions, false)
R.styleable.DirectoryPickerPreference_mimeType -> mimeType = attrArray.getString(R.styleable.DirectoryPickerPreference_mimeType)
}
Expand Down
22 changes: 11 additions & 11 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
object Dependencies {
object Versions {
const val Accompanist = "0.30.1"
const val Activity = "1.7.2"
const val Activity = "1.8.2"
const val AppCompat = "1.6.1"
const val CameraX = "1.2.3"
const val CameraX = "1.3.1"
const val CardView = "1.0.0"
const val Coil = "2.2.2"
const val CommonsCompress = "1.21"
const val ComposeBom = "2023.06.01"
const val ComposeBom = "2023.10.01"
const val ConstraintLayout = "2.1.4"
const val Core = "1.10.1"
const val Core = "1.12.0"
const val Desugar = "2.0.2"
const val DocumentFile = "1.0.1"
const val Flexbox = "3.0.0"
const val Fragment = "1.5.7"
const val Fragment = "1.6.2"
const val Gradle = "8.2.0"
const val Gson = "2.8.6"
const val HiltX = "1.1.0"
Expand All @@ -22,18 +22,18 @@ object Dependencies {
const val Kotlin = "1.9.21"
const val KotlinxCoroutines = "1.7.3"
const val Ksp = "1.9.0-1.0.12"
const val LifecycleViewModel = "2.6.1"
const val LifecycleViewModel = "2.6.2"
const val Material = "1.7.0"
const val OkHttp = "4.11.0"
const val Picasso = "2.71828"
const val Preference = "1.2.0"
const val RecyclerView = "1.3.1"
const val Room = "2.6.0"
const val Preference = "1.2.1"
const val RecyclerView = "1.3.2"
const val Room = "2.6.1"
const val RxAndroid = "2.1.1"
const val RxJava = "2.2.10"
const val Splashscreen = "1.0.0"
const val SwipeRefreshLayout = "1.1.0"
const val Work = "2.8.1"
const val Work = "2.9.0"
const val Markwon = "4.6.2"
const val Retrofit = "2.9.0"
const val Xz = "1.9"
Expand Down Expand Up @@ -76,7 +76,7 @@ object Dependencies {
const val roomRxJava = "androidx.room:room-rxjava2:${Versions.Room}"
const val splashscreen = "androidx.core:core-splashscreen:${Versions.Splashscreen}"
const val swipeRefreshLayout = "androidx.swiperefreshlayout:swiperefreshlayout:${Versions.SwipeRefreshLayout}"
const val work = "androidx.work:work-runtime-ktx:${Versions.Work}"
const val work = "androidx.work:work-runtime:${Versions.Work}"
const val material = "com.google.android.material:material:${Versions.Material}"
}

Expand Down

0 comments on commit 0ac5cf2

Please sign in to comment.