Merge pull request #7591 from weihuoya/setting-desc

Android: show setting value as description
This commit is contained in:
JMC47 2019-01-02 15:09:20 -05:00 committed by GitHub
commit aac17bf0d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 16 deletions

View File

@ -48,6 +48,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
private ArrayList<SettingsItem> mSettings;
private SettingsItem mClickedItem;
private int mClickedPosition;
private int mSeekbarProgress;
private AlertDialog mDialog;
@ -57,6 +58,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
{
mView = view;
mContext = context;
mClickedPosition = -1;
}
@Override
@ -157,9 +159,10 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
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 final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
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 final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
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 final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
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 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
mView.putSetting(setting);
}
}
closeDialog();
}
mView.onSettingChanged();
@ -358,6 +364,11 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
{
if (mDialog != null)
{
if (mClickedPosition != -1)
{
notifyItemChanged(mClickedPosition);
mClickedPosition = -1;
}
mDialog.dismiss();
mDialog = null;
}

View File

@ -404,7 +404,7 @@ public final class SettingsFragmentPresenter
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 @@ public final class SettingsFragmentPresenter
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 @@ public final class SettingsFragmentPresenter
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 @@ public final class SettingsFragmentPresenter
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 @@ public final class SettingsFragmentPresenter
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)));
}

View File

@ -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 final class SingleChoiceViewHolder extends SettingViewHolder
{
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);
}
}
}

View File

@ -38,12 +38,16 @@ public final class SliderViewHolder extends SettingViewHolder
{
mTextSettingDescription.setText(item.getDescriptionId());
}
else
{
mTextSettingDescription.setText(mItem.getSelectedValue() + mItem.getUnits());
}
}
@Override
public void onClick(View clicked)
{
getAdapter().onSliderClick(mItem);
getAdapter().onSliderClick(mItem, getAdapterPosition());
}
}