diff --git a/Android/res/values/strings.xml b/Android/res/values/strings.xml
index b8927c663..2ee849cc8 100644
--- a/Android/res/values/strings.xml
+++ b/Android/res/values/strings.xml
@@ -141,6 +141,8 @@
Vertical interrupts per second
Reset GFX Plugin
Always reload GFX plugin
+ Reset settings
+ Reset all settings back to their defaults?
- @string/DListPerSecond
diff --git a/Android/src/emu/project64/jni/NativeExports.java b/Android/src/emu/project64/jni/NativeExports.java
index 6fd7f89fd..e7962625d 100644
--- a/Android/src/emu/project64/jni/NativeExports.java
+++ b/Android/src/emu/project64/jni/NativeExports.java
@@ -37,6 +37,7 @@ public class NativeExports
public static native void LoadRomList();
public static native void RefreshRomDir(String RomDir, boolean Recursive);
public static native void ExternalEvent(int Type);
+ public static native void ResetApplicationSettings();
public static native void onSurfaceCreated();
public static native void onSurfaceChanged(int width, int height);
@@ -44,8 +45,10 @@ public class NativeExports
public static native void UISettingsSaveBool(int Type, boolean Value);
public static native void UISettingsSaveDword(int Type, int Value);
+ public static native void UISettingsSaveString(int type, String value);
public static native boolean UISettingsLoadBool(int Type);
public static native int UISettingsLoadDword(int Type);
+ public static native String UISettingsLoadString(int type);
public static native String UISettingsLoadStringIndex(int Type, int Index);
}
diff --git a/Android/src/emu/project64/settings/BaseSettingsFragment.java b/Android/src/emu/project64/settings/BaseSettingsFragment.java
index 53f9449ae..56ed38d13 100644
--- a/Android/src/emu/project64/settings/BaseSettingsFragment.java
+++ b/Android/src/emu/project64/settings/BaseSettingsFragment.java
@@ -24,14 +24,19 @@
package emu.project64.settings;
import emu.project64.R;
+import emu.project64.SplashActivity;
+import emu.project64.jni.NativeExports;
+import android.content.DialogInterface;
+import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
+import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceFragmentCompat;
-public abstract class BaseSettingsFragment extends PreferenceFragmentCompat
+public abstract class BaseSettingsFragment extends PreferenceFragmentCompat
{
protected abstract int getXml();
protected abstract int getTitleId();
@@ -47,7 +52,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat
{
super.onStart();
final AppCompatActivity activity = (AppCompatActivity)getActivity();
- if (activity != null && activity.getSupportActionBar() != null)
+ if (activity != null && activity.getSupportActionBar() != null)
{
activity.getSupportActionBar().setTitle(getString(getTitleId()));
}
@@ -56,8 +61,8 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat
protected void loadFragment(Fragment fragment)
{
getActivity().getSupportFragmentManager().beginTransaction()
- .replace(R.id.fragment_placeholder, fragment)
- .addToBackStack("main").commit();
+ .replace(R.id.fragment_placeholder, fragment)
+ .addToBackStack("main").commit();
}
@Override
@@ -71,4 +76,39 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat
}*/
super.onDisplayPreferenceDialog(preference);
}
+
+ @Override
+ public boolean onPreferenceTreeClick(Preference preference)
+ {
+ if (preference.getKey().equals("settings_reset"))
+ {
+ DialogInterface.OnClickListener internalListener = new DialogInterface.OnClickListener()
+ {
+ @Override
+ public void onClick( DialogInterface dialog, int which )
+ {
+ if( which == DialogInterface.BUTTON_POSITIVE )
+ {
+ NativeExports.ResetApplicationSettings();
+ SplashActivity.Reset();
+ Intent SplashIntent = new Intent(getActivity(), SplashActivity.class);
+ SplashIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
+ startActivity(SplashIntent);
+ }
+ }
+ };
+
+ String title = getString( R.string.settings_reset_title );
+ String message = getString( R.string.settings_reset_message );
+ AlertDialog.Builder builder = new AlertDialog.Builder( getActivity() ).setTitle( title ).setMessage( message ).setCancelable( false )
+ .setNegativeButton( getString( android.R.string.cancel ), internalListener )
+ .setPositiveButton( getString( android.R.string.ok ), internalListener );
+ builder.create().show();
+ }
+ else
+ {
+ return super.onPreferenceTreeClick(preference);
+ }
+ return true;
+ }
}