Merge pull request #9698 from JosJuice/android-settings-charsequence

Android: Use CharSequence for SettingsItem name/description
This commit is contained in:
Mat M 2021-05-13 06:40:30 -04:00 committed by GitHub
commit 8d7b0004b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 513 additions and 464 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,17 @@ 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;
}
public CheckBoxSetting(AbstractBooleanSetting setting, CharSequence title,
CharSequence description)
{
super(title, description);
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,10 +9,10 @@ public class LogCheckBoxSetting extends CheckBoxSetting
{ {
String mKey; String mKey;
public LogCheckBoxSetting(String key, int titleId, int descriptionId) public LogCheckBoxSetting(String key, CharSequence title, CharSequence description)
{ {
super(new AdHocBooleanSetting(Settings.FILE_LOGGER, Settings.SECTION_LOGGER_LOGS, key, false), super(new AdHocBooleanSetting(Settings.FILE_LOGGER, Settings.SECTION_LOGGER_LOGS, key, false),
titleId, descriptionId); title, description);
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

@ -176,6 +176,13 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
mView.onSettingChanged(); mView.onSettingChanged();
} }
public void notifyAllSettingsChanged()
{
notifyItemRangeChanged(0, getItemCount());
mView.onSettingChanged();
}
public void onBooleanClick(CheckBoxSetting item, int position, boolean checked) public void onBooleanClick(CheckBoxSetting item, int position, boolean checked)
{ {
item.setChecked(getSettings(), checked); item.setChecked(getSettings(), checked);
@ -194,7 +201,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 +215,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 +233,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 +251,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 +286,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()));
@ -334,20 +341,6 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
mClickedItem = null; mClickedItem = null;
} }
public void setAllLogTypes(boolean value)
{
Settings settings = mView.getSettings();
for (Map.Entry<String, String> entry : SettingsFragmentPresenter.LOG_TYPE_NAMES.entrySet())
{
new AdHocBooleanSetting(Settings.FILE_LOGGER, Settings.SECTION_LOGGER_LOGS, entry.getKey(),
false).setBoolean(settings, value);
}
notifyItemRangeChanged(0, getItemCount());
mView.onSettingChanged();
}
public static void clearLog() public static void clearLog()
{ {
// Don't delete the log in case it is being monitored by another app. // Don't delete the log in case it is being monitored by another app.

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;
@ -40,25 +41,8 @@ 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. mTextSettingName.setText(item.getName());
if (item.getNameId() == 0 && item instanceof LogCheckBoxSetting) mTextSettingDescription.setText(item.getDescription());
{
String key = ((LogCheckBoxSetting) item).getKey();
mTextSettingName.setText(SettingsFragmentPresenter.LOG_TYPE_NAMES.get(key));
}
else
{
mTextSettingName.setText(item.getNameId());
}
if (item.getDescriptionId() > 0)
{
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