diff --git a/app/build.gradle b/app/build.gradle index a38f82f7..b20c8221 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -100,6 +100,7 @@ dependencies { implementation 'androidx.fragment:fragment-ktx:1.2.5' implementation "com.google.dagger:hilt-android:$hilt_version" kapt "com.google.dagger:hilt-android-compiler:$hilt_version" + implementation 'com.google.android:flexbox:2.0.1' /* Kotlin */ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" diff --git a/app/src/main/java/emu/skyline/AppDialog.kt b/app/src/main/java/emu/skyline/AppDialog.kt index d198c7a1..3c6385dc 100644 --- a/app/src/main/java/emu/skyline/AppDialog.kt +++ b/app/src/main/java/emu/skyline/AppDialog.kt @@ -48,9 +48,7 @@ class AppDialog : BottomSheetDialogFragment() { /** * This inflates the layout of the dialog after initial view creation */ - override fun onCreateView(inflater : LayoutInflater, container : ViewGroup?, savedInstanceState : Bundle?) : View? { - return AppDialogBinding.inflate(inflater).also { binding = it }.root - } + override fun onCreateView(inflater : LayoutInflater, container : ViewGroup?, savedInstanceState : Bundle?) = AppDialogBinding.inflate(inflater).also { binding = it }.root /** * This expands the bottom sheet so that it's fully visible and map the B button to back diff --git a/app/src/main/java/emu/skyline/KeyReader.kt b/app/src/main/java/emu/skyline/KeyReader.kt index ceeb20b7..bd3c5f0f 100644 --- a/app/src/main/java/emu/skyline/KeyReader.kt +++ b/app/src/main/java/emu/skyline/KeyReader.kt @@ -31,16 +31,14 @@ object KeyReader { if (!DocumentFile.isDocumentUri(context, uri)) return false - val fileName = DocumentFile.fromSingleUri(context, uri)!!.name - if (fileName?.substringAfterLast('.')?.startsWith("keys")?.not() == true) - return false - val tmpOutputFile = File("${context.filesDir.canonicalFile}/${keyType.fileName}.tmp") val inputStream = context.contentResolver.openInputStream(uri) tmpOutputFile.bufferedWriter().use { writer -> val valid = inputStream!!.bufferedReader().useLines { for (line in it) { + if (line.startsWith(";")) continue + val pair = line.split("=") if (pair.size != 2) return@useLines false diff --git a/app/src/main/java/emu/skyline/MainActivity.kt b/app/src/main/java/emu/skyline/MainActivity.kt index 944e6109..e5f7c26c 100644 --- a/app/src/main/java/emu/skyline/MainActivity.kt +++ b/app/src/main/java/emu/skyline/MainActivity.kt @@ -108,12 +108,14 @@ class MainActivity : AppCompatActivity() { binding.chipGroup.setOnCheckedChangeListener { group, checkedId -> for (i in 0 until group.childCount) { if (group.getChildAt(i).id == checkedId) { + settings.filter = i formatFilter = if (i == 0) null else formatOrder[i - 1] populateAdapter() break } } } + binding.chipGroup.check(binding.chipGroup.getChildAt(settings.filter).id) viewModel.stateData.observe(owner = this, onChanged = ::handleState) loadRoms(!settings.refreshRequired) diff --git a/app/src/main/java/emu/skyline/utils/Settings.kt b/app/src/main/java/emu/skyline/utils/Settings.kt index 7cd0e68d..8f3b7bf3 100644 --- a/app/src/main/java/emu/skyline/utils/Settings.kt +++ b/app/src/main/java/emu/skyline/utils/Settings.kt @@ -33,4 +33,6 @@ class Settings @Inject constructor(@ApplicationContext private val context : Con var logCompact by sharedPreferences(context, false) var logLevel by sharedPreferences(context, "3") + + var filter by sharedPreferences(context, 0) } diff --git a/app/src/main/java/emu/skyline/utils/SharedPreferencesDelegate.kt b/app/src/main/java/emu/skyline/utils/SharedPreferencesDelegate.kt index 9c43116b..0360c851 100644 --- a/app/src/main/java/emu/skyline/utils/SharedPreferencesDelegate.kt +++ b/app/src/main/java/emu/skyline/utils/SharedPreferencesDelegate.kt @@ -22,7 +22,8 @@ class SharedPreferencesDelegate(context : Context, private val clazz : Class< Float::class.java, java.lang.Float::class.java -> putFloat(keyName, value as Float) Boolean::class.java, java.lang.Boolean::class.java -> putBoolean(keyName, value as Boolean) String::class.java, java.lang.String::class.java -> putString(keyName, value as String) - else -> error("Unsupported type $clazz ${Float::class.java}") + Int::class.java, java.lang.Integer::class.java -> putInt(keyName, value as Int) + else -> error("Unsupported type $clazz") } }.apply() } @@ -34,6 +35,7 @@ class SharedPreferencesDelegate(context : Context, private val clazz : Class< Float::class.java, java.lang.Float::class.java -> it.getFloat(keyName, default as Float) Boolean::class.java, java.lang.Boolean::class.java -> it.getBoolean(keyName, default as Boolean) String::class.java, java.lang.String::class.java -> it.getString(keyName, default as String) + Int::class.java, java.lang.Integer::class.java -> it.getInt(keyName, default as Int) else -> error("Unsupported type $clazz") } } as T diff --git a/app/src/main/res/layout/app_dialog.xml b/app/src/main/res/layout/app_dialog.xml index ca81c1e7..b0f55c0c 100644 --- a/app/src/main/res/layout/app_dialog.xml +++ b/app/src/main/res/layout/app_dialog.xml @@ -1,73 +1,72 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:nextFocusRight="@id/game_play" + android:padding="16dp"> + android:id="@+id/game_icon" + android:layout_width="150dp" + android:layout_height="150dp" + android:contentDescription="@string/icon" + android:focusable="false" + app:shapeAppearanceOverlay="@style/RoundedAppImage" + tools:src="@drawable/default_icon" /> + + + android:textAppearance="?android:attr/textAppearanceListItem" + android:textSize="18sp" + tools:text="Title" /> + android:id="@+id/game_subtitle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceListItemSecondary" + android:textColor="@android:color/tertiary_text_light" + android:textSize="14sp" + tools:text="Subtitle" /> - - - +