]> git.gag.com Git - debian/openrocket/commitdiff
Many style and navigation changes. Pulled in ActionBarCompat from Android sample...
authorkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Sat, 11 Feb 2012 20:17:39 +0000 (20:17 +0000)
committerkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Sat, 11 Feb 2012 20:17:39 +0000 (20:17 +0000)
git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@409 180e2498-e6e9-4542-8430-84ac67f01cd8

52 files changed:
android/AndroidManifest.xml
android/libs/android-support-v4.jar
android/lint.xml [new file with mode: 0644]
android/project.properties
android/res/drawable-hdpi/actionbar_shadow.9.png [new file with mode: 0644]
android/res/drawable-mdpi/actionbar_shadow.9.png [new file with mode: 0644]
android/res/drawable-mdpi/ic_home_carat.png [new file with mode: 0644]
android/res/drawable-mdpi/or_launcher.png [new file with mode: 0644]
android/res/drawable-xhdpi/actionbar_shadow.9.png [new file with mode: 0644]
android/res/drawable-xhdpi/or_launcher.png [new file with mode: 0644]
android/res/drawable/actionbar_compat_item.xml [new file with mode: 0644]
android/res/drawable/actionbar_compat_item_focused.xml [new file with mode: 0644]
android/res/drawable/actionbar_compat_item_pressed.xml [new file with mode: 0644]
android/res/drawable/home_item.xml [new file with mode: 0644]
android/res/drawable/or_launcher.png [deleted file]
android/res/layout-v11/actionbar_indeterminate_progress.xml [new file with mode: 0644]
android/res/layout-xlarge-land/openrocketviewer.xml
android/res/layout-xlarge-port/openrocketviewer.xml
android/res/layout/actionbar_compat.xml [new file with mode: 0644]
android/res/layout/motor_burn.xml
android/res/layout/openrocketviewer.xml
android/res/layout/rocket_overview.xml
android/res/layout/simplefilebrowser.xml
android/res/layout/simulation_series_dialog.xml
android/res/menu/main_menu.xml
android/res/menu/motor_browser_option_menu.xml
android/res/menu/rocket_viewer_option_menu.xml
android/res/values-v11/styles.xml [new file with mode: 0644]
android/res/values-v13/styles.xml [new file with mode: 0644]
android/res/values/actionbar_attrs.xml [new file with mode: 0644]
android/res/values/actionbar_colors.xml [new file with mode: 0644]
android/res/values/actionbar_dimens.xml [new file with mode: 0644]
android/res/values/actionbar_ids.xml [new file with mode: 0644]
android/res/values/actionbar_styles.xml [new file with mode: 0644]
android/res/values/strings.xml
android/res/values/styles.xml
android/src/net/sf/openrocket/android/Main.java
android/src/net/sf/openrocket/android/actionbarcompat/ActionBarActivity.java [new file with mode: 0644]
android/src/net/sf/openrocket/android/actionbarcompat/ActionBarFragmentActivity.java [new file with mode: 0644]
android/src/net/sf/openrocket/android/actionbarcompat/ActionBarHelper.java [new file with mode: 0644]
android/src/net/sf/openrocket/android/actionbarcompat/ActionBarHelperBase.java [new file with mode: 0644]
android/src/net/sf/openrocket/android/actionbarcompat/ActionBarHelperHoneycomb.java [new file with mode: 0644]
android/src/net/sf/openrocket/android/actionbarcompat/ActionBarHelperICS.java [new file with mode: 0644]
android/src/net/sf/openrocket/android/actionbarcompat/ActionBarListActivity.java [new file with mode: 0644]
android/src/net/sf/openrocket/android/actionbarcompat/SimpleMenu.java [new file with mode: 0644]
android/src/net/sf/openrocket/android/actionbarcompat/SimpleMenuItem.java [new file with mode: 0644]
android/src/net/sf/openrocket/android/filebrowser/SimpleFileBrowser.java
android/src/net/sf/openrocket/android/motor/BurnPlotActivity.java
android/src/net/sf/openrocket/android/motor/BurnPlotFragment.java
android/src/net/sf/openrocket/android/motor/MotorBrowserActivity.java
android/src/net/sf/openrocket/android/rocket/OpenRocketViewer.java
android/src/net/sf/openrocket/android/util/TabsAdapter.java [deleted file]

index 010f71bdb0289f0aa88a397eb908e3e3b6169841..5d8e63761df20c73935188b500d5a39550fa2ba6 100644 (file)
@@ -6,7 +6,7 @@
 \r
     <uses-sdk\r
         android:minSdkVersion="9"\r
-        android:targetSdkVersion="9" />\r
+        android:targetSdkVersion="15" />\r
 \r
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />\r
     <uses-permission android:name="android.permission.INTERNET" />\r
         android:debuggable="true"\r
         android:icon="@drawable/or_launcher"\r
         android:killAfterRestore="true"\r
-        android:label="@string/app_name" >\r
+        android:label="@string/app_name"\r
+        android:theme="@style/AppTheme" >\r
         <activity\r
             android:name=".android.Main"\r
-            android:theme="@android:style/Theme.Black.NoTitleBar" >\r
+            android:theme="@style/AppTheme.NoTitleBar" >\r
             <intent-filter>\r
                 <action android:name="android.intent.action.MAIN" />\r
 \r
         </activity>\r
         <activity\r
             android:name=".android.rocket.OpenRocketLoaderActivity"\r
-            android:theme="@android:style/Theme.Black.NoTitleBar" >\r
+            android:theme="@style/AppTheme.NoTitleBar" >\r
 \r
             <!--\r
                  I don't understand why I need to have two different intent filters. \r
                                Combining the <data> elements into a single field did not result in a working \r
                                application. The first intent-filter (with mimeType wildcard) convinces the \r
                                file browser to associate the correct launcher icon. the second intent-filter \r
-                               is actually invoked when a file is selected.\r\r\r\r
+                               is actually invoked when a file is selected.\r\r
             -->\r
             <!-- this intent filter convinces the file browser to display icons -->\r
             <intent-filter>\r
@@ -61,9 +62,7 @@
                     android:scheme="file" />\r
             </intent-filter>\r
         </activity>\r
-        <activity\r
-            android:name=".android.rocket.OpenRocketViewer"\r
-            android:label="@string/app_name" />\r
+        <activity android:name=".android.rocket.OpenRocketViewer" />\r
         <activity android:name=".android.PreferencesActivity" >\r
             <intent-filter>\r
                 <action android:name="net.sf.openrocket.android.PreferencesActivity" />\r
             </intent-filter>\r
         </activity>\r
         <activity android:name=".android.motor.MotorBrowserActivity" />\r
-        <activity android:name=".android.motor.BurnPlotActivity" />\r
+        <activity\r
+            android:name=".android.motor.BurnPlotActivity"\r
+            android:theme="@style/AppTheme.NoTitleBar" />\r
         <activity android:name=".android.thrustcurve.TCQueryActivity" />\r
-        <activity android:name=".android.simulation.SimulationViewActivity" />\r
+        <activity\r
+            android:name=".android.simulation.SimulationViewActivity"\r
+            android:theme="@style/AppTheme.NoTitleBar" />\r
         <activity android:name=".android.filebrowser.SimpleFileBrowser" />\r
     </application>\r
 \r
index b9a42793cd4a849dfe8175a68f7c3b5d363bf2a1..d006198e6abd489276ad3c69eec894d141c2289f 100644 (file)
Binary files a/android/libs/android-support-v4.jar and b/android/libs/android-support-v4.jar differ
diff --git a/android/lint.xml b/android/lint.xml
new file mode 100644 (file)
index 0000000..ee0eead
--- /dev/null
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lint>
+</lint>
\ No newline at end of file
index f049142c179997a39273e97b75614cf42c9e1b88..8da376af8d49472521c33bad1d544b8755a62c16 100644 (file)
@@ -8,4 +8,4 @@
 # project structure.
 
 # Project target.
-target=android-10
+target=android-15
diff --git a/android/res/drawable-hdpi/actionbar_shadow.9.png b/android/res/drawable-hdpi/actionbar_shadow.9.png
new file mode 100644 (file)
index 0000000..3c80a3f
Binary files /dev/null and b/android/res/drawable-hdpi/actionbar_shadow.9.png differ
diff --git a/android/res/drawable-mdpi/actionbar_shadow.9.png b/android/res/drawable-mdpi/actionbar_shadow.9.png
new file mode 100644 (file)
index 0000000..cae1778
Binary files /dev/null and b/android/res/drawable-mdpi/actionbar_shadow.9.png differ
diff --git a/android/res/drawable-mdpi/ic_home_carat.png b/android/res/drawable-mdpi/ic_home_carat.png
new file mode 100644 (file)
index 0000000..22dad56
Binary files /dev/null and b/android/res/drawable-mdpi/ic_home_carat.png differ
diff --git a/android/res/drawable-mdpi/or_launcher.png b/android/res/drawable-mdpi/or_launcher.png
new file mode 100644 (file)
index 0000000..849b6f1
Binary files /dev/null and b/android/res/drawable-mdpi/or_launcher.png differ
diff --git a/android/res/drawable-xhdpi/actionbar_shadow.9.png b/android/res/drawable-xhdpi/actionbar_shadow.9.png
new file mode 100644 (file)
index 0000000..30778e3
Binary files /dev/null and b/android/res/drawable-xhdpi/actionbar_shadow.9.png differ
diff --git a/android/res/drawable-xhdpi/or_launcher.png b/android/res/drawable-xhdpi/or_launcher.png
new file mode 100644 (file)
index 0000000..77464db
Binary files /dev/null and b/android/res/drawable-xhdpi/or_launcher.png differ
diff --git a/android/res/drawable/actionbar_compat_item.xml b/android/res/drawable/actionbar_compat_item.xml
new file mode 100644 (file)
index 0000000..4b3960c
--- /dev/null
@@ -0,0 +1,23 @@
+<!--
+  Copyright 2011 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:drawable="@drawable/actionbar_compat_item_pressed"
+        android:state_pressed="true" />
+    <item android:drawable="@drawable/actionbar_compat_item_focused"
+        android:state_focused="true" />
+    <item android:drawable="@android:color/transparent" />
+</selector>
diff --git a/android/res/drawable/actionbar_compat_item_focused.xml b/android/res/drawable/actionbar_compat_item_focused.xml
new file mode 100644 (file)
index 0000000..04811d3
--- /dev/null
@@ -0,0 +1,19 @@
+<!--
+  Copyright 2011 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <solid android:color="#ef7000" />
+</shape>
diff --git a/android/res/drawable/actionbar_compat_item_pressed.xml b/android/res/drawable/actionbar_compat_item_pressed.xml
new file mode 100644 (file)
index 0000000..72ff4b4
--- /dev/null
@@ -0,0 +1,19 @@
+<!--
+  Copyright 2011 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <solid android:color="#eda700" />
+</shape>
diff --git a/android/res/drawable/home_item.xml b/android/res/drawable/home_item.xml
new file mode 100644 (file)
index 0000000..9afcd5a
--- /dev/null
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<bitmap  xmlns:android="http://schemas.android.com/apk/res/android"
+    android:src="@drawable/or_launcher"/>
diff --git a/android/res/drawable/or_launcher.png b/android/res/drawable/or_launcher.png
deleted file mode 100644 (file)
index 77464db..0000000
Binary files a/android/res/drawable/or_launcher.png and /dev/null differ
diff --git a/android/res/layout-v11/actionbar_indeterminate_progress.xml b/android/res/layout-v11/actionbar_indeterminate_progress.xml
new file mode 100644 (file)
index 0000000..c05750e
--- /dev/null
@@ -0,0 +1,27 @@
+<!--
+  Copyright 2011 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:gravity="center">
+    <ProgressBar android:layout_width="32dp"
+        android:layout_height="32dp"
+        android:layout_marginLeft="12dp"
+        android:layout_marginRight="12dp"
+        android:layout_gravity="center"
+        style="?android:attr/indeterminateProgressStyle" />
+</FrameLayout>
index 5ecb9d73452cf2a0372f84151fa274090ef8032d..648162451a5d1c885e9a260e4368115b881ffee0 100644 (file)
@@ -4,42 +4,23 @@
     android:layout_height="match_parent"\r
     android:orientation="horizontal" >\r
 \r
