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
@@ -3,6 +3,7 @@
|
|
3
3
|
#include "rhodes/jni/com_rhomobile_rhodes_RhodesService.h"
|
4
4
|
|
5
5
|
#include <common/RhoConf.h>
|
6
|
+
#include <common/app_build_configs.h>
|
6
7
|
#include <logging/RhoLogConf.h>
|
7
8
|
#include <common/RhodesApp.h>
|
8
9
|
#include <sync/SyncThread.h>
|
@@ -223,39 +224,83 @@ jint JNI_OnLoad(JavaVM* vm, void* /*reserved*/)
|
|
223
224
|
return jversion;
|
224
225
|
}
|
225
226
|
|
226
|
-
|
227
|
+
namespace details
|
227
228
|
{
|
228
|
-
jclass clsMap = getJNIClass(RHODES_JAVA_CLASS_MAP);
|
229
|
-
if (!clsMap) return Qnil;
|
230
|
-
jclass clsSet = getJNIClass(RHODES_JAVA_CLASS_SET);
|
231
|
-
if (!clsSet) return Qnil;
|
232
|
-
jclass clsIterator = getJNIClass(RHODES_JAVA_CLASS_ITERATOR);
|
233
|
-
if (!clsIterator) return Qnil;
|
234
229
|
|
235
|
-
|
230
|
+
std::string rho_cast_helper<std::string, jstring>::operator()(JNIEnv *env, jstring s)
|
231
|
+
{
|
232
|
+
const char *ts = env->GetStringUTFChars(s, JNI_FALSE);
|
233
|
+
std::string ret(ts);
|
234
|
+
env->ReleaseStringUTFChars(s, ts);
|
235
|
+
return ret;
|
236
|
+
}
|
237
|
+
|
238
|
+
jstring rho_cast_helper<jstring, char const *>::operator()(JNIEnv *env, char const *s)
|
239
|
+
{
|
240
|
+
return env->NewStringUTF(s);
|
241
|
+
}
|
236
242
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
243
|
+
static rho::common::CMutex rho_cast_java_ruby_mtx;
|
244
|
+
|
245
|
+
static jclass clsString;
|
246
|
+
static jclass clsMap;
|
247
|
+
static jclass clsSet;
|
248
|
+
static jclass clsIterator;
|
249
|
+
|
250
|
+
static jmethodID midMapGet;
|
251
|
+
static jmethodID midMapKeySet;
|
252
|
+
static jmethodID midSetIterator;
|
253
|
+
static jmethodID midIteratorHasNext;
|
254
|
+
static jmethodID midIteratorNext;
|
255
|
+
|
256
|
+
static bool rho_cast_java_ruby_init(JNIEnv *env)
|
257
|
+
{
|
258
|
+
static rho::common::CMutex rho_fd_mtx;
|
259
|
+
static bool initialized = false;
|
260
|
+
if (initialized)
|
261
|
+
return true;
|
262
|
+
|
263
|
+
rho::common::CMutexLock guard(rho_cast_java_ruby_mtx);
|
264
|
+
if (initialized)
|
265
|
+
return true;
|
266
|
+
|
267
|
+
clsString = getJNIClass(RHODES_JAVA_CLASS_STRING);
|
268
|
+
if (!clsString) return false;
|
269
|
+
clsMap = getJNIClass(RHODES_JAVA_CLASS_MAP);
|
270
|
+
if (!clsMap) return false;
|
271
|
+
clsSet = getJNIClass(RHODES_JAVA_CLASS_SET);
|
272
|
+
if (!clsSet) return false;
|
273
|
+
clsIterator = getJNIClass(RHODES_JAVA_CLASS_ITERATOR);
|
274
|
+
if (!clsIterator) return false;
|
275
|
+
|
276
|
+
midMapGet = getJNIClassMethod(env, clsMap, "get", "(Ljava/lang/Object;)Ljava/lang/Object;");
|
277
|
+
if (!midMapGet) return false;
|
278
|
+
midMapKeySet = getJNIClassMethod(env, clsMap, "keySet", "()Ljava/util/Set;");
|
279
|
+
if (!midMapKeySet) return false;
|
280
|
+
midSetIterator = getJNIClassMethod(env, clsSet, "iterator", "()Ljava/util/Iterator;");
|
281
|
+
if (!midSetIterator) return false;
|
282
|
+
midIteratorHasNext = getJNIClassMethod(env, clsIterator, "hasNext", "()Z");
|
283
|
+
if (!midIteratorHasNext) return false;
|
284
|
+
midIteratorNext = getJNIClassMethod(env, clsIterator, "next", "()Ljava/lang/Object;");
|
285
|
+
if (!midIteratorNext) return false;
|
286
|
+
|
287
|
+
initialized = true;
|
288
|
+
return true;
|
289
|
+
}
|
247
290
|
|
248
|
-
|
291
|
+
static VALUE convertJavaMapToRubyHash(JNIEnv *env, jobject objMap)
|
292
|
+
{
|
293
|
+
jobject objSet = env->CallObjectMethod(objMap, midMapKeySet);
|
249
294
|
if (!objSet) return Qnil;
|
250
|
-
jobject objIterator = env->CallObjectMethod(objSet,
|
295
|
+
jobject objIterator = env->CallObjectMethod(objSet, midSetIterator);
|
251
296
|
if (!objIterator) return Qnil;
|
252
297
|
|
253
298
|
CHoldRubyValue retval(rho_ruby_createHash());
|
254
|
-
while(env->CallBooleanMethod(objIterator,
|
299
|
+
while(env->CallBooleanMethod(objIterator, midIteratorHasNext))
|
255
300
|
{
|
256
|
-
jstring objKey = (jstring)env->CallObjectMethod(objIterator,
|
301
|
+
jstring objKey = (jstring)env->CallObjectMethod(objIterator, midIteratorNext);
|
257
302
|
if (!objKey) return Qnil;
|
258
|
-
jstring objValue = (jstring)env->CallObjectMethod(objMap,
|
303
|
+
jstring objValue = (jstring)env->CallObjectMethod(objMap, midMapGet, objKey);
|
259
304
|
if (!objValue) return Qnil;
|
260
305
|
|
261
306
|
std::string const &strKey = rho_cast<std::string>(objKey);
|
@@ -268,20 +313,43 @@ VALUE convertJavaMapToRubyHash(jobject objMap)
|
|
268
313
|
return retval;
|
269
314
|
}
|
270
315
|
|
271
|
-
|
316
|
+
jobject rho_cast_helper<jobject, VALUE>::operator()(JNIEnv *env, VALUE value)
|
272
317
|
{
|
318
|
+
if (!rho_cast_java_ruby_init(env))
|
319
|
+
{
|
320
|
+
env->ThrowNew(getJNIClass(RHODES_JAVA_CLASS_RUNTIME_EXCEPTION), "Java <=> Ruby conversion initialization failed");
|
321
|
+
return NULL;
|
322
|
+
}
|
273
323
|
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
324
|
+
if (NIL_P(value))
|
325
|
+
return NULL;
|
326
|
+
|
327
|
+
if (TYPE(value) == T_STRING)
|
328
|
+
return env->NewStringUTF(RSTRING_PTR(value));
|
329
|
+
|
330
|
+
RAWLOG_ERROR("rho_cast<jobject, VALUE>: unknown type of value");
|
331
|
+
return NULL;
|
280
332
|
}
|
281
333
|
|
282
|
-
|
334
|
+
VALUE rho_cast_helper<VALUE, jobject>::operator()(JNIEnv *env, jobject obj)
|
283
335
|
{
|
284
|
-
|
336
|
+
if (!rho_cast_java_ruby_init(env))
|
337
|
+
{
|
338
|
+
env->ThrowNew(getJNIClass(RHODES_JAVA_CLASS_RUNTIME_EXCEPTION), "Java <=> Ruby conversion initialization failed");
|
339
|
+
return Qnil;
|
340
|
+
}
|
341
|
+
|
342
|
+
if (!obj)
|
343
|
+
return Qnil;
|
344
|
+
|
345
|
+
if (env->IsInstanceOf(obj, clsString))
|
346
|
+
return rho_ruby_create_string(rho_cast<std::string>(env, (jstring)obj).c_str());
|
347
|
+
|
348
|
+
if (env->IsInstanceOf(obj, clsMap))
|
349
|
+
return convertJavaMapToRubyHash(env, obj);
|
350
|
+
|
351
|
+
RAWLOG_ERROR("rho_cast<VALUE, jobject>: unknown type of value");
|
352
|
+
return Qnil;
|
285
353
|
}
|
286
354
|
|
287
355
|
} // namespace details
|
@@ -477,6 +545,15 @@ RHO_GLOBAL jstring JNICALL Java_com_rhomobile_rhodes_RhodesService_normalizeUrl
|
|
477
545
|
return rho_cast<jstring>(env, cs);
|
478
546
|
}
|
479
547
|
|
548
|
+
RHO_GLOBAL jstring JNICALL Java_com_rhomobile_rhodes_RhodesService_getBuildConfig
|
549
|
+
(JNIEnv *env, jobject, jstring key)
|
550
|
+
{
|
551
|
+
std::string const &s = rho_cast<std::string>(key);
|
552
|
+
const char* cs = get_app_build_config_item(s.c_str());
|
553
|
+
return rho_cast<jstring>(env, cs);
|
554
|
+
}
|
555
|
+
|
556
|
+
|
480
557
|
RHO_GLOBAL void JNICALL Java_com_rhomobile_rhodes_RhodesService_navigateBack
|
481
558
|
(JNIEnv *, jclass)
|
482
559
|
{
|
@@ -532,3 +609,7 @@ RHO_GLOBAL char *rho_timezone()
|
|
532
609
|
}
|
533
610
|
return tz;
|
534
611
|
}
|
612
|
+
|
613
|
+
RHO_GLOBAL const char* rho_sys_get_start_params() {
|
614
|
+
return "";
|
615
|
+
}
|
@@ -13,7 +13,7 @@ RHO_GLOBAL VALUE rho_ringtone_manager_get_all()
|
|
13
13
|
|
14
14
|
jobject obj = env->CallStaticObjectMethod(cls, mid);
|
15
15
|
if (!obj) return Qnil;
|
16
|
-
return
|
16
|
+
return rho_cast<VALUE>(obj);
|
17
17
|
}
|
18
18
|
|
19
19
|
RHO_GLOBAL void rho_ringtone_manager_stop()
|
@@ -3,6 +3,7 @@ package com.rhomobile.rhodes;
|
|
3
3
|
public class Capabilities {
|
4
4
|
|
5
5
|
public static boolean AUDIO_ENABLED = true;
|
6
|
+
public static boolean BLUETOOTH_ENABLED = true;
|
6
7
|
public static boolean CALENDAR_ENABLED = true;
|
7
8
|
public static boolean CAMERA_ENABLED = true;
|
8
9
|
public static boolean GPS_ENABLED = true;
|
@@ -21,10 +21,8 @@
|
|
21
21
|
package com.rhomobile.rhodes;
|
22
22
|
|
23
23
|
import java.util.Timer;
|
24
|
-
import java.util.TimerTask;
|
25
24
|
|
26
25
|
import com.rhomobile.rhodes.mainview.MainView;
|
27
|
-
import com.rhomobile.rhodes.util.PerformOnUiThread;
|
28
26
|
|
29
27
|
import android.content.Intent;
|
30
28
|
import android.content.pm.ActivityInfo;
|
@@ -57,6 +55,8 @@ public class Rhodes extends RhoActivity {
|
|
57
55
|
private Bundle mSavedBundle = null;
|
58
56
|
private SplashScreen mSplashScreen = null;
|
59
57
|
private Handler mHandler = null;
|
58
|
+
|
59
|
+
private Object mStartParams = null;
|
60
60
|
|
61
61
|
/** Called when the activity is first created. */
|
62
62
|
@Override
|
@@ -65,10 +65,13 @@ public class Rhodes extends RhoActivity {
|
|
65
65
|
|
66
66
|
super.onCreate(savedInstanceState);
|
67
67
|
mHandler = new Handler();
|
68
|
-
|
68
|
+
|
69
69
|
// Here Log should be used, not Logger. It is because Logger is not initialized yet.
|
70
70
|
Log.v(TAG, "+++ onCreate");
|
71
71
|
|
72
|
+
mStartParams = getIntent().getExtras();
|
73
|
+
Log.d(TAG, "start parameters: " + mStartParams);
|
74
|
+
|
72
75
|
instance = this;
|
73
76
|
|
74
77
|
FrameLayout v = new FrameLayout(this);
|
@@ -100,7 +103,7 @@ public class Rhodes extends RhoActivity {
|
|
100
103
|
RhodesService service = RhodesService.getInstance();
|
101
104
|
if (service == null) {
|
102
105
|
Log.v(TAG, "Starting rhodes service...");
|
103
|
-
service = new RhodesService(this, mOuterFrame, mSplashScreen);
|
106
|
+
service = new RhodesService(this, mOuterFrame, mSplashScreen, mStartParams);
|
104
107
|
}
|
105
108
|
else
|
106
109
|
Log.v(TAG, "Rhodes service already started...");
|
@@ -130,13 +133,11 @@ public class Rhodes extends RhoActivity {
|
|
130
133
|
private Timer mTimerPostponeCreate = null;
|
131
134
|
|
132
135
|
public void onResume() {
|
133
|
-
RhodesService.platformLog("Rhodes", "onResume()");
|
134
|
-
|
135
136
|
super.onResume();
|
136
|
-
|
137
|
+
RhodesService.platformLog("Rhodes", "onResume()");
|
137
138
|
}
|
138
139
|
|
139
|
-
public static void
|
140
|
+
public static void runPostponedSetup() {
|
140
141
|
final Rhodes r = Rhodes.getInstance();
|
141
142
|
r.mHandler.post( new Runnable() {
|
142
143
|
public void run() {
|
@@ -4,6 +4,8 @@ import java.io.File;
|
|
4
4
|
import java.io.IOException;
|
5
5
|
import java.util.Calendar;
|
6
6
|
import java.util.Enumeration;
|
7
|
+
import java.util.Iterator;
|
8
|
+
import java.util.List;
|
7
9
|
import java.util.Locale;
|
8
10
|
import java.util.Map;
|
9
11
|
import java.util.Set;
|
@@ -11,7 +13,7 @@ import java.util.TimeZone;
|
|
11
13
|
import java.util.Vector;
|
12
14
|
|
13
15
|
import com.rhomobile.rhodes.alert.Alert;
|
14
|
-
import com.rhomobile.rhodes.
|
16
|
+
import com.rhomobile.rhodes.event.EventStore;
|
15
17
|
import com.rhomobile.rhodes.file.RhoFileApi;
|
16
18
|
import com.rhomobile.rhodes.geolocation.GeoLocation;
|
17
19
|
import com.rhomobile.rhodes.mainview.MainView;
|
@@ -68,6 +70,8 @@ public class RhodesService {
|
|
68
70
|
public static final int RHO_MAIN_VIEW = 2;
|
69
71
|
public static final int RHO_TOOLBAR_VIEW = 3;
|
70
72
|
|
73
|
+
private static final String RHO_START_PARAMS_KEY = "RhoStartParams";
|
74
|
+
|
71
75
|
private static RhodesService instance = null;
|
72
76
|
|
73
77
|
public static RhodesService getInstance() {
|
@@ -128,6 +132,10 @@ public class RhodesService {
|
|
128
132
|
uiHandler.post(r);
|
129
133
|
}
|
130
134
|
|
135
|
+
public void post(Runnable r, int delay) {
|
136
|
+
uiHandler.postDelayed(r, delay);
|
137
|
+
}
|
138
|
+
|
131
139
|
private static int screenWidth;
|
132
140
|
private static int screenHeight;
|
133
141
|
private static int screenOrientation;
|
@@ -162,6 +170,8 @@ public class RhodesService {
|
|
162
170
|
|
163
171
|
public native String normalizeUrl(String url);
|
164
172
|
|
173
|
+
public static native String getBuildConfig(String key);
|
174
|
+
|
165
175
|
public static native void loadUrl(String url);
|
166
176
|
|
167
177
|
public static native void navigateBack();
|
@@ -273,13 +283,19 @@ public class RhodesService {
|
|
273
283
|
|
274
284
|
return false;
|
275
285
|
}
|
286
|
+
|
287
|
+
private static int mGeoLocationInactivityTimeout;
|
288
|
+
|
289
|
+
public static int getGeoLocationInactivityTimeout() {
|
290
|
+
return mGeoLocationInactivityTimeout;
|
291
|
+
}
|
276
292
|
|
277
293
|
public static SplashScreen showSplashScreen(Context ctx, ViewGroup myOuterFrame) {
|
278
294
|
SplashScreen splashScreen = new SplashScreen(ctx);
|
279
295
|
splashScreen.start(myOuterFrame);
|
280
296
|
return splashScreen;
|
281
297
|
}
|
282
|
-
|
298
|
+
|
283
299
|
public void hideSplashScreen() {
|
284
300
|
PerformOnUiThread.exec(new Runnable() {
|
285
301
|
public void run() {
|
@@ -324,7 +340,7 @@ public class RhodesService {
|
|
324
340
|
Rhodes.getInstance().getWindow().setFeatureInt(Window.FEATURE_PROGRESS, MAX_PROGRESS);
|
325
341
|
super.onPageFinished(view, url);
|
326
342
|
if (!setupExecuted) {
|
327
|
-
Rhodes.
|
343
|
+
Rhodes.runPostponedSetup();
|
328
344
|
setupExecuted = true;
|
329
345
|
}
|
330
346
|
|
@@ -444,7 +460,7 @@ public class RhodesService {
|
|
444
460
|
return instance != null;
|
445
461
|
}
|
446
462
|
|
447
|
-
public RhodesService(Activity c, ViewGroup rootWindow, SplashScreen splash_s) {
|
463
|
+
public RhodesService(Activity c, ViewGroup rootWindow, SplashScreen splash_s, Object params) {
|
448
464
|
|
449
465
|
ctx = c;
|
450
466
|
instance = this;
|
@@ -467,7 +483,13 @@ public class RhodesService {
|
|
467
483
|
if (Utils.isAppHashChanged()) {
|
468
484
|
try {
|
469
485
|
Log.i(TAG, "Application hash was changed, so remove files");
|
470
|
-
|
486
|
+
String[] folders = {"apps", "lib"};
|
487
|
+
for (String folder : folders) {
|
488
|
+
File f = new File(rootPath, folder);
|
489
|
+
if (!f.exists())
|
490
|
+
continue;
|
491
|
+
Utils.deleteRecursively(f);
|
492
|
+
}
|
471
493
|
initRootPath();
|
472
494
|
RhoFileApi.init();
|
473
495
|
RhoFileApi.copy("hash");
|
@@ -480,6 +502,53 @@ public class RhodesService {
|
|
480
502
|
|
481
503
|
createRhodesApp();
|
482
504
|
|
505
|
+
/*
|
506
|
+
boolean rhoGalleryApp = false;
|
507
|
+
if (params != null && params instanceof Bundle) {
|
508
|
+
Bundle startParams = (Bundle)params;
|
509
|
+
String v = startParams.getString("rhogallery_app");
|
510
|
+
if (v != null && v.equals("1"))
|
511
|
+
rhoGalleryApp = true;
|
512
|
+
}
|
513
|
+
if (!rhoGalleryApp && RhoConf.getBool("rhogallery_only_app")) {
|
514
|
+
Logger.E(TAG, "This is RhoGallery only app and can be started only from RhoGallery");
|
515
|
+
exitApp();
|
516
|
+
}
|
517
|
+
*/
|
518
|
+
boolean can_start = true;
|
519
|
+
String security_token = getBuildConfig("security_token");
|
520
|
+
if (security_token != null) {
|
521
|
+
if (security_token.length() > 0) {
|
522
|
+
can_start = false;
|
523
|
+
if (params != null && params instanceof Bundle) {
|
524
|
+
Bundle startParams = (Bundle)params;
|
525
|
+
String rho_start_params = startParams.getString(RHO_START_PARAMS_KEY);
|
526
|
+
if (rho_start_params != null) {
|
527
|
+
String security_token_key = "sequrity_token=";
|
528
|
+
int sec_index = rho_start_params.indexOf(security_token_key);
|
529
|
+
if (sec_index >= 0) {
|
530
|
+
String tmp = rho_start_params.substring(sec_index + security_token_key.length(), rho_start_params.length() - sec_index - security_token_key.length());
|
531
|
+
int end_of_token = tmp.indexOf(",");
|
532
|
+
if (end_of_token >= 0) {
|
533
|
+
tmp = tmp.substring(0, end_of_token);
|
534
|
+
}
|
535
|
+
end_of_token = tmp.indexOf(" ");
|
536
|
+
if (end_of_token >= 0) {
|
537
|
+
tmp = tmp.substring(0, end_of_token);
|
538
|
+
}
|
539
|
+
if (tmp.equals(security_token)) {
|
540
|
+
can_start = true;
|
541
|
+
}
|
542
|
+
}
|
543
|
+
}
|
544
|
+
}
|
545
|
+
}
|
546
|
+
}
|
547
|
+
if (!can_start) {
|
548
|
+
Logger.E(TAG, "SECURITY_TOKEN parameter is not valid for this application !");
|
549
|
+
exitApp();
|
550
|
+
}
|
551
|
+
|
483
552
|
boolean fullScreen = true;
|
484
553
|
if (RhoConf.isExist("full_screen"))
|
485
554
|
fullScreen = RhoConf.getBool("full_screen");
|
@@ -494,7 +563,9 @@ public class RhodesService {
|
|
494
563
|
|
495
564
|
Logger.I("Rhodes", "Loading...");
|
496
565
|
//showSplashScreen();
|
497
|
-
splashScreen
|
566
|
+
if (splashScreen != null) {
|
567
|
+
splashScreen.rho_start();
|
568
|
+
}
|
498
569
|
|
499
570
|
// Increase WebView rendering priority
|
500
571
|
WebView w = new WebView(ctx);
|
@@ -516,6 +587,10 @@ public class RhodesService {
|
|
516
587
|
// TODO: detect camera availability
|
517
588
|
isCameraAvailable = true;
|
518
589
|
|
590
|
+
mGeoLocationInactivityTimeout = RhoConf.getInt("geo_location_inactivity_timeout");
|
591
|
+
if (mGeoLocationInactivityTimeout == 0)
|
592
|
+
mGeoLocationInactivityTimeout = 25*1000; // 25s
|
593
|
+
|
519
594
|
// Register custom uri handlers here
|
520
595
|
uriHandlers.addElement(new ExternalHttpHandler(ctx));
|
521
596
|
uriHandlers.addElement(new MailUriHandler(ctx));
|
@@ -563,6 +638,7 @@ public class RhodesService {
|
|
563
638
|
}
|
564
639
|
}
|
565
640
|
}, false);
|
641
|
+
getMainActivity().finish();
|
566
642
|
Process.killProcess(Process.myPid());
|
567
643
|
}
|
568
644
|
|
@@ -595,17 +671,17 @@ public class RhodesService {
|
|
595
671
|
}
|
596
672
|
|
597
673
|
public void activityStopped() {
|
598
|
-
PerformOnUiThread.exec( new Runnable() {
|
599
|
-
public void run() {
|
600
|
-
if (wakeLockObject != null) {
|
601
|
-
Logger.I(TAG, "activityStopped() temporary destroy wakeLock object");
|
602
|
-
wakeLockObject.release();
|
603
|
-
wakeLockObject = null;
|
604
|
-
}
|
605
|
-
}
|
606
|
-
}, false);
|
607
674
|
--activitiesActive;
|
608
675
|
if (activitiesActive == 0) {
|
676
|
+
PerformOnUiThread.exec( new Runnable() {
|
677
|
+
public void run() {
|
678
|
+
if (wakeLockObject != null) {
|
679
|
+
Logger.I(TAG, "activityStopped() temporary destroy wakeLock object");
|
680
|
+
wakeLockObject.release();
|
681
|
+
wakeLockObject = null;
|
682
|
+
}
|
683
|
+
}
|
684
|
+
}, false);
|
609
685
|
needGeoLocationRestart = GeoLocation.isAvailable();
|
610
686
|
GeoLocation.stop();
|
611
687
|
callActivationCallback(false);
|
@@ -726,40 +802,47 @@ public class RhodesService {
|
|
726
802
|
}
|
727
803
|
|
728
804
|
public static Object getProperty(String name) {
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
805
|
+
try {
|
806
|
+
if (name.equalsIgnoreCase("platform"))
|
807
|
+
return "ANDROID";
|
808
|
+
else if (name.equalsIgnoreCase("locale"))
|
809
|
+
return getCurrentLocale();
|
810
|
+
else if (name.equalsIgnoreCase("country"))
|
811
|
+
return getCurrentCountry();
|
812
|
+
else if (name.equalsIgnoreCase("screen_width"))
|
813
|
+
return new Integer(getScreenWidth());
|
814
|
+
else if (name.equalsIgnoreCase("screen_height"))
|
815
|
+
return new Integer(getScreenHeight());
|
816
|
+
else if (name.equalsIgnoreCase("has_camera"))
|
817
|
+
return new Boolean(isCameraAvailable);
|
818
|
+
else if (name.equalsIgnoreCase("has_network"))
|
819
|
+
return hasNetwork();
|
820
|
+
else if (name.equalsIgnoreCase("ppi_x"))
|
821
|
+
return new Float(screenPpiX);
|
822
|
+
else if (name.equalsIgnoreCase("ppi_y"))
|
823
|
+
return new Float(screenPpiY);
|
824
|
+
else if (name.equalsIgnoreCase("phone_number")) {
|
825
|
+
TelephonyManager manager = (TelephonyManager)RhodesService.getInstance().
|
826
|
+
getContext().getSystemService(Context.TELEPHONY_SERVICE);
|
827
|
+
String number = manager.getLine1Number();
|
828
|
+
return number;
|
829
|
+
}
|
830
|
+
else if (name.equalsIgnoreCase("device_name")) {
|
831
|
+
return Build.DEVICE;
|
832
|
+
}
|
833
|
+
else if (name.equalsIgnoreCase("is_emulator")) {
|
834
|
+
String strDevice = Build.DEVICE;
|
835
|
+
return new Boolean(strDevice != null && strDevice.equalsIgnoreCase("generic"));
|
836
|
+
}
|
837
|
+
else if (name.equalsIgnoreCase("os_version")) {
|
838
|
+
return Build.VERSION.RELEASE;
|
839
|
+
}
|
840
|
+
else if (name.equalsIgnoreCase("has_calendar")) {
|
841
|
+
return new Boolean(EventStore.hasCalendar());
|
842
|
+
}
|
760
843
|
}
|
761
|
-
|
762
|
-
|
844
|
+
catch (Exception e) {
|
845
|
+
Logger.E(TAG, "Can't get property \"" + name + "\": " + e);
|
763
846
|
}
|
764
847
|
|
765
848
|
return null;
|
@@ -775,7 +858,7 @@ public class RhodesService {
|
|
775
858
|
return tz.getDisplayName();
|
776
859
|
}
|
777
860
|
|
778
|
-
public static void runApplication(String appName,
|
861
|
+
public static void runApplication(String appName, Object params) {
|
779
862
|
try {
|
780
863
|
Context ctx = RhodesService.getInstance().getContext();
|
781
864
|
PackageManager mgr = ctx.getPackageManager();
|
@@ -791,12 +874,64 @@ public class RhodesService {
|
|
791
874
|
|
792
875
|
Intent intent = new Intent();
|
793
876
|
intent.setClassName(appName, className);
|
877
|
+
if (params != null) {
|
878
|
+
Bundle startParams = new Bundle();
|
879
|
+
if (params instanceof String) {
|
880
|
+
startParams.putString(RHO_START_PARAMS_KEY, (String)params);
|
881
|
+
}
|
882
|
+
/*
|
883
|
+
else if (params instanceof List<?>) {
|
884
|
+
for (Object obj : (List<?>)params) {
|
885
|
+
startParams.putInt(obj.toString(), 1);
|
886
|
+
}
|
887
|
+
}
|
888
|
+
else if (params instanceof Map<?,?>) {
|
889
|
+
Map<?,?> mp = (Map<?,?>)params;
|
890
|
+
for (Iterator<?> it = mp.keySet().iterator(); it.hasNext();) {
|
891
|
+
Object key = it.next();
|
892
|
+
Object value = mp.get(key);
|
893
|
+
startParams.putString(key.toString(), value == null ? null : value.toString());
|
894
|
+
}
|
895
|
+
}
|
896
|
+
*/
|
897
|
+
else
|
898
|
+
throw new IllegalArgumentException("Unknown type of incoming parameter");
|
899
|
+
|
900
|
+
intent.putExtras(startParams);
|
901
|
+
}
|
794
902
|
ctx.startActivity(intent);
|
795
903
|
}
|
796
904
|
catch (Exception e) {
|
797
905
|
Logger.E(TAG, "Can't run application " + appName + ": " + e.getMessage());
|
798
906
|
}
|
799
907
|
}
|
908
|
+
|
909
|
+
public static boolean isAppInstalled(String appName) {
|
910
|
+
try {
|
911
|
+
try {
|
912
|
+
RhodesService.getInstance().getContext().getPackageManager().getPackageInfo(appName, 0);
|
913
|
+
return true;
|
914
|
+
}
|
915
|
+
catch (NameNotFoundException ne) {
|
916
|
+
return false;
|
917
|
+
}
|
918
|
+
}
|
919
|
+
catch (Exception e) {
|
920
|
+
Logger.E(TAG, "Can't check is app " + appName + " installed: " + e.getMessage());
|
921
|
+
return false;
|
922
|
+
}
|
923
|
+
}
|
924
|
+
|
925
|
+
public static void uninstallApplication(String appName) {
|
926
|
+
try {
|
927
|
+
Uri packageUri = Uri.parse("package:" + appName);
|
928
|
+
Intent intent = new Intent(Intent.ACTION_DELETE, packageUri);
|
929
|
+
RhodesService.getInstance().startActivity(intent);
|
930
|
+
}
|
931
|
+
catch (Exception e) {
|
932
|
+
Logger.E(TAG, "Can't uninstall application " + appName + ": " + e.getMessage());
|
933
|
+
}
|
934
|
+
}
|
800
935
|
|
801
936
|
public static void openExternalUrl(String url) {
|
802
937
|
try {
|