Skip to content

Commit

Permalink
Android: Clear preferences linked to WiimoteNew.ini when overwriting
Browse files Browse the repository at this point in the history
Otherwise the preferences can end up in a state that is inconsistent
with WiimoteNew.ini.
  • Loading branch information
JosJuice committed Nov 28, 2019
1 parent b793ee6 commit 7e64bdc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.dolphinemu.dolphinemu.activities;

import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
Expand Down Expand Up @@ -237,6 +238,14 @@ public static void launchFile(FragmentActivity activity, String[] filePaths)
activity.startActivity(launcher);
}

public static void clearWiimoteNewIniLinkedPreferences(Context context)
{
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
editor.remove("wiiController");
editor.remove("motionControlsEnabled");
editor.apply();
}

@Override
protected void onCreate(Bundle savedInstanceState)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import androidx.localbroadcastmanager.content.LocalBroadcastManager;

import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.activities.EmulationActivity;

import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -152,6 +153,7 @@ private static void initializeExternalStorage(Context context)
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (prefs.getInt("WiimoteNewVersion", 0) != WiimoteNewVersion)
{
EmulationActivity.clearWiimoteNewIniLinkedPreferences(context);
copyAsset("WiimoteNew.ini", new File(configDirectory, "WiimoteNew.ini"), true, context);
SharedPreferences.Editor sPrefsEditor = prefs.edit();
sPrefsEditor.putInt("WiimoteNewVersion", WiimoteNewVersion);
Expand Down

0 comments on commit 7e64bdc

Please sign in to comment.