-    <TabHost\r
-        android:id="@android:id/tabhost"\r
-        android:layout_width="match_parent"\r
+    <android.support.v4.view.ViewPager\r
+        android:id="@+id/pager"\r
         android:layout_weight="4"\r
+        android:layout_width="match_parent"\r
         android:layout_height="match_parent" >\r
 \r
-        <LinearLayout\r
+        <android.support.v4.view.PagerTitleStrip\r
             android:layout_width="match_parent"\r
             android:layout_height="match_parent"\r
-            android:orientation="vertical" >\r
-\r
-            <TabWidget\r
-                android:id="@android:id/tabs"\r
-                android:layout_width="match_parent"\r
-                android:layout_height="wrap_content"\r
-                android:layout_weight="0"\r
-                android:orientation="horizontal" />\r
+            android:layout_gravity="top" />\r
+    </android.support.v4.view.ViewPager>\r
 \r
-            <FrameLayout\r
-                android:id="@android:id/tabcontent"\r
-                android:layout_width="0dp"\r
-                android:layout_height="0dp"\r
-                android:layout_weight="0" />\r
-\r
-            <android.support.v4.view.ViewPager\r
-                android:id="@+id/pager"\r
-                android:layout_width="match_parent"\r
-                android:layout_height="0dp"\r
-                android:layout_weight="1" />\r
-        </LinearLayout>\r
-    </TabHost>\r
-    \r
-    <LinearLayout android:id="@+id/sidepane"\r
+    <LinearLayout\r
+        android:id="@+id/sidepane"\r
         android:layout_width="wrap_content"\r
-        android:layout_weight="1"\r
         android:layout_height="wrap_content"\r
-        android:orientation="vertical"/>\r
+        android:layout_weight="1"\r
+        android:orientation="vertical" />\r
 \r
 </LinearLayout>
\ No newline at end of file
index 055b97487c4c76b630df227d60e466c2a69cb993..f0b7ac936cee96a4c03cf99c673250299528ab0a 100644 (file)
@@ -4,42 +4,23 @@
     android:layout_height="match_parent"\r
     android:orientation="vertical" >\r
 \r
-    <TabHost\r
-        android:id="@android:id/tabhost"\r
+    <android.support.v4.view.ViewPager\r
+        android:id="@+id/pager"\r
         android:layout_width="match_parent"\r
-        android:layout_weight="4"\r
-        android:layout_height="match_parent" >\r
+        android:layout_height="match_parent"\r
+        android:layout_weight="3" >\r
 \r
-        <LinearLayout\r
+        <android.support.v4.view.PagerTitleStrip\r
             android:layout_width="match_parent"\r
             android:layout_height="match_parent"\r
-            android:orientation="vertical" >\r
+            android:layout_gravity="top" />\r
+    </android.support.v4.view.ViewPager>\r
 \r
-            <TabWidget\r
-                android:id="@android:id/tabs"\r
-                android:layout_width="match_parent"\r
-                android:layout_height="wrap_content"\r
-                android:layout_weight="0"\r
-                android:orientation="horizontal" />\r
-\r
-            <FrameLayout\r
-                android:id="@android:id/tabcontent"\r
-                android:layout_width="0dp"\r
-                android:layout_height="0dp"\r
-                android:layout_weight="0" />\r
-\r
-            <android.support.v4.view.ViewPager\r
-                android:id="@+id/pager"\r
-                android:layout_width="match_parent"\r
-                android:layout_height="0dp"\r
-                android:layout_weight="1" />\r
-        </LinearLayout>\r
-    </TabHost>\r
-    \r
-    <LinearLayout android:id="@+id/sidepane"\r
+    <LinearLayout\r
+        android:id="@+id/sidepane"\r
         android:layout_width="wrap_content"\r
-        android:layout_weight="1"\r
         android:layout_height="wrap_content"\r
-        android:orientation="vertical"/>\r
+        android:layout_weight="1"\r
+        android:orientation="vertical" />\r
 \r
 </LinearLayout>
\ No newline at end of file
diff --git a/android/res/layout/actionbar_compat.xml b/android/res/layout/actionbar_compat.xml
new file mode 100644 (file)
index 0000000..7e504d9
--- /dev/null
@@ -0,0 +1,22 @@
+<!--
+  Copyright 2011 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@id/actionbar_compat"
+    android:background="#ff000000"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="horizontal" />
index 5b8e3a1a60b201cc8eb6055d2491af2768aa7390..a51b1291306bbec0e9336450586f8b17ea805170 100644 (file)
@@ -3,8 +3,8 @@
     android:id="@+id/xyplot"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
-    android:layout_marginLeft="0px"
-    android:layout_marginRight="0px"
-    android:layout_marginTop="5px"
-    title="plot"
+    android:layout_marginLeft="2dp"
+    android:layout_marginRight="2dp"
+    android:layout_marginTop="5dp"
+    title="                                                                              "
 />
index efb2b6be5ad84785974a4dc19cd455155c3b650f..105284ef47d2e0a25d2a561900b0cc4ba8d2c40d 100644 (file)
@@ -1,33 +1,18 @@
 <?xml version="1.0" encoding="utf-8"?>\r
-<TabHost\r
-    xmlns:android="http://schemas.android.com/apk/res/android"\r
-    android:id="@android:id/tabhost"\r
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
     android:layout_width="match_parent"\r
-    android:layout_height="match_parent">\r
+    android:layout_height="match_parent"\r
+    android:orientation="vertical" >\r
 \r
-    <LinearLayout\r
-        android:orientation="vertical"\r
+    <android.support.v4.view.ViewPager\r
+        android:id="@+id/pager"\r
         android:layout_width="match_parent"\r
-        android:layout_height="match_parent">\r
+        android:layout_height="match_parent" >\r
 \r
-        <TabWidget\r
-            android:id="@android:id/tabs"\r
-            android:orientation="horizontal"\r
+        <android.support.v4.view.PagerTitleStrip\r
             android:layout_width="match_parent"\r
-            android:layout_height="wrap_content"\r
-            android:layout_weight="0"/>\r
+            android:layout_height="match_parent"\r
+            android:layout_gravity="top"/>\r
+    </android.support.v4.view.ViewPager>\r
 \r
-        <FrameLayout\r
-            android:id="@android:id/tabcontent"\r
-            android:layout_width="0dp"\r
-            android:layout_height="0dp"\r
-            android:layout_weight="0"/>\r
-\r
-        <android.support.v4.view.ViewPager\r
-            android:id="@+id/pager"\r
-            android:layout_width="match_parent"\r
-            android:layout_height="0dp"\r
-            android:layout_weight="1"/>\r
-\r
-    </LinearLayout>\r
-</TabHost>\r
+</LinearLayout>
\ No newline at end of file
index 7eca8962d9506ea77e6a50f93a0d476782d619cd..a9cb3ffa3376e5b0d49adf52d9657f65b45d095f 100644 (file)
         android:orientation="vertical" >\r
 \r
         <TextView\r
+            style="@style/labelTextStyle"\r
             android:layout_width="match_parent"\r
             android:layout_height="wrap_content"\r
             android:text="Designer" />\r
 \r
         <TextView\r
+            style="@style/valueTextStyle"\r
             android:id="@+id/openrocketviewerDesigner"\r
             android:layout_width="match_parent"\r
             android:layout_height="wrap_content"\r
             android:text="" />\r
 \r
         <TextView\r
+            style="@style/labelTextStyle"\r
             android:layout_width="match_parent"\r
             android:layout_height="wrap_content"\r
             android:text="Length" />\r
 \r
         <TextView\r
+            style="@style/valueTextStyle"\r
             android:id="@+id/openrocketviewerLength"\r
             android:layout_width="match_parent"\r
             android:layout_height="wrap_content"\r
             android:text="" />\r
 \r
         <TextView\r
+            style="@style/labelTextStyle"\r
             android:layout_width="match_parent"\r
             android:layout_height="wrap_content"\r
             android:text="Empty Mass" />\r
 \r
         <TextView\r
+            style="@style/valueTextStyle"\r
             android:id="@+id/openrocketviewerMass"\r
             android:layout_width="match_parent"\r
             android:layout_height="wrap_content"\r
             android:text="" />\r
 \r
         <TextView\r
+            style="@style/labelTextStyle"\r
             android:layout_width="match_parent"\r
             android:layout_height="wrap_content"\r
             android:text="Stage Count" />\r
 \r
         <TextView\r
+            style="@style/valueTextStyle"\r
             android:id="@+id/openrocketviewerStageCount"\r
             android:layout_width="match_parent"\r
             android:layout_height="wrap_content"\r
         <Spinner\r
             android:id="@+id/openrocketviewerConfigurationSpinner"\r
             android:layout_width="match_parent"\r
-            android:layout_height="wrap_content" />\r
+            android:layout_height="wrap_content"\r
+            android:prompt="@string/overviewConfigurationSpinnerPrompt" />\r
 \r
         <TextView\r
+            style="@style/labelTextStyle"\r
             android:layout_width="match_parent"\r
             android:layout_height="wrap_content"\r
             android:text="Lift off weight" />\r
 \r
         <TextView\r
+            style="@style/valueTextStyle"\r
             android:id="@+id/openrocketviewerLiftOffWeight"\r
             android:layout_width="match_parent"\r
             android:layout_height="wrap_content"\r
             android:text="" />\r
 \r
         <TextView\r
+            style="@style/labelTextStyle"\r
             android:layout_width="match_parent"\r
             android:layout_height="wrap_content"\r
             android:text="CG" />\r
 \r
         <TextView\r
+            style="@style/valueTextStyle"\r
             android:id="@+id/openrocketviewerCG"\r
             android:layout_width="match_parent"\r
             android:layout_height="wrap_content"\r
             android:text="" />\r
 \r
         <TextView\r
+            style="@style/labelTextStyle"\r
             android:layout_width="match_parent"\r
             android:layout_height="wrap_content"\r
             android:text="CP" />\r
 \r
         <TextView\r
+            style="@style/valueTextStyle"\r
             android:id="@+id/openrocketviewerCP"\r
             android:layout_width="match_parent"\r
             android:layout_height="wrap_content"\r
             android:text="" />\r
 \r
         <TextView\r
+            style="@style/labelTextStyle"\r
             android:layout_width="match_parent"\r
             android:layout_height="wrap_content"\r
             android:text="Stability margin" />\r
 \r
         <TextView\r
+            style="@style/valueTextStyle"\r
             android:id="@+id/openrocketviewerStabilityMargin"\r
             android:layout_width="match_parent"\r
             android:layout_height="wrap_content"\r
