mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-09 23:59:27 +01:00
commit
1b97f081b8
@ -1,5 +1,7 @@
|
|||||||
package org.dolphinemu.dolphinemu.activities;
|
package org.dolphinemu.dolphinemu.activities;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@ -10,21 +12,38 @@ import com.nononsenseapps.filepicker.FilePickerActivity;
|
|||||||
import org.dolphinemu.dolphinemu.fragments.CustomFilePickerFragment;
|
import org.dolphinemu.dolphinemu.fragments.CustomFilePickerFragment;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
public class CustomFilePickerActivity extends FilePickerActivity
|
public class CustomFilePickerActivity extends FilePickerActivity
|
||||||
|
|
||||||
{
|
{
|
||||||
|
public static final String EXTRA_EXTENSIONS = "dolphinemu.org.filepicker.extensions";
|
||||||
|
|
||||||
|
private HashSet<String> mExtensions;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
|
{
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
Intent intent = getIntent();
|
||||||
|
if (intent != null)
|
||||||
|
{
|
||||||
|
mExtensions = (HashSet<String>) intent.getSerializableExtra(EXTRA_EXTENSIONS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractFilePickerFragment<File> getFragment(
|
protected AbstractFilePickerFragment<File> getFragment(
|
||||||
@Nullable final String startPath, final int mode, final boolean allowMultiple,
|
@Nullable final String startPath, final int mode, final boolean allowMultiple,
|
||||||
final boolean allowCreateDir, final boolean allowExistingFile,
|
final boolean allowCreateDir, final boolean allowExistingFile,
|
||||||
final boolean singleClick)
|
final boolean singleClick)
|
||||||
{
|
{
|
||||||
AbstractFilePickerFragment<File> fragment = new CustomFilePickerFragment();
|
CustomFilePickerFragment fragment = new CustomFilePickerFragment();
|
||||||
// startPath is allowed to be null. In that case, default folder should be SD-card and not "/"
|
// startPath is allowed to be null. In that case, default folder should be SD-card and not "/"
|
||||||
fragment.setArgs(
|
fragment.setArgs(
|
||||||
startPath != null ? startPath : Environment.getExternalStorageDirectory().getPath(),
|
startPath != null ? startPath : Environment.getExternalStorageDirectory().getPath(),
|
||||||
mode, allowMultiple, allowCreateDir, allowExistingFile, singleClick);
|
mode, allowMultiple, allowCreateDir, allowExistingFile, singleClick);
|
||||||
|
fragment.setExtensions(mExtensions);
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.Surface;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@ -411,7 +410,7 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
// If the user picked a file, as opposed to just backing out.
|
// If the user picked a file, as opposed to just backing out.
|
||||||
if (resultCode == MainActivity.RESULT_OK)
|
if (resultCode == MainActivity.RESULT_OK)
|
||||||
{
|
{
|
||||||
String newDiscPath = FileBrowserHelper.getSelectedDirectory(result);
|
String newDiscPath = FileBrowserHelper.getSelectedPath(result);
|
||||||
if (!TextUtils.isEmpty(newDiscPath))
|
if (!TextUtils.isEmpty(newDiscPath))
|
||||||
{
|
{
|
||||||
NativeLibrary.ChangeDisc(newDiscPath);
|
NativeLibrary.ChangeDisc(newDiscPath);
|
||||||
@ -643,7 +642,8 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case MENU_ACTION_CHANGE_DISC:
|
case MENU_ACTION_CHANGE_DISC:
|
||||||
FileBrowserHelper.openFilePicker(this, REQUEST_CHANGE_DISC, false);
|
FileBrowserHelper.openFilePicker(this, REQUEST_CHANGE_DISC, false,
|
||||||
|
FileBrowserHelper.GAME_EXTENSIONS);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case MENU_SET_IR_SENSITIVITY:
|
case MENU_SET_IR_SENSITIVITY:
|
||||||
|
@ -10,9 +10,12 @@ import androidx.fragment.app.FragmentActivity;
|
|||||||
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import org.dolphinemu.dolphinemu.NativeLibrary;
|
||||||
import org.dolphinemu.dolphinemu.R;
|
import org.dolphinemu.dolphinemu.R;
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
|
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity;
|
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity;
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
|
||||||
import org.dolphinemu.dolphinemu.ui.platform.Platform;
|
import org.dolphinemu.dolphinemu.ui.platform.Platform;
|
||||||
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
|
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
|
||||||
|
|
||||||
@ -61,22 +64,28 @@ public class GamePropertiesDialog extends DialogFragment
|
|||||||
.getSupportFragmentManager(), "game_details");
|
.getSupportFragmentManager(), "game_details");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
SettingsActivity.launch(getContext(), MenuTag.CONFIG, gameId);
|
NativeLibrary.SetConfig(SettingsFile.FILE_NAME_DOLPHIN + ".ini",
|
||||||
|
Settings.SECTION_INI_CORE, SettingsFile.KEY_DEFAULT_ISO, path);
|
||||||
|
NativeLibrary.ReloadConfig();
|
||||||
|
Toast.makeText(getContext(), "Default ISO set", Toast.LENGTH_SHORT).show();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
SettingsActivity.launch(getContext(), MenuTag.GRAPHICS, gameId);
|
SettingsActivity.launch(getContext(), MenuTag.CONFIG, gameId);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
SettingsActivity.launch(getContext(), MenuTag.GCPAD_TYPE, gameId);
|
SettingsActivity.launch(getContext(), MenuTag.GRAPHICS, gameId);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
|
SettingsActivity.launch(getContext(), MenuTag.GCPAD_TYPE, gameId);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
// Clear option for GC, Wii controls for else
|
// Clear option for GC, Wii controls for else
|
||||||
if (platform == Platform.GAMECUBE.toInt())
|
if (platform == Platform.GAMECUBE.toInt())
|
||||||
clearGameSettings(gameId);
|
clearGameSettings(gameId);
|
||||||
else
|
else
|
||||||
SettingsActivity.launch(getActivity(), MenuTag.WIIMOTE, gameId);
|
SettingsActivity.launch(getActivity(), MenuTag.WIIMOTE, gameId);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 6:
|
||||||
clearGameSettings(gameId);
|
clearGameSettings(gameId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -8,13 +8,13 @@ import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
public class Settings
|
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_CORE = "Core";
|
||||||
public static final String SECTION_INI_INTERFACE = "Interface";
|
public static final String SECTION_INI_INTERFACE = "Interface";
|
||||||
public static final String SECTION_INI_DSP = "DSP";
|
public static final String SECTION_INI_DSP = "DSP";
|
||||||
@ -42,7 +42,8 @@ public class Settings
|
|||||||
static
|
static
|
||||||
{
|
{
|
||||||
configFileSectionsMap.put(SettingsFile.FILE_NAME_DOLPHIN,
|
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));
|
SECTION_BINDINGS, SECTION_ANALYTICS, SECTION_DEBUG));
|
||||||
configFileSectionsMap.put(SettingsFile.FILE_NAME_GFX,
|
configFileSectionsMap.put(SettingsFile.FILE_NAME_GFX,
|
||||||
Arrays.asList(SECTION_GFX_SETTINGS, SECTION_GFX_ENHANCEMENTS, SECTION_GFX_HACKS,
|
Arrays.asList(SECTION_GFX_SETTINGS, SECTION_GFX_ENHANCEMENTS, SECTION_GFX_HACKS,
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -21,6 +21,8 @@ public abstract class SettingsItem
|
|||||||
public static final int TYPE_STRING_SINGLE_CHOICE = 6;
|
public static final int TYPE_STRING_SINGLE_CHOICE = 6;
|
||||||
public static final int TYPE_RUMBLE_BINDING = 7;
|
public static final int TYPE_RUMBLE_BINDING = 7;
|
||||||
public static final int TYPE_SINGLE_CHOICE_DYNAMIC_DESCRIPTIONS = 8;
|
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 mKey;
|
||||||
private String mSection;
|
private String mSection;
|
||||||
|
@ -5,6 +5,7 @@ public enum MenuTag
|
|||||||
CONFIG("config"),
|
CONFIG("config"),
|
||||||
CONFIG_GENERAL("config_general"),
|
CONFIG_GENERAL("config_general"),
|
||||||
CONFIG_INTERFACE("config_interface"),
|
CONFIG_INTERFACE("config_interface"),
|
||||||
|
CONFIG_PATHS("config_paths"),
|
||||||
CONFIG_GAME_CUBE("config_gamecube"),
|
CONFIG_GAME_CUBE("config_gamecube"),
|
||||||
CONFIG_WII("config_wii"),
|
CONFIG_WII("config_wii"),
|
||||||
WIIMOTE("wiimote"),
|
WIIMOTE("wiimote"),
|
||||||
|
@ -19,8 +19,10 @@ import android.view.MenuItem;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.dolphinemu.dolphinemu.R;
|
import org.dolphinemu.dolphinemu.R;
|
||||||
|
import org.dolphinemu.dolphinemu.ui.main.MainActivity;
|
||||||
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
|
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
|
||||||
import org.dolphinemu.dolphinemu.utils.DirectoryStateReceiver;
|
import org.dolphinemu.dolphinemu.utils.DirectoryStateReceiver;
|
||||||
|
import org.dolphinemu.dolphinemu.utils.FileBrowserHelper;
|
||||||
|
|
||||||
public final class SettingsActivity extends AppCompatActivity implements SettingsActivityView
|
public final class SettingsActivity extends AppCompatActivity implements SettingsActivityView
|
||||||
{
|
{
|
||||||
@ -154,6 +156,32 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
|
|||||||
LocalBroadcastManager.getInstance(this).unregisterReceiver(receiver);
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: After result of FilePicker, duplicate SettingsActivity appears.
|
||||||
|
// Finish to avoid this. Is there a better method?
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showLoading()
|
public void showLoading()
|
||||||
{
|
{
|
||||||
|
@ -184,6 +184,11 @@ public final class SettingsActivityPresenter
|
|||||||
outState.putBoolean(KEY_SHOULD_SAVE, mShouldSave);
|
outState.putBoolean(KEY_SHOULD_SAVE, mShouldSave);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean shouldSave()
|
||||||
|
{
|
||||||
|
return mShouldSave;
|
||||||
|
}
|
||||||
|
|
||||||
public void onGcPadSettingChanged(MenuTag key, int value)
|
public void onGcPadSettingChanged(MenuTag key, int value)
|
||||||
{
|
{
|
||||||
if (value != 0) // Not disabled
|
if (value != 0) // Not disabled
|
||||||
@ -217,4 +222,9 @@ public final class SettingsActivityPresenter
|
|||||||
mView.showSettingsFragment(menuTag, bundle, true, gameId);
|
mView.showSettingsFragment(menuTag, bundle, true, gameId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onFileConfirmed(String file)
|
||||||
|
{
|
||||||
|
SettingsAdapter.onFilePickerConfirmation(file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.dolphinemu.dolphinemu.NativeLibrary;
|
||||||
import org.dolphinemu.dolphinemu.R;
|
import org.dolphinemu.dolphinemu.R;
|
||||||
import org.dolphinemu.dolphinemu.dialogs.MotionAlertDialog;
|
import org.dolphinemu.dolphinemu.dialogs.MotionAlertDialog;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
|
||||||
@ -22,6 +23,7 @@ import org.dolphinemu.dolphinemu.features.settings.model.IntSetting;
|
|||||||
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
|
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.StringSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.StringSetting;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.CheckBoxSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.CheckBoxSetting;
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.model.view.FilePicker;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.InputBindingSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.InputBindingSetting;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.RumbleBindingSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.RumbleBindingSetting;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem;
|
||||||
@ -31,6 +33,8 @@ import org.dolphinemu.dolphinemu.features.settings.model.view.SliderSetting;
|
|||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.StringSingleChoiceSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.StringSingleChoiceSetting;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.SubmenuSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.SubmenuSetting;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.CheckBoxSettingViewHolder;
|
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.CheckBoxSettingViewHolder;
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.ConfirmRunnableViewHolder;
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.FilePickerViewHolder;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.HeaderViewHolder;
|
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.HeaderViewHolder;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.InputBindingSettingViewHolder;
|
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.InputBindingSettingViewHolder;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.RumbleBindingViewHolder;
|
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.RumbleBindingViewHolder;
|
||||||
@ -39,14 +43,19 @@ import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.SingleChoiceVie
|
|||||||
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.SliderViewHolder;
|
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.SliderViewHolder;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.SubmenuViewHolder;
|
import org.dolphinemu.dolphinemu.features.settings.ui.viewholder.SubmenuViewHolder;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
|
import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
|
||||||
|
import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
|
||||||
|
import org.dolphinemu.dolphinemu.utils.FileBrowserHelper;
|
||||||
import org.dolphinemu.dolphinemu.utils.Log;
|
import org.dolphinemu.dolphinemu.utils.Log;
|
||||||
|
|
||||||
|
import java.security.InvalidParameterException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolder>
|
public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolder>
|
||||||
implements DialogInterface.OnClickListener, SeekBar.OnSeekBarChangeListener
|
implements DialogInterface.OnClickListener, SeekBar.OnSeekBarChangeListener
|
||||||
{
|
{
|
||||||
private SettingsFragmentView mView;
|
private SettingsFragmentView mView;
|
||||||
|
private static SettingsFragmentView sView;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private ArrayList<SettingsItem> mSettings;
|
private ArrayList<SettingsItem> mSettings;
|
||||||
|
|
||||||
@ -57,9 +66,14 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
|||||||
private AlertDialog mDialog;
|
private AlertDialog mDialog;
|
||||||
private TextView mTextSliderValue;
|
private TextView mTextSliderValue;
|
||||||
|
|
||||||
|
// TODO: Properly restore these two on activity recreation
|
||||||
|
private static FilePicker sFilePicker;
|
||||||
|
private static SettingsItem sItem;
|
||||||
|
|
||||||
public SettingsAdapter(SettingsFragmentView view, Context context)
|
public SettingsAdapter(SettingsFragmentView view, Context context)
|
||||||
{
|
{
|
||||||
mView = view;
|
mView = view;
|
||||||
|
sView = view;
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mClickedPosition = -1;
|
mClickedPosition = -1;
|
||||||
}
|
}
|
||||||
@ -102,6 +116,14 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
|||||||
view = inflater.inflate(R.layout.list_item_setting, parent, false);
|
view = inflater.inflate(R.layout.list_item_setting, parent, false);
|
||||||
return new RumbleBindingViewHolder(view, this, mContext);
|
return new RumbleBindingViewHolder(view, this, mContext);
|
||||||
|
|
||||||
|
case SettingsItem.TYPE_FILE_PICKER:
|
||||||
|
view = inflater.inflate(R.layout.list_item_setting, parent, false);
|
||||||
|
return new FilePickerViewHolder(view, this);
|
||||||
|
|
||||||
|
case SettingsItem.TYPE_CONFIRM_RUNNABLE:
|
||||||
|
view = inflater.inflate(R.layout.list_item_setting, parent, false);
|
||||||
|
return new ConfirmRunnableViewHolder(view, this, mContext, mView);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log.error("[SettingsAdapter] Invalid view type: " + viewType);
|
Log.error("[SettingsAdapter] Invalid view type: " + viewType);
|
||||||
return null;
|
return null;
|
||||||
@ -274,6 +296,72 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
|||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onFilePickerDirectoryClick(SettingsItem item)
|
||||||
|
{
|
||||||
|
sFilePicker = (FilePicker) item;
|
||||||
|
sItem = item;
|
||||||
|
|
||||||
|
FileBrowserHelper.openDirectoryPicker(mView.getActivity(), FileBrowserHelper.GAME_EXTENSIONS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onFilePickerFileClick(SettingsItem item)
|
||||||
|
{
|
||||||
|
sFilePicker = (FilePicker) item;
|
||||||
|
sItem = item;
|
||||||
|
|
||||||
|
HashSet<String> extensions;
|
||||||
|
switch (sFilePicker.getRequestType())
|
||||||
|
{
|
||||||
|
case MainPresenter.REQUEST_SD_FILE:
|
||||||
|
extensions = FileBrowserHelper.RAW_EXTENSION;
|
||||||
|
break;
|
||||||
|
case MainPresenter.REQUEST_GAME_FILE:
|
||||||
|
extensions = FileBrowserHelper.GAME_EXTENSIONS;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new InvalidParameterException("Unhandled request code");
|
||||||
|
}
|
||||||
|
|
||||||
|
FileBrowserHelper.openFilePicker(mView.getActivity(), sFilePicker.getRequestType(), false,
|
||||||
|
extensions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onFilePickerConfirmation(String file)
|
||||||
|
{
|
||||||
|
NativeLibrary.SetConfig(sFilePicker.getFile(), sItem.getSection(), sItem.getKey(), file);
|
||||||
|
NativeLibrary.ReloadConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void resetPaths()
|
||||||
|
{
|
||||||
|
StringSetting defaultISO =
|
||||||
|
new StringSetting(SettingsFile.KEY_DEFAULT_ISO, Settings.SECTION_INI_CORE, "");
|
||||||
|
StringSetting NANDRootPath =
|
||||||
|
new StringSetting(SettingsFile.KEY_NAND_ROOT_PATH, Settings.SECTION_INI_GENERAL,
|
||||||
|
SettingsFragmentPresenter.getDefaultNANDRootPath());
|
||||||
|
StringSetting dumpPath =
|
||||||
|
new StringSetting(SettingsFile.KEY_DUMP_PATH, Settings.SECTION_INI_GENERAL,
|
||||||
|
SettingsFragmentPresenter.getDefaultDumpPath());
|
||||||
|
StringSetting loadPath =
|
||||||
|
new StringSetting(SettingsFile.KEY_LOAD_PATH, Settings.SECTION_INI_GENERAL,
|
||||||
|
SettingsFragmentPresenter.getDefaultLoadPath());
|
||||||
|
StringSetting resourcePackPath =
|
||||||
|
new StringSetting(SettingsFile.KEY_RESOURCE_PACK_PATH, Settings.SECTION_INI_GENERAL,
|
||||||
|
SettingsFragmentPresenter.getDefaultResourcePackPath());
|
||||||
|
StringSetting sdPath =
|
||||||
|
new StringSetting(SettingsFile.KEY_WII_SD_CARD_PATH, Settings.SECTION_INI_GENERAL,
|
||||||
|
SettingsFragmentPresenter.getDefaultSDPath());
|
||||||
|
|
||||||
|
sView.putSetting(defaultISO);
|
||||||
|
sView.putSetting(NANDRootPath);
|
||||||
|
sView.putSetting(dumpPath);
|
||||||
|
sView.putSetting(loadPath);
|
||||||
|
sView.putSetting(resourcePackPath);
|
||||||
|
sView.putSetting(sdPath);
|
||||||
|
|
||||||
|
sView.onSettingChanged();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which)
|
public void onClick(DialogInterface dialog, int which)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.dolphinemu.dolphinemu.features.settings.ui;
|
package org.dolphinemu.dolphinemu.features.settings.ui;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
@ -39,6 +38,7 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
|
|||||||
titles.put(MenuTag.CONFIG, R.string.preferences_settings);
|
titles.put(MenuTag.CONFIG, R.string.preferences_settings);
|
||||||
titles.put(MenuTag.CONFIG_GENERAL, R.string.general_submenu);
|
titles.put(MenuTag.CONFIG_GENERAL, R.string.general_submenu);
|
||||||
titles.put(MenuTag.CONFIG_INTERFACE, R.string.interface_submenu);
|
titles.put(MenuTag.CONFIG_INTERFACE, R.string.interface_submenu);
|
||||||
|
titles.put(MenuTag.CONFIG_PATHS, R.string.paths_submenu);
|
||||||
titles.put(MenuTag.CONFIG_GAME_CUBE, R.string.gamecube_submenu);
|
titles.put(MenuTag.CONFIG_GAME_CUBE, R.string.gamecube_submenu);
|
||||||
titles.put(MenuTag.CONFIG_WII, R.string.wii_submenu);
|
titles.put(MenuTag.CONFIG_WII, R.string.wii_submenu);
|
||||||
titles.put(MenuTag.WIIMOTE, R.string.grid_menu_wiimote_settings);
|
titles.put(MenuTag.WIIMOTE, R.string.grid_menu_wiimote_settings);
|
||||||
@ -217,5 +217,4 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
|
|||||||
{
|
{
|
||||||
mActivity.onExtensionSettingChanged(menuTag, value);
|
mActivity.onExtensionSettingChanged(menuTag, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package org.dolphinemu.dolphinemu.features.settings.ui;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import org.dolphinemu.dolphinemu.DolphinApplication;
|
|
||||||
import org.dolphinemu.dolphinemu.NativeLibrary;
|
import org.dolphinemu.dolphinemu.NativeLibrary;
|
||||||
import org.dolphinemu.dolphinemu.R;
|
import org.dolphinemu.dolphinemu.R;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
|
||||||
@ -13,6 +12,8 @@ import org.dolphinemu.dolphinemu.features.settings.model.SettingSection;
|
|||||||
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
|
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.StringSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.StringSetting;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.CheckBoxSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.CheckBoxSetting;
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.model.view.ConfirmRunnable;
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.model.view.FilePicker;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.HeaderSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.HeaderSetting;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.InputBindingSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.InputBindingSetting;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.RumbleBindingSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.RumbleBindingSetting;
|
||||||
@ -23,10 +24,10 @@ import org.dolphinemu.dolphinemu.features.settings.model.view.SliderSetting;
|
|||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.StringSingleChoiceSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.StringSingleChoiceSetting;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.SubmenuSetting;
|
import org.dolphinemu.dolphinemu.features.settings.model.view.SubmenuSetting;
|
||||||
import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
|
import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
|
||||||
|
import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
|
||||||
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
|
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
|
||||||
import org.dolphinemu.dolphinemu.utils.EGLHelper;
|
import org.dolphinemu.dolphinemu.utils.EGLHelper;
|
||||||
import org.dolphinemu.dolphinemu.utils.Log;
|
import org.dolphinemu.dolphinemu.utils.Log;
|
||||||
import org.dolphinemu.dolphinemu.utils.TvUtil;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -135,6 +136,10 @@ public final class SettingsFragmentPresenter
|
|||||||
addInterfaceSettings(sl);
|
addInterfaceSettings(sl);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CONFIG_PATHS:
|
||||||
|
addPathsSettings(sl);
|
||||||
|
break;
|
||||||
|
|
||||||
case CONFIG_GAME_CUBE:
|
case CONFIG_GAME_CUBE:
|
||||||
addGameCubeSettings(sl);
|
addGameCubeSettings(sl);
|
||||||
break;
|
break;
|
||||||
@ -205,6 +210,7 @@ public final class SettingsFragmentPresenter
|
|||||||
{
|
{
|
||||||
sl.add(new SubmenuSetting(null, null, R.string.general_submenu, 0, MenuTag.CONFIG_GENERAL));
|
sl.add(new SubmenuSetting(null, null, R.string.general_submenu, 0, MenuTag.CONFIG_GENERAL));
|
||||||
sl.add(new SubmenuSetting(null, null, R.string.interface_submenu, 0, MenuTag.CONFIG_INTERFACE));
|
sl.add(new SubmenuSetting(null, null, R.string.interface_submenu, 0, MenuTag.CONFIG_INTERFACE));
|
||||||
|
sl.add(new SubmenuSetting(null, null, R.string.paths_submenu, 0, MenuTag.CONFIG_PATHS));
|
||||||
|
|
||||||
sl.add(new SubmenuSetting(null, null, R.string.gamecube_submenu, 0, MenuTag.CONFIG_GAME_CUBE));
|
sl.add(new SubmenuSetting(null, null, R.string.gamecube_submenu, 0, MenuTag.CONFIG_GAME_CUBE));
|
||||||
sl.add(new SubmenuSetting(null, null, R.string.wii_submenu, 0, MenuTag.CONFIG_WII));
|
sl.add(new SubmenuSetting(null, null, R.string.wii_submenu, 0, MenuTag.CONFIG_WII));
|
||||||
@ -307,6 +313,47 @@ public final class SettingsFragmentPresenter
|
|||||||
onScreenDisplayMessages));
|
onScreenDisplayMessages));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addPathsSettings(ArrayList<SettingsItem> sl)
|
||||||
|
{
|
||||||
|
Setting defaultISO = null;
|
||||||
|
Setting NANDRootPath = null;
|
||||||
|
Setting dumpPath = null;
|
||||||
|
Setting loadPath = null;
|
||||||
|
Setting resourcePackPath = null;
|
||||||
|
Setting wiiSDCardPath = null;
|
||||||
|
|
||||||
|
SettingSection coreSection = mSettings.getSection(Settings.SECTION_INI_CORE);
|
||||||
|
SettingSection generalSection = mSettings.getSection(Settings.SECTION_INI_GENERAL);
|
||||||
|
defaultISO = coreSection.getSetting(SettingsFile.KEY_DEFAULT_ISO);
|
||||||
|
NANDRootPath = generalSection.getSetting(SettingsFile.KEY_NAND_ROOT_PATH);
|
||||||
|
dumpPath = generalSection.getSetting(SettingsFile.KEY_DUMP_PATH);
|
||||||
|
loadPath = generalSection.getSetting(SettingsFile.KEY_LOAD_PATH);
|
||||||
|
resourcePackPath = generalSection.getSetting(SettingsFile.KEY_RESOURCE_PACK_PATH);
|
||||||
|
wiiSDCardPath = generalSection.getSetting(SettingsFile.KEY_WII_SD_CARD_PATH);
|
||||||
|
|
||||||
|
sl.add(new FilePicker(SettingsFile.FILE_NAME_DOLPHIN, SettingsFile.KEY_DEFAULT_ISO,
|
||||||
|
Settings.SECTION_INI_CORE, R.string.default_ISO, 0, "",
|
||||||
|
MainPresenter.REQUEST_GAME_FILE, defaultISO));
|
||||||
|
sl.add(new FilePicker(SettingsFile.FILE_NAME_DOLPHIN, SettingsFile.KEY_NAND_ROOT_PATH,
|
||||||
|
Settings.SECTION_INI_GENERAL, R.string.wii_NAND_root, 0, getDefaultNANDRootPath(),
|
||||||
|
MainPresenter.REQUEST_DIRECTORY, NANDRootPath));
|
||||||
|
sl.add(new FilePicker(SettingsFile.FILE_NAME_DOLPHIN, SettingsFile.KEY_DUMP_PATH,
|
||||||
|
Settings.SECTION_INI_GENERAL, R.string.dump_path, 0, getDefaultDumpPath(),
|
||||||
|
MainPresenter.REQUEST_DIRECTORY, dumpPath));
|
||||||
|
sl.add(new FilePicker(SettingsFile.FILE_NAME_DOLPHIN, SettingsFile.KEY_LOAD_PATH,
|
||||||
|
Settings.SECTION_INI_GENERAL, R.string.load_path, 0, getDefaultLoadPath(),
|
||||||
|
MainPresenter.REQUEST_DIRECTORY, loadPath));
|
||||||
|
sl.add(new FilePicker(SettingsFile.FILE_NAME_DOLPHIN, SettingsFile.KEY_RESOURCE_PACK_PATH,
|
||||||
|
Settings.SECTION_INI_GENERAL, R.string.resource_pack_path, 0,
|
||||||
|
getDefaultResourcePackPath(),
|
||||||
|
MainPresenter.REQUEST_DIRECTORY, resourcePackPath));
|
||||||
|
sl.add(new FilePicker(SettingsFile.FILE_NAME_DOLPHIN, SettingsFile.KEY_WII_SD_CARD_PATH,
|
||||||
|
Settings.SECTION_INI_GENERAL, R.string.SD_card_path, 0, getDefaultSDPath(),
|
||||||
|
MainPresenter.REQUEST_SD_FILE, wiiSDCardPath));
|
||||||
|
sl.add(new ConfirmRunnable(R.string.reset_paths, 0, R.string.reset_paths_confirmation, 0,
|
||||||
|
SettingsAdapter::resetPaths));
|
||||||
|
}
|
||||||
|
|
||||||
private void addGameCubeSettings(ArrayList<SettingsItem> sl)
|
private void addGameCubeSettings(ArrayList<SettingsItem> sl)
|
||||||
{
|
{
|
||||||
Setting systemLanguage = null;
|
Setting systemLanguage = null;
|
||||||
@ -1545,4 +1592,29 @@ public final class SettingsFragmentPresenter
|
|||||||
|
|
||||||
return extensionValue;
|
return extensionValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getDefaultNANDRootPath()
|
||||||
|
{
|
||||||
|
return DirectoryInitialization.getUserDirectory() + "/Wii";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDefaultDumpPath()
|
||||||
|
{
|
||||||
|
return DirectoryInitialization.getUserDirectory() + "/Dump";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDefaultLoadPath()
|
||||||
|
{
|
||||||
|
return DirectoryInitialization.getUserDirectory() + "/Load";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDefaultResourcePackPath()
|
||||||
|
{
|
||||||
|
return DirectoryInitialization.getUserDirectory() + "/ResourcePacks";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDefaultSDPath()
|
||||||
|
{
|
||||||
|
return DirectoryInitialization.getUserDirectory() + "/Wii/sd.raw";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,87 @@
|
|||||||
|
package org.dolphinemu.dolphinemu.features.settings.ui.viewholder;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import org.dolphinemu.dolphinemu.R;
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.model.view.ConfirmRunnable;
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem;
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter;
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsFragmentView;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
|
||||||
|
public final class ConfirmRunnableViewHolder extends SettingViewHolder
|
||||||
|
{
|
||||||
|
private ConfirmRunnable mItem;
|
||||||
|
private SettingsFragmentView mView;
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
|
private TextView mTextSettingName;
|
||||||
|
private TextView mTextSettingDescription;
|
||||||
|
|
||||||
|
public ConfirmRunnableViewHolder(View itemView, SettingsAdapter adapter, Context context,
|
||||||
|
SettingsFragmentView view)
|
||||||
|
{
|
||||||
|
super(itemView, adapter);
|
||||||
|
|
||||||
|
mContext = context;
|
||||||
|
mView = view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void findViews(View root)
|
||||||
|
{
|
||||||
|
mTextSettingName = (TextView) root.findViewById(R.id.text_setting_name);
|
||||||
|
mTextSettingDescription = (TextView) root.findViewById(R.id.text_setting_description);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bind(SettingsItem item)
|
||||||
|
{
|
||||||
|
mItem = (ConfirmRunnable) item;
|
||||||
|
|
||||||
|
mTextSettingName.setText(item.getNameId());
|
||||||
|
|
||||||
|
if (item.getDescriptionId() > 0)
|
||||||
|
{
|
||||||
|
mTextSettingDescription.setText(item.getDescriptionId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View clicked)
|
||||||
|
{
|
||||||
|
String alertTitle = mContext.getString(mItem.getNameId());
|
||||||
|
String alertText = mContext.getString(mItem.getAlertText());
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(mContext)
|
||||||
|
.setTitle(alertTitle)
|
||||||
|
.setMessage(alertText);
|
||||||
|
|
||||||
|
builder
|
||||||
|
.setPositiveButton("Yes", (dialog, whichButton) ->
|
||||||
|
{
|
||||||
|
mItem.getRunnable().run();
|
||||||
|
|
||||||
|
if (mItem.getConfirmationText() > 0)
|
||||||
|
{
|
||||||
|
String confirmationText = mContext.getString(mItem.getConfirmationText());
|
||||||
|
Toast.makeText(mContext, confirmationText, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
dialog.dismiss();
|
||||||
|
|
||||||
|
// TODO: Remove finish and properly update dynamic settings descriptions.
|
||||||
|
mView.getActivity().finish();
|
||||||
|
})
|
||||||
|
.setNegativeButton("No", (dialog, whichButton) ->
|
||||||
|
{
|
||||||
|
dialog.dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.show();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
package org.dolphinemu.dolphinemu.features.settings.ui.viewholder;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.dolphinemu.dolphinemu.NativeLibrary;
|
||||||
|
import org.dolphinemu.dolphinemu.R;
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.model.view.FilePicker;
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem;
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter;
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
|
||||||
|
import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
|
||||||
|
|
||||||
|
public final class FilePickerViewHolder extends SettingViewHolder
|
||||||
|
{
|
||||||
|
private FilePicker mFilePicker;
|
||||||
|
private SettingsItem mItem;
|
||||||
|
|
||||||
|
private TextView mTextSettingName;
|
||||||
|
private TextView mTextSettingDescription;
|
||||||
|
|
||||||
|
public FilePickerViewHolder(View itemView, SettingsAdapter adapter)
|
||||||
|
{
|
||||||
|
super(itemView, adapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void findViews(View root)
|
||||||
|
{
|
||||||
|
mTextSettingName = (TextView) root.findViewById(R.id.text_setting_name);
|
||||||
|
mTextSettingDescription = (TextView) root.findViewById(R.id.text_setting_description);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bind(SettingsItem item)
|
||||||
|
{
|
||||||
|
mFilePicker = (FilePicker) item;
|
||||||
|
mItem = item;
|
||||||
|
|
||||||
|
mTextSettingName.setText(item.getNameId());
|
||||||
|
|
||||||
|
if (item.getDescriptionId() > 0)
|
||||||
|
{
|
||||||
|
mTextSettingDescription.setText(item.getDescriptionId());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mTextSettingDescription.setText(NativeLibrary
|
||||||
|
.GetConfig(mFilePicker.getFile(), item.getSection(), item.getKey(),
|
||||||
|
mFilePicker.getSelectedValue()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View clicked)
|
||||||
|
{
|
||||||
|
if (mFilePicker.getRequestType() == MainPresenter.REQUEST_DIRECTORY)
|
||||||
|
{
|
||||||
|
getAdapter().onFilePickerDirectoryClick(mItem);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getAdapter().onFilePickerFileClick(mItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -54,6 +54,12 @@ public final class SettingsFile
|
|||||||
public static final String KEY_SLOT_A_DEVICE = "SlotA";
|
public static final String KEY_SLOT_A_DEVICE = "SlotA";
|
||||||
public static final String KEY_SLOT_B_DEVICE = "SlotB";
|
public static final String KEY_SLOT_B_DEVICE = "SlotB";
|
||||||
public static final String KEY_ENABLE_SAVE_STATES = "EnableSaveStates";
|
public static final String KEY_ENABLE_SAVE_STATES = "EnableSaveStates";
|
||||||
|
public static final String KEY_DEFAULT_ISO = "DefaultISO";
|
||||||
|
public static final String KEY_NAND_ROOT_PATH = "NANDRootPath";
|
||||||
|
public static final String KEY_DUMP_PATH = "DumpPath";
|
||||||
|
public static final String KEY_LOAD_PATH = "LoadPath";
|
||||||
|
public static final String KEY_RESOURCE_PACK_PATH = "ResourcePackPath";
|
||||||
|
public static final String KEY_WII_SD_CARD_PATH = "WiiSDCardPath";
|
||||||
|
|
||||||
public static final String KEY_ANALYTICS_ENABLED = "Enabled";
|
public static final String KEY_ANALYTICS_ENABLED = "Enabled";
|
||||||
public static final String KEY_ANALYTICS_PERMISSION_ASKED = "PermissionAsked";
|
public static final String KEY_ANALYTICS_PERMISSION_ASKED = "PermissionAsked";
|
||||||
|
@ -14,14 +14,23 @@ import org.dolphinemu.dolphinemu.R;
|
|||||||
import com.nononsenseapps.filepicker.FilePickerFragment;
|
import com.nononsenseapps.filepicker.FilePickerFragment;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class CustomFilePickerFragment extends FilePickerFragment
|
public class CustomFilePickerFragment extends FilePickerFragment
|
||||||
{
|
{
|
||||||
private static final Set<String> extensions = new HashSet<>(Arrays.asList(
|
public static final String KEY_EXTENSIONS = "KEY_EXTENSIONS";
|
||||||
"gcm", "tgc", "iso", "ciso", "gcz", "wbfs", "wad", "dol", "elf", "dff"));
|
|
||||||
|
private HashSet<String> mExtensions;
|
||||||
|
|
||||||
|
public void setExtensions(HashSet<String> extensions)
|
||||||
|
{
|
||||||
|
Bundle b = getArguments();
|
||||||
|
if (b == null)
|
||||||
|
b = new Bundle();
|
||||||
|
|
||||||
|
b.putSerializable(KEY_EXTENSIONS, extensions);
|
||||||
|
setArguments(b);
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
@ -37,6 +46,8 @@ public class CustomFilePickerFragment extends FilePickerFragment
|
|||||||
{
|
{
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
|
mExtensions = (HashSet<String>) getArguments().getSerializable(KEY_EXTENSIONS);
|
||||||
|
|
||||||
if (mode == MODE_DIR)
|
if (mode == MODE_DIR)
|
||||||
{
|
{
|
||||||
TextView ok = getActivity().findViewById(R.id.nnf_button_ok);
|
TextView ok = getActivity().findViewById(R.id.nnf_button_ok);
|
||||||
@ -56,7 +67,7 @@ public class CustomFilePickerFragment extends FilePickerFragment
|
|||||||
|
|
||||||
return (showHiddenItems || !file.isHidden()) &&
|
return (showHiddenItems || !file.isHidden()) &&
|
||||||
(file.isDirectory() ||
|
(file.isDirectory() ||
|
||||||
extensions.contains(fileExtension(file.getName()).toLowerCase()));
|
mExtensions.contains(fileExtension(file.getName()).toLowerCase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -145,13 +145,14 @@ public final class MainActivity extends AppCompatActivity implements MainView
|
|||||||
@Override
|
@Override
|
||||||
public void launchFileListActivity()
|
public void launchFileListActivity()
|
||||||
{
|
{
|
||||||
FileBrowserHelper.openDirectoryPicker(this);
|
FileBrowserHelper.openDirectoryPicker(this, FileBrowserHelper.GAME_EXTENSIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void launchOpenFileActivity()
|
public void launchOpenFileActivity()
|
||||||
{
|
{
|
||||||
FileBrowserHelper.openFilePicker(this, MainPresenter.REQUEST_OPEN_FILE, true);
|
FileBrowserHelper.openFilePicker(this, MainPresenter.REQUEST_GAME_FILE, false,
|
||||||
|
FileBrowserHelper.GAME_EXTENSIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -162,17 +163,18 @@ public final class MainActivity extends AppCompatActivity implements MainView
|
|||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent result)
|
protected void onActivityResult(int requestCode, int resultCode, Intent result)
|
||||||
{
|
{
|
||||||
|
super.onActivityResult(requestCode, resultCode, result);
|
||||||
switch (requestCode)
|
switch (requestCode)
|
||||||
{
|
{
|
||||||
case MainPresenter.REQUEST_ADD_DIRECTORY:
|
case MainPresenter.REQUEST_DIRECTORY:
|
||||||
// If the user picked a file, as opposed to just backing out.
|
// If the user picked a file, as opposed to just backing out.
|
||||||
if (resultCode == MainActivity.RESULT_OK)
|
if (resultCode == MainActivity.RESULT_OK)
|
||||||
{
|
{
|
||||||
mPresenter.onDirectorySelected(FileBrowserHelper.getSelectedDirectory(result));
|
mPresenter.onDirectorySelected(FileBrowserHelper.getSelectedPath(result));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MainPresenter.REQUEST_OPEN_FILE:
|
case MainPresenter.REQUEST_GAME_FILE:
|
||||||
// If the user picked a file, as opposed to just backing out.
|
// If the user picked a file, as opposed to just backing out.
|
||||||
if (resultCode == MainActivity.RESULT_OK)
|
if (resultCode == MainActivity.RESULT_OK)
|
||||||
{
|
{
|
||||||
|
@ -15,8 +15,9 @@ import org.dolphinemu.dolphinemu.services.GameFileCacheService;
|
|||||||
|
|
||||||
public final class MainPresenter
|
public final class MainPresenter
|
||||||
{
|
{
|
||||||
public static final int REQUEST_ADD_DIRECTORY = 1;
|
public static final int REQUEST_DIRECTORY = 1;
|
||||||
public static final int REQUEST_OPEN_FILE = 2;
|
public static final int REQUEST_GAME_FILE = 2;
|
||||||
|
public static final int REQUEST_SD_FILE = 3;
|
||||||
|
|
||||||
private final MainView mView;
|
private final MainView mView;
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
|
@ -5,7 +5,6 @@ import android.content.pm.PackageManager;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.leanback.app.BrowseFragment;
|
|
||||||
import androidx.leanback.app.BrowseSupportFragment;
|
import androidx.leanback.app.BrowseSupportFragment;
|
||||||
import androidx.leanback.widget.ArrayObjectAdapter;
|
import androidx.leanback.widget.ArrayObjectAdapter;
|
||||||
import androidx.leanback.widget.HeaderItem;
|
import androidx.leanback.widget.HeaderItem;
|
||||||
@ -141,13 +140,14 @@ public final class TvMainActivity extends FragmentActivity implements MainView
|
|||||||
@Override
|
@Override
|
||||||
public void launchFileListActivity()
|
public void launchFileListActivity()
|
||||||
{
|
{
|
||||||
FileBrowserHelper.openDirectoryPicker(this);
|
FileBrowserHelper.openDirectoryPicker(this, FileBrowserHelper.GAME_EXTENSIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void launchOpenFileActivity()
|
public void launchOpenFileActivity()
|
||||||
{
|
{
|
||||||
FileBrowserHelper.openFilePicker(this, MainPresenter.REQUEST_OPEN_FILE, true);
|
FileBrowserHelper.openFilePicker(this, MainPresenter.REQUEST_GAME_FILE, false,
|
||||||
|
FileBrowserHelper.GAME_EXTENSIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -169,17 +169,18 @@ public final class TvMainActivity extends FragmentActivity implements MainView
|
|||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent result)
|
protected void onActivityResult(int requestCode, int resultCode, Intent result)
|
||||||
{
|
{
|
||||||
|
super.onActivityResult(requestCode, resultCode, result);
|
||||||
switch (requestCode)
|
switch (requestCode)
|
||||||
{
|
{
|
||||||
case MainPresenter.REQUEST_ADD_DIRECTORY:
|
case MainPresenter.REQUEST_DIRECTORY:
|
||||||
// If the user picked a file, as opposed to just backing out.
|
// If the user picked a file, as opposed to just backing out.
|
||||||
if (resultCode == MainActivity.RESULT_OK)
|
if (resultCode == MainActivity.RESULT_OK)
|
||||||
{
|
{
|
||||||
mPresenter.onDirectorySelected(FileBrowserHelper.getSelectedDirectory(result));
|
mPresenter.onDirectorySelected(FileBrowserHelper.getSelectedPath(result));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MainPresenter.REQUEST_OPEN_FILE:
|
case MainPresenter.REQUEST_GAME_FILE:
|
||||||
// If the user picked a file, as opposed to just backing out.
|
// If the user picked a file, as opposed to just backing out.
|
||||||
if (resultCode == MainActivity.RESULT_OK)
|
if (resultCode == MainActivity.RESULT_OK)
|
||||||
{
|
{
|
||||||
|
@ -14,11 +14,20 @@ import org.dolphinemu.dolphinemu.activities.CustomFilePickerActivity;
|
|||||||
import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
|
import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public final class FileBrowserHelper
|
public final class FileBrowserHelper
|
||||||
{
|
{
|
||||||
public static void openDirectoryPicker(FragmentActivity activity)
|
public static final HashSet<String> GAME_EXTENSIONS = new HashSet<>(Arrays.asList(
|
||||||
|
"gcm", "tgc", "iso", "ciso", "gcz", "wbfs", "wad", "dol", "elf", "dff"));
|
||||||
|
|
||||||
|
public static final HashSet<String> RAW_EXTENSION = new HashSet<>(Collections.singletonList(
|
||||||
|
"raw"));
|
||||||
|
|
||||||
|
public static void openDirectoryPicker(FragmentActivity activity, HashSet<String> extensions)
|
||||||
{
|
{
|
||||||
Intent i = new Intent(activity, CustomFilePickerActivity.class);
|
Intent i = new Intent(activity, CustomFilePickerActivity.class);
|
||||||
|
|
||||||
@ -27,11 +36,13 @@ public final class FileBrowserHelper
|
|||||||
i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_DIR);
|
i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_DIR);
|
||||||
i.putExtra(FilePickerActivity.EXTRA_START_PATH,
|
i.putExtra(FilePickerActivity.EXTRA_START_PATH,
|
||||||
Environment.getExternalStorageDirectory().getPath());
|
Environment.getExternalStorageDirectory().getPath());
|
||||||
|
i.putExtra(CustomFilePickerActivity.EXTRA_EXTENSIONS, extensions);
|
||||||
|
|
||||||
activity.startActivityForResult(i, MainPresenter.REQUEST_ADD_DIRECTORY);
|
activity.startActivityForResult(i, MainPresenter.REQUEST_DIRECTORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openFilePicker(FragmentActivity activity, int requestCode, boolean allowMulti)
|
public static void openFilePicker(FragmentActivity activity, int requestCode, boolean allowMulti,
|
||||||
|
HashSet<String> extensions)
|
||||||
{
|
{
|
||||||
Intent i = new Intent(activity, CustomFilePickerActivity.class);
|
Intent i = new Intent(activity, CustomFilePickerActivity.class);
|
||||||
|
|
||||||
@ -40,12 +51,13 @@ public final class FileBrowserHelper
|
|||||||
i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_FILE);
|
i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_FILE);
|
||||||
i.putExtra(FilePickerActivity.EXTRA_START_PATH,
|
i.putExtra(FilePickerActivity.EXTRA_START_PATH,
|
||||||
Environment.getExternalStorageDirectory().getPath());
|
Environment.getExternalStorageDirectory().getPath());
|
||||||
|
i.putExtra(CustomFilePickerActivity.EXTRA_EXTENSIONS, extensions);
|
||||||
|
|
||||||
activity.startActivityForResult(i, requestCode);
|
activity.startActivityForResult(i, requestCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static String getSelectedDirectory(Intent result)
|
public static String getSelectedPath(Intent result)
|
||||||
{
|
{
|
||||||
// Use the provided utility method to parse the result
|
// Use the provided utility method to parse the result
|
||||||
List<Uri> files = Utils.getSelectedFilesFromResult(result);
|
List<Uri> files = Utils.getSelectedFilesFromResult(result);
|
||||||
|
@ -337,6 +337,7 @@
|
|||||||
|
|
||||||
<string-array name="gameSettingsMenusGC">
|
<string-array name="gameSettingsMenusGC">
|
||||||
<item>Details</item>
|
<item>Details</item>
|
||||||
|
<item>Set as Default ISO</item>
|
||||||
<item>Core Settings</item>
|
<item>Core Settings</item>
|
||||||
<item>GFX Settings</item>
|
<item>GFX Settings</item>
|
||||||
<item>GameCube Controller Settings</item>
|
<item>GameCube Controller Settings</item>
|
||||||
@ -344,6 +345,7 @@
|
|||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="gameSettingsMenusWii">
|
<string-array name="gameSettingsMenusWii">
|
||||||
<item>Details</item>
|
<item>Details</item>
|
||||||
|
<item>Set as Default ISO</item>
|
||||||
<item>Core Settings</item>
|
<item>Core Settings</item>
|
||||||
<item>GFX Settings</item>
|
<item>GFX Settings</item>
|
||||||
<item>GameCube Controller Settings</item>
|
<item>GameCube Controller Settings</item>
|
||||||
|
@ -162,6 +162,17 @@
|
|||||||
<string name="osd_messages">Show On-Screen Display Messages</string>
|
<string name="osd_messages">Show On-Screen Display Messages</string>
|
||||||
<string name="osd_messages_description">Display messages over the emulation screen area. These messages include memory card writes, video backend and CPU information, and JIT cache clearing.</string>
|
<string name="osd_messages_description">Display messages over the emulation screen area. These messages include memory card writes, video backend and CPU information, and JIT cache clearing.</string>
|
||||||
|
|
||||||
|
<!-- Path Settings -->
|
||||||
|
<string name="paths_submenu">Paths</string>
|
||||||
|
<string name="default_ISO">Default ISO</string>
|
||||||
|
<string name="wii_NAND_root">Wii NAND Root</string>
|
||||||
|
<string name="dump_path">Dump Path</string>
|
||||||
|
<string name="load_path">Load Path</string>
|
||||||
|
<string name="resource_pack_path">Resource Pack Path</string>
|
||||||
|
<string name="SD_card_path">SD Card Path</string>
|
||||||
|
<string name="reset_paths">Reset Paths to Default Settings</string>
|
||||||
|
<string name="reset_paths_confirmation">Are you sure you want to reset Paths to default settings?</string>
|
||||||
|
|
||||||
<!-- Graphics Settings -->
|
<!-- Graphics Settings -->
|
||||||
<string name="graphics_general">General</string>
|
<string name="graphics_general">General</string>
|
||||||
<string name="graphics_enhancements_and_hacks">Enhancements & Hacks</string>
|
<string name="graphics_enhancements_and_hacks">Enhancements & Hacks</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user