mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-13 07:58:36 +02:00
Android: Add a button for accessing controller mappings
The settings GameCube Controller N and Wii Remote N (where N is a number) have two purposes: You can select what controller type you want to use, and also, when you select a controller type (even if you're selecting the one that already is selected), the mapping settings open. This second part is less discoverable than it ideally should be. I'm changing it so that there now is a button for opening the mapping settings instead.
This commit is contained in:
parent
f682225c15
commit
8acc39cc3f
@ -467,7 +467,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
||||
}
|
||||
}
|
||||
|
||||
private void handleMenuTag(MenuTag menuTag, int value)
|
||||
public void handleMenuTag(MenuTag menuTag, int value)
|
||||
{
|
||||
if (menuTag != null)
|
||||
{
|
||||
@ -504,8 +504,6 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
||||
if (scSetting.getSelectedValue(getSettings()) != value)
|
||||
mView.onSettingChanged();
|
||||
|
||||
handleMenuTag(scSetting.getMenuTag(), value);
|
||||
|
||||
scSetting.setSelectedValue(getSettings(), value);
|
||||
|
||||
closeDialog();
|
||||
@ -530,8 +528,6 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
||||
if (!scSetting.getSelectedValue(getSettings()).equals(value))
|
||||
mView.onSettingChanged();
|
||||
|
||||
handleMenuTag(scSetting.getMenuTag(), which);
|
||||
|
||||
scSetting.setSelectedValue(getSettings(), value);
|
||||
|
||||
closeDialog();
|
||||
|
@ -10,12 +10,16 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dolphinemu.dolphinemu.databinding.ListItemSettingBinding;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.view.SingleChoiceSetting;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.view.SingleChoiceSettingDynamicDescriptions;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.view.StringSingleChoiceSetting;
|
||||
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
|
||||
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public final class SingleChoiceViewHolder extends SettingViewHolder
|
||||
{
|
||||
private SettingsItem mItem;
|
||||
@ -35,6 +39,9 @@ public final class SingleChoiceViewHolder extends SettingViewHolder
|
||||
|
||||
mBinding.textSettingName.setText(item.getName());
|
||||
|
||||
SettingsAdapter adapter = getAdapter();
|
||||
Settings settings = adapter.getSettings();
|
||||
|
||||
if (!TextUtils.isEmpty(item.getDescription()))
|
||||
{
|
||||
mBinding.textSettingDescription.setText(item.getDescription());
|
||||
@ -42,7 +49,7 @@ public final class SingleChoiceViewHolder extends SettingViewHolder
|
||||
else if (item instanceof SingleChoiceSetting)
|
||||
{
|
||||
SingleChoiceSetting setting = (SingleChoiceSetting) item;
|
||||
int selected = setting.getSelectedValue(getAdapter().getSettings());
|
||||
int selected = setting.getSelectedValue(settings);
|
||||
Resources resMgr = mBinding.textSettingDescription.getContext().getResources();
|
||||
String[] choices = resMgr.getStringArray(setting.getChoicesId());
|
||||
int[] values = resMgr.getIntArray(setting.getValuesId());
|
||||
@ -58,7 +65,7 @@ public final class SingleChoiceViewHolder extends SettingViewHolder
|
||||
{
|
||||
StringSingleChoiceSetting setting = (StringSingleChoiceSetting) item;
|
||||
String[] choices = setting.getChoices();
|
||||
int valueIndex = setting.getSelectedValueIndex(getAdapter().getSettings());
|
||||
int valueIndex = setting.getSelectedValueIndex(settings);
|
||||
if (valueIndex != -1)
|
||||
mBinding.textSettingDescription.setText(choices[valueIndex]);
|
||||
}
|
||||
@ -66,7 +73,7 @@ public final class SingleChoiceViewHolder extends SettingViewHolder
|
||||
{
|
||||
SingleChoiceSettingDynamicDescriptions setting =
|
||||
(SingleChoiceSettingDynamicDescriptions) item;
|
||||
int selected = setting.getSelectedValue(getAdapter().getSettings());
|
||||
int selected = setting.getSelectedValue(settings);
|
||||
Resources resMgr = mBinding.textSettingDescription.getContext().getResources();
|
||||
String[] choices = resMgr.getStringArray(setting.getDescriptionChoicesId());
|
||||
int[] values = resMgr.getIntArray(setting.getDescriptionValuesId());
|
||||
@ -79,6 +86,35 @@ public final class SingleChoiceViewHolder extends SettingViewHolder
|
||||
}
|
||||
}
|
||||
|
||||
MenuTag menuTag = null;
|
||||
Function<Settings, Integer> getSelectedValue = null;
|
||||
if (item instanceof SingleChoiceSetting)
|
||||
{
|
||||
SingleChoiceSetting setting = (SingleChoiceSetting) item;
|
||||
menuTag = setting.getMenuTag();
|
||||
getSelectedValue = setting::getSelectedValue;
|
||||
}
|
||||
else if (item instanceof StringSingleChoiceSetting)
|
||||
{
|
||||
StringSingleChoiceSetting setting = (StringSingleChoiceSetting) item;
|
||||
menuTag = setting.getMenuTag();
|
||||
getSelectedValue = setting::getSelectedValueIndex;
|
||||
}
|
||||
|
||||
if (menuTag != null)
|
||||
{
|
||||
mBinding.buttonMoreSettings.setVisibility(View.VISIBLE);
|
||||
|
||||
final MenuTag finalMenuTag = menuTag;
|
||||
final Function<Settings, Integer> finalGetSelectedValue = getSelectedValue;
|
||||
mBinding.buttonMoreSettings.setOnClickListener((view) ->
|
||||
adapter.handleMenuTag(finalMenuTag, finalGetSelectedValue.apply(settings)));
|
||||
}
|
||||
else
|
||||
{
|
||||
mBinding.buttonMoreSettings.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
setStyle(mBinding.textSettingName, mItem);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout android:id="@+id/root"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:minHeight="72dp"
|
||||
android:nextFocusLeft="@id/button_more_settings">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_setting_name"
|
||||
style="@style/TextAppearance.MaterialComponents.Headline5"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginEnd="@dimen/spacing_large"
|
||||
android:layout_marginStart="@dimen/spacing_large"
|
||||
android:layout_marginTop="@dimen/spacing_large"
|
||||
android:textSize="16sp"
|
||||
android:textAlignment="viewStart"
|
||||
tools:text="Setting Name" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_setting_description"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignStart="@+id/text_setting_name"
|
||||
android:layout_below="@+id/text_setting_name"
|
||||
android:layout_marginBottom="@dimen/spacing_large"
|
||||
android:layout_marginEnd="@dimen/spacing_large"
|
||||
android:layout_marginStart="@dimen/spacing_large"
|
||||
android:layout_marginTop="@dimen/spacing_small"
|
||||
android:textAlignment="viewStart"
|
||||
tools:text="@string/overclock_enable_description" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_more_settings"
|
||||
style="?attr/materialIconButtonStyle"
|
||||
android:contentDescription="@string/more_settings"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="@dimen/spacing_small"
|
||||
android:nextFocusRight="@id/root"
|
||||
android:visibility="gone"
|
||||
app:icon="@drawable/ic_settings"
|
||||
app:iconTint="?attr/colorOnPrimaryContainer" />
|
||||
|
||||
</RelativeLayout>
|
@ -1,13 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
<RelativeLayout android:id="@+id/root"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:minHeight="72dp">
|
||||
android:minHeight="72dp"
|
||||
android:nextFocusRight="@id/button_more_settings">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_setting_name"
|
||||
@ -28,7 +30,6 @@
|
||||
android:id="@+id/text_setting_description"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignStart="@+id/text_setting_name"
|
||||
android:layout_below="@+id/text_setting_name"
|
||||
@ -39,4 +40,18 @@
|
||||
android:textAlignment="viewStart"
|
||||
tools:text="@string/overclock_enable_description" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_more_settings"
|
||||
style="?attr/materialIconButtonStyle"
|
||||
android:contentDescription="@string/more_settings"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="@dimen/spacing_small"
|
||||
android:nextFocusLeft="@id/root"
|
||||
android:visibility="gone"
|
||||
app:icon="@drawable/ic_settings"
|
||||
app:iconTint="?attr/colorOnPrimaryContainer" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
@ -478,6 +478,7 @@
|
||||
<string name="disabled">Disabled</string>
|
||||
<string name="other">Other</string>
|
||||
<string name="continue_anyway">Continue Anyway</string>
|
||||
<string name="more_settings">More Settings</string>
|
||||
|
||||
<!-- Game Grid Screen-->
|
||||
<string name="platform_gamecube">GameCube Games</string>
|
||||
|
Loading…
Reference in New Issue
Block a user