[Android] Add settings
This commit is contained in:
parent
e0647a88c0
commit
5eafd11f3b
|
@ -43,17 +43,7 @@
|
|||
android:label="@string/ScanRomsActivity_title"
|
||||
android:theme="@style/Theme.AppCompat" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name="emu.project64.persistent.GlobalPrefsActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/SettingsGlobalActivity_title"
|
||||
android:theme="@style/Theme.AppCompat" >
|
||||
<intent-filter>
|
||||
<action android:name=".persistent.GlobalPrefsActivity" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<!--
|
||||
For the GameActivities, do not restart the activity when the phone's slider
|
||||
opens or closes, or when the orientation (and thereby screen size) changes.
|
||||
|
@ -77,5 +67,11 @@
|
|||
<activity
|
||||
android:name="emu.project64.AboutActivity"
|
||||
android:theme="@style/Theme.Project64.About" />
|
||||
<activity
|
||||
android:name="emu.project64.settings.SettingsActivity"
|
||||
android:theme="@style/Theme.Project64.Apearance" />
|
||||
<activity
|
||||
android:name="emu.project64.settings.GameSettingsActivity"
|
||||
android:theme="@style/Theme.Project64.Apearance" />
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/background_actionbar"
|
||||
android:theme="@style/Project64.Toolbar" />
|
||||
<FrameLayout
|
||||
android:id="@+id/fragment_placeholder"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" >
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
|
@ -6,7 +6,4 @@
|
|||
<attr name="font_actionbar" format="reference|color" />
|
||||
<attr name="font_actionbar_selected" format="reference|color" />
|
||||
<attr name="textMenuColor" format="reference|color" />
|
||||
<declare-styleable name="PathPreference">
|
||||
<attr name="selectionMode" format="integer" />
|
||||
</declare-styleable>
|
||||
</resources>
|
|
@ -11,7 +11,6 @@
|
|||
<string name="SplashActivity_title" translatable="false">@string/app_name</string>
|
||||
<string name="GalleryActivity_title" translatable="false">@string/app_name</string>
|
||||
<string name="ScanRomsActivity_title" translatable="false">@string/app_name</string>
|
||||
<string name="SettingsGlobalActivity_title" translatable="false">@string/menuItem_globalSettings</string>
|
||||
<string name="GameActivity_title" translatable="false">@string/app_name</string>
|
||||
|
||||
</resources>
|
|
@ -25,7 +25,6 @@
|
|||
<string name="menuItem_refreshRoms">Refresh ROMs</string>
|
||||
<string name="menuItem_gameDir">Game Dir</string>
|
||||
<string name="menuItem_settings">Settings</string>
|
||||
<string name="menuItem_globalSettings">Global settings</string>
|
||||
<string name="menuItem_about">About</string>
|
||||
<string name="menuItem_appVersion">App version</string>
|
||||
<string name="menuItem_hardwareInfo">Hardware info</string>
|
||||
|
@ -61,18 +60,86 @@
|
|||
<string name="about_copyright" translatable="false">Copyleft © 1998–2016 by Project64.\n</string>
|
||||
<string name="authors" translatable="false">Zilmar, Jabo, Smiff, Gent, Jahra!n, Witten, RadeonUser, Trotterwatch, pixi, Azimer, Gonetz, cxd4, AmbientMalice, LegendOfDragoon, Nekokabu, Lithium64, death-droid, LuigiBlood, dsx.</string>
|
||||
|
||||
<!-- Gallery sections -->
|
||||
<string name="galleryRecentlyPlayed">Recently played</string>
|
||||
<string name="galleryLibrary">Library</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="preferences">Settings</string>
|
||||
<string name="settings_title">Settings</string>
|
||||
<string name="displayFps_title">Framerate</string>
|
||||
<string name="displayFps_summary">Display FPS on screen</string>
|
||||
<string name="audioEnabled_title">Enabled</string>
|
||||
<string name="audioEnabled_title">Enable Audio</string>
|
||||
<string name="audioEnabled_summary">Enable/Disable audio output</string>
|
||||
<string name="advancedSettings_title">Hide Advanced Settings</string>
|
||||
<string name="advancedSettings_summary">Remove more complex settings that most users will not want to use</string>
|
||||
<string name="debuggerEnabled_title">Enable debugger</string>
|
||||
<string name="debuggerEnabled_summary">Enable/Disable extra options to try and debug why games do not work</string>
|
||||
<string name="BlockLinking_title">Advanced Block Linking</string>
|
||||
<string name="BlockLinking_summary">Precompile blocks together</string>
|
||||
<string name="GenerateLogFiles_title">Generate Log Files</string>
|
||||
<string name="GenerateLogFiles_summary">Log recompiler code</string>
|
||||
<string name="logging">Logging</string>
|
||||
<string name="project64core">Project64 Core</string>
|
||||
<string name="logging_project64core">Logging - Project64 Core</string>
|
||||
<string name="TraceError">Error</string>
|
||||
<string name="TraceWarning">Warning</string>
|
||||
<string name="TraceNotice">Notice</string>
|
||||
<string name="TraceInfo">Info</string>
|
||||
<string name="TraceDebug">Debug</string>
|
||||
<string name="TraceVerbose">Verbose</string>
|
||||
<string name="TraceMD5">MD5</string>
|
||||
<string name="TraceThread">Thread</string>
|
||||
<string name="TracePath">Path</string>
|
||||
<string name="TraceSettings">Settings</string>
|
||||
<string name="TraceUnknown">Unknown</string>
|
||||
<string name="TraceAppInit">App Init</string>
|
||||
<string name="TraceAppCleanup">App Cleanup</string>
|
||||
<string name="TraceN64System">N64 System</string>
|
||||
<string name="TracePlugins">Plugins</string>
|
||||
<string name="TraceGFXPlugin">GFX Plugin</string>
|
||||
<string name="TraceAudioPlugin">Audio Plugin</string>
|
||||
<string name="TraceControllerPlugin">Controller Plugin</string>
|
||||
<string name="TraceRSPPlugin">RSP Plugin</string>
|
||||
<string name="TraceRSP">RSP</string>
|
||||
<string name="TraceAudio">Audio</string>
|
||||
<string name="TraceRegisterCache">Register Cache</string>
|
||||
<string name="TraceRecompiler">Recompiler</string>
|
||||
<string name="TraceTLB">TLB</string>
|
||||
<string name="TraceProtectedMem">Protected Mem</string>
|
||||
<string name="TraceUserInterface">User Interface</string>
|
||||
<string name="TraceRomList">Rom List</string>
|
||||
<string name="TraceExceptionHandler">Exception Handler</string>
|
||||
<string name="CpuType">CPU core style</string>
|
||||
<string name="Interpreter">Interpreter</string>
|
||||
<string name="Recompiler">Recompiler</string>
|
||||
<string name="SyncCores">Synchronize Cores</string>
|
||||
|
||||
<string-array name="cpu_core_list">
|
||||
<item>@string/Interpreter</item>
|
||||
<item>@string/Recompiler</item>
|
||||
<item>@string/SyncCores</item>
|
||||
</string-array>
|
||||
<string-array name="cpu_core_values" translatable="false">
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="trace_severity_list">
|
||||
<item>@string/TraceError</item>
|
||||
<item>@string/TraceWarning</item>
|
||||
<item>@string/TraceNotice</item>
|
||||
<item>@string/TraceInfo</item>
|
||||
<item>@string/TraceDebug</item>
|
||||
<item>@string/TraceVerbose</item>
|
||||
</string-array>
|
||||
<string-array name="trace_severity_values" translatable="false">
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
<item>5</item>
|
||||
<item>6</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Path Preferences (selected path will become the summary) -->
|
||||
<!-- '~' indicates rel path & use storage dir if path doesn't exist -->
|
||||
<!-- '!' indicates rel path & create parent dirs if path doesn't exist -->
|
||||
<string name="pathPreference_dialogTitle">Selected folder: %1$s</string>
|
||||
<string name="pathGameSaves_title">Game save folder</string>
|
||||
<string name="pathGameSaves_default">!project64</string>
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/preferences">
|
||||
|
||||
<ListPreference
|
||||
android:entries="@array/cpu_core_list"
|
||||
android:entryValues="@array/cpu_core_values"
|
||||
android:key="Game_CpuType"
|
||||
android:title="@string/CpuType" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="Game_BlockLinking"
|
||||
android:summary="@string/BlockLinking_summary"
|
||||
android:title="@string/BlockLinking_title" />
|
||||
</PreferenceScreen>
|
|
@ -0,0 +1,114 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<ListPreference
|
||||
android:entries="@array/trace_severity_list"
|
||||
android:entryValues="@array/trace_severity_values"
|
||||
android:key="Debugger_TraceMD5"
|
||||
android:title="@string/TraceMD5" />
|
||||
<ListPreference
|
||||
android:entries="@array/trace_severity_list"
|
||||
android:entryValues="@array/trace_severity_values"
|
||||
android:key="Debugger_TraceThread"
|
||||
android:title="@string/TraceThread" />
|
||||
<ListPreference
|
||||
android:entries="@array/trace_severity_list"
|
||||
android:entryValues="@array/trace_severity_values"
|
||||
android:key="Debugger_TracePath"
|
||||
android:title="@string/TracePath" />
|
||||
<ListPreference
|
||||
android:entries="@array/trace_severity_list"
|
||||
android:entryValues="@array/trace_severity_values"
|
||||
android:key="Debugger_TraceSettings"
|
||||
android:title="@string/TraceSettings" />
|
||||
<ListPreference
|
||||
android:entries="@array/trace_severity_list"
|
||||
android:entryValues="@array/trace_severity_values"
|
||||
android:key="Debugger_TraceUnknown"
|
||||
android:title="@string/TraceUnknown" />
|
||||
<ListPreference
|
||||
android:entries="@array/trace_severity_list"
|
||||
android:entryValues="@array/trace_severity_values"
|
||||
android:key="Debugger_TraceAppInit"
|
||||
android:title="@string/TraceAppInit" />
|
||||
<ListPreference
|
||||
android:entries="@array/trace_severity_list"
|
||||
android:entryValues="@array/trace_severity_values"
|
||||
android:key="Debugger_TraceAppCleanup"
|
||||
android:title="@string/TraceAppCleanup" />
|
||||
<ListPreference
|
||||
android:entries="@array/trace_severity_list"
|
||||
android:entryValues="@array/trace_severity_values"
|
||||
android:key="Debugger_TraceN64System"
|
||||
android:title="@string/TraceN64System" />
|
||||
<ListPreference
|
||||
android:entries="@array/trace_severity_list"
|
||||
android:entryValues="@array/trace_severity_values"
|
||||
android:key="Debugger_TracePlugins"
|
||||
android:title="@string/TracePlugins" />
|
||||
<ListPreference
|
||||
android:entries="@array/trace_severity_list"
|
||||
android:entryValues="@array/trace_severity_values"
|
||||
android:key="Debugger_TraceGFXPlugin"
|
||||
android:title="@string/TraceGFXPlugin" />
|
||||
<ListPreference
|
||||
android:entries="@array/trace_severity_list"
|
||||
android:entryValues="@array/trace_severity_values"
|
||||
android:key="Debugger_TraceAudioPlugin"
|
||||
android:title="@string/TraceAudioPlugin" />
|
||||
<ListPreference
|
||||
android:entries="@array/trace_severity_list"
|
||||
android:entryValues="@array/trace_severity_values"
|
||||
android:key="Debugger_TraceControllerPlugin"
|
||||
android:title="@string/TraceControllerPlugin" />
|
||||
<ListPreference
|
||||
android:entries="@array/trace_severity_list"
|
||||
android:entryValues="@array/trace_severity_values"
|
||||
android:key="Debugger_TraceRSPPlugin"
|
||||
android:title="@string/TraceRSPPlugin" />
|
||||
<ListPreference
|
||||
android:entries="@array/trace_severity_list"
|
||||
android:entryValues="@array/trace_severity_values"
|
||||
android:key="Debugger_TraceRSP"
|
||||
android:title="@string/TraceRSP" />
|
||||
<ListPreference
|
||||
android:entries="@array/trace_severity_list"
|
||||
android:entryValues="@array/trace_severity_values"
|
||||
android:key="Debugger_TraceAudio"
|
||||
android:title="@string/TraceAudio" />
|
||||
<ListPreference
|
||||
android:entries="@array/trace_severity_list"
|
||||
android:entryValues="@array/trace_severity_values"
|
||||
android:key="Debugger_TraceRegisterCache"
|
||||
android:title="@string/TraceRegisterCache" />
|
||||
<ListPreference
|
||||
android:entries="@array/trace_severity_list"
|
||||
android:entryValues="@array/trace_severity_values"
|
||||
android:key="Debugger_TraceRecompiler"
|
||||
android:title="@string/TraceRecompiler" />
|
||||
<ListPreference
|
||||
android:entries="@array/trace_severity_list"
|
||||
android:entryValues="@array/trace_severity_values"
|
||||
android:key="Debugger_TraceTLB"
|
||||
android:title="@string/TraceTLB" />
|
||||
<ListPreference
|
||||
android:entries="@array/trace_severity_list"
|
||||
android:entryValues="@array/trace_severity_values"
|
||||
android:key="Debugger_TraceProtectedMEM"
|
||||
android:title="@string/TraceProtectedMem" />
|
||||
<ListPreference
|
||||
android:entries="@array/trace_severity_list"
|
||||
android:entryValues="@array/trace_severity_values"
|
||||
android:key="Debugger_TraceUserInterface"
|
||||
android:title="@string/TraceUserInterface" />
|
||||
<ListPreference
|
||||
android:entries="@array/trace_severity_list"
|
||||
android:entryValues="@array/trace_severity_values"
|
||||
android:key="Debugger_TraceRomList"
|
||||
android:title="@string/TraceRomList" />
|
||||
<ListPreference
|
||||
android:entries="@array/trace_severity_list"
|
||||
android:entryValues="@array/trace_severity_values"
|
||||
android:key="Debugger_TraceExceptionHandler"
|
||||
android:title="@string/TraceExceptionHandler" />
|
||||
</PreferenceScreen>
|
|
@ -1,77 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
***********************************************************************************
|
||||
RECOMMENDED PRACTICES FOR DESIGNERS & DEVELOPERS:
|
||||
|
||||
Wherever possible, use Android's built-in Preference framework for defining global
|
||||
user settings and the menu interface that supports them:
|
||||
http://developer.android.com/guide/topics/ui/settings.html
|
||||
http://developer.android.com/design/patterns/settings.html
|
||||
|
||||
Please follow our naming convention (casing and underscores) for all Preferences:
|
||||
<CheckBoxPreference
|
||||
android:key="myKey"
|
||||
android:title="@string/myKey_title"
|
||||
android:summary="@string/myKey_summary"
|
||||
...
|
||||
/>
|
||||
<ListPreference
|
||||
...
|
||||
android:entries="@array/myKey_entries"
|
||||
android:entryValues="@array/myKey_values"
|
||||
android:defaultValue="@string/myKey_default"
|
||||
...
|
||||
/>
|
||||
<emu.project64.MyCustomPreference
|
||||
...
|
||||
project64:myAttribute="@string/myKey_myAttribute"
|
||||
...
|
||||
/>
|
||||
|
||||
Strings should never be hard-coded into this file, with the exception perhaps of
|
||||
boolean default values. Instead, define all strings as resources in:
|
||||
res/values/strings.xml
|
||||
|
||||
To improve code readability, define all arrays as resources in:
|
||||
res/values/arrays.xml
|
||||
Define default array values below the arrays themselves in arrays.xml, rather than
|
||||
in strings.xml. This makes it easy to keep arrays and their default values
|
||||
synchronized.
|
||||
|
||||
To minimize app size, consider using Android's built-in resources when possible.
|
||||
For example, consider icon resources in "@android:drawable/..." instead of custom
|
||||
resources in "@drawable/...".
|
||||
***********************************************************************************
|
||||
-->
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:project64="http://schemas.android.com/apk/res/emu.project64"
|
||||
android:key="screenRoot" >
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="categoryDisplay"
|
||||
android:title="@string/categoryDisplay_title" >
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="displayFps"
|
||||
android:summary="@string/displayFps_summary"
|
||||
android:title="@string/displayFps_title" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:key="categoryAudio"
|
||||
android:title="@string/categoryAudio_title" >
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="enableAudio"
|
||||
android:summary="@string/audioEnabled_summary"
|
||||
android:title="@string/audioEnabled_title" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:key="categoryData"
|
||||
android:title="@string/categoryData_title" >
|
||||
<emu.project64.preference.PathPreference
|
||||
android:defaultValue="@string/pathGameSaves_default"
|
||||
android:key="pathGameSaves"
|
||||
android:title="@string/pathGameSaves_title"
|
||||
project64:selectionMode="0" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/preferences">
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="audio_Enabled"
|
||||
android:summary="@string/audioEnabled_summary"
|
||||
android:title="@string/audioEnabled_title" />
|
||||
|
||||
|
||||
</PreferenceScreen>
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/preferences">
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="audio_Enabled"
|
||||
android:summary="@string/audioEnabled_summary"
|
||||
android:title="@string/audioEnabled_title" />
|
||||
<CheckBoxPreference
|
||||
android:key="UserInterface_BasicMode"
|
||||
android:summary="@string/advancedSettings_summary"
|
||||
android:title="@string/advancedSettings_title" />
|
||||
<CheckBoxPreference
|
||||
android:key="Debugger_Enabled"
|
||||
android:summary="@string/debuggerEnabled_summary"
|
||||
android:title="@string/debuggerEnabled_title" />
|
||||
<CheckBoxPreference
|
||||
android:key="Debugger_GenerateLogFiles"
|
||||
android:summary="@string/GenerateLogFiles_summary"
|
||||
android:title="@string/GenerateLogFiles_title" />
|
||||
<PreferenceCategory android:title="@string/logging" >
|
||||
<Preference
|
||||
android:title="@string/project64core"
|
||||
android:key="logging_core" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
|
@ -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<GalleryItem> mGalleryItems = new ArrayList<GalleryItem>();
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 ) );
|
||||
}
|
||||
}
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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<CharSequence> mNames = new ArrayList<CharSequence>();
|
||||
private final List<String> mPaths = new ArrayList<String>();
|
||||
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.</p>
|
||||
* <li>0 = Directories can only be used as a choice.
|
||||
* <li>1 = Files can only be used as a choice.
|
||||
* <li>2 = Directories and files can be used as a choice.</li>
|
||||
*/
|
||||
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<String> 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;
|
||||
}
|
||||
}
|
|
@ -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<SavedStringState> CREATOR = new Parcelable.Creator<SavedStringState>()
|
||||
{
|
||||
@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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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)); }
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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")));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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,6 +24,61 @@ 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");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue