Added some functionality to Main activity. Splash screen is displayed for a little bit, then the user is presented with two buttons - one to open a file browser to find ork files, the other to start the motor browser.
This commit is contained in:
parent
0970409101
commit
c546dba066
BIN
android/res/drawable-mdpi/splashscreen.png
Normal file
BIN
android/res/drawable-mdpi/splashscreen.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 185 KiB |
31
android/res/layout/main.xml
Normal file
31
android/res/layout/main.xml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/splashscreen"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:src="@drawable/splashscreen" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Welcome to OpenRocket" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:onClick="pickOrkFiles"
|
||||||
|
android:text="View ork file" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:onClick="browseMotors"
|
||||||
|
android:text="View motors" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -1,7 +1,81 @@
|
|||||||
package net.sf.openrocket.android;
|
package net.sf.openrocket.android;
|
||||||
|
|
||||||
|
import net.sf.openrocket.R;
|
||||||
|
import net.sf.openrocket.android.motor.MotorHierarchicalBrowser;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
public class Main extends Activity {
|
public class Main extends Activity {
|
||||||
|
|
||||||
|
private static final int PICK_ORK_FILE_RESULT = 1;
|
||||||
|
|
||||||
|
private static final int STOPSPLASH = 0;
|
||||||
|
//time in milliseconds
|
||||||
|
private static final long SPLASHTIME = 3000;
|
||||||
|
|
||||||
|
private ImageView splash;
|
||||||
|
|
||||||
|
//handler for splash screen
|
||||||
|
private Handler splashHandler = new Handler() {
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see android.os.Handler#handleMessage(android.os.Message)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
switch (msg.what) {
|
||||||
|
case STOPSPLASH:
|
||||||
|
//remove SplashScreen from view
|
||||||
|
splash.setVisibility(View.GONE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
super.handleMessage(msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Called when the activity is first created. */
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle icicle) {
|
||||||
|
super.onCreate(icicle);
|
||||||
|
setContentView(R.layout.main);
|
||||||
|
splash = (ImageView) findViewById(R.id.splashscreen);
|
||||||
|
Message msg = new Message();
|
||||||
|
msg.what = STOPSPLASH;
|
||||||
|
splashHandler.sendMessageDelayed(msg, SPLASHTIME);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see android.app.Activity#onActivityResult(int, int, android.content.Intent)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
switch ( requestCode ) {
|
||||||
|
case PICK_ORK_FILE_RESULT:
|
||||||
|
if(resultCode==RESULT_OK){
|
||||||
|
Uri file = data.getData();
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
|
intent.setData(file);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void pickOrkFiles( View v ) {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
|
intent.setType("file/*");
|
||||||
|
startActivityForResult(intent,PICK_ORK_FILE_RESULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void browseMotors( View v ) {
|
||||||
|
Intent i = new Intent(Main.this, MotorHierarchicalBrowser.class);
|
||||||
|
startActivity(i);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user