Permalink
Browse files

Merge pull request #6338 from mahdihijazi/settings_enhancements

Update Android UI Settings to have the most common used settings
  • Loading branch information...
degasus committed Jul 4, 2018
2 parents 0cf205f + 77e51ab commit fd83937987f5a6a9152513975375c49d49028daf
Showing with 610 additions and 164 deletions.
  1. +3 −3 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java
  2. +3 −3 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java
  3. +16 −0 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/settings/IntSetting.java
  4. +1 −0 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/settings/view/SettingsItem.java
  5. +14 −1 .../Android/app/src/main/java/org/dolphinemu/dolphinemu/model/settings/view/SingleChoiceSetting.java
  6. +2 −1 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/settings/view/SliderSetting.java
  7. +97 −0 ...id/app/src/main/java/org/dolphinemu/dolphinemu/model/settings/view/StringSingleChoiceSetting.java
  8. +4 −3 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/settings/view/SubmenuSetting.java
  9. +16 −0 .../Android/app/src/main/java/org/dolphinemu/dolphinemu/services/DirectoryInitializationService.java
  10. +2 −1 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java
  11. +6 −6 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainPresenter.java
  12. +2 −5 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainView.java
  13. +5 −4 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java
  14. +106 −0 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/MenuTag.java
  15. +11 −14 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsActivity.java
  16. +15 −11 ...ce/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsActivityPresenter.java
  17. +8 −8 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsActivityView.java
  18. +43 −12 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsAdapter.java
  19. +18 −12 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsFragment.java
  20. +173 −64 ...ce/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsFragmentPresenter.java
  21. +7 −8 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/SettingsFragmentView.java
  22. +11 −3 ...id/app/src/main/java/org/dolphinemu/dolphinemu/ui/settings/viewholder/SingleChoiceViewHolder.java
  23. +6 −0 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/SettingsFile.java
  24. +1 −0 Source/Android/app/src/main/res/layout/list_item_settings_header.xml
  25. +3 −3 Source/Android/app/src/main/res/menu/menu_game_grid.xml
  26. +18 −0 Source/Android/app/src/main/res/values/arrays.xml
  27. +19 −2 Source/Android/app/src/main/res/values/strings.xml