index 3d89e59f7161977a23cdcafe317ba4f7143da808..7fad576b2dda39a7d818050dfd4a5acaf628092e 100644 (file)
@@ -4,11 +4,6 @@
     android:layout_height="fill_parent"\r
     android:orientation="vertical" >\r
 \r
-    <TextView\r
-        android:id="@+id/path"\r
-        android:layout_width="fill_parent"\r
-        android:layout_height="wrap_content" />\r
-\r
     <ListView\r
         android:id="@android:id/list"\r
         android:layout_width="fill_parent"\r
index 5640418143bf5ca4a9b6367414553935ac918332..0b28cfd6e547a54956541dda29cbfc5fd7f98bbd 100644 (file)
@@ -6,7 +6,7 @@
 
     <!--  shim to get dialog correct size ?? -->
     <View
-        android:layout_width="2000dp"
+        android:layout_width="200dp"
         android:layout_height="0px"
         android:layout_margin="0px"
         android:orientation="horizontal" />
index f378ed0f9fa4385ac18860520924aae29b386de5..1e40af72a4ae66a3525cbe15756ce6f2511398e3 100644 (file)
@@ -1,15 +1,10 @@
 <?xml version="1.0" encoding="utf-8"?>\r
 <menu xmlns:android="http://schemas.android.com/apk/res/android" >\r
 \r
-    <item\r
-        android:id="@+id/main_menu_open"\r
-        android:title="Open"/>\r
-    <item\r
-        android:id="@+id/main_menu_motor"\r
-        android:title="Motor"/>\r
     <item\r
         android:id="@+id/main_menu_preferences"\r
         android:title="@string/Preferences"\r
-        android:icon="@drawable/ic_menu_preferences"/>\r
+        android:icon="@drawable/ic_menu_preferences"\r
+        android:showAsAction="always"/>\r
 \r
 </menu>
\ No newline at end of file
index 154bd5955b94e4c4e5412c91546b2548273af9d5..05b6e96b3ea2f813d0728f8a1bf12fb5f00e024f 100644 (file)
@@ -7,6 +7,7 @@
     <item
         android:id="@+id/preference_menu_option"
         android:icon="@drawable/ic_menu_preferences"
-        android:title="@string/Preferences"/>
+        android:title="@string/Preferences"
+        />
 
 </menu>
\ No newline at end of file
index 4ebd72d47564695f0272d608b8ebfc9bda4b62c9..0afdcd1463b2e9601f11d427effb617487b499cb 100644 (file)
@@ -3,7 +3,8 @@
 \r
     <item\r
         android:id="@+id/motor_list_menu_option"\r
-        android:title="Motor List"/>\r
+        android:title="Motor List"\r
+        android:showAsAction="always"/>\r
     <item\r
         android:id="@+id/preference_menu_option"\r
         android:title="@string/Preferences"\r
diff --git a/android/res/values-v11/styles.xml b/android/res/values-v11/styles.xml
new file mode 100644 (file)
index 0000000..3888fc5
--- /dev/null
@@ -0,0 +1,34 @@
+<!--
+  Copyright 2011 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<resources>
+
+    <style name="AppTheme" parent="android:style/Theme.Holo">
+        <item name="android:actionBarStyle">@style/ActionBar</item>
+        <item name="android:windowContentOverlay">@drawable/actionbar_shadow</item>
+    </style>
+
+    <style name="ActionBar" parent="android:style/Widget.Holo.ActionBar">
+        <item name="android:background">@color/actionbar_background_color</item>
+        <item name="android:titleTextStyle">@style/ActionBarTitle</item>
+        <item name="android:logo">@drawable/home_item</item>
+    </style>
+
+    <style name="ActionBarTitle">
+        <item name="android:textColor">@color/actionbar_title_color</item>
+    </style>
+
+</resources>
\ No newline at end of file
diff --git a/android/res/values-v13/styles.xml b/android/res/values-v13/styles.xml
new file mode 100644 (file)
index 0000000..69466f3
--- /dev/null
@@ -0,0 +1,24 @@
+<!--
+  Copyright 2011 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<resources>
+
+    <style name="ActionBarTitle" parent="android:style/TextAppearance.Holo.Widget.ActionBar.Title">
+        <item name="android:textColor">@color/actionbar_title_color</item>
+        <item name="android:background">@color/actionbar_background_color</item>
+    </style>
+
+</resources>
\ No newline at end of file
diff --git a/android/res/values/actionbar_attrs.xml b/android/res/values/actionbar_attrs.xml
new file mode 100644 (file)
index 0000000..d731929
--- /dev/null
@@ -0,0 +1,27 @@
+<!--
+  Copyright 2011 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<resources>
+
+    <declare-styleable name="AppTheme">
+        <attr name="actionbarCompatHomeAsUpStyle" format="reference" />
+        <attr name="actionbarCompatTitleStyle" format="reference" />
+        <attr name="actionbarCompatItemStyle" format="reference" />
+        <attr name="actionbarCompatItemHomeStyle" format="reference" />
+        <attr name="actionbarCompatProgressIndicatorStyle" format="reference" />
+    </declare-styleable>
+
+</resources>
diff --git a/android/res/values/actionbar_colors.xml b/android/res/values/actionbar_colors.xml
new file mode 100644 (file)
index 0000000..5748817
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<resources>
+
+    <color name="actionbar_title_color">#FFFFFF</color>
+    <color name="actionbar_background_color">#ff000000</color>
+    
+</resources>
diff --git a/android/res/values/actionbar_dimens.xml b/android/res/values/actionbar_dimens.xml
new file mode 100644 (file)
index 0000000..d0960f0
--- /dev/null
@@ -0,0 +1,21 @@
+<!--
+  Copyright 2011 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<resources>
+    <dimen name="actionbar_compat_height">48dp</dimen>
+    <dimen name="actionbar_compat_button_width">48dp</dimen>
+    <dimen name="actionbar_compat_button_home_width">40dp</dimen>
+</resources>
diff --git a/android/res/values/actionbar_ids.xml b/android/res/values/actionbar_ids.xml
new file mode 100644 (file)
index 0000000..d0c0897
--- /dev/null
@@ -0,0 +1,24 @@
+<!--
+  Copyright 2011 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<resources>
+    <item type="id" name="actionbar_compat" />
+    <item type="id" name="actionbar_home_as_up" />
+    <item type="id" name="actionbar_compat_title" />
+    <item type="id" name="actionbar_compat_item_refresh_progress" />
+    <item type="id" name="actionbar_compat_item_refresh" />
+    <item type="id" name="menu_refresh" />
+</resources>
diff --git a/android/res/values/actionbar_styles.xml b/android/res/values/actionbar_styles.xml
new file mode 100644 (file)
index 0000000..81effec
--- /dev/null
@@ -0,0 +1,72 @@
+<!--\r
+  Copyright 2011 The Android Open Source Project\r
+\r
+  Licensed under the Apache License, Version 2.0 (the "License");\r
+  you may not use this file except in compliance with the License.\r
+  You may obtain a copy of the License at\r
+\r
+      http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+  Unless required by applicable law or agreed to in writing, software\r
+  distributed under the License is distributed on an "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  See the License for the specific language governing permissions and\r
+  limitations under the License.\r
+  -->\r
+\r
+<resources>\r
+\r
+    <style name="AppTheme" parent="android:style/Theme">\r
+        <item name="android:textColor">#FFFFFF</item>\r
+        <item name="android:windowTitleSize">@dimen/actionbar_compat_height</item>\r
+        <item name="android:windowTitleBackgroundStyle">@style/ActionBarCompat</item>\r
+        <item name="android:windowContentOverlay">@drawable/actionbar_shadow</item>\r
+\r
+        <!-- for programmatic instantiation -->\r
+        <item name="actionbarCompatTitleStyle">@style/ActionBarCompatTitle</item>\r
+        <item name="actionbarCompatItemStyle">@style/ActionBarCompatItem</item>\r
+        <item name="actionbarCompatItemHomeStyle">@style/ActionBarCompatHomeItem</item>\r
+        <item name="actionbarCompatProgressIndicatorStyle">@style/ActionBarCompatProgressIndicator</item>\r
+        <item name="actionbarCompatHomeAsUpStyle">@style/ActionBarCompatHomeAsUp</item>\r
+    </style>\r
+\r
+    <style name="ActionBarCompat">\r
+        <item name="android:background">@color/actionbar_background_color</item>\r
+    </style>\r
+\r
+    <style name="ActionBarCompatHomeAsUp">\r
+        <item name="android:background">@drawable/ic_home_carat</item>\r
+    </style>\r
+    \r
+    <style name="ActionBarCompatItemBase">\r
+        <!-- layout_width/height must be set in code -->\r
+        <item name="android:scaleType">center</item>\r
+        <item name="android:background">@drawable/actionbar_compat_item</item>\r
+    </style>\r
+\r
+    <style name="ActionBarCompatProgressIndicator" parent="android:style/Widget.ProgressBar.Large">\r
+        <item name="android:indeterminate">true</item>\r
+    </style>\r
+\r
+    <style name="ActionBarCompatTitleBase">\r
+        <item name="android:id">@id/actionbar_compat_title</item>\r
+        <!-- layout_width/height/weight must be set in code -->\r
+        <item name="android:gravity">center_vertical</item>\r
+        <item name="android:textSize">16sp</item>\r
+        <item name="android:paddingLeft">6dp</item>\r
+        <item name="android:paddingRight">6dp</item>\r
+        <item name="android:singleLine">true</item>\r
+        <item name="android:ellipsize">marquee</item>\r
+    </style>\r
+\r
+    <style name="ActionBarCompatTitle" parent="style/ActionBarCompatTitleBase">\r
+        <item name="android:textColor">@color/actionbar_title_color</item>\r
+    </style>\r
+\r
+    <style name="ActionBarCompatItem" parent="style/ActionBarCompatItemBase">\r
+    </style>\r
+\r
+    <style name="ActionBarCompatHomeItem" parent="style/ActionBarCompatItemBase">\r
+    </style>\r
+\r
+</resources>\r
index eeb1b49440f383078c1ea054736db592dfddb108..46a5104fe853ba1e9c3d278ddfa91bf56823ad51 100644 (file)
 \r
     <string name="TCMotorSearchFormSubmit">Submit</string>\r
     <string name="tcdownload">Download from ThrustCurve</string>\r
+    <string name="overviewConfigurationSpinnerPrompt">Select Configuration</string>\r
     <string name="simulationSeries1Label">Series 1</string>\r
     <string name="simulationSeries2Label">Series 2</string>\r
 \r
     <string name="motorbrowsergrouptitle">Motor Browser Grouping</string>\r
     <string name="useinternalfilebrowsertitle">Use Internal File Browser</string>\r
-    <string name="useinternalfilebrowsersummary">uncheck to use system file browser if available</string>\r
+    <string name="useinternalfilebrowsersummary">Check to use built in file browser instead of external file browser</string>\r
     \r
     <string-array name="PreferenceUnitLengthEntries">\r
         <item>Millimeters</item>\r
index 005c60078f033eecdad3176793d78e3014283445..761a4e1fb003f4aa955aa4ec2fb155fbbde27f6e 100644 (file)
@@ -1,7 +1,17 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
-    <style parent="@android:attr/listViewStyle" name="treeViewListStyle">
+
+    <style name="treeViewListStyle" parent="@android:attr/listViewStyle">
         <item name="android:background">@android:color/white</item>
         <item name="android:divider">@drawable/divider</item>
     </style>
