Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #11346 from t895/grid-settings
Android: Move game grid options to MainActivity
- Loading branch information
Showing
16 changed files
with
337 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
...Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/GridOptionDialogFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| package org.dolphinemu.dolphinemu.fragments | ||
|
|
||
| import com.google.android.material.bottomsheet.BottomSheetDialogFragment | ||
| import android.view.LayoutInflater | ||
| import android.view.ViewGroup | ||
| import android.os.Bundle | ||
| import android.view.View | ||
| import com.google.android.material.bottomsheet.BottomSheetBehavior | ||
| import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting | ||
| import android.widget.CompoundButton | ||
| import androidx.appcompat.app.AppCompatActivity | ||
| import com.google.android.material.bottomsheet.BottomSheetDialog | ||
| import org.dolphinemu.dolphinemu.databinding.FragmentGridOptionsBinding | ||
| import org.dolphinemu.dolphinemu.databinding.FragmentGridOptionsTvBinding | ||
| import org.dolphinemu.dolphinemu.features.settings.model.NativeConfig | ||
| import org.dolphinemu.dolphinemu.ui.main.MainView | ||
|
|
||
| class GridOptionDialogFragment : BottomSheetDialogFragment() { | ||
|
|
||
| private lateinit var mView: MainView | ||
|
|
||
| private var _mBindingMobile: FragmentGridOptionsBinding? = null | ||
| private var _mBindingTv: FragmentGridOptionsTvBinding? = null | ||
|
|
||
| // This property is only valid between onCreateView and | ||
| // onDestroyView. | ||
| private val mBindingMobile get() = _mBindingMobile!! | ||
| private val mBindingTv get() = _mBindingTv!! | ||
|
|
||
| override fun onCreateView( | ||
| inflater: LayoutInflater, container: ViewGroup?, | ||
| savedInstanceState: Bundle? | ||
| ): View { | ||
| mView = (activity as MainView) | ||
|
|
||
| if (activity is AppCompatActivity) | ||
| { | ||
| _mBindingMobile = FragmentGridOptionsBinding.inflate(inflater, container, false) | ||
| return mBindingMobile.root | ||
| } | ||
| _mBindingTv = FragmentGridOptionsTvBinding.inflate(inflater, container, false) | ||
| return mBindingTv.root | ||
| } | ||
|
|
||
| override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
| if (activity is AppCompatActivity) { | ||
| setUpCoverButtons() | ||
| setUpTitleButtons() | ||
|
|
||
| // Pins fragment to the top of the dialog ensures the dialog is expanded in landscape by default | ||
| BottomSheetBehavior.from<View>(mBindingMobile.gridSheet).state = | ||
| BottomSheetBehavior.STATE_EXPANDED | ||
| dialog?.setOnShowListener { | ||
| val dialog = it as BottomSheetDialog | ||
| mBindingMobile.gridSheet.let { sheet -> | ||
| dialog.behavior.peekHeight = sheet.height | ||
| } | ||
| } | ||
| } else { | ||
| setUpCoverButtonsTv() | ||
|
|
||
| // Pins fragment to the top of the dialog ensures the dialog is expanded in landscape by default | ||
| BottomSheetBehavior.from<View>(mBindingTv.gridSheet).state = | ||
| BottomSheetBehavior.STATE_EXPANDED | ||
| dialog?.setOnShowListener { | ||
| val dialog = it as BottomSheetDialog | ||
| mBindingTv.gridSheet.let { sheet -> | ||
| dialog.behavior.peekHeight = sheet.height | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| override fun onDestroyView() { | ||
| super.onDestroyView() | ||
| _mBindingMobile = null | ||
| _mBindingTv = null | ||
| } | ||
|
|
||
| private fun setUpCoverButtons() { | ||
| mBindingMobile.switchDownloadCovers.isChecked = | ||
| BooleanSetting.MAIN_USE_GAME_COVERS.booleanGlobal | ||
| mBindingMobile.rootDownloadCovers.setOnClickListener { | ||
| mBindingMobile.switchDownloadCovers.isChecked = !mBindingMobile.switchDownloadCovers.isChecked | ||
| } | ||
| mBindingMobile.switchDownloadCovers.setOnCheckedChangeListener { _: CompoundButton, _: Boolean -> | ||
| BooleanSetting.MAIN_USE_GAME_COVERS.setBooleanGlobal( | ||
| NativeConfig.LAYER_BASE, | ||
| mBindingMobile.switchDownloadCovers.isChecked | ||
| ) | ||
| mView.reloadGrid() | ||
| } | ||
| } | ||
|
|
||
| private fun setUpTitleButtons() { | ||
| mBindingMobile.switchShowTitles.isChecked = BooleanSetting.MAIN_SHOW_GAME_TITLES.booleanGlobal | ||
| mBindingMobile.rootShowTitles.setOnClickListener { | ||
| mBindingMobile.switchShowTitles.isChecked = !mBindingMobile.switchShowTitles.isChecked | ||
| } | ||
| mBindingMobile.switchShowTitles.setOnCheckedChangeListener { _: CompoundButton, _: Boolean -> | ||
| BooleanSetting.MAIN_SHOW_GAME_TITLES.setBooleanGlobal( | ||
| NativeConfig.LAYER_BASE, | ||
| mBindingMobile.switchShowTitles.isChecked | ||
| ) | ||
| mView.reloadGrid() | ||
| } | ||
| } | ||
|
|
||
| // TODO: Remove this when leanback is removed | ||
| private fun setUpCoverButtonsTv() { | ||
| mBindingTv.switchDownloadCovers.isChecked = | ||
| BooleanSetting.MAIN_USE_GAME_COVERS.booleanGlobal | ||
| mBindingTv.rootDownloadCovers.setOnClickListener { | ||
| mBindingTv.switchDownloadCovers.isChecked = !mBindingTv.switchDownloadCovers.isChecked | ||
| } | ||
| mBindingTv.switchDownloadCovers.setOnCheckedChangeListener { _: CompoundButton, _: Boolean -> | ||
| BooleanSetting.MAIN_USE_GAME_COVERS.setBooleanGlobal( | ||
| NativeConfig.LAYER_BASE, | ||
| mBindingTv.switchDownloadCovers.isChecked | ||
| ) | ||
| mView.reloadGrid() | ||
| } | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:height="24dp" | ||
| android:width="24dp" | ||
| android:viewportHeight="24" | ||
| android:viewportWidth="24"> | ||
| <path | ||
| android:fillColor="?attr/colorControlNormal" | ||
| android:pathData="M10,18h4v-2h-4v2zM3,6v2h18L21,6L3,6zM6,13h12v-2L6,11v2z" /> | ||
| </vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:height="24dp" | ||
| android:width="24dp" | ||
| android:viewportHeight="24" | ||
| android:viewportWidth="24"> | ||
| <path | ||
| android:fillColor="@android:color/white" | ||
| android:pathData="M10,18h4v-2h-4v2zM3,6v2h18L21,6L3,6zM6,13h12v-2L6,11v2z" /> | ||
| </vector> |
83 changes: 83 additions & 0 deletions
83
Source/Android/app/src/main/res/layout/fragment_grid_options.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <androidx.coordinatorlayout.widget.CoordinatorLayout | ||
| xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content"> | ||
|
|
||
| <androidx.appcompat.widget.LinearLayoutCompat | ||
| android:id="@+id/grid_sheet" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:orientation="vertical" | ||
| android:paddingBottom="@dimen/spacing_xtralarge" | ||
| app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"> | ||
|
|
||
| <com.google.android.material.bottomsheet.BottomSheetDragHandleView | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_gravity="center_horizontal"/> | ||
|
|
||
| <androidx.constraintlayout.widget.ConstraintLayout | ||
| android:id="@+id/root_download_covers" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:background="?attr/selectableItemBackground" | ||
| android:clickable="true" | ||
| android:focusable="true"> | ||
|
|
||
| <TextView | ||
| android:id="@+id/text_download_covers" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginStart="24dp" | ||
| android:text="@string/download_game_covers" | ||
| app:layout_constraintBottom_toBottomOf="@+id/switch_download_covers" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintTop_toTopOf="@+id/switch_download_covers" /> | ||
|
|
||
| <com.google.android.material.materialswitch.MaterialSwitch | ||
| android:id="@+id/switch_download_covers" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginEnd="24dp" | ||
| app:layout_constraintBottom_toBottomOf="parent" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintTop_toTopOf="parent" /> | ||
|
|
||
| </androidx.constraintlayout.widget.ConstraintLayout> | ||
|
|
||
| <androidx.constraintlayout.widget.ConstraintLayout | ||
| android:id="@+id/root_show_titles" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginBottom="16dp" | ||
| android:layout_marginTop="16dp" | ||
| android:background="?attr/selectableItemBackground" | ||
| android:clickable="true" | ||
| android:focusable="true"> | ||
|
|
||
| <TextView | ||
| android:id="@+id/text_show_titles" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginStart="24dp" | ||
| android:text="@string/show_titles_in_game_list" | ||
| app:layout_constraintBottom_toBottomOf="@+id/switch_show_titles" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintTop_toTopOf="@+id/switch_show_titles" /> | ||
|
|
||
| <com.google.android.material.materialswitch.MaterialSwitch | ||
| android:id="@+id/switch_show_titles" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginEnd="24dp" | ||
| app:layout_constraintBottom_toBottomOf="parent" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintTop_toTopOf="parent" /> | ||
|
|
||
| </androidx.constraintlayout.widget.ConstraintLayout> | ||
|
|
||
| </androidx.appcompat.widget.LinearLayoutCompat> | ||
|
|
||
| </androidx.coordinatorlayout.widget.CoordinatorLayout> |
48 changes: 48 additions & 0 deletions
48
Source/Android/app/src/main/res/layout/fragment_grid_options_tv.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <androidx.coordinatorlayout.widget.CoordinatorLayout | ||
| xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content"> | ||
|
|
||
| <androidx.appcompat.widget.LinearLayoutCompat | ||
| android:id="@+id/grid_sheet" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:orientation="vertical" | ||
| app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"> | ||
|
|
||
| <androidx.constraintlayout.widget.ConstraintLayout | ||
| android:id="@+id/root_download_covers" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:background="?attr/selectableItemBackground" | ||
| android:paddingTop="@dimen/spacing_xtralarge" | ||
| android:paddingBottom="@dimen/spacing_xtralarge" | ||
| android:clickable="true" | ||
| android:focusable="true"> | ||
|
|
||
| <TextView | ||
| android:id="@+id/text_download_covers" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginStart="24dp" | ||
| android:text="@string/download_game_covers" | ||
| app:layout_constraintBottom_toBottomOf="@+id/switch_download_covers" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintTop_toTopOf="@+id/switch_download_covers" /> | ||
|
|
||
| <com.google.android.material.switchmaterial.SwitchMaterial | ||
| android:id="@+id/switch_download_covers" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginEnd="24dp" | ||
| app:layout_constraintBottom_toBottomOf="parent" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintTop_toTopOf="parent" /> | ||
|
|
||
| </androidx.constraintlayout.widget.ConstraintLayout> | ||
|
|
||
| </androidx.appcompat.widget.LinearLayoutCompat> | ||
|
|
||
| </androidx.coordinatorlayout.widget.CoordinatorLayout> |
Oops, something went wrong.