Skip to content
Permalink
Browse files

Merge pull request #7591 from weihuoya/setting-desc

Android: show setting value as description
  • Loading branch information...
JMC47 committed Jan 2, 2019
2 parents b235121 + 6314633 commit aac17bf0d8675cb0572e5182945d1de9bd0487e7
@@ -48,6 +48,7 @@
private ArrayList<SettingsItem> mSettings;

private SettingsItem mClickedItem;
private int mClickedPosition;
private int mSeekbarProgress;

private AlertDialog mDialog;
@@ -57,6 +58,7 @@ public SettingsAdapter(SettingsFragmentView view, Context context)
{
mView = view;
mContext = context;
mClickedPosition = -1;
}

@Override
@@ -157,9 +159,10 @@ public void onBooleanClick(CheckBoxSetting item, int position, boolean checked)
mView.onSettingChanged();
}

public void onSingleChoiceClick(SingleChoiceSetting item)
public void onSingleChoiceClick(SingleChoiceSetting item, int position)
{
mClickedItem = item;
mClickedPosition = position;

int value = getSelectionForSingleChoiceValue(item);

@@ -171,9 +174,10 @@ public void onSingleChoiceClick(SingleChoiceSetting item)
mDialog = builder.show();
}

public void onStringSingleChoiceClick(StringSingleChoiceSetting item)
public void onStringSingleChoiceClick(StringSingleChoiceSetting item, int position)
{
mClickedItem = item;
mClickedPosition = position;

AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity());

@@ -183,9 +187,10 @@ public void onStringSingleChoiceClick(StringSingleChoiceSetting item)
mDialog = builder.show();
}

public void onSliderClick(SliderSetting item)
public void onSliderClick(SliderSetting item, int position)
{
mClickedItem = item;
mClickedPosition = position;
mSeekbarProgress = item.getSelectedValue();
AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity());

@@ -195,7 +200,6 @@ public void onSliderClick(SliderSetting item)
builder.setTitle(item.getNameId());
builder.setView(view);
builder.setPositiveButton(R.string.ok, this);
builder.setNegativeButton(R.string.cancel, this);
mDialog = builder.show();

mTextSliderValue = (TextView) view.findViewById(R.id.text_value);
@@ -347,6 +351,8 @@ else if (mClickedItem instanceof SliderSetting)
mView.putSetting(setting);
}
}

closeDialog();
}

