From 00a8f4faaa29984835a21ea9e69f24f6f6ef43a3 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 19 Jul 2020 15:57:27 +0200 Subject: [PATCH] Android: Make FilePicker act like a normal setting The reason why the finish() call was added no longer exists. (Also, there was never a duplicate SettingsActivity as far as I can tell, only a duplicate SettingsFragment.) --- .../features/settings/model/view/FilePicker.java | 5 +++++ .../features/settings/ui/SettingsActivity.java | 14 -------------- .../features/settings/ui/SettingsAdapter.java | 8 +++----- .../ui/viewholder/FilePickerViewHolder.java | 7 +------ 4 files changed, 9 insertions(+), 25 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/FilePicker.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/FilePicker.java index 15b69c5e0d..8a6890d019 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/FilePicker.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/FilePicker.java @@ -20,6 +20,11 @@ public final class FilePicker extends SettingsItem return settings.getSection(getFile(), getSection()).getString(getKey(), mDefaultValue); } + public void setSelectedValue(Settings settings, String selection) + { + settings.getSection(getFile(), getSection()).setString(getKey(), selection); + } + public int getRequestType() { return mRequestType; diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java index 837024c2ab..830f0d5539 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java @@ -171,26 +171,12 @@ public final class SettingsActivity extends AppCompatActivity implements Setting { super.onActivityResult(requestCode, resultCode, result); - // Save modified non-FilePicker settings beforehand since finish() won't save them. - // onStop() must come before handling the resultCode to properly save FilePicker selection. - mPresenter.onStop(true); - // If the user picked a file, as opposed to just backing out. if (resultCode == MainActivity.RESULT_OK) { String path = FileBrowserHelper.getSelectedPath(result); getFragment().getAdapter().onFilePickerConfirmation(path); - - // Prevent duplicate Toasts. - if (!mPresenter.shouldSave()) - { - Toast.makeText(this, "Saved settings to INI files", Toast.LENGTH_SHORT).show(); - } } - - // TODO: After result of FilePicker, duplicate SettingsActivity appears. - // Finish to avoid this. Is there a better method? - finish(); } @Override diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.java index a640c843bf..6daa5b2052 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.java @@ -310,12 +310,10 @@ public final class SettingsAdapter extends RecyclerView.Adapter