android: Make adjustScale reflect changes without closing the dialog

This commit is contained in:
FearlessTobi 2020-04-18 06:08:27 +02:00 committed by bunnei
parent 775a4a8fc2
commit 6438c5e6c3

View File

@ -439,6 +439,7 @@ public final class EmulationActivity extends AppCompatActivity {
} }
public void onStopTrackingTouch(SeekBar seekBar) { public void onStopTrackingTouch(SeekBar seekBar) {
setControlScale(seekbar.getProgress());
} }
}); });
@ -448,26 +449,29 @@ public final class EmulationActivity extends AppCompatActivity {
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.emulation_control_scale); builder.setTitle(R.string.emulation_control_scale);
builder.setView(view); builder.setView(view);
final int previousProgress = seekbar.getProgress();
builder.setNegativeButton(android.R.string.cancel, (dialogInterface, i) -> { builder.setNegativeButton(android.R.string.cancel, (dialogInterface, i) -> {
setControlScale(previousProgress);
}); });
builder.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> builder.setPositiveButton(android.R.string.ok, (dialogInterface, i) ->
{ {
SharedPreferences.Editor editor = mPreferences.edit(); setControlScale(seekbar.getProgress());
editor.putInt("controlScale", seekbar.getProgress());
editor.apply();
mEmulationFragment.refreshInputOverlay();
}); });
builder.setNeutralButton(R.string.slider_default, (dialogInterface, i) -> { builder.setNeutralButton(R.string.slider_default, (dialogInterface, i) -> {
SharedPreferences.Editor editor = mPreferences.edit(); setControlScale(50);
editor.putInt("controlScale", 50);
editor.apply();
mEmulationFragment.refreshInputOverlay();
}); });
AlertDialog alertDialog = builder.create(); AlertDialog alertDialog = builder.create();
alertDialog.show(); alertDialog.show();
} }
private void setControlScale(int scale) {
SharedPreferences.Editor editor = mPreferences.edit();
editor.putInt("controlScale", scale);
editor.apply();
mEmulationFragment.refreshInputOverlay();
}
private void resetOverlay() { private void resetOverlay() {
new AlertDialog.Builder(this) new AlertDialog.Builder(this)
.setTitle(getString(R.string.emulation_touch_overlay_reset)) .setTitle(getString(R.string.emulation_touch_overlay_reset))