-</resources>
+
+    <style name="labelTextStyle" parent="@android:style/TextAppearance.Medium" />
+
+    <style name="valueTextStyle" parent="@android:style/TextAppearance.Large" />
+
+    <style name="AppTheme.NoTitleBar" parent="@style/AppTheme">
+        <item name="android:windowNoTitle">true</item>
+    </style>
+
+</resources>
\ No newline at end of file
index 8dacde3afb6aa9b4b0543a8f8be11226bc7dec8f..ee76e9a8387c43a008f65a09f8046dd33dcd4248 100644 (file)
@@ -51,12 +51,6 @@ public class Main extends FragmentActivity {
        @Override\r
        public boolean onOptionsItemSelected(MenuItem item) {\r
                switch( item.getItemId() ) {\r
-               case R.id.main_menu_motor:\r
-                       ActivityHelpers.browseMotors(this);\r
-                       return true;\r
-               case R.id.main_menu_open:\r
-                       pickOrkFiles();\r
-                       return true;\r
                case R.id.main_menu_preferences:\r
                        ActivityHelpers.startPreferences(this);\r
                        return true;\r
diff --git a/android/src/net/sf/openrocket/android/actionbarcompat/ActionBarActivity.java b/android/src/net/sf/openrocket/android/actionbarcompat/ActionBarActivity.java
new file mode 100644 (file)
index 0000000..a3bad47
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.sf.openrocket.android.actionbarcompat;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuInflater;
+
+/**
+ * A base activity that defers common functionality across app activities to an {@link
+ * ActionBarHelper}.
+ *
+ * NOTE: dynamically marking menu items as invisible/visible is not currently supported.
+ *
+ * NOTE: this may used with the Android Compatibility Package by extending
+ * android.support.v4.app.FragmentActivity instead of {@link Activity}.
+ */
+public abstract class ActionBarActivity extends Activity {
+    final ActionBarHelper mActionBarHelper = ActionBarHelper.createInstance(this);
+
+    /**
+     * Returns the {@link ActionBarHelper} for this activity.
+     */
+    protected ActionBarHelper getActionBarHelper() {
+        return mActionBarHelper;
+    }
+
+    /**{@inheritDoc}*/
+    @Override
+    public MenuInflater getMenuInflater() {
+        return mActionBarHelper.getMenuInflater(super.getMenuInflater());
+    }
+
+    /**{@inheritDoc}*/
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mActionBarHelper.onCreate(savedInstanceState);
+    }
+
+    /**{@inheritDoc}*/
+    @Override
+    protected void onPostCreate(Bundle savedInstanceState) {
+        super.onPostCreate(savedInstanceState);
+        mActionBarHelper.onPostCreate(savedInstanceState);
+    }
+
+    /**
+     * Base action bar-aware implementation for
+     * {@link Activity#onCreateOptionsMenu(android.view.Menu)}.
+     *
+     * Note: marking menu items as invisible/visible is not currently supported.
+     */
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        boolean retValue = false;
+        retValue |= mActionBarHelper.onCreateOptionsMenu(menu);
+        retValue |= super.onCreateOptionsMenu(menu);
+        return retValue;
+    }
+
+    /**{@inheritDoc}*/
+    @Override
+    protected void onTitleChanged(CharSequence title, int color) {
+        mActionBarHelper.onTitleChanged(title, color);
+        super.onTitleChanged(title, color);
+    }
+}
diff --git a/android/src/net/sf/openrocket/android/actionbarcompat/ActionBarFragmentActivity.java b/android/src/net/sf/openrocket/android/actionbarcompat/ActionBarFragmentActivity.java
new file mode 100644 (file)
index 0000000..526c962
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.sf.openrocket.android.actionbarcompat;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+import android.view.Menu;
+import android.view.MenuInflater;
+
+/**
+ * A base activity that defers common functionality across app activities to an {@link
+ * ActionBarHelper}.
+ *
+ * NOTE: dynamically marking menu items as invisible/visible is not currently supported.
+ *
+ * NOTE: this may used with the Android Compatibility Package by extending
+ * android.support.v4.app.FragmentActivity instead of {@link Activity}.
+ */
+public abstract class ActionBarFragmentActivity extends FragmentActivity {
+    final ActionBarHelper mActionBarHelper = ActionBarHelper.createInstance(this);
+
+    /**
+     * Returns the {@link ActionBarHelper} for this activity.
+     */
+    protected ActionBarHelper getActionBarHelper() {
+        return mActionBarHelper;
+    }
+
+    /**{@inheritDoc}*/
+    @Override
+    public MenuInflater getMenuInflater() {
+        return mActionBarHelper.getMenuInflater(super.getMenuInflater());
+    }
+
+    /**{@inheritDoc}*/
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mActionBarHelper.onCreate(savedInstanceState);
+    }
+
+    /**{@inheritDoc}*/
+    @Override
+    protected void onPostCreate(Bundle savedInstanceState) {
+        super.onPostCreate(savedInstanceState);
+        mActionBarHelper.onPostCreate(savedInstanceState);
+    }
+
+    /**
+     * Base action bar-aware implementation for
+     * {@link Activity#onCreateOptionsMenu(android.view.Menu)}.
+     *
+     * Note: marking menu items as invisible/visible is not currently supported.
+     */
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        boolean retValue = false;
+        retValue |= mActionBarHelper.onCreateOptionsMenu(menu);
+        retValue |= super.onCreateOptionsMenu(menu);
+        return retValue;
+    }
+
+    /**{@inheritDoc}*/
+    @Override
+    protected void onTitleChanged(CharSequence title, int color) {
+        mActionBarHelper.onTitleChanged(title, color);
+        super.onTitleChanged(title, color);
+    }
+}
diff --git a/android/src/net/sf/openrocket/android/actionbarcompat/ActionBarHelper.java b/android/src/net/sf/openrocket/android/actionbarcompat/ActionBarHelper.java
new file mode 100644 (file)
index 0000000..e0595d8
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.sf.openrocket.android.actionbarcompat;
+
+import net.sf.openrocket.R;
+import android.app.Activity;
+import android.os.Build;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuInflater;
+
+/**
+ * An abstract class that handles some common action bar-related functionality in the app. This
+ * class provides functionality useful for both phones and tablets, and does not require any Android
+ * 3.0-specific features, although it uses them if available.
+ *
+ * Two implementations of this class are {@link ActionBarHelperBase} for a pre-Honeycomb version of
+ * the action bar, and {@link ActionBarHelperHoneycomb}, which uses the built-in ActionBar features
+ * in Android 3.0 and later.
+ */
+public abstract class ActionBarHelper {
+    protected Activity mActivity;
+
+    /**
+     * Factory method for creating {@link ActionBarHelper} objects for a
+     * given activity. Depending on which device the app is running, either a basic helper or
+     * Honeycomb-specific helper will be returned.
+     */
+    public static ActionBarHelper createInstance(Activity activity) {
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+            return new ActionBarHelperICS(activity);
+        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
+            return new ActionBarHelperHoneycomb(activity);
+        } else {
+            return new ActionBarHelperBase(activity);
+        }
+    }
+
+    protected ActionBarHelper(Activity activity) {
+        mActivity = activity;
+    }
+
+    /**
+     * Action bar helper code to be run in {@link Activity#onCreate(android.os.Bundle)}.
+     */
+    public void onCreate(Bundle savedInstanceState) {
+    }
+
+    /**
+     * Action bar helper code to be run in {@link Activity#onPostCreate(android.os.Bundle)}.
+     */
+    public void onPostCreate(Bundle savedInstanceState) {
+    }
+
+    /**
+     * Action bar helper code to be run in {@link Activity#onCreateOptionsMenu(android.view.Menu)}.
+     *
+     * NOTE: Setting the visibility of menu items in <em>menu</em> is not currently supported.
+     */
+    public boolean onCreateOptionsMenu(Menu menu) {
+        return true;
+    }
+
+    /**
+     * Action bar helper code to be run in {@link Activity#onTitleChanged(CharSequence, int)}.
+     */
+    protected void onTitleChanged(CharSequence title, int color) {
+    }
+
+    /**
+     * Sets the indeterminate loading state of the item with ID {@link R.id.menu_refresh}.
+     * (where the item ID was menu_refresh).
+     */
+    public abstract void setRefreshActionItemState(boolean refreshing);
+
+    /**
+     * Returns a {@link MenuInflater} for use when inflating menus. The implementation of this
+     * method in {@link ActionBarHelperBase} returns a wrapped menu inflater that can read
+     * action bar metadata from a menu resource pre-Honeycomb.
+     */
+    public MenuInflater getMenuInflater(MenuInflater superMenuInflater) {
+        return superMenuInflater;
+    }
+    
+    public abstract void setDisplayHomeAsUpEnabled( boolean enabled );
+    
+    public abstract void hide();
+}
diff --git a/android/src/net/sf/openrocket/android/actionbarcompat/ActionBarHelperBase.java b/android/src/net/sf/openrocket/android/actionbarcompat/ActionBarHelperBase.java
new file mode 100644 (file)
index 0000000..6c8054f
--- /dev/null
@@ -0,0 +1,331 @@
+/*
+ * Copyright 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.sf.openrocket.android.actionbarcompat;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+import net.sf.openrocket.R;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.res.XmlResourceParser;
+import android.os.Bundle;
+import android.view.Gravity;
+import android.view.InflateException;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+
+/**
+ * A class that implements the action bar pattern for pre-Honeycomb devices.
+ */
+public class ActionBarHelperBase extends ActionBarHelper {
+    private static final String MENU_RES_NAMESPACE = "http://schemas.android.com/apk/res/android";
+    private static final String MENU_ATTR_ID = "id";
+    private static final String MENU_ATTR_SHOW_AS_ACTION = "showAsAction";
+    
+    private boolean showHomeAsUpEnabled = false;
+
+    protected Set<Integer> mActionItemIds = new HashSet<Integer>();
+
+    protected ActionBarHelperBase(Activity activity) {
+        super(activity);
+    }
+
+    /**{@inheritDoc}*/
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        mActivity.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
+    }
+
+    /**{@inheritDoc}*/
+    @Override
+    public void onPostCreate(Bundle savedInstanceState) {
+        mActivity.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
+                R.layout.actionbar_compat);
+        setupActionBar();
+
+        SimpleMenu menu = new SimpleMenu(mActivity);
+        mActivity.onCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, menu);
+        mActivity.onPrepareOptionsMenu(menu);
+        for (int i = 0; i < menu.size(); i++) {
+            MenuItem item = menu.getItem(i);
+            if (mActionItemIds.contains(item.getItemId())) {
+                addActionItemCompatFromMenuItem(item);
+            }
+        }
+    }
+
+    /**
+     * Sets up the compatibility action bar with the given title.
+     */
+    private void setupActionBar() {
+        final ViewGroup actionBarCompat = getActionBarCompat();
+        if (actionBarCompat == null) {
+            return;
+        }
+
+        LinearLayout.LayoutParams springLayoutParams = new LinearLayout.LayoutParams(
+                0, ViewGroup.LayoutParams.FILL_PARENT);
+        springLayoutParams.weight = 1;
+
+        // Add Home as Up Carat
+        ImageButton homeAsUp = new ImageButton(mActivity,null, R.attr.actionbarCompatHomeAsUpStyle);
+        homeAsUp.setId(R.id.actionbar_home_as_up);
+        LinearLayout.LayoutParams centerVerticalParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+        centerVerticalParams.gravity = Gravity.CENTER_VERTICAL;
+        homeAsUp.setLayoutParams(centerVerticalParams);
+        homeAsUp.setVisibility( showHomeAsUpEnabled ? View.VISIBLE : View.INVISIBLE );
+        actionBarCompat.addView(homeAsUp);
+        
+        // Add Home button
+        SimpleMenu tempMenu = new SimpleMenu(mActivity);
+        SimpleMenuItem homeItem = new SimpleMenuItem(
+                tempMenu, android.R.id.home, 0, mActivity.getString(R.string.app_name));
+        homeItem.setIcon(R.drawable.home_item);
+        addActionItemCompatFromMenuItem(homeItem);
+
+        // Add title text
+        TextView titleText = new TextView(mActivity, null, R.attr.actionbarCompatTitleStyle);
+        titleText.setLayoutParams(springLayoutParams);
+        titleText.setText(mActivity.getTitle());
+        actionBarCompat.addView(titleText);
+        
+    }
+
+    /**{@inheritDoc}*/
+    @Override
+    public void setRefreshActionItemState(boolean refreshing) {
+        View refreshButton = mActivity.findViewById(R.id.actionbar_compat_item_refresh);
+        View refreshIndicator = mActivity.findViewById(
+                R.id.actionbar_compat_item_refresh_progress);
+
+        if (refreshButton != null) {
+            refreshButton.setVisibility(refreshing ? View.GONE : View.VISIBLE);
+        }
+        if (refreshIndicator != null) {
+            refreshIndicator.setVisibility(refreshing ? View.VISIBLE : View.GONE);
+        }
+    }
+
+    /**
+     * Action bar helper code to be run in {@link Activity#onCreateOptionsMenu(android.view.Menu)}.
+     *
+     * NOTE: This code will mark on-screen menu items as invisible.
+     */
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        // Hides on-screen action items from the options menu.
+        for (Integer id : mActionItemIds) {
+            menu.findItem(id).setVisible(false);
+        }
+        return true;
+    }
+
+    /**{@inheritDoc}*/
+    @Override
+    protected void onTitleChanged(CharSequence title, int color) {
+        TextView titleView = (TextView) mActivity.findViewById(R.id.actionbar_compat_title);
+        if (titleView != null) {
+            titleView.setText(title);
+        }
+    }
+
+    /**
+     * Returns a {@link android.view.MenuInflater} that can read action bar metadata on
+     * pre-Honeycomb devices.
+     */
+    public MenuInflater getMenuInflater(MenuInflater superMenuInflater) {
+        return new WrappedMenuInflater(mActivity, superMenuInflater);
+    }
+
+    @Override
+       public void setDisplayHomeAsUpEnabled(boolean enabled) {
+       showHomeAsUpEnabled = enabled;
+       View v = mActivity.findViewById(R.id.actionbar_home_as_up);
+       if ( v != null ) {
+               v.setVisibility( showHomeAsUpEnabled ? View.VISIBLE : View.INVISIBLE );
+       }
+               
+       }
+
+    @Override
+    public void hide() {
+       ViewGroup actionbar = getActionBarCompat();
+       actionbar.setVisibility(View.GONE);
+    }
+       /**
+     * Returns the {@link android.view.ViewGroup} for the action bar on phones (compatibility action
+     * bar). Can return null, and will return null on Honeycomb.
+     */
+    private ViewGroup getActionBarCompat() {
+        return (ViewGroup) mActivity.findViewById(R.id.actionbar_compat);
+    }
+
+    /**
+     * Adds an action button to the compatibility action bar, using menu information from a {@link
+     * android.view.MenuItem}. If the menu item ID is <code>menu_refresh</code>, the menu item's
+     * state can be changed to show a loading spinner using
+     * {@link com.example.android.actionbarcompat.ActionBarHelperBase#setRefreshActionItemState(boolean)}.
+     */
+    private View addActionItemCompatFromMenuItem(final MenuItem item) {
+        final int itemId = item.getItemId();
+
+        final ViewGroup actionBar = getActionBarCompat();
+        if (actionBar == null) {
+            return null;
+        }
+
+        // Create the button
+        ImageButton actionButton = new ImageButton(mActivity, null,
+                itemId == android.R.id.home
+                        ? R.attr.actionbarCompatItemHomeStyle
+                        : R.attr.actionbarCompatItemStyle);
+        actionButton.setLayoutParams(new ViewGroup.LayoutParams(
+                (int) mActivity.getResources().getDimension(
+                        itemId == android.R.id.home
+                                ? R.dimen.actionbar_compat_button_home_width
+                                : R.dimen.actionbar_compat_button_width),
+                ViewGroup.LayoutParams.FILL_PARENT));
+        if (itemId == R.id.menu_refresh) {
+            actionButton.setId(R.id.actionbar_compat_item_refresh);
+        }
+        actionButton.setImageDrawable(item.getIcon());
+        actionButton.setScaleType(ImageView.ScaleType.CENTER);
+        actionButton.setContentDescription(item.getTitle());
+        actionButton.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View view) {
+                mActivity.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item);
+            }
+        });
+
+        actionBar.addView(actionButton);
+
+        if (item.getItemId() == R.id.menu_refresh) {
+            // Refresh buttons should be stateful, and allow for indeterminate progress indicators,
+            // so add those.
+            ProgressBar indicator = new ProgressBar(mActivity, null,
+                    R.attr.actionbarCompatProgressIndicatorStyle);
+
+            final int buttonWidth = mActivity.getResources().getDimensionPixelSize(
+                    R.dimen.actionbar_compat_button_width);
+            final int buttonHeight = mActivity.getResources().getDimensionPixelSize(
+                    R.dimen.actionbar_compat_height);
+            final int progressIndicatorWidth = buttonWidth / 2;
+
+            LinearLayout.LayoutParams indicatorLayoutParams = new LinearLayout.LayoutParams(
+                    progressIndicatorWidth, progressIndicatorWidth);
+            indicatorLayoutParams.setMargins(
+                    (buttonWidth - progressIndicatorWidth) / 2,
+                    (buttonHeight - progressIndicatorWidth) / 2,
+                    (buttonWidth - progressIndicatorWidth) / 2,
+                    0);
+            indicator.setLayoutParams(indicatorLayoutParams);
+            indicator.setVisibility(View.GONE);
+            indicator.setId(R.id.actionbar_compat_item_refresh_progress);
+            actionBar.addView(indicator);
+        }
+
+        return actionButton;
+    }
+
+    /**
+     * A {@link android.view.MenuInflater} that reads action bar metadata.
+     */
+    private class WrappedMenuInflater extends MenuInflater {
+        MenuInflater mInflater;
+
+        public WrappedMenuInflater(Context context, MenuInflater inflater) {
+            super(context);
+            mInflater = inflater;
+        }
+
+        @Override
+        public void inflate(int menuRes, Menu menu) {
+            loadActionBarMetadata(menuRes);
+            mInflater.inflate(menuRes, menu);
+        }
+
+        /**
+         * Loads action bar metadata from a menu resource, storing a list of menu item IDs that
+         * should be shown on-screen (i.e. those with showAsAction set to always or ifRoom).
+         * @param menuResId
+         */
+        private void loadActionBarMetadata(int menuResId) {
+            XmlResourceParser parser = null;
+            try {
+                parser = mActivity.getResources().getXml(menuResId);
+
+                int eventType = parser.getEventType();
+                int itemId;
+                int showAsAction;
+
+                boolean eof = false;
+                while (!eof) {
+                    switch (eventType) {
+                        case XmlPullParser.START_TAG:
+                            if (!parser.getName().equals("item")) {
+                                break;
+                            }
+
+                            itemId = parser.getAttributeResourceValue(MENU_RES_NAMESPACE,
+                                    MENU_ATTR_ID, 0);
+                            if (itemId == 0) {
+                                break;
+                            }
+
+                            showAsAction = parser.getAttributeIntValue(MENU_RES_NAMESPACE,
+                                    MENU_ATTR_SHOW_AS_ACTION, -1);
+                            if (showAsAction == MenuItem.SHOW_AS_ACTION_ALWAYS ||
+                                    showAsAction == MenuItem.SHOW_AS_ACTION_IF_ROOM) {
+                                mActionItemIds.add(itemId);
+                            }
+                            break;
+
+                        case XmlPullParser.END_DOCUMENT:
+                            eof = true;
+                            break;
+                    }
+
+                    eventType = parser.next();
+                }
+            } catch (XmlPullParserException e) {
+                throw new InflateException("Error inflating menu XML", e);
+            } catch (IOException e) {
+                throw new InflateException("Error inflating menu XML", e);
+            } finally {
+                if (parser != null) {
+                    parser.close();
+                }
+            }
+        }
+
+    }
+}
diff --git a/android/src/net/sf/openrocket/android/actionbarcompat/ActionBarHelperHoneycomb.java b/android/src/net/sf/openrocket/android/actionbarcompat/ActionBarHelperHoneycomb.java
new file mode 100644 (file)
index 0000000..e31a4f9
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.sf.openrocket.android.actionbarcompat;
+
+import net.sf.openrocket.R;
+import android.app.Activity;
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+
+/**
+ * An extension of {@link ActionBarHelper} that provides Android 3.0-specific functionality for
+ * Honeycomb tablets. It thus requires API level 11.
+ */
+public class ActionBarHelperHoneycomb extends ActionBarHelper {
+    private Menu mOptionsMenu;
+    private View mRefreshIndeterminateProgressView = null;
+
+    protected ActionBarHelperHoneycomb(Activity activity) {
+        super(activity);
+    }
+
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        mOptionsMenu = menu;
+        return super.onCreateOptionsMenu(menu);
+    }
+
+    @Override
+    public void setRefreshActionItemState(boolean refreshing) {
+        // On Honeycomb, we can set the state of the refresh button by giving it a custom
+        // action view.
+        if (mOptionsMenu == null) {
+            return;
+        }
+
+        final MenuItem refreshItem = mOptionsMenu.findItem(R.id.menu_refresh);
+        if (refreshItem != null) {
+            if (refreshing) {
+                if (mRefreshIndeterminateProgressView == null) {
+                    LayoutInflater inflater = (LayoutInflater)
+                            getActionBarThemedContext().getSystemService(
+                                    Context.LAYOUT_INFLATER_SERVICE);
+                    mRefreshIndeterminateProgressView = inflater.inflate(
+                            R.layout.actionbar_indeterminate_progress, null);
+                }
+
+                refreshItem.setActionView(mRefreshIndeterminateProgressView);
+            } else {
+                refreshItem.setActionView(null);
+            }
+        }
+    }
+
+    /**
+     * Returns a {@link Context} suitable for inflating layouts for the action bar. The
+     * implementation for this method in {@link ActionBarHelperICS} asks the action bar for a
+     * themed context.
+     */
+    protected Context getActionBarThemedContext() {
+        return mActivity;
+    }
+
+       @Override
+       public void setDisplayHomeAsUpEnabled(boolean enabled) {
+               mActivity.getActionBar().setDisplayHomeAsUpEnabled(enabled);
+       }
+    
+       @Override
+       public void hide() {
+               mActivity.getActionBar().hide();
+       }
+    
+}
diff --git a/android/src/net/sf/openrocket/android/actionbarcompat/ActionBarHelperICS.java b/android/src/net/sf/openrocket/android/actionbarcompat/ActionBarHelperICS.java
new file mode 100644 (file)
index 0000000..7d00612
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.sf.openrocket.android.actionbarcompat;
+
+import android.app.Activity;
+import android.content.Context;
+
+/**
+ * An extension of {@link com.example.android.actionbarcompat.ActionBarHelper} that provides Android
+ * 4.0-specific functionality for IceCreamSandwich devices. It thus requires API level 14.
+ */
+public class ActionBarHelperICS extends ActionBarHelperHoneycomb {
+    protected ActionBarHelperICS(Activity activity) {
+        super(activity);
+    }
+
+    @Override
+    protected Context getActionBarThemedContext() {
+        return mActivity.getActionBar().getThemedContext();
+    }
+}
diff --git a/android/src/net/sf/openrocket/android/actionbarcompat/ActionBarListActivity.java b/android/src/net/sf/openrocket/android/actionbarcompat/ActionBarListActivity.java
new file mode 100644 (file)
index 0000000..b813208
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.sf.openrocket.android.actionbarcompat;
+
+import android.app.Activity;
+import android.app.ListActivity;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuInflater;
+
+public abstract class ActionBarListActivity extends ListActivity {
+    final ActionBarHelper mActionBarHelper = ActionBarHelper.createInstance(this);
+
+    /**
+     * Returns the {@link ActionBarHelper} for this activity.
+     */
+    protected ActionBarHelper getActionBarHelper() {
+        return mActionBarHelper;
+    }
+
+    /**{@inheritDoc}*/
+    @Override
+    public MenuInflater getMenuInflater() {
+        return mActionBarHelper.getMenuInflater(super.getMenuInflater());
+    }
+
+    /**{@inheritDoc}*/
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mActionBarHelper.onCreate(savedInstanceState);
+    }
+
+    /**{@inheritDoc}*/
+    @Override
+    protected void onPostCreate(Bundle savedInstanceState) {
+        super.onPostCreate(savedInstanceState);
+        mActionBarHelper.onPostCreate(savedInstanceState);
+    }
+
+    /**
+     * Base action bar-aware implementation for
+     * {@link Activity#onCreateOptionsMenu(android.view.Menu)}.
+     *
+     * Note: marking menu items as invisible/visible is not currently supported.
+     */
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        boolean retValue = false;
+        retValue |= mActionBarHelper.onCreateOptionsMenu(menu);
+        retValue |= super.onCreateOptionsMenu(menu);
+        return retValue;
+    }
+
+    /**{@inheritDoc}*/
+    @Override
+    protected void onTitleChanged(CharSequence title, int color) {
+        mActionBarHelper.onTitleChanged(title, color);
+        super.onTitleChanged(title, color);
+    }
+}
diff --git a/android/src/net/sf/openrocket/android/actionbarcompat/SimpleMenu.java b/android/src/net/sf/openrocket/android/actionbarcompat/SimpleMenu.java
new file mode 100644 (file)
index 0000000..fb9a48f
--- /dev/null
@@ -0,0 +1,203 @@
+/*
+ * Copyright 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.sf.openrocket.android.actionbarcompat;
+
+import java.util.ArrayList;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.Resources;
+import android.view.KeyEvent;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.SubMenu;
+
+/**
+ * A <em>really</em> dumb implementation of the {@link android.view.Menu} interface, that's only
+ * useful for our actionbar-compat purposes. See
+ * <code>com.android.internal.view.menu.MenuBuilder</code> in AOSP for a more complete
+ * implementation.
+ */
+public class SimpleMenu implements Menu {
+
+    private Context mContext;
+    private Resources mResources;
+
+    private ArrayList<SimpleMenuItem> mItems;
+
+    public SimpleMenu(Context context) {
+        mContext = context;
+        mResources = context.getResources();
+        mItems = new ArrayList<SimpleMenuItem>();
+    }
+
+    public Context getContext() {
+        return mContext;
+    }
+
+    public Resources getResources() {
+        return mResources;
+    }
+
+    public MenuItem add(CharSequence title) {
+        return addInternal(0, 0, title);
+    }
+
+    public MenuItem add(int titleRes) {
+        return addInternal(0, 0, mResources.getString(titleRes));
+    }
+
+    public MenuItem add(int groupId, int itemId, int order, CharSequence title) {
+        return addInternal(itemId, order, title);
+    }
+
+    public MenuItem add(int groupId, int itemId, int order, int titleRes) {
+        return addInternal(itemId, order, mResources.getString(titleRes));
+    }
+
+    /**
+     * Adds an item to the menu.  The other add methods funnel to this.
+     */
+    private MenuItem addInternal(int itemId, int order, CharSequence title) {
+        final SimpleMenuItem item = new SimpleMenuItem(this, itemId, order, title);
+        mItems.add(findInsertIndex(mItems, order), item);
+        return item;
+    }
+
+    private static int findInsertIndex(ArrayList<? extends MenuItem> items, int order) {
+        for (int i = items.size() - 1; i >= 0; i--) {
+            MenuItem item = items.get(i);
+            if (item.getOrder() <= order) {
+                return i + 1;
+            }
+        }
+
+        return 0;
+    }
+
+    public int findItemIndex(int id) {
+        final int size = size();
+
+        for (int i = 0; i < size; i++) {
+            SimpleMenuItem item = mItems.get(i);
+            if (item.getItemId() == id) {
+                return i;
+            }
+        }
+
+        return -1;
+    }
+
+    public void removeItem(int itemId) {
+        removeItemAtInt(findItemIndex(itemId));
+    }
+
+    private void removeItemAtInt(int index) {
+        if ((index < 0) || (index >= mItems.size())) {
+            return;
+        }
+        mItems.remove(index);
+    }
+
+    public void clear() {
+        mItems.clear();
+    }
+
+    public MenuItem findItem(int id) {
+        final int size = size();
+        for (int i = 0; i < size; i++) {
+            SimpleMenuItem item = mItems.get(i);
+            if (item.getItemId() == id) {
+                return item;
+            }
+        }
+
+        return null;
+    }
+
+    public int size() {
+        return mItems.size();
+    }
+
+    public MenuItem getItem(int index) {
+        return mItems.get(index);
+    }
+
+    // Unsupported operations.
+
+    public SubMenu addSubMenu(CharSequence charSequence) {
+        throw new UnsupportedOperationException("This operation is not supported for SimpleMenu");
+    }
+
+    public SubMenu addSubMenu(int titleRes) {
+        throw new UnsupportedOperationException("This operation is not supported for SimpleMenu");
+    }
+
+    public SubMenu addSubMenu(int groupId, int itemId, int order, CharSequence title) {
+        throw new UnsupportedOperationException("This operation is not supported for SimpleMenu");
+    }
+
+    public SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes) {
+        throw new UnsupportedOperationException("This operation is not supported for SimpleMenu");
+    }
+
+    public int addIntentOptions(int i, int i1, int i2, ComponentName componentName,
+            Intent[] intents, Intent intent, int i3, MenuItem[] menuItems) {
+        throw new UnsupportedOperationException("This operation is not supported for SimpleMenu");
+    }
+
+    public void removeGroup(int i) {
+        throw new UnsupportedOperationException("This operation is not supported for SimpleMenu");
+    }
+
+    public void setGroupCheckable(int i, boolean b, boolean b1) {
+        throw new UnsupportedOperationException("This operation is not supported for SimpleMenu");
+    }
+
+    public void setGroupVisible(int i, boolean b) {
+        throw new UnsupportedOperationException("This operation is not supported for SimpleMenu");
+    }
+
+    public void setGroupEnabled(int i, boolean b) {
+        throw new UnsupportedOperationException("This operation is not supported for SimpleMenu");
+    }
+
+    public boolean hasVisibleItems() {
+        throw new UnsupportedOperationException("This operation is not supported for SimpleMenu");
+    }
+
+    public void close() {
+        throw new UnsupportedOperationException("This operation is not supported for SimpleMenu");
+    }
+
+    public boolean performShortcut(int i, KeyEvent keyEvent, int i1) {
+        throw new UnsupportedOperationException("This operation is not supported for SimpleMenu");
+    }
+
+    public boolean isShortcutKey(int i, KeyEvent keyEvent) {
+        throw new UnsupportedOperationException("This operation is not supported for SimpleMenu");
+    }
+
+    public boolean performIdentifierAction(int i, int i1) {
+        throw new UnsupportedOperationException("This operation is not supported for SimpleMenu");
+    }
+
+    public void setQwertyMode(boolean b) {
+        throw new UnsupportedOperationException("This operation is not supported for SimpleMenu");
+    }
+}
diff --git a/android/src/net/sf/openrocket/android/actionbarcompat/SimpleMenuItem.java b/android/src/net/sf/openrocket/android/actionbarcompat/SimpleMenuItem.java
new file mode 100644 (file)
index 0000000..8af4c5d
--- /dev/null
@@ -0,0 +1,260 @@
+/*
+ * Copyright 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.sf.openrocket.android.actionbarcompat;
+
+import android.content.Intent;
+import android.graphics.drawable.Drawable;
+import android.view.ActionProvider;
+import android.view.ContextMenu;
+import android.view.MenuItem;
+import android.view.SubMenu;
+import android.view.View;
+
+/**
+ * A <em>really</em> dumb implementation of the {@link android.view.MenuItem} interface, that's only
+ * useful for our actionbar-compat purposes. See
+ * <code>com.android.internal.view.menu.MenuItemImpl</code> in AOSP for a more complete
+ * implementation.
+ */
+public class SimpleMenuItem implements MenuItem {
+
+    private SimpleMenu mMenu;
+
+    private final int mId;
+    private final int mOrder;
+    private CharSequence mTitle;
+    private CharSequence mTitleCondensed;
+    private Drawable mIconDrawable;
+    private int mIconResId = 0;
+    private boolean mEnabled = true;
+
+    public SimpleMenuItem(SimpleMenu menu, int id, int order, CharSequence title) {
+        mMenu = menu;
+        mId = id;
+        mOrder = order;
+        mTitle = title;
+    }
+
+    public int getItemId() {
+        return mId;
+    }
+
+    public int getOrder() {
+        return mOrder;
+    }
+
+    public MenuItem setTitle(CharSequence title) {
+        mTitle = title;
+        return this;
+    }
+
+    public MenuItem setTitle(int titleRes) {
+        return setTitle(mMenu.getContext().getString(titleRes));
+    }
+
+    public CharSequence getTitle() {
+        return mTitle;
+    }
+
+    public MenuItem setTitleCondensed(CharSequence title) {
+        mTitleCondensed = title;
+        return this;
+    }
+
+    public CharSequence getTitleCondensed() {
+        return mTitleCondensed != null ? mTitleCondensed : mTitle;
+    }
+
+    public MenuItem setIcon(Drawable icon) {
+        mIconResId = 0;
+        mIconDrawable = icon;
+        return this;
+    }
+
+    public MenuItem setIcon(int iconResId) {
+        mIconDrawable = null;
+        mIconResId = iconResId;
+        return this;
+    }
+
+    public Drawable getIcon() {
+        if (mIconDrawable != null) {
+            return mIconDrawable;
+        }
+
+        if (mIconResId != 0) {
+            return mMenu.getResources().getDrawable(mIconResId);
+        }
+
+        return null;
+    }
+
+    public MenuItem setEnabled(boolean enabled) {
+        mEnabled = enabled;
+        return this;
+    }
+
+    public boolean isEnabled() {
+        return mEnabled;
+    }
+
+    // No-op operations. We use no-ops to allow inflation from menu XML.
+
+    public int getGroupId() {
+        // Noop
+        return 0;
+    }
+
+    public View getActionView() {
+        // Noop
+        return null;
+    }
+
+    public MenuItem setActionProvider(ActionProvider actionProvider) {
+        // Noop
+        return this;
+    }
+
+    public ActionProvider getActionProvider() {
+        // Noop
+        return null;
+    }
+
+    public boolean expandActionView() {
+        // Noop
+        return false;
+    }
+
+    public boolean collapseActionView() {
+        // Noop
+        return false;
+    }
+
+    public boolean isActionViewExpanded() {
+        // Noop
+        return false;
+    }
+
+    public MenuItem setOnActionExpandListener(OnActionExpandListener onActionExpandListener) {
+        // Noop
+        return this;
+    }
+
+    public MenuItem setIntent(Intent intent) {
+        // Noop
+        return this;
+    }
+
+       public Intent getIntent() {
+        // Noop
+        return null;
+    }
+
+    public MenuItem setShortcut(char c, char c1) {
+        // Noop
+        return this;
+    }
+
+    public MenuItem setNumericShortcut(char c) {
+        // Noop
+        return this;
+    }
+
+    public char getNumericShortcut() {
+        // Noop
+        return 0;
+    }
+
+    public MenuItem setAlphabeticShortcut(char c) {
+        // Noop
+        return this;
+    }
+
+    public char getAlphabeticShortcut() {
+        // Noop
+        return 0;
+    }
+
+    public MenuItem setCheckable(boolean b) {
+        // Noop
+        return this;
+    }
+
+    public boolean isCheckable() {
+        // Noop
+        return false;
+    }
+
+    public MenuItem setChecked(boolean b) {
+        // Noop
+        return this;
+    }
+
+    public boolean isChecked() {
+        // Noop
+        return false;
+    }
+
+    public MenuItem setVisible(boolean b) {
+        // Noop
+        return this;
+    }
+
+    public boolean isVisible() {
+        // Noop
+        return true;
+    }
+
+    public boolean hasSubMenu() {
+        // Noop
+        return false;
+    }
+
+    public SubMenu getSubMenu() {
+        // Noop
+        return null;
+    }
+
+    public MenuItem setOnMenuItemClickListener(OnMenuItemClickListener onMenuItemClickListener) {
+        // Noop
+        return this;
+    }
+
+    public ContextMenu.ContextMenuInfo getMenuInfo() {
+        // Noop
+        return null;
+    }
+
+    public void setShowAsAction(int i) {
+        // Noop
+    }
+
+    public MenuItem setShowAsActionFlags(int i) {
+        // Noop
+        return null;
+    }
+
+    public MenuItem setActionView(View view) {
+        // Noop
+        return this;
+    }
+
+    public MenuItem setActionView(int i) {
+        // Noop
+        return this;
+    }
+}
index 853f488976754eb1f5f545770f5838e8517c8000..1c4ff406a72d7a8b6864535058ce8dfd8df646aa 100644 (file)
@@ -9,8 +9,8 @@ import java.util.Comparator;
 import java.util.List;\r
 \r
 import net.sf.openrocket.R;\r