@@ -14,9 +14,9 @@
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
import org.dolphinemu.dolphinemu.ui.settings.MenuTag;
import org.dolphinemu.dolphinemu.ui.settings.SettingsActivity;
import org.dolphinemu.dolphinemu.utils.PicassoUtils;
import org.dolphinemu.dolphinemu.utils.SettingsFile;
import org.dolphinemu.dolphinemu.viewholders.GameViewHolder;
import java.io.File;
@@ -156,10 +156,10 @@ public boolean onLongClick(View view)
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case 0:
SettingsActivity.launch(activity, SettingsFile.FILE_NAME_DOLPHIN, gameId);
SettingsActivity.launch(activity, MenuTag.CONFIG, gameId);
break;
case 1:
SettingsActivity.launch(activity, SettingsFile.FILE_NAME_GFX, gameId);
SettingsActivity.launch(activity, MenuTag.GRAPHICS, gameId);
break;
case 2:
String path = DirectoryInitializationService.getUserDirectory() + "/GameSettings/" + gameId + ".ini";
@@ -17,9 +17,9 @@
import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
import org.dolphinemu.dolphinemu.ui.platform.Platform;
import org.dolphinemu.dolphinemu.ui.settings.MenuTag;
import org.dolphinemu.dolphinemu.ui.settings.SettingsActivity;
import org.dolphinemu.dolphinemu.utils.PicassoUtils;
import org.dolphinemu.dolphinemu.utils.SettingsFile;
import org.dolphinemu.dolphinemu.viewholders.TvGameViewHolder;
import java.io.File;
@@ -103,10 +103,10 @@ public boolean onLongClick(View view)
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case 0:
SettingsActivity.launch(activity, SettingsFile.FILE_NAME_DOLPHIN, gameId);
SettingsActivity.launch(activity, MenuTag.CONFIG, gameId);
break;
case 1:
SettingsActivity.launch(activity, SettingsFile.FILE_NAME_GFX, gameId);
SettingsActivity.launch(activity, MenuTag.GRAPHICS, gameId);
break;
case 2:
String path = DirectoryInitializationService.getUserDirectory() + "/GameSettings/" + gameId + ".ini";
@@ -1,15 +1,25 @@
package org.dolphinemu.dolphinemu.model.settings;
import org.dolphinemu.dolphinemu.ui.settings.MenuTag;
public final class IntSetting extends Setting
{
private int mValue;
private MenuTag menuTag;
public IntSetting(String key, String section, int file, int value)
{
super(key, section, file);
mValue = value;
}
public IntSetting(String key, String section, int file, int value, MenuTag menuTag)
{
super(key, section, file);
mValue = value;
this.menuTag = menuTag;
}
public int getValue()
{
return mValue;
@@ -25,4 +35,10 @@ public String getValueAsString()
{
return Integer.toString(mValue);
}
public MenuTag getMenuTag()
{
return menuTag;
}
}
@@ -17,6 +17,7 @@
public static final int TYPE_SLIDER = 3;
public static final int TYPE_SUBMENU = 4;
public static final int TYPE_INPUT_BINDING = 5;
public static final int TYPE_STRING_SINGLE_CHOICE = 6;
private String mKey;
private String mSection;
@@ -2,20 +2,28 @@
import org.dolphinemu.dolphinemu.model.settings.IntSetting;
import org.dolphinemu.dolphinemu.model.settings.Setting;
import org.dolphinemu.dolphinemu.ui.settings.MenuTag;
public final class SingleChoiceSetting extends SettingsItem
{
private int mDefaultValue;
private int mChoicesId;
private int mValuesId;
private MenuTag menuTag;
public SingleChoiceSetting(String key, String section, int file, int titleId, int descriptionId, int choicesId, int valuesId, int defaultValue, Setting setting)
public SingleChoiceSetting(String key, String section, int file, int titleId, int descriptionId, int choicesId, int valuesId, int defaultValue, Setting setting, MenuTag menuTag)
{
super(key, section, file, setting, titleId, descriptionId);
mValuesId = valuesId;
mChoicesId = choicesId;
mDefaultValue = defaultValue;
this.menuTag = menuTag;
}
public SingleChoiceSetting(String key, String section, int file, int titleId, int descriptionId, int choicesId, int valuesId, int defaultValue, Setting setting)
{
this(key, section, file, titleId, descriptionId, choicesId, valuesId, defaultValue, setting, null);
}
public int getChoicesId()
@@ -41,6 +49,11 @@ public int getSelectedValue()
}
}
public MenuTag getMenuTag()
{
return menuTag;
}
/**
* Write a value to the backing int. If that int was previously null,
* initializes a new one and returns it, so it can be added to the Hashmap.
@@ -43,7 +43,8 @@ public int getSelectedValue()
else if (setting instanceof FloatSetting)
{
FloatSetting floatSetting = (FloatSetting) setting;
if (floatSetting.getKey().equals(SettingsFile.KEY_OVERCLOCK_PERCENT))
if (floatSetting.getKey().equals(SettingsFile.KEY_OVERCLOCK_PERCENT)
|| floatSetting.getKey().equals(SettingsFile.KEY_SPEED_LIMIT))
{
return Math.round(floatSetting.getValue() * 100);
}
@@ -0,0 +1,97 @@
package org.dolphinemu.dolphinemu.model.settings.view;
import org.dolphinemu.dolphinemu.model.settings.Setting;
import org.dolphinemu.dolphinemu.model.settings.StringSetting;
public class StringSingleChoiceSetting extends SettingsItem
{
private String mDefaultValue;
private String[] mChoicesId;
private String[] mValuesId;
public StringSingleChoiceSetting(String key, String section, int file, int titleId, int descriptionId, String[] choicesId, String[] valuesId, String defaultValue, Setting setting)
{
super(key, section, file, setting, titleId, descriptionId);
mValuesId = valuesId;
mChoicesId = choicesId;
mDefaultValue = defaultValue;
}
public String[] getChoicesId()
{
return mChoicesId;
}
public String[] getValuesId()
{
return mValuesId;
}
public String getValueAt(int index)
{
if (mValuesId == null)
return null;
if (index >= 0 && index < mValuesId.length)
{
return mValuesId[index];
}
return "";
}
public String getSelectedValue()
{
if (getSetting() != null)
{
StringSetting setting = (StringSetting) getSetting();
return setting.getValue();
}
else
{
return mDefaultValue;
}
}
public int getSelectValueIndex() {
String selectedValue = getSelectedValue();
for(int i=0;i<mValuesId.length;i++) {
if(mValuesId[i].equals(selectedValue)) {
return i;
}
}
return -1;
}
/**
* Write a value to the backing int. If that int was previously null,
* initializes a new one and returns it, so it can be added to the Hashmap.
*
* @param selection New value of the int.
* @return null if overwritten successfully otherwise; a newly created IntSetting.
*/
public StringSetting setSelectedValue(String selection)
{
if (getSetting() == null)
{
StringSetting setting = new StringSetting(getKey(), getSection(), getFile(), selection);
setSetting(setting);
return setting;
}
else
{
StringSetting setting = (StringSetting) getSetting();
setting.setValue(selection);
return null;
}
}
@Override
public int getType()
{
return TYPE_STRING_SINGLE_CHOICE;
}
}
@@ -1,18 +1,19 @@
package org.dolphinemu.dolphinemu.model.settings.view;
import org.dolphinemu.dolphinemu.model.settings.Setting;
import org.dolphinemu.dolphinemu.ui.settings.MenuTag;
public final class SubmenuSetting extends SettingsItem
{
private String mMenuKey;
private MenuTag mMenuKey;
public SubmenuSetting(String key, Setting setting, int titleId, int descriptionId, String menuKey)
public SubmenuSetting(String key, Setting setting, int titleId, int descriptionId, MenuTag menuKey)
{
super(key, null, 0, setting, titleId, descriptionId);
mMenuKey = menuKey;
}
public String getMenuKey()
public MenuTag getMenuKey()
{
return mMenuKey;
}
@@ -37,6 +37,7 @@
public static final String EXTRA_STATE = "directoryState";
private static volatile DirectoryInitializationState directoryState = null;
private static String userPath;
private static String internalPath;
private static AtomicBoolean isDolphinDirectoryInitializationRunning = new AtomicBoolean(false);
public enum DirectoryInitializationState
@@ -110,6 +111,7 @@ private boolean setDolphinUserDirectory()
private void initializeInternalStorage()
{
File sysDirectory = new File(getFilesDir(), "Sys");
internalPath = sysDirectory.getAbsolutePath();
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
String revision = NativeLibrary.GetGitRevision();
@@ -177,6 +179,20 @@ else if (isDolphinDirectoryInitializationRunning.get())
}
public static String getDolphinInternalDirectory()
{
if (directoryState == null)
{
throw new IllegalStateException("DirectoryInitializationService has to run at least once!");
}
else if (isDolphinDirectoryInitializationRunning.get())
{
throw new IllegalStateException("DirectoryInitializationService has to finish running first!");
}
return internalPath;
}
private void sendBroadcastState(DirectoryInitializationState state)
{
Intent localIntent =
@@ -21,6 +21,7 @@
import org.dolphinemu.dolphinemu.services.GameFileCacheService;
import org.dolphinemu.dolphinemu.ui.platform.Platform;
import org.dolphinemu.dolphinemu.ui.platform.PlatformGamesView;
import org.dolphinemu.dolphinemu.ui.settings.MenuTag;
import org.dolphinemu.dolphinemu.ui.settings.SettingsActivity;
import org.dolphinemu.dolphinemu.utils.FileBrowserHelper;
import org.dolphinemu.dolphinemu.utils.PermissionsHandler;
@@ -129,7 +130,7 @@ public void refreshFragmentScreenshot(int fragmentPosition)
}
@Override
public void launchSettingsActivity(String menuTag)
public void launchSettingsActivity(MenuTag menuTag)
{
SettingsActivity.launch(this, menuTag, "");
}
@@ -10,7 +10,7 @@
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.model.GameFileCache;
import org.dolphinemu.dolphinemu.services.GameFileCacheService;
import org.dolphinemu.dolphinemu.utils.SettingsFile;
import org.dolphinemu.dolphinemu.ui.settings.MenuTag;
public final class MainPresenter
{
@@ -64,19 +64,19 @@ public boolean handleOptionSelection(int itemId, Context context)
switch (itemId)
{
case R.id.menu_settings_core:
mView.launchSettingsActivity(SettingsFile.FILE_NAME_DOLPHIN);
mView.launchSettingsActivity(MenuTag.CONFIG);
return true;
case R.id.menu_settings_video:
mView.launchSettingsActivity(SettingsFile.FILE_NAME_GFX);
case R.id.menu_settings_graphics:
mView.launchSettingsActivity(MenuTag.GRAPHICS);
return true;
case R.id.menu_settings_gcpad:
mView.launchSettingsActivity(SettingsFile.FILE_NAME_GCPAD);
mView.launchSettingsActivity(MenuTag.GCPAD_TYPE);
return true;
case R.id.menu_settings_wiimote:
mView.launchSettingsActivity(SettingsFile.FILE_NAME_WIIMOTE);
mView.launchSettingsActivity(MenuTag.WIIMOTE);
return true;
case R.id.menu_refresh:
@@ -1,9 +1,6 @@
package org.dolphinemu.dolphinemu.ui.main;
import android.database.Cursor;
import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.ui.platform.Platform;
import org.dolphinemu.dolphinemu.ui.settings.MenuTag;
/**
* Abstraction for the screen that shows on application launch.
@@ -29,7 +26,7 @@
void refreshFragmentScreenshot(int fragmentPosition);
void launchSettingsActivity(String menuTag);
void launchSettingsActivity(MenuTag menuTag);
void launchFileListActivity();
Oops, something went wrong.

0 comments on commit fd83937

Please sign in to comment.