rhodes 2.2.4.beta.1 → 2.2.5.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +10 -0
- data/Rakefile +119 -3
- data/lib/build/jake.rb +15 -1
- data/lib/framework/dateME.rb +6 -1
- data/lib/framework/rho/render.rb +18 -15
- data/lib/framework/rho/rho.rb +105 -43
- data/lib/framework/rho/rhoapplication.rb +1 -1
- data/lib/framework/rho/rhocontact.rb +41 -13
- data/lib/framework/rho/rhocontroller.rb +10 -1
- data/lib/framework/rho/rhoevent_c.rb +6 -1
- data/lib/framework/rho/rhosupport.rb +1 -1
- data/lib/framework/rhodes.rb +1 -1
- data/lib/framework/rholang/rhomsg_de.rb +1 -1
- data/lib/framework/rholang/rhomsg_es.rb +1 -1
- data/lib/framework/rholang/rhomsg_it.rb +28 -0
- data/lib/framework/rhom/rhom.rb +6 -0
- data/lib/framework/rhom/rhom_model.rb +14 -7
- data/lib/framework/rhom/rhom_object_factory.rb +121 -56
- data/lib/framework/version.rb +1 -1
- data/lib/rhodes.rb +1 -1
- data/platform/android/Rhodes/AndroidManifest.full.xml +62 -0
- data/platform/android/Rhodes/AndroidManifest.xml +3 -34
- data/platform/android/Rhodes/jni/include/rhodes/JNIRhodes.h +17 -2
- data/platform/android/Rhodes/jni/src/alert.cpp +16 -0
- data/platform/android/Rhodes/jni/src/callbacks.cpp +27 -3
- data/platform/android/Rhodes/jni/src/nativebar.cpp +3 -0
- data/platform/android/Rhodes/jni/src/nativeview.cpp +131 -1
- data/platform/android/Rhodes/jni/src/phonebook.cpp +102 -41
- data/platform/android/Rhodes/jni/src/rhodes.cpp +113 -32
- data/platform/android/Rhodes/jni/src/ringtones.cpp +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Capabilities.java +1 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +9 -8
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +184 -49
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/SplashScreen.java +49 -25
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/Alert.java +104 -57
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/EventStore.java +36 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocation.java +24 -14
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java +7 -8
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +185 -3
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoNativeViewManager.java +54 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/Contact.java +107 -14
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorNew.java +72 -24
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorOld.java +22 -21
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/Phonebook.java +91 -11
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/util/PerformOnUiThread.java +10 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/ChromeClientNew.java +11 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebSettingsNew.java +10 -0
- data/platform/android/build/android.rake +50 -9
- data/platform/android/build/librhocommon_build.files +1 -0
- data/platform/bb/Hsqldb/src/org/hsqldb/Parser.java +3 -2
- data/platform/bb/Hsqldb/src/org/hsqldb/SchemaManager.java +3 -1
- data/platform/bb/Hsqldb/src/org/hsqldb/Session.java +7 -0
- data/platform/bb/Hsqldb/src/org/hsqldb/Tokenizer.java +2 -2
- data/platform/bb/RubyVM/RubyVM.jdp +1 -0
- data/platform/bb/RubyVM/src/com/rho/AppBuildConfig.java +22 -0
- data/platform/bb/RubyVM/src/com/rho/RhoRuby.java +5 -0
- data/platform/bb/RubyVM/src/com/rho/net/RhoConnection.java +1 -1
- data/platform/bb/RubyVM/src/com/rho/sync/SyncEngine.java +51 -4
- data/platform/bb/RubyVM/src/com/rho/sync/SyncNotify.java +21 -10
- data/platform/bb/RubyVM/src/com/rho/sync/SyncSource.java +82 -33
- data/platform/bb/RubyVM/src/com/rho/sync/SyncThread.java +59 -6
- data/platform/bb/RubyVM/src/com/xruby/GeneratedMethods/RubyFloat_Methods.java +5 -0
- data/platform/bb/RubyVM/src/com/xruby/GeneratedMethods/RubyString_Methods.java +19 -7
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/ArrayPacker.java +1 -1
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyFloat.java +5 -0
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyString.java +55 -11
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyTime.java +18 -2
- data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyKernelModule.java +8 -5
- data/platform/bb/RubyVM/src/j2me/lang/CharacterMe.java +1 -1
- data/platform/bb/RubyVM/src/j2me/util/StringParser.java +2 -0
- data/platform/bb/build/RubyVM_build.files +1 -0
- data/platform/bb/build/bb.rake +21 -2
- data/platform/bb/rhodes/platform/4.7/com/rho/RhoMainScreen.java +3 -3
- data/platform/bb/rhodes/platform/common/com/rho/RhoMainScreen.java +1 -1
- data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +1 -2
- data/platform/bb/rhodes/src/com/rho/net/NetworkAccess.java +15 -16
- data/platform/bb/rhodes/src/com/rho/rubyext/RhoCalendar.java +4 -0
- data/platform/bb/rhodes/src/com/rho/rubyext/System.java +58 -0
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +90 -4
- data/platform/iphone/Classes/AppManager/AppManager.m +43 -5
- data/platform/iphone/Classes/Event/Event.h +2 -0
- data/platform/iphone/Classes/Event/Event.m +12 -1
- data/platform/iphone/Classes/GeoLocation/LocationController.m +9 -3
- data/platform/iphone/Classes/MapView/MapViewController.m +20 -9
- data/platform/iphone/Classes/NativeBar.m +27 -0
- data/platform/iphone/Classes/Phonebook/phonebook.m +17 -0
- data/platform/iphone/Classes/RhoAlert.m +61 -1
- data/platform/iphone/Classes/RhoMainView.h +1 -0
- data/platform/iphone/Classes/Rhodes.h +2 -0
- data/platform/iphone/Classes/Rhodes.m +108 -1
- data/platform/iphone/Classes/SimpleMainView.h +4 -0
- data/platform/iphone/Classes/SimpleMainView.m +30 -3
- data/platform/iphone/Classes/SplashViewController.m +3 -1
- data/platform/iphone/Classes/TabbedMainView.h +2 -0
- data/platform/iphone/Classes/TabbedMainView.m +63 -11
- data/platform/iphone/Classes/rho/net/NetRequestImpl.m +26 -0
- data/platform/iphone/Info.plist +12 -1
- data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +8 -0
- data/platform/iphone/rbuild/iphone.rake +181 -25
- data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +5 -5
- data/platform/shared/common/IRhoThreadImpl.h +1 -1
- data/platform/shared/common/PosixThreadImpl.cpp +5 -3
- data/platform/shared/common/PosixThreadImpl.h +1 -1
- data/platform/shared/common/RhoFilePath.h +11 -0
- data/platform/shared/common/RhoNativeViewManager.h +17 -0
- data/platform/shared/common/RhoThread.h +1 -1
- data/platform/shared/common/RhodesApp.cpp +29 -8
- data/platform/shared/common/ThreadQueue.cpp +5 -3
- data/platform/shared/common/ThreadQueue.h +2 -1
- data/platform/shared/common/app_build_configs.c +25 -0
- data/platform/shared/common/app_build_configs.h +11 -0
- data/platform/shared/net/AsyncHttp.cpp +5 -5
- data/platform/shared/net/CURLNetRequest.cpp +25 -7
- data/platform/shared/net/CURLNetRequest.h +2 -1
- data/platform/shared/net/HttpServer.cpp +28 -0
- data/platform/shared/ruby/ext/nativebar/nativebar.i +3 -0
- data/platform/shared/ruby/ext/nativebar/nativebar_wrap.c +26 -1
- data/platform/shared/ruby/ext/rho/rhoruby.c +6 -0
- data/platform/shared/ruby/ext/rho/rhoruby.h +1 -0
- data/platform/shared/ruby/ext/rho/rhosupport.c +15 -2
- data/platform/shared/ruby/ext/syncengine/syncengine.i +14 -2
- data/platform/shared/ruby/ext/syncengine/syncengine_wrap.c +97 -2
- data/platform/shared/ruby/ext/system/system.i +13 -0
- data/platform/shared/ruby/ext/system/system_wrap.c +104 -1
- data/platform/shared/rubyext/RhoAppAdapter.cpp +7 -0
- data/platform/shared/sync/SyncEngine.cpp +43 -3
- data/platform/shared/sync/SyncEngine.h +13 -0
- data/platform/shared/sync/SyncNotify.cpp +41 -23
- data/platform/shared/sync/SyncNotify.h +18 -4
- data/platform/shared/sync/SyncSource.cpp +52 -14
- data/platform/shared/sync/SyncSource.h +1 -0
- data/platform/shared/sync/SyncThread.cpp +29 -9
- data/platform/shared/sync/SyncThread.h +4 -2
- data/platform/wm/RhoLib/RhoLib.vcproj +8 -0
- data/platform/wm/build/build_inf.js +15 -9
- data/platform/wm/build/wm.rake +10 -5
- data/platform/wm/rhodes/Alert.cpp +10 -0
- data/platform/wm/rhodes/Alert.h +3 -3
- data/platform/wm/rhodes/MainWindow.cpp +171 -26
- data/platform/wm/rhodes/MainWindow.h +23 -1
- data/platform/wm/rhodes/MetaHandler.cpp +192 -0
- data/platform/wm/rhodes/MetaHandler.h +31 -0
- data/platform/wm/rhodes/RhoNativeViewManager.cpp +126 -0
- data/platform/wm/rhodes/RhoNativeViewManagerWM.h +20 -0
- data/platform/wm/rhodes/Rhodes.cpp +91 -2
- data/platform/wm/rhodes/Rhodes.rc +15 -6
- data/platform/wm/rhodes/SyncStatusDlg.cpp +32 -0
- data/platform/wm/rhodes/SyncStatusDlg.h +29 -0
- data/platform/wm/rhodes/resource.h +5 -2
- data/platform/wm/rhodes/rho/common/RhoThreadImpl.cpp +3 -1
- data/platform/wm/rhodes/rho/common/RhoThreadImpl.h +1 -1
- data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +146 -14
- data/platform/wm/rhodes/rhodes.vcproj +28 -0
- data/rakefile.rb +119 -3
- data/res/build-tools/iphonesim/README +58 -0
- data/res/build-tools/iphonesim/Source/iPhoneSimulator.h +43 -0
- data/res/build-tools/iphonesim/Source/iPhoneSimulator.m +224 -0
- data/res/build-tools/iphonesim/Source/main.m +52 -0
- data/res/build-tools/iphonesim/Source/nsprintf.h +3 -0
- data/res/build-tools/iphonesim/Source/nsprintf.m +42 -0
- data/res/build-tools/iphonesim/build/Release/iphonesim +0 -0
- data/res/build-tools/iphonesim/iPhoneSimulatorRemoteClient/iPhoneSimulatorRemoteClient.h +124 -0
- data/res/build-tools/iphonesim/iphonesim.xcodeproj/project.pbxproj +261 -0
- data/res/build-tools/iphonesim/iphonesim_Prefix.pch +7 -0
- data/res/generators/rhogen.rb +5 -0
- data/res/generators/templates/application/app/layout.erb +7 -13
- data/res/generators/templates/application/app/loading.png +0 -0
- data/res/generators/templates/application/build.yml +3 -0
- data/res/generators/templates/application/icon/icon114.png +0 -0
- data/res/generators/templates/application/icon/icon57.png +0 -0
- data/res/generators/templates/application/icon/icon72.png +0 -0
- data/res/generators/templates/application/public/css/iphone.css +96 -0
- data/res/generators/templates/application/public/images/backButton.png +0 -0
- data/res/generators/templates/application/public/jqtouch/jqtouch.js +2 -1
- data/res/generators/templates/application/rhoconfig.txt +2 -0
- data/rhodes.gemspec +1 -1
- data/spec/phone_spec/app/spec/array_pack_spec.rb +108 -0
- data/spec/phone_spec/app/spec/bulksync_spec.rb +1 -0
- data/spec/phone_spec/app/spec/date_spec.rb +27 -0
- data/spec/phone_spec/app/spec/fixtures/classes.rb +91 -0
- data/spec/phone_spec/app/spec/lstrip_spec.rb +57 -0
- data/spec/phone_spec/app/spec/rho_spec.rb +50 -19
- data/spec/phone_spec/app/spec/rhom_object_spec.rb +78 -0
- data/spec/phone_spec/app/spec/rstrip_spec.rb +51 -0
- data/spec/phone_spec/app/spec/strip_spec.rb +50 -0
- data/spec/phone_spec/app/spec/syncengine_spec.rb +46 -3
- data/spec/phone_spec/app/spec_runner.rb +6 -0
- metadata +34 -4
@@ -15,6 +15,7 @@ import android.widget.ImageView;
|
|
15
15
|
|
16
16
|
public class SplashScreen {
|
17
17
|
|
18
|
+
private static final String LOADING_ANDROID_PNG = "apps/app/loading.android.png";
|
18
19
|
private static final String LOADING_PNG = "apps/app/loading.png";
|
19
20
|
private static final String LOADING_PAGE = "apps/app/loading.html";
|
20
21
|
|
@@ -26,7 +27,7 @@ public class SplashScreen {
|
|
26
27
|
private native void nativeHide();
|
27
28
|
|
28
29
|
public class SplashImageView extends ImageView {
|
29
|
-
|
30
|
+
public boolean setupExecuted = false;
|
30
31
|
|
31
32
|
public SplashImageView(Context ctx) {
|
32
33
|
super(ctx);
|
@@ -36,7 +37,7 @@ public class SplashScreen {
|
|
36
37
|
RhodesService.platformLog(TAG, "Splash Screen Image REAL DRAWING !");
|
37
38
|
super.onDraw(canvas);
|
38
39
|
if (!setupExecuted) {
|
39
|
-
Rhodes.
|
40
|
+
Rhodes.runPostponedSetup();
|
40
41
|
setupExecuted = true;
|
41
42
|
}
|
42
43
|
}
|
@@ -51,7 +52,9 @@ public class SplashScreen {
|
|
51
52
|
//RhodesService r = RhodesService.getInstance();
|
52
53
|
//boolean bc = r.isBundleChanged();
|
53
54
|
|
54
|
-
String file =
|
55
|
+
String file = LOADING_ANDROID_PNG;
|
56
|
+
|
57
|
+
boolean loading_android_ok = false;
|
55
58
|
|
56
59
|
Bitmap bitmap = null;
|
57
60
|
try {
|
@@ -64,38 +67,59 @@ public class SplashScreen {
|
|
64
67
|
v.setAdjustViewBounds(false);
|
65
68
|
v.setId(RhodesService.RHO_SPLASH_VIEW);
|
66
69
|
view = v;
|
70
|
+
loading_android_ok = true;
|
67
71
|
}
|
68
72
|
catch (IOException e) {
|
69
|
-
|
70
|
-
|
71
|
-
String page = LOADING_PAGE;
|
72
|
-
|
73
|
-
boolean hasNeededPage;
|
73
|
+
}
|
74
|
+
if (!loading_android_ok) {
|
74
75
|
try {
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
v.loadUrl("file:///android_asset/" + page);
|
76
|
+
file = LOADING_PNG;
|
77
|
+
InputStream is = am.open(file);
|
78
|
+
bitmap = BitmapFactory.decodeStream(is);
|
79
|
+
is.close();
|
80
|
+
|
81
|
+
ImageView v = new SplashImageView(ctx);
|
82
|
+
v.setImageBitmap(bitmap);
|
83
|
+
v.setAdjustViewBounds(false);
|
84
|
+
v.setId(RhodesService.RHO_SPLASH_VIEW);
|
85
|
+
view = v;
|
86
86
|
}
|
87
|
-
|
88
|
-
|
87
|
+
catch (IOException e) {
|
88
|
+
|
89
|
+
WebView v = RhodesService.createLoadingWebView(ctx);
|
90
|
+
|
91
|
+
String page = LOADING_PAGE;
|
92
|
+
|
93
|
+
boolean hasNeededPage;
|
94
|
+
try {
|
95
|
+
InputStream is1 = am.open(page);
|
96
|
+
if (is1 != null)
|
97
|
+
is1.close();
|
98
|
+
hasNeededPage = true;
|
99
|
+
}
|
100
|
+
catch (IOException e1) {
|
101
|
+
hasNeededPage = false;
|
102
|
+
}
|
103
|
+
|
104
|
+
if (hasNeededPage) {
|
105
|
+
v.loadUrl("file:///android_asset/" + page);
|
106
|
+
}
|
107
|
+
else {
|
108
|
+
v.loadData("<html><title>Loading</title><body>Loading...</body></html>", "text/html", "utf-8");
|
109
|
+
}
|
110
|
+
|
111
|
+
v.setId(RhodesService.RHO_SPLASH_VIEW);
|
112
|
+
|
113
|
+
view = v;
|
89
114
|
}
|
90
|
-
|
91
|
-
v.setId(RhodesService.RHO_SPLASH_VIEW);
|
92
|
-
|
93
|
-
view = v;
|
94
115
|
}
|
95
116
|
}
|
96
117
|
|
97
118
|
public void start(ViewGroup outer) {
|
98
119
|
outer.removeAllViews();
|
120
|
+
if (view instanceof SplashImageView) {
|
121
|
+
((SplashImageView)view).setupExecuted = false;
|
122
|
+
}
|
99
123
|
outer.addView(view);
|
100
124
|
RhodesService.platformLog(TAG, " view was showed on screen");
|
101
125
|
}
|
@@ -55,6 +55,7 @@ public class Alert {
|
|
55
55
|
private static final String TAG = "Alert";
|
56
56
|
|
57
57
|
private static Dialog currentAlert = null;
|
58
|
+
private static TextView s_textView = null;
|
58
59
|
private static MediaPlayer currentMP = null;
|
59
60
|
|
60
61
|
private static native void doCallback(String url, String id, String title);
|
@@ -98,6 +99,33 @@ public class Alert {
|
|
98
99
|
}
|
99
100
|
|
100
101
|
};
|
102
|
+
|
103
|
+
private static class ShowStatusDialog implements Runnable
|
104
|
+
{
|
105
|
+
private String m_strMessage;
|
106
|
+
private String m_strHide;
|
107
|
+
|
108
|
+
public ShowStatusDialog(String strMessage, String strHide)
|
109
|
+
{
|
110
|
+
m_strMessage = strMessage;
|
111
|
+
m_strHide = strHide;
|
112
|
+
}
|
113
|
+
|
114
|
+
@SuppressWarnings("unchecked")
|
115
|
+
public void run()
|
116
|
+
{
|
117
|
+
if ( currentAlert != null )
|
118
|
+
{
|
119
|
+
s_textView.setText(m_strMessage);
|
120
|
+
return;
|
121
|
+
}
|
122
|
+
|
123
|
+
Vector<CustomButton> buttons = new Vector<CustomButton>();
|
124
|
+
buttons.addElement(new CustomButton(m_strHide));
|
125
|
+
|
126
|
+
makeDialog( "", m_strMessage, null, buttons, null);
|
127
|
+
}
|
128
|
+
}
|
101
129
|
|
102
130
|
private static class ShowDialog implements Runnable {
|
103
131
|
private Object params;
|
@@ -108,7 +136,7 @@ public class Alert {
|
|
108
136
|
|
109
137
|
@SuppressWarnings("unchecked")
|
110
138
|
public void run() {
|
111
|
-
String title = "Alert";
|
139
|
+
String title = "";//"Alert";
|
112
140
|
String message = null;
|
113
141
|
Drawable icon = null;
|
114
142
|
String callback = null;
|
@@ -116,7 +144,8 @@ public class Alert {
|
|
116
144
|
|
117
145
|
Context ctx = RhodesService.getInstance().getContext();
|
118
146
|
|
119
|
-
if (params instanceof String)
|
147
|
+
if (params instanceof String)
|
148
|
+
{
|
120
149
|
message = (String)params;
|
121
150
|
buttons.addElement(new CustomButton("OK"));
|
122
151
|
}
|
@@ -184,63 +213,71 @@ public class Alert {
|
|
184
213
|
}
|
185
214
|
}
|
186
215
|
|
187
|
-
|
188
|
-
return;
|
189
|
-
|
190
|
-
Dialog dialog = new Dialog(ctx);
|
191
|
-
dialog.setTitle(title);
|
192
|
-
dialog.setCancelable(false);
|
193
|
-
dialog.setCanceledOnTouchOutside(false);
|
194
|
-
|
195
|
-
LinearLayout main = new LinearLayout(ctx);
|
196
|
-
main.setOrientation(LinearLayout.VERTICAL);
|
197
|
-
main.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
|
198
|
-
main.setPadding(10, 10, 10, 10);
|
199
|
-
|
200
|
-
LinearLayout top = new LinearLayout(ctx);
|
201
|
-
top.setOrientation(LinearLayout.HORIZONTAL);
|
202
|
-
top.setGravity(Gravity.CENTER);
|
203
|
-
top.setPadding(10, 10, 10, 10);
|
204
|
-
top.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
|
205
|
-
main.addView(top);
|
206
|
-
|
207
|
-
if (icon != null) {
|
208
|
-
ImageView imgView = new ImageView(ctx);
|
209
|
-
imgView.setImageDrawable(icon);
|
210
|
-
imgView.setScaleType(ImageView.ScaleType.CENTER);
|
211
|
-
imgView.setPadding(10, 10, 10, 10);
|
212
|
-
top.addView(imgView);
|
213
|
-
}
|
214
|
-
|
215
|
-
TextView textView = new TextView(ctx);
|
216
|
-
textView.setText(message);
|
217
|
-
textView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
|
218
|
-
textView.setGravity(Gravity.CENTER);
|
219
|
-
top.addView(textView);
|
220
|
-
|
221
|
-
LinearLayout bottom = new LinearLayout(ctx);
|
222
|
-
bottom.setOrientation(buttons.size() > 3 ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL);
|
223
|
-
bottom.setGravity(Gravity.CENTER);
|
224
|
-
bottom.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
|
225
|
-
main.addView(bottom);
|
226
|
-
|
227
|
-
for (int i = 0, lim = buttons.size(); i < lim; ++i) {
|
228
|
-
CustomButton btn = buttons.elementAt(i);
|
229
|
-
Button button = new Button(ctx);
|
230
|
-
button.setText(btn.title);
|
231
|
-
button.setOnClickListener(new ShowDialogListener(callback, btn.id, btn.title, dialog));
|
232
|
-
button.setLayoutParams(new LinearLayout.LayoutParams(
|
233
|
-
lim > 3 ? LayoutParams.FILL_PARENT : LayoutParams.WRAP_CONTENT,
|
234
|
-
LayoutParams.WRAP_CONTENT, 1));
|
235
|
-
bottom.addView(button);
|
236
|
-
}
|
237
|
-
|
238
|
-
dialog.setContentView(main);
|
239
|
-
dialog.show();
|
240
|
-
|
241
|
-
currentAlert = dialog;
|
216
|
+
makeDialog( title, message, icon, buttons, callback);
|
242
217
|
}
|
243
218
|
};
|
219
|
+
|
220
|
+
private static void makeDialog( String title, String message, Drawable icon, Vector<CustomButton> buttons, String callback)
|
221
|
+
{
|
222
|
+
if (message == null)
|
223
|
+
return;
|
224
|
+
|
225
|
+
Context ctx = RhodesService.getInstance().getContext();
|
226
|
+
|
227
|
+
Dialog dialog = new Dialog(ctx);
|
228
|
+
dialog.setTitle(title);
|
229
|
+
dialog.setCancelable(false);
|
230
|
+
dialog.setCanceledOnTouchOutside(false);
|
231
|
+
|
232
|
+
LinearLayout main = new LinearLayout(ctx);
|
233
|
+
main.setOrientation(LinearLayout.VERTICAL);
|
234
|
+
main.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
|
235
|
+
main.setPadding(10, 10, 10, 10);
|
236
|
+
|
237
|
+
LinearLayout top = new LinearLayout(ctx);
|
238
|
+
top.setOrientation(LinearLayout.HORIZONTAL);
|
239
|
+
top.setGravity(Gravity.CENTER);
|
240
|
+
top.setPadding(10, 10, 10, 10);
|
241
|
+
top.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
|
242
|
+
main.addView(top);
|
243
|
+
|
244
|
+
if (icon != null) {
|
245
|
+
ImageView imgView = new ImageView(ctx);
|
246
|
+
imgView.setImageDrawable(icon);
|
247
|
+
imgView.setScaleType(ImageView.ScaleType.CENTER);
|
248
|
+
imgView.setPadding(10, 10, 10, 10);
|
249
|
+
top.addView(imgView);
|
250
|
+
}
|
251
|
+
|
252
|
+
TextView textView = new TextView(ctx);
|
253
|
+
s_textView = textView;
|
254
|
+
textView.setText(message);
|
255
|
+
textView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
|
256
|
+
textView.setGravity(Gravity.CENTER);
|
257
|
+
top.addView(textView);
|
258
|
+
|
259
|
+
LinearLayout bottom = new LinearLayout(ctx);
|
260
|
+
bottom.setOrientation(buttons.size() > 3 ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL);
|
261
|
+
bottom.setGravity(Gravity.CENTER);
|
262
|
+
bottom.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
|
263
|
+
main.addView(bottom);
|
264
|
+
|
265
|
+
for (int i = 0, lim = buttons.size(); i < lim; ++i) {
|
266
|
+
CustomButton btn = buttons.elementAt(i);
|
267
|
+
Button button = new Button(ctx);
|
268
|
+
button.setText(btn.title);
|
269
|
+
button.setOnClickListener(new ShowDialogListener(callback, btn.id, btn.title, dialog));
|
270
|
+
button.setLayoutParams(new LinearLayout.LayoutParams(
|
271
|
+
lim > 3 ? LayoutParams.FILL_PARENT : LayoutParams.WRAP_CONTENT,
|
272
|
+
LayoutParams.WRAP_CONTENT, 1));
|
273
|
+
bottom.addView(button);
|
274
|
+
}
|
275
|
+
|
276
|
+
dialog.setContentView(main);
|
277
|
+
dialog.show();
|
278
|
+
|
279
|
+
currentAlert = dialog;
|
280
|
+
}
|
244
281
|
|
245
282
|
private static class HideDialog implements Runnable {
|
246
283
|
public void run() {
|
@@ -274,6 +311,16 @@ public class Alert {
|
|
274
311
|
reportFail("hidePopup", e);
|
275
312
|
}
|
276
313
|
}
|
314
|
+
|
315
|
+
public static void showStatusPopup(String message, String hide) {
|
316
|
+
try {
|
317
|
+
Logger.I(TAG, "showStatusPopup");
|
318
|
+
PerformOnUiThread.exec(new ShowStatusDialog(message, hide), false);
|
319
|
+
}
|
320
|
+
catch (Exception e) {
|
321
|
+
reportFail("showStatusPopup", e);
|
322
|
+
}
|
323
|
+
}
|
277
324
|
|
278
325
|
public static void vibrate(int duration) {
|
279
326
|
try {
|
@@ -45,6 +45,29 @@ public class EventStore {
|
|
45
45
|
throw new IllegalAccessException("Capability CALENDAR disabled");
|
46
46
|
}
|
47
47
|
|
48
|
+
public static boolean hasCalendar() {
|
49
|
+
if (!Capabilities.CALENDAR_ENABLED) {
|
50
|
+
Logger.E(TAG, "Calendar capability is not enabled !!!");
|
51
|
+
return false;
|
52
|
+
}
|
53
|
+
final Cursor calendarCursor = getContentResolver().query(
|
54
|
+
Uri.parse("content://" + AUTHORITY + "/calendars"),
|
55
|
+
new String[] {"_id"},
|
56
|
+
null, null, null);
|
57
|
+
try {
|
58
|
+
if (calendarCursor != null) {
|
59
|
+
if (calendarCursor.moveToFirst())
|
60
|
+
return true;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
finally {
|
64
|
+
if (calendarCursor != null) {
|
65
|
+
calendarCursor.close();
|
66
|
+
}
|
67
|
+
}
|
68
|
+
return false;
|
69
|
+
}
|
70
|
+
|
48
71
|
private static ContentResolver getContentResolver() {
|
49
72
|
return RhodesService.getInstance().getContext().getContentResolver();
|
50
73
|
}
|
@@ -105,9 +128,20 @@ public class EventStore {
|
|
105
128
|
String eid = eventCursor.getString(0);
|
106
129
|
Event event = new Event(eid);
|
107
130
|
|
131
|
+
Date eventStartDate = new Date(eventCursor.getLong(2));
|
132
|
+
Date eventEndDate = new Date(eventCursor.getLong(3));
|
133
|
+
if (eventStartDate.before(eventEndDate)) {
|
134
|
+
Date tmp = eventStartDate;
|
135
|
+
eventStartDate = eventEndDate;
|
136
|
+
eventEndDate = tmp;
|
137
|
+
}
|
138
|
+
|
139
|
+
if (eventEndDate.before(startDate) || eventStartDate.after(endDate))
|
140
|
+
continue;
|
141
|
+
|
108
142
|
event.title = eventCursor.getString(1);
|
109
|
-
event.startDate =
|
110
|
-
event.endDate =
|
143
|
+
event.startDate = eventStartDate;
|
144
|
+
event.endDate = eventEndDate;
|
111
145
|
event.location = eventCursor.getString(4);
|
112
146
|
event.notes = eventCursor.getString(5);
|
113
147
|
switch (eventCursor.getInt(6)) {
|
@@ -22,12 +22,16 @@ package com.rhomobile.rhodes.geolocation;
|
|
22
22
|
|
23
23
|
import com.rhomobile.rhodes.Capabilities;
|
24
24
|
import com.rhomobile.rhodes.Logger;
|
25
|
+
import com.rhomobile.rhodes.RhodesService;
|
26
|
+
import com.rhomobile.rhodes.util.PerformOnUiThread;
|
25
27
|
|
26
28
|
public class GeoLocation {
|
27
29
|
|
28
30
|
private static final String TAG = "GeoLocation";
|
29
31
|
private static GeoLocationImpl locImpl = null;
|
30
32
|
|
33
|
+
private static int mInactivityTimerId = 0;
|
34
|
+
|
31
35
|
private static void reportFail(String name, Exception e) {
|
32
36
|
Logger.E(TAG, "Call of \"" + name + "\" failed: " + e.getMessage());
|
33
37
|
}
|
@@ -37,13 +41,24 @@ public class GeoLocation {
|
|
37
41
|
throw new IllegalAccessException("Capability GPS disabled");
|
38
42
|
}
|
39
43
|
|
40
|
-
private static void
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
+
private static void updateInactivityTimer() {
|
45
|
+
final int id = ++mInactivityTimerId;
|
46
|
+
PerformOnUiThread.exec(new Runnable() {
|
47
|
+
public void run() {
|
48
|
+
if (id != mInactivityTimerId)
|
49
|
+
return;
|
50
|
+
Logger.D(TAG, "Stop geolocation service by timeout");
|
51
|
+
GeoLocation.stop();
|
52
|
+
}
|
53
|
+
}, RhodesService.getGeoLocationInactivityTimeout());
|
54
|
+
}
|
55
|
+
|
56
|
+
private static GeoLocationImpl getImpl() {
|
44
57
|
synchronized (TAG) {
|
45
58
|
if (locImpl == null)
|
46
59
|
locImpl = new GeoLocationImpl();
|
60
|
+
updateInactivityTimer();
|
61
|
+
return locImpl;
|
47
62
|
}
|
48
63
|
}
|
49
64
|
|
@@ -70,8 +85,7 @@ public class GeoLocation {
|
|
70
85
|
boolean result = false;
|
71
86
|
if (locImpl != null) {
|
72
87
|
checkState();
|
73
|
-
|
74
|
-
result = locImpl.isAvailable();
|
88
|
+
result = getImpl().isAvailable();
|
75
89
|
}
|
76
90
|
Logger.T(TAG, "Geo location service is " + (result ? "" : "not ") + "available");
|
77
91
|
return result;
|
@@ -87,8 +101,7 @@ public class GeoLocation {
|
|
87
101
|
try {
|
88
102
|
checkState();
|
89
103
|
Logger.T(TAG, "getLatitude");
|
90
|
-
|
91
|
-
return locImpl.GetLatitude();
|
104
|
+
return getImpl().getLatitude();
|
92
105
|
}
|
93
106
|
catch (Exception e) {
|
94
107
|
reportFail("getLatitude", e);
|
@@ -101,8 +114,7 @@ public class GeoLocation {
|
|
101
114
|
try {
|
102
115
|
checkState();
|
103
116
|
Logger.T(TAG, "getLongitude");
|
104
|
-
|
105
|
-
return locImpl.GetLongitude();
|
117
|
+
return getImpl().getLongitude();
|
106
118
|
}
|
107
119
|
catch (Exception e) {
|
108
120
|
reportFail("getLongitude", e);
|
@@ -115,8 +127,7 @@ public class GeoLocation {
|
|
115
127
|
try {
|
116
128
|
checkState();
|
117
129
|
Logger.T(TAG, "isKnownPosition");
|
118
|
-
|
119
|
-
return locImpl.isKnownPosition();
|
130
|
+
return getImpl().isKnownPosition();
|
120
131
|
}
|
121
132
|
catch (Exception e) {
|
122
133
|
reportFail("isKnownPosition", e);
|
@@ -134,8 +145,7 @@ public class GeoLocation {
|
|
134
145
|
|
135
146
|
checkState();
|
136
147
|
Logger.T(TAG, "setTimeout");
|
137
|
-
|
138
|
-
locImpl.setTimeout(nsec);
|
148
|
+
getImpl().setTimeout(nsec);
|
139
149
|
}
|
140
150
|
catch (Exception e) {
|
141
151
|
reportFail("setTimeout", e);
|
@@ -107,23 +107,22 @@ public class GeoLocationImpl implements LocationListener {
|
|
107
107
|
determined = false;
|
108
108
|
}
|
109
109
|
|
110
|
-
Logger.T(TAG, "gps enabled: " +
|
111
|
-
Logger.T(TAG, "determined: " +
|
110
|
+
Logger.T(TAG, "gps enabled: " + Boolean.toString(locationManager.isProviderEnabled(PROVIDER)));
|
111
|
+
Logger.T(TAG, "determined: " + Boolean.toString(determined));
|
112
112
|
if (determined) {
|
113
|
-
Logger.T(TAG, "longitude: " +
|
114
|
-
Logger.T(TAG, "latitude: " +
|
113
|
+
Logger.T(TAG, "longitude: " + Double.toString(longitude));
|
114
|
+
Logger.T(TAG, "latitude: " + Double.toString(latitude));
|
115
115
|
}
|
116
116
|
|
117
117
|
if (determined != prevDetermined || latitude != prevLat || longitude != prevLon) {
|
118
118
|
geoCallback();
|
119
119
|
}
|
120
|
-
|
121
120
|
} catch (Exception e) {
|
122
121
|
determined = false;
|
123
122
|
Logger.E(TAG, e.getMessage());
|
124
123
|
}
|
125
124
|
}
|
126
|
-
|
125
|
+
|
127
126
|
public void onLocationChanged(Location location) {
|
128
127
|
Logger.T(TAG, "onLocationChanged");
|
129
128
|
setCurrentGpsLocation(location);
|
@@ -159,11 +158,11 @@ public class GeoLocationImpl implements LocationListener {
|
|
159
158
|
return available;
|
160
159
|
}
|
161
160
|
|
162
|
-
public synchronized double
|
161
|
+
public synchronized double getLatitude() {
|
163
162
|
return latitude;
|
164
163
|
}
|
165
164
|
|
166
|
-
public synchronized double
|
165
|
+
public synchronized double getLongitude() {
|
167
166
|
return longitude;
|
168
167
|
}
|
169
168
|
|