mirror of https://git.suyu.dev/suyu/suyu
android: Use collapsing toolbar layout in settings
This commit is contained in:
parent
b31ab11842
commit
aa8a48e94c
|
@ -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?
|
||||
|
||||
|
|
|
@ -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<SettingsItem>()
|
||||
if (menuTag == null) {
|
||||
|
@ -77,7 +77,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
|||
}
|
||||
|
||||
private fun addConfigSettings(sl: ArrayList<SettingsItem>) {
|
||||
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<SettingsItem>) {
|
||||
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<SettingsItem>) {
|
||||
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<SettingsItem>) {
|
||||
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<SettingsItem>) {
|
||||
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<SettingsItem>) {
|
||||
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
|
||||
|
|
|
@ -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">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar_settings"
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
style="?attr/collapsingToolbarLayoutMediumStyle"
|
||||
android:id="@+id/toolbar_settings_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize" />
|
||||
android:layout_height="?attr/collapsingToolbarLayoutMediumSize"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar_settings"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_collapseMode="pin" />
|
||||
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
|
|
Loading…
Reference in New Issue