Android: Show warning when using old pre-defined controller INIs
Co-authored-by: Charles Lombardo <clombardo169@gmail.com>
This commit is contained in:
parent
8b78f73e80
commit
7ef229d908
|
@ -9,6 +9,7 @@ import android.os.Bundle;
|
|||
import android.provider.Settings;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -339,7 +340,7 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
|
|||
|
||||
public void setToolbarTitle(String title)
|
||||
{
|
||||
mToolbarLayout.setTitle(title);
|
||||
mBinding.toolbarSettingsLayout.setTitle(title);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -354,6 +355,14 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
|
|||
return mMappingAllDevices;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setOldControllerSettingsWarningVisibility(boolean visible)
|
||||
{
|
||||
// We use INVISIBLE instead of GONE to avoid getting a stale height for the return value
|
||||
mBinding.oldControllerSettingsWarning.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
|
||||
return visible ? mBinding.oldControllerSettingsWarning.getHeight() : 0;
|
||||
}
|
||||
|
||||
private void setInsets()
|
||||
{
|
||||
ViewCompat.setOnApplyWindowInsetsListener(mBinding.appbarSettings, (v, windowInsets) ->
|
||||
|
@ -364,6 +373,10 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
|
|||
|
||||
mBinding.frameContentSettings.setPadding(insets.left, 0, insets.right, 0);
|
||||
|
||||
int textPadding = getResources().getDimensionPixelSize(R.dimen.spacing_large);
|
||||
mBinding.oldControllerSettingsWarning.setPadding(textPadding + insets.left, textPadding,
|
||||
textPadding + insets.right, textPadding + insets.bottom);
|
||||
|
||||
InsetsHelper.applyNavbarWorkaround(insets.bottom, mBinding.workaroundView);
|
||||
ThemeHelper.setNavigationBarColor(this,
|
||||
MaterialColors.getColor(mBinding.appbarSettings, R.attr.colorSurface));
|
||||
|
|
|
@ -109,4 +109,13 @@ public interface SettingsActivityView
|
|||
* not just the device configured for the controller.
|
||||
*/
|
||||
boolean isMappingAllDevices();
|
||||
|
||||
/**
|
||||
* Shows or hides a warning telling the user that they're using incompatible controller settings.
|
||||
* The warning is hidden by default.
|
||||
*
|
||||
* @param visible Whether the warning should be visible.
|
||||
* @return The height of the warning view, or 0 if the view is now invisible.
|
||||
*/
|
||||
int setOldControllerSettingsWarningVisibility(boolean visible);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
|
|||
|
||||
private SettingsAdapter mAdapter;
|
||||
|
||||
private int mOldControllerSettingsWarningHeight = 0;
|
||||
|
||||
private static final Map<MenuTag, Integer> titles = new HashMap<>();
|
||||
|
||||
static
|
||||
|
@ -260,13 +262,23 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
|
|||
return mActivity.isMappingAllDevices();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOldControllerSettingsWarningVisibility(boolean visible)
|
||||
{
|
||||
mOldControllerSettingsWarningHeight =
|
||||
mActivity.setOldControllerSettingsWarningVisibility(visible);
|
||||
|
||||
// Trigger the insets listener we've registered
|
||||
mBinding.listSettings.requestApplyInsets();
|
||||
}
|
||||
|
||||
private void setInsets()
|
||||
{
|
||||
ViewCompat.setOnApplyWindowInsetsListener(mBinding.listSettings, (v, windowInsets) ->
|
||||
{
|
||||
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
v.setPadding(0, 0, 0,
|
||||
insets.bottom + getResources().getDimensionPixelSize(R.dimen.spacing_list));
|
||||
int listSpacing = getResources().getDimensionPixelSize(R.dimen.spacing_list);
|
||||
v.setPadding(0, 0, 0, insets.bottom + listSpacing + mOldControllerSettingsWarningHeight);
|
||||
return windowInsets;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ public final class SettingsFragmentPresenter
|
|||
|
||||
private Settings mSettings;
|
||||
private ArrayList<SettingsItem> mSettingsList;
|
||||
private boolean mHasOldControllerSettings = false;
|
||||
|
||||
private int mSerialPort1Type;
|
||||
private int mControllerNumber;
|
||||
|
@ -144,6 +145,7 @@ public final class SettingsFragmentPresenter
|
|||
else
|
||||
{
|
||||
mView.showSettingsList(mSettingsList);
|
||||
mView.setOldControllerSettingsWarningVisibility(mHasOldControllerSettings);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1220,6 +1222,8 @@ public final class SettingsFragmentPresenter
|
|||
|
||||
sl.add(new RunRunnable(mContext, R.string.input_clear, R.string.input_clear_description,
|
||||
R.string.input_reset_warning, 0, true, () -> clearControllerSettings(controller)));
|
||||
|
||||
updateOldControllerSettingsWarningVisibility(controller);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1232,6 +1236,8 @@ public final class SettingsFragmentPresenter
|
|||
private void addControllerMappingSettings(ArrayList<SettingsItem> sl,
|
||||
EmulatedController controller, Set<Integer> groupTypeFilter)
|
||||
{
|
||||
updateOldControllerSettingsWarningVisibility(controller);
|
||||
|
||||
int groupCount = controller.getGroupCount();
|
||||
for (int i = 0; i < groupCount; i++)
|
||||
{
|
||||
|
@ -1287,16 +1293,28 @@ public final class SettingsFragmentPresenter
|
|||
}
|
||||
}
|
||||
|
||||
private void updateOldControllerSettingsWarningVisibility(EmulatedController controller)
|
||||
{
|
||||
String defaultDevice = controller.getDefaultDevice();
|
||||
|
||||
mHasOldControllerSettings = defaultDevice.startsWith("Android/") &&
|
||||
defaultDevice.endsWith("/Touchscreen");
|
||||
|
||||
mView.setOldControllerSettingsWarningVisibility(mHasOldControllerSettings);
|
||||
}
|
||||
|
||||
private void loadDefaultControllerSettings(EmulatedController controller)
|
||||
{
|
||||
controller.loadDefaultSettings();
|
||||
mView.getAdapter().notifyAllSettingsChanged();
|
||||
updateOldControllerSettingsWarningVisibility(controller);
|
||||
}
|
||||
|
||||
private void clearControllerSettings(EmulatedController controller)
|
||||
{
|
||||
controller.clearSettings();
|
||||
mView.getAdapter().notifyAllSettingsChanged();
|
||||
updateOldControllerSettingsWarningVisibility(controller);
|
||||
}
|
||||
|
||||
private static int getLogVerbosityEntries()
|
||||
|
|
|
@ -101,4 +101,12 @@ public interface SettingsFragmentView
|
|||
* not just the device configured for the controller.
|
||||
*/
|
||||
boolean isMappingAllDevices();
|
||||
|
||||
/**
|
||||
* Shows or hides a warning telling the user that they're using incompatible controller settings.
|
||||
* The warning is hidden by default.
|
||||
*
|
||||
* @param visible Whether the warning should be visible.
|
||||
*/
|
||||
void setOldControllerSettingsWarningVisibility(boolean visible);
|
||||
}
|
||||
|
|
|
@ -39,6 +39,18 @@
|
|||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/old_controller_settings_warning"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="?attr/colorErrorContainer"
|
||||
android:text="@string/old_controller_settings"
|
||||
android:textColor="?attr/colorOnErrorContainer"
|
||||
android:visibility="invisible"
|
||||
android:clickable="true"
|
||||
android:focusable="false" />
|
||||
|
||||
<View
|
||||
android:id="@+id/workaround_view"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
<string name="input_clear">Clear</string>
|
||||
<string name="input_clear_description">Clear settings for this controller.</string>
|
||||
<string name="input_reset_warning">Are you sure? Your current controller settings will be deleted.</string>
|
||||
<string name="old_controller_settings">Your controller settings are from an old version of Dolphin and won\'t work in this version. Press \"Default\" to start over with new settings.</string>
|
||||
|
||||
<string name="input_binding">Input Binding</string>
|
||||
<string name="input_binding_description">Press or move an input to bind it to %1$s.</string>
|
||||
|
|
Loading…
Reference in New Issue