+import net.sf.openrocket.android.actionbarcompat.ActionBarListActivity;\r
 import android.app.AlertDialog;\r
-import android.app.ListActivity;\r
 import android.content.DialogInterface;\r
 import android.content.Intent;\r
 import android.net.Uri;\r
@@ -19,14 +19,12 @@ import android.os.Environment;
 import android.view.View;\r
 import android.widget.ArrayAdapter;\r
 import android.widget.ListView;\r
-import android.widget.TextView;\r
 \r
-public class SimpleFileBrowser extends ListActivity {\r
+public class SimpleFileBrowser extends ActionBarListActivity {\r
 \r
        private List<String> item = null;\r
        private List<String> path = null;\r
        private String root = "/";\r
-       private TextView myPath;\r
 \r
        private static final OrkFileFilter filter = new OrkFileFilter();\r
        private static final Collator sorter = Collator.getInstance();\r
@@ -40,7 +38,6 @@ public class SimpleFileBrowser extends ListActivity {
        public void onCreate(Bundle savedInstanceState) {\r
                super.onCreate(savedInstanceState);\r
                setContentView(R.layout.simplefilebrowser);\r
-               myPath = (TextView) findViewById(R.id.path);\r
                getDir( Environment.getExternalStorageDirectory().getAbsolutePath() );\r
        }\r
 \r
@@ -88,7 +85,7 @@ public class SimpleFileBrowser extends ListActivity {
        }\r
 \r
        private void getDir(String dirPath) {\r
-               myPath.setText("Location: " + dirPath);\r
+               setTitle(dirPath);\r
                item = new ArrayList<String>();\r
                path = new ArrayList<String>();\r
 \r
index f1d00cf39a3f499dcd7921364a5755057f80f4f2..03aa88f336a99a08e21b1d003cd17579ebc9b304 100644 (file)
@@ -19,5 +19,5 @@ public class BurnPlotActivity extends FragmentActivity {
                getSupportFragmentManager().beginTransaction().replace(android.R.id.content, burnPlot).commit();\r
                \r
        }\r
-       \r
+\r
 }\r
index 7600f2a0dfd330fbbb2fdb0a1bf26eceb42ef0cb..1f0c72254a59a5907368260cd284969ca7025bc2 100644 (file)
@@ -8,6 +8,7 @@ import net.sf.openrocket.R;
 import net.sf.openrocket.android.db.DbAdapter;\r
 import net.sf.openrocket.android.util.AndroidLogWrapper;\r
 import android.graphics.Color;\r
+import android.graphics.Paint;\r
 import android.graphics.PointF;\r
 import android.os.Bundle;\r
 import android.support.v4.app.Fragment;\r
@@ -48,25 +49,25 @@ public class BurnPlotFragment extends Fragment implements OnTouchListener {
                frag.setArguments(bundle);\r
                return frag;\r
        }\r
-       \r
+\r
        @Override\r
        public void onCreate(Bundle savedInstanceState) {\r
                AndroidLogWrapper.d(BurnPlotFragment.class,"onCreate");\r
-               \r
+\r
                if ( savedInstanceState!= null) {\r
                        motorId = savedInstanceState.getLong("motorId",-1);\r
                } else {\r
                        Bundle b = getArguments();\r
                        motorId = b.getLong("motorId");\r
                }\r
-               \r
+\r
                DbAdapter mDbHelper = new DbAdapter(getActivity());\r
                mDbHelper.open();\r
 \r
                try {\r
                        motor = mDbHelper.getMotorDao().fetchMotor(motorId);\r
                } catch ( Exception e ) {\r
-                       \r
+\r
                }\r
 \r
                mDbHelper.close();\r
@@ -98,22 +99,25 @@ public class BurnPlotFragment extends Fragment implements OnTouchListener {
                }\r
                return l;\r
        }\r
-       \r
+\r
        private void init( ExtendedThrustCurveMotor motor ) {\r
 \r
                mySimpleXYPlot.setUserDomainOrigin(0);\r
                mySimpleXYPlot.setUserRangeOrigin(0);\r
                mySimpleXYPlot.setRangeLabel("impuse (n)");\r
                mySimpleXYPlot.setDomainLabel("time (s)");\r
-               mySimpleXYPlot.addMarker(new YValueMarker(motor.getThrustCurveMotor().getAverageThrustEstimate(),"average" ));\r
+               YValueMarker average = new YValueMarker(motor.getThrustCurveMotor().getAverageThrustEstimate(),"average" );\r
+               average.getLinePaint().setColor(Color.BLACK);\r
+               average.getTextPaint().setColor(Color.BLACK);\r
+               mySimpleXYPlot.addMarker( average );\r
                mySimpleXYPlot.disableAllMarkup();\r
 \r
-\r
                try {\r
                        mySeries = new SimpleXYSeries( \r
                                        fromArray(motor.getThrustCurveMotor().getTimePoints()),\r
-                                       fromArray(motor.getThrustCurveMotor().getThrustPoints()),\r
-                                       motor.getThrustCurveMotor().getDesignation());\r
+                                       fromArray(motor.getThrustCurveMotor().getThrustPoints()), \r
+                                       motor.getThrustCurveMotor().getManufacturer().getDisplayName() + " " + motor.getThrustCurveMotor().getDesignation()\r
+                                       );\r
                } catch ( Exception ex ) {\r
 \r
                        Vector<Double> data = new Vector<Double>();\r
@@ -124,8 +128,11 @@ public class BurnPlotFragment extends Fragment implements OnTouchListener {
                        mySeries = new SimpleXYSeries(data, SimpleXYSeries.ArrayFormat.XY_VALS_INTERLEAVED,"no data");\r
                }\r
 \r
-               mySimpleXYPlot.addSeries(mySeries, LineAndPointRenderer.class,\r
-                               new LineAndPointFormatter(Color.rgb(0, 255, 0), Color.rgb(200, 0, 0), null));\r
+               LineAndPointFormatter formatter= new LineAndPointFormatter(Color.RED, Color.GREEN, Color.GREEN);\r
+\r
+               formatter.getLinePaint().setShadowLayer(0, 0, 0, 0);\r
+               formatter.getVertexPaint().setShadowLayer(0, 0, 0, 0);\r
+               mySimpleXYPlot.addSeries(mySeries, LineAndPointRenderer.class,formatter);\r
 \r
                //Set of internal variables for keeping track of the boundaries\r
                mySimpleXYPlot.calculateMinMaxVals();\r
index 282baec288e81230b8510433465635d231a10fd9..34a92b98c1a8f9367313862f362113917c172d5a 100644 (file)
@@ -3,18 +3,18 @@ package net.sf.openrocket.android.motor;
 import net.sf.openrocket.R;\r
 import net.sf.openrocket.android.ActivityHelpers;\r
 import net.sf.openrocket.android.PreferencesActivity;\r
+import net.sf.openrocket.android.actionbarcompat.ActionBarFragmentActivity;\r
 import net.sf.openrocket.android.util.AndroidLogWrapper;\r
 import android.content.Intent;\r
 import android.os.Bundle;\r
 import android.support.v4.app.Fragment;\r
-import android.support.v4.app.FragmentActivity;\r
 import android.support.v4.app.FragmentTransaction;\r
 import android.view.Menu;\r
 import android.view.MenuInflater;\r
 import android.view.MenuItem;\r
 import android.view.View;\r
 \r
-public class MotorBrowserActivity extends FragmentActivity\r
+public class MotorBrowserActivity extends ActionBarFragmentActivity\r
 implements MotorListFragment.OnMotorSelectedListener\r
 {\r
 \r
@@ -27,6 +27,7 @@ implements MotorListFragment.OnMotorSelectedListener
        public void onCreate(Bundle savedInstanceState) {\r
                super.onCreate(savedInstanceState);\r
                setContentView(R.layout.motorbrowser);\r
+               getActionBarHelper().setDisplayHomeAsUpEnabled(true);\r
                getSupportFragmentManager().beginTransaction().add( R.id.motorBrowserList, new MotorListFragment()).commit();\r
        }\r
 \r
@@ -41,6 +42,9 @@ implements MotorListFragment.OnMotorSelectedListener
        public boolean onMenuItemSelected(int featureId, MenuItem item) {\r
                AndroidLogWrapper.d(MotorBrowserActivity.class,"onMenuItemSelected" + item.getItemId());\r
                switch(item.getItemId()) {\r
+               case android.R.id.home:\r
+                       finish();\r
+                       return true;\r
                case R.id.download_from_thrustcurve_menu_option:\r
                        ActivityHelpers.downloadFromThrustcurve(this,DOWNLOAD_REQUEST_CODE);\r
                        return true;\r
index 9362c8bf24401d3ecac80aea12601a78fd435de7..5ea7982743e2fad54bcd3ec24879e456a7f1deb6 100644 (file)
@@ -4,72 +4,45 @@ package net.sf.openrocket.android.rocket;
 import net.sf.openrocket.R;\r
 import net.sf.openrocket.android.ActivityHelpers;\r
 import net.sf.openrocket.android.Application;\r
+import net.sf.openrocket.android.actionbarcompat.ActionBarFragmentActivity;\r
 import net.sf.openrocket.android.simulation.SimulationChart;\r
 import net.sf.openrocket.android.simulation.SimulationFragment;\r
 import net.sf.openrocket.android.simulation.SimulationViewActivity;\r
 import net.sf.openrocket.android.util.AndroidLogWrapper;\r
-import net.sf.openrocket.android.util.TabsAdapter;\r
-import net.sf.openrocket.document.OpenRocketDocument;\r
 import net.sf.openrocket.document.Simulation;\r
-import net.sf.openrocket.rocketcomponent.Configuration;\r
 import android.content.Intent;\r
 import android.os.Bundle;\r
 import android.support.v4.app.Fragment;\r
-import android.support.v4.app.FragmentActivity;\r
+import android.support.v4.app.FragmentManager;\r
+import android.support.v4.app.FragmentPagerAdapter;\r
 import android.support.v4.app.FragmentTransaction;\r
 import android.support.v4.view.ViewPager;\r
 import android.view.Menu;\r
 import android.view.MenuInflater;\r
 import android.view.MenuItem;\r
 import android.view.View;\r
-import android.widget.TabHost;\r
 \r
-public class OpenRocketViewer extends FragmentActivity\r
+public class OpenRocketViewer extends ActionBarFragmentActivity\r
 implements Simulations.OnSimulationSelectedListener\r
 {\r
 \r
-       OpenRocketDocument rocketDocument;\r
-       Configuration rocketConfiguration;\r
-\r
        private Application app;\r
 \r
-       TabHost mTabHost;\r
-       ViewPager  mViewPager;\r
-       TabsAdapter mTabsAdapter;\r
-\r
        @Override\r
        protected void onCreate(Bundle savedInstanceState) {\r
                super.onCreate(savedInstanceState);\r
 \r
                app = (Application) this.getApplication();\r
-\r
                setContentView(R.layout.openrocketviewer);\r
-\r
-               mTabHost = (TabHost)findViewById(android.R.id.tabhost);\r
-               mTabHost.setup();\r
-\r
-               mViewPager = (ViewPager)findViewById(R.id.pager);\r
-\r
-               mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager);\r
-\r
-               mTabsAdapter.addTab(mTabHost.newTabSpec("overview").setIndicator("Overview"),\r
-                               Overview.class, null);\r
-               mTabsAdapter.addTab(mTabHost.newTabSpec("components").setIndicator("Components"),\r
-                               Component.class, null);\r
-               mTabsAdapter.addTab(mTabHost.newTabSpec("simulations").setIndicator("Simulations"),\r
-                               Simulations.class, null);\r
-\r
-               if (savedInstanceState != null) {\r
-                       mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab"));\r
-               }\r
+               ViewPager viewPager = (ViewPager)findViewById(R.id.pager);\r
+               viewPager.setAdapter( new OpenRocketViewerPager( this.getSupportFragmentManager()));\r
+               \r
+               setTitle(app.getRocketDocument().getRocket().getName());\r
+               \r
+               getActionBarHelper().setDisplayHomeAsUpEnabled(true);\r
+               \r
        }\r
-\r
-       @Override\r
-       protected void onSaveInstanceState(Bundle outState) {\r
-               super.onSaveInstanceState(outState);\r
-               outState.putString("tab", mTabHost.getCurrentTabTag());\r
-       }\r
-\r
+       \r
        @Override\r
        public boolean onCreateOptionsMenu(Menu menu) {\r
                MenuInflater inflater = getMenuInflater();\r
@@ -81,6 +54,9 @@ implements Simulations.OnSimulationSelectedListener
        public boolean onMenuItemSelected(int featureId, MenuItem item) {\r
                AndroidLogWrapper.d(OpenRocketViewer.class,"onMenuItemSelected" + item.getItemId());\r
                switch(item.getItemId()) {\r
+               case android.R.id.home:\r
+                       finish();\r
+                       return true;\r
                case R.id.motor_list_menu_option:\r
                        ActivityHelpers.browseMotors(this);\r
                        return true;\r
@@ -116,4 +92,39 @@ implements Simulations.OnSimulationSelectedListener
                }\r
        }\r
 \r
+       private class OpenRocketViewerPager extends FragmentPagerAdapter {\r
+\r
+               public OpenRocketViewerPager( FragmentManager fm ) {\r
+                       super(fm);\r
+               }\r
+               @Override\r
+               public int getCount() {\r
+                       return 3;\r
+               }\r
+               @Override\r
+               public Fragment getItem( int position ) {\r
+                       switch (position) {\r
+                       case 0:\r
+                               return new Overview();\r
+                       case 1:\r
+                               return new Component();\r
+                       case 2:\r
+                               return new Simulations();\r
+                       }\r
+                       return null;\r
+               }\r
+               @Override\r
+               public CharSequence getPageTitle(int position) {\r
+                       switch (position) {\r
+                       case 0:\r
+                               return "Overview";\r
+                       case 1:\r
+                               return "Components";\r
+                       case 2:\r
+                               return "Simulations";\r
+                       }\r
+                       return null;\r
+               }\r
+       }\r
+\r
 }\r
diff --git a/android/src/net/sf/openrocket/android/util/TabsAdapter.java b/android/src/net/sf/openrocket/android/util/TabsAdapter.java
deleted file mode 100644 (file)
index e8d8c6a..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-package net.sf.openrocket.android.util;\r
-\r
-import java.util.ArrayList;\r
-\r
-import android.content.Context;\r
-import android.os.Bundle;\r
-import android.support.v4.app.Fragment;\r
-import android.support.v4.app.FragmentActivity;\r
-import android.support.v4.app.FragmentPagerAdapter;\r
-import android.support.v4.view.ViewPager;\r
-import android.view.View;\r
-import android.view.ViewGroup;\r
-import android.widget.TabHost;\r
-import android.widget.TabWidget;\r
-\r
-//This class was copied from:\r
-//http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentTabsPager.html\r
-//With the following copyright & license.\r
-\r
-/*\r
-* Copyright (C) 2011 The Android Open Source Project\r
-*\r
-* Licensed under the Apache License, Version 2.0 (the "License");\r
-* you may not use this file except in compliance with the License.\r
-* You may obtain a copy of the License at\r
-*\r
-*      http://www.apache.org/licenses/LICENSE-2.0\r
-*\r
-* Unless required by applicable law or agreed to in writing, software\r
-* distributed under the License is distributed on an "AS IS" BASIS,\r
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-* See the License for the specific language governing permissions and\r
-* limitations under the License.\r
-*/\r
-\r
-/**\r
- * This is a helper class that implements the management of tabs and all\r
- * details of connecting a ViewPager with associated TabHost.  It relies on a\r
- * trick.  Normally a tab host has a simple API for supplying a View or\r
- * Intent that each tab will show.  This is not sufficient for switching\r
- * between pages.  So instead we make the content part of the tab host\r
- * 0dp high (it is not shown) and the TabsAdapter supplies its own dummy\r
- * view to show as the tab content.  It listens to changes in tabs, and takes\r
- * care of switch to the correct paged in the ViewPager whenever the selected\r
- * tab changes.\r
- */\r
-public class TabsAdapter extends FragmentPagerAdapter\r
-        implements TabHost.OnTabChangeListener, ViewPager.OnPageChangeListener {\r
-    private final Context mContext;\r
-    private final TabHost mTabHost;\r
-    private final ViewPager mViewPager;\r
-    private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();\r
-\r
-    static final class TabInfo {\r
-        private final String tag;\r
-        private final Class<?> clss;\r
-        private final Bundle args;\r
-\r
-        TabInfo(String _tag, Class<?> _class, Bundle _args) {\r
-            tag = _tag;\r
-            clss = _class;\r
-            args = _args;\r
-        }\r
-    }\r
-\r
-    static class DummyTabFactory implements TabHost.TabContentFactory {\r
-        private final Context mContext;\r
-\r
-        public DummyTabFactory(Context context) {\r
-            mContext = context;\r
-        }\r
-\r
-        @Override\r
-        public View createTabContent(String tag) {\r
-            View v = new View(mContext);\r
-            v.setMinimumWidth(0);\r
-            v.setMinimumHeight(0);\r
-            return v;\r
-        }\r
-    }\r
-\r
-    public TabsAdapter(FragmentActivity activity, TabHost tabHost, ViewPager pager) {\r
-        super(activity.getSupportFragmentManager());\r
-        mContext = activity;\r
-        mTabHost = tabHost;\r
-        mViewPager = pager;\r
-        mTabHost.setOnTabChangedListener(this);\r
-        mViewPager.setAdapter(this);\r
-        mViewPager.setOnPageChangeListener(this);\r
-    }\r
-\r
-    public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) {\r
-        tabSpec.setContent(new DummyTabFactory(mContext));\r
-        String tag = tabSpec.getTag();\r
-\r
-        TabInfo info = new TabInfo(tag, clss, args);\r
-        mTabs.add(info);\r
-        mTabHost.addTab(tabSpec);\r
-        notifyDataSetChanged();\r
-    }\r
-\r
-    @Override\r
-    public int getCount() {\r
-        return mTabs.size();\r
-    }\r
-\r
-    @Override\r
-    public Fragment getItem(int position) {\r
-        TabInfo info = mTabs.get(position);\r
-        return Fragment.instantiate(mContext, info.clss.getName(), info.args);\r
-    }\r
-\r
-    @Override\r
-    public void onTabChanged(String tabId) {\r
-        int position = mTabHost.getCurrentTab();\r
-        mViewPager.setCurrentItem(position);\r
-    }\r
-\r
-    @Override\r
-    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {\r
-    }\r
-\r
-    @Override\r
-    public void onPageSelected(int position) {\r
-        // Unfortunately when TabHost changes the current tab, it kindly\r
-        // also takes care of putting focus on it when not in touch mode.\r
-        // The jerk.\r
-        // This hack tries to prevent this from pulling focus out of our\r
-        // ViewPager.\r
-        TabWidget widget = mTabHost.getTabWidget();\r
-        int oldFocusability = widget.getDescendantFocusability();\r
-        widget.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);\r
-        mTabHost.setCurrentTab(position);\r
-        widget.setDescendantFocusability(oldFocusability);\r
-    }\r
-\r
-    @Override\r
-    public void onPageScrollStateChanged(int state) {\r
-    }\r
-}\r