mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-05-13 00:08:39 +02:00
[android,ui] feat fullscreen app setting (#3676)
why not? i like it a lot on both phone and TV. toggle in app settings. disabled by default so no hassle. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3676 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Co-authored-by: xbzk <xbzk@eden-emu.dev> Co-committed-by: xbzk <xbzk@eden-emu.dev>
This commit is contained in:
parent
96e177702e
commit
5ebdb29afd
12 changed files with 223 additions and 10 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
package org.yuzu.yuzu_emu.dialogs
|
package org.yuzu.yuzu_emu.dialogs
|
||||||
|
|
@ -20,6 +20,8 @@ import org.yuzu.yuzu_emu.databinding.DialogChatBinding
|
||||||
import org.yuzu.yuzu_emu.databinding.ItemChatMessageBinding
|
import org.yuzu.yuzu_emu.databinding.ItemChatMessageBinding
|
||||||
import org.yuzu.yuzu_emu.features.settings.model.StringSetting
|
import org.yuzu.yuzu_emu.features.settings.model.StringSetting
|
||||||
import org.yuzu.yuzu_emu.network.NetPlayManager
|
import org.yuzu.yuzu_emu.network.NetPlayManager
|
||||||
|
import org.yuzu.yuzu_emu.utils.CompatUtils
|
||||||
|
import org.yuzu.yuzu_emu.utils.FullscreenHelper
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|
@ -34,6 +36,13 @@ class ChatDialog(context: Context) : BottomSheetDialog(context) {
|
||||||
private lateinit var binding: DialogChatBinding
|
private lateinit var binding: DialogChatBinding
|
||||||
private lateinit var chatAdapter: ChatAdapter
|
private lateinit var chatAdapter: ChatAdapter
|
||||||
private val handler = Handler(Looper.getMainLooper())
|
private val handler = Handler(Looper.getMainLooper())
|
||||||
|
private val hideSystemBars: Boolean by lazy {
|
||||||
|
runCatching {
|
||||||
|
FullscreenHelper.shouldHideSystemBars(CompatUtils.findActivity(context))
|
||||||
|
}.getOrElse {
|
||||||
|
FullscreenHelper.isFullscreenEnabled(context)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(alekpop, crueter): Top drawer for message notifications, perhaps use system notifs?
|
// TODO(alekpop, crueter): Top drawer for message notifications, perhaps use system notifs?
|
||||||
// TODO(alekpop, crueter): Context menu actions for chat users
|
// TODO(alekpop, crueter): Context menu actions for chat users
|
||||||
|
|
@ -41,6 +50,7 @@ class ChatDialog(context: Context) : BottomSheetDialog(context) {
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
setOnShowListener { applyFullscreenMode() }
|
||||||
binding = DialogChatBinding.inflate(LayoutInflater.from(context))
|
binding = DialogChatBinding.inflate(LayoutInflater.from(context))
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
|
||||||
|
|
@ -75,6 +85,11 @@ class ChatDialog(context: Context) : BottomSheetDialog(context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onStart() {
|
||||||
|
super.onStart()
|
||||||
|
applyFullscreenMode()
|
||||||
|
}
|
||||||
|
|
||||||
override fun dismiss() {
|
override fun dismiss() {
|
||||||
NetPlayManager.setChatOpen(false)
|
NetPlayManager.setChatOpen(false)
|
||||||
super.dismiss()
|
super.dismiss()
|
||||||
|
|
@ -108,6 +123,12 @@ class ChatDialog(context: Context) : BottomSheetDialog(context) {
|
||||||
private fun scrollToBottom() {
|
private fun scrollToBottom() {
|
||||||
binding.chatRecyclerView.scrollToPosition(chatAdapter.itemCount - 1)
|
binding.chatRecyclerView.scrollToPosition(chatAdapter.itemCount - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun applyFullscreenMode() {
|
||||||
|
window?.let { window ->
|
||||||
|
FullscreenHelper.applyToWindow(window, hideSystemBars)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ChatAdapter(private val messages: List<ChatMessage>) :
|
class ChatAdapter(private val messages: List<ChatMessage>) :
|
||||||
|
|
|
||||||
|
|
@ -31,15 +31,25 @@ import org.yuzu.yuzu_emu.databinding.DialogLobbyBrowserBinding
|
||||||
import org.yuzu.yuzu_emu.databinding.ItemLobbyRoomBinding
|
import org.yuzu.yuzu_emu.databinding.ItemLobbyRoomBinding
|
||||||
import org.yuzu.yuzu_emu.features.settings.model.StringSetting
|
import org.yuzu.yuzu_emu.features.settings.model.StringSetting
|
||||||
import org.yuzu.yuzu_emu.network.NetPlayManager
|
import org.yuzu.yuzu_emu.network.NetPlayManager
|
||||||
|
import org.yuzu.yuzu_emu.utils.CompatUtils
|
||||||
|
import org.yuzu.yuzu_emu.utils.FullscreenHelper
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
class LobbyBrowser(context: Context) : BottomSheetDialog(context) {
|
class LobbyBrowser(context: Context) : BottomSheetDialog(context) {
|
||||||
private lateinit var binding: DialogLobbyBrowserBinding
|
private lateinit var binding: DialogLobbyBrowserBinding
|
||||||
private lateinit var adapter: LobbyRoomAdapter
|
private lateinit var adapter: LobbyRoomAdapter
|
||||||
private val handler = Handler(Looper.getMainLooper())
|
private val handler = Handler(Looper.getMainLooper())
|
||||||
|
private val hideSystemBars: Boolean by lazy {
|
||||||
|
runCatching {
|
||||||
|
FullscreenHelper.shouldHideSystemBars(CompatUtils.findActivity(context))
|
||||||
|
}.getOrElse {
|
||||||
|
FullscreenHelper.isFullscreenEnabled(context)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
setOnShowListener { applyFullscreenMode() }
|
||||||
|
|
||||||
behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||||
behavior.skipCollapsed =
|
behavior.skipCollapsed =
|
||||||
|
|
@ -81,6 +91,7 @@ class LobbyBrowser(context: Context) : BottomSheetDialog(context) {
|
||||||
behavior.expandedOffset = 0
|
behavior.expandedOffset = 0
|
||||||
behavior.skipCollapsed = true
|
behavior.skipCollapsed = true
|
||||||
behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||||
|
applyFullscreenMode()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupRecyclerView() {
|
private fun setupRecyclerView() {
|
||||||
|
|
@ -274,4 +285,10 @@ class LobbyBrowser(context: Context) : BottomSheetDialog(context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class ScoreItem(val score: Double, val item: NetPlayManager.RoomInfo)
|
private inner class ScoreItem(val score: Double, val item: NetPlayManager.RoomInfo)
|
||||||
|
|
||||||
|
private fun applyFullscreenMode() {
|
||||||
|
window?.let { window ->
|
||||||
|
FullscreenHelper.applyToWindow(window, hideSystemBars)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
package org.yuzu.yuzu_emu.dialogs
|
package org.yuzu.yuzu_emu.dialogs
|
||||||
|
|
@ -36,6 +36,7 @@ import org.yuzu.yuzu_emu.features.settings.model.StringSetting
|
||||||
import org.yuzu.yuzu_emu.network.NetDataValidators
|
import org.yuzu.yuzu_emu.network.NetDataValidators
|
||||||
import org.yuzu.yuzu_emu.network.NetPlayManager
|
import org.yuzu.yuzu_emu.network.NetPlayManager
|
||||||
import org.yuzu.yuzu_emu.utils.CompatUtils
|
import org.yuzu.yuzu_emu.utils.CompatUtils
|
||||||
|
import org.yuzu.yuzu_emu.utils.FullscreenHelper
|
||||||
import org.yuzu.yuzu_emu.utils.GameHelper
|
import org.yuzu.yuzu_emu.utils.GameHelper
|
||||||
|
|
||||||
class NetPlayDialog(context: Context) : BottomSheetDialog(context) {
|
class NetPlayDialog(context: Context) : BottomSheetDialog(context) {
|
||||||
|
|
@ -43,9 +44,17 @@ class NetPlayDialog(context: Context) : BottomSheetDialog(context) {
|
||||||
|
|
||||||
private val gameNameList: MutableList<Array<String>> = mutableListOf()
|
private val gameNameList: MutableList<Array<String>> = mutableListOf()
|
||||||
private val gameIdList: MutableList<Array<Long>> = mutableListOf()
|
private val gameIdList: MutableList<Array<Long>> = mutableListOf()
|
||||||
|
private val hideSystemBars: Boolean by lazy {
|
||||||
|
runCatching {
|
||||||
|
FullscreenHelper.shouldHideSystemBars(CompatUtils.findActivity(context))
|
||||||
|
}.getOrElse {
|
||||||
|
FullscreenHelper.isFullscreenEnabled(context)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
setOnShowListener { applyFullscreenMode() }
|
||||||
|
|
||||||
behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||||
behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||||
|
|
@ -118,6 +127,11 @@ class NetPlayDialog(context: Context) : BottomSheetDialog(context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onStart() {
|
||||||
|
super.onStart()
|
||||||
|
applyFullscreenMode()
|
||||||
|
}
|
||||||
|
|
||||||
data class NetPlayItems(
|
data class NetPlayItems(
|
||||||
val option: Int,
|
val option: Int,
|
||||||
val name: String,
|
val name: String,
|
||||||
|
|
@ -352,6 +366,11 @@ class NetPlayDialog(context: Context) : BottomSheetDialog(context) {
|
||||||
TextValidatorWatcher.validStates.clear()
|
TextValidatorWatcher.validStates.clear()
|
||||||
val activity = CompatUtils.findActivity(context)
|
val activity = CompatUtils.findActivity(context)
|
||||||
val dialog = BottomSheetDialog(activity)
|
val dialog = BottomSheetDialog(activity)
|
||||||
|
dialog.setOnShowListener {
|
||||||
|
dialog.window?.let { window ->
|
||||||
|
FullscreenHelper.applyToWindow(window, hideSystemBars)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dialog.behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
dialog.behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||||
dialog.behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
dialog.behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||||
|
|
@ -582,6 +601,12 @@ class NetPlayDialog(context: Context) : BottomSheetDialog(context) {
|
||||||
dialog.show()
|
dialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun applyFullscreenMode() {
|
||||||
|
window?.let { window ->
|
||||||
|
FullscreenHelper.applyToWindow(window, hideSystemBars)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun showModerationDialog() {
|
private fun showModerationDialog() {
|
||||||
val activity = CompatUtils.findActivity(context)
|
val activity = CompatUtils.findActivity(context)
|
||||||
val dialog = MaterialAlertDialogBuilder(activity)
|
val dialog = MaterialAlertDialogBuilder(activity)
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,8 @@ object Settings {
|
||||||
const val PREF_THEME_MODE = "ThemeMode"
|
const val PREF_THEME_MODE = "ThemeMode"
|
||||||
const val PREF_BLACK_BACKGROUNDS = "BlackBackgrounds"
|
const val PREF_BLACK_BACKGROUNDS = "BlackBackgrounds"
|
||||||
const val PREF_STATIC_THEME_COLOR = "StaticThemeColor"
|
const val PREF_STATIC_THEME_COLOR = "StaticThemeColor"
|
||||||
|
const val PREF_APP_FULLSCREEN = "AppFullscreen"
|
||||||
|
const val APP_FULLSCREEN_DEFAULT = false
|
||||||
|
|
||||||
enum class EmulationOrientation(val int: Int) {
|
enum class EmulationOrientation(val int: Int) {
|
||||||
Unspecified(0),
|
Unspecified(0),
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,7 @@ class SettingsActivity : AppCompatActivity() {
|
||||||
)
|
)
|
||||||
|
|
||||||
setInsets()
|
setInsets()
|
||||||
|
applyFullscreenPreference()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun navigateBack() {
|
fun navigateBack() {
|
||||||
|
|
@ -122,6 +123,18 @@ class SettingsActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
applyFullscreenPreference()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onWindowFocusChanged(hasFocus: Boolean) {
|
||||||
|
super.onWindowFocusChanged(hasFocus)
|
||||||
|
if (hasFocus) {
|
||||||
|
applyFullscreenPreference()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
super.onStop()
|
super.onStop()
|
||||||
Log.info("[SettingsActivity] Settings activity stopping. Saving settings to INI...")
|
Log.info("[SettingsActivity] Settings activity stopping. Saving settings to INI...")
|
||||||
|
|
@ -188,4 +201,8 @@ class SettingsActivity : AppCompatActivity() {
|
||||||
windowInsets
|
windowInsets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun applyFullscreenPreference() {
|
||||||
|
FullscreenHelper.applyToActivity(this)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ import org.yuzu.yuzu_emu.features.settings.model.view.*
|
||||||
import org.yuzu.yuzu_emu.utils.InputHandler
|
import org.yuzu.yuzu_emu.utils.InputHandler
|
||||||
import org.yuzu.yuzu_emu.utils.NativeConfig
|
import org.yuzu.yuzu_emu.utils.NativeConfig
|
||||||
import org.yuzu.yuzu_emu.utils.DirectoryInitialization
|
import org.yuzu.yuzu_emu.utils.DirectoryInitialization
|
||||||
|
import org.yuzu.yuzu_emu.utils.FullscreenHelper
|
||||||
|
import androidx.core.content.edit
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import org.yuzu.yuzu_emu.fragments.MessageDialogFragment
|
import org.yuzu.yuzu_emu.fragments.MessageDialogFragment
|
||||||
|
|
||||||
|
|
@ -1187,6 +1189,39 @@ class SettingsFragmentPresenter(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val fullscreenSetting: AbstractBooleanSetting = object : AbstractBooleanSetting {
|
||||||
|
override fun getBoolean(needsGlobal: Boolean): Boolean =
|
||||||
|
FullscreenHelper.isFullscreenEnabled(context)
|
||||||
|
|
||||||
|
override fun setBoolean(value: Boolean) {
|
||||||
|
FullscreenHelper.setFullscreenEnabled(context, value)
|
||||||
|
settingsViewModel.setShouldRecreate(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
override val key: String = Settings.PREF_APP_FULLSCREEN
|
||||||
|
override val isRuntimeModifiable: Boolean = true
|
||||||
|
override val pairedSettingKey: String = ""
|
||||||
|
override val isSwitchable: Boolean = false
|
||||||
|
override var global: Boolean = true
|
||||||
|
override val isSaveable: Boolean = true
|
||||||
|
override val defaultValue: Boolean = Settings.APP_FULLSCREEN_DEFAULT
|
||||||
|
|
||||||
|
override fun getValueAsString(needsGlobal: Boolean): String =
|
||||||
|
getBoolean(needsGlobal).toString()
|
||||||
|
|
||||||
|
override fun reset() {
|
||||||
|
setBoolean(defaultValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
add(
|
||||||
|
SwitchSetting(
|
||||||
|
fullscreenSetting,
|
||||||
|
titleId = R.string.fullscreen_mode,
|
||||||
|
descriptionId = R.string.fullscreen_mode_description
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
add(HeaderSetting(R.string.buttons))
|
add(HeaderSetting(R.string.buttons))
|
||||||
add(BooleanSetting.ENABLE_FOLDER_BUTTON.key)
|
add(BooleanSetting.ENABLE_FOLDER_BUTTON.key)
|
||||||
add(BooleanSetting.ENABLE_QLAUNCH_BUTTON.key)
|
add(BooleanSetting.ENABLE_QLAUNCH_BUTTON.key)
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import org.yuzu.yuzu_emu.R
|
||||||
import org.yuzu.yuzu_emu.YuzuApplication
|
import org.yuzu.yuzu_emu.YuzuApplication
|
||||||
import org.yuzu.yuzu_emu.databinding.ActivitySettingsBinding
|
import org.yuzu.yuzu_emu.databinding.ActivitySettingsBinding
|
||||||
import org.yuzu.yuzu_emu.utils.DirectoryInitialization
|
import org.yuzu.yuzu_emu.utils.DirectoryInitialization
|
||||||
|
import org.yuzu.yuzu_emu.utils.FullscreenHelper
|
||||||
import org.yuzu.yuzu_emu.utils.InsetsHelper
|
import org.yuzu.yuzu_emu.utils.InsetsHelper
|
||||||
import org.yuzu.yuzu_emu.utils.ThemeHelper
|
import org.yuzu.yuzu_emu.utils.ThemeHelper
|
||||||
|
|
||||||
|
|
@ -89,6 +90,7 @@ class SettingsSubscreenActivity : AppCompatActivity() {
|
||||||
)
|
)
|
||||||
|
|
||||||
setInsets()
|
setInsets()
|
||||||
|
applyFullscreenPreference()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
|
|
@ -98,6 +100,18 @@ class SettingsSubscreenActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
applyFullscreenPreference()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onWindowFocusChanged(hasFocus: Boolean) {
|
||||||
|
super.onWindowFocusChanged(hasFocus)
|
||||||
|
if (hasFocus) {
|
||||||
|
applyFullscreenPreference()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun navigateBack() {
|
fun navigateBack() {
|
||||||
val navHostFragment =
|
val navHostFragment =
|
||||||
supportFragmentManager.findFragmentById(R.id.fragment_container) as NavHostFragment
|
supportFragmentManager.findFragmentById(R.id.fragment_container) as NavHostFragment
|
||||||
|
|
@ -149,4 +163,8 @@ class SettingsSubscreenActivity : AppCompatActivity() {
|
||||||
windowInsets
|
windowInsets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun applyFullscreenPreference() {
|
||||||
|
FullscreenHelper.applyToActivity(this)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
import androidx.core.view.updatePadding
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
|
|
@ -22,6 +23,7 @@ import org.yuzu.yuzu_emu.databinding.FragmentProfileManagerBinding
|
||||||
import org.yuzu.yuzu_emu.model.HomeViewModel
|
import org.yuzu.yuzu_emu.model.HomeViewModel
|
||||||
import org.yuzu.yuzu_emu.model.UserProfile
|
import org.yuzu.yuzu_emu.model.UserProfile
|
||||||
import org.yuzu.yuzu_emu.utils.NativeConfig
|
import org.yuzu.yuzu_emu.utils.NativeConfig
|
||||||
|
import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins
|
||||||
|
|
||||||
class ProfileManagerFragment : Fragment() {
|
class ProfileManagerFragment : Fragment() {
|
||||||
private var _binding: FragmentProfileManagerBinding? = null
|
private var _binding: FragmentProfileManagerBinding? = null
|
||||||
|
|
@ -172,11 +174,19 @@ class ProfileManagerFragment : Fragment() {
|
||||||
val leftInsets = barInsets.left + cutoutInsets.left
|
val leftInsets = barInsets.left + cutoutInsets.left
|
||||||
val rightInsets = barInsets.right + cutoutInsets.right
|
val rightInsets = barInsets.right + cutoutInsets.right
|
||||||
|
|
||||||
val fabLayoutParams = binding.buttonAddUser.layoutParams as ViewGroup.MarginLayoutParams
|
binding.toolbarProfiles.updateMargins(left = leftInsets, right = rightInsets)
|
||||||
fabLayoutParams.leftMargin = leftInsets + 24
|
binding.listProfiles.updateMargins(left = leftInsets, right = rightInsets)
|
||||||
fabLayoutParams.rightMargin = rightInsets + 24
|
binding.listProfiles.updatePadding(
|
||||||
fabLayoutParams.bottomMargin = barInsets.bottom + 24
|
bottom = barInsets.bottom +
|
||||||
binding.buttonAddUser.layoutParams = fabLayoutParams
|
resources.getDimensionPixelSize(R.dimen.spacing_bottom_list_fab)
|
||||||
|
)
|
||||||
|
|
||||||
|
val fabSpacing = resources.getDimensionPixelSize(R.dimen.spacing_fab)
|
||||||
|
binding.buttonAddUser.updateMargins(
|
||||||
|
left = leftInsets + fabSpacing,
|
||||||
|
right = rightInsets + fabSpacing,
|
||||||
|
bottom = barInsets.bottom + fabSpacing
|
||||||
|
)
|
||||||
|
|
||||||
windowInsets
|
windowInsets
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,7 @@ class MainActivity : AppCompatActivity(), ThemeProvider {
|
||||||
checkForUpdates()
|
checkForUpdates()
|
||||||
}
|
}
|
||||||
setInsets()
|
setInsets()
|
||||||
|
applyFullscreenPreference()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkForUpdates() {
|
private fun checkForUpdates() {
|
||||||
|
|
@ -345,6 +346,14 @@ class MainActivity : AppCompatActivity(), ThemeProvider {
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
ThemeHelper.setCorrectTheme(this)
|
ThemeHelper.setCorrectTheme(this)
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
applyFullscreenPreference()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onWindowFocusChanged(hasFocus: Boolean) {
|
||||||
|
super.onWindowFocusChanged(hasFocus)
|
||||||
|
if (hasFocus) {
|
||||||
|
applyFullscreenPreference()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setInsets() = ViewCompat.setOnApplyWindowInsetsListener(
|
private fun setInsets() = ViewCompat.setOnApplyWindowInsetsListener(
|
||||||
|
|
@ -364,6 +373,10 @@ class MainActivity : AppCompatActivity(), ThemeProvider {
|
||||||
windowInsets
|
windowInsets
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun applyFullscreenPreference() {
|
||||||
|
FullscreenHelper.applyToActivity(this)
|
||||||
|
}
|
||||||
|
|
||||||
override fun setTheme(resId: Int) {
|
override fun setTheme(resId: Int) {
|
||||||
super.setTheme(resId)
|
super.setTheme(resId)
|
||||||
themeId = resId
|
themeId = resId
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
package org.yuzu.yuzu_emu.utils
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.Window
|
||||||
|
import androidx.core.content.edit
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
import androidx.core.view.WindowInsetsControllerCompat
|
||||||
|
import androidx.preference.PreferenceManager
|
||||||
|
import org.yuzu.yuzu_emu.features.settings.model.Settings
|
||||||
|
|
||||||
|
object FullscreenHelper {
|
||||||
|
fun isFullscreenEnabled(context: Context): Boolean {
|
||||||
|
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(
|
||||||
|
Settings.PREF_APP_FULLSCREEN,
|
||||||
|
Settings.APP_FULLSCREEN_DEFAULT
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setFullscreenEnabled(context: Context, enabled: Boolean) {
|
||||||
|
PreferenceManager.getDefaultSharedPreferences(context).edit {
|
||||||
|
putBoolean(Settings.PREF_APP_FULLSCREEN, enabled)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun shouldHideSystemBars(activity: Activity): Boolean {
|
||||||
|
val rootInsets = ViewCompat.getRootWindowInsets(activity.window.decorView)
|
||||||
|
val barsCurrentlyHidden =
|
||||||
|
rootInsets?.isVisible(WindowInsetsCompat.Type.systemBars())?.not() ?: false
|
||||||
|
return isFullscreenEnabled(activity) || barsCurrentlyHidden
|
||||||
|
}
|
||||||
|
|
||||||
|
fun applyToWindow(window: Window, hideSystemBars: Boolean) {
|
||||||
|
val controller = WindowInsetsControllerCompat(window, window.decorView)
|
||||||
|
|
||||||
|
if (hideSystemBars) {
|
||||||
|
controller.hide(WindowInsetsCompat.Type.systemBars())
|
||||||
|
controller.systemBarsBehavior =
|
||||||
|
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||||
|
} else {
|
||||||
|
controller.show(WindowInsetsCompat.Type.systemBars())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun applyToActivity(activity: Activity) {
|
||||||
|
applyToWindow(activity.window, isFullscreenEnabled(activity))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,21 +5,22 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="?attr/colorSurface"
|
android:background="?attr/colorSurface">
|
||||||
android:fitsSystemWindows="true">
|
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:id="@+id/appbar"
|
android:id="@+id/appbar"
|
||||||
style="@style/Widget.Eden.TransparentTopAppBarLayout"
|
style="@style/Widget.Eden.TransparentTopAppBarLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:fitsSystemWindows="true">
|
android:fitsSystemWindows="true"
|
||||||
|
android:touchscreenBlocksFocus="false">
|
||||||
|
|
||||||
<com.google.android.material.appbar.MaterialToolbar
|
<com.google.android.material.appbar.MaterialToolbar
|
||||||
android:id="@+id/toolbar_profiles"
|
android:id="@+id/toolbar_profiles"
|
||||||
style="@style/Widget.Eden.TransparentTopToolbar"
|
style="@style/Widget.Eden.TransparentTopToolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:touchscreenBlocksFocus="false"
|
||||||
app:title="@string/profile_manager"
|
app:title="@string/profile_manager"
|
||||||
app:navigationIcon="@drawable/ic_back"
|
app:navigationIcon="@drawable/ic_back"
|
||||||
app:titleCentered="false" />
|
app:titleCentered="false" />
|
||||||
|
|
|
||||||
|
|
@ -1160,6 +1160,8 @@
|
||||||
<string name="theme_material_you">Material You</string>
|
<string name="theme_material_you">Material You</string>
|
||||||
<string name="app_settings">App Settings</string>
|
<string name="app_settings">App Settings</string>
|
||||||
<string name="theme_and_color">Theme And Color</string>
|
<string name="theme_and_color">Theme And Color</string>
|
||||||
|
<string name="fullscreen_mode">Fullscreen mode</string>
|
||||||
|
<string name="fullscreen_mode_description">Hide Android system bars across app screens. Swipe from an edge to reveal them temporarily.</string>
|
||||||
|
|
||||||
<!-- Theme Modes -->
|
<!-- Theme Modes -->
|
||||||
<string name="change_theme_mode">Change theme mode</string>
|
<string name="change_theme_mode">Change theme mode</string>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue