rhodes 3.3.2 → 3.3.3.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/Manifest.txt +4 -0
- data/Rakefile +2 -2
- data/doc/device-caps.txt +2 -2
- data/doc/rhodes-api.txt +0 -3
- data/installer/rhostudio-moto.nsi +14 -48
- data/installer/rhostudio.nsi +12 -12
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +167 -46
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SplashScreen.java +15 -15
- data/platform/android/build/android.rake +36 -24
- data/platform/iphone/Classes/MapView/GoogleGeocoder.h +2 -1
- data/platform/iphone/Classes/MapView/GoogleGeocoder.m +44 -6
- data/platform/iphone/Classes/MapView/MapViewController.m +10 -1
- data/platform/shared/common/ExtManager.cpp +103 -0
- data/platform/shared/common/ExtManager.h +101 -0
- data/platform/shared/common/RhodesApp.cpp +3 -2
- data/platform/shared/common/RhodesApp.h +3 -0
- data/platform/shared/common/map/GeocodingMapEngine.cpp +24 -1
- data/platform/shared/common/map/GeocodingMapEngine.h +3 -0
- data/platform/shared/logging/RhoLogConf.cpp +2 -1
- data/platform/shared/net/HttpServer.cpp +1 -1
- data/platform/shared/ruby/ext/rho/rhoruby.c +6 -0
- data/platform/wm/RhoLib/RhoLib.vcproj +8 -0
- data/platform/wm/rhodes/DateTimePicker.cpp +38 -8
- data/platform/wm/rhodes/DateTimePicker.h +4 -0
- data/platform/wm/rhodes/LogOptionsDlg.cpp +16 -0
- data/platform/wm/rhodes/LogOptionsDlg.h +3 -2
- data/platform/wm/rhodes/LogView.cpp +21 -1
- data/platform/wm/rhodes/LogView.h +3 -1
- data/platform/wm/rhodes/MainWindow.cpp +1 -2
- data/platform/wm/rhodes/MapView/MapViewManager.cpp +16 -2
- data/platform/wm/rhodes/MapView/MapViewManager.h +2 -0
- data/platform/wm/rhodes/Rhodes.cpp +2 -1
- data/platform/wm/rhodes/Rhodes.rc +7 -6
- data/platform/wm/rhodes/rho/rubyext/RhoSignature.cpp +303 -147
- data/platform/wm/rhodes/rho/rubyext/RhoSignature.h +22 -16
- data/platform/wm/rhoelements.sln +3 -3
- data/platform/wp7/RhoRubyLib/common/RhoFile.cs +16 -0
- data/platform/wp7/RhoRubyLib/net/HttpServer.cs +5 -5
- data/platform/wp7/RhoRubyLib/views/RhoView.xaml +1 -1
- data/platform/wp7/RhoRubyLib/views/RhoView.xaml.cs +36 -3
- data/rakefile.rb +2 -2
- data/res/generators/rhogen.rb +5 -0
- data/res/generators/templates/application/app/layout.erb +6 -2
- data/res/generators/templates/application/public/js/jquery-wp7-patch.js +149 -0
- data/res/generators/templates/extension/extensions/montana/ext/montana/platform/wm/Montana.sln +29 -7
- data/res/generators/templates/extension/extensions/montana/ext/montana/platform/wm/Montana.vcproj +316 -0
- data/res/generators/templates/extension/extensions/montana/ext/montana/platform/wm/montana.vsprops +15 -0
- data/version +1 -1
- metadata +11 -5
data/CHANGELOG
CHANGED
data/Manifest.txt
CHANGED
@@ -2117,6 +2117,8 @@ platform/shared/common/AppMenu.h
|
|
2117
2117
|
platform/shared/common/AutoPointer.h
|
2118
2118
|
platform/shared/common/BundleManager.cpp
|
2119
2119
|
platform/shared/common/emml.h
|
2120
|
+
platform/shared/common/ExtManager.cpp
|
2121
|
+
platform/shared/common/ExtManager.h
|
2120
2122
|
platform/shared/common/InputStream.h
|
2121
2123
|
platform/shared/common/iphone/RhoClassFactory.cpp
|
2122
2124
|
platform/shared/common/iphone/RhoClassfactory.h
|
@@ -4783,6 +4785,7 @@ res/generators/templates/application/public/jquery/jquery-1.6.4.js
|
|
4783
4785
|
res/generators/templates/application/public/jquery/jquery-1.6.4.min.js
|
4784
4786
|
res/generators/templates/application/public/js/application.js
|
4785
4787
|
res/generators/templates/application/public/js/jqmobile-patch.js
|
4788
|
+
res/generators/templates/application/public/js/jquery-wp7-patch.js
|
4786
4789
|
res/generators/templates/application/public/js/rho.js
|
4787
4790
|
res/generators/templates/application/public/js/rhogeolocation-wm.js
|
4788
4791
|
res/generators/templates/application/public/js/rhogeolocation.js
|
@@ -4809,6 +4812,7 @@ res/generators/templates/extension/extensions/montana/ext/montana/platform/iphon
|
|
4809
4812
|
res/generators/templates/extension/extensions/montana/ext/montana/platform/iphone/Rakefile
|
4810
4813
|
res/generators/templates/extension/extensions/montana/ext/montana/platform/wm/Montana.sln
|
4811
4814
|
res/generators/templates/extension/extensions/montana/ext/montana/platform/wm/Montana.vcproj
|
4815
|
+
res/generators/templates/extension/extensions/montana/ext/montana/platform/wm/montana.vsprops
|
4812
4816
|
res/generators/templates/extension/extensions/montana/ext/montana/platform/wm/Rakefile
|
4813
4817
|
res/generators/templates/extension/extensions/montana/ext/montana/platform/wm/src/montana_wm.cpp
|
4814
4818
|
res/generators/templates/extension/extensions/montana/ext/montana/platform/wm/src/montana_wm.h
|
data/Rakefile
CHANGED
@@ -274,8 +274,8 @@ namespace "config" do
|
|
274
274
|
$app_config["capabilities"] += ["barcode"] if $app_config["extensions"].index("barcode-moto")
|
275
275
|
end
|
276
276
|
|
277
|
-
puts "$app_config['extensions'] : #{$app_config['extensions']}"
|
278
|
-
puts "$app_config['capabilities'] : #{$app_config['capabilities']}"
|
277
|
+
puts "$app_config['extensions'] : #{$app_config['extensions'].inspect}"
|
278
|
+
puts "$app_config['capabilities'] : #{$app_config['capabilities'].inspect}"
|
279
279
|
|
280
280
|
$hidden_app = $app_config["hidden_app"].nil?() ? "0" : $app_config["hidden_app"]
|
281
281
|
|
data/doc/device-caps.txt
CHANGED
@@ -717,7 +717,7 @@ Get a list of scanners present on the device. Return array of hashes ('name','id
|
|
717
717
|
Enables the scanner. barcode_callback get the same parameters as Barcode.take_barcode:
|
718
718
|
|
719
719
|
:::ruby
|
720
|
-
Barcode.enable(url_for(:action => :barcode_callback), {:
|
720
|
+
Barcode.enable(url_for(:action => :barcode_callback), {:id=>id_from_enumerate})
|
721
721
|
|
722
722
|
Callback parameters:
|
723
723
|
|
@@ -742,7 +742,7 @@ Performs a soft trigger stop
|
|
742
742
|
Enables the scanner and start scanner. Before callback is called scanner is disabled:
|
743
743
|
|
744
744
|
:::ruby
|
745
|
-
Barcode.take_barcode(url_for(:action => :barcode_callback), {:
|
745
|
+
Barcode.take_barcode(url_for(:action => :barcode_callback), {:id=>id_from_enumerate})
|
746
746
|
|
747
747
|
THe callback uses these parameters.
|
748
748
|
|
data/doc/rhodes-api.txt
CHANGED
@@ -52,13 +52,10 @@ The [BluetoothSession Class](/rhodes/device-caps#bluetooth) controls the session
|
|
52
52
|
|
53
53
|
The [NFC Classes](/rhodes/nfc) provide access to Near Field Communication functionality, which is currently only supported on Android.
|
54
54
|
|
55
|
-
ZZZ Filled in
|
56
55
|
The [RingtoneManager Class](/rhodes/ringtonemanager-api) allows you to view and play a device's ringtones.
|
57
56
|
|
58
|
-
ZZZZ Filled in
|
59
57
|
The [Alert Class](/rhodes/alert-api) lets you call system alert methods for popup, vibrate, or playing audio files.
|
60
58
|
|
61
|
-
ZZZZ Filled in
|
62
59
|
The [Timer Class](/rhodes/timer-api) lets the device use a timer.
|
63
60
|
|
64
61
|
The [MapView Class](/rhodes/device-caps#mapview) provides an embeddable map interface with the create method and various settings and annotations depending on the map provider (such as Google).
|
@@ -81,11 +81,11 @@ section
|
|
81
81
|
createShortCut "$SMPROGRAMS\RhoStudio\RhoStudio.lnk" "$INSTDIR\eclipse\RhoStudio.exe"
|
82
82
|
|
83
83
|
# added information in 'unistall programs' in contorol panel
|
84
|
-
WriteRegStr
|
84
|
+
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\RhoStudio" \
|
85
85
|
"DisplayName" "RhoStudio - RAD tool for develop and debug rhodes/rhoconnect applications"
|
86
|
-
WriteRegStr
|
86
|
+
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\RhoStudio" \
|
87
87
|
"UninstallString" "$\"$INSTDIR\uninstall.exe$\""
|
88
|
-
WriteRegStr
|
88
|
+
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\RhoStudio" \
|
89
89
|
"DisplayIcon" "$\"$INSTDIR\uninstall.exe$\""
|
90
90
|
|
91
91
|
Goto okFinishSection
|
@@ -114,27 +114,27 @@ section "uninstall"
|
|
114
114
|
# remove env vars
|
115
115
|
Push "PATH"
|
116
116
|
Push "R"
|
117
|
-
Push "
|
117
|
+
Push "HKCU"
|
118
118
|
Push "$INSTDIR\ruby\bin"
|
119
119
|
Call un.EnvVarUpdate
|
120
120
|
Pop $R0
|
121
121
|
|
122
122
|
Push "PATH"
|
123
123
|
Push "R"
|
124
|
-
Push "
|
124
|
+
Push "HKCU"
|
125
125
|
Push "$INSTDIR\make-3.81\bin"
|
126
126
|
Call un.EnvVarUpdate
|
127
127
|
Pop $R0
|
128
128
|
|
129
129
|
Push "PATH"
|
130
130
|
Push "R"
|
131
|
-
Push "
|
131
|
+
Push "HKCU"
|
132
132
|
Push "$INSTDIR\redis-2.4.0"
|
133
133
|
Call un.EnvVarUpdate
|
134
134
|
Pop $R0
|
135
135
|
|
136
|
-
DeleteRegValue
|
137
|
-
DeleteRegKey
|
136
|
+
DeleteRegValue HKCU "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" REDIS_HOME
|
137
|
+
DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\RhoStudio"
|
138
138
|
|
139
139
|
# remove $INSTDIR
|
140
140
|
RMDir /r /REBOOTOK $INSTDIR
|
@@ -150,7 +150,7 @@ Section "GNU Make" gnumakeSection
|
|
150
150
|
|
151
151
|
Push "PATH"
|
152
152
|
Push "P"
|
153
|
-
Push "
|
153
|
+
Push "HKCU"
|
154
154
|
Push "$INSTDIR\make-3.81\bin"
|
155
155
|
Call EnvVarUpdate
|
156
156
|
Pop $R0
|
@@ -181,14 +181,14 @@ Section "DevKit" devkitSection
|
|
181
181
|
|
182
182
|
Push "PATH"
|
183
183
|
Push "P"
|
184
|
-
Push "
|
184
|
+
Push "HKCU"
|
185
185
|
Push "$INSTDIR\devkit\mingw\bin"
|
186
186
|
Call EnvVarUpdate
|
187
187
|
Pop $R0
|
188
188
|
|
189
189
|
Push "PATH"
|
190
190
|
Push "P"
|
191
|
-
Push "
|
191
|
+
Push "HKCU"
|
192
192
|
Push "$INSTDIR\devkit\bin"
|
193
193
|
Call EnvVarUpdate
|
194
194
|
Pop $R0
|
@@ -201,7 +201,6 @@ Section "Ruby, Rubygems, Rhodes, Rhoconnect and adapters" rubySection
|
|
201
201
|
|
202
202
|
File /r "ruby"
|
203
203
|
File /r "make-3.81"
|
204
|
-
#File /r "rhosync"
|
205
204
|
File "README.html"
|
206
205
|
File "RHOSTUDIO-LICENSE.txt"
|
207
206
|
|
@@ -209,7 +208,7 @@ Section "Ruby, Rubygems, Rhodes, Rhoconnect and adapters" rubySection
|
|
209
208
|
|
210
209
|
Push "PATH"
|
211
210
|
Push "P"
|
212
|
-
Push "
|
211
|
+
Push "HKCU"
|
213
212
|
Push "$INSTDIR\ruby\bin"
|
214
213
|
Call EnvVarUpdate
|
215
214
|
Pop $R0
|
@@ -228,14 +227,14 @@ Section "Redis" redisSection
|
|
228
227
|
|
229
228
|
Push "PATH"
|
230
229
|
Push "P"
|
231
|
-
Push "
|
230
|
+
Push "HKCU"
|
232
231
|
Push "$INSTDIR\redis-2.4.0"
|
233
232
|
Call EnvVarUpdate
|
234
233
|
Pop $R0
|
235
234
|
|
236
235
|
Push "REDIS_HOME"
|
237
236
|
Push "P"
|
238
|
-
Push "
|
237
|
+
Push "HKCU"
|
239
238
|
Push "$INSTDIR\redis-2.4.0"
|
240
239
|
Call EnvVarUpdate
|
241
240
|
Pop $R0
|
@@ -300,39 +299,6 @@ SectionEnd
|
|
300
299
|
;======================================================
|
301
300
|
;Functions
|
302
301
|
|
303
|
-
Function .onInit
|
304
|
-
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "configUi.ini"
|
305
|
-
FunctionEnd
|
306
|
-
|
307
|
-
LangString TEXT_IO_TITLE ${LANG_ENGLISH} "Configuration page"
|
308
|
-
LangString TEXT_IO_SUBTITLE ${LANG_ENGLISH} "This page will update application files based on your system configuration."
|
309
|
-
|
310
|
-
/*
|
311
|
-
Function customerConfig
|
312
|
-
!insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE)"
|
313
|
-
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "configUi.ini"
|
314
|
-
!insertmacro MUI_INSTALLOPTIONS_READ $varApacheEmail "configUi.ini" "Field 3" "State"
|
315
|
-
!insertmacro MUI_INSTALLOPTIONS_READ $varApachePort "configUi.ini" "Field 4" "State"
|
316
|
-
|
317
|
-
Push SERVERADMIN
|
318
|
-
Push $varApacheEmail
|
319
|
-
Push all
|
320
|
-
Push all
|
321
|
-
Push $INSTDIR\apache2\conf\httpd.conf
|
322
|
-
Call AdvReplaceInFile
|
323
|
-
|
324
|
-
Push SERVERPORT
|
325
|
-
Push $varApachePort
|
326
|
-
Push all
|
327
|
-
Push all
|
328
|
-
Push $INSTDIR\apache2\conf\httpd.conf
|
329
|
-
Call AdvReplaceInFile
|
330
|
-
|
331
|
-
ExecWait '"$INSTDIR\apache2\bin\httpd.exe" -k install'
|
332
|
-
ExecWait 'net start Apache2.2'
|
333
|
-
FunctionEnd
|
334
|
-
*/
|
335
|
-
|
336
302
|
Function FixScriptFilesInDir
|
337
303
|
Exch $R0 #path
|
338
304
|
Exch
|
data/installer/rhostudio.nsi
CHANGED
@@ -80,11 +80,11 @@ section
|
|
80
80
|
createShortCut "$SMPROGRAMS\RhoStudio\RhoStudio.lnk" "$INSTDIR\eclipse\RhoStudio.exe"
|
81
81
|
|
82
82
|
# added information in 'unistall programs' in contorol panel
|
83
|
-
WriteRegStr
|
83
|
+
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\RhoStudio" \
|
84
84
|
"DisplayName" "RhoStudio - RAD tool for develop and debug rhodes/rhoconnect applications"
|
85
|
-
WriteRegStr
|
85
|
+
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\RhoStudio" \
|
86
86
|
"UninstallString" "$\"$INSTDIR\uninstall.exe$\""
|
87
|
-
WriteRegStr
|
87
|
+
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\RhoStudio" \
|
88
88
|
"DisplayIcon" "$\"$INSTDIR\uninstall.exe$\""
|
89
89
|
|
90
90
|
Goto okFinishSection
|
@@ -113,21 +113,21 @@ section "uninstall"
|
|
113
113
|
# remove env vars
|
114
114
|
Push "PATH"
|
115
115
|
Push "R"
|
116
|
-
Push "
|
116
|
+
Push "HKCU"
|
117
117
|
Push "$INSTDIR\ruby\bin"
|
118
118
|
Call un.EnvVarUpdate
|
119
119
|
Pop $R0
|
120
120
|
|
121
121
|
Push "PATH"
|
122
122
|
Push "R"
|
123
|
-
Push "
|
123
|
+
Push "HKCU"
|
124
124
|
Push "$INSTDIR\make-3.81\bin"
|
125
125
|
Call un.EnvVarUpdate
|
126
126
|
Pop $R0
|
127
127
|
|
128
128
|
Push "PATH"
|
129
129
|
Push "R"
|
130
|
-
Push "
|
130
|
+
Push "HKCU"
|
131
131
|
Push "$INSTDIR\redis-2.4.0"
|
132
132
|
Call un.EnvVarUpdate
|
133
133
|
Pop $R0
|
@@ -149,7 +149,7 @@ Section "GNU Make" gnumakeSection
|
|
149
149
|
|
150
150
|
Push "PATH"
|
151
151
|
Push "P"
|
152
|
-
Push "
|
152
|
+
Push "HKCU"
|
153
153
|
Push "$INSTDIR\make-3.81\bin"
|
154
154
|
Call EnvVarUpdate
|
155
155
|
Pop $R0
|
@@ -180,14 +180,14 @@ Section "DevKit" devkitSection
|
|
180
180
|
|
181
181
|
Push "PATH"
|
182
182
|
Push "P"
|
183
|
-
Push "
|
183
|
+
Push "HKCU"
|
184
184
|
Push "$INSTDIR\devkit\mingw\bin"
|
185
185
|
Call EnvVarUpdate
|
186
186
|
Pop $R0
|
187
187
|
|
188
188
|
Push "PATH"
|
189
189
|
Push "P"
|
190
|
-
Push "
|
190
|
+
Push "HKCU"
|
191
191
|
Push "$INSTDIR\devkit\bin"
|
192
192
|
Call EnvVarUpdate
|
193
193
|
Pop $R0
|
@@ -208,7 +208,7 @@ Section "Ruby, Rubygems, Rhodes, Rhoconnect and adapters" rubySection
|
|
208
208
|
|
209
209
|
Push "PATH"
|
210
210
|
Push "P"
|
211
|
-
Push "
|
211
|
+
Push "HKCU"
|
212
212
|
Push "$INSTDIR\ruby\bin"
|
213
213
|
Call EnvVarUpdate
|
214
214
|
Pop $R0
|
@@ -227,14 +227,14 @@ Section "Redis" redisSection
|
|
227
227
|
|
228
228
|
Push "PATH"
|
229
229
|
Push "P"
|
230
|
-
Push "
|
230
|
+
Push "HKCU"
|
231
231
|
Push "$INSTDIR\redis-2.4.0"
|
232
232
|
Call EnvVarUpdate
|
233
233
|
Pop $R0
|
234
234
|
|
235
235
|
Push "REDIS_HOME"
|
236
236
|
Push "P"
|
237
|
-
Push "
|
237
|
+
Push "HKCU"
|
238
238
|
Push "$INSTDIR\redis-2.4.0"
|
239
239
|
Call EnvVarUpdate
|
240
240
|
Pop $R0
|
@@ -48,10 +48,15 @@ public class RhodesApplication extends Application{
|
|
48
48
|
|
49
49
|
private static final String TAG = RhodesApplication.class.getSimpleName();
|
50
50
|
private static Handler mHandler;
|
51
|
+
static AppEventObserver sRhodesAppActiveWatcher;
|
51
52
|
static {
|
52
53
|
NativeLibraries.load();
|
53
54
|
}
|
54
55
|
|
56
|
+
public static void handleAppStarted() {
|
57
|
+
sRhodesAppActiveWatcher.run();
|
58
|
+
}
|
59
|
+
|
55
60
|
private ApplicationInfo getAppInfo() {
|
56
61
|
Context context = this;
|
57
62
|
String pkgName = context.getPackageName();
|
@@ -84,6 +89,8 @@ public class RhodesApplication extends Application{
|
|
84
89
|
|
85
90
|
Log.i(TAG, "Initializing...");
|
86
91
|
|
92
|
+
sRhodesAppActiveWatcher = AppState.AppStarted.addObserver("RhodesAppActiveObserver", true);
|
93
|
+
|
87
94
|
RhodesApplication.runWhen(
|
88
95
|
UiState.MainActivityStarted,
|
89
96
|
new StateHandler(false) {
|
@@ -228,19 +235,124 @@ public class RhodesApplication extends Application{
|
|
228
235
|
public abstract void run();
|
229
236
|
}
|
230
237
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
238
|
+
/**
|
239
|
+
*
|
240
|
+
* @author lexis_tikh
|
241
|
+
*
|
242
|
+
*/
|
243
|
+
private static class EventObserver implements Runnable{
|
244
|
+
private volatile boolean mReady = false;
|
245
|
+
private boolean mCheckOnce;
|
246
|
+
private String mTag;
|
247
|
+
|
248
|
+
public EventObserver(String tag, boolean once) { mTag = tag; mCheckOnce = once; }
|
249
|
+
public synchronized boolean isReady() { return mReady; }
|
250
|
+
public String toString() { return mTag + " - " + (mReady?"ready":"not ready");}
|
251
|
+
public synchronized void reset() { mReady = false; }
|
252
|
+
public boolean isCheckOnce() { return mCheckOnce; }
|
253
|
+
public void run() { // notify
|
254
|
+
synchronized(this) {
|
255
|
+
mReady = true;
|
256
|
+
}
|
257
|
+
Logger.I(mTag, "Ready");
|
258
|
+
}
|
259
|
+
}
|
260
|
+
|
261
|
+
public static class AppEventObserver extends EventObserver {
|
262
|
+
private AppState mState;
|
263
|
+
|
264
|
+
public AppEventObserver(String tag, AppState state, boolean once) {
|
265
|
+
super(tag, once);
|
266
|
+
mState = state;
|
267
|
+
}
|
268
|
+
public void run() {
|
269
|
+
super.run();
|
270
|
+
|
271
|
+
if(mState == null) throw new IllegalStateException("AppEventObserver state is not initialized");
|
272
|
+
|
273
|
+
RhodesApplication.stateChanged(mState);
|
274
|
+
}
|
275
|
+
}
|
276
|
+
|
277
|
+
public static class UiEventObserver extends EventObserver {
|
278
|
+
private UiState mState;
|
279
|
+
|
280
|
+
public UiEventObserver(String tag, UiState state, boolean once) {
|
281
|
+
super(tag, once);
|
282
|
+
mState = state;
|
283
|
+
}
|
284
|
+
public void run() {
|
285
|
+
super.run();
|
286
|
+
|
287
|
+
if(mState == null) throw new IllegalStateException("UiEventObserver state is not initialized");
|
288
|
+
|
289
|
+
RhodesApplication.stateChanged(mState);
|
290
|
+
}
|
291
|
+
}
|
292
|
+
|
293
|
+
private static int runHandlers(Collection<StateHandler> handlers) {
|
294
|
+
if (handlers == null) return 0;
|
295
|
+
|
296
|
+
for(StateHandler handler: handlers) {
|
297
|
+
handler.run();
|
235
298
|
Exception error = handler.getError();
|
236
299
|
if (error != null)
|
237
300
|
{
|
238
301
|
Logger.E(TAG, error);
|
239
302
|
Thread.dumpStack();
|
240
303
|
}
|
241
|
-
|
304
|
+
}
|
305
|
+
|
306
|
+
return handlers.size();
|
307
|
+
}
|
308
|
+
|
309
|
+
private static class StateImpl <Observer extends EventObserver> {
|
310
|
+
private String TAG;
|
311
|
+
private Vector<Observer> mObservers = new Vector<Observer>();
|
312
|
+
private Vector<StateHandler> mHandlers = new Vector<StateHandler>();
|
313
|
+
|
314
|
+
public StateImpl(String tag) { TAG = tag; }
|
315
|
+
|
316
|
+
public void addObserver(Observer o) { mObservers.add(o); }
|
317
|
+
public void addHandler(StateHandler h) { mHandlers.add(h); }
|
318
|
+
|
319
|
+
public boolean isComplete() {
|
320
|
+
boolean complete = true;
|
321
|
+
for (Observer observer: mObservers) {
|
322
|
+
complete &= observer.isReady();
|
323
|
+
if (!complete) {
|
324
|
+
Logger.D(TAG, observer.toString());
|
325
|
+
break;
|
326
|
+
}
|
327
|
+
}
|
328
|
+
return complete;
|
329
|
+
}
|
330
|
+
|
331
|
+
public Collection<StateHandler> commitHandlers() {
|
332
|
+
Vector<StateHandler> handlers = new Vector<StateHandler>();
|
333
|
+
Vector<StateHandler> doneHandlers = new Vector<StateHandler>();
|
334
|
+
for (StateHandler handler: mHandlers) {
|
335
|
+
handlers.add(handler);
|
336
|
+
if (handler.isRunOnce()) {
|
337
|
+
doneHandlers.add(handler);
|
338
|
+
}
|
339
|
+
}
|
340
|
+
mHandlers.removeAll(doneHandlers);
|
341
|
+
return handlers;
|
342
|
+
}
|
343
|
+
|
344
|
+
public void commitObservers() {
|
345
|
+
Vector<EventObserver> observers = new Vector<EventObserver>();
|
346
|
+
for (EventObserver o: mObservers) {
|
347
|
+
if (o.isCheckOnce()) {
|
348
|
+
observers.add(o);
|
349
|
+
}
|
350
|
+
}
|
351
|
+
mObservers.removeAll(observers);
|
352
|
+
}
|
242
353
|
}
|
243
354
|
|
355
|
+
|
244
356
|
public enum AppState
|
245
357
|
{
|
246
358
|
Undefined("Undefined") {
|
@@ -264,42 +376,49 @@ public class RhodesApplication extends Application{
|
|
264
376
|
|
265
377
|
private Vector<StateHandler> mHandlers = new Vector<StateHandler>();
|
266
378
|
private String TAG;
|
379
|
+
private StateImpl<AppEventObserver> mImpl;
|
267
380
|
|
268
|
-
private AppState(String tag) {
|
381
|
+
private AppState(String tag) {
|
382
|
+
TAG = tag;
|
383
|
+
mImpl = new StateImpl<AppEventObserver>(tag);
|
384
|
+
}
|
269
385
|
|
270
386
|
private synchronized Collection<StateHandler> commit()
|
271
387
|
{
|
272
|
-
|
388
|
+
Collection<StateHandler> handlers = null;// = new Vector<StateHandler>();
|
273
389
|
|
274
390
|
Logger.T(TAG, "Starting commit. Current AppState: " + sAppState.TAG);
|
275
|
-
if((
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
mHandlers.removeAll(doneHandlers);
|
288
|
-
sAppState = this;
|
391
|
+
if(mImpl.isComplete()) {
|
392
|
+
if((this == AppActivated) && (sAppState == Undefined)) {
|
393
|
+
appActivatedFlag = true;
|
394
|
+
Logger.I(TAG, "Cannot commit now, application will be activated when started.");
|
395
|
+
} else {
|
396
|
+
Logger.T(TAG, "Commiting AppState handlers.");
|
397
|
+
|
398
|
+
handlers = mImpl.commitHandlers();
|
399
|
+
mImpl.commitObservers();
|
400
|
+
|
401
|
+
sAppState = this;
|
402
|
+
}
|
289
403
|
}
|
290
404
|
Logger.T(TAG, "After AppState commit: " + sAppState.TAG);
|
291
405
|
return handlers;
|
292
406
|
}
|
293
407
|
|
294
408
|
public synchronized void addHandler(StateHandler handler) { mHandlers.add(handler); }
|
409
|
+
public synchronized AppEventObserver addObserver(String tag, boolean once) {
|
410
|
+
AppEventObserver observer = new AppEventObserver(tag, this, once);
|
411
|
+
mImpl.addObserver(observer);
|
412
|
+
return observer;
|
413
|
+
}
|
295
414
|
public abstract boolean canHandle(AppState state);
|
296
|
-
|
415
|
+
|
297
416
|
static public void handleState(AppState state) {
|
298
|
-
runHandlers(state.commit());
|
299
|
-
Logger.I(sAppState.TAG, "Handlers have completed
|
417
|
+
int cnt = runHandlers(state.commit());
|
418
|
+
Logger.I(sAppState.TAG, "Handlers have completed: " + cnt);
|
300
419
|
if((state == AppStarted) && appActivatedFlag) {
|
301
|
-
runHandlers(AppActivated.commit());
|
302
|
-
Logger.I(sAppState.TAG, "Handlers have completed
|
420
|
+
cnt = runHandlers(AppActivated.commit());
|
421
|
+
Logger.I(sAppState.TAG, "Handlers have completed: " + cnt);
|
303
422
|
}
|
304
423
|
return;
|
305
424
|
}
|
@@ -324,40 +443,42 @@ public class RhodesApplication extends Application{
|
|
324
443
|
public boolean canHandle(UiState state) { return (state == this) || (state == MainActivityCreated); }
|
325
444
|
};
|
326
445
|
|
327
|
-
private
|
446
|
+
private StateImpl<UiEventObserver> mImpl;
|
328
447
|
public String TAG;
|
329
448
|
|
330
|
-
private UiState(String tag) {
|
449
|
+
private UiState(String tag) {
|
450
|
+
TAG = tag;
|
451
|
+
mImpl = new StateImpl<UiEventObserver>(tag);
|
452
|
+
}
|
331
453
|
|
332
454
|
private synchronized Collection<StateHandler> commit()
|
333
455
|
{
|
334
|
-
|
456
|
+
Collection<StateHandler> handlers = null;
|
335
457
|
|
336
458
|
Logger.T(TAG, "Starting commit. Current UiState: " + sUiState.TAG);
|
337
459
|
|
338
|
-
if (
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
doneHandlers.add(handler);
|
346
|
-
}
|
347
|
-
}
|
348
|
-
mHandlers.removeAll(doneHandlers);
|
349
|
-
sUiState = this;
|
350
|
-
}
|
460
|
+
if (mImpl.isComplete()) {
|
461
|
+
if (!sUiState.canHandle(this)) {
|
462
|
+
handlers = mImpl.commitHandlers();
|
463
|
+
mImpl.commitObservers();
|
464
|
+
sUiState = this;
|
465
|
+
}
|
466
|
+
}
|
351
467
|
Logger.T(TAG, "After UiState commit: " + sUiState.TAG);
|
352
468
|
return handlers;
|
353
469
|
}
|
354
470
|
|
355
|
-
public synchronized void addHandler(StateHandler handler) {
|
471
|
+
public synchronized void addHandler(StateHandler handler) { mImpl.addHandler(handler); }
|
472
|
+
public synchronized UiEventObserver addObserver(String tag, boolean once) {
|
473
|
+
UiEventObserver observer = new UiEventObserver(tag, this, once);
|
474
|
+
mImpl.addObserver(observer);
|
475
|
+
return observer;
|
476
|
+
}
|
356
477
|
public abstract boolean canHandle(UiState state);
|
357
|
-
|
478
|
+
|
358
479
|
static public void handleState(UiState state) {
|
359
|
-
runHandlers(state.commit());
|
360
|
-
Logger.I(sAppState.TAG, "Handlers have completed
|
480
|
+
int cnt = runHandlers(state.commit());
|
481
|
+
Logger.I(sAppState.TAG, "Handlers have completed: " + cnt);
|
361
482
|
}
|
362
483
|
}
|
363
484
|
|