[Android] Add reset in

This commit is contained in:
zilmar 2016-10-02 11:47:38 +11:00
parent 7f83a52641
commit 0c5bddfb6c
3 changed files with 49 additions and 4 deletions

View File

@ -141,6 +141,8 @@
<string name="VerticalInterruptsPerSecond">Vertical interrupts per second</string> <string name="VerticalInterruptsPerSecond">Vertical interrupts per second</string>
<string name="ForceGfxReset_title">Reset GFX Plugin</string> <string name="ForceGfxReset_title">Reset GFX Plugin</string>
<string name="ForceGfxReset_summary">Always reload GFX plugin</string> <string name="ForceGfxReset_summary">Always reload GFX plugin</string>
<string name="settings_reset_title">Reset settings</string>
<string name="settings_reset_message">Reset all settings back to their defaults?</string>
<string-array name="DisplaySpeed_list"> <string-array name="DisplaySpeed_list">
<item>@string/DListPerSecond</item> <item>@string/DListPerSecond</item>

View File

@ -37,6 +37,7 @@ public class NativeExports
public static native void LoadRomList(); public static native void LoadRomList();
public static native void RefreshRomDir(String RomDir, boolean Recursive); public static native void RefreshRomDir(String RomDir, boolean Recursive);
public static native void ExternalEvent(int Type); public static native void ExternalEvent(int Type);
public static native void ResetApplicationSettings();
public static native void onSurfaceCreated(); public static native void onSurfaceCreated();
public static native void onSurfaceChanged(int width, int height); 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 UISettingsSaveBool(int Type, boolean Value);
public static native void UISettingsSaveDword(int Type, int 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 boolean UISettingsLoadBool(int Type);
public static native int UISettingsLoadDword(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); public static native String UISettingsLoadStringIndex(int Type, int Index);
} }

View File

@ -24,9 +24,14 @@
package emu.project64.settings; package emu.project64.settings;
import emu.project64.R; 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.os.Bundle;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceFragmentCompat; import android.support.v7.preference.PreferenceFragmentCompat;
@ -71,4 +76,39 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat
}*/ }*/
super.onDisplayPreferenceDialog(preference); 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;
}
} }