Android: Use CharSequence for SettingsItem name/description

This commit is contained in:
JosJuice 2021-05-09 16:25:41 +02:00
parent 049b92b7ef
commit a8f48feddb
29 changed files with 486 additions and 437 deletions

View File

@ -1,5 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view; package org.dolphinemu.dolphinemu.features.settings.model.view;
import android.content.Context;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings; import org.dolphinemu.dolphinemu.features.settings.model.Settings;
@ -8,9 +10,10 @@ public class CheckBoxSetting extends SettingsItem
{ {
protected AbstractBooleanSetting mSetting; protected AbstractBooleanSetting mSetting;
public CheckBoxSetting(AbstractBooleanSetting setting, int titleId, int descriptionId) public CheckBoxSetting(Context context, AbstractBooleanSetting setting, int titleId,
int descriptionId)
{ {
super(titleId, descriptionId); super(context, titleId, descriptionId);
mSetting = setting; mSetting = setting;
} }

View File

@ -1,5 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view; package org.dolphinemu.dolphinemu.features.settings.model.view;
import android.content.Context;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractStringSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractStringSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings; import org.dolphinemu.dolphinemu.features.settings.model.Settings;
@ -12,10 +14,10 @@ public final class FilePicker extends SettingsItem
private int mRequestType; private int mRequestType;
private String mDefaultPathRelativeToUserDirectory; private String mDefaultPathRelativeToUserDirectory;
public FilePicker(AbstractStringSetting setting, int titleId, int descriptionId, int requestType, public FilePicker(Context context, AbstractStringSetting setting, int titleId, int descriptionId,
@Nullable String defaultPathRelativeToUserDirectory) int requestType, @Nullable String defaultPathRelativeToUserDirectory)
{ {
super(titleId, descriptionId); super(context, titleId, descriptionId);
mSetting = setting; mSetting = setting;
mRequestType = requestType; mRequestType = requestType;
mDefaultPathRelativeToUserDirectory = defaultPathRelativeToUserDirectory; mDefaultPathRelativeToUserDirectory = defaultPathRelativeToUserDirectory;

View File

@ -1,5 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view; package org.dolphinemu.dolphinemu.features.settings.model.view;
import android.content.Context;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractFloatSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractFloatSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings; import org.dolphinemu.dolphinemu.features.settings.model.Settings;
@ -8,10 +10,10 @@ public class FloatSliderSetting extends SliderSetting
{ {
protected AbstractFloatSetting mSetting; protected AbstractFloatSetting mSetting;
public FloatSliderSetting(AbstractFloatSetting setting, int titleId, int descriptionId, int min, public FloatSliderSetting(Context context, AbstractFloatSetting setting, int titleId,
int max, String units) int descriptionId, int min, int max, String units)
{ {
super(titleId, descriptionId, min, max, units); super(context, titleId, descriptionId, min, max, units);
mSetting = setting; mSetting = setting;
} }

View File

@ -1,12 +1,14 @@
package org.dolphinemu.dolphinemu.features.settings.model.view; package org.dolphinemu.dolphinemu.features.settings.model.view;
import android.content.Context;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
public final class HeaderSetting extends SettingsItem public final class HeaderSetting extends SettingsItem
{ {
public HeaderSetting(int titleId, int descriptionId) public HeaderSetting(Context context, int titleId, int descriptionId)
{ {
super(titleId, descriptionId); super(context, titleId, descriptionId);
} }
@Override @Override

View File

@ -1,5 +1,6 @@
package org.dolphinemu.dolphinemu.features.settings.model.view; package org.dolphinemu.dolphinemu.features.settings.model.view;
import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.view.InputDevice; import android.view.InputDevice;
@ -17,9 +18,10 @@ public class InputBindingSetting extends SettingsItem
private String mGameId; private String mGameId;
public InputBindingSetting(String file, String section, String key, int titleId, String gameId) public InputBindingSetting(Context context, String file, String section, String key, int titleId,
String gameId)
{ {
super(titleId, 0); super(context, titleId, 0);
mFile = file; mFile = file;
mSection = section; mSection = section;
mKey = key; mKey = key;

View File

@ -1,5 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view; package org.dolphinemu.dolphinemu.features.settings.model.view;
import android.content.Context;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings; import org.dolphinemu.dolphinemu.features.settings.model.Settings;
@ -8,10 +10,10 @@ public final class IntSliderSetting extends SliderSetting
{ {
private AbstractIntSetting mSetting; private AbstractIntSetting mSetting;
public IntSliderSetting(AbstractIntSetting setting, int titleId, int descriptionId, int min, public IntSliderSetting(Context context, AbstractIntSetting setting, int titleId,
int max, String units) int descriptionId, int min, int max, String units)
{ {
super(titleId, descriptionId, min, max, units); super(context, titleId, descriptionId, min, max, units);
mSetting = setting; mSetting = setting;
} }

View File

@ -1,15 +1,17 @@
package org.dolphinemu.dolphinemu.features.settings.model.view; package org.dolphinemu.dolphinemu.features.settings.model.view;
import android.content.Context;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings; import org.dolphinemu.dolphinemu.features.settings.model.Settings;
public final class InvertedCheckBoxSetting extends CheckBoxSetting public final class InvertedCheckBoxSetting extends CheckBoxSetting
{ {
public InvertedCheckBoxSetting(AbstractBooleanSetting setting, int titleId, public InvertedCheckBoxSetting(Context context, AbstractBooleanSetting setting, int titleId,
int descriptionId) int descriptionId)
{ {
super(setting, titleId, descriptionId); super(context, setting, titleId, descriptionId);
} }
@Override @Override

View File

@ -1,5 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view; package org.dolphinemu.dolphinemu.features.settings.model.view;
import android.content.Context;
import org.dolphinemu.dolphinemu.features.settings.model.AdHocBooleanSetting; import org.dolphinemu.dolphinemu.features.settings.model.AdHocBooleanSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings; import org.dolphinemu.dolphinemu.features.settings.model.Settings;
@ -7,9 +9,10 @@ public class LogCheckBoxSetting extends CheckBoxSetting
{ {
String mKey; String mKey;
public LogCheckBoxSetting(String key, int titleId, int descriptionId) public LogCheckBoxSetting(Context context, String key, int titleId, int descriptionId)
{ {
super(new AdHocBooleanSetting(Settings.FILE_LOGGER, Settings.SECTION_LOGGER_LOGS, key, false), super(context,
new AdHocBooleanSetting(Settings.FILE_LOGGER, Settings.SECTION_LOGGER_LOGS, key, false),
titleId, descriptionId); titleId, descriptionId);
mKey = key; mKey = key;
} }

View File

@ -1,15 +1,17 @@
package org.dolphinemu.dolphinemu.features.settings.model.view; package org.dolphinemu.dolphinemu.features.settings.model.view;
import android.content.Context;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractFloatSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractFloatSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings; import org.dolphinemu.dolphinemu.features.settings.model.Settings;
public final class PercentSliderSetting extends FloatSliderSetting public final class PercentSliderSetting extends FloatSliderSetting
{ {
public PercentSliderSetting(AbstractFloatSetting setting, int titleId, int descriptionId, int min, public PercentSliderSetting(Context context, AbstractFloatSetting setting, int titleId,
int max, String units) int descriptionId, int min, int max, String units)
{ {
super(setting, titleId, descriptionId, min, max, units); super(context, setting, titleId, descriptionId, min, max, units);
} }
@Override @Override

View File

@ -1,5 +1,6 @@
package org.dolphinemu.dolphinemu.features.settings.model.view; package org.dolphinemu.dolphinemu.features.settings.model.view;
import android.content.Context;
import android.os.Vibrator; import android.os.Vibrator;
import android.view.InputDevice; import android.view.InputDevice;
import android.view.KeyEvent; import android.view.KeyEvent;
@ -12,9 +13,10 @@ import org.dolphinemu.dolphinemu.utils.Rumble;
public class RumbleBindingSetting extends InputBindingSetting public class RumbleBindingSetting extends InputBindingSetting
{ {
public RumbleBindingSetting(String file, String section, String key, int titleId, String gameId) public RumbleBindingSetting(Context context, String file, String section, String key, int titleId,
String gameId)
{ {
super(file, section, key, titleId, gameId); super(context, file, section, key, titleId, gameId);
} }
/** /**

View File

@ -1,5 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view; package org.dolphinemu.dolphinemu.features.settings.model.view;
import android.content.Context;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
public final class RunRunnable extends SettingsItem public final class RunRunnable extends SettingsItem
@ -8,10 +10,10 @@ public final class RunRunnable extends SettingsItem
private final int mToastTextAfterRun; private final int mToastTextAfterRun;
private final Runnable mRunnable; private final Runnable mRunnable;
public RunRunnable(int titleId, int descriptionId, int alertText, int toastTextAfterRun, public RunRunnable(Context context, int titleId, int descriptionId, int alertText,
Runnable runnable) int toastTextAfterRun, Runnable runnable)
{ {
super(titleId, descriptionId); super(context, titleId, descriptionId);
mAlertText = alertText; mAlertText = alertText;
mToastTextAfterRun = toastTextAfterRun; mToastTextAfterRun = toastTextAfterRun;
mRunnable = runnable; mRunnable = runnable;

View File

@ -1,5 +1,8 @@
package org.dolphinemu.dolphinemu.features.settings.model.view; package org.dolphinemu.dolphinemu.features.settings.model.view;
import android.content.Context;
import org.dolphinemu.dolphinemu.DolphinApplication;
import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings; import org.dolphinemu.dolphinemu.features.settings.model.Settings;
@ -24,33 +27,39 @@ public abstract class SettingsItem
public static final int TYPE_FILE_PICKER = 9; public static final int TYPE_FILE_PICKER = 9;
public static final int TYPE_RUN_RUNNABLE = 10; public static final int TYPE_RUN_RUNNABLE = 10;
private final int mNameId; private final CharSequence mName;
private final int mDescriptionId; private final CharSequence mDescription;
/** /**
* Base constructor. * Base constructor.
* *
* @param nameId Resource ID for a text string to be displayed as this setting's name. * @param name A text string to be displayed as this setting's name.
* @param descriptionId Resource ID for a text string to be displayed as this setting's description. * @param description A text string to be displayed as this setting's description.
*/ */
public SettingsItem(CharSequence name, CharSequence description)
public SettingsItem(int nameId, int descriptionId)
{ {
mNameId = nameId; mName = name;
mDescriptionId = descriptionId; mDescription = description;
} }
/** /**
* @return A resource ID for a text string representing this setting's name. * @param nameId Resource ID for a text string to be displayed as this setting's name.
* @param descriptionId Resource ID for a text string to be displayed as this setting's description.
*/ */
public int getNameId() public SettingsItem(Context context, int nameId, int descriptionId)
{ {
return mNameId; mName = nameId == 0 ? "" : context.getText(nameId);
mDescription = descriptionId == 0 ? "" : context.getText(descriptionId);
} }
public int getDescriptionId() public CharSequence getName()
{ {
return mDescriptionId; return mName;
}
public CharSequence getDescription()
{
return mDescription;
} }
/** /**

View File

@ -1,5 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view; package org.dolphinemu.dolphinemu.features.settings.model.view;
import android.content.Context;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings; import org.dolphinemu.dolphinemu.features.settings.model.Settings;
@ -13,20 +15,20 @@ public final class SingleChoiceSetting extends SettingsItem
private int mValuesId; private int mValuesId;
private MenuTag menuTag; private MenuTag menuTag;
public SingleChoiceSetting(AbstractIntSetting setting, int titleId, int descriptionId, public SingleChoiceSetting(Context context, AbstractIntSetting setting, int titleId,
int choicesId, int valuesId, MenuTag menuTag) int descriptionId, int choicesId, int valuesId, MenuTag menuTag)
{ {
super(titleId, descriptionId); super(context, titleId, descriptionId);
mSetting = setting; mSetting = setting;
mValuesId = valuesId; mValuesId = valuesId;
mChoicesId = choicesId; mChoicesId = choicesId;
this.menuTag = menuTag; this.menuTag = menuTag;
} }
public SingleChoiceSetting(AbstractIntSetting setting, int titleId, int descriptionId, public SingleChoiceSetting(Context context, AbstractIntSetting setting, int titleId,
int choicesId, int valuesId) int descriptionId, int choicesId, int valuesId)
{ {
this(setting, titleId, descriptionId, choicesId, valuesId, null); this(context, setting, titleId, descriptionId, choicesId, valuesId, null);
} }
public int getChoicesId() public int getChoicesId()

View File

@ -1,5 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view; package org.dolphinemu.dolphinemu.features.settings.model.view;
import android.content.Context;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings; import org.dolphinemu.dolphinemu.features.settings.model.Settings;
@ -15,11 +17,11 @@ public final class SingleChoiceSettingDynamicDescriptions extends SettingsItem
private int mDescriptionValuesId; private int mDescriptionValuesId;
private MenuTag menuTag; private MenuTag menuTag;
public SingleChoiceSettingDynamicDescriptions(AbstractIntSetting setting, int titleId, public SingleChoiceSettingDynamicDescriptions(Context context, AbstractIntSetting setting,
int descriptionId, int choicesId, int valuesId, int descriptionChoicesId, int titleId, int descriptionId, int choicesId, int valuesId, int descriptionChoicesId,
int descriptionValuesId, MenuTag menuTag) int descriptionValuesId, MenuTag menuTag)
{ {
super(titleId, descriptionId); super(context, titleId, descriptionId);
mSetting = setting; mSetting = setting;
mValuesId = valuesId; mValuesId = valuesId;
mChoicesId = choicesId; mChoicesId = choicesId;
@ -28,11 +30,11 @@ public final class SingleChoiceSettingDynamicDescriptions extends SettingsItem
this.menuTag = menuTag; this.menuTag = menuTag;
} }
public SingleChoiceSettingDynamicDescriptions(AbstractIntSetting setting, int titleId, public SingleChoiceSettingDynamicDescriptions(Context context, AbstractIntSetting setting,
int descriptionId, int choicesId, int valuesId, int descriptionChoicesId, int titleId, int descriptionId, int choicesId, int valuesId, int descriptionChoicesId,
int descriptionValuesId) int descriptionValuesId)
{ {
this(setting, titleId, descriptionId, choicesId, valuesId, descriptionChoicesId, this(context, setting, titleId, descriptionId, choicesId, valuesId, descriptionChoicesId,
descriptionValuesId, null); descriptionValuesId, null);
} }

View File

@ -1,5 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view; package org.dolphinemu.dolphinemu.features.settings.model.view;
import android.content.Context;
import org.dolphinemu.dolphinemu.features.settings.model.Settings; import org.dolphinemu.dolphinemu.features.settings.model.Settings;
public abstract class SliderSetting extends SettingsItem public abstract class SliderSetting extends SettingsItem
@ -8,9 +10,10 @@ public abstract class SliderSetting extends SettingsItem
private int mMax; private int mMax;
private String mUnits; private String mUnits;
public SliderSetting(int nameId, int descriptionId, int min, int max, String units) public SliderSetting(Context context, int nameId, int descriptionId, int min, int max,
String units)
{ {
super(nameId, descriptionId); super(context, nameId, descriptionId);
mMin = min; mMin = min;
mMax = max; mMax = max;
mUnits = units; mUnits = units;

View File

@ -1,5 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view; package org.dolphinemu.dolphinemu.features.settings.model.view;
import android.content.Context;
import org.dolphinemu.dolphinemu.DolphinApplication; import org.dolphinemu.dolphinemu.DolphinApplication;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractStringSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractStringSetting;
@ -14,36 +16,36 @@ public class StringSingleChoiceSetting extends SettingsItem
private String[] mValuesId; private String[] mValuesId;
private MenuTag mMenuTag; private MenuTag mMenuTag;
public StringSingleChoiceSetting(AbstractStringSetting setting, int titleId, public StringSingleChoiceSetting(Context context, AbstractStringSetting setting, int titleId,
int descriptionId, String[] choicesId, String[] valuesId, MenuTag menuTag) int descriptionId, String[] choicesId, String[] valuesId, MenuTag menuTag)
{ {
super(titleId, descriptionId); super(context, titleId, descriptionId);
mSetting = setting; mSetting = setting;
mChoicesId = choicesId; mChoicesId = choicesId;
mValuesId = valuesId; mValuesId = valuesId;
mMenuTag = menuTag; mMenuTag = menuTag;
} }
public StringSingleChoiceSetting(AbstractStringSetting setting, int titleId, public StringSingleChoiceSetting(Context context, AbstractStringSetting setting, int titleId,
int descriptionId, String[] choicesId, String[] valuesId) int descriptionId, String[] choicesId, String[] valuesId)
{ {
this(setting, titleId, descriptionId, choicesId, valuesId, null); this(context, setting, titleId, descriptionId, choicesId, valuesId, null);
} }
public StringSingleChoiceSetting(AbstractStringSetting setting, int titleId, public StringSingleChoiceSetting(Context context, AbstractStringSetting setting, int titleId,
int descriptionId, int choicesId, int valuesId, MenuTag menuTag) int descriptionId, int choicesId, int valuesId, MenuTag menuTag)
{ {
super(titleId, descriptionId); super(context, titleId, descriptionId);
mSetting = setting; mSetting = setting;
mChoicesId = DolphinApplication.getAppContext().getResources().getStringArray(choicesId); mChoicesId = DolphinApplication.getAppContext().getResources().getStringArray(choicesId);
mValuesId = DolphinApplication.getAppContext().getResources().getStringArray(valuesId); mValuesId = DolphinApplication.getAppContext().getResources().getStringArray(valuesId);
mMenuTag = menuTag; mMenuTag = menuTag;
} }
public StringSingleChoiceSetting(AbstractStringSetting setting, int titleId, public StringSingleChoiceSetting(Context context, AbstractStringSetting setting, int titleId,
int descriptionId, int choicesId, int valuesId) int descriptionId, int choicesId, int valuesId)
{ {
this(setting, titleId, descriptionId, choicesId, valuesId, null); this(context, setting, titleId, descriptionId, choicesId, valuesId, null);
} }
public String[] getChoicesId() public String[] getChoicesId()

View File

@ -1,5 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model.view; package org.dolphinemu.dolphinemu.features.settings.model.view;
import android.content.Context;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag; import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
@ -7,9 +9,9 @@ public final class SubmenuSetting extends SettingsItem
{ {
private MenuTag mMenuKey; private MenuTag mMenuKey;
public SubmenuSetting(int titleId, MenuTag menuKey) public SubmenuSetting(Context context, int titleId, MenuTag menuKey)
{ {
super(titleId, 0); super(context, titleId, 0);
mMenuKey = menuKey; mMenuKey = menuKey;
} }

View File

@ -194,7 +194,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity(), AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity(),
R.style.DolphinDialogBase); R.style.DolphinDialogBase);
builder.setTitle(item.getNameId()); builder.setTitle(item.getName());
builder.setSingleChoiceItems(item.getChoicesId(), value, this); builder.setSingleChoiceItems(item.getChoicesId(), value, this);
mDialog = builder.show(); mDialog = builder.show();
@ -208,7 +208,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity(), AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity(),
R.style.DolphinDialogBase); R.style.DolphinDialogBase);
builder.setTitle(item.getNameId()); builder.setTitle(item.getName());
builder.setSingleChoiceItems(item.getChoicesId(), item.getSelectValueIndex(getSettings()), builder.setSingleChoiceItems(item.getChoicesId(), item.getSelectValueIndex(getSettings()),
this); this);
@ -226,7 +226,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity(), AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity(),
R.style.DolphinDialogBase); R.style.DolphinDialogBase);
builder.setTitle(item.getNameId()); builder.setTitle(item.getName());
builder.setSingleChoiceItems(item.getChoicesId(), value, this); builder.setSingleChoiceItems(item.getChoicesId(), value, this);
mDialog = builder.show(); mDialog = builder.show();
@ -244,7 +244,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
LayoutInflater inflater = LayoutInflater.from(mView.getActivity()); LayoutInflater inflater = LayoutInflater.from(mView.getActivity());
View view = inflater.inflate(R.layout.dialog_seekbar, null); View view = inflater.inflate(R.layout.dialog_seekbar, null);
builder.setTitle(item.getNameId()); builder.setTitle(item.getName());
builder.setView(view); builder.setView(view);
builder.setPositiveButton(R.string.ok, this); builder.setPositiveButton(R.string.ok, this);
mDialog = builder.show(); mDialog = builder.show();
@ -279,7 +279,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
dialog.setMessage(String.format(mContext.getString( dialog.setMessage(String.format(mContext.getString(
item instanceof RumbleBindingSetting ? item instanceof RumbleBindingSetting ?
R.string.input_rumble_description : R.string.input_binding_description), R.string.input_rumble_description : R.string.input_binding_description),
mContext.getString(item.getNameId()))); item.getName()));
dialog.setButton(AlertDialog.BUTTON_NEGATIVE, mContext.getString(R.string.cancel), this); dialog.setButton(AlertDialog.BUTTON_NEGATIVE, mContext.getString(R.string.cancel), this);
dialog.setButton(AlertDialog.BUTTON_NEUTRAL, mContext.getString(R.string.clear), dialog.setButton(AlertDialog.BUTTON_NEUTRAL, mContext.getString(R.string.clear),
(dialogInterface, i) -> item.clearValue(getSettings())); (dialogInterface, i) -> item.clearValue(getSettings()));

View File

@ -26,7 +26,7 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
private static final String ARGUMENT_MENU_TAG = "menu_tag"; private static final String ARGUMENT_MENU_TAG = "menu_tag";
private static final String ARGUMENT_GAME_ID = "game_id"; private static final String ARGUMENT_GAME_ID = "game_id";
private SettingsFragmentPresenter mPresenter = new SettingsFragmentPresenter(this); private SettingsFragmentPresenter mPresenter;
private SettingsActivityView mActivity; private SettingsActivityView mActivity;
private SettingsAdapter mAdapter; private SettingsAdapter mAdapter;
@ -102,7 +102,8 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
MenuTag menuTag = (MenuTag) args.getSerializable(ARGUMENT_MENU_TAG); MenuTag menuTag = (MenuTag) args.getSerializable(ARGUMENT_MENU_TAG);
String gameId = getArguments().getString(ARGUMENT_GAME_ID); String gameId = getArguments().getString(ARGUMENT_GAME_ID);
mAdapter = new SettingsAdapter(this, getActivity()); mPresenter = new SettingsFragmentPresenter(this, getContext());
mAdapter = new SettingsAdapter(this, getContext());
mPresenter.onCreate(menuTag, gameId, args); mPresenter.onCreate(menuTag, gameId, args);
} }

View File

@ -1,5 +1,6 @@
package org.dolphinemu.dolphinemu.features.settings.ui.viewholder; package org.dolphinemu.dolphinemu.features.settings.ui.viewholder;
import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.TextView; import android.widget.TextView;
@ -41,24 +42,17 @@ public final class CheckBoxSettingViewHolder extends SettingViewHolder
mItem = (CheckBoxSetting) item; mItem = (CheckBoxSetting) item;
// Special case for LogTypes retrieved via JNI since those aren't string references. // Special case for LogTypes retrieved via JNI since those aren't string references.
if (item.getNameId() == 0 && item instanceof LogCheckBoxSetting) if (TextUtils.isEmpty(item.getName()) && item instanceof LogCheckBoxSetting)
{ {
String key = ((LogCheckBoxSetting) item).getKey(); String key = ((LogCheckBoxSetting) item).getKey();
mTextSettingName.setText(SettingsFragmentPresenter.LOG_TYPE_NAMES.get(key)); mTextSettingName.setText(SettingsFragmentPresenter.LOG_TYPE_NAMES.get(key));
} }
else else
{ {
mTextSettingName.setText(item.getNameId()); mTextSettingName.setText(item.getName());
} }
if (item.getDescriptionId() > 0) mTextSettingDescription.setText(item.getDescription());
{
mTextSettingDescription.setText(item.getDescriptionId());
}
else
{
mTextSettingDescription.setText("");
}
mCheckbox.setChecked(mItem.isChecked(getAdapter().getSettings())); mCheckbox.setChecked(mItem.isChecked(getAdapter().getSettings()));

View File

@ -56,11 +56,11 @@ public final class FilePickerViewHolder extends SettingViewHolder
itemView.setBackgroundResource(R.drawable.invalid_setting_background); itemView.setBackgroundResource(R.drawable.invalid_setting_background);
} }
mTextSettingName.setText(item.getNameId()); mTextSettingName.setText(item.getName());
if (item.getDescriptionId() > 0) if (!TextUtils.isEmpty(item.getDescription()))
{ {
mTextSettingDescription.setText(item.getDescriptionId()); mTextSettingDescription.setText(item.getDescription());
} }
else else
{ {

View File

@ -28,7 +28,7 @@ public final class HeaderViewHolder extends SettingViewHolder
@Override @Override
public void bind(SettingsItem item) public void bind(SettingsItem item)
{ {
mHeaderName.setText(item.getNameId()); mHeaderName.setText(item.getName());
} }
@Override @Override

View File

@ -43,7 +43,7 @@ public final class InputBindingSettingViewHolder extends SettingViewHolder
mItem = (InputBindingSetting) item; mItem = (InputBindingSetting) item;
mTextSettingName.setText(mItem.getNameId()); mTextSettingName.setText(mItem.getName());
mTextSettingDescription mTextSettingDescription
.setText(sharedPreferences.getString(mItem.getKey() + mItem.getGameId(), "")); .setText(sharedPreferences.getString(mItem.getKey() + mItem.getGameId(), ""));

View File

@ -43,7 +43,7 @@ public class RumbleBindingViewHolder extends SettingViewHolder
mItem = (RumbleBindingSetting) item; mItem = (RumbleBindingSetting) item;
mTextSettingName.setText(item.getNameId()); mTextSettingName.setText(item.getName());
mTextSettingDescription mTextSettingDescription
.setText(sharedPreferences.getString(mItem.getKey() + mItem.getGameId(), "")); .setText(sharedPreferences.getString(mItem.getKey() + mItem.getGameId(), ""));

View File

@ -41,12 +41,8 @@ public final class RunRunnableViewHolder extends SettingViewHolder
{ {
mItem = (RunRunnable) item; mItem = (RunRunnable) item;
mTextSettingName.setText(item.getNameId()); mTextSettingName.setText(item.getName());
mTextSettingDescription.setText(item.getDescription());
if (item.getDescriptionId() > 0)
{
mTextSettingDescription.setText(item.getDescriptionId());
}
} }
@Override @Override
@ -57,7 +53,7 @@ public final class RunRunnableViewHolder extends SettingViewHolder
if (alertTextID > 0) if (alertTextID > 0)
{ {
AlertDialog.Builder builder = new AlertDialog.Builder(mContext, R.style.DolphinDialogBase) AlertDialog.Builder builder = new AlertDialog.Builder(mContext, R.style.DolphinDialogBase)
.setTitle(mItem.getNameId()) .setTitle(mItem.getName())
.setMessage(alertTextID); .setMessage(alertTextID);
builder builder

View File

@ -1,6 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.ui.viewholder; package org.dolphinemu.dolphinemu.features.settings.ui.viewholder;
import android.content.res.Resources; import android.content.res.Resources;
import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
@ -37,11 +38,11 @@ public final class SingleChoiceViewHolder extends SettingViewHolder
{ {
mItem = item; mItem = item;
mTextSettingName.setText(item.getNameId()); mTextSettingName.setText(item.getName());
if (item.getDescriptionId() > 0) if (!TextUtils.isEmpty(item.getDescription()))
{ {
mTextSettingDescription.setText(item.getDescriptionId()); mTextSettingDescription.setText(item.getDescription());
} }
else if (item instanceof SingleChoiceSetting) else if (item instanceof SingleChoiceSetting)
{ {

View File

@ -1,6 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.ui.viewholder; package org.dolphinemu.dolphinemu.features.settings.ui.viewholder;
import android.content.Context; import android.content.Context;
import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
@ -39,11 +40,11 @@ public final class SliderViewHolder extends SettingViewHolder
{ {
mItem = (SliderSetting) item; mItem = (SliderSetting) item;
mTextSettingName.setText(item.getNameId()); mTextSettingName.setText(item.getName());
if (item.getDescriptionId() > 0) if (!TextUtils.isEmpty(item.getDescription()))
{ {
mTextSettingDescription.setText(item.getDescriptionId()); mTextSettingDescription.setText(item.getDescription());
} }
else else
{ {

View File

@ -32,7 +32,7 @@ public final class SubmenuViewHolder extends SettingViewHolder
{ {
mItem = (SubmenuSetting) item; mItem = (SubmenuSetting) item;
mTextSettingName.setText(item.getNameId()); mTextSettingName.setText(item.getName());
} }
@Override @Override