From 5eafd11f3b9c8ab369eb2ea0410abeaaa2385c38 Mon Sep 17 00:00:00 2001
From: zilmar
Date: Sun, 10 Jul 2016 07:41:46 +1000
Subject: [PATCH] [Android] Add settings
---
Android/AndroidManifest.xml | 16 +-
Android/res/layout/settings_activity.xml | 22 ++
Android/res/values/attrs.xml | 3 -
Android/res/values/strings-no-translate.xml | 1 -
Android/res/values/strings.xml | 85 ++++-
Android/res/xml/game_settings.xml | 15 +
Android/res/xml/logging_project64core.xml | 114 +++++++
Android/res/xml/preferences_global.xml | 77 -----
Android/res/xml/settings.xml | 12 +
Android/res/xml/settings_advanced.xml | 26 ++
.../src/emu/project64/GalleryActivity.java | 24 +-
Android/src/emu/project64/SplashActivity.java | 6 +-
Android/src/emu/project64/dialog/Popups.java | 64 ----
.../project64/game/GameLifecycleHandler.java | 15 +-
.../emu/project64/game/GameMenuHandler.java | 1 -
.../persistent/GlobalPrefsActivity.java | 70 ----
.../project64/preference/PathPreference.java | 307 ------------------
.../preference/SavedStringState.java | 68 ----
.../settings/BaseSettingsFragment.java | 74 +++++
.../settings/GameSettingsActivity.java | 87 +++++
.../settings/GameSettingsFragment.java | 36 ++
.../settings/LoggingProject64Core.java | 28 ++
.../project64/settings/SettingsActivity.java | 183 +++++++++++
.../project64/settings/SettingsFragment.java | 54 +++
Android/src/emu/project64/util/Notifier.java | 92 ++++++
25 files changed, 849 insertions(+), 631 deletions(-)
create mode 100644 Android/res/layout/settings_activity.xml
create mode 100644 Android/res/xml/game_settings.xml
create mode 100644 Android/res/xml/logging_project64core.xml
delete mode 100644 Android/res/xml/preferences_global.xml
create mode 100644 Android/res/xml/settings.xml
create mode 100644 Android/res/xml/settings_advanced.xml
delete mode 100644 Android/src/emu/project64/dialog/Popups.java
delete mode 100644 Android/src/emu/project64/persistent/GlobalPrefsActivity.java
delete mode 100644 Android/src/emu/project64/preference/PathPreference.java
delete mode 100644 Android/src/emu/project64/preference/SavedStringState.java
create mode 100644 Android/src/emu/project64/settings/BaseSettingsFragment.java
create mode 100644 Android/src/emu/project64/settings/GameSettingsActivity.java
create mode 100644 Android/src/emu/project64/settings/GameSettingsFragment.java
create mode 100644 Android/src/emu/project64/settings/LoggingProject64Core.java
create mode 100644 Android/src/emu/project64/settings/SettingsActivity.java
create mode 100644 Android/src/emu/project64/settings/SettingsFragment.java
diff --git a/Android/AndroidManifest.xml b/Android/AndroidManifest.xml
index 73ce387e3..de695cb3d 100644
--- a/Android/AndroidManifest.xml
+++ b/Android/AndroidManifest.xml
@@ -43,17 +43,7 @@
android:label="@string/ScanRomsActivity_title"
android:theme="@style/Theme.AppCompat" >
-
-
-
-
-
-
- Recently played
- Library
-
+
+ Settings
+ Settings
Framerate
Display FPS on screen
- Enabled
+ Enable Audio
Enable/Disable audio output
+ Hide Advanced Settings
+ Remove more complex settings that most users will not want to use
+ Enable debugger
+ Enable/Disable extra options to try and debug why games do not work
+ Advanced Block Linking
+ Precompile blocks together
+ Generate Log Files
+ Log recompiler code
+ Logging
+ Project64 Core
+ Logging - Project64 Core
+ Error
+ Warning
+ Notice
+ Info
+ Debug
+ Verbose
+ MD5
+ Thread
+ Path
+ Settings
+ Unknown
+ App Init
+ App Cleanup
+ N64 System
+ Plugins
+ GFX Plugin
+ Audio Plugin
+ Controller Plugin
+ RSP Plugin
+ RSP
+ Audio
+ Register Cache
+ Recompiler
+ TLB
+ Protected Mem
+ User Interface
+ Rom List
+ Exception Handler
+ CPU core style
+ Interpreter
+ Recompiler
+ Synchronize Cores
+
+
+ - @string/Interpreter
+ - @string/Recompiler
+ - @string/SyncCores
+
+
+ - 1
+ - 2
+ - 3
+
+
+
+ - @string/TraceError
+ - @string/TraceWarning
+ - @string/TraceNotice
+ - @string/TraceInfo
+ - @string/TraceDebug
+ - @string/TraceVerbose
+
+
+ - 1
+ - 2
+ - 3
+ - 4
+ - 5
+ - 6
+
+
-
-
- Selected folder: %1$s
Game save folder
!project64
diff --git a/Android/res/xml/game_settings.xml b/Android/res/xml/game_settings.xml
new file mode 100644
index 000000000..cf3f608fe
--- /dev/null
+++ b/Android/res/xml/game_settings.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
diff --git a/Android/res/xml/logging_project64core.xml b/Android/res/xml/logging_project64core.xml
new file mode 100644
index 000000000..7453dbfad
--- /dev/null
+++ b/Android/res/xml/logging_project64core.xml
@@ -0,0 +1,114 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Android/res/xml/preferences_global.xml b/Android/res/xml/preferences_global.xml
deleted file mode 100644
index 49aba9b4c..000000000
--- a/Android/res/xml/preferences_global.xml
+++ /dev/null
@@ -1,77 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Android/res/xml/settings.xml b/Android/res/xml/settings.xml
new file mode 100644
index 000000000..d19cb9318
--- /dev/null
+++ b/Android/res/xml/settings.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
diff --git a/Android/res/xml/settings_advanced.xml b/Android/res/xml/settings_advanced.xml
new file mode 100644
index 000000000..496dcd055
--- /dev/null
+++ b/Android/res/xml/settings_advanced.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Android/src/emu/project64/GalleryActivity.java b/Android/src/emu/project64/GalleryActivity.java
index 886cf3332..0efbc2dc6 100644
--- a/Android/src/emu/project64/GalleryActivity.java
+++ b/Android/src/emu/project64/GalleryActivity.java
@@ -15,7 +15,6 @@ import java.util.ArrayList;
import java.util.List;
import emu.project64.R;
-import emu.project64.dialog.Popups;
import emu.project64.dialog.ProgressDialog;
import emu.project64.game.GameActivity;
import emu.project64.game.GameActivityXperiaPlay;
@@ -28,7 +27,8 @@ import emu.project64.inAppPurchase.Inventory;
import emu.project64.jni.NativeExports;
import emu.project64.jni.SettingsID;
import emu.project64.jni.SystemEvent;
-import emu.project64.persistent.GlobalPrefsActivity;
+import emu.project64.settings.GameSettingsActivity;
+import emu.project64.settings.SettingsActivity;
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.content.Context;
@@ -38,6 +38,7 @@ import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
+import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@@ -73,7 +74,6 @@ public class GalleryActivity extends AppCompatActivity implements IabBroadcastLi
public int galleryMaxWidth;
public int galleryHalfSpacing;
public int galleryColumns = 2;
- public float galleryAspectRatio;
// Misc.
private static List mGalleryItems = new ArrayList();
@@ -166,7 +166,6 @@ public class GalleryActivity extends AppCompatActivity implements IabBroadcastLi
// Update the grid layout
galleryMaxWidth = (int) getResources().getDimension( R.dimen.galleryImageWidth );
galleryHalfSpacing = (int) getResources().getDimension( R.dimen.galleryHalfSpacing );
- galleryAspectRatio = galleryMaxWidth * 1.0f / getResources().getDimension( R.dimen.galleryImageHeight );
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics( metrics );
@@ -315,8 +314,12 @@ public class GalleryActivity extends AppCompatActivity implements IabBroadcastLi
startActivityForResult( intent, GAME_DIR_REQUEST_CODE );
return true;
case R.id.menuItem_settings:
- Intent GlobalPrefsIntent = new Intent( this, GlobalPrefsActivity.class );
- startActivity( GlobalPrefsIntent );
+ Intent SettingsIntent = new Intent(this, SettingsActivity.class);
+ startActivity( SettingsIntent );
+ return true;
+ case R.id.menuItem_forum:
+ Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://forum.pj64-emu.com/forumdisplay.php?f=13"));
+ startActivity(browserIntent);
return true;
case R.id.menuItem_about:
Intent AboutIntent = new Intent(this, AboutActivity.class);
@@ -391,7 +394,7 @@ public class GalleryActivity extends AppCompatActivity implements IabBroadcastLi
menuItemLst.add(new Item("Resume from Auto save", R.drawable.ic_lock));
}
menuItemLst.add(new Item("Restart", R.drawable.ic_refresh));
- if (ShowSettings)
+ if (ShowSettings && !NativeExports.SettingsLoadBool(SettingsID.UserInterface_BasicMode.getValue()))
{
menuItemLst.add(new Item("Settings", R.drawable.ic_sliders));
}
@@ -452,10 +455,6 @@ public class GalleryActivity extends AppCompatActivity implements IabBroadcastLi
{
return false;
}
- if (position == 3)
- {
- return false;
- }
return true;
}
};
@@ -514,7 +513,8 @@ public class GalleryActivity extends AppCompatActivity implements IabBroadcastLi
}
else if (item == 3)
{
- //settings still to do
+ Intent SettingsIntent = new Intent(finalContext, GameSettingsActivity.class);
+ startActivity( SettingsIntent );
}
}
});
diff --git a/Android/src/emu/project64/SplashActivity.java b/Android/src/emu/project64/SplashActivity.java
index 2577b89fa..8ff33d757 100644
--- a/Android/src/emu/project64/SplashActivity.java
+++ b/Android/src/emu/project64/SplashActivity.java
@@ -20,11 +20,11 @@ import emu.project64.jni.UISettingID;
import emu.project64.task.ExtractAssetsTask;
import emu.project64.task.ExtractAssetsTask.ExtractAssetsListener;
import emu.project64.task.ExtractAssetsTask.Failure;
+import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.os.Handler;
-import android.support.v7.app.AppCompatActivity;
import android.text.Html;
import android.util.Log;
import android.view.Window;
@@ -35,7 +35,7 @@ import android.widget.TextView;
* The main activity that presents the splash screen, extracts the assets if necessary, and launches
* the main menu activity.
*/
-public class SplashActivity extends AppCompatActivity implements ExtractAssetsListener
+public class SplashActivity extends Activity implements ExtractAssetsListener
{
/**
* Asset version number, used to determine stale assets. Increment this number every time the
@@ -75,7 +75,7 @@ public class SplashActivity extends AppCompatActivity implements ExtractAssetsLi
// Lay out the content
setContentView( R.layout.splash_activity );
- ((TextView) findViewById( R.id.versionText )).setText("v1.0");
+ ((TextView) findViewById( R.id.versionText )).setText(NativeExports.appVersion());
mTextView = (TextView) findViewById( R.id.mainText );
if (!mInit)
diff --git a/Android/src/emu/project64/dialog/Popups.java b/Android/src/emu/project64/dialog/Popups.java
deleted file mode 100644
index 463bf3086..000000000
--- a/Android/src/emu/project64/dialog/Popups.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-* *
-* Project 64 - A Nintendo 64 emulator. *
-* http://www.pj64-emu.com/ *
-* Copyright (C) 2012 Project64. All rights reserved. *
-* *
-* License: *
-* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
-* *
-****************************************************************************/
-package emu.project64.dialog;
-
-import emu.project64.R;
-import emu.project64.util.DeviceUtil;
-import android.annotation.SuppressLint;
-import android.app.AlertDialog.Builder;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-
-public class Popups
-{
-
- public static void showHardwareInfo( Context context )
- {
- String title = context.getString( R.string.menuItem_hardwareInfo );
- String axisInfo = DeviceUtil.getAxisInfo();
- String peripheralInfo = DeviceUtil.getPeripheralInfo();
- String cpuInfo = DeviceUtil.getCpuInfo();
- String message = axisInfo + peripheralInfo + cpuInfo;
- showShareableText( context, title, message );
- }
-
- public static void showShareableText( final Context context, String title, final String message )
- {
- // Set up click handler to share text with a user-selected app (email, clipboard, etc.)
- DialogInterface.OnClickListener shareHandler = new DialogInterface.OnClickListener()
- {
- @SuppressLint( "InlinedApi" )
- @Override
- public void onClick( DialogInterface dialog, int which )
- {
- launchPlainText( context, message,
- context.getText( R.string.actionShare_title ) );
- }
- };
-
- new Builder( context ).setTitle( title ).setMessage( message.toString() )
- .setNeutralButton( R.string.actionShare_title, shareHandler ).create().show();
- }
-
- @SuppressLint( "InlinedApi" )
- public static void launchPlainText( Context context, String text, CharSequence chooserTitle )
- {
- // See http://android-developers.blogspot.com/2012/02/share-with-intents.html
- Intent intent = new Intent( android.content.Intent.ACTION_SEND );
- intent.setType( "text/plain" );
- intent.addFlags( Intent.FLAG_ACTIVITY_NEW_DOCUMENT );
- intent.putExtra( Intent.EXTRA_TEXT, text );
- // intent.putExtra( Intent.EXTRA_SUBJECT, subject );
- // intent.putExtra( Intent.EXTRA_EMAIL, new String[] { emailTo } );
- context.startActivity( Intent.createChooser( intent, chooserTitle ) );
- }
-}
diff --git a/Android/src/emu/project64/game/GameLifecycleHandler.java b/Android/src/emu/project64/game/GameLifecycleHandler.java
index 679c06082..3ac61a9b3 100644
--- a/Android/src/emu/project64/game/GameLifecycleHandler.java
+++ b/Android/src/emu/project64/game/GameLifecycleHandler.java
@@ -253,14 +253,17 @@ public class GameLifecycleHandler implements SurfaceHolder.Callback, GameSurface
{
Log.i("GameLifecycleHandler", "onPause");
}
- AutoSave();
mIsResumed = false;
mStopped = true;
- if (LOG_GAMELIFECYCLEHANDLER)
- {
- Log.i("GameLifecycleHandler", "Stop Emulation");
- }
- NativeExports.StopEmulation();
+ if (NativeExports.SettingsLoadBool(SettingsID.GameRunning_CPU_Running.getValue()) == true)
+ {
+ AutoSave();
+ if (LOG_GAMELIFECYCLEHANDLER)
+ {
+ Log.i("GameLifecycleHandler", "Stop Emulation");
+ }
+ NativeExports.StopEmulation();
+ }
if (LOG_GAMELIFECYCLEHANDLER)
{
Log.i("GameLifecycleHandler", "onPause - done");
diff --git a/Android/src/emu/project64/game/GameMenuHandler.java b/Android/src/emu/project64/game/GameMenuHandler.java
index 563649ace..dd80cb1a8 100644
--- a/Android/src/emu/project64/game/GameMenuHandler.java
+++ b/Android/src/emu/project64/game/GameMenuHandler.java
@@ -141,7 +141,6 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup
NativeExports.ExternalEvent( SystemEvent.SysEvent_ResumeCPU_FromMenu.getValue());
mLifecycleHandler.AutoSave();
NativeExports.CloseSystem();
- mActivity.finish();
break;
}
return false;
diff --git a/Android/src/emu/project64/persistent/GlobalPrefsActivity.java b/Android/src/emu/project64/persistent/GlobalPrefsActivity.java
deleted file mode 100644
index 674bc3733..000000000
--- a/Android/src/emu/project64/persistent/GlobalPrefsActivity.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-* *
-* Project64 - A Nintendo 64 emulator. *
-* http://www.pj64-emu.com/ *
-* Copyright (C) 2012 Project64. All rights reserved. *
-* *
-* License: *
-* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
-* *
-****************************************************************************/
-package emu.project64.persistent;
-
-import emu.project64.R;
-
-import emu.project64.compat.AppCompatPreferenceActivity;
-import android.annotation.TargetApi;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
-import android.os.Bundle;
-import android.preference.Preference;
-import android.preference.Preference.OnPreferenceClickListener;
-
-public class GlobalPrefsActivity extends AppCompatPreferenceActivity implements OnPreferenceClickListener,
- OnSharedPreferenceChangeListener
-{
- private static final String NAVIGATION_MODE = "navigationMode";
-
- @SuppressWarnings( "deprecation" )
- @Override
- protected void onCreate( Bundle savedInstanceState )
- {
- super.onCreate( savedInstanceState );
-
- // Load user preference menu structure from XML and update view
- addPreferencesFromResource( R.xml.preferences_global );
-
- }
-
-
- @Override
- public void onSharedPreferenceChanged( SharedPreferences sharedPreferences, String key )
- {
- if( key.equals( NAVIGATION_MODE ) )
- {
- // Sometimes one preference change affects the hierarchy or layout of the views. In this
- // case it's easier just to restart the activity than try to figure out what to fix.
- finish();
- startActivity(getIntent());
- }
- else
- {
- // Just refresh the preference screens in place
- refreshViews();
- }
- }
-
- @TargetApi( 9 )
- private void refreshViews()
- {
- // Refresh the preferences object
-
- }
-
- @Override
- public boolean onPreferenceClick( Preference preference )
- {
- // Let Android handle all other preference clicks
- return false;
- }
-}
diff --git a/Android/src/emu/project64/preference/PathPreference.java b/Android/src/emu/project64/preference/PathPreference.java
deleted file mode 100644
index e4a8e7220..000000000
--- a/Android/src/emu/project64/preference/PathPreference.java
+++ /dev/null
@@ -1,307 +0,0 @@
-/****************************************************************************
-* *
-* Project 64 - A Nintendo 64 emulator. *
-* http://www.pj64-emu.com/ *
-* Copyright (C) 2012 Project64. All rights reserved. *
-* *
-* License: *
-* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
-* *
-****************************************************************************/
-package emu.project64.preference;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import emu.project64.R;
-
-import emu.project64.AndroidDevice;
-import emu.project64.dialog.Prompt;
-import emu.project64.util.FileUtil;
-import android.app.AlertDialog.Builder;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.res.TypedArray;
-import android.os.Environment;
-import android.os.Parcelable;
-import android.preference.DialogPreference;
-import android.text.TextUtils;
-import android.util.AttributeSet;
-import android.widget.ArrayAdapter;
-
-/**
- * A {@link DialogPreference} that is specifically for choosing a directory path or file on a device.
- */
-public class PathPreference extends DialogPreference
-{
- /** The user must select a directory. No files will be shown in the list. */
- public static final int SELECTION_MODE_DIRECTORY = 0;
-
- /** The user must select a file. The dialog will only close when a file is selected. */
- public static final int SELECTION_MODE_FILE = 1;
-
- /** The user may select a file or a directory. The Ok button must be used. */
- public static final int SELECTION_MODE_ANY = 2;
-
- private static final String STORAGE_DIR = Environment.getExternalStorageDirectory().getAbsolutePath();
-
- private final boolean mUseDefaultSummary;
- private int mSelectionMode = SELECTION_MODE_ANY;
- private boolean mDoReclick = false;
- private final List mNames = new ArrayList();
- private final List mPaths = new ArrayList();
- private String mNewValue;
- private String mValue;
-
- /**
- * Constructor
- *
- * @param context The {@link Context} that this PathPreference is being used in.
- * @param attrs A collection of attributes, as found associated with a tag in an XML document.
- */
- public PathPreference( Context context, AttributeSet attrs )
- {
- super( context, attrs );
-
- mUseDefaultSummary = TextUtils.isEmpty( getSummary() );
-
- // Get the selection mode from the XML file, if provided
- TypedArray a = context.obtainStyledAttributes( attrs, R.styleable.PathPreference );
- mSelectionMode = a.getInteger( R.styleable.PathPreference_selectionMode, SELECTION_MODE_ANY );
- a.recycle();
- }
-
- /**
- * Sets the path that PathPrefence will use.
- *
- * @param value The path that this PathPreference instance will use.
- */
- public void setValue( String value )
- {
- mValue = validate( value );
- if( shouldPersist() )
- persistString( mValue );
-
- // Summary always reflects the true/persisted value, does not track the temporary/new value
- if( mUseDefaultSummary )
- setSummary( mSelectionMode == SELECTION_MODE_FILE ? new File( mValue ).getName() : mValue );
-
- // Reset the dialog info
- populate( mValue );
- }
-
- /**
- * Sets the specific selection mode to use.
- *
- * @param value The selection mode to use.
- * 0 = Directories can only be used as a choice.
- * 1 = Files can only be used as a choice.
- * 2 = Directories and files can be used as a choice.
- */
- public void setSelectionMode( int value )
- {
- mSelectionMode = value;
- }
-
- /**
- * Gets the path value being used.
- *
- * @return The path value being used by this PathPreference.
- */
- public String getValue()
- {
- return mValue;
- }
-
- /**
- * Gets the current selection mode being used.
- *
- * @return The current selection mode being used by this PathPreference.
- */
- public int getSelectionMode()
- {
- return mSelectionMode;
- }
-
- @Override
- protected Object onGetDefaultValue( TypedArray a, int index )
- {
- return a.getString( index );
- }
-
- @Override
- protected void onSetInitialValue( boolean restorePersistedValue, Object defaultValue )
- {
- setValue( restorePersistedValue ? getPersistedString( mValue ) : (String) defaultValue );
- }
-
- @Override
- protected void onPrepareDialogBuilder( Builder builder )
- {
- super.onPrepareDialogBuilder( builder );
-
- // Add the list entries
- if( AndroidDevice.IS_HONEYCOMB )
- {
- // Holo theme has folder icons and "Parent folder" text
- ArrayAdapter adapter = Prompt.createFilenameAdapter( getContext(), mPaths, mNames );
- builder.setAdapter( adapter, this );
- }
- else
- {
- // Basic theme uses bold text for folders and ".." for the parent
- CharSequence[] items = mNames.toArray( new CharSequence[mNames.size()] );
- builder.setItems( items, this );
- }
-
- // Remove the Ok button when user must choose a file
- if( mSelectionMode == SELECTION_MODE_FILE )
- builder.setPositiveButton( null, null );
- }
-
- @Override
- public void onClick( DialogInterface dialog, int which )
- {
- // If the user clicked a list item...
- if( which >= 0 && which < mPaths.size() )
- {
- mNewValue = mPaths.get( which );
- File path = new File( mNewValue );
- if( path.isDirectory() )
- {
- // ...navigate into...
- populate( mNewValue );
- mDoReclick = true;
- }
- else
- {
- // ...or close dialog positively
- which = DialogInterface.BUTTON_POSITIVE;
- }
- }
-
- // Call super last, parameters may have changed above
- super.onClick( dialog, which );
- }
-
- @Override
- protected void onDialogClosed( boolean positiveResult )
- {
- super.onDialogClosed( positiveResult );
-
- if( positiveResult && callChangeListener( mNewValue ) )
- {
- // User clicked Ok: clean the state by persisting value
- setValue( mNewValue );
- }
- else if( mDoReclick )
- {
- // User clicked a list item: maintain dirty value and re-open
- mDoReclick = false;
- onClick();
- }
- else
- {
- // User clicked Cancel/Back: clean state by restoring persisted value
- populate( mValue );
- }
- }
-
- @Override
- protected Parcelable onSaveInstanceState()
- {
- final SavedStringState myState = new SavedStringState( super.onSaveInstanceState() );
- myState.mValue = mNewValue;
- return myState;
- }
-
- @Override
- protected void onRestoreInstanceState( Parcelable state )
- {
- if( state == null || !state.getClass().equals( SavedStringState.class ) )
- {
- // Didn't save state for us in onSaveInstanceState
- super.onRestoreInstanceState( state );
- return;
- }
-
- final SavedStringState myState = (SavedStringState) state;
- super.onRestoreInstanceState( myState.getSuperState() );
- populate( myState.mValue );
-
- // If the dialog is already showing, we must close and reopen to refresh the contents
- // TODO: Find a less hackish solution, if one exists
- if( getDialog() != null )
- {
- mDoReclick = true;
- getDialog().dismiss();
- }
- }
-
- // Populates the dialog view with files and folders on the device.
- private void populate( String path )
- {
- // Cache the path to persist on Ok
- mNewValue = path;
-
- // Quick exit if null
- if( path == null )
- return;
-
- // If start path is a file, list it and its siblings in the parent directory
- File startPath = new File( path );
- if( startPath.isFile() )
- startPath = startPath.getParentFile();
-
- // Set the dialog title based on the selection mode
- switch( mSelectionMode )
- {
- case SELECTION_MODE_FILE:
- // If selecting only files, set title to parent directory name
- setDialogTitle( startPath.getPath() );
- break;
- case SELECTION_MODE_DIRECTORY:
- case SELECTION_MODE_ANY:
- // Otherwise clarify the directory that will be selected if user clicks Ok
- setDialogTitle( getContext().getString( R.string.pathPreference_dialogTitle,
- startPath.getPath() ) );
- break;
- }
-
- // Populate the key-value pairs for the list entries
- boolean isFilesIncluded = mSelectionMode != SELECTION_MODE_DIRECTORY;
- FileUtil.populate( startPath, true, true, isFilesIncluded, mNames, mPaths );
- }
-
- private static String validate( String value )
- {
- if( TextUtils.isEmpty( value ) )
- {
- // Use storage directory if value is empty
- value = STORAGE_DIR;
- }
- else
- {
- // Non-empty string provided
- // Prefixes encode additional information:
- // ! and ~ mean path is relative to storage dir
- // ! means parent dirs should be created if path does not exist
- // ~ means storage dir should be used if path does not exist
- boolean isRelativePath = value.startsWith( "!" ) || value.startsWith( "~" );
- boolean forceParentDirs = value.startsWith( "!" );
-
- // Build the absolute path if necessary
- if( isRelativePath )
- value = STORAGE_DIR + "/" + value.substring( 1 );
-
- // Ensure the parent directories exist if requested
- File file = new File( value );
- if( forceParentDirs )
- file.mkdirs();
- else if( !file.exists() )
- value = STORAGE_DIR;
- }
- return value;
- }
-}
diff --git a/Android/src/emu/project64/preference/SavedStringState.java b/Android/src/emu/project64/preference/SavedStringState.java
deleted file mode 100644
index 34d303785..000000000
--- a/Android/src/emu/project64/preference/SavedStringState.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-* *
-* Project 64 - A Nintendo 64 emulator. *
-* http://www.pj64-emu.com/ *
-* Copyright (C) 2012 Project64. All rights reserved. *
-* *
-* License: *
-* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
-* *
-****************************************************************************/
-package emu.project64.preference;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.preference.Preference;
-import android.preference.Preference.BaseSavedState;
-
-public class SavedStringState extends BaseSavedState
-{
- String mValue;
-
- public SavedStringState( Parcel source )
- {
- super( source );
- mValue = source.readString();
- }
-
- @Override
- public void writeToParcel( Parcel dest, int flags )
- {
- super.writeToParcel( dest, flags );
- dest.writeString( mValue );
- }
-
- public SavedStringState( Parcelable superState )
- {
- super( superState );
- }
-
- public static final Parcelable.Creator CREATOR = new Parcelable.Creator()
- {
- @Override
- public SavedStringState createFromParcel( Parcel in )
- {
- return new SavedStringState( in );
- }
-
- @Override
- public SavedStringState[] newArray( int size )
- {
- return new SavedStringState[size];
- }
- };
-
- public static Parcelable onSaveInstanceState( final Parcelable superState,
- Preference preference, String value )
- {
- if( preference.isPersistent() )
- {
- // No need to save instance state since it's persistent
- return superState;
- }
-
- final SavedStringState myState = new SavedStringState( superState );
- myState.mValue = value;
- return myState;
- }
-}
diff --git a/Android/src/emu/project64/settings/BaseSettingsFragment.java b/Android/src/emu/project64/settings/BaseSettingsFragment.java
new file mode 100644
index 000000000..53f9449ae
--- /dev/null
+++ b/Android/src/emu/project64/settings/BaseSettingsFragment.java
@@ -0,0 +1,74 @@
+/*
+ * *************************************************************************
+ * BasePreferenceFragment.java
+ * **************************************************************************
+ * Copyright © 2015 VLC authors and VideoLAN
+ * Author: Geoffrey Métais
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * ***************************************************************************
+ */
+
+package emu.project64.settings;
+
+import emu.project64.R;
+import android.os.Bundle;
+import android.support.v4.app.DialogFragment;
+import android.support.v4.app.Fragment;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceFragmentCompat;
+
+public abstract class BaseSettingsFragment extends PreferenceFragmentCompat
+{
+ protected abstract int getXml();
+ protected abstract int getTitleId();
+
+ @Override
+ public void onCreatePreferences(Bundle bundle, String s)
+ {
+ addPreferencesFromResource(getXml());
+ }
+
+ @Override
+ public void onStart()
+ {
+ super.onStart();
+ final AppCompatActivity activity = (AppCompatActivity)getActivity();
+ if (activity != null && activity.getSupportActionBar() != null)
+ {
+ activity.getSupportActionBar().setTitle(getString(getTitleId()));
+ }
+ }
+
+ protected void loadFragment(Fragment fragment)
+ {
+ getActivity().getSupportFragmentManager().beginTransaction()
+ .replace(R.id.fragment_placeholder, fragment)
+ .addToBackStack("main").commit();
+ }
+
+ @Override
+ public void onDisplayPreferenceDialog(Preference preference)
+ {
+ /*if (AndroidUtil.isHoneycombOrLater() && preference instanceof MultiSelectListPreference) {
+ DialogFragment dialogFragment = MultiSelectListPreferenceDialogFragmentCompat.newInstance(preference.getKey());
+ dialogFragment.setTargetFragment(this, 0);
+ dialogFragment.show(getFragmentManager(), DIALOG_FRAGMENT_TAG);
+ return;
+ }*/
+ super.onDisplayPreferenceDialog(preference);
+ }
+}
diff --git a/Android/src/emu/project64/settings/GameSettingsActivity.java b/Android/src/emu/project64/settings/GameSettingsActivity.java
new file mode 100644
index 000000000..0ae26cf3c
--- /dev/null
+++ b/Android/src/emu/project64/settings/GameSettingsActivity.java
@@ -0,0 +1,87 @@
+/****************************************************************************
+* *
+* Project64 - A Nintendo 64 emulator. *
+* http://www.pj64-emu.com/ *
+* Copyright (C) 2012 Project64. All rights reserved. *
+* *
+* License: *
+* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
+* *
+****************************************************************************/
+package emu.project64.settings;
+
+import emu.project64.AndroidDevice;
+import emu.project64.R;
+import emu.project64.jni.NativeExports;
+import emu.project64.jni.SettingsID;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.view.MenuItem;
+
+public class GameSettingsActivity extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener
+{
+ @Override
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.settings_activity);
+
+ // Add the tool bar to the activity (which supports the fancy menu/arrow animation)
+ Toolbar toolbar = (Toolbar) findViewById( R.id.toolbar );
+ toolbar.setTitle( getString(R.string.settings_title) );
+ setSupportActionBar( toolbar );
+ ActionBar actionbar = getSupportActionBar();
+
+ if (AndroidDevice.IS_ICE_CREAM_SANDWICH)
+ {
+ actionbar.setHomeButtonEnabled(true);
+ actionbar.setDisplayHomeAsUpEnabled(true);
+ }
+
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
+ sharedPrefs.edit().clear()
+ .putString("Game_CpuType",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Game_CpuType.getValue())))
+ .putBoolean("Game_BlockLinking",NativeExports.SettingsLoadBool(SettingsID.Game_BlockLinking.getValue()))
+ .apply();
+
+ sharedPrefs.registerOnSharedPreferenceChangeListener(this);
+
+ if (savedInstanceState == null)
+ {
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_placeholder, new GameSettingsFragment()).commit();
+ }
+ }
+
+ @Override
+ protected void onStop()
+ {
+ super.onStop();
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
+ sharedPrefs.unregisterOnSharedPreferenceChangeListener(this);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item)
+ {
+ switch (item.getItemId())
+ {
+ case android.R.id.home:
+ if (!getSupportFragmentManager().popBackStackImmediate())
+ finish();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key)
+ {
+ if (key.equals("Game_CpuType")) { NativeExports.SettingsSaveDword(SettingsID.Game_CpuType.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
+ else if (key.equals("Game_BlockLinking")) { NativeExports.SettingsSaveBool(SettingsID.Game_BlockLinking.getValue(), sharedPreferences.getBoolean(key,false)); }
+ }
+}
diff --git a/Android/src/emu/project64/settings/GameSettingsFragment.java b/Android/src/emu/project64/settings/GameSettingsFragment.java
new file mode 100644
index 000000000..35c74aaa4
--- /dev/null
+++ b/Android/src/emu/project64/settings/GameSettingsFragment.java
@@ -0,0 +1,36 @@
+/****************************************************************************
+* *
+* Project64 - A Nintendo 64 emulator. *
+* http://www.pj64-emu.com/ *
+* Copyright (C) 2012 Project64. All rights reserved. *
+* *
+* License: *
+* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
+* *
+****************************************************************************/
+package emu.project64.settings;
+
+import emu.project64.R;
+import emu.project64.jni.NativeExports;
+import emu.project64.jni.SettingsID;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.support.v7.preference.ListPreference;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceManager;
+
+public class GameSettingsFragment extends BaseSettingsFragment
+{
+ @Override
+ protected int getXml()
+ {
+ return R.xml.game_settings;
+ }
+
+ @Override
+ protected int getTitleId()
+ {
+ return R.string.preferences;
+ }
+}
diff --git a/Android/src/emu/project64/settings/LoggingProject64Core.java b/Android/src/emu/project64/settings/LoggingProject64Core.java
new file mode 100644
index 000000000..a34990c08
--- /dev/null
+++ b/Android/src/emu/project64/settings/LoggingProject64Core.java
@@ -0,0 +1,28 @@
+/****************************************************************************
+* *
+* Project64 - A Nintendo 64 emulator. *
+* http://www.pj64-emu.com/ *
+* Copyright (C) 2012 Project64. All rights reserved. *
+* *
+* License: *
+* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
+* *
+****************************************************************************/
+package emu.project64.settings;
+
+import emu.project64.R;
+
+public class LoggingProject64Core extends BaseSettingsFragment
+{
+ @Override
+ protected int getXml()
+ {
+ return R.xml.logging_project64core;
+ }
+
+ @Override
+ protected int getTitleId()
+ {
+ return R.string.logging_project64core;
+ }
+}
diff --git a/Android/src/emu/project64/settings/SettingsActivity.java b/Android/src/emu/project64/settings/SettingsActivity.java
new file mode 100644
index 000000000..2ffcf3447
--- /dev/null
+++ b/Android/src/emu/project64/settings/SettingsActivity.java
@@ -0,0 +1,183 @@
+/****************************************************************************
+* *
+* Project64 - A Nintendo 64 emulator. *
+* http://www.pj64-emu.com/ *
+* Copyright (C) 2012 Project64. All rights reserved. *
+* *
+* License: *
+* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
+* *
+****************************************************************************/
+package emu.project64.settings;
+
+import emu.project64.AndroidDevice;
+import emu.project64.R;
+import emu.project64.jni.NativeExports;
+import emu.project64.jni.SettingsID;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.view.MenuItem;
+
+public class SettingsActivity extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener
+{
+ @Override
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.settings_activity);
+
+ // Add the tool bar to the activity (which supports the fancy menu/arrow animation)
+ Toolbar toolbar = (Toolbar) findViewById( R.id.toolbar );
+ toolbar.setTitle( getString(R.string.settings_title) );
+ setSupportActionBar( toolbar );
+ ActionBar actionbar = getSupportActionBar();
+
+ if (AndroidDevice.IS_ICE_CREAM_SANDWICH)
+ {
+ actionbar.setHomeButtonEnabled(true);
+ actionbar.setDisplayHomeAsUpEnabled(true);
+ }
+
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
+ sharedPrefs.edit().clear()
+ .putBoolean("audio_Enabled",true)
+ .putBoolean("UserInterface_BasicMode",NativeExports.SettingsLoadBool(SettingsID.UserInterface_BasicMode.getValue()))
+ .putBoolean("Debugger_Enabled",NativeExports.SettingsLoadBool(SettingsID.Debugger_Enabled.getValue()))
+ .putBoolean("Debugger_GenerateLogFiles",NativeExports.SettingsLoadBool(SettingsID.Debugger_GenerateLogFiles.getValue()))
+ .putString("Debugger_TraceMD5",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceMD5.getValue())))
+ .putString("Debugger_TraceThread",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceThread.getValue())))
+ .putString("Debugger_TracePath",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TracePath.getValue())))
+ .putString("Debugger_TraceSettings",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceSettings.getValue())))
+ .putString("Debugger_TraceUnknown",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceUnknown.getValue())))
+ .putString("Debugger_TraceAppInit",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceAppInit.getValue())))
+ .putString("Debugger_TraceAppCleanup",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceAppCleanup.getValue())))
+ .putString("Debugger_TraceN64System",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceN64System.getValue())))
+ .putString("Debugger_TracePlugins",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TracePlugins.getValue())))
+ .putString("Debugger_TraceGFXPlugin",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceGFXPlugin.getValue())))
+ .putString("Debugger_TraceAudioPlugin",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceAudioPlugin.getValue())))
+ .putString("Debugger_TraceControllerPlugin",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceControllerPlugin.getValue())))
+ .putString("Debugger_TraceRSPPlugin",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRSPPlugin.getValue())))
+ .putString("Debugger_TraceRSP",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRSP.getValue())))
+ .putString("Debugger_TraceAudio",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceAudio.getValue())))
+ .putString("Debugger_TraceRegisterCache",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRegisterCache.getValue())))
+ .putString("Debugger_TraceRecompiler",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRecompiler.getValue())))
+ .putString("Debugger_TraceTLB",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceTLB.getValue())))
+ .putString("Debugger_TraceProtectedMEM",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceProtectedMEM.getValue())))
+ .putString("Debugger_TraceUserInterface",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceUserInterface.getValue())))
+ .putString("Debugger_TraceRomList",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRomList.getValue())))
+ .putString("Debugger_TraceExceptionHandler",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceExceptionHandler.getValue())))
+ .apply();
+
+ sharedPrefs.registerOnSharedPreferenceChangeListener(this);
+
+ if (savedInstanceState == null)
+ {
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_placeholder, new SettingsFragment()).commit();
+ }
+ }
+
+ @Override
+ protected void onStop()
+ {
+ super.onStop();
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
+ sharedPrefs.unregisterOnSharedPreferenceChangeListener(this);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item)
+ {
+ switch (item.getItemId())
+ {
+ case android.R.id.home:
+ if (!getSupportFragmentManager().popBackStackImmediate())
+ finish();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key)
+ {
+ if (key.equals("UserInterface_BasicMode"))
+ {
+ NativeExports.SettingsSaveBool(SettingsID.UserInterface_BasicMode.getValue(), sharedPreferences.getBoolean(key,false));
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_placeholder, new SettingsFragment()).commit();
+ }
+ else if (key.equals("Debugger_Enabled")) { NativeExports.SettingsSaveBool(SettingsID.Debugger_Enabled.getValue(), sharedPreferences.getBoolean(key,false)); }
+ else if (key.equals("Debugger_GenerateLogFiles")) { NativeExports.SettingsSaveBool(SettingsID.Debugger_GenerateLogFiles.getValue(), sharedPreferences.getBoolean(key,false)); }
+ else if (key.equals("Debugger_TraceMD5")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceMD5.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
+ else if (key.equals("Debugger_TraceThread")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceThread.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
+ else if (key.equals("Debugger_TracePath")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TracePath.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
+ else if (key.equals("Debugger_TraceSettings")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceSettings.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
+ else if (key.equals("Debugger_TraceUnknown")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceUnknown.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
+ else if (key.equals("Debugger_TraceAppInit")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceAppInit.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
+ else if (key.equals("Debugger_TraceAppCleanup")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceAppCleanup.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
+ else if (key.equals("Debugger_TraceN64System"))
+ {
+ NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceN64System.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1")));
+ }
+ else if (key.equals("Debugger_TracePlugins"))
+ {
+ NativeExports.SettingsSaveDword(SettingsID.Debugger_TracePlugins.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1")));
+ }
+ else if (key.equals("Debugger_TraceGFXPlugin"))
+ {
+ NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceGFXPlugin.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1")));
+ }
+ else if (key.equals("Debugger_TraceAudioPlugin"))
+ {
+ NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceAudioPlugin.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1")));
+ }
+ else if (key.equals("Debugger_TraceControllerPlugin"))
+ {
+ NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceControllerPlugin.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1")));
+ }
+ else if (key.equals("Debugger_TraceRSPPlugin"))
+ {
+ NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRSPPlugin.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1")));
+ }
+ else if (key.equals("Debugger_TraceRSP"))
+ {
+ NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRSP.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1")));
+ }
+ else if (key.equals("Debugger_TraceAudio"))
+ {
+ NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceAudio.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1")));
+ }
+ else if (key.equals("Debugger_TraceRegisterCache"))
+ {
+ NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRegisterCache.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1")));
+ }
+ else if (key.equals("Debugger_TraceRecompiler"))
+ {
+ NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRecompiler.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1")));
+ }
+ else if (key.equals("Debugger_TraceTLB"))
+ {
+ NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceTLB.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1")));
+ }
+ else if (key.equals("Debugger_TraceProtectedMEM"))
+ {
+ NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceProtectedMEM.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1")));
+ }
+ else if (key.equals("Debugger_TraceUserInterface"))
+ {
+ NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceUserInterface.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1")));
+ }
+ else if (key.equals("Debugger_TraceRomList"))
+ {
+ NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRomList.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1")));
+ }
+ else if (key.equals("Debugger_TraceExceptionHandler"))
+ {
+ NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceExceptionHandler.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1")));
+ }
+ }
+}
diff --git a/Android/src/emu/project64/settings/SettingsFragment.java b/Android/src/emu/project64/settings/SettingsFragment.java
new file mode 100644
index 000000000..4085e0740
--- /dev/null
+++ b/Android/src/emu/project64/settings/SettingsFragment.java
@@ -0,0 +1,54 @@
+/****************************************************************************
+* *
+* Project64 - A Nintendo 64 emulator. *
+* http://www.pj64-emu.com/ *
+* Copyright (C) 2012 Project64. All rights reserved. *
+* *
+* License: *
+* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
+* *
+****************************************************************************/
+package emu.project64.settings;
+
+import emu.project64.R;
+import emu.project64.jni.NativeExports;
+import emu.project64.jni.SettingsID;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.support.v7.preference.ListPreference;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceManager;
+
+public class SettingsFragment extends BaseSettingsFragment
+{
+ @Override
+ protected int getXml()
+ {
+ if (!NativeExports.SettingsLoadBool(SettingsID.UserInterface_BasicMode.getValue()))
+ {
+ return R.xml.settings_advanced;
+ }
+ return R.xml.settings;
+ }
+
+ @Override
+ protected int getTitleId()
+ {
+ return R.string.preferences;
+ }
+
+ @Override
+ public boolean onPreferenceTreeClick(Preference preference)
+ {
+ if (preference.getKey().equals("logging_core"))
+ {
+ loadFragment(new LoggingProject64Core());
+ }
+ else
+ {
+ return super.onPreferenceTreeClick(preference);
+ }
+ return true;
+ }
+}
diff --git a/Android/src/emu/project64/util/Notifier.java b/Android/src/emu/project64/util/Notifier.java
index 26a17167a..a1aabd1a7 100644
--- a/Android/src/emu/project64/util/Notifier.java
+++ b/Android/src/emu/project64/util/Notifier.java
@@ -11,6 +11,9 @@
package emu.project64.util;
import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.util.Log;
import android.view.Gravity;
import android.widget.Toast;
@@ -21,7 +24,62 @@ public final class Notifier
{
private static Toast sToast = null;
private static Runnable sToastMessager = null;
+ private static Runnable sDisplayMessager = null;
+ /**
+ * Pop up a temporary message on the device.
+ *
+ * @param activity The activity to display from
+ * @param message The message string to display.
+ */
+ public static void DisplayError( Activity activity, String message )
+ {
+ if( activity == null )
+ return;
+
+ final String finalMessage = new String(message);
+ final Activity finalActivity = activity;
+
+ sDisplayMessager = new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ new AlertDialog.Builder(finalActivity)
+ .setTitle("Error")
+ .setMessage(finalMessage)
+ .setPositiveButton("OK", new DialogInterface.OnClickListener()
+ {
+ public void onClick(DialogInterface dialog, int id)
+ {
+ // You don't have to do anything here if you just want it dismissed when clicked
+ synchronized(sDisplayMessager)
+ {
+ sDisplayMessager.notify();
+ };
+ }
+ })
+ .create()
+ .show();
+ }
+ };
+ activity.runOnUiThread( sDisplayMessager );
+ synchronized(sDisplayMessager)
+ {
+ try
+ {
+ sDisplayMessager.wait();
+ }
+ catch (InterruptedException e)
+ {
+ }
+ catch (IllegalMonitorStateException e)
+ {
+ }
+ }
+ Log.d("DisplayError", "Done");
+ }
+
/**
* Pop up a temporary message on the device.
*
@@ -65,4 +123,38 @@ public final class Notifier
}
activity.runOnUiThread( sToastMessager );
}
+
+ private static Runnable runEmulationStopped = null;
+ public static void EmulationStopped (Activity activity)
+ {
+ final Activity finalActivity = activity;
+
+ runEmulationStopped = new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ finalActivity.finish();
+ synchronized(runEmulationStopped)
+ {
+ runEmulationStopped.notify();
+ };
+ }
+ };
+ activity.runOnUiThread( runEmulationStopped );
+ synchronized(runEmulationStopped)
+ {
+ try
+ {
+ runEmulationStopped.wait();
+ }
+ catch (InterruptedException e)
+ {
+ }
+ catch (IllegalMonitorStateException e)
+ {
+ }
+ }
+ Log.d("EmulationStopped", "Done");
+ }
}