Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: Add Paths to UI #7920

Merged
merged 4 commits into from
Mar 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Android: Add Paths to UI
  • Loading branch information
Ebola16 committed Mar 22, 2020
commit ccda75f33fc2ff698b73cdec2d41476f00f781ff
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
import android.widget.SeekBar;
import android.widget.TextView;
Expand Down Expand Up @@ -402,7 +401,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent result)
// If the user picked a file, as opposed to just backing out.
if (resultCode == MainActivity.RESULT_OK)
{
String newDiscPath = FileBrowserHelper.getSelectedDirectory(result);
String newDiscPath = FileBrowserHelper.getSelectedPath(result);
if (!TextUtils.isEmpty(newDiscPath))
{
NativeLibrary.ChangeDisc(newDiscPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

public class Settings
{
public static final String SECTION_INI_GENERAL = "General";
public static final String SECTION_INI_CORE = "Core";
public static final String SECTION_INI_INTERFACE = "Interface";
public static final String SECTION_INI_DSP = "DSP";
Expand Down Expand Up @@ -42,7 +42,8 @@ public class Settings
static
{
configFileSectionsMap.put(SettingsFile.FILE_NAME_DOLPHIN,
Arrays.asList(SECTION_INI_CORE, SECTION_INI_INTERFACE, SECTION_INI_DSP,
Arrays.asList(SECTION_INI_GENERAL, SECTION_INI_CORE, SECTION_INI_INTERFACE,
SECTION_INI_DSP,
SECTION_BINDINGS, SECTION_ANALYTICS, SECTION_DEBUG));
configFileSectionsMap.put(SettingsFile.FILE_NAME_GFX,
Arrays.asList(SECTION_GFX_SETTINGS, SECTION_GFX_ENHANCEMENTS, SECTION_GFX_HACKS,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.dolphinemu.dolphinemu.features.settings.model.view;

public final class ConfirmRunnable extends SettingsItem
{
private int mAlertText;
private int mConfirmationText;
private Runnable mRunnable;

public ConfirmRunnable(int titleId, int descriptionId, int alertText, int confirmationText,
Runnable runnable)
{
super(null, null, null, titleId, descriptionId);
mAlertText = alertText;
mConfirmationText = confirmationText;
mRunnable = runnable;
}

public int getAlertText()
{
return mAlertText;
}

public int getConfirmationText()
{
return mConfirmationText;
}

public Runnable getRunnable()
{
return mRunnable;
}

@Override
public int getType()
{
return TYPE_CONFIRM_RUNNABLE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.dolphinemu.dolphinemu.features.settings.model.view;

import org.dolphinemu.dolphinemu.features.settings.model.Setting;
import org.dolphinemu.dolphinemu.features.settings.model.StringSetting;

public final class FilePicker extends SettingsItem
{
private String mFile;
private String mDefaultValue;
private int mRequestType;

public FilePicker(String file, String key, String section, int titleId, int descriptionId,
String defaultVault, int requestType, Setting setting)
{
super(key, section, setting, titleId, descriptionId);
mFile = file;
mDefaultValue = defaultVault;
mRequestType = requestType;
}

public String getFile()
{
return mFile + ".ini";
}

public String getSelectedValue()
{
StringSetting setting = (StringSetting) getSetting();

if (setting == null)
{
return mDefaultValue;
}
else
{
return setting.getValue();
}
}

public int getRequestType()
{
return mRequestType;
}

@Override
public int getType()
{
return TYPE_FILE_PICKER;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public abstract class SettingsItem
public static final int TYPE_STRING_SINGLE_CHOICE = 6;
public static final int TYPE_RUMBLE_BINDING = 7;
public static final int TYPE_SINGLE_CHOICE_DYNAMIC_DESCRIPTIONS = 8;
public static final int TYPE_FILE_PICKER = 9;
public static final int TYPE_CONFIRM_RUNNABLE = 10;

private String mKey;
private String mSection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public enum MenuTag
CONFIG("config"),
CONFIG_GENERAL("config_general"),
CONFIG_INTERFACE("config_interface"),
CONFIG_PATHS("config_paths"),
CONFIG_GAME_CUBE("config_gamecube"),
CONFIG_WII("config_wii"),
WIIMOTE("wiimote"),
Expand All @@ -26,7 +27,8 @@ public enum MenuTag
WIIMOTE_EXTENSION_1("wiimote_extension", 4),
WIIMOTE_EXTENSION_2("wiimote_extension", 5),
WIIMOTE_EXTENSION_3("wiimote_extension", 6),
WIIMOTE_EXTENSION_4("wiimote_extension", 7);
WIIMOTE_EXTENSION_4("wiimote_extension", 7),
BLANK("Blank");

private String tag;
private int subType = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
import android.widget.Toast;

import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.ui.main.MainActivity;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
import org.dolphinemu.dolphinemu.utils.DirectoryStateReceiver;
import org.dolphinemu.dolphinemu.utils.FileBrowserHelper;

public final class SettingsActivity extends AppCompatActivity implements SettingsActivityView
{
Expand Down Expand Up @@ -103,13 +105,13 @@ public void onBackPressed()

@Override
public void showSettingsFragment(MenuTag menuTag, Bundle extras, boolean addToStack,
String gameID)
boolean customAnimations, String gameID)
{
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

if (addToStack)
{
if (areSystemAnimationsEnabled())
if (areSystemAnimationsEnabled() && customAnimations)
{
transaction.setCustomAnimations(
R.animator.settings_enter,
Expand Down Expand Up @@ -154,6 +156,35 @@ public void stopListeningToDirectoryInitializationService(DirectoryStateReceiver
LocalBroadcastManager.getInstance(this).unregisterReceiver(receiver);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent result)
{
super.onActivityResult(requestCode, resultCode, result);

// Save modified non-FilePicker settings beforehand since finish() won't save them.
// onStop() must come before handling the resultCode to properly save FilePicker selection.
mPresenter.onStop(true);

// If the user picked a file, as opposed to just backing out.
if (resultCode == MainActivity.RESULT_OK)
{
mPresenter.onFileConfirmed(FileBrowserHelper.getSelectedPath(result));

// Prevent duplicate Toasts.
if (!mPresenter.shouldSave())
{
Toast.makeText(this, "Saved settings to INI files", Toast.LENGTH_SHORT).show();
}
}
// Clear static variables for File Picker activities that don't set extensions.
SettingsAdapter.sFilePicker = null;
SettingsAdapter.sItem = null;

// TODO: After result of FilePicker, duplicate SettingsActivity appears.
// Finish to avoid this. Is there a better method?
finish();
}

@Override
public void showLoading()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private void loadSettingsUI()
}
}

mView.showSettingsFragment(menuTag, null, false, gameId);
mView.showSettingsFragment(menuTag, null, false, true, gameId);
mView.onSettingsFileLoaded(mSettings);
}

Expand Down Expand Up @@ -184,13 +184,18 @@ public void saveState(Bundle outState)
outState.putBoolean(KEY_SHOULD_SAVE, mShouldSave);
}

public boolean shouldSave()
{
return mShouldSave;
}

public void onGcPadSettingChanged(MenuTag key, int value)
{
if (value != 0) // Not disabled
{
Bundle bundle = new Bundle();
bundle.putInt(SettingsFragmentPresenter.ARG_CONTROLLER_TYPE, value / 6);
mView.showSettingsFragment(key, bundle, true, gameId);
mView.showSettingsFragment(key, bundle, true, true, gameId);
}
}

Expand All @@ -199,7 +204,7 @@ public void onWiimoteSettingChanged(MenuTag menuTag, int value)
switch (value)
{
case 1:
mView.showSettingsFragment(menuTag, null, true, gameId);
mView.showSettingsFragment(menuTag, null, true, true, gameId);
break;

case 2:
Expand All @@ -214,7 +219,12 @@ public void onExtensionSettingChanged(MenuTag menuTag, int value)
{
Bundle bundle = new Bundle();
bundle.putInt(SettingsFragmentPresenter.ARG_CONTROLLER_TYPE, value);
mView.showSettingsFragment(menuTag, bundle, true, gameId);
mView.showSettingsFragment(menuTag, bundle, true, true, gameId);
}
}

public void onFileConfirmed(String file)
{
SettingsAdapter.onFilePickerConfirmation(file);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ public interface SettingsActivityView
/**
* Show a new SettingsFragment.
*
* @param menuTag Identifier for the settings group that should be displayed.
* @param addToStack Whether or not this fragment should replace a previous one.
* @param menuTag Identifier for the settings group that should be displayed.
* @param addToStack Whether or not this fragment should replace a previous one.
* @param customAnimations Custom animations are used if true while system animations are enabled.
*/
void showSettingsFragment(MenuTag menuTag, Bundle extras, boolean addToStack, String gameId);
void showSettingsFragment(MenuTag menuTag, Bundle extras, boolean addToStack,
boolean customAnimations, String gameId);

/**
* Called by a contained Fragment to get access to the Setting HashMap
Expand Down
Loading