mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
minor ui touchups
This commit is contained in:
@@ -28,7 +28,6 @@ import androidx.documentfile.provider.DocumentFile
|
||||
import coil.load
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.materialswitch.MaterialSwitch
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.FileOutputStream
|
||||
@@ -121,7 +120,6 @@ class GameLibraryActivity : AppCompatActivity() {
|
||||
private lateinit var btnAbout: ImageButton
|
||||
private lateinit var btnViewList: MaterialButton
|
||||
private lateinit var btnViewGrid: MaterialButton
|
||||
private lateinit var switchBoxArtLookup: MaterialSwitch
|
||||
|
||||
private var gamesFolderUri: Uri? = null
|
||||
private var scanGeneration = 0
|
||||
@@ -175,15 +173,14 @@ class GameLibraryActivity : AppCompatActivity() {
|
||||
btnAbout = findViewById(R.id.btn_library_about)
|
||||
btnViewList = findViewById(R.id.btn_view_list)
|
||||
btnViewGrid = findViewById(R.id.btn_view_grid)
|
||||
switchBoxArtLookup = findViewById(R.id.switch_box_art_lookup)
|
||||
btnViewList.isCheckable = true
|
||||
btnViewGrid.isCheckable = true
|
||||
|
||||
gamesFolderUri = prefs.getString("gamesFolderUri", null)?.let(Uri::parse)
|
||||
useCoverGrid = prefs.getBoolean("library_cover_grid", false)
|
||||
boxArtLookupEnabled = prefs.getBoolean("library_box_art_lookup", true)
|
||||
boxArtLookupEnabled = true
|
||||
prefs.edit().putBoolean("library_box_art_lookup", true).apply()
|
||||
|
||||
switchBoxArtLookup.isChecked = boxArtLookupEnabled
|
||||
syncDisplayModeUi()
|
||||
|
||||
btnBootDashboard.setOnClickListener {
|
||||
@@ -207,13 +204,6 @@ class GameLibraryActivity : AppCompatActivity() {
|
||||
}
|
||||
btnViewList.setOnClickListener { setDisplayMode(false) }
|
||||
btnViewGrid.setOnClickListener { setDisplayMode(true) }
|
||||
switchBoxArtLookup.setOnCheckedChangeListener { _, checked ->
|
||||
boxArtLookupEnabled = checked
|
||||
prefs.edit().putBoolean("library_box_art_lookup", checked).apply()
|
||||
if (useCoverGrid) {
|
||||
renderGames()
|
||||
}
|
||||
}
|
||||
updateConvertButtonState()
|
||||
|
||||
if (!isFolderReady(gamesFolderUri)) {
|
||||
@@ -572,7 +562,6 @@ class GameLibraryActivity : AppCompatActivity() {
|
||||
private fun syncDisplayModeUi() {
|
||||
btnViewList.isChecked = !useCoverGrid
|
||||
btnViewGrid.isChecked = useCoverGrid
|
||||
switchBoxArtLookup.visibility = if (useCoverGrid) View.VISIBLE else View.GONE
|
||||
gamesListContainer.visibility = if (useCoverGrid) View.GONE else View.VISIBLE
|
||||
gamesGridContainer.visibility = if (useCoverGrid) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Process
|
||||
import android.view.Gravity
|
||||
import android.view.InputDevice
|
||||
import android.view.KeyEvent
|
||||
import android.view.MotionEvent
|
||||
@@ -725,48 +726,108 @@ class MainActivity : SDLActivity(), InputManager.InputDeviceListener {
|
||||
return
|
||||
}
|
||||
|
||||
val options = arrayOf(
|
||||
getString(R.string.in_game_menu_resume),
|
||||
val dp = resources.displayMetrics.density
|
||||
val verticalButtonSpacing = (8 * dp).toInt()
|
||||
val horizontalButtonSpacing = (8 * dp).toInt()
|
||||
lateinit var dialog: androidx.appcompat.app.AlertDialog
|
||||
data class MenuButtonSpec(
|
||||
val label: String,
|
||||
val action: () -> Unit,
|
||||
)
|
||||
|
||||
fun createMenuButton(spec: MenuButtonSpec): MaterialButton {
|
||||
return MaterialButton(
|
||||
this@MainActivity,
|
||||
null,
|
||||
com.google.android.material.R.attr.materialButtonOutlinedStyle
|
||||
).apply {
|
||||
text = spec.label
|
||||
gravity = Gravity.CENTER
|
||||
textAlignment = View.TEXT_ALIGNMENT_CENTER
|
||||
isSingleLine = false
|
||||
maxLines = 2
|
||||
setOnClickListener {
|
||||
dialog.dismiss()
|
||||
spec.action()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun addSingleButton(parent: LinearLayout, spec: MenuButtonSpec) {
|
||||
parent.addView(createMenuButton(spec).apply {
|
||||
layoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
).also { lp ->
|
||||
lp.bottomMargin = verticalButtonSpacing
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun addButtonRow(parent: LinearLayout, left: MenuButtonSpec, right: MenuButtonSpec) {
|
||||
parent.addView(
|
||||
LinearLayout(this).apply {
|
||||
orientation = LinearLayout.HORIZONTAL
|
||||
layoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
).also { lp ->
|
||||
lp.bottomMargin = verticalButtonSpacing
|
||||
}
|
||||
addView(createMenuButton(left).apply {
|
||||
layoutParams = LinearLayout.LayoutParams(
|
||||
0,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
1f
|
||||
).also { lp ->
|
||||
lp.marginEnd = horizontalButtonSpacing
|
||||
}
|
||||
})
|
||||
addView(createMenuButton(right).apply {
|
||||
layoutParams = LinearLayout.LayoutParams(
|
||||
0,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
1f
|
||||
)
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
val resumeButton = MenuButtonSpec(getString(R.string.in_game_menu_resume)) { /* Resume */ }
|
||||
val touchControlsButton = MenuButtonSpec(
|
||||
if (isControllerVisible) {
|
||||
getString(R.string.in_game_menu_hide_touch_controls)
|
||||
} else {
|
||||
getString(R.string.in_game_menu_show_touch_controls)
|
||||
},
|
||||
getString(R.string.in_game_menu_save_state),
|
||||
getString(R.string.in_game_menu_load_state),
|
||||
getString(R.string.in_game_menu_reboot_system),
|
||||
getString(R.string.in_game_menu_exit_to_library),
|
||||
getString(R.string.in_game_menu_quit_app),
|
||||
)
|
||||
|
||||
val dp = resources.displayMetrics.density
|
||||
lateinit var dialog: androidx.appcompat.app.AlertDialog
|
||||
}
|
||||
) {
|
||||
toggleOnScreenController()
|
||||
}
|
||||
val saveStateButton = MenuButtonSpec(getString(R.string.in_game_menu_save_state)) {
|
||||
showSaveStateDialog()
|
||||
}
|
||||
val loadStateButton = MenuButtonSpec(getString(R.string.in_game_menu_load_state)) {
|
||||
showLoadStateDialog()
|
||||
}
|
||||
val rebootButton = MenuButtonSpec(getString(R.string.in_game_menu_reboot_system)) {
|
||||
showRebootSystemConfirmation()
|
||||
}
|
||||
val exitToLibraryButton = MenuButtonSpec(getString(R.string.in_game_menu_exit_to_library)) {
|
||||
exitToGameLibrary()
|
||||
}
|
||||
val quitAppButton = MenuButtonSpec(getString(R.string.in_game_menu_quit_app)) {
|
||||
quitApp()
|
||||
}
|
||||
|
||||
val buttonList = LinearLayout(this).apply {
|
||||
orientation = LinearLayout.VERTICAL
|
||||
setPadding((20 * dp).toInt(), (12 * dp).toInt(), (20 * dp).toInt(), 0)
|
||||
options.forEachIndexed { i, label ->
|
||||
addView(MaterialButton(this@MainActivity, null,
|
||||
com.google.android.material.R.attr.materialButtonOutlinedStyle).apply {
|
||||
text = label
|
||||
layoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
).also { lp -> lp.bottomMargin = (8 * dp).toInt() }
|
||||
setOnClickListener {
|
||||
dialog.dismiss()
|
||||
when (i) {
|
||||
0 -> { /* Resume — dialog dismissed above */ }
|
||||
1 -> toggleOnScreenController()
|
||||
2 -> showSaveStateDialog()
|
||||
3 -> showLoadStateDialog()
|
||||
4 -> showRebootSystemConfirmation()
|
||||
5 -> exitToGameLibrary()
|
||||
6 -> quitApp()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
addSingleButton(this, resumeButton)
|
||||
addSingleButton(this, touchControlsButton)
|
||||
addButtonRow(this, saveStateButton, loadStateButton)
|
||||
addSingleButton(this, rebootButton)
|
||||
addButtonRow(this, exitToLibraryButton, quitAppButton)
|
||||
}
|
||||
|
||||
val scrollContainer = NestedScrollView(this).apply {
|
||||
|
||||
@@ -169,13 +169,30 @@
|
||||
app:iconPadding="8dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/switch_box_art_lookup"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/library_box_art_lookup"
|
||||
android:textColor="@color/xemu_text_muted" />
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:contentDescription="@null"
|
||||
android:src="@drawable/ic_xemu_info"
|
||||
android:tint="@color/xemu_notice" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_library_long_press_hint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/library_long_press_hint"
|
||||
android:textAlignment="center"
|
||||
android:textAppearance="@style/TextAppearance.Material3.BodySmall"
|
||||
android:textColor="@color/xemu_text_muted" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
<color name="xemu_green_dark">#66FF00</color>
|
||||
<color name="xemu_green_container">#1A5224</color>
|
||||
|
||||
<!-- Notice -->
|
||||
<color name="xemu_notice">#FFD54F</color>
|
||||
|
||||
<!-- Danger / warning -->
|
||||
<color name="xemu_warning">#FF6B6B</color>
|
||||
<color name="xemu_warning_container">#4A1515</color>
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
<string name="library_view_list">List</string>
|
||||
<string name="library_view_cover_grid">Cover Grid</string>
|
||||
<string name="library_box_art_lookup">Look up box art online</string>
|
||||
<string name="library_long_press_hint">Press and hold on a game for more options.</string>
|
||||
<string name="library_no_folder">No folder selected</string>
|
||||
<string name="library_loading_games">Scanning games...</string>
|
||||
<string name="library_converting_game">Converting %1$s...</string>
|
||||
|
||||
Reference in New Issue
Block a user