Skip to content

Commit

Permalink
Android: Dynamic SettingsActivity Titles
Browse files Browse the repository at this point in the history
  • Loading branch information
Ebola16 committed Oct 9, 2018
1 parent 4809726 commit e9e14fc
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
import org.dolphinemu.dolphinemu.utils.DirectoryStateReceiver;

import java.util.HashMap;
import java.util.Map;

public final class SettingsActivity extends AppCompatActivity implements SettingsActivityView
{
private static final String ARG_MENU_TAG = "menu_tag";
Expand All @@ -27,6 +30,36 @@ public final class SettingsActivity extends AppCompatActivity implements Setting

private ProgressDialog dialog;

private static final Map<MenuTag, Integer> 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.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 void launch(Context context, MenuTag menuTag, String gameId)
{
Intent settings = new Intent(context, SettingsActivity.class);
Expand Down Expand Up @@ -94,6 +127,13 @@ protected void onStop()
@Override
public void onBackPressed()
{
Intent launcher = getIntent();
MenuTag menuTag = (MenuTag) launcher.getSerializableExtra(ARG_MENU_TAG);
if (titles.containsKey(menuTag))
{
setTitle(titles.get(menuTag));
}

mPresenter.onBackPressed();
}

Expand Down Expand Up @@ -122,6 +162,11 @@ public void showSettingsFragment(MenuTag menuTag, Bundle extras, boolean addToSt
FRAGMENT_TAG);

transaction.commit();

if (titles.containsKey(menuTag))
{
setTitle(titles.get(menuTag));
}
}

private boolean areSystemAnimationsEnabled()
Expand Down
9 changes: 9 additions & 0 deletions Source/Android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@
<string name="wiimote_7">Wii Remote 4</string>
<!-- END WARNING -->

<!-- WARNING Do not move these controller entries AT ALL COSTS! They are indexed with ints, and an assumption
is made that they are placed together so that we can access them sequentially in a loop.
Wiimotes start at 4 since they are mapped to padID's 4-7 in the native code.-->
<string name="wiimote_extension_4">Wii Remote Extension 1</string>
<string name="wiimote_extension_5">Wii Remote Extension 2</string>
<string name="wiimote_extension_6">Wii Remote Extension 3</string>
<string name="wiimote_extension_7">Wii Remote Extension 4</string>
<!-- END WARNING -->

<string name="wiimote_extensions">Extension</string>
<string name="wiimote_extensions_description">Choose and bind the Wii Remote extension.</string>
<string name="wiimote_ir">IR</string>
Expand Down

0 comments on commit e9e14fc

Please sign in to comment.