diff options
| author | JosJuice <josjuice@gmail.com> | 2019-07-13 18:05:04 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-13 18:05:04 +0200 |
| commit | 533f6bfeb9a0c624d7837d0ce8daaac586e21233 (patch) | |
| tree | 79c61a68072dd6f4ef06f6e714cb684a4a68704c /Source/Android/app/src/main/java | |
| parent | 2f5e6cfff16bc9c6eff5800a009d23c1b98078ca (diff) | |
| parent | 36166c9b4f7e72b5f9e9a00cb1326a442a4a171e (diff) | |
Merge pull request #8203 from JosJuice/android-no-copy-to-gameini
Android: Don't copy global INIs into game INIs
Diffstat (limited to 'Source/Android/app/src/main/java')
6 files changed, 70 insertions, 15 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java index b901f2f691..174d2d1ff2 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java @@ -253,6 +253,8 @@ public final class NativeLibrary Rumble.checkRumble(padID, state); } + public static native void NewGameIniFile(); + public static native void LoadGameIniFile(String gameId); public static native void SaveGameIniFile(String gameId); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/Settings.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/Settings.java index d76d9ec688..ca34fc575b 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/Settings.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/Settings.java @@ -97,31 +97,22 @@ public class Settings { sections = new Settings.SettingsSectionMap(); - HashSet<String> filesToExclude = new HashSet<>(); - if (!TextUtils.isEmpty(gameId)) + if (TextUtils.isEmpty(gameId)) { - // for per-game settings, don't load the WiiMoteNew.ini settings - filesToExclude.add(SettingsFile.FILE_NAME_WIIMOTE); + loadDolphinSettings(view); } - - loadDolphinSettings(view, filesToExclude); - - if (!TextUtils.isEmpty(gameId)) + else { - loadGenericGameSettings(gameId, view); loadCustomGameSettings(gameId, view); } } - private void loadDolphinSettings(SettingsActivityView view, HashSet<String> filesToExclude) + private void loadDolphinSettings(SettingsActivityView view) { for (Map.Entry<String, List<String>> entry : configFileSectionsMap.entrySet()) { String fileName = entry.getKey(); - if (filesToExclude == null || !filesToExclude.contains(fileName)) - { - sections.putAll(SettingsFile.readFile(fileName, view)); - } + sections.putAll(SettingsFile.readFile(fileName, view)); } } @@ -192,4 +183,36 @@ public class Settings SettingsFile.saveCustomGameSettings(gameId, sections); } } + + public void clearSettings() + { + sections.clear(); + } + + public boolean gameIniContainsJunk() + { + // Older versions of Android Dolphin would copy the entire contents of most of the global INIs + // into any game INI that got saved (with some of the sections renamed to match the game INI + // section names). The problems with this are twofold: + // + // 1. The user game INIs will contain entries that Dolphin doesn't support reading from + // game INIs. This is annoying when editing game INIs manually but shouldn't really be + // a problem for those who only use the GUI. + // + // 2. Global settings will stick around in user game INIs. For instance, if someone wants to + // change the texture cache accuracy to safe for all games, they have to edit not only the + // global settings but also every single game INI they have created, since the old value of + // the texture cache accuracy setting has been copied into every user game INI. + // + // These problems are serious enough that we should detect and delete such INI files. + // Problem 1 is easy to detect, but due to the nature of problem 2, it's unfortunately not + // possible to know which lines were added intentionally by the user and which lines were added + // unintentionally, which is why we have to delete the whole file in order to fix everything. + + if (TextUtils.isEmpty(gameId)) + return false; + + SettingSection interfaceSection = sections.get("Interface"); + return interfaceSection != null && interfaceSection.getSetting("ThemeName") != null; + } } 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 78b8ef2d1f..56b407cb82 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 @@ -1,5 +1,6 @@ package org.dolphinemu.dolphinemu.features.settings.ui; +import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; @@ -185,6 +186,18 @@ public final class SettingsActivity extends AppCompatActivity implements Setting } @Override + public void showGameIniJunkDeletionQuestion() + { + new AlertDialog.Builder(this) + .setTitle(getString(R.string.game_ini_junk_title)) + .setMessage(getString(R.string.game_ini_junk_question)) + .setPositiveButton(R.string.yes, (dialogInterface, i) -> mPresenter.clearSettings()) + .setNegativeButton(R.string.no, null) + .create() + .show(); + } + + @Override public org.dolphinemu.dolphinemu.features.settings.model.Settings getSettings() { return mPresenter.getSettings(); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java index 57bbe9d6cc..21115e464d 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java @@ -58,6 +58,11 @@ public final class SettingsActivityPresenter if (!TextUtils.isEmpty(gameId)) { mSettings.loadSettings(gameId, mView); + + if (mSettings.gameIniContainsJunk()) + { + mView.showGameIniJunkDeletionQuestion(); + } } else { @@ -118,6 +123,12 @@ public final class SettingsActivityPresenter return mSettings; } + public void clearSettings() + { + mSettings.clearSettings(); + onSettingChanged(); + } + public void onStop(boolean finishing) { if (directoryStateReceiver != null) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityView.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityView.java index 910c9f0014..71583aa989 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityView.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityView.java @@ -120,6 +120,11 @@ public interface SettingsActivityView void showExternalStorageNotMountedHint(); /** + * Tell the user that there is junk in the game INI and ask if they want to delete the whole file. + */ + void showGameIniJunkDeletionQuestion(); + + /** * Start the DirectoryInitialization and listen for the result. * * @param receiver the broadcast receiver for the DirectoryInitialization diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java index 7ba9bcfd38..54640a3710 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java @@ -452,7 +452,8 @@ public final class SettingsFile final HashMap<String, SettingSection> sections) { Set<String> sortedSections = new TreeSet<>(sections.keySet()); - NativeLibrary.LoadGameIniFile(gameId); + + NativeLibrary.NewGameIniFile(); for (String sectionKey : sortedSections) { SettingSection section = sections.get(sectionKey); |