mView.onSettingChanged();
@@ -358,6 +364,11 @@ public void closeDialog()
{
if (mDialog != null)
{
if (mClickedPosition != -1)
{
notifyItemChanged(mClickedPosition);
mClickedPosition = -1;
}
mDialog.dismiss();
mDialog = null;
}
@@ -404,7 +404,7 @@ private void addGraphicsSettings(ArrayList<SettingsItem> sl)

sl.add(new HeaderSetting(null, null, R.string.graphics_general, 0));
sl.add(new SingleChoiceSetting(SettingsFile.KEY_VIDEO_BACKEND_INDEX, Settings.SECTION_INI_CORE,
R.string.video_backend, R.string.video_backend_description, R.array.videoBackendEntries,
R.string.video_backend, 0, R.array.videoBackendEntries,
R.array.videoBackendValues, 0, videoBackend));
sl.add(new CheckBoxSetting(SettingsFile.KEY_SHOW_FPS, Settings.SECTION_GFX_SETTINGS,
R.string.show_fps, R.string.show_fps_description, false, showFps));
@@ -466,7 +466,7 @@ private void addEnhanceSettings(ArrayList<SettingsItem> sl)
shaderListValues[0] = "";
sl.add(new StringSingleChoiceSetting(SettingsFile.KEY_POST_SHADER,
Settings.SECTION_GFX_ENHANCEMENTS, R.string.post_processing_shader,
R.string.post_processing_shader_description, shaderListEntries, shaderListValues, "",
0, shaderListEntries, shaderListValues, "",
shader));

sl.add(new CheckBoxSetting(SettingsFile.KEY_SCALED_EFB, Settings.SECTION_GFX_HACKS,
@@ -493,11 +493,11 @@ private void addEnhanceSettings(ArrayList<SettingsItem> sl)
R.string.wide_screen_hack, R.string.wide_screen_hack_description, false,
wideScreenHack));

/*
Check if we support stereo
If we support desktop GL then we must support at least OpenGL 3.2
If we only support OpenGLES then we need both OpenGLES 3.1 and AEP
*/
/*
Check if we support stereo
If we support desktop GL then we must support at least OpenGL 3.2
If we only support OpenGLES then we need both OpenGLES 3.1 and AEP
*/
EGLHelper helper = new EGLHelper(EGLHelper.EGL_OPENGL_ES2_BIT);

if ((helper.supportsOpenGL() && helper.GetVersion() >= 320) ||
@@ -815,7 +815,7 @@ private void addWiimoteSubSettings(ArrayList<SettingsItem> sl, int wiimoteNumber
MenuTag.getWiimoteExtensionMenuTag(wiimoteNumber));
sl.add(new SingleChoiceSetting(SettingsFile.KEY_WIIMOTE_EXTENSION,
Settings.SECTION_WIIMOTE + (wiimoteNumber - 3), R.string.wiimote_extensions,
R.string.wiimote_extensions_description, R.array.wiimoteExtensionsEntries,
0, R.array.wiimoteExtensionsEntries,
R.array.wiimoteExtensionsValues, 0, extension,
MenuTag.getWiimoteExtensionMenuTag(wiimoteNumber)));
}
@@ -827,7 +827,7 @@ private void addWiimoteSubSettings(ArrayList<SettingsItem> sl, int wiimoteNumber
MenuTag.getWiimoteExtensionMenuTag(wiimoteNumber));
sl.add(new SingleChoiceSetting(SettingsFile.KEY_WIIMOTE_EXTENSION + (wiimoteNumber - 4),
Settings.SECTION_CONTROLS, R.string.wiimote_extensions,
R.string.wiimote_extensions_description, R.array.wiimoteExtensionsEntries,
0, R.array.wiimoteExtensionsEntries,
R.array.wiimoteExtensionsValues, 0, extension,
MenuTag.getWiimoteExtensionMenuTag(wiimoteNumber)));
}
@@ -1,5 +1,6 @@
package org.dolphinemu.dolphinemu.features.settings.ui.viewholder;

import android.content.res.Resources;
import android.view.View;
import android.widget.TextView;

@@ -39,18 +40,42 @@ public void bind(SettingsItem item)
{
mTextSettingDescription.setText(item.getDescriptionId());
}
else if (item instanceof SingleChoiceSetting)
{
SingleChoiceSetting setting = (SingleChoiceSetting) item;
int selected = setting.getSelectedValue();
Resources resMgr = mTextSettingDescription.getContext().getResources();
String[] choices = resMgr.getStringArray(setting.getChoicesId());
int[] values = resMgr.getIntArray(setting.getValuesId());
for (int i = 0; i < values.length; ++i)
{
if (values[i] == selected)
{
mTextSettingDescription.setText(choices[i]);
}
}
}
else if (item instanceof StringSingleChoiceSetting)
{
StringSingleChoiceSetting setting = (StringSingleChoiceSetting) item;
String[] choices = setting.getChoicesId();
int valueIndex = setting.getSelectValueIndex();
if (valueIndex != -1)
mTextSettingDescription.setText(choices[valueIndex]);
}
}

@Override
public void onClick(View clicked)
{
int position = getAdapterPosition();
if (mItem instanceof SingleChoiceSetting)
{
getAdapter().onSingleChoiceClick((SingleChoiceSetting) mItem);
getAdapter().onSingleChoiceClick((SingleChoiceSetting) mItem, position);
}
else if (mItem instanceof StringSingleChoiceSetting)
{
getAdapter().onStringSingleChoiceClick((StringSingleChoiceSetting) mItem);
getAdapter().onStringSingleChoiceClick((StringSingleChoiceSetting) mItem, position);
}
}
}
@@ -38,12 +38,16 @@ public void bind(SettingsItem item)
{
mTextSettingDescription.setText(item.getDescriptionId());
}
else
{
mTextSettingDescription.setText(mItem.getSelectedValue() + mItem.getUnits());
}
}

@Override
public void onClick(View clicked)
{
getAdapter().onSliderClick(mItem);
getAdapter().onSliderClick(mItem, getAdapterPosition());
}
}

0 comments on commit aac17bf

Please sign in to comment.
You can’t perform that action at this time.