mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-24 00:51:48 +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 'androidx.fragment:fragment-ktx:1.2.5'
|
||||||
implementation "com.google.dagger:hilt-android:$hilt_version"
|
implementation "com.google.dagger:hilt-android:$hilt_version"
|
||||||
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
|
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
|
||||||
|
implementation 'com.google.android:flexbox:2.0.1'
|
||||||
|
|
||||||
/* Kotlin */
|
/* Kotlin */
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
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
|
* This inflates the layout of the dialog after initial view creation
|
||||||
*/
|
*/
|
||||||
override fun onCreateView(inflater : LayoutInflater, container : ViewGroup?, savedInstanceState : Bundle?) : View? {
|
override fun onCreateView(inflater : LayoutInflater, container : ViewGroup?, savedInstanceState : Bundle?) = AppDialogBinding.inflate(inflater).also { binding = it }.root
|
||||||
return 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
|
* 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))
|
if (!DocumentFile.isDocumentUri(context, uri))
|
||||||
return false
|
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 tmpOutputFile = File("${context.filesDir.canonicalFile}/${keyType.fileName}.tmp")
|
||||||
|
|
||||||
val inputStream = context.contentResolver.openInputStream(uri)
|
val inputStream = context.contentResolver.openInputStream(uri)
|
||||||
tmpOutputFile.bufferedWriter().use { writer ->
|
tmpOutputFile.bufferedWriter().use { writer ->
|
||||||
val valid = inputStream!!.bufferedReader().useLines {
|
val valid = inputStream!!.bufferedReader().useLines {
|
||||||
for (line in it) {
|
for (line in it) {
|
||||||
|
if (line.startsWith(";")) continue
|
||||||
|
|
||||||
val pair = line.split("=")
|
val pair = line.split("=")
|
||||||
if (pair.size != 2)
|
if (pair.size != 2)
|
||||||
return@useLines false
|
return@useLines false
|
||||||
|
@ -108,12 +108,14 @@ class MainActivity : AppCompatActivity() {
|
|||||||
binding.chipGroup.setOnCheckedChangeListener { group, checkedId ->
|
binding.chipGroup.setOnCheckedChangeListener { group, checkedId ->
|
||||||
for (i in 0 until group.childCount) {
|
for (i in 0 until group.childCount) {
|
||||||
if (group.getChildAt(i).id == checkedId) {
|
if (group.getChildAt(i).id == checkedId) {
|
||||||
|
settings.filter = i
|
||||||
formatFilter = if (i == 0) null else formatOrder[i - 1]
|
formatFilter = if (i == 0) null else formatOrder[i - 1]
|
||||||
populateAdapter()
|
populateAdapter()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
binding.chipGroup.check(binding.chipGroup.getChildAt(settings.filter).id)
|
||||||
|
|
||||||
viewModel.stateData.observe(owner = this, onChanged = ::handleState)
|
viewModel.stateData.observe(owner = this, onChanged = ::handleState)
|
||||||
loadRoms(!settings.refreshRequired)
|
loadRoms(!settings.refreshRequired)
|
||||||
|
@ -33,4 +33,6 @@ class Settings @Inject constructor(@ApplicationContext private val context : Con
|
|||||||
var logCompact by sharedPreferences(context, false)
|
var logCompact by sharedPreferences(context, false)
|
||||||
|
|
||||||
var logLevel by sharedPreferences(context, "3")
|
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)
|
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)
|
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)
|
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()
|
}.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)
|
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)
|
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)
|
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")
|
else -> error("Unsupported type $clazz")
|
||||||
}
|
}
|
||||||
} as T
|
} as T
|
||||||
|
@ -40,13 +40,12 @@
|
|||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
tools:text="Subtitle" />
|
tools:text="Subtitle" />
|
||||||
|
|
||||||
<LinearLayout
|
<com.google.android.flexbox.FlexboxLayout
|
||||||
android:id="@+id/linearLayout"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:orientation="horizontal">
|
app:flexWrap="wrap">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/game_play"
|
android:id="@+id/game_play"
|
||||||
@ -68,6 +67,6 @@
|
|||||||
android:layout_marginStart="6dp"
|
android:layout_marginStart="6dp"
|
||||||
android:text="@string/pin"
|
android:text="@string/pin"
|
||||||
android:textColor="?attr/colorAccent" />
|
android:textColor="?attr/colorAccent" />
|
||||||
</LinearLayout>
|
</com.google.android.flexbox.FlexboxLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -122,7 +122,7 @@
|
|||||||
android:id="@+id/swipe_refresh_layout"
|
android:id="@+id/swipe_refresh_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="-4dp"
|
android:layout_marginTop="-8dp"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@ -139,9 +139,10 @@
|
|||||||
android:id="@+id/chip_group"
|
android:id="@+id/chip_group"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="18dp"
|
android:paddingStart="18dp"
|
||||||
android:layout_marginTop="16dp"
|
android:paddingTop="16dp"
|
||||||
android:layout_marginEnd="18dp"
|
android:paddingEnd="18dp"
|
||||||
|
android:paddingBottom="4dp"
|
||||||
app:checkedChip="@id/all_chip"
|
app:checkedChip="@id/all_chip"
|
||||||
app:chipSpacingHorizontal="16dp"
|
app:chipSpacingHorizontal="16dp"
|
||||||
app:selectionRequired="true"
|
app:selectionRequired="true"
|
||||||
@ -161,8 +162,7 @@
|
|||||||
android:id="@+id/app_list"
|
android:id="@+id/app_list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false" />
|
||||||
android:paddingTop="4dp" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
Loading…
Reference in New Issue
Block a user