mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-23 09:11:52 +01:00
Add flexbox layout for wrapping
* Save filter selection * Handle ini comments in key reader
This commit is contained in:
parent
bcdd2d9027
commit
2e76fbe4b6
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -22,7 +22,8 @@ class SharedPreferencesDelegate<T>(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<T>(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
|
||||
|
@ -1,73 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
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">
|
||||
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">
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
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: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" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/game_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:orientation="vertical">
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||
android:textSize="18sp"
|
||||
tools:text="Title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/game_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
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" />
|
||||
|
||||
<TextView
|
||||
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" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="8dp"
|
||||
android:orientation="horizontal">
|
||||
<com.google.android.flexbox.FlexboxLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="8dp"
|
||||
app:flexWrap="wrap">
|
||||
|
||||
<Button
|
||||
android:id="@+id/game_play"
|
||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton.Icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:focusedByDefault="true"
|
||||
android:text="@string/play"
|
||||
android:textColor="?attr/colorAccent"
|
||||
app:icon="@drawable/ic_play"
|
||||
app:iconTint="?attr/colorAccent" />
|
||||
android:id="@+id/game_play"
|
||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton.Icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:focusedByDefault="true"
|
||||
android:text="@string/play"
|
||||
android:textColor="?attr/colorAccent"
|
||||
app:icon="@drawable/ic_play"
|
||||
app:iconTint="?attr/colorAccent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/game_pin"
|
||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:text="@string/pin"
|
||||
android:textColor="?attr/colorAccent" />
|
||||
</LinearLayout>
|
||||
android:id="@+id/game_pin"
|
||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:text="@string/pin"
|
||||
android:textColor="?attr/colorAccent" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
@ -122,7 +122,7 @@
|
||||
android:id="@+id/swipe_refresh_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="-4dp"
|
||||
android:layout_marginTop="-8dp"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<LinearLayout
|
||||
@ -139,9 +139,10 @@
|
||||
android:id="@+id/chip_group"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="18dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="18dp"
|
||||
android:paddingStart="18dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingEnd="18dp"
|
||||
android:paddingBottom="4dp"
|
||||
app:checkedChip="@id/all_chip"
|
||||
app:chipSpacingHorizontal="16dp"
|
||||
app:selectionRequired="true"
|
||||
@ -161,8 +162,7 @@
|
||||
android:id="@+id/app_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:paddingTop="4dp" />
|
||||
android:clipToPadding="false" />
|
||||
</LinearLayout>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user