Change OpenRocketViewer to tab layout with three tabs: overview, components, and...
[debian/openrocket] / src / net / sf / openrocket / android / Application.java
1 package net.sf.openrocket.android;\r
2 \r
3 import java.util.Locale;\r
4 \r
5 import android.preference.PreferenceManager;\r
6 \r
7 import net.sf.openrocket.database.ThrustCurveMotorSetDatabase;\r
8 import net.sf.openrocket.document.OpenRocketDocument;\r
9 import net.sf.openrocket.l10n.DebugTranslator;\r
10 import net.sf.openrocket.l10n.ResourceBundleTranslator;\r
11 import net.sf.openrocket.l10n.Translator;\r
12 \r
13 public class Application extends android.app.Application {\r
14 \r
15         private OpenRocketDocument rocketDocument;\r
16         \r
17         // Big B boolean so I can synchronize on it.\r
18         private static Boolean initialized = false;\r
19         \r
20         public static void initialize() {\r
21                 synchronized (initialized) {\r
22                         if ( initialized == true ) {\r
23                                 return;\r
24                         }\r
25 \r
26                         // Android does not have a default sax parser set.  This needs to be defined first.\r
27                         System.setProperty("org.xml.sax.driver","org.xmlpull.v1.sax2.Driver");\r
28 \r
29                         net.sf.openrocket.startup.Application.setLogger( new LogHelper() );\r
30                         \r
31                         net.sf.openrocket.startup.Application.setPreferences( new PreferencesAdapter() );\r
32                         \r
33                         ThrustCurveMotorSetDatabase db = new ThrustCurveMotorSetDatabase(false) {\r
34                                 \r
35                                 @Override\r
36                                 protected void loadMotors() {\r
37                                 }\r
38                         };\r
39                         db.startLoading();\r
40 \r
41                         net.sf.openrocket.startup.Application.setMotorSetDatabase(db);\r
42                         \r
43                         Translator t;\r
44                         t = new ResourceBundleTranslator("l10n.messages");\r
45                         if (Locale.getDefault().getLanguage().equals("xx")) {\r
46                                 t = new DebugTranslator(t);\r
47                         }\r
48                         \r
49                         net.sf.openrocket.startup.Application.setBaseTranslator(t);\r
50 \r
51                         initialized = true;\r
52                 }\r
53         }\r
54 \r
55         public Application() {\r
56                 initialize();\r
57         }\r
58 \r
59         /* (non-Javadoc)\r
60          * @see android.app.Application#onCreate()\r
61          */\r
62         @Override\r
63         public void onCreate() {\r
64                 super.onCreate();\r
65                 PreferencesActivity.initializePreferences(this, PreferenceManager.getDefaultSharedPreferences(this));\r
66         }\r
67 \r
68         /**\r
69          * @return the rocketDocument\r
70          */\r
71         public OpenRocketDocument getRocketDocument() {\r
72                 return rocketDocument;\r
73         }\r
74 \r
75         /**\r
76          * @param rocketDocument the rocketDocument to set\r
77          */\r
78         public void setRocketDocument(OpenRocketDocument rocketDocument) {\r
79                 this.rocketDocument = rocketDocument;\r
80         }\r
81         \r
82         \r
83         \r
84 }\r