Skip to content

Commit

Permalink
Merge pull request dolphin-emu#10981 from JosJuice/android-string-sin…
Browse files Browse the repository at this point in the history
…gle-choice-naming

Android: Clean up StringSingleChoiceSetting naming
  • Loading branch information
lioncash authored Aug 18, 2022
2 parents 63638d4 + 46cb106 commit fea552a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,33 @@ public class StringSingleChoiceSetting extends SettingsItem
{
private AbstractStringSetting mSetting;

private String[] mChoicesId;
private String[] mValuesId;
private String[] mChoices;
private String[] mValues;
private MenuTag mMenuTag;

public StringSingleChoiceSetting(Context context, AbstractStringSetting setting, int titleId,
int descriptionId, String[] choicesId, String[] valuesId, MenuTag menuTag)
int descriptionId, String[] choices, String[] values, MenuTag menuTag)
{
super(context, titleId, descriptionId);
mSetting = setting;
mChoicesId = choicesId;
mValuesId = valuesId;
mChoices = choices;
mValues = values;
mMenuTag = menuTag;
}

public StringSingleChoiceSetting(Context context, AbstractStringSetting setting, int titleId,
int descriptionId, String[] choicesId, String[] valuesId)
int descriptionId, String[] choices, String[] values)
{
this(context, setting, titleId, descriptionId, choicesId, valuesId, null);
this(context, setting, titleId, descriptionId, choices, values, null);
}

public StringSingleChoiceSetting(Context context, AbstractStringSetting setting, int titleId,
int descriptionId, int choicesId, int valuesId, MenuTag menuTag)
{
super(context, titleId, descriptionId);
mSetting = setting;
mChoicesId = DolphinApplication.getAppContext().getResources().getStringArray(choicesId);
mValuesId = DolphinApplication.getAppContext().getResources().getStringArray(valuesId);
mChoices = DolphinApplication.getAppContext().getResources().getStringArray(choicesId);
mValues = DolphinApplication.getAppContext().getResources().getStringArray(valuesId);
mMenuTag = menuTag;
}

Expand All @@ -50,24 +50,24 @@ public StringSingleChoiceSetting(Context context, AbstractStringSetting setting,
this(context, setting, titleId, descriptionId, choicesId, valuesId, null);
}

public String[] getChoicesId()
public String[] getChoices()
{
return mChoicesId;
return mChoices;
}

public String[] getValuesId()
public String[] getValues()
{
return mValuesId;
return mValues;
}

public String getValueAt(int index)
{
if (mValuesId == null)
if (mValues == null)
return null;

if (index >= 0 && index < mValuesId.length)
if (index >= 0 && index < mValues.length)
{
return mValuesId[index];
return mValues[index];
}

return "";
Expand All @@ -78,12 +78,12 @@ public String getSelectedValue(Settings settings)
return mSetting.getString(settings);
}

public int getSelectValueIndex(Settings settings)
public int getSelectedValueIndex(Settings settings)
{
String selectedValue = getSelectedValue(settings);
for (int i = 0; i < mValuesId.length; i++)
for (int i = 0; i < mValues.length; i++)
{
if (mValuesId[i].equals(selectedValue))
if (mValues[i].equals(selectedValue))
{
return i;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public void onStringSingleChoiceClick(StringSingleChoiceSetting item, int positi
AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity());

builder.setTitle(item.getName());
builder.setSingleChoiceItems(item.getChoicesId(), item.getSelectValueIndex(getSettings()),
builder.setSingleChoiceItems(item.getChoices(), item.getSelectedValueIndex(getSettings()),
this);

mDialog = builder.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ else if (item instanceof SingleChoiceSetting)
else if (item instanceof StringSingleChoiceSetting)
{
StringSingleChoiceSetting setting = (StringSingleChoiceSetting) item;
String[] choices = setting.getChoicesId();
int valueIndex = setting.getSelectValueIndex(getAdapter().getSettings());
String[] choices = setting.getChoices();
int valueIndex = setting.getSelectedValueIndex(getAdapter().getSettings());
if (valueIndex != -1)
mTextSettingDescription.setText(choices[valueIndex]);
}
Expand Down

0 comments on commit fea552a

Please sign in to comment.