First cut at splash screen on Android

This commit is contained in:
Aaron Culliney 2015-07-26 15:07:43 -07:00
parent a0cadc83c6
commit 16a743fd50
10 changed files with 152 additions and 26 deletions

View File

@ -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);
@ -122,8 +131,7 @@ public class Apple2Activity extends Activity {
}
private void _copyFile(String dataDir, String subdir, String assetName)
throws IOException
{
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();
@ -226,7 +234,7 @@ public class Apple2Activity extends Activity {
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);
@ -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) {

View File

@ -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;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 KiB

View 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>

View File

@ -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>