]> git.gag.com Git - debian/openrocket/commitdiff
Added some functionality to Main activity. Splash screen is displayed for a little...
authorkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Tue, 3 Jan 2012 18:56:38 +0000 (18:56 +0000)
committerkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Tue, 3 Jan 2012 18:56:38 +0000 (18:56 +0000)
git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@266 180e2498-e6e9-4542-8430-84ac67f01cd8

android/res/drawable-mdpi/splashscreen.png [new file with mode: 0644]
android/res/layout/main.xml [new file with mode: 0644]
src/net/sf/openrocket/android/Main.java

diff --git a/android/res/drawable-mdpi/splashscreen.png b/android/res/drawable-mdpi/splashscreen.png
new file mode 100644 (file)
index 0000000..5af7cfb
Binary files /dev/null and b/android/res/drawable-mdpi/splashscreen.png differ
diff --git a/android/res/layout/main.xml b/android/res/layout/main.xml
new file mode 100644 (file)
index 0000000..53b32ec
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+    android:layout_width="fill_parent"\r
+    android:layout_height="fill_parent"\r
+    android:orientation="vertical" >\r
+\r
+    <ImageView\r
+        android:id="@+id/splashscreen"\r
+        android:layout_width="wrap_content"\r
+        android:layout_height="fill_parent"\r
+        android:layout_gravity="center"\r
+        android:src="@drawable/splashscreen" />\r
+\r
+    <TextView\r
+        android:layout_width="fill_parent"\r
+        android:layout_height="wrap_content"\r
+        android:text="Welcome to OpenRocket" />\r
+\r
+    <Button\r
+        android:layout_width="fill_parent"\r
+        android:layout_height="wrap_content"\r
+        android:onClick="pickOrkFiles"\r
+        android:text="View ork file" />\r
+\r
+    <Button\r
+        android:layout_width="fill_parent"\r
+        android:layout_height="wrap_content"\r
+        android:onClick="browseMotors"\r
+        android:text="View motors" />\r
+\r
+</LinearLayout>
\ No newline at end of file
index 07cfe4ef5b4f651e4a788258bd90cdea0910f196..347115c628be8cbb27c074f05992b283291d6f25 100644 (file)
@@ -1,7 +1,81 @@
 package net.sf.openrocket.android;\r
 \r
+import net.sf.openrocket.R;\r
+import net.sf.openrocket.android.motor.MotorHierarchicalBrowser;\r
 import android.app.Activity;\r
+import android.content.Intent;\r
+import android.net.Uri;\r
+import android.os.Bundle;\r
+import android.os.Handler;\r
+import android.os.Message;\r
+import android.view.View;\r
+import android.widget.ImageView;\r
 \r
 public class Main extends Activity {\r
 \r
+       private static final int PICK_ORK_FILE_RESULT = 1;\r
+\r
+       private static final int STOPSPLASH = 0;\r
+       //time in milliseconds\r
+       private static final long SPLASHTIME = 3000;\r
+\r
+       private ImageView splash;\r
+\r
+       //handler for splash screen\r
+       private Handler splashHandler = new Handler() {\r
+               /* (non-Javadoc)\r
+                * @see android.os.Handler#handleMessage(android.os.Message)\r
+                */\r
+               @Override\r
+               public void handleMessage(Message msg) {\r
+                       switch (msg.what) {\r
+                       case STOPSPLASH:\r
+                               //remove SplashScreen from view\r
+                               splash.setVisibility(View.GONE);\r
+                               break;\r
+                       }\r
+                       super.handleMessage(msg);\r
+               }\r
+       };\r
+\r
+       /** Called when the activity is first created. */\r
+       @Override\r
+       public void onCreate(Bundle icicle) {\r
+               super.onCreate(icicle);\r
+               setContentView(R.layout.main);\r
+               splash = (ImageView) findViewById(R.id.splashscreen);\r
+               Message msg = new Message();\r
+               msg.what = STOPSPLASH;\r
+               splashHandler.sendMessageDelayed(msg, SPLASHTIME);\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see android.app.Activity#onActivityResult(int, int, android.content.Intent)\r
+        */\r
+       @Override\r
+       protected void onActivityResult(int requestCode, int resultCode, Intent data) {\r
+               switch ( requestCode ) {\r
+               case PICK_ORK_FILE_RESULT:\r
+                       if(resultCode==RESULT_OK){\r
+                               Uri file = data.getData();\r
+                               Intent intent = new Intent(Intent.ACTION_VIEW);\r
+                               intent.setData(file);\r
+                               startActivity(intent);\r
+                       }\r
+                       break;\r
+               }\r
+               super.onActivityResult(requestCode, resultCode, data);\r
+       }\r
+\r
+       public void pickOrkFiles( View v ) {\r
+               Intent intent = new Intent(Intent.ACTION_GET_CONTENT);\r
+               intent.setType("file/*");\r
+               startActivityForResult(intent,PICK_ORK_FILE_RESULT);\r
+       }\r
+\r
+       public void browseMotors( View v ) {\r
+               Intent i = new Intent(Main.this, MotorHierarchicalBrowser.class);\r
+               startActivity(i);\r
+       }\r
+\r
 }\r