From aa8a48e94c1eea9fc49ef999c666c7a76457c5b1 Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Mon, 22 May 2023 13:52:04 -0400 Subject: android: Use collapsing toolbar layout in settings --- .../yuzu_emu/features/settings/ui/SettingsActivity.kt | 4 ++++ .../features/settings/ui/SettingsFragmentPresenter.kt | 14 +++++++------- .../app/src/main/res/layout/activity_settings.xml | 19 +++++++++++++++---- 3 files changed, 26 insertions(+), 11 deletions(-) (limited to 'src/android') diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt index aadf273dd..5c6f7eec5 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsActivity.kt @@ -190,6 +190,10 @@ class SettingsActivity : AppCompatActivity(), SettingsActivityView { finish() } + fun setToolbarTitle(title: String) { + binding.toolbarSettingsLayout.title = title + } + private val settingsFragment: SettingsFragment? get() = supportFragmentManager.findFragmentByTag(FRAGMENT_TAG) as SettingsFragment? diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt index dda44376c..bd5bfca5e 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt @@ -54,7 +54,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView) fun loadSettingsList() { if (!TextUtils.isEmpty(gameId)) { - settingsActivity.title = "Game Settings: $gameId" + settingsActivity.setToolbarTitle("Game Settings: $gameId") } val sl = ArrayList() if (menuTag == null) { @@ -77,7 +77,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView) } private fun addConfigSettings(sl: ArrayList) { - settingsActivity.setTitle(R.string.preferences_settings) + settingsActivity.setToolbarTitle(settingsActivity.getString(R.string.preferences_settings)) sl.apply { add( SubmenuSetting( @@ -121,7 +121,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView) } private fun addGeneralSettings(sl: ArrayList) { - settingsActivity.setTitle(R.string.preferences_general) + settingsActivity.setToolbarTitle(settingsActivity.getString(R.string.preferences_general)) sl.apply { add( SwitchSetting( @@ -159,7 +159,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView) } private fun addSystemSettings(sl: ArrayList) { - settingsActivity.setTitle(R.string.preferences_system) + settingsActivity.setToolbarTitle(settingsActivity.getString(R.string.preferences_system)) sl.apply { add( SwitchSetting( @@ -214,7 +214,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView) } private fun addGraphicsSettings(sl: ArrayList) { - settingsActivity.setTitle(R.string.preferences_graphics) + settingsActivity.setToolbarTitle(settingsActivity.getString(R.string.preferences_graphics)) sl.apply { add( SingleChoiceSetting( @@ -322,7 +322,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView) } private fun addAudioSettings(sl: ArrayList) { - settingsActivity.setTitle(R.string.preferences_audio) + settingsActivity.setToolbarTitle(settingsActivity.getString(R.string.preferences_audio)) sl.add( SliderSetting( IntSetting.AUDIO_VOLUME, @@ -338,7 +338,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView) } private fun addThemeSettings(sl: ArrayList) { - settingsActivity.setTitle(R.string.preferences_theme) + settingsActivity.setToolbarTitle(settingsActivity.getString(R.string.preferences_theme)) sl.apply { val theme: AbstractIntSetting = object : AbstractIntSetting { override var int: Int diff --git a/src/android/app/src/main/res/layout/activity_settings.xml b/src/android/app/src/main/res/layout/activity_settings.xml index b72aee03c..6bb9ee9d2 100644 --- a/src/android/app/src/main/res/layout/activity_settings.xml +++ b/src/android/app/src/main/res/layout/activity_settings.xml @@ -11,12 +11,23 @@ android:id="@+id/appbar_settings" android:layout_width="match_parent" android:layout_height="wrap_content" - android:fitsSystemWindows="true"> + android:fitsSystemWindows="true" + app:elevation="0dp"> - + android:layout_height="?attr/collapsingToolbarLayoutMediumSize" + app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"> + + + + -- cgit v1.2.3