mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-01-27 23:33:52 +00:00
Clean up first-time initialization and insure touch keypad has reasonable defaults
This commit is contained in:
parent
5df1e2400e
commit
36cb44e1e8
@ -179,7 +179,13 @@ public class Apple2Activity extends Activity {
|
|||||||
Log.e(TAG, "onCreate()");
|
Log.e(TAG, "onCreate()");
|
||||||
|
|
||||||
_setCustomExceptionHandler();
|
_setCustomExceptionHandler();
|
||||||
String dataDir = Apple2DisksMenu.firstTimeAssetsInitialization(this);
|
|
||||||
|
// run first-time initializations
|
||||||
|
if (!Apple2Preferences.FIRST_TIME_CONFIGURED.booleanValue(this)) {
|
||||||
|
Apple2DisksMenu.firstTime(this);
|
||||||
|
Apple2Preferences.KeypadPreset.IJKM_SPACE.apply(this);
|
||||||
|
}
|
||||||
|
Apple2Preferences.FIRST_TIME_CONFIGURED.saveBoolean(this, true);
|
||||||
|
|
||||||
// get device audio parameters for native OpenSLES
|
// get device audio parameters for native OpenSLES
|
||||||
mSampleRate = DevicePropertyCalculator.getRecommendedSampleRate(this);
|
mSampleRate = DevicePropertyCalculator.getRecommendedSampleRate(this);
|
||||||
@ -187,6 +193,7 @@ public class Apple2Activity extends Activity {
|
|||||||
mStereoBufferSize = DevicePropertyCalculator.getRecommendedBufferSize(this, /*isStereo:*/true);
|
mStereoBufferSize = DevicePropertyCalculator.getRecommendedBufferSize(this, /*isStereo:*/true);
|
||||||
Log.d(TAG, "Device sampleRate:" + mSampleRate + " mono bufferSize:" + mMonoBufferSize + " stereo bufferSize:" + mStereoBufferSize);
|
Log.d(TAG, "Device sampleRate:" + mSampleRate + " mono bufferSize:" + mMonoBufferSize + " stereo bufferSize:" + mStereoBufferSize);
|
||||||
|
|
||||||
|
String dataDir = Apple2DisksMenu.getDataDir(this);
|
||||||
nativeOnCreate(dataDir, mSampleRate, mMonoBufferSize, mStereoBufferSize);
|
nativeOnCreate(dataDir, mSampleRate, mMonoBufferSize, mStereoBufferSize);
|
||||||
|
|
||||||
// NOTE: load preferences after nativeOnCreate ... native CPU thread should still be paused
|
// NOTE: load preferences after nativeOnCreate ... native CPU thread should still be paused
|
||||||
|
@ -97,7 +97,11 @@ public class Apple2DisksMenu implements Apple2MenuView {
|
|||||||
// HACK NOTE 2015/02/22 : Apparently native code cannot easily access stuff in the APK ... so copy various resources
|
// HACK NOTE 2015/02/22 : Apparently native code cannot easily access stuff in the APK ... so copy various resources
|
||||||
// out of the APK and into the /data/data/... for ease of access. Because this is FOSS software we don't care about
|
// out of the APK and into the /data/data/... for ease of access. Because this is FOSS software we don't care about
|
||||||
// security or DRM for these assets =)
|
// security or DRM for these assets =)
|
||||||
public static String firstTimeAssetsInitialization(Apple2Activity activity) {
|
public static String getDataDir(Apple2Activity activity) {
|
||||||
|
|
||||||
|
if (sDataDir != null) {
|
||||||
|
return sDataDir;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PackageManager pm = activity.getPackageManager();
|
PackageManager pm = activity.getPackageManager();
|
||||||
@ -108,9 +112,11 @@ public class Apple2DisksMenu implements Apple2MenuView {
|
|||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Apple2Preferences.ASSETS_CONFIGURED.booleanValue(activity)) {
|
return sDataDir;
|
||||||
return sDataDir;
|
}
|
||||||
}
|
|
||||||
|
public static void firstTime(Apple2Activity activity) {
|
||||||
|
getDataDir(activity);
|
||||||
|
|
||||||
Log.d(TAG, "First time copying stuff-n-things out of APK for ease-of-NDK access...");
|
Log.d(TAG, "First time copying stuff-n-things out of APK for ease-of-NDK access...");
|
||||||
|
|
||||||
@ -127,11 +133,6 @@ public class Apple2DisksMenu implements Apple2MenuView {
|
|||||||
Log.e(TAG, "problem copying resources : " + e);
|
Log.e(TAG, "problem copying resources : " + e);
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d(TAG, "Saving default preferences");
|
|
||||||
Apple2Preferences.ASSETS_CONFIGURED.saveBoolean(activity, true);
|
|
||||||
|
|
||||||
return sDataDir;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
@ -16,10 +16,10 @@ import android.content.Context;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
|
||||||
public enum Apple2Preferences {
|
public enum Apple2Preferences {
|
||||||
ASSETS_CONFIGURED {
|
FIRST_TIME_CONFIGURED {
|
||||||
@Override
|
@Override
|
||||||
public void load(Apple2Activity activity) {
|
public void load(Apple2Activity activity) {
|
||||||
// ...
|
/* ... */
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -353,7 +353,7 @@ public enum Apple2Preferences {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int intValue(Apple2Activity activity) {
|
public int intValue(Apple2Activity activity) {
|
||||||
return activity.getPreferences(Context.MODE_PRIVATE).getInt(toString(), -1);
|
return activity.getPreferences(Context.MODE_PRIVATE).getInt(toString(), KeypadPreset.IJKM_SPACE.ordinal() + 1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
KEYPAD_NORTHWEST_KEY {
|
KEYPAD_NORTHWEST_KEY {
|
||||||
@ -759,6 +759,8 @@ public enum Apple2Preferences {
|
|||||||
|
|
||||||
public static void resetPreferences(Apple2Activity activity) {
|
public static void resetPreferences(Apple2Activity activity) {
|
||||||
activity.getPreferences(Context.MODE_PRIVATE).edit().clear().commit();
|
activity.getPreferences(Context.MODE_PRIVATE).edit().clear().commit();
|
||||||
|
FIRST_TIME_CONFIGURED.saveBoolean(activity, true);
|
||||||
|
KeypadPreset.IJKM_SPACE.apply(activity);
|
||||||
loadPreferences(activity);
|
loadPreferences(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user