From 2edc58950b92567b5d1c3e043945be8c6add9859 Mon Sep 17 00:00:00 2001 From: Ryan Meredith Date: Fri, 15 Mar 2019 01:45:13 -0400 Subject: [PATCH] Dynamic SettingsActivity Titles --- .../settings/ui/SettingsActivity.java | 1 - .../settings/ui/SettingsFragment.java | 43 ++++++++++++++++++- .../ui/SettingsFragmentPresenter.java | 3 +- .../app/src/main/res/values/strings.xml | 9 ++++ 4 files changed, 53 insertions(+), 3 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java index 56b407cb82..314e8daf51 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java @@ -98,7 +98,6 @@ public final class SettingsActivity extends AppCompatActivity implements Setting mPresenter.onBackPressed(); } - @Override public void showSettingsFragment(MenuTag menuTag, Bundle extras, boolean addToStack, String gameID) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragment.java index 2c9f532e82..a9e2720cd7 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragment.java @@ -17,6 +17,8 @@ import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem; import org.dolphinemu.dolphinemu.ui.DividerItemDecoration; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; public final class SettingsFragment extends Fragment implements SettingsFragmentView { @@ -28,6 +30,37 @@ public final class SettingsFragment extends Fragment implements SettingsFragment private SettingsAdapter mAdapter; + private static final Map titles = new HashMap<>(); + + static + { + titles.put(MenuTag.CONFIG, R.string.preferences_settings); + titles.put(MenuTag.CONFIG_GENERAL, R.string.general_submenu); + titles.put(MenuTag.CONFIG_INTERFACE, R.string.interface_submenu); + titles.put(MenuTag.CONFIG_GAME_CUBE, R.string.gamecube_submenu); + titles.put(MenuTag.CONFIG_WII, R.string.wii_submenu); + titles.put(MenuTag.WIIMOTE, R.string.grid_menu_wiimote_settings); + titles.put(MenuTag.WIIMOTE_EXTENSION, R.string.wiimote_extensions); + titles.put(MenuTag.GCPAD_TYPE, R.string.grid_menu_gcpad_settings); + titles.put(MenuTag.GRAPHICS, R.string.grid_menu_graphics_settings); + titles.put(MenuTag.HACKS, R.string.hacks_submenu); + titles.put(MenuTag.DEBUG, R.string.debug_submenu); + titles.put(MenuTag.ENHANCEMENTS, R.string.enhancements_submenu); + titles.put(MenuTag.STEREOSCOPY, R.string.stereoscopy_submenu); + titles.put(MenuTag.GCPAD_1, R.string.controller_0); + titles.put(MenuTag.GCPAD_2, R.string.controller_1); + titles.put(MenuTag.GCPAD_3, R.string.controller_2); + titles.put(MenuTag.GCPAD_4, R.string.controller_3); + titles.put(MenuTag.WIIMOTE_1, R.string.wiimote_4); + titles.put(MenuTag.WIIMOTE_2, R.string.wiimote_5); + titles.put(MenuTag.WIIMOTE_3, R.string.wiimote_6); + titles.put(MenuTag.WIIMOTE_4, R.string.wiimote_7); + titles.put(MenuTag.WIIMOTE_EXTENSION_1, R.string.wiimote_extension_4); + titles.put(MenuTag.WIIMOTE_EXTENSION_2, R.string.wiimote_extension_5); + titles.put(MenuTag.WIIMOTE_EXTENSION_3, R.string.wiimote_extension_6); + titles.put(MenuTag.WIIMOTE_EXTENSION_4, R.string.wiimote_extension_7); + } + public static Fragment newInstance(MenuTag menuTag, String gameId, Bundle extras) { SettingsFragment fragment = new SettingsFragment(); @@ -94,6 +127,14 @@ public final class SettingsFragment extends Fragment implements SettingsFragment @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + Bundle args = getArguments(); + MenuTag menuTag = (MenuTag) args.getSerializable(ARGUMENT_MENU_TAG); + + if (titles.containsKey(menuTag)) + { + getActivity().setTitle(titles.get(menuTag)); + } + LinearLayoutManager manager = new LinearLayoutManager(getActivity()); RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.list_settings); @@ -103,7 +144,7 @@ public final class SettingsFragment extends Fragment implements SettingsFragment recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), null)); SettingsActivityView activity = (SettingsActivityView) getActivity(); - mPresenter.onViewCreated(activity.getSettings()); + mPresenter.onViewCreated(menuTag, activity.getSettings()); } @Override diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java index f150d44ff3..f98872d3d4 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java @@ -69,8 +69,9 @@ public final class SettingsFragmentPresenter } } - public void onViewCreated(Settings settings) + public void onViewCreated(MenuTag menuTag, Settings settings) { + this.mMenuTag = menuTag; setSettings(settings); } diff --git a/Source/Android/app/src/main/res/values/strings.xml b/Source/Android/app/src/main/res/values/strings.xml index c64446fd8d..ad7551ad5a 100644 --- a/Source/Android/app/src/main/res/values/strings.xml +++ b/Source/Android/app/src/main/res/values/strings.xml @@ -31,6 +31,15 @@ Wii Remote 4 + + Wii Remote Extension 1 + Wii Remote Extension 2 + Wii Remote Extension 3 + Wii Remote Extension 4 + + Extension Choose and bind the Wii Remote extension. IR