diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SettingsItem.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SettingsItem.java index ebc68f6948..5a9e5321e3 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SettingsItem.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SettingsItem.java @@ -77,4 +77,14 @@ public abstract class SettingsItem AbstractSetting setting = getSetting(); return setting != null && setting.isRuntimeEditable(); } + + public boolean hasSetting() + { + return getSetting() != null; + } + + public void clear(Settings settings) + { + getSetting().delete(settings); + } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.java index 8873a668fb..b2091d3d05 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.java @@ -160,6 +160,14 @@ public final class SettingsAdapter extends RecyclerView.Adapter sl) @@ -356,8 +357,6 @@ public final class SettingsFragmentPresenter MainPresenter.REQUEST_DIRECTORY, "/ResourcePacks")); sl.add(new FilePicker(StringSetting.MAIN_SD_PATH, R.string.SD_card_path, 0, MainPresenter.REQUEST_SD_FILE, "/Wii/sd.raw")); - sl.add(new RunRunnable(R.string.reset_paths, 0, R.string.reset_paths_confirmation, 0, - mView.getAdapter()::resetPaths)); } private void addGameCubeSettings(ArrayList sl) @@ -435,16 +434,19 @@ public final class SettingsFragmentPresenter { for (int i = 0; i < 4; i++) { + // GameCube controller 1 is set to Emulated by default, all others disabled + int defaultValue = i == 0 ? 6 : 0; + LegacyIntSetting gcPadSetting; if (mGameID.equals("")) { gcPadSetting = new LegacyIntSetting(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, - SettingsFile.KEY_GCPAD_TYPE + i, 0); + SettingsFile.KEY_GCPAD_TYPE + i, defaultValue); } else { gcPadSetting = new LegacyIntSetting(Settings.GAME_SETTINGS_PLACEHOLDER_FILE_NAME, - Settings.SECTION_CONTROLS, SettingsFile.KEY_GCPAD_G_TYPE + i, 0); + Settings.SECTION_CONTROLS, SettingsFile.KEY_GCPAD_G_TYPE + i, defaultValue); } // TODO: This controller_0 + i business is quite the hack. It should work, but only if the definitions are kept together and in order. sl.add(new SingleChoiceSetting(gcPadSetting, R.string.controller_0 + i, 0, @@ -456,16 +458,19 @@ public final class SettingsFragmentPresenter { for (int i = 0; i < 4; i++) { + // Wii Remote 1 is set to Emulated by default, all others disabled + int defaultValue = i == 0 ? 1 : 0; + LegacyIntSetting wiimoteSetting; if (mGameID.equals("")) { wiimoteSetting = new LegacyIntSetting(Settings.FILE_WIIMOTE, - Settings.SECTION_WIIMOTE + (i + 1), SettingsFile.KEY_WIIMOTE_TYPE, 0); + Settings.SECTION_WIIMOTE + (i + 1), SettingsFile.KEY_WIIMOTE_TYPE, defaultValue); } else { wiimoteSetting = new LegacyIntSetting(Settings.GAME_SETTINGS_PLACEHOLDER_FILE_NAME, - Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIMOTE_G_TYPE + i, 0); + Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIMOTE_G_TYPE + i, defaultValue); } // TODO: This wiimote_0 + i business is quite the hack. It should work, but only if the definitions are kept together and in order. sl.add(new SingleChoiceSetting(wiimoteSetting, R.string.wiimote_4 + i, 0, @@ -493,6 +498,7 @@ public final class SettingsFragmentPresenter sl.add(new HeaderSetting(R.string.graphics_enhancements_and_hacks, 0)); sl.add(new SubmenuSetting(R.string.enhancements_submenu, MenuTag.ENHANCEMENTS)); sl.add(new SubmenuSetting(R.string.hacks_submenu, MenuTag.HACKS)); + sl.add(new HeaderSetting(R.string.setting_clear_info, 0)); } private void addEnhanceSettings(ArrayList sl) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/CheckBoxSettingViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/CheckBoxSettingViewHolder.java index 07206a04fa..5a505ea9df 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/CheckBoxSettingViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/CheckBoxSettingViewHolder.java @@ -4,6 +4,8 @@ import android.view.View; import android.widget.CheckBox; import android.widget.TextView; +import androidx.annotation.Nullable; + import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.features.settings.model.view.CheckBoxSetting; import org.dolphinemu.dolphinemu.features.settings.model.view.LogCheckBoxSetting; @@ -78,4 +80,10 @@ public final class CheckBoxSettingViewHolder extends SettingViewHolder setStyle(mTextSettingName, mItem); } + + @Nullable @Override + protected SettingsItem getItem() + { + return mItem; + } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/FilePickerViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/FilePickerViewHolder.java index 39b17d587a..790ce1acf9 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/FilePickerViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/FilePickerViewHolder.java @@ -4,6 +4,8 @@ import android.text.TextUtils; import android.view.View; import android.widget.TextView; +import androidx.annotation.Nullable; + import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.features.settings.model.view.FilePicker; import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem; @@ -82,4 +84,10 @@ public final class FilePickerViewHolder extends SettingViewHolder setStyle(mTextSettingName, mItem); } + + @Nullable @Override + protected SettingsItem getItem() + { + return mItem; + } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/HeaderViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/HeaderViewHolder.java index 6ece671bf4..2661379e70 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/HeaderViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/HeaderViewHolder.java @@ -3,6 +3,8 @@ package org.dolphinemu.dolphinemu.features.settings.ui.viewholder; import android.view.View; import android.widget.TextView; +import androidx.annotation.Nullable; + import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem; import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter; @@ -34,4 +36,10 @@ public final class HeaderViewHolder extends SettingViewHolder { // no-op } + + @Nullable @Override + protected SettingsItem getItem() + { + return null; + } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/InputBindingSettingViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/InputBindingSettingViewHolder.java index 7dda7b3630..8e65949112 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/InputBindingSettingViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/InputBindingSettingViewHolder.java @@ -6,6 +6,8 @@ import android.preference.PreferenceManager; import android.view.View; import android.widget.TextView; +import androidx.annotation.Nullable; + import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.features.settings.model.view.InputBindingSetting; import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem; @@ -61,4 +63,10 @@ public final class InputBindingSettingViewHolder extends SettingViewHolder setStyle(mTextSettingName, mItem); } + + @Nullable @Override + protected SettingsItem getItem() + { + return mItem; + } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/RumbleBindingViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/RumbleBindingViewHolder.java index 3968e0c078..dc77ccf0c5 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/RumbleBindingViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/RumbleBindingViewHolder.java @@ -6,6 +6,8 @@ import android.preference.PreferenceManager; import android.view.View; import android.widget.TextView; +import androidx.annotation.Nullable; + import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.features.settings.model.view.RumbleBindingSetting; import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem; @@ -61,4 +63,10 @@ public class RumbleBindingViewHolder extends SettingViewHolder setStyle(mTextSettingName, mItem); } + + @Nullable @Override + protected SettingsItem getItem() + { + return mItem; + } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/RunRunnableViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/RunRunnableViewHolder.java index 1fd87824df..b80f218e6a 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/RunRunnableViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/RunRunnableViewHolder.java @@ -5,6 +5,7 @@ import android.view.View; import android.widget.TextView; import android.widget.Toast; +import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import org.dolphinemu.dolphinemu.R; @@ -56,8 +57,8 @@ public final class RunRunnableViewHolder extends SettingViewHolder if (alertTextID > 0) { AlertDialog.Builder builder = new AlertDialog.Builder(mContext, R.style.DolphinDialogBase) - .setTitle(mContext.getString(mItem.getNameId())) - .setMessage(mContext.getString(alertTextID)); + .setTitle(mItem.getNameId()) + .setMessage(alertTextID); builder .setPositiveButton(R.string.ok, (dialog, whichButton) -> @@ -75,6 +76,12 @@ public final class RunRunnableViewHolder extends SettingViewHolder } } + @Nullable @Override + protected SettingsItem getItem() + { + return mItem; + } + private void runRunnable() { mItem.getRunnable().run(); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SettingViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SettingViewHolder.java index c23a3a270b..bd1cf09f2c 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SettingViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SettingViewHolder.java @@ -1,12 +1,14 @@ package org.dolphinemu.dolphinemu.features.settings.ui.viewholder; - +import android.content.Context; import android.graphics.Paint; import android.graphics.Typeface; import android.view.View; import android.widget.TextView; import android.widget.Toast; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; import androidx.recyclerview.widget.RecyclerView; import org.dolphinemu.dolphinemu.DolphinApplication; @@ -15,7 +17,7 @@ import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem; import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter; public abstract class SettingViewHolder extends RecyclerView.ViewHolder - implements View.OnClickListener + implements View.OnClickListener, View.OnLongClickListener { private SettingsAdapter mAdapter; @@ -26,6 +28,7 @@ public abstract class SettingViewHolder extends RecyclerView.ViewHolder mAdapter = adapter; itemView.setOnClickListener(this); + itemView.setOnLongClickListener(this); findViews(itemView); } @@ -72,4 +75,40 @@ public abstract class SettingViewHolder extends RecyclerView.ViewHolder * @param clicked The view that was clicked on. */ public abstract void onClick(View clicked); + + @Nullable + protected abstract SettingsItem getItem(); + + public boolean onLongClick(View clicked) + { + SettingsItem item = getItem(); + + if (item == null || !item.hasSetting()) + return false; + + if (!item.isEditable()) + { + showNotRuntimeEditableError(); + return true; + } + + Context context = clicked.getContext(); + + AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.DolphinDialogBase) + .setMessage(R.string.setting_clear_confirm); + + builder + .setPositiveButton(R.string.ok, (dialog, whichButton) -> + { + getAdapter().clearSetting(item, getAdapterPosition()); + bind(item); + Toast.makeText(context, R.string.setting_cleared, Toast.LENGTH_SHORT).show(); + dialog.dismiss(); + }) + .setNegativeButton(R.string.cancel, (dialog, whichButton) -> dialog.dismiss()); + + builder.show(); + + return true; + } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SingleChoiceViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SingleChoiceViewHolder.java index a8f869cba9..c359d4d6e1 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SingleChoiceViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SingleChoiceViewHolder.java @@ -4,6 +4,8 @@ import android.content.res.Resources; import android.view.View; import android.widget.TextView; +import androidx.annotation.Nullable; + import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem; import org.dolphinemu.dolphinemu.features.settings.model.view.SingleChoiceSetting; @@ -110,4 +112,10 @@ public final class SingleChoiceViewHolder extends SettingViewHolder setStyle(mTextSettingName, mItem); } + + @Nullable @Override + protected SettingsItem getItem() + { + return mItem; + } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SliderViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SliderViewHolder.java index 6a7d9a0fa3..64534fe957 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SliderViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SliderViewHolder.java @@ -4,6 +4,8 @@ import android.content.Context; import android.view.View; import android.widget.TextView; +import androidx.annotation.Nullable; + import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem; import org.dolphinemu.dolphinemu.features.settings.model.view.SliderSetting; @@ -66,5 +68,11 @@ public final class SliderViewHolder extends SettingViewHolder setStyle(mTextSettingName, mItem); } + + @Nullable @Override + protected SettingsItem getItem() + { + return mItem; + } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SubmenuViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SubmenuViewHolder.java index 0560f3818f..33aa4bfb33 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SubmenuViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SubmenuViewHolder.java @@ -3,6 +3,8 @@ package org.dolphinemu.dolphinemu.features.settings.ui.viewholder; import android.view.View; import android.widget.TextView; +import androidx.annotation.Nullable; + import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem; import org.dolphinemu.dolphinemu.features.settings.model.view.SubmenuSetting; @@ -38,4 +40,10 @@ public final class SubmenuViewHolder extends SettingViewHolder { getAdapter().onSubmenuClick(mItem); } + + @Nullable @Override + protected SettingsItem getItem() + { + return mItem; + } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java index b058c6cd3f..e65805fd95 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java @@ -215,11 +215,6 @@ public final class SettingsFile public static void readFile(final String fileName, IniFile ini, SettingsActivityView view) { readFile(getSettingsFile(fileName), ini, view); - - if (fileName.equals(Settings.FILE_DOLPHIN)) - { - addGcPadSettingsIfTheyDontExist(ini); - } } /** @@ -328,19 +323,4 @@ public final class SettingsFile return new File(wiiConfigPath); } - - private static void addGcPadSettingsIfTheyDontExist(IniFile ini) - { - IniFile.Section coreSection = ini.getOrCreateSection(Settings.SECTION_INI_CORE); - - for (int i = 0; i < 4; i++) - { - String key = SettingsFile.KEY_GCPAD_TYPE + i; - if (!coreSection.exists(key)) - { - // Set GameCube controller 1 to enabled, all others disabled - coreSection.setInt(key, i == 0 ? 6 : 0); - } - } - } } diff --git a/Source/Android/app/src/main/res/values/strings.xml b/Source/Android/app/src/main/res/values/strings.xml index 902665ba05..e940416ca9 100644 --- a/Source/Android/app/src/main/res/values/strings.xml +++ b/Source/Android/app/src/main/res/values/strings.xml @@ -183,8 +183,6 @@ Load Path Resource Pack Path SD Card Path - Reset Paths to Default Settings - Are you sure you want to reset Paths to default settings? General @@ -418,6 +416,9 @@ It can efficiently compress both junk data and encrypted Wii data. You need to allow write access to external storage for the emulator to work Loading Settings... This setting can\'t be changed while a game is running. + Long press a setting to clear it. + Do you want to restore this setting to its default value? + Setting cleared Change Disc The external storage needs to be available in order to use Dolphin