rhodes 3.0.0 → 3.0.1.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/Rakefile +9 -2
- data/doc/application.txt +1 -1
- data/doc/build.txt +49 -70
- data/doc/device-caps.txt +22 -97
- data/doc/extensions.txt +1 -1
- data/doc/nfc.txt +542 -0
- data/doc/rhom.txt +7 -5
- data/doc/simulator.txt +116 -0
- data/doc/ui.txt +1 -1
- data/lib/build/jake.rb +5 -5
- data/lib/extensions/debugger/debugger.rb +63 -35
- data/lib/extensions/nfc/ext/nfc/platform/android/AndroidManifest.xml +8 -6
- data/lib/extensions/nfc/ext/nfc/platform/android/jni/src/nfc.cpp +1070 -249
- data/lib/extensions/nfc/ext/nfc/platform/android/res/xml/filter_nfc.xml +1 -5
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/Nfc.java +894 -72
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcActivity.java +82 -18
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcMessage.java +65 -0
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcRecord.java +88 -24
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcTechActivity.java +3 -0
- data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc.i +204 -3
- data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc_wrap.c +1047 -5
- data/lib/extensions/nfc/nfc.rb +635 -91
- data/lib/extensions/rhoxml/rexml/encodings/CP-1252.rb +103 -0
- data/lib/extensions/rhoxml/rexml/encodings/ISO-8859-1.rb +7 -0
- data/lib/framework/dateME.rb +26 -0
- data/lib/framework/rho/render.rb +21 -9
- data/lib/framework/rho/rho.rb +12 -0
- data/lib/framework/rho/rhoevent_bb.rb +3 -0
- data/lib/framework/rho/rhoevent_c.rb +3 -0
- data/lib/framework/rhodes.rb +1 -1
- data/lib/framework/rhom/rhom_db_adapter.rb +9 -9
- data/lib/framework/rhosystem.rb +17 -0
- data/lib/framework/stringio.rb +18 -0
- data/lib/framework/version.rb +1 -1
- data/lib/rhodes.rb +1 -1
- data/platform/android/Rhodes/AndroidManifest.xml +2 -2
- data/platform/android/Rhodes/res/xml/filter_nfc.xml +1 -5
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/BaseActivity.java +0 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushReceiver.java +10 -6
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoCryptImpl.java +29 -18
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +67 -12
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivityListener.java +14 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +102 -28
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +35 -66
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/WebView.java +5 -5
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/Alert.java +69 -41
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/PopupActivity.java +7 -5
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/util/PerformOnUiThread.java +68 -35
- data/platform/android/build/RhodesSRC_build.files +1 -0
- data/platform/android/build/android.rake +2 -2
- data/platform/bb/RubyVM/src/com/rho/RhoConf.java +1 -0
- data/platform/bb/RubyVM/src/com/rho/db/DBAdapter.java +18 -6
- data/platform/bb/build/bb.rake +1 -1
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +5 -4
- data/platform/iphone/Classes/SimpleMainView.m +1 -1
- data/platform/iphone/Info.plist +1 -1
- data/platform/shared/common/RhodesApp.cpp +9 -3
- data/platform/shared/curl/lib/rhossl.c +5 -2
- data/platform/shared/db/DBAdapter.cpp +9 -0
- data/platform/shared/net/CURLNetRequest.cpp +8 -3
- data/platform/shared/net/iphone/sslimpl.cpp +3 -2
- data/platform/shared/net/ssl.cpp +8 -0
- data/platform/shared/ruby/ext/rho/rhoruby.c +10 -0
- data/platform/shared/ruby/ext/rho/rhoruby.h +1 -0
- data/platform/shared/ruby/ext/sqlite3_api/sqlite3_api_wrap.c +3 -4
- data/platform/win32/RhoSimulator/QtCore4.dll +0 -0
- data/platform/win32/RhoSimulator/QtGui4.dll +0 -0
- data/platform/win32/RhoSimulator/QtNetwork4.dll +0 -0
- data/platform/win32/RhoSimulator/QtWebKit4.dll +0 -0
- data/platform/win32/RhoSimulator/RhoSimulator.exe +0 -0
- data/platform/win32/RhoSimulator/imageformats/qgif4.dll +0 -0
- data/platform/win32/RhoSimulator/imageformats/qico4.dll +0 -0
- data/platform/win32/RhoSimulator/imageformats/qjpeg4.dll +0 -0
- data/platform/win32/RhoSimulator/imageformats/qmng4.dll +0 -0
- data/platform/win32/RhoSimulator/imageformats/qsvg4.dll +0 -0
- data/platform/win32/RhoSimulator/imageformats/qtiff4.dll +0 -0
- data/platform/win32/RhoSimulator/libeay32.dll +0 -0
- data/platform/win32/RhoSimulator/ssleay32.dll +0 -0
- data/platform/wm/build/wm.rake +27 -3
- data/platform/wm/rhodes/Rhodes.cpp +4 -0
- data/platform/wm/rhodes/emulator/MainWindowCallback.h +1 -0
- data/platform/wm/rhodes/emulator/MainWindowProxy.cpp +3 -1
- data/platform/wm/rhodes/emulator/MainWindowQt.cpp +23 -12
- data/platform/wm/rhodes/emulator/MainWindowQt.h +5 -1
- data/platform/wm/rhodes/emulator/QtMainWindow.cpp +39 -6
- data/platform/wm/rhodes/emulator/QtMainWindow.h +1 -1
- data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +5 -0
- data/platform/wp7/IronRuby/{Bin → bin}/Silverlight3Release/IronRuby.Libraries.dll +0 -0
- data/platform/wp7/IronRuby/{Bin → bin}/Silverlight3Release/IronRuby.dll +0 -0
- data/platform/wp7/IronRuby/bin/Silverlight3Release/Microsoft.Dynamic.dll +0 -0
- data/platform/wp7/IronRuby/{Bin → bin}/Silverlight3Release/Microsoft.Scripting.Core.dll +0 -0
- data/platform/wp7/IronRuby/{Bin → bin}/Silverlight3Release/Microsoft.Scripting.dll +0 -0
- data/platform/wp7/RhoAppRunner/Program.cs +2 -2
- data/platform/wp7/RhoRubyLib/RhoRuby.cs +8 -0
- data/platform/wp7/RhoRubyLib/common/RhodesApp.cs +29 -7
- data/platform/wp7/RhoRubyLib/db/DBAdapter.cs +5 -2
- data/platform/wp7/RhoRubyLib/logging/RhoLogger.cs +12 -0
- data/platform/wp7/RhoRubyLib/net/HttpServer.cs +2 -0
- data/platform/wp7/RhoRubyLib/net/NetRequest.cs +1 -1
- data/platform/wp7/RhoRubyLib/rubyext/RhoAsyncHttp.cs +52 -7
- data/platform/wp7/RhoRubyLib/rubyext/RhoDatabase.cs +85 -18
- data/platform/wp7/RhoRubyLib/rubyext/RhoJSON.cs +38 -3
- data/platform/wp7/RhoRubyLib/rubyext/RhoKernelOps.cs +27 -2
- data/platform/wp7/RhoRubyLib/rubyext/RhoNativeBar.cs +111 -15
- data/platform/wp7/RhoRubyLib/rubyext/RhoSyncEngine.cs +330 -55
- data/platform/wp7/RhoRubyLib/rubyext/RhoWebView.cs +61 -4
- data/platform/wp7/build/wp.rake +89 -72
- data/platform/wp7/rhodes/App.xaml.cs +1 -1
- data/rakefile.rb +9 -2
- data/rhodes.gemspec +1 -3
- data/spec/phone_spec/app/spec/asynchttp_spec.rb +7 -9
- data/spec/phone_spec/app/spec/uri_spec.rb +75 -0
- data/spec/phone_spec/app/spec_runner.rb +4 -0
- metadata +21 -15
- data/Manifest.txt +0 -6403
- data/platform/win32/RhoSimulator/codecs/qcncodecs4.dll +0 -0
- data/platform/win32/RhoSimulator/codecs/qjpcodecs4.dll +0 -0
- data/platform/win32/RhoSimulator/codecs/qkrcodecs4.dll +0 -0
- data/platform/win32/RhoSimulator/codecs/qtwcodecs4.dll +0 -0
- data/platform/wp7/IronRuby/Bin/Silverlight3Release/Microsoft.Dynamic.dll +0 -0
@@ -1,6 +1,8 @@
|
|
1
1
|
package com.rhomobile.rhodes;
|
2
2
|
|
3
3
|
import java.lang.reflect.Constructor;
|
4
|
+
import java.util.ArrayList;
|
5
|
+
import java.util.Iterator;
|
4
6
|
|
5
7
|
import com.rhomobile.rhodes.bluetooth.RhoBluetoothManager;
|
6
8
|
import com.rhomobile.rhodes.mainview.MainView;
|
@@ -55,6 +57,7 @@ public class RhodesActivity extends BaseActivity {
|
|
55
57
|
private WebChromeClient mChromeClient;
|
56
58
|
private WebViewClient mWebViewClient;
|
57
59
|
private RhoWebSettings mWebSettings;
|
60
|
+
|
58
61
|
|
59
62
|
private long uiThreadId = 0;
|
60
63
|
|
@@ -62,6 +65,25 @@ public class RhodesActivity extends BaseActivity {
|
|
62
65
|
return uiThreadId;
|
63
66
|
}
|
64
67
|
|
68
|
+
private ArrayList<RhodesActivityListener> mListeners = null;
|
69
|
+
|
70
|
+
private boolean mIsForeground = false;
|
71
|
+
|
72
|
+
public boolean isForegroundNow() {
|
73
|
+
return mIsForeground;
|
74
|
+
}
|
75
|
+
|
76
|
+
public void addRhodesActivityListener(RhodesActivityListener listener) {
|
77
|
+
if (!mListeners.contains(listener)) {
|
78
|
+
mListeners.add(listener);
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
public void removeRhodesActivityListener(RhodesActivityListener listener) {
|
83
|
+
mListeners.remove(listener);
|
84
|
+
}
|
85
|
+
|
86
|
+
|
65
87
|
private Runnable mSetup = new Runnable() {
|
66
88
|
public void run() {
|
67
89
|
doSetup();
|
@@ -73,6 +95,8 @@ public class RhodesActivity extends BaseActivity {
|
|
73
95
|
|
74
96
|
super.onCreate(savedInstanceState);
|
75
97
|
|
98
|
+
mListeners = new ArrayList<RhodesActivityListener>();
|
99
|
+
|
76
100
|
Thread ct = Thread.currentThread();
|
77
101
|
//ct.setPriority(Thread.MAX_PRIORITY);
|
78
102
|
uiThreadId = ct.getId();
|
@@ -135,14 +159,19 @@ public class RhodesActivity extends BaseActivity {
|
|
135
159
|
getInstance().getWindow().setFlags( WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN, WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
136
160
|
}
|
137
161
|
}
|
138
|
-
}
|
139
|
-
, false);
|
162
|
+
});
|
140
163
|
}
|
141
164
|
|
142
165
|
@Override
|
143
166
|
protected void onNewIntent(Intent intent) {
|
144
167
|
super.onNewIntent(intent);
|
145
|
-
Log.
|
168
|
+
Log.d(TAG, "RhodesActivity.onNewIntent()");
|
169
|
+
{
|
170
|
+
Iterator<RhodesActivityListener> iterator = mListeners.iterator();
|
171
|
+
while (iterator.hasNext()) {
|
172
|
+
iterator.next().onNewIntent(this, intent);
|
173
|
+
}
|
174
|
+
}
|
146
175
|
}
|
147
176
|
|
148
177
|
@Override
|
@@ -150,36 +179,54 @@ public class RhodesActivity extends BaseActivity {
|
|
150
179
|
super.onStart();
|
151
180
|
RhodesService.rhodesActivityStarted(true);
|
152
181
|
|
153
|
-
Log.
|
182
|
+
Log.d(TAG, "RhodesActivity.onStart()");
|
154
183
|
|
155
184
|
RhodesApplication.stateChanged(RhodesApplication.UiState.MainActivityStarted);
|
156
|
-
}
|
185
|
+
}
|
186
|
+
|
187
|
+
@Override
|
188
|
+
public void onResume() {
|
189
|
+
mIsForeground = true;
|
190
|
+
super.onResume();
|
191
|
+
{
|
192
|
+
Iterator<RhodesActivityListener> iterator = mListeners.iterator();
|
193
|
+
while (iterator.hasNext()) {
|
194
|
+
iterator.next().onResume(this);
|
195
|
+
}
|
196
|
+
}
|
197
|
+
}
|
157
198
|
|
158
199
|
@Override
|
159
200
|
public void onPause()
|
160
201
|
{
|
202
|
+
mIsForeground = false;
|
203
|
+
{
|
204
|
+
Iterator<RhodesActivityListener> iterator = mListeners.iterator();
|
205
|
+
while (iterator.hasNext()) {
|
206
|
+
iterator.next().onPause(this);
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
161
210
|
RhodesApplication.stateChanged(RhodesApplication.UiState.MainActivityPaused);
|
162
211
|
|
163
212
|
RhodesService.rhodesActivityStarted(false);
|
164
213
|
|
165
214
|
super.onPause();
|
166
|
-
Log.
|
215
|
+
Log.d(TAG, "RhodesActivity.onPause()");
|
167
216
|
|
168
|
-
RhodesService
|
169
|
-
if (r != null)
|
170
|
-
r.callUiDestroyedCallback();
|
217
|
+
RhodesService.callUiDestroyedCallback();
|
171
218
|
}
|
172
219
|
|
173
220
|
@Override
|
174
221
|
public void onStop()
|
175
222
|
{
|
176
223
|
super.onStop();
|
177
|
-
Log.
|
224
|
+
Log.d(TAG, "RhodesActivity.onStop()");
|
178
225
|
}
|
179
226
|
|
180
227
|
@Override
|
181
228
|
public void onDestroy() {
|
182
|
-
Log.
|
229
|
+
Log.d(TAG, "RhodesActivity.onDestroy()");
|
183
230
|
|
184
231
|
//TODO: Check is it really correct in case activity killed immediately after onPause()
|
185
232
|
sInstance = null;
|
@@ -218,10 +265,18 @@ public class RhodesActivity extends BaseActivity {
|
|
218
265
|
return mAppMenu.onMenuItemSelected(item);
|
219
266
|
}
|
220
267
|
|
268
|
+
@Deprecated
|
221
269
|
public static RhodesActivity getInstance() {
|
222
270
|
return sInstance;
|
223
271
|
}
|
224
|
-
|
272
|
+
|
273
|
+
public static RhodesActivity safeGetInstance() throws NullPointerException {
|
274
|
+
if(sInstance != null)
|
275
|
+
return sInstance;
|
276
|
+
else
|
277
|
+
throw new NullPointerException("RhodesActivity.sInstance == null");
|
278
|
+
}
|
279
|
+
|
225
280
|
public RhodesService getService() {
|
226
281
|
return mRhodesService;
|
227
282
|
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
package com.rhomobile.rhodes;
|
2
|
+
|
3
|
+
import android.content.Intent;
|
4
|
+
|
5
|
+
|
6
|
+
public interface RhodesActivityListener {
|
7
|
+
|
8
|
+
void onPause(RhodesActivity activity);
|
9
|
+
void onResume(RhodesActivity activity);
|
10
|
+
void onNewIntent(RhodesActivity activity, Intent intent);
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
package com.rhomobile.rhodes;
|
2
2
|
|
3
|
+
import java.util.Collection;
|
3
4
|
import java.util.Vector;
|
4
5
|
|
5
6
|
import android.app.Application;
|
@@ -21,11 +22,19 @@ public class RhodesApplication extends Application{
|
|
21
22
|
|
22
23
|
public static void create()
|
23
24
|
{
|
25
|
+
if (sAppState != AppState.Undefined) {
|
26
|
+
Logger.E(TAG, "Cannot create application, it is already started!!!");
|
27
|
+
return;
|
28
|
+
}
|
24
29
|
createRhodesApp();
|
25
30
|
}
|
26
31
|
|
27
32
|
public static void start()
|
28
33
|
{
|
34
|
+
if (sAppState != AppState.Undefined) {
|
35
|
+
Logger.E(TAG, "Cannot start application it is already started!!!");
|
36
|
+
return;
|
37
|
+
}
|
29
38
|
startRhodesApp();
|
30
39
|
}
|
31
40
|
|
@@ -50,12 +59,34 @@ public class RhodesApplication extends Application{
|
|
50
59
|
}, 500);
|
51
60
|
}
|
52
61
|
|
53
|
-
|
62
|
+
|
63
|
+
public static abstract class StateHandler implements Runnable
|
54
64
|
{
|
55
|
-
|
65
|
+
private Exception error;
|
66
|
+
private boolean runOnce;
|
67
|
+
|
68
|
+
public StateHandler(boolean once) { runOnce = once; }
|
69
|
+
|
70
|
+
protected void setError(Exception err) { error = err; }
|
71
|
+
public Exception getError() { return error; }
|
72
|
+
public boolean isRunOnce() { return runOnce; }
|
73
|
+
public abstract void run();
|
74
|
+
}
|
75
|
+
|
76
|
+
private static void runHandlers(Collection<StateHandler> handlers)
|
77
|
+
{
|
78
|
+
for(StateHandler handler: handlers) {
|
79
|
+
handler.run();
|
80
|
+
Exception error = handler.getError();
|
81
|
+
if (error != null)
|
82
|
+
{
|
83
|
+
Logger.E(TAG, error);
|
84
|
+
Thread.dumpStack();
|
85
|
+
}
|
86
|
+
}
|
56
87
|
}
|
57
88
|
|
58
|
-
enum AppState
|
89
|
+
public enum AppState
|
59
90
|
{
|
60
91
|
Undefined("Undefined") {
|
61
92
|
@Override
|
@@ -74,30 +105,52 @@ public class RhodesApplication extends Application{
|
|
74
105
|
public boolean canHandle(AppState state) { return (state == this) || (state == AppStarted); }
|
75
106
|
};
|
76
107
|
|
108
|
+
private static boolean appActivatedFlag = false;
|
109
|
+
|
77
110
|
private Vector<StateHandler> mHandlers = new Vector<StateHandler>();
|
78
111
|
private String TAG;
|
79
112
|
|
80
113
|
private AppState(String tag) { TAG = tag; }
|
81
114
|
|
82
|
-
private synchronized
|
115
|
+
private synchronized Collection<StateHandler> commit()
|
83
116
|
{
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
117
|
+
Vector<StateHandler> handlers = new Vector<StateHandler>();
|
118
|
+
|
119
|
+
Logger.T(TAG, "Starting commit. Current AppState: " + sAppState.TAG);
|
120
|
+
if((this == AppActivated) && (sAppState == Undefined)) {
|
121
|
+
appActivatedFlag = true;
|
122
|
+
Logger.I(TAG, "Cannot commit now, application will be activated when started.");
|
123
|
+
} else {
|
124
|
+
Logger.T(TAG, "Commiting AppState handlers.");
|
125
|
+
Vector<StateHandler> doneHandlers = new Vector<StateHandler>();
|
126
|
+
for (StateHandler handler: mHandlers) {
|
127
|
+
handlers.add(handler);
|
128
|
+
if (handler.isRunOnce()) {
|
129
|
+
doneHandlers.add(handler);
|
130
|
+
}
|
131
|
+
}
|
132
|
+
mHandlers.removeAll(doneHandlers);
|
133
|
+
sAppState = this;
|
90
134
|
}
|
91
|
-
|
135
|
+
Logger.T(TAG, "After AppState commit: " + sAppState.TAG);
|
136
|
+
return handlers;
|
92
137
|
}
|
93
138
|
|
94
139
|
public synchronized void addHandler(StateHandler handler) { mHandlers.add(handler); }
|
95
140
|
public abstract boolean canHandle(AppState state);
|
96
141
|
|
97
|
-
static public void handleState(AppState state) {
|
142
|
+
static public void handleState(AppState state) {
|
143
|
+
runHandlers(state.commit());
|
144
|
+
Logger.I(sAppState.TAG, "Handlers have completed.");
|
145
|
+
if((state == AppStarted) && appActivatedFlag) {
|
146
|
+
runHandlers(AppActivated.commit());
|
147
|
+
Logger.I(sAppState.TAG, "Handlers have completed.");
|
148
|
+
}
|
149
|
+
return;
|
150
|
+
}
|
98
151
|
}
|
99
152
|
|
100
|
-
enum UiState
|
153
|
+
public enum UiState
|
101
154
|
{
|
102
155
|
Undefined("Undefined") {
|
103
156
|
@Override
|
@@ -121,31 +174,50 @@ public class RhodesApplication extends Application{
|
|
121
174
|
|
122
175
|
private UiState(String tag) { TAG = tag; }
|
123
176
|
|
124
|
-
private synchronized
|
177
|
+
private synchronized Collection<StateHandler> commit()
|
125
178
|
{
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
179
|
+
Vector<StateHandler> handlers = new Vector<StateHandler>();
|
180
|
+
|
181
|
+
Logger.T(TAG, "Starting commit. Current UiState: " + sUiState.TAG);
|
182
|
+
|
183
|
+
if (!sUiState.canHandle(this)) {
|
184
|
+
|
185
|
+
Logger.T(TAG, "Commiting UiState handlers.");
|
186
|
+
Vector<StateHandler> doneHandlers = new Vector<StateHandler>();
|
187
|
+
for (StateHandler handler: mHandlers) {
|
188
|
+
handlers.add(handler);
|
189
|
+
if (handler.isRunOnce()) {
|
190
|
+
doneHandlers.add(handler);
|
191
|
+
}
|
192
|
+
}
|
193
|
+
mHandlers.removeAll(doneHandlers);
|
194
|
+
sUiState = this;
|
195
|
+
}
|
196
|
+
Logger.T(TAG, "After UiState commit: " + sUiState.TAG);
|
197
|
+
return handlers;
|
134
198
|
}
|
135
199
|
|
136
200
|
public synchronized void addHandler(StateHandler handler) { mHandlers.add(handler); }
|
137
201
|
public abstract boolean canHandle(UiState state);
|
138
202
|
|
139
|
-
static public void handleState(UiState state) {
|
203
|
+
static public void handleState(UiState state) {
|
204
|
+
runHandlers(state.commit());
|
205
|
+
Logger.I(sAppState.TAG, "Handlers have completed.");
|
206
|
+
}
|
140
207
|
}
|
141
208
|
|
142
209
|
private static AppState sAppState = AppState.Undefined;
|
143
210
|
private static UiState sUiState = UiState.Undefined;
|
144
211
|
|
212
|
+
public static boolean canHandleNow(AppState state) { return sAppState.canHandle(state); }
|
213
|
+
public static boolean canHandleNow(UiState state) { return sUiState.canHandle(state); }
|
214
|
+
|
145
215
|
public static void runWhen(AppState state, StateHandler handler) {
|
216
|
+
Logger.T(TAG, "Current AppState : " + sAppState.TAG);
|
146
217
|
if (sAppState.canHandle(state)) {
|
147
218
|
Logger.T(TAG, "Running AppState handler immediately: " + state.TAG);
|
148
|
-
|
219
|
+
handler.run();
|
220
|
+
if (handler.isRunOnce())
|
149
221
|
return;
|
150
222
|
}
|
151
223
|
state.addHandler(handler);
|
@@ -153,9 +225,11 @@ public class RhodesApplication extends Application{
|
|
153
225
|
}
|
154
226
|
|
155
227
|
public static void runWhen(UiState state, StateHandler handler) {
|
228
|
+
Logger.T(TAG, "Current UiState : " + sUiState.TAG);
|
156
229
|
if (sUiState.canHandle(state)) {
|
157
230
|
Logger.T(TAG, "Running UiState handler immediately: " + state.TAG);
|
158
|
-
|
231
|
+
handler.run();
|
232
|
+
if (handler.isRunOnce())
|
159
233
|
return;
|
160
234
|
}
|
161
235
|
state.addHandler(handler);
|
@@ -164,13 +238,13 @@ public class RhodesApplication extends Application{
|
|
164
238
|
|
165
239
|
public static void stateChanged(AppState state)
|
166
240
|
{
|
167
|
-
|
168
|
-
AppState.
|
241
|
+
AppState.handleState(state);
|
242
|
+
Logger.I(TAG, "New AppState: " + sAppState.TAG);
|
169
243
|
}
|
170
244
|
public static void stateChanged(UiState state)
|
171
245
|
{
|
172
|
-
sUiState = state;
|
173
246
|
UiState.handleState(state);
|
247
|
+
Logger.I(TAG, "New UiState: " + sUiState.TAG);
|
174
248
|
}
|
175
249
|
|
176
250
|
}
|
@@ -74,7 +74,7 @@ public class RhodesService extends Service {
|
|
74
74
|
|
75
75
|
private static final String TAG = RhodesService.class.getSimpleName();
|
76
76
|
|
77
|
-
private static final boolean DEBUG =
|
77
|
+
private static final boolean DEBUG = false;
|
78
78
|
|
79
79
|
public static final String INTENT_EXTRA_PREFIX = "com.rhomobile.rhodes.";
|
80
80
|
|
@@ -404,8 +404,11 @@ public class RhodesService extends Service {
|
|
404
404
|
|
405
405
|
try {
|
406
406
|
if (Capabilities.PUSH_ENABLED) {
|
407
|
-
|
407
|
+
String pushPin = getPushRegistrationId();
|
408
|
+
if (pushPin.length() == 0)
|
408
409
|
PushService.register();
|
410
|
+
else
|
411
|
+
Log.i(TAG, "PUSH already registered: " + pushPin);
|
409
412
|
}
|
410
413
|
} catch (IllegalAccessException e) {
|
411
414
|
Log.e(TAG, e.getMessage());
|
@@ -512,12 +515,11 @@ public class RhodesService extends Service {
|
|
512
515
|
Logger.D(TAG, "Received PUSH message: " + extras);
|
513
516
|
RhodesApplication.runWhen(
|
514
517
|
RhodesApplication.AppState.AppStarted,
|
515
|
-
new RhodesApplication.StateHandler() {
|
518
|
+
new RhodesApplication.StateHandler(true) {
|
516
519
|
@Override
|
517
|
-
public
|
520
|
+
public void run()
|
518
521
|
{
|
519
522
|
handlePushMessage(extras);
|
520
|
-
return true;
|
521
523
|
}
|
522
524
|
});
|
523
525
|
break;
|
@@ -583,9 +585,8 @@ public class RhodesService extends Service {
|
|
583
585
|
}
|
584
586
|
}
|
585
587
|
|
586
|
-
public void setMainView(MainView v) {
|
587
|
-
RhodesActivity
|
588
|
-
ra.setMainView(v);
|
588
|
+
public void setMainView(MainView v) throws NullPointerException {
|
589
|
+
RhodesActivity.safeGetInstance().setMainView(v);
|
589
590
|
}
|
590
591
|
|
591
592
|
public MainView getMainView() {
|
@@ -638,7 +639,7 @@ public class RhodesService extends Service {
|
|
638
639
|
aboutDialog.setCancelable(true);
|
639
640
|
aboutDialog.show();
|
640
641
|
}
|
641
|
-
}
|
642
|
+
});
|
642
643
|
}
|
643
644
|
|
644
645
|
public static void showLogView() {
|
@@ -649,7 +650,7 @@ public class RhodesService extends Service {
|
|
649
650
|
logViewDialog.setCancelable(true);
|
650
651
|
logViewDialog.show();
|
651
652
|
}
|
652
|
-
}
|
653
|
+
});
|
653
654
|
}
|
654
655
|
|
655
656
|
public static void showLogOptions() {
|
@@ -660,7 +661,7 @@ public class RhodesService extends Service {
|
|
660
661
|
logOptionsDialog.setCancelable(true);
|
661
662
|
logOptionsDialog.show();
|
662
663
|
}
|
663
|
-
}
|
664
|
+
});
|
664
665
|
}
|
665
666
|
|
666
667
|
// Called from native code
|
@@ -1109,7 +1110,7 @@ public class RhodesService extends Service {
|
|
1109
1110
|
Logger.E(TAG, "Can't install file from " + tmpFile.getAbsolutePath() + ": " + e.getMessage());
|
1110
1111
|
}
|
1111
1112
|
}
|
1112
|
-
}
|
1113
|
+
});
|
1113
1114
|
}
|
1114
1115
|
}
|
1115
1116
|
catch (IOException e) {
|
@@ -1206,7 +1207,7 @@ public class RhodesService extends Service {
|
|
1206
1207
|
if (Push.PUSH_NOTIFICATIONS.equals(NOTIFICATION_ALWAYS))
|
1207
1208
|
statusNotification = true;
|
1208
1209
|
else if (Push.PUSH_NOTIFICATIONS.equals(NOTIFICATION_BACKGROUND))
|
1209
|
-
statusNotification = !
|
1210
|
+
statusNotification = !RhodesApplication.canHandleNow(RhodesApplication.AppState.AppActivated);
|
1210
1211
|
|
1211
1212
|
if (statusNotification) {
|
1212
1213
|
Intent intent = new Intent(getContext(), RhodesActivity.class);
|
@@ -1215,28 +1216,12 @@ public class RhodesService extends Service {
|
|
1215
1216
|
|
1216
1217
|
if (alert != null) {
|
1217
1218
|
Logger.D(TAG, "PUSH: Alert: " + alert);
|
1218
|
-
|
1219
|
-
RhodesApplication.UiState.MainActivityStarted,
|
1220
|
-
new RhodesApplication.StateHandler() {
|
1221
|
-
@Override
|
1222
|
-
public boolean run() {
|
1223
|
-
Alert.showPopup(alert);
|
1224
|
-
return true;
|
1225
|
-
}
|
1226
|
-
});
|
1219
|
+
Alert.showPopup(alert);
|
1227
1220
|
}
|
1228
1221
|
final String sound = extras.getString("sound");
|
1229
1222
|
if (sound != null) {
|
1230
1223
|
Logger.D(TAG, "PUSH: Sound file name: " + sound);
|
1231
|
-
|
1232
|
-
RhodesApplication.UiState.MainActivityStarted,
|
1233
|
-
new RhodesApplication.StateHandler() {
|
1234
|
-
@Override
|
1235
|
-
public boolean run() {
|
1236
|
-
Alert.playFile("/public/alerts/" + sound, null);
|
1237
|
-
return true;
|
1238
|
-
}
|
1239
|
-
});
|
1224
|
+
Alert.playFile("/public/alerts/" + sound, null);
|
1240
1225
|
}
|
1241
1226
|
String vibrate = extras.getString("vibrate");
|
1242
1227
|
if (vibrate != null) {
|
@@ -1250,15 +1235,7 @@ public class RhodesService extends Service {
|
|
1250
1235
|
}
|
1251
1236
|
final int arg_duration = duration;
|
1252
1237
|
Logger.D(TAG, "Vibrate " + duration + " seconds");
|
1253
|
-
|
1254
|
-
RhodesApplication.UiState.MainActivityStarted,
|
1255
|
-
new RhodesApplication.StateHandler() {
|
1256
|
-
@Override
|
1257
|
-
public boolean run() {
|
1258
|
-
Alert.vibrate(arg_duration);
|
1259
|
-
return true;
|
1260
|
-
}
|
1261
|
-
});
|
1238
|
+
Alert.vibrate(arg_duration);
|
1262
1239
|
}
|
1263
1240
|
|
1264
1241
|
String syncSources = extras.getString("do_sync");
|
@@ -1272,28 +1249,12 @@ public class RhodesService extends Service {
|
|
1272
1249
|
break;
|
1273
1250
|
} else {
|
1274
1251
|
final String arg_source = source.trim();
|
1275
|
-
|
1276
|
-
RhodesApplication.AppState.AppStarted,
|
1277
|
-
new RhodesApplication.StateHandler() {
|
1278
|
-
@Override
|
1279
|
-
public boolean run() {
|
1280
|
-
doSyncSource(arg_source);
|
1281
|
-
return true;
|
1282
|
-
}
|
1283
|
-
});
|
1252
|
+
doSyncSource(arg_source);
|
1284
1253
|
}
|
1285
1254
|
}
|
1286
1255
|
|
1287
1256
|
if (syncAll) {
|
1288
|
-
|
1289
|
-
RhodesApplication.AppState.AppStarted,
|
1290
|
-
new RhodesApplication.StateHandler() {
|
1291
|
-
@Override
|
1292
|
-
public boolean run() {
|
1293
|
-
doSyncAllSources(true);
|
1294
|
-
return true;
|
1295
|
-
}
|
1296
|
-
});
|
1257
|
+
doSyncAllSources(true);
|
1297
1258
|
}
|
1298
1259
|
}
|
1299
1260
|
}
|
@@ -1337,7 +1298,7 @@ public class RhodesService extends Service {
|
|
1337
1298
|
RhodesService rs = RhodesService.getInstance();
|
1338
1299
|
if(rs != null) rs.wakeLock.acquire(true);
|
1339
1300
|
else Logger.E(TAG, "rho_sys_set_sleeping() - No RhodesService has initialized !!!"); }
|
1340
|
-
}
|
1301
|
+
});
|
1341
1302
|
}
|
1342
1303
|
}
|
1343
1304
|
return wasEnabled;
|
@@ -1395,7 +1356,7 @@ public class RhodesService extends Service {
|
|
1395
1356
|
public void startActivity(Intent intent) {
|
1396
1357
|
|
1397
1358
|
RhodesActivity ra = RhodesActivity.getInstance();
|
1398
|
-
if(intent.getComponent().compareTo(new ComponentName(this, RhodesActivity.class.getName())) == 0) {
|
1359
|
+
if(intent.getComponent() != null && intent.getComponent().compareTo(new ComponentName(this, RhodesActivity.class.getName())) == 0) {
|
1399
1360
|
Logger.T(TAG, "Start or bring main activity: " + RhodesActivity.class.getName() + ".");
|
1400
1361
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
1401
1362
|
if (ra == null) {
|
@@ -1406,6 +1367,19 @@ public class RhodesService extends Service {
|
|
1406
1367
|
}
|
1407
1368
|
|
1408
1369
|
if (ra != null) {
|
1370
|
+
Logger.T(TAG, "Starting new activity on top.");
|
1371
|
+
if (DEBUG) {
|
1372
|
+
Bundle extras = intent.getExtras();
|
1373
|
+
if (extras != null) {
|
1374
|
+
for (String key: extras.keySet()) {
|
1375
|
+
Object val = extras.get(key);
|
1376
|
+
if(val != null)
|
1377
|
+
Log.d(TAG, key + ": " + val.toString());
|
1378
|
+
else
|
1379
|
+
Log.d(TAG, key + ": <empty>");
|
1380
|
+
}
|
1381
|
+
}
|
1382
|
+
}
|
1409
1383
|
ra.startActivity(intent);
|
1410
1384
|
} else {
|
1411
1385
|
throw new IllegalStateException("Trying to start activity, but there is no main activity instance (we are in background, no UI active)");
|
@@ -1434,13 +1408,8 @@ public class RhodesService extends Service {
|
|
1434
1408
|
throw new IllegalStateException("No rhodes service instance at this moment");
|
1435
1409
|
|
1436
1410
|
Logger.T(TAG, "Bring main activity to front");
|
1437
|
-
|
1438
|
-
Logger.T(TAG, "There is main activity, should bring to front");
|
1439
|
-
else
|
1440
|
-
Logger.T(TAG, "There is no main activity, should start new one");
|
1441
|
-
|
1411
|
+
|
1442
1412
|
Intent intent = new Intent(srv, RhodesActivity.class);
|
1443
|
-
// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
1444
1413
|
srv.startActivity(intent);
|
1445
1414
|
}
|
1446
1415
|
|