mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-06-26 00:29:27 +00:00
First cut at splash screen on Android
This commit is contained in:
parent
a0cadc83c6
commit
16a743fd50
|
@ -46,6 +46,7 @@ public class Apple2Activity extends Activity {
|
|||
private ArrayList<Apple2MenuView> mMenuStack = new ArrayList<Apple2MenuView>();
|
||||
private AlertDialog mQuitDialog = null;
|
||||
private AlertDialog mRebootDialog = null;
|
||||
private Apple2SplashScreen mSplashScreen = null;
|
||||
|
||||
private int mWidth = 0;
|
||||
private int mHeight = 0;
|
||||
|
@ -62,19 +63,27 @@ public class Apple2Activity extends Activity {
|
|||
}
|
||||
|
||||
private native void nativeOnCreate(String dataDir, int sampleRate, int monoBufferSize, int stereoBufferSize);
|
||||
|
||||
private native void nativeGraphicsInitialized(int width, int height);
|
||||
|
||||
private native void nativeGraphicsChanged(int width, int height);
|
||||
|
||||
private native void nativeOnKeyDown(int keyCode, int metaState);
|
||||
|
||||
private native void nativeOnKeyUp(int keyCode, int metaState);
|
||||
|
||||
private native void nativeOnUncaughtException(String home, String trace);
|
||||
|
||||
public native void nativeOnResume(boolean isSystemResume);
|
||||
|
||||
public native void nativeOnPause();
|
||||
|
||||
public native void nativeOnQuit();
|
||||
|
||||
public native boolean nativeOnTouch(int action, int pointerCount, int pointerIndex, float[] xCoords, float[] yCoords);
|
||||
|
||||
public native void nativeReboot();
|
||||
|
||||
public native void nativeRender();
|
||||
|
||||
public native void nativeChooseDisk(String path, boolean driveA, boolean readOnly);
|
||||
|
@ -91,7 +100,7 @@ public class Apple2Activity extends Activity {
|
|||
PackageInfo pi = pm.getPackageInfo(getPackageName(), 0);
|
||||
dataDir = pi.applicationInfo.dataDir;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e(TAG, ""+e);
|
||||
Log.e(TAG, "" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
|
@ -111,7 +120,7 @@ public class Apple2Activity extends Activity {
|
|||
_copyFile(dataDir, "disks", disk);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "problem copying resources : "+e);
|
||||
Log.e(TAG, "problem copying resources : " + e);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
|
@ -122,14 +131,13 @@ public class Apple2Activity extends Activity {
|
|||
}
|
||||
|
||||
private void _copyFile(String dataDir, String subdir, String assetName)
|
||||
throws IOException
|
||||
{
|
||||
String outputPath = dataDir+File.separator+subdir;
|
||||
Log.d(TAG, "Copying "+subdir+File.separator+assetName+" to "+outputPath+File.separator+assetName+" ...");
|
||||
throws IOException {
|
||||
String outputPath = dataDir + File.separator + subdir;
|
||||
Log.d(TAG, "Copying " + subdir + File.separator + assetName + " to " + outputPath + File.separator + assetName + " ...");
|
||||
new File(outputPath).mkdirs();
|
||||
|
||||
InputStream is = getAssets().open(subdir+File.separator+assetName);
|
||||
File file = new File(outputPath+File.separator+assetName);
|
||||
InputStream is = getAssets().open(subdir + File.separator + assetName);
|
||||
File file = new File(outputPath + File.separator + assetName);
|
||||
file.setWritable(true);
|
||||
FileOutputStream os = new FileOutputStream(file);
|
||||
|
||||
|
@ -164,7 +172,7 @@ public class Apple2Activity extends Activity {
|
|||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Immediately set up exception handler ...
|
||||
final String homeDir = "/data/data/"+this.getPackageName();
|
||||
final String homeDir = "/data/data/" + this.getPackageName();
|
||||
final Thread.UncaughtExceptionHandler defaultExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
|
||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||
@Override
|
||||
|
@ -222,11 +230,11 @@ public class Apple2Activity extends Activity {
|
|||
mSampleRate = DevicePropertyCalculator.getRecommendedSampleRate(this);
|
||||
mMonoBufferSize = DevicePropertyCalculator.getRecommendedBufferSize(this, /*isStereo:*/false);
|
||||
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);
|
||||
|
||||
nativeOnCreate(mDataDir, mSampleRate, mMonoBufferSize, mStereoBufferSize);
|
||||
|
||||
// NOTE: load preferences after nativeOnCreate
|
||||
// NOTE: load preferences after nativeOnCreate ... native CPU thread should still be paused
|
||||
Apple2Preferences.loadPreferences(this);
|
||||
|
||||
mView = new Apple2View(this);
|
||||
|
@ -273,7 +281,7 @@ public class Apple2Activity extends Activity {
|
|||
if (mainMenu != null) {
|
||||
mainMenu.dismiss();
|
||||
}
|
||||
if (mQuitDialog != null && mQuitDialog.isShowing()) {
|
||||
if (mQuitDialog != null && mQuitDialog.isShowing()) {
|
||||
mQuitDialog.dismiss();
|
||||
}
|
||||
if (mRebootDialog != null && mRebootDialog.isShowing()) {
|
||||
|
@ -325,19 +333,19 @@ public class Apple2Activity extends Activity {
|
|||
private String actionToString(int action) {
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
return "CANCEL:"+action;
|
||||
return "CANCEL:" + action;
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
return "DOWN:"+action;
|
||||
return "DOWN:" + action;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
return "MOVE:"+action;
|
||||
return "MOVE:" + action;
|
||||
case MotionEvent.ACTION_UP:
|
||||
return "UP:"+action;
|
||||
return "UP:" + action;
|
||||
case MotionEvent.ACTION_POINTER_DOWN:
|
||||
return "PDOWN:"+action;
|
||||
return "PDOWN:" + action;
|
||||
case MotionEvent.ACTION_POINTER_UP:
|
||||
return "PUP:"+action;
|
||||
return "PUP:" + action;
|
||||
default:
|
||||
return "UNK:"+action;
|
||||
return "UNK:" + action;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -355,9 +363,9 @@ public class Apple2Activity extends Activity {
|
|||
*/
|
||||
int pointerIndex = ev.getActionIndex();
|
||||
|
||||
Log.d(TAG, "Event "+actionToString(ev.getActionMasked())+" for "+pointerIndex+" at time "+ev.getEventTime()+" :");
|
||||
for (int p=0; p<pointerCount; p++) {
|
||||
Log.d(TAG, " pointer "+ev.getPointerId(p)+": ("+ev.getX(p)+","+ev.getY(p)+")");
|
||||
Log.d(TAG, "Event " + actionToString(ev.getActionMasked()) + " for " + pointerIndex + " at time " + ev.getEventTime() + " :");
|
||||
for (int p = 0; p < pointerCount; p++) {
|
||||
Log.d(TAG, " pointer " + ev.getPointerId(p) + ": (" + ev.getX(p) + "," + ev.getY(p) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -382,7 +390,7 @@ public class Apple2Activity extends Activity {
|
|||
int action = event.getActionMasked();
|
||||
int pointerIndex = event.getActionIndex();
|
||||
int pointerCount = event.getPointerCount();
|
||||
for (int i=0; i<pointerCount/* && i < MAX_FINGERS */; i++) {
|
||||
for (int i = 0; i < pointerCount/* && i < MAX_FINGERS */; i++) {
|
||||
mXCoords[i] = event.getX(i);
|
||||
mYCoords[i] = event.getY(i);
|
||||
}
|
||||
|
@ -409,7 +417,25 @@ public class Apple2Activity extends Activity {
|
|||
mWidth = w;
|
||||
mHeight = h;
|
||||
|
||||
// tell native about this...
|
||||
nativeGraphicsInitialized(w, h);
|
||||
|
||||
showSplashScreen();
|
||||
}
|
||||
|
||||
public synchronized void showSplashScreen() {
|
||||
if (mSplashScreen != null && mSplashScreen.isShowing()) {
|
||||
return;
|
||||
}
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mSplashScreen == null) {
|
||||
mSplashScreen = new Apple2SplashScreen(Apple2Activity.this);
|
||||
}
|
||||
mSplashScreen.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public synchronized void pushApple2View(Apple2MenuView apple2MenuView) {
|
||||
|
@ -420,7 +446,7 @@ public class Apple2Activity extends Activity {
|
|||
}
|
||||
|
||||
public synchronized Apple2MenuView popApple2View() {
|
||||
int lastIndex = mMenuStack.size()-1;
|
||||
int lastIndex = mMenuStack.size() - 1;
|
||||
if (lastIndex < 0) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Apple // emulator for *nix
|
||||
*
|
||||
* This software package is subject to the GNU General Public License
|
||||
* version 2 or later (your choice) as published by the Free Software
|
||||
* Foundation.
|
||||
*
|
||||
* THERE ARE NO WARRANTIES WHATSOEVER.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.deadc0de.apple2ix;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
|
||||
public class Apple2SplashScreen implements Apple2MenuView {
|
||||
|
||||
private final static String TAG = "Apple2SplashScreen";
|
||||
|
||||
private Apple2Activity mActivity = null;
|
||||
private View mSettingsView = null;
|
||||
|
||||
public Apple2SplashScreen(Apple2Activity activity) {
|
||||
mActivity = activity;
|
||||
setup();
|
||||
}
|
||||
|
||||
private void setup() {
|
||||
LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
mSettingsView = inflater.inflate(R.layout.activity_splash_screen, null, false);
|
||||
|
||||
Drawable d = mActivity.getResources().getDrawable(R.drawable.apple_iie);
|
||||
ImageView imageView = (ImageView)mSettingsView.findViewById(R.id.splashView);
|
||||
imageView.setImageDrawable(d);
|
||||
|
||||
Button startButton = (Button)mSettingsView.findViewById(R.id.startButton);
|
||||
startButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Apple2SplashScreen.this.dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void show() {
|
||||
if (isShowing()) {
|
||||
return;
|
||||
}
|
||||
mActivity.pushApple2View(this);
|
||||
}
|
||||
|
||||
public void dismiss() {
|
||||
mActivity.popApple2View(this);
|
||||
}
|
||||
|
||||
public boolean isShowing() {
|
||||
return mSettingsView.isShown();
|
||||
}
|
||||
|
||||
public View getView() {
|
||||
return mSettingsView;
|
||||
}
|
||||
}
|
BIN
Android/app/src/main/res/drawable-hdpi/apple_iie.png
Normal file
BIN
Android/app/src/main/res/drawable-hdpi/apple_iie.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 196 KiB |
BIN
Android/app/src/main/res/drawable-ldpi/apple_iie.png
Normal file
BIN
Android/app/src/main/res/drawable-ldpi/apple_iie.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 196 KiB |
BIN
Android/app/src/main/res/drawable-mdpi/apple_iie.png
Normal file
BIN
Android/app/src/main/res/drawable-mdpi/apple_iie.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 196 KiB |
BIN
Android/app/src/main/res/drawable-xhdpi/apple_iie.png
Normal file
BIN
Android/app/src/main/res/drawable-xhdpi/apple_iie.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 355 KiB |
BIN
Android/app/src/main/res/drawable-xxhdpi/apple_iie.png
Normal file
BIN
Android/app/src/main/res/drawable-xxhdpi/apple_iie.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 355 KiB |
BIN
Android/app/src/main/res/drawable-xxxhdpi/apple_iie.png
Normal file
BIN
Android/app/src/main/res/drawable-xxxhdpi/apple_iie.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 479 KiB |
32
Android/app/src/main/res/layout/activity_splash_screen.xml
Normal file
32
Android/app/src/main/res/layout/activity_splash_screen.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/preference_margin_left"
|
||||
android:layout_marginStart="@dimen/preference_margin_left"
|
||||
android:layout_marginRight="@dimen/preference_margin_right"
|
||||
android:layout_marginEnd="@dimen/preference_margin_right"
|
||||
android:layout_marginTop="@dimen/preference_margin_top"
|
||||
android:layout_marginBottom="@dimen/preference_margin_bottom"
|
||||
android:layout_weight="1">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:id="@+id/splashView" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/emulation_continue"
|
||||
android:id="@+id/startButton"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginRight="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginTop="18dp" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -19,6 +19,8 @@
|
|||
<string name="diskA">Drive 1</string>
|
||||
<string name="diskB">Drive 2</string>
|
||||
<string name="disk_read_write">Read/write</string>
|
||||
<string name="emulation_continue">Continue…</string>
|
||||
<string name="emulation_welcome">Party like it\'s 1987!</string>
|
||||
<string name="header_disks">Insert disk:</string>
|
||||
<string name="joystick">Joystick</string>
|
||||
<string name="input_configure">Configure input devices…</string>
|
||||
|
@ -69,8 +71,6 @@
|
|||
<string name="speaker_volume_summary">Set the speaker volume</string>
|
||||
<string name="speed_alt">Alternate CPU Speed</string>
|
||||
<string name="speed_cpu">CPU Speed</string>
|
||||
<string name="speed_swipe">Swipe changes emulation speed</string>
|
||||
<string name="speed_swipe_summary">Left/right swiping decreases/increases emulation speed</string>
|
||||
<string name="settings">Apple2ix emulator settings</string>
|
||||
<string name="settings_audio">Apple2ix audio settings</string>
|
||||
<string name="settings_advanced">Advanced settings</string>
|
||||
|
|
Loading…
Reference in New Issue
Block a user