rhodes 2.2.6 → 2.3.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +20 -0
- data/README.md +46 -0
- data/Rakefile +85 -80
- data/bin/rhodes +2 -2
- data/bin/rhogen +1 -1
- data/doc/application.txt +277 -0
- data/doc/bb-css.txt +209 -0
- data/doc/build.txt +785 -0
- data/doc/configuration.txt +236 -0
- data/doc/connect-to-web-services.txt +282 -0
- data/doc/contributing.txt +64 -0
- data/doc/css-framework.txt +144 -0
- data/doc/device-caps.txt +1152 -0
- data/doc/extensions.txt +528 -0
- data/doc/files.txt +4 -0
- data/doc/generator.txt +141 -0
- data/doc/install.txt +35 -0
- data/doc/introduction.txt +88 -0
- data/doc/rhom.txt +826 -0
- data/doc/standard-css.txt +392 -0
- data/doc/synchronization.txt +542 -0
- data/doc/test-log-debug.txt +148 -0
- data/doc/tutorial.txt +136 -0
- data/doc/ui.txt +766 -0
- data/installer/EnvVarUpdate.nsh +328 -0
- data/installer/README.html +81 -0
- data/installer/RHOSYNC-LICENSE.txt +675 -0
- data/installer/icon.ico +0 -0
- data/installer/instant-rhodes.nsi +427 -0
- data/lib/build/jake.rb +15 -1
- data/lib/extensions/barcode/ext/barcode/platform/android/jni/src/imageprovider.cpp +1 -1
- data/lib/extensions/barcode/ext/barcode/platform/bb/Barcode6.files +45 -0
- data/lib/extensions/barcode/ext/barcode/platform/bb/Rakefile +6 -0
- data/lib/extensions/barcode/ext/barcode/platform/bb/barcode6.jdp +92 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/Barcode.xcodeproj/project.pbxproj +7 -4
- data/lib/extensions/barcode/ext/barcode/platform/iphone/Rakefile +2 -1
- data/lib/extensions/barcode/ext/barcode/platform/wm/src/wm_imageprovider.cpp +1 -1
- data/lib/extensions/digest-sha1/ext/build.bat +1 -0
- data/lib/extensions/digest-sha1/ext/digest-sha1.vcproj +335 -0
- data/lib/extensions/esri/ext/build +17 -0
- data/lib/extensions/esri/ext/build.bat +29 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/Classes/ESRIViewFactory.h +7 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/Classes/ESRIViewFactory.mm +58 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/Classes/ESRIViewFactoryRegister.mm +22 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/Classes/ESRIViewManager.h +21 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/Classes/ESRIViewManager.mm +32 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/Classes/InitESRI.c +5 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/Classes/MapViewControllerESRI.h +143 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/Classes/MapViewControllerESRI.m +919 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/ESRI.xcodeproj/project.pbxproj +320 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/ESRI_Prefix.pch +7 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/Rakefile +76 -0
- data/lib/extensions/esri/ext.yml +3 -0
- data/lib/extensions/net-http/monitor.rb +265 -0
- data/lib/extensions/net-http/net/ftp.rb +981 -0
- data/lib/extensions/net-http/thread.rb +367 -0
- data/lib/extensions/rhocgi/cgi.rb +16 -0
- data/lib/extensions/rhospec/rhospec.rb +118 -0
- data/lib/framework/base64.rb +91 -0
- data/lib/framework/builtinME.rb +13 -10
- data/lib/framework/ostruct.rb +145 -0
- data/lib/framework/res/back_btn.wm.png +0 -0
- data/lib/framework/res/blue_pushpin.wm.png +0 -0
- data/lib/framework/res/blue_pushpin_small.wm.png +0 -0
- data/lib/framework/res/callout.wm.png +0 -0
- data/lib/framework/res/callout_link.wm.png +0 -0
- data/lib/framework/res/forward_btn.wm.png +0 -0
- data/lib/framework/res/home_btn.wm.png +0 -0
- data/lib/framework/res/options_btn.wm.png +0 -0
- data/lib/framework/res/refresh_btn.wm.png +0 -0
- data/lib/framework/rho/render.rb +5 -2
- data/lib/framework/rho/rho.rb +320 -50
- data/lib/framework/rho/rhoapplication.rb +48 -10
- data/lib/framework/rho/rhonativeviewmanager.rb +73 -0
- data/lib/framework/rho/rhosupport.rb +15 -1
- data/lib/framework/rho/rhotabbar.rb +29 -0
- data/lib/framework/rho/rhotoolbar.rb +17 -0
- data/lib/framework/rho/rhoutils.rb +22 -6
- data/lib/framework/rhodes.rb +1 -1
- data/lib/framework/rholang/rhomsg_de.rb +4 -3
- data/lib/framework/rholang/rhomsg_en.rb +1 -0
- data/lib/framework/rholang/rhomsg_es.rb +1 -0
- data/lib/framework/rholang/rhomsg_it.rb +1 -0
- data/lib/framework/rhom/rhom.rb +31 -10
- data/lib/framework/rhom/rhom_db_adapter.rb +33 -23
- data/lib/framework/rhom/rhom_object_factory.rb +465 -249
- data/lib/framework/rhom/rhom_source.rb +22 -7
- data/lib/framework/version.rb +1 -1
- data/lib/rhodes.rb +1 -1
- data/platform/android/Rhodes/AndroidManifest.xml +83 -20
- data/platform/android/Rhodes/gen/com/rhomobile/rhodes/R.java +5 -0
- data/platform/android/Rhodes/jni/include/rhodes/RhoClassFactory.h +2 -0
- data/platform/android/Rhodes/jni/include/rhodes/details/rhojava.inc +9 -5
- data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_RhodesAppOptions.h +53 -0
- data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_RhodesService.h +46 -56
- data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_SplashScreen.h +10 -0
- data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_mapview_MapView.h +93 -0
- data/platform/android/Rhodes/jni/include/rhodes/rhocryptimpl.h +38 -0
- data/platform/android/Rhodes/jni/include/rhodes.h +64 -8
- data/platform/android/Rhodes/jni/src/RhoClassFactory.cpp +6 -0
- data/platform/android/Rhodes/jni/src/alert.cpp +5 -11
- data/platform/android/Rhodes/jni/src/bluetooth.cpp +66 -29
- data/platform/android/Rhodes/jni/src/callbacks.cpp +24 -21
- data/platform/android/Rhodes/jni/src/camera.cpp +2 -6
- data/platform/android/Rhodes/jni/src/datetimepicker.cpp +13 -11
- data/platform/android/Rhodes/jni/src/event.cpp +9 -15
- data/platform/android/Rhodes/jni/src/fileapi.cpp +13 -27
- data/platform/android/Rhodes/jni/src/logconf.cpp +3 -3
- data/platform/android/Rhodes/jni/src/mapview.cpp +696 -16
- data/platform/android/Rhodes/jni/src/menu.cpp +3 -3
- data/platform/android/Rhodes/jni/src/nativebar.cpp +55 -4
- data/platform/android/Rhodes/jni/src/nativeview.cpp +33 -0
- data/platform/android/Rhodes/jni/src/phonebook.cpp +6 -11
- data/platform/android/Rhodes/jni/src/rhoconf.cpp +4 -4
- data/platform/android/Rhodes/jni/src/rhocryptimpl.cpp +87 -0
- data/platform/android/Rhodes/jni/src/rhodes.cpp +55 -34
- data/platform/android/Rhodes/jni/src/ringtones.cpp +2 -3
- data/platform/android/Rhodes/jni/src/signature.cpp +3 -5
- data/platform/android/Rhodes/jni/src/splashscreen.cpp +7 -0
- data/platform/android/Rhodes/jni/src/sslimpl.cpp +17 -20
- data/platform/android/Rhodes/jni/src/webview.cpp +13 -12
- data/platform/android/Rhodes/res/drawable/callout.png +0 -0
- data/platform/android/Rhodes/res/drawable/callout_link.png +0 -0
- data/platform/android/Rhodes/res/drawable/signature_cancel.png +0 -0
- data/platform/android/Rhodes/res/drawable/signature_clear.png +0 -0
- data/platform/android/Rhodes/res/drawable/signature_ok.png +0 -0
- data/platform/android/Rhodes/res/layout/datetime.xml +4 -0
- data/platform/android/Rhodes/res/layout/signature.xml +24 -17
- data/platform/android/Rhodes/res/layout/status_bar_ongoing_event_progress_bar.xml +102 -0
- data/platform/android/Rhodes/res/values/strings.xml +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/AndroidR.java +6 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Base64.java +575 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/BaseActivity.java +83 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/NativeBar.java +21 -3
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushReceiver.java +23 -15
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushService.java +2 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoCryptImpl.java +151 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoMenu.java +2 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +372 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesAppOptions.java +11 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +58 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +705 -523
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RingtoneManager.java +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/SplashScreen.java +167 -85
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Utils.java +36 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/WebView.java +4 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/Alert.java +33 -20
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/IRhoBluetoothManager.java +2 -6
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothManager.java +2 -24
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothManagerNew.java +106 -36
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothManagerOld.java +15 -58
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothSession.java +0 -7
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/Camera.java +6 -4
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/FileList.java +4 -3
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/ImageCapture.java +91 -27
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/datetime/DateTimePicker.java +6 -3
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/datetime/DateTimePickerScreen.java +275 -42
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/EventStore.java +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/file/RhoFileApi.java +1 -3
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/MainView.java +1 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +120 -43
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/TabbedMainView.java +518 -28
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/AnnotationsOverlay.java +2 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/GoogleMapView.java +434 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MapTouch.java +20 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MapView.java +296 -336
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MultiTouchHandler.java +111 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/OneTouchHandler.java +77 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/TouchHandler.java +10 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoNativeViewManager.java +0 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/Contact.java +5 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorNew.java +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorOld.java +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/signature/ImageCapture.java +6 -11
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/signature/Signature.java +6 -4
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/signature/SignatureView.java +0 -7
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/ui/LogViewDialog.java +9 -4
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/util/PerformOnUiThread.java +8 -8
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/ChromeClientNew.java +5 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/ChromeClientOld.java +11 -7
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebSettingsNew.java +3 -5
- data/platform/android/build/RhodesSRC_build.files +32 -23
- data/platform/android/build/android.rake +28 -11
- data/platform/android/build/androidcommon.rb +2 -0
- data/platform/android/build/librhocommon_build.files +9 -5
- data/platform/android/build/librhodes_build.files +1 -0
- data/platform/android/build/libruby_build.files +1 -0
- data/platform/bb/Hsqldb/Hsqldb.jdp +0 -2
- data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBResult.java +10 -2
- data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBStorage.java +37 -5
- data/platform/bb/Hsqldb/src/org/hsqldb/Column.java +5 -5
- data/platform/bb/Hsqldb/src/org/hsqldb/Expression.java +1 -1
- data/platform/bb/Hsqldb/src/org/hsqldb/Function.java +73 -78
- data/platform/bb/Hsqldb/src/org/hsqldb/Library.java +288 -8
- data/platform/bb/RubyVM/RubyVM.jdp +3 -0
- data/platform/bb/RubyVM/src/com/rho/FilePath.java +13 -1
- data/platform/bb/RubyVM/src/com/rho/IRhoRubyHelper.java +2 -2
- data/platform/bb/RubyVM/src/com/rho/RhoAppAdapter.java +12 -0
- data/platform/bb/RubyVM/src/com/rho/RhoClassFactory.java +18 -1
- data/platform/bb/RubyVM/src/com/rho/RhoConf.java +128 -108
- data/platform/bb/RubyVM/src/com/rho/RhoLogConf.java +9 -10
- data/platform/bb/RubyVM/src/com/rho/RhoLogger.java +16 -1
- data/platform/bb/RubyVM/src/com/rho/RhoProfiler.java +1 -1
- data/platform/bb/RubyVM/src/com/rho/RhoRuby.java +20 -0
- data/platform/bb/RubyVM/src/com/rho/RhodesApp.java +5 -2
- data/platform/bb/RubyVM/src/com/rho/ThreadQueue.java +65 -46
- data/platform/bb/RubyVM/src/com/rho/db/DBAdapter.java +192 -50
- data/platform/bb/RubyVM/src/com/rho/db/DBAttrManager.java +8 -114
- data/platform/bb/RubyVM/src/com/rho/db/DBException.java +1 -1
- data/platform/bb/RubyVM/src/com/rho/db/IDBCallback.java +1 -1
- data/platform/bb/RubyVM/src/com/rho/db/IDBResult.java +5 -3
- data/platform/bb/RubyVM/src/com/rho/db/IDBStorage.java +5 -1
- data/platform/bb/RubyVM/src/com/rho/file/FileAccessBB.java +109 -0
- data/platform/bb/RubyVM/src/com/rho/file/RhoFile.java +85 -0
- data/platform/bb/RubyVM/src/com/rho/net/NetRequest.java +12 -4
- data/platform/bb/RubyVM/src/com/rho/net/NetResponse.java +5 -0
- data/platform/bb/RubyVM/src/com/rho/net/RhoConnection.java +37 -23
- data/platform/bb/RubyVM/src/com/rho/net/URI.java +84 -0
- data/platform/bb/RubyVM/src/com/rho/sync/ClientRegister.java +1 -1
- data/platform/bb/RubyVM/src/com/rho/sync/SyncEngine.java +119 -61
- data/platform/bb/RubyVM/src/com/rho/sync/SyncNotify.java +61 -24
- data/platform/bb/RubyVM/src/com/rho/sync/SyncSource.java +108 -54
- data/platform/bb/RubyVM/src/com/rho/sync/SyncThread.java +121 -163
- data/platform/bb/RubyVM/src/com/xruby/GeneratedMethods/RubyString_Methods.java +23 -0
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyMutex.java +1 -1
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyRange.java +3 -1
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyRegexp.java +3 -1
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyString.java +208 -25
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyTime.java +3 -1
- data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RhoSupport.java +5 -1
- data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyAPI.java +12 -5
- data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyID.java +1 -0
- data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyKernelModule.java +16 -0
- data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyKernelModule_Methods.java +5 -0
- data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyValue.java +1 -1
- data/platform/bb/RubyVM/src/com/xruby/runtime/stdlib/RubyStringIO.java +4 -1
- data/platform/bb/{Hsqldb → RubyVM}/src/j2me/math/Number.java +33 -0
- data/platform/bb/build/RubyVM_build.files +3 -0
- data/platform/bb/build/bb.rake +140 -62
- data/platform/bb/build/hsqldb_build.files +0 -2
- data/platform/bb/build/rhodes_build.files +5 -0
- data/platform/bb/rhodes/platform/4.7/com/rho/RhoMainScreen.java +43 -7
- data/platform/bb/rhodes/platform/5.0/com/rho/BrowserAdapter5.java +23 -2
- data/platform/bb/rhodes/platform/5.0/com/rho/RhodesApplicationPlatform.java +5 -0
- data/platform/bb/rhodes/platform/5.0/com/rho/db/SqliteCopyResult.java +143 -0
- data/platform/bb/rhodes/platform/5.0/com/rho/db/SqliteResult.java +269 -0
- data/platform/bb/rhodes/platform/5.0/com/rho/db/SqliteStorage.java +446 -0
- data/platform/bb/rhodes/platform/common/com/rho/BrowserAdapter5.java +3 -0
- data/platform/bb/rhodes/platform/common/com/rho/RhoMainScreen.java +12 -2
- data/platform/bb/rhodes/platform/common/com/rho/db/SqliteCopyResult.java +2 -0
- data/platform/bb/rhodes/platform/common/com/rho/db/SqliteResult.java +2 -0
- data/platform/bb/rhodes/platform/common/com/rho/db/SqliteStorage.java +2 -0
- data/platform/bb/rhodes/resources/mappin.png +0 -0
- data/platform/bb/rhodes/rhodes.jdp +3 -0
- data/platform/bb/rhodes/src/com/rho/BrowserAdapter.java +21 -18
- data/platform/bb/rhodes/src/com/rho/BrowserAdapter5.java +150 -0
- data/platform/bb/rhodes/src/com/rho/IBrowserAdapter.java +1 -0
- data/platform/bb/rhodes/src/com/rho/RhoMainScreen.java +63 -4
- data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +6 -5
- data/platform/bb/rhodes/src/com/rho/RhodesApplicationPlatform.java +242 -2
- data/platform/bb/rhodes/src/com/rho/db/SqliteCopyResult.java +143 -0
- data/platform/bb/rhodes/src/com/rho/db/SqliteResult.java +269 -0
- data/platform/bb/rhodes/src/com/rho/db/SqliteStorage.java +446 -0
- data/platform/bb/rhodes/src/com/rho/file/Jsr75File.java +1 -1
- data/platform/bb/rhodes/src/com/rho/net/NetworkAccess.java +71 -14
- data/platform/bb/rhodes/src/com/rho/net/bb/BBHttpConnection.java +4 -2
- data/platform/bb/rhodes/src/com/rho/rubyext/Alert.java +28 -12
- data/platform/bb/rhodes/src/com/rho/rubyext/System.java +100 -4
- data/platform/bb/rhodes/src/com/rho/rubyext/WebView.java +3 -2
- data/platform/bb/rhodes/src/com/rho/rubyext/XMLParser.java +1 -1
- data/platform/bb/rhodes/src/rhomobile/NativeBar.java +32 -0
- data/platform/bb/rhodes/src/rhomobile/PushListeningThread.java +9 -2
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +174 -41
- data/platform/bb/rhodes/src/rhomobile/datetime/DateTimePicker.java +52 -3
- data/platform/bb/rhodes/src/rhomobile/datetime/DateTimeScreen.java +33 -1
- data/platform/bb/rhodes/src/rhomobile/mapview/Annotation.java +2 -14
- data/platform/bb/rhodes/src/rhomobile/mapview/ESRIMapField.java +686 -0
- data/platform/bb/rhodes/src/rhomobile/mapview/ESRIMapProvider.java +14 -0
- data/platform/bb/rhodes/src/rhomobile/mapview/GeoCoding.java +13 -0
- data/platform/bb/rhodes/src/rhomobile/mapview/GoogleGeoCoding.java +174 -0
- data/platform/bb/rhodes/src/rhomobile/mapview/GoogleMapField.java +104 -330
- data/platform/bb/rhodes/src/rhomobile/mapview/MapTools.java +79 -0
- data/platform/bb/rhodes/src/rhomobile/mapview/MapView.java +35 -12
- data/platform/bb/rhodes/src/rhomobile/mapview/MapViewParent.java +2 -1
- data/platform/bb/rhodes/src/rhomobile/mapview/MapViewScreen.java +336 -44
- data/platform/bb/rhodes/src/rhomobile/mapview/RhoMapField.java +3 -6
- data/platform/iphone/Classes/AppManager/AppManager.m +19 -4
- data/platform/iphone/Classes/DateTime.h +4 -0
- data/platform/iphone/Classes/DateTime.m +1 -1
- data/platform/iphone/Classes/DateTimePicker.m +8 -1
- data/platform/iphone/Classes/DateTimePickerDelegate.m +7 -1
- data/platform/iphone/Classes/Event/Event.m +2 -2
- data/platform/iphone/Classes/MapView/MapViewController.h +4 -1
- data/platform/iphone/Classes/MapView/MapViewController.m +6 -46
- data/platform/iphone/Classes/MapView/MapViewManager.h +26 -0
- data/platform/iphone/Classes/MapView/MapViewManager.m +172 -0
- data/platform/iphone/Classes/NativeBar.h +34 -0
- data/platform/iphone/Classes/NativeBar.m +131 -26
- data/platform/iphone/Classes/NativeView/NVDelegate.h +26 -0
- data/platform/iphone/Classes/NativeView/NVDelegate.m +40 -0
- data/platform/iphone/Classes/NativeView/NVViewController.h +24 -0
- data/platform/iphone/Classes/NativeView/NVViewController.m +90 -0
- data/platform/iphone/Classes/NativeView/RhoNativeViewManager.mm +449 -0
- data/platform/iphone/Classes/{RhoNativeViewManagerOC.h → NativeView/RhoNativeViewManagerOC.h} +15 -0
- data/platform/iphone/Classes/RhoAlert.m +3 -3
- data/platform/iphone/Classes/RhoMainView.h +3 -0
- data/platform/iphone/Classes/Rhodes.h +6 -2
- data/platform/iphone/Classes/Rhodes.m +47 -79
- data/platform/iphone/Classes/Signature/SignatureViewController.m +1 -0
- data/platform/iphone/Classes/SimpleMainView.h +18 -1
- data/platform/iphone/Classes/SimpleMainView.m +180 -35
- data/platform/iphone/Classes/SplitView/LeftViewController.h +1 -1
- data/platform/iphone/Classes/SplitView/LeftViewController.m +13 -7
- data/platform/iphone/Classes/SplitView/RightViewController.h +1 -1
- data/platform/iphone/Classes/SplitView/RightViewController.m +26 -11
- data/platform/iphone/Classes/SplitView/SplittedMainView.h +1 -6
- data/platform/iphone/Classes/SplitView/SplittedMainView.m +14 -52
- data/platform/iphone/Classes/TabbedMainView.h +25 -3
- data/platform/iphone/Classes/TabbedMainView.m +340 -14
- data/platform/iphone/ESRI/BluePushpin.png +0 -0
- data/platform/iphone/ESRI/BluePushpin@2x.png +0 -0
- data/platform/iphone/ESRI/esri.png +0 -0
- data/platform/iphone/ESRI/esri@2x.png +0 -0
- data/platform/iphone/Info.plist +1 -1
- data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +26 -3
- data/platform/iphone/rbuild/iphone.rake +100 -4
- data/platform/iphone/rhorubylib/rhorubylib.xcodeproj/project.pbxproj +12 -0
- data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +116 -12
- data/platform/shared/SyncClient/SyncClient.cpp +29 -3
- data/platform/shared/SyncClient/SyncClient.h +2 -1
- data/platform/shared/common/IRhoClassFactory.h +3 -0
- data/platform/shared/common/IRhoCrypt.h +16 -0
- data/platform/shared/common/IRhoThreadImpl.h +1 -0
- data/platform/shared/common/RhoAppAdapter.h +2 -0
- data/platform/shared/common/RhoConf.cpp +97 -46
- data/platform/shared/common/RhoConf.h +14 -13
- data/platform/shared/common/RhoFile.cpp +10 -0
- data/platform/shared/common/RhoFile.h +1 -0
- data/platform/shared/common/RhoMath.cpp +43 -0
- data/platform/shared/common/RhoMath.h +27 -0
- data/platform/shared/common/RhoNativeViewManager.h +27 -1
- data/platform/shared/common/RhoPort.h +11 -0
- data/platform/shared/common/RhoStd.h +5 -0
- data/platform/shared/common/RhoThread.cpp +1 -1
- data/platform/shared/common/RhoThread.h +1 -1
- data/platform/shared/common/RhodesApp.cpp +381 -139
- data/platform/shared/common/RhodesApp.h +24 -10
- data/platform/shared/common/RhodesAppBase.cpp +72 -1
- data/platform/shared/common/RhodesAppBase.h +5 -1
- data/platform/shared/common/SplashScreen.h +4 -4
- data/platform/shared/common/ThreadQueue.cpp +44 -17
- data/platform/shared/common/ThreadQueue.h +4 -0
- data/platform/shared/common/app_build_configs.c +0 -1
- data/platform/shared/common/iphone/RhoClassfactory.h +6 -0
- data/platform/shared/common/iphone/RhoCryptImpl.h +47 -0
- data/platform/shared/common/iphone/RhoCryptImpl.mm +286 -0
- data/platform/shared/common/map/ESRIMapEngine.cpp +921 -0
- data/platform/shared/common/map/ESRIMapEngine.h +255 -0
- data/platform/shared/common/map/GoogleMapEngine.cpp +160 -0
- data/platform/shared/common/map/GoogleMapEngine.h +52 -0
- data/platform/shared/common/map/MapEngine.cpp +304 -0
- data/platform/shared/common/map/MapEngine.h +214 -0
- data/platform/shared/db/DBAdapter.cpp +147 -18
- data/platform/shared/db/DBAdapter.h +38 -12
- data/platform/shared/db/DBAttrManager.cpp +4 -3
- data/platform/shared/db/DBAttrManager.h +7 -7
- data/platform/shared/db/res/db/syncdb.triggers +0 -5
- data/platform/shared/db/res/db/syncdb_java.triggers +21 -0
- data/platform/shared/json/JSONIterator.cpp +11 -1
- data/platform/shared/json/JSONIterator.h +1 -0
- data/platform/shared/logging/RhoLogConf.cpp +29 -12
- data/platform/shared/net/CURLNetRequest.cpp +80 -25
- data/platform/shared/net/CURLNetRequest.h +6 -2
- data/platform/shared/net/HttpServer.cpp +12 -6
- data/platform/shared/net/HttpServer.h +2 -1
- data/platform/shared/net/INetRequest.h +1 -0
- data/platform/shared/ruby/ext/alert/alert.i +5 -0
- data/platform/shared/ruby/ext/alert/alert_wrap.c +439 -108
- data/platform/shared/ruby/ext/datetimepicker/datetimepicker.i +42 -0
- data/platform/shared/ruby/ext/datetimepicker/datetimepicker_wrap.c +521 -120
- data/platform/shared/ruby/ext/nativebar/nativebar.i +16 -0
- data/platform/shared/ruby/ext/nativebar/nativebar_wrap.c +623 -128
- data/platform/shared/ruby/ext/nativeviewmanager/nativeviewmanager.i +18 -0
- data/platform/shared/ruby/ext/nativeviewmanager/nativeviewmanager_wrap.c +2321 -0
- data/platform/shared/ruby/ext/rho/extensions.c +0 -1
- data/platform/shared/ruby/ext/rho/rhoruby.c +53 -0
- data/platform/shared/ruby/ext/rho/rhoruby.h +6 -0
- data/platform/shared/ruby/ext/sqlite3_api/sqlite3_api_wrap.c +6 -3
- data/platform/shared/ruby/ext/syncengine/syncengine.i +9 -1
- data/platform/shared/ruby/ext/syncengine/syncengine_wrap.c +61 -0
- data/platform/shared/ruby/ext/system/system.i +4 -0
- data/platform/shared/ruby/ext/system/system_wrap.c +33 -5
- data/platform/shared/rubyext/RhoAppAdapter.cpp +11 -1
- data/platform/shared/rubyext/System.cpp +9 -0
- data/platform/shared/rubyext/WebView.h +1 -0
- data/platform/shared/sqlite/crypto.c +907 -0
- data/platform/shared/sqlite/sqlite3.c +6 -0
- data/platform/shared/sync/SyncEngine.cpp +49 -19
- data/platform/shared/sync/SyncEngine.h +0 -1
- data/platform/shared/sync/SyncNotify.cpp +14 -5
- data/platform/shared/sync/SyncNotify.h +2 -2
- data/platform/shared/sync/SyncSource.cpp +79 -33
- data/platform/shared/sync/SyncSource.h +1 -0
- data/platform/shared/sync/SyncThread.cpp +26 -11
- data/platform/shared/xruby/src/com/xruby/compiler/codedom/StringExpression.java +4 -2
- data/platform/wm/RhoLib/RhoLib.vcproj +108 -72
- data/platform/wm/build/wm.rake +6 -0
- data/platform/wm/rhodes/Alert.cpp +4 -3
- data/platform/wm/rhodes/Alert.h +1 -1
- data/platform/wm/rhodes/DateTimePicker.cpp +30 -3
- data/platform/wm/rhodes/DateTimePicker.h +9 -1
- data/platform/wm/rhodes/MainWindow.cpp +121 -61
- data/platform/wm/rhodes/MainWindow.h +29 -4
- data/platform/wm/rhodes/MapView/Graphics.cpp +547 -0
- data/platform/wm/rhodes/MapView/Graphics.h +136 -0
- data/platform/wm/rhodes/MapView/MapViewManager.cpp +391 -0
- data/platform/wm/rhodes/MapView/MapViewManager.h +158 -0
- data/platform/wm/rhodes/RhoCryptImpl.cpp +248 -0
- data/platform/wm/rhodes/RhoCryptImpl.h +51 -0
- data/platform/wm/rhodes/RhoNativeViewManager.cpp +208 -0
- data/platform/wm/rhodes/Rhodes.cpp +94 -102
- data/platform/wm/rhodes/Rhodes.rc +27 -0
- data/platform/wm/rhodes/SyncStatusDlg.cpp +1 -0
- data/platform/wm/rhodes/SyncStatusDlg.h +2 -1
- data/platform/wm/rhodes/bluetooth/Bluetooth.cpp +7 -4
- data/platform/wm/rhodes/camera/Camera.cpp +36 -15
- data/platform/wm/rhodes/camera/Camera.h +0 -4
- data/platform/wm/rhodes/resource.h +10 -2
- data/platform/wm/rhodes/rho/common/RhoClassFactory.cpp +7 -0
- data/platform/wm/rhodes/rho/common/RhoClassFactory.h +1 -0
- data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +10 -2
- data/platform/wm/rhodes/rho/net/NetRequestImpl.h +10 -0
- data/platform/wm/rhodes/rho/rubyext/NativeToolbar.cpp +513 -0
- data/platform/wm/rhodes/rho/rubyext/NativeToolbar.h +74 -0
- data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +22 -10
- data/platform/wm/rhodes/rho/rubyext/WebView.cpp +5 -0
- data/platform/wm/rhodes/rhodes.vcproj +38 -2
- data/platform/wm/rhodes/stdafx.h +2 -1
- data/platform/wm/rubylib/rubylib.vcproj +12 -0
- data/rakefile.rb +85 -80
- data/res/build-tools/iphonesim/Source/iPhoneSimulator.m +14 -3
- data/res/build-tools/iphonesim/build/Release/iphonesim +0 -0
- data/res/build-tools/iphonesim/iphonesim.xcodeproj/project.pbxproj +2 -0
- data/res/build-tools/xruby-0.3.3.jar +0 -0
- data/res/generators/templates/application/app/application.rb +2 -2
- data/res/generators/templates/application/app/helpers/application_helper.rb +1 -1
- data/res/generators/templates/application/public/css/android.css +1 -0
- data/res/generators/templates/application/public/jqtouch/jquery.1.3.2.min.js +1 -1
- data/res/generators/templates/application/rhoconfig.txt +66 -14
- data/rhodes.gemspec +3 -3
- data/spec/framework_spec/app/spec/core/file/expand_path_spec.rb +7 -3
- data/spec/framework_spec/build.yml +1 -1
- data/spec/phone_spec/Rakefile +1 -0
- data/spec/phone_spec/app/Account/account.rb +2 -0
- data/spec/phone_spec/app/Account_s/account_s.rb +7 -0
- data/spec/phone_spec/app/spec/{fixtures → array/fixtures}/classes.rb +0 -0
- data/spec/phone_spec/app/spec/{array_pack_spec.rb → array/pack_spec.rb} +2 -1
- data/spec/phone_spec/app/spec/bulksync_spec.rb +1 -0
- data/spec/phone_spec/app/spec/contacts_spec.rb +2 -0
- data/spec/phone_spec/app/spec/rho_spec.rb +34 -233
- data/spec/phone_spec/app/spec/rhom_object_spec.rb +396 -87
- data/spec/phone_spec/app/spec/string/element_set_spec.rb +251 -0
- data/spec/phone_spec/app/spec/string/end_with_spec.rb +49 -0
- data/spec/phone_spec/app/spec/string/fixtures/classes.rb +27 -0
- data/spec/phone_spec/app/spec/{lstrip_spec.rb → string/lstrip_spec.rb} +0 -0
- data/spec/phone_spec/app/spec/string/replace_spec.rb +52 -0
- data/spec/phone_spec/app/spec/{rstrip_spec.rb → string/rstrip_spec.rb} +0 -0
- data/spec/phone_spec/app/spec/string/slice_spec.rb +473 -0
- data/spec/phone_spec/app/spec/string/split_spec.rb +302 -0
- data/spec/phone_spec/app/spec/string/start_with_spec.rb +48 -0
- data/spec/phone_spec/app/spec/{strip_spec.rb → string/strip_spec.rb} +0 -0
- data/spec/phone_spec/app/spec/syncengine_spec.rb +30 -1
- data/spec/phone_spec/app/spec_runner.rb +15 -7
- data/spec/phone_spec/build.yml +2 -2
- metadata +154 -25
- data/README.textile +0 -45
- data/platform/android/Rhodes/AndroidManifest.full.xml +0 -62
- data/platform/android/Rhodes/gen/com/rhomobile/rhodes/Manifest.java +0 -14
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoActivity.java +0 -20
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +0 -193
- data/platform/bb/Hsqldb/src/com/rho/file/FileAccessBB.java +0 -25
- data/platform/bb/RubyVM/src/com/rho/AppBuildConfig.java +0 -22
- data/platform/bb/RubyVM/src/com/rho/Capabilities.java +0 -6
- data/platform/bb/RubyVM/src/com/rho/Extensions.java +0 -11
- data/platform/iphone/Classes/RhoNativeViewManager.mm +0 -226
@@ -2,14 +2,19 @@ package com.rhomobile.rhodes;
|
|
2
2
|
|
3
3
|
import java.io.File;
|
4
4
|
import java.io.IOException;
|
5
|
+
import java.io.InputStream;
|
6
|
+
import java.io.OutputStream;
|
7
|
+
import java.lang.reflect.InvocationTargetException;
|
8
|
+
import java.lang.reflect.Method;
|
9
|
+
import java.net.HttpURLConnection;
|
10
|
+
import java.net.URL;
|
11
|
+
import java.net.URLConnection;
|
5
12
|
import java.util.Calendar;
|
6
13
|
import java.util.Enumeration;
|
7
|
-
import java.util.Iterator;
|
8
|
-
import java.util.List;
|
9
14
|
import java.util.Locale;
|
10
|
-
import java.util.Map;
|
11
15
|
import java.util.Set;
|
12
16
|
import java.util.TimeZone;
|
17
|
+
import java.util.UUID;
|
13
18
|
import java.util.Vector;
|
14
19
|
|
15
20
|
import com.rhomobile.rhodes.alert.Alert;
|
@@ -27,131 +32,118 @@ import com.rhomobile.rhodes.uri.TelUriHandler;
|
|
27
32
|
import com.rhomobile.rhodes.uri.UriHandler;
|
28
33
|
import com.rhomobile.rhodes.uri.VideoUriHandler;
|
29
34
|
import com.rhomobile.rhodes.util.PerformOnUiThread;
|
30
|
-
import com.rhomobile.rhodes.webview.ChromeClientOld;
|
31
|
-
import com.rhomobile.rhodes.webview.RhoWebSettings;
|
32
35
|
|
33
|
-
import android.app.
|
36
|
+
import android.app.AlertDialog;
|
37
|
+
import android.app.Notification;
|
38
|
+
import android.app.NotificationManager;
|
39
|
+
import android.app.PendingIntent;
|
40
|
+
import android.app.Service;
|
41
|
+
import android.content.BroadcastReceiver;
|
34
42
|
import android.content.Context;
|
43
|
+
import android.content.DialogInterface;
|
35
44
|
import android.content.Intent;
|
45
|
+
import android.content.IntentFilter;
|
36
46
|
import android.content.pm.ActivityInfo;
|
37
47
|
import android.content.pm.ApplicationInfo;
|
38
48
|
import android.content.pm.PackageInfo;
|
39
49
|
import android.content.pm.PackageManager;
|
40
50
|
import android.content.pm.PackageManager.NameNotFoundException;
|
41
|
-
import android.graphics.Bitmap;
|
42
51
|
import android.net.ConnectivityManager;
|
43
52
|
import android.net.NetworkInfo;
|
44
53
|
import android.net.Uri;
|
54
|
+
import android.os.Binder;
|
45
55
|
import android.os.Build;
|
46
56
|
import android.os.Bundle;
|
47
|
-
import android.os.
|
57
|
+
import android.os.IBinder;
|
48
58
|
import android.os.PowerManager;
|
49
|
-
import android.os.Process;
|
50
59
|
import android.telephony.TelephonyManager;
|
51
60
|
import android.util.DisplayMetrics;
|
52
61
|
import android.util.Log;
|
53
62
|
import android.view.Display;
|
54
|
-
import android.view.View;
|
55
|
-
import android.view.ViewGroup;
|
56
|
-
import android.view.Window;
|
57
63
|
import android.view.WindowManager;
|
58
|
-
import android.webkit.WebChromeClient;
|
59
64
|
import android.webkit.WebSettings;
|
60
65
|
import android.webkit.WebView;
|
61
|
-
import android.
|
66
|
+
import android.widget.RemoteViews;
|
62
67
|
|
63
|
-
public class RhodesService {
|
68
|
+
public class RhodesService extends Service {
|
64
69
|
|
65
|
-
private final
|
66
|
-
|
67
|
-
public static final String INTENT_EXTRA_PREFIX = "com.rhomobile.rhodes.";
|
70
|
+
private static final String TAG = RhodesService.class.getSimpleName();
|
68
71
|
|
69
|
-
|
70
|
-
public static final int RHO_MAIN_VIEW = 2;
|
71
|
-
public static final int RHO_TOOLBAR_VIEW = 3;
|
72
|
+
private static final boolean DEBUG = false;
|
72
73
|
|
73
|
-
|
74
|
+
public static final String INTENT_EXTRA_PREFIX = "com.rhomobile.rhodes.";
|
74
75
|
|
75
|
-
|
76
|
+
public static final String INTENT_SOURCE = INTENT_EXTRA_PREFIX + ".intent.source";
|
76
77
|
|
77
|
-
public static
|
78
|
-
|
79
|
-
}
|
78
|
+
public static int WINDOW_FLAGS = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN;
|
79
|
+
public static int WINDOW_MASK = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN;
|
80
80
|
|
81
|
-
private
|
81
|
+
private static final int DOWNLOAD_PACKAGE_ID = 1;
|
82
82
|
|
83
|
-
|
84
|
-
|
85
|
-
}
|
83
|
+
private static final String ACTION_ASK_CANCEL_DOWNLOAD = "com.rhomobile.rhodes.DownloadManager.ACTION_ASK_CANCEL_DOWNLOAD";
|
84
|
+
private static final String ACTION_CANCEL_DOWNLOAD = "com.rhomobile.rhodes.DownloadManager.ACTION_CANCEL_DOWNLOAD";
|
86
85
|
|
87
|
-
|
88
|
-
return ctx;
|
89
|
-
}
|
86
|
+
private static RhodesService sInstance;
|
90
87
|
|
91
|
-
|
92
|
-
StringBuilder s = new StringBuilder();
|
93
|
-
s.append("ms[");
|
94
|
-
s.append(System.currentTimeMillis());
|
95
|
-
s.append("] ");
|
96
|
-
s.append(_message);
|
97
|
-
android.util.Log.v(_tag, s.toString());
|
98
|
-
}
|
88
|
+
private final IBinder mBinder = new LocalBinder();
|
99
89
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
}
|
90
|
+
@SuppressWarnings("rawtypes")
|
91
|
+
private static final Class[] mStartForegroundSignature = new Class[] {int.class, Notification.class};
|
92
|
+
@SuppressWarnings("rawtypes")
|
93
|
+
private static final Class[] mStopForegroundSignature = new Class[] {boolean.class};
|
104
94
|
|
105
|
-
private
|
95
|
+
private Method mStartForeground;
|
96
|
+
private Method mStopForeground;
|
106
97
|
|
107
|
-
private
|
98
|
+
private NotificationManager mNM;
|
108
99
|
|
109
|
-
|
110
|
-
public static int WINDOW_MASK = WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
100
|
+
//private MainView mMainView;
|
111
101
|
|
112
|
-
|
102
|
+
private static int mScreenWidth;
|
103
|
+
private static int mScreenHeight;
|
104
|
+
private static int mScreenOrientation;
|
113
105
|
|
114
|
-
|
115
|
-
|
116
|
-
private long uiThreadId = 0;
|
117
|
-
|
118
|
-
public long getUiThreadId() {
|
119
|
-
return uiThreadId;
|
120
|
-
}
|
106
|
+
private static float mScreenPpiX;
|
107
|
+
private static float mScreenPpiY;
|
121
108
|
|
122
|
-
|
123
|
-
ctx = c;
|
124
|
-
uiThreadId = id;
|
125
|
-
uiHandler = handler;
|
126
|
-
//RhoBluetoothManager.sharedInstance();
|
127
|
-
}
|
109
|
+
private static boolean mCameraAvailable;
|
128
110
|
|
129
|
-
private
|
111
|
+
private static int sActivitiesActive;
|
130
112
|
|
131
|
-
|
132
|
-
|
113
|
+
private static int mGeoLocationInactivityTimeout;
|
114
|
+
|
115
|
+
public static int getGeoLocationInactivityTimeout() {
|
116
|
+
return mGeoLocationInactivityTimeout;
|
133
117
|
}
|
134
118
|
|
135
|
-
|
136
|
-
|
119
|
+
private RhoLogConf m_rhoLogConf = new RhoLogConf();
|
120
|
+
public RhoLogConf getLogConf() {
|
121
|
+
return m_rhoLogConf;
|
137
122
|
}
|
138
123
|
|
139
|
-
private
|
140
|
-
private static int screenHeight;
|
141
|
-
private static int screenOrientation;
|
124
|
+
private boolean mNeedGeoLocationRestart = false;
|
142
125
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
private static boolean isCameraAvailable;
|
147
|
-
|
148
|
-
private WebChromeClient chromeClient;
|
149
|
-
private RhoWebSettings webSettings;
|
126
|
+
static PowerManager.WakeLock wakeLockObject = null;
|
127
|
+
static boolean wakeLockEnabled = false;
|
150
128
|
|
151
|
-
private
|
129
|
+
private Vector<UriHandler> mUriHandlers = new Vector<UriHandler>();
|
152
130
|
|
153
|
-
|
154
|
-
|
131
|
+
public boolean handleUrlLoading(String url) {
|
132
|
+
Enumeration<UriHandler> e = mUriHandlers.elements();
|
133
|
+
while (e.hasMoreElements()) {
|
134
|
+
UriHandler handler = e.nextElement();
|
135
|
+
try {
|
136
|
+
if (handler.handle(url))
|
137
|
+
return true;
|
138
|
+
}
|
139
|
+
catch (Exception ex) {
|
140
|
+
Logger.E(TAG, ex.getMessage());
|
141
|
+
continue;
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
return false;
|
146
|
+
}
|
155
147
|
|
156
148
|
private native void initClassLoader(ClassLoader c);
|
157
149
|
|
@@ -161,85 +153,44 @@ public class RhodesService {
|
|
161
153
|
public native void doSyncAllSources(boolean v);
|
162
154
|
public native void doSyncSource(String source);
|
163
155
|
|
164
|
-
public native String getOptionsUrl();
|
165
|
-
public native String getStartUrl();
|
166
|
-
public native String getCurrentUrl();
|
167
|
-
public native String getAppBackUrl();
|
168
|
-
|
169
|
-
public static native String getBlobPath();
|
170
|
-
|
171
156
|
public native String normalizeUrl(String url);
|
172
157
|
|
173
|
-
public
|
158
|
+
public native void doRequest(String url);
|
174
159
|
|
175
160
|
public static native void loadUrl(String url);
|
176
161
|
|
177
162
|
public static native void navigateBack();
|
178
163
|
|
179
|
-
|
164
|
+
private String mRootPath;
|
165
|
+
private native void nativeInitPath(String rootPath, String sqliteJournalsPath, String apkPath);
|
180
166
|
|
181
|
-
public native void
|
167
|
+
public static native void onScreenOrientationChanged(int width, int height, int angle);
|
182
168
|
|
183
|
-
public native
|
169
|
+
public native void callUiCreatedCallback();
|
170
|
+
public native void callUiDestroyedCallback();
|
171
|
+
public native void callActivationCallback(boolean active);
|
184
172
|
|
185
|
-
public static native
|
173
|
+
public static native String getBuildConfig(String key);
|
186
174
|
|
187
|
-
|
188
|
-
private native void nativeInitPath(String rootPath, String sqliteJournalsPath, String apkPath);
|
175
|
+
public static native boolean isOnStartPage();
|
189
176
|
|
190
|
-
static
|
191
|
-
static boolean wakeLockEnabled = false;
|
177
|
+
public static native boolean canStartApp(String strCmdLine, String strSeparators);
|
192
178
|
|
193
|
-
public static
|
194
|
-
|
195
|
-
int wasEnabled = 1;
|
196
|
-
if (wakeLockObject != null) {
|
197
|
-
wasEnabled = 0;
|
198
|
-
}
|
199
|
-
if (enable != 0) {
|
200
|
-
// disable lock device
|
201
|
-
PerformOnUiThread.exec( new Runnable() {
|
202
|
-
public void run() {
|
203
|
-
if (wakeLockObject != null) {
|
204
|
-
wakeLockObject.release();
|
205
|
-
wakeLockObject = null;
|
206
|
-
wakeLockEnabled = false;
|
207
|
-
}
|
208
|
-
}
|
209
|
-
}, false);
|
210
|
-
}
|
211
|
-
else {
|
212
|
-
// lock device from sleep
|
213
|
-
PerformOnUiThread.exec( new Runnable() {
|
214
|
-
public void run() {
|
215
|
-
if (wakeLockObject == null) {
|
216
|
-
PowerManager pm = (PowerManager)getInstance().getContext().getSystemService(Context.POWER_SERVICE);
|
217
|
-
if (pm != null) {
|
218
|
-
wakeLockObject = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, TAG);
|
219
|
-
wakeLockObject.acquire();
|
220
|
-
wakeLockEnabled = true;
|
221
|
-
}
|
222
|
-
else {
|
223
|
-
Logger.E(TAG, "rho_sys_set_sleeping() - Can not get PowerManager !!!");
|
224
|
-
}
|
225
|
-
}
|
226
|
-
}
|
227
|
-
}, false);
|
228
|
-
}
|
229
|
-
return wasEnabled;
|
179
|
+
public static RhodesService getInstance() {
|
180
|
+
return sInstance;
|
230
181
|
}
|
231
182
|
|
232
183
|
private void initRootPath() {
|
233
184
|
ApplicationInfo appInfo = getAppInfo();
|
234
185
|
String dataDir = appInfo.dataDir;
|
235
186
|
|
236
|
-
|
237
|
-
Log.d(TAG, "Root path: " +
|
187
|
+
mRootPath = dataDir + "/rhodata/";
|
188
|
+
Log.d(TAG, "Root path: " + mRootPath);
|
238
189
|
|
239
190
|
String sqliteJournalsPath = dataDir + "/sqlite_stmt_journals/";
|
240
191
|
Log.d(TAG, "Sqlite journals path: " + sqliteJournalsPath);
|
241
192
|
|
242
|
-
File f = new File(
|
193
|
+
File f = new File(mRootPath);
|
243
194
|
f.mkdirs();
|
244
195
|
f = new File(f, "db/db-files");
|
245
196
|
f.mkdirs();
|
@@ -248,464 +199,325 @@ public class RhodesService {
|
|
248
199
|
|
249
200
|
String apkPath = appInfo.sourceDir;
|
250
201
|
|
251
|
-
nativeInitPath(
|
202
|
+
nativeInitPath(mRootPath, sqliteJournalsPath, apkPath);
|
203
|
+
}
|
204
|
+
|
205
|
+
public String getRootPath() {
|
206
|
+
return mRootPath;
|
252
207
|
}
|
253
208
|
|
254
209
|
private ApplicationInfo getAppInfo() {
|
255
|
-
|
210
|
+
Context context = this;
|
211
|
+
String pkgName = context.getPackageName();
|
256
212
|
try {
|
257
|
-
ApplicationInfo info =
|
213
|
+
ApplicationInfo info = context.getPackageManager().getApplicationInfo(pkgName, 0);
|
258
214
|
return info;
|
259
215
|
} catch (NameNotFoundException e) {
|
260
216
|
throw new RuntimeException("Internal error: package " + pkgName + " not found: " + e.getMessage());
|
261
217
|
}
|
262
218
|
}
|
263
219
|
|
264
|
-
public
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
private Vector<UriHandler> uriHandlers = new Vector<UriHandler>();
|
269
|
-
|
270
|
-
private boolean handleUrlLoading(String url) {
|
271
|
-
Enumeration<UriHandler> e = uriHandlers.elements();
|
272
|
-
while (e.hasMoreElements()) {
|
273
|
-
UriHandler handler = e.nextElement();
|
274
|
-
try {
|
275
|
-
if (handler.handle(url))
|
276
|
-
return true;
|
277
|
-
}
|
278
|
-
catch (Exception ex) {
|
279
|
-
Logger.E(TAG, ex.getMessage());
|
280
|
-
continue;
|
281
|
-
}
|
220
|
+
public class LocalBinder extends Binder {
|
221
|
+
RhodesService getService() {
|
222
|
+
return RhodesService.this;
|
282
223
|
}
|
283
|
-
|
284
|
-
return false;
|
285
|
-
}
|
224
|
+
};
|
286
225
|
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
226
|
+
@Override
|
227
|
+
public IBinder onBind(Intent intent) {
|
228
|
+
if (DEBUG)
|
229
|
+
Log.d(TAG, "+++ onBind");
|
230
|
+
return mBinder;
|
291
231
|
}
|
292
232
|
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
}
|
298
|
-
|
299
|
-
public void hideSplashScreen() {
|
300
|
-
PerformOnUiThread.exec(new Runnable() {
|
301
|
-
public void run() {
|
302
|
-
if (splashScreen != null) {
|
303
|
-
splashScreen.hide(outerFrame);
|
304
|
-
splashScreen = null;
|
305
|
-
}
|
306
|
-
View view = mainView.getView();
|
307
|
-
view.setVisibility(View.VISIBLE);
|
308
|
-
view.requestFocus();
|
309
|
-
}
|
310
|
-
}, false);
|
311
|
-
}
|
312
|
-
|
313
|
-
public static WebView createLoadingWebView(Context ctx) {
|
314
|
-
WebView w = new WebView(ctx);
|
315
|
-
|
316
|
-
//webSettings.setWebSettings(w);
|
317
|
-
|
318
|
-
w.clearCache(true);
|
319
|
-
|
320
|
-
w.setWebViewClient(new WebViewClient() {
|
321
|
-
|
322
|
-
private boolean splashHidden = false;
|
323
|
-
private boolean setupExecuted = false;
|
324
|
-
|
325
|
-
@Override
|
326
|
-
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
327
|
-
super.onPageStarted(view, url, favicon);
|
328
|
-
}
|
329
|
-
|
330
|
-
@Override
|
331
|
-
public void onPageFinished(WebView view, String url) {
|
332
|
-
RhodesService rs = RhodesService.getInstance();
|
333
|
-
if (rs != null) {
|
334
|
-
if (!splashHidden && url.startsWith("http://")) {
|
335
|
-
rs.hideSplashScreen();
|
336
|
-
splashHidden = true;
|
337
|
-
}
|
338
|
-
}
|
339
|
-
//if (ENABLE_LOADING_INDICATION)
|
340
|
-
Rhodes.getInstance().getWindow().setFeatureInt(Window.FEATURE_PROGRESS, MAX_PROGRESS);
|
341
|
-
super.onPageFinished(view, url);
|
342
|
-
if (!setupExecuted) {
|
343
|
-
Rhodes.runPostponedSetup();
|
344
|
-
setupExecuted = true;
|
345
|
-
}
|
346
|
-
|
347
|
-
}
|
348
|
-
|
349
|
-
});
|
350
|
-
|
351
|
-
//w.setWebChromeClient(chromeClient);
|
352
|
-
|
353
|
-
return w;
|
354
|
-
|
355
|
-
}
|
356
|
-
|
357
|
-
public WebView createWebView() {
|
358
|
-
WebView w = new WebView(ctx);
|
233
|
+
@Override
|
234
|
+
public void onCreate() {
|
235
|
+
if (DEBUG)
|
236
|
+
Log.d(TAG, "+++ onCreate");
|
359
237
|
|
360
|
-
|
238
|
+
sInstance = this;
|
361
239
|
|
362
|
-
|
363
|
-
|
364
|
-
w.setWebViewClient(new WebViewClient() {
|
365
|
-
|
366
|
-
private boolean splashHidden = false;
|
367
|
-
|
368
|
-
@Override
|
369
|
-
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
370
|
-
return handleUrlLoading(url);
|
371
|
-
}
|
372
|
-
|
373
|
-
@Override
|
374
|
-
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
375
|
-
Rhodes r = Rhodes.getInstance();
|
376
|
-
if (ENABLE_LOADING_INDICATION)
|
377
|
-
r.getWindow().setFeatureInt(Window.FEATURE_PROGRESS, 0);
|
378
|
-
super.onPageStarted(view, url, favicon);
|
379
|
-
}
|
380
|
-
|
381
|
-
@Override
|
382
|
-
public void onPageFinished(WebView view, String url) {
|
383
|
-
// Set title
|
384
|
-
Rhodes r = Rhodes.getInstance();
|
385
|
-
String title = view.getTitle();
|
386
|
-
r.setTitle(title);
|
387
|
-
// Hide splash screen
|
388
|
-
if (!splashHidden && url.startsWith("http://")) {
|
389
|
-
hideSplashScreen();
|
390
|
-
splashHidden = true;
|
391
|
-
}
|
392
|
-
//if (ENABLE_LOADING_INDICATION)
|
393
|
-
r.getWindow().setFeatureInt(Window.FEATURE_PROGRESS, MAX_PROGRESS);
|
394
|
-
super.onPageFinished(view, url);
|
395
|
-
}
|
396
|
-
|
397
|
-
});
|
240
|
+
Context context = this;
|
398
241
|
|
399
|
-
|
242
|
+
mNM = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
|
400
243
|
|
401
|
-
|
402
|
-
}
|
403
|
-
|
404
|
-
private void initWebStuff() {
|
405
|
-
String ccName;
|
406
|
-
String wsName;
|
407
|
-
int sdkVersion = Integer.parseInt(Build.VERSION.SDK);
|
408
|
-
if (sdkVersion < Build.VERSION_CODES.ECLAIR_MR1) {
|
409
|
-
ccName = "ChromeClientOld";
|
410
|
-
wsName = "RhoWebSettingsOld";
|
411
|
-
}
|
412
|
-
else {
|
413
|
-
ccName = "ChromeClientNew";
|
414
|
-
wsName = "RhoWebSettingsNew";
|
415
|
-
}
|
416
|
-
|
417
|
-
try {
|
418
|
-
String pkgname = ChromeClientOld.class.getPackage().getName();
|
419
|
-
String fullName = pkgname + "." + ccName;
|
420
|
-
Class<? extends WebChromeClient> ccClass =
|
421
|
-
Class.forName(fullName).asSubclass(WebChromeClient.class);
|
422
|
-
chromeClient = ccClass.newInstance();
|
423
|
-
|
424
|
-
pkgname = RhoWebSettings.class.getPackage().getName();
|
425
|
-
fullName = pkgname + "." + wsName;
|
426
|
-
Class<? extends RhoWebSettings> wsClass =
|
427
|
-
Class.forName(fullName).asSubclass(RhoWebSettings.class);
|
428
|
-
webSettings = wsClass.newInstance();
|
429
|
-
}
|
430
|
-
catch (Exception e) {
|
431
|
-
throw new IllegalStateException(e);
|
432
|
-
}
|
433
|
-
}
|
434
|
-
|
435
|
-
public void setMainView(MainView v) {
|
436
|
-
View main = outerFrame.findViewById(RHO_MAIN_VIEW);
|
437
|
-
if (main != null)
|
438
|
-
outerFrame.removeView(main);
|
439
|
-
mainView = v;
|
440
|
-
main = mainView.getView();
|
441
|
-
if (outerFrame.findViewById(RHO_SPLASH_VIEW) != null)
|
442
|
-
main.setVisibility(View.INVISIBLE);
|
443
|
-
outerFrame.addView(main);
|
444
|
-
}
|
445
|
-
|
446
|
-
public MainView getMainView() {
|
447
|
-
return mainView;
|
448
|
-
}
|
449
|
-
|
450
|
-
public void setRootWindow(ViewGroup rootWindow) {
|
451
|
-
if (rootWindow == outerFrame)
|
452
|
-
return;
|
453
|
-
if (outerFrame != null)
|
454
|
-
outerFrame.removeAllViews();
|
455
|
-
outerFrame = rootWindow;
|
456
|
-
outerFrame.addView(mainView.getView());
|
457
|
-
}
|
458
|
-
|
459
|
-
public static boolean isCreated() {
|
460
|
-
return instance != null;
|
461
|
-
}
|
462
|
-
|
463
|
-
public RhodesService(Activity c, ViewGroup rootWindow, SplashScreen splash_s, Object params) {
|
464
|
-
|
465
|
-
ctx = c;
|
466
|
-
instance = this;
|
467
|
-
outerFrame = rootWindow;
|
468
|
-
|
469
|
-
//showSplashScreen();
|
470
|
-
splashScreen = splash_s;
|
244
|
+
initClassLoader(context.getClassLoader());
|
471
245
|
|
472
|
-
initClassLoader(ctx.getClassLoader());
|
473
|
-
|
474
246
|
try {
|
475
247
|
initRootPath();
|
476
248
|
RhoFileApi.init();
|
477
249
|
} catch (IOException e) {
|
478
250
|
Log.e(TAG, e.getMessage());
|
479
|
-
|
251
|
+
exit();
|
480
252
|
return;
|
481
253
|
}
|
482
254
|
|
483
255
|
if (Utils.isAppHashChanged()) {
|
484
256
|
try {
|
485
257
|
Log.i(TAG, "Application hash was changed, so remove files");
|
258
|
+
Utils.deleteChildrenIgnoreFirstLevel(new File(getRootPath(), "apps"), "rhoconfig.txt");
|
259
|
+
Utils.deleteRecursively(new File(getRootPath(), "lib"));
|
260
|
+
/*
|
486
261
|
String[] folders = {"apps", "lib"};
|
487
262
|
for (String folder : folders) {
|
488
|
-
File f = new File(
|
263
|
+
File f = new File(getRootPath(), folder);
|
489
264
|
if (!f.exists())
|
490
265
|
continue;
|
491
266
|
Utils.deleteRecursively(f);
|
492
|
-
}
|
267
|
+
}*/
|
493
268
|
initRootPath();
|
494
269
|
RhoFileApi.init();
|
495
270
|
RhoFileApi.copy("hash");
|
496
271
|
} catch (IOException e) {
|
497
272
|
Log.e(TAG, e.getMessage());
|
498
|
-
|
273
|
+
exit();
|
499
274
|
return;
|
500
275
|
}
|
501
276
|
}
|
502
277
|
|
503
278
|
createRhodesApp();
|
504
279
|
|
505
|
-
|
506
|
-
|
507
|
-
|
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
|
-
}
|
280
|
+
RhodesActivity ra = RhodesActivity.getInstance();
|
281
|
+
SplashScreen splashScreen = ra.getSplashScreen();
|
282
|
+
splashScreen.start();
|
551
283
|
|
552
|
-
|
553
|
-
if (RhoConf.isExist("full_screen"))
|
554
|
-
fullScreen = RhoConf.getBool("full_screen");
|
555
|
-
if (!fullScreen) {
|
556
|
-
WINDOW_FLAGS = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN;
|
557
|
-
WINDOW_MASK = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN;
|
558
|
-
}
|
284
|
+
initForegroundServiceApi();
|
559
285
|
|
560
|
-
|
286
|
+
setFullscreenParameters();
|
561
287
|
|
562
|
-
initWebStuff();
|
563
|
-
|
564
288
|
Logger.I("Rhodes", "Loading...");
|
565
|
-
//showSplashScreen();
|
566
|
-
if (splashScreen != null) {
|
567
|
-
splashScreen.rho_start();
|
568
|
-
}
|
569
289
|
|
570
290
|
// Increase WebView rendering priority
|
571
|
-
WebView w = new WebView(
|
291
|
+
WebView w = new WebView(context);
|
572
292
|
WebSettings webSettings = w.getSettings();
|
573
293
|
webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
|
574
294
|
|
575
295
|
// Get screen width/height
|
576
|
-
WindowManager wm = (WindowManager)
|
296
|
+
WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
|
577
297
|
Display d = wm.getDefaultDisplay();
|
578
|
-
|
579
|
-
|
580
|
-
|
298
|
+
mScreenHeight = d.getHeight();
|
299
|
+
mScreenWidth = d.getWidth();
|
300
|
+
mScreenOrientation = d.getOrientation();
|
581
301
|
|
582
302
|
DisplayMetrics metrics = new DisplayMetrics();
|
583
303
|
d.getMetrics(metrics);
|
584
|
-
|
585
|
-
|
304
|
+
mScreenPpiX = metrics.xdpi;
|
305
|
+
mScreenPpiY = metrics.ydpi;
|
586
306
|
|
587
307
|
// TODO: detect camera availability
|
588
|
-
|
308
|
+
mCameraAvailable = true;
|
589
309
|
|
590
310
|
mGeoLocationInactivityTimeout = RhoConf.getInt("geo_location_inactivity_timeout");
|
591
311
|
if (mGeoLocationInactivityTimeout == 0)
|
592
312
|
mGeoLocationInactivityTimeout = 25*1000; // 25s
|
593
313
|
|
594
314
|
// Register custom uri handlers here
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
315
|
+
mUriHandlers.addElement(new ExternalHttpHandler(context));
|
316
|
+
mUriHandlers.addElement(new MailUriHandler(context));
|
317
|
+
mUriHandlers.addElement(new TelUriHandler(context));
|
318
|
+
mUriHandlers.addElement(new SmsUriHandler(context));
|
319
|
+
mUriHandlers.addElement(new VideoUriHandler(context));
|
320
|
+
|
321
|
+
getRhodesApplication().addOnExitHandler(new Runnable() {
|
322
|
+
public void run() {
|
323
|
+
PerformOnUiThread.exec( new Runnable() {
|
324
|
+
public void run() {
|
325
|
+
if (wakeLockObject != null) {
|
326
|
+
wakeLockObject.release();
|
327
|
+
wakeLockObject = null;
|
328
|
+
wakeLockEnabled = false;
|
329
|
+
}
|
330
|
+
}
|
331
|
+
}, false);
|
332
|
+
}
|
333
|
+
});
|
600
334
|
|
601
335
|
try {
|
602
|
-
if (Capabilities.PUSH_ENABLED)
|
336
|
+
if (Capabilities.PUSH_ENABLED) {
|
603
337
|
PushService.register();
|
338
|
+
|
339
|
+
getRhodesApplication().addOnExitHandler(new Runnable() {
|
340
|
+
public void run() {
|
341
|
+
try {
|
342
|
+
PushService.unregister();
|
343
|
+
} catch (IllegalAccessException e) {
|
344
|
+
Log.e(TAG, e.getMessage());
|
345
|
+
}
|
346
|
+
}
|
347
|
+
});
|
348
|
+
}
|
604
349
|
} catch (IllegalAccessException e) {
|
605
350
|
Log.e(TAG, e.getMessage());
|
606
|
-
|
351
|
+
exit();
|
607
352
|
return;
|
608
353
|
}
|
609
354
|
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
}
|
615
|
-
|
616
|
-
});
|
617
|
-
init.start();
|
355
|
+
startRhodesApp();
|
356
|
+
|
357
|
+
if (sActivitiesActive > 0)
|
358
|
+
handleAppActivation();
|
618
359
|
}
|
619
360
|
|
620
|
-
|
621
|
-
|
361
|
+
private void setFullscreenParameters() {
|
362
|
+
boolean fullScreen = true;
|
363
|
+
if (RhoConf.isExist("full_screen"))
|
364
|
+
fullScreen = RhoConf.getBool("full_screen");
|
365
|
+
if (fullScreen) {
|
366
|
+
WINDOW_FLAGS = WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
367
|
+
WINDOW_MASK = WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
368
|
+
RhodesActivity.setFullscreen(1);
|
369
|
+
}
|
370
|
+
else {
|
371
|
+
WINDOW_FLAGS = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN;
|
372
|
+
WINDOW_MASK = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN;
|
373
|
+
RhodesActivity.setFullscreen(0);
|
374
|
+
}
|
375
|
+
//Utils.platformLog(TAG, "rhoconfig full_screen = "+String.valueOf(fullScreen)+" ");
|
622
376
|
}
|
623
|
-
|
624
|
-
|
377
|
+
|
378
|
+
private void initForegroundServiceApi() {
|
625
379
|
try {
|
626
|
-
|
627
|
-
|
628
|
-
}
|
629
|
-
|
380
|
+
mStartForeground = getClass().getMethod("startForeground", mStartForegroundSignature);
|
381
|
+
mStopForeground = getClass().getMethod("stopForeground", mStopForegroundSignature);
|
382
|
+
}
|
383
|
+
catch (NoSuchMethodException e) {
|
384
|
+
mStartForeground = null;
|
385
|
+
mStopForeground = null;
|
630
386
|
}
|
387
|
+
}
|
388
|
+
|
389
|
+
@Override
|
390
|
+
public void onDestroy() {
|
391
|
+
if (DEBUG)
|
392
|
+
Log.d(TAG, "+++ onDestroy");
|
393
|
+
sInstance = null;
|
394
|
+
getRhodesApplication().exit();
|
395
|
+
}
|
396
|
+
|
397
|
+
@Override
|
398
|
+
public void onStart(Intent intent, int startId) {
|
399
|
+
if (DEBUG)
|
400
|
+
Log.d(TAG, "+++ onStart");
|
401
|
+
try {
|
402
|
+
handleCommand(intent);
|
403
|
+
}
|
404
|
+
catch (Exception e) {
|
405
|
+
Logger.E(TAG, "Can't handle service command: " + e.getMessage());
|
406
|
+
}
|
407
|
+
}
|
408
|
+
|
409
|
+
@Override
|
410
|
+
public int onStartCommand(Intent intent, int flags, int startId) {
|
411
|
+
if (DEBUG)
|
412
|
+
Log.d(TAG, "+++ onStartCommand");
|
413
|
+
try {
|
414
|
+
handleCommand(intent);
|
415
|
+
}
|
416
|
+
catch (Exception e) {
|
417
|
+
Logger.E(TAG, "Can't handle service command: " + e.getMessage());
|
418
|
+
}
|
419
|
+
return Service.START_STICKY;
|
420
|
+
}
|
421
|
+
|
422
|
+
private void handleCommand(Intent intent) {
|
423
|
+
String source = intent.getStringExtra(INTENT_SOURCE);
|
424
|
+
if (source == null)
|
425
|
+
throw new IllegalArgumentException("Service command received from empty source");
|
631
426
|
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
427
|
+
Logger.D(TAG, "Service command received from " + source);
|
428
|
+
if (source.equals(PushReceiver.INTENT_SOURCE)) {
|
429
|
+
int type = intent.getIntExtra(PushReceiver.INTENT_TYPE, PushReceiver.INTENT_TYPE_UNKNOWN);
|
430
|
+
switch (type) {
|
431
|
+
case PushReceiver.INTENT_TYPE_REGISTRATION_ID:
|
432
|
+
String id = intent.getStringExtra(PushReceiver.INTENT_REGISTRATION_ID);
|
433
|
+
if (id == null)
|
434
|
+
throw new IllegalArgumentException("Empty registration id received in service command");
|
435
|
+
setPushRegistrationId(id);
|
436
|
+
break;
|
437
|
+
case PushReceiver.INTENT_TYPE_MESSAGE:
|
438
|
+
Bundle extras = intent.getBundleExtra(PushReceiver.INTENT_EXTRAS);
|
439
|
+
handlePushMessage(extras);
|
440
|
+
break;
|
441
|
+
default:
|
442
|
+
Logger.W(TAG, "Unknown command type received from " + source + ": " + type);
|
639
443
|
}
|
640
|
-
}
|
641
|
-
getMainActivity().finish();
|
642
|
-
Process.killProcess(Process.myPid());
|
444
|
+
}
|
643
445
|
}
|
644
446
|
|
645
|
-
public void
|
646
|
-
if (
|
647
|
-
|
648
|
-
|
649
|
-
needGeoLocationRestart = false;
|
447
|
+
public void startServiceForeground(int id, Notification notification) {
|
448
|
+
if (mStartForeground != null) {
|
449
|
+
try {
|
450
|
+
mStartForeground.invoke(this, new Object[] {Integer.valueOf(id), notification});
|
650
451
|
}
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
wakeLockObject = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, TAG);
|
659
|
-
wakeLockObject.acquire();
|
660
|
-
}
|
661
|
-
else {
|
662
|
-
Logger.E(TAG, "activityStarted() - Can not get PowerManager !!!");
|
663
|
-
}
|
664
|
-
}
|
665
|
-
}
|
666
|
-
}
|
667
|
-
}, false);
|
668
|
-
callActivationCallback(true);
|
452
|
+
catch (InvocationTargetException e) {
|
453
|
+
Log.e(TAG, "Unable to invoke startForeground", e);
|
454
|
+
}
|
455
|
+
catch (IllegalAccessException e) {
|
456
|
+
Log.e(TAG, "Unable to invoke startForeground", e);
|
457
|
+
}
|
458
|
+
return;
|
669
459
|
}
|
670
|
-
|
460
|
+
|
461
|
+
setForeground(true);
|
462
|
+
mNM.notify(id, notification);
|
671
463
|
}
|
672
464
|
|
673
|
-
public void
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
needGeoLocationRestart = GeoLocation.isAvailable();
|
686
|
-
GeoLocation.stop();
|
687
|
-
callActivationCallback(false);
|
465
|
+
public void stopServiceForeground(int id) {
|
466
|
+
if (mStopForeground != null) {
|
467
|
+
try {
|
468
|
+
mStopForeground.invoke(this, new Object[] {Integer.valueOf(id)});
|
469
|
+
}
|
470
|
+
catch (InvocationTargetException e) {
|
471
|
+
Log.e(TAG, "Unable to invoke stopForeground", e);
|
472
|
+
}
|
473
|
+
catch (IllegalAccessException e) {
|
474
|
+
Log.e(TAG, "Unable to invoke stopForeground", e);
|
475
|
+
}
|
476
|
+
return;
|
688
477
|
}
|
478
|
+
|
479
|
+
mNM.cancel(id);
|
480
|
+
setForeground(false);
|
481
|
+
}
|
482
|
+
|
483
|
+
public void setMainView(MainView v) {
|
484
|
+
RhodesActivity ra = RhodesActivity.getInstance();
|
485
|
+
ra.setMainView(v);
|
486
|
+
}
|
487
|
+
|
488
|
+
public MainView getMainView() {
|
489
|
+
RhodesActivity ra = RhodesActivity.getInstance();
|
490
|
+
if (ra == null)
|
491
|
+
return null;
|
492
|
+
return ra.getMainView();
|
493
|
+
}
|
494
|
+
|
495
|
+
public RhodesApplication getRhodesApplication() {
|
496
|
+
return (RhodesApplication)getApplication();
|
497
|
+
}
|
498
|
+
|
499
|
+
public static void exit() {
|
500
|
+
getInstance().getRhodesApplication().exit();
|
689
501
|
}
|
690
502
|
|
691
503
|
public void rereadScreenProperties() {
|
692
504
|
// check for orientarion changed
|
693
505
|
// Get screen width/height
|
694
|
-
WindowManager wm = (WindowManager)
|
506
|
+
WindowManager wm = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
|
695
507
|
Display d = wm.getDefaultDisplay();
|
696
|
-
|
697
|
-
|
508
|
+
mScreenHeight = d.getHeight();
|
509
|
+
mScreenWidth = d.getWidth();
|
698
510
|
int newScreenOrientation = d.getOrientation();
|
699
|
-
if (newScreenOrientation !=
|
700
|
-
onScreenOrientationChanged(
|
701
|
-
|
511
|
+
if (newScreenOrientation != mScreenOrientation) {
|
512
|
+
onScreenOrientationChanged(mScreenWidth, mScreenHeight, 90);
|
513
|
+
mScreenOrientation = newScreenOrientation;
|
702
514
|
}
|
703
515
|
}
|
704
516
|
|
705
517
|
public static void showAboutDialog() {
|
706
518
|
PerformOnUiThread.exec(new Runnable() {
|
707
519
|
public void run() {
|
708
|
-
final AboutDialog aboutDialog = new AboutDialog(
|
520
|
+
final AboutDialog aboutDialog = new AboutDialog(RhodesActivity.getInstance());
|
709
521
|
aboutDialog.setTitle("About");
|
710
522
|
aboutDialog.setCanceledOnTouchOutside(true);
|
711
523
|
aboutDialog.setCancelable(true);
|
@@ -717,7 +529,7 @@ public class RhodesService {
|
|
717
529
|
public static void showLogView() {
|
718
530
|
PerformOnUiThread.exec(new Runnable() {
|
719
531
|
public void run() {
|
720
|
-
final LogViewDialog logViewDialog = new LogViewDialog(
|
532
|
+
final LogViewDialog logViewDialog = new LogViewDialog(RhodesActivity.getInstance());
|
721
533
|
logViewDialog.setTitle("Log View");
|
722
534
|
logViewDialog.setCancelable(true);
|
723
535
|
logViewDialog.show();
|
@@ -728,7 +540,7 @@ public class RhodesService {
|
|
728
540
|
public static void showLogOptions() {
|
729
541
|
PerformOnUiThread.exec(new Runnable() {
|
730
542
|
public void run() {
|
731
|
-
final LogOptionsDialog logOptionsDialog = new LogOptionsDialog(
|
543
|
+
final LogOptionsDialog logOptionsDialog = new LogOptionsDialog(RhodesActivity.getInstance());
|
732
544
|
logOptionsDialog.setTitle("Logging Options");
|
733
545
|
logOptionsDialog.setCancelable(true);
|
734
546
|
logOptionsDialog.show();
|
@@ -754,7 +566,7 @@ public class RhodesService {
|
|
754
566
|
return false;
|
755
567
|
}
|
756
568
|
|
757
|
-
Context ctx = RhodesService.
|
569
|
+
Context ctx = RhodesService.getContext();
|
758
570
|
ConnectivityManager conn = (ConnectivityManager)ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
|
759
571
|
if (conn == null)
|
760
572
|
{
|
@@ -794,11 +606,11 @@ public class RhodesService {
|
|
794
606
|
}
|
795
607
|
|
796
608
|
public static int getScreenWidth() {
|
797
|
-
return
|
609
|
+
return mScreenWidth;
|
798
610
|
}
|
799
611
|
|
800
612
|
public static int getScreenHeight() {
|
801
|
-
return
|
613
|
+
return mScreenHeight;
|
802
614
|
}
|
803
615
|
|
804
616
|
public static Object getProperty(String name) {
|
@@ -814,16 +626,16 @@ public class RhodesService {
|
|
814
626
|
else if (name.equalsIgnoreCase("screen_height"))
|
815
627
|
return new Integer(getScreenHeight());
|
816
628
|
else if (name.equalsIgnoreCase("has_camera"))
|
817
|
-
return new Boolean(
|
629
|
+
return new Boolean(mCameraAvailable);
|
818
630
|
else if (name.equalsIgnoreCase("has_network"))
|
819
631
|
return hasNetwork();
|
820
632
|
else if (name.equalsIgnoreCase("ppi_x"))
|
821
|
-
return new Float(
|
633
|
+
return new Float(mScreenPpiX);
|
822
634
|
else if (name.equalsIgnoreCase("ppi_y"))
|
823
|
-
return new Float(
|
635
|
+
return new Float(mScreenPpiY);
|
824
636
|
else if (name.equalsIgnoreCase("phone_number")) {
|
825
|
-
|
826
|
-
|
637
|
+
Context context = RhodesService.getContext();
|
638
|
+
TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
|
827
639
|
String number = manager.getLine1Number();
|
828
640
|
return number;
|
829
641
|
}
|
@@ -848,10 +660,6 @@ public class RhodesService {
|
|
848
660
|
return null;
|
849
661
|
}
|
850
662
|
|
851
|
-
public static void exit() {
|
852
|
-
RhodesService.getInstance().exitApp();
|
853
|
-
}
|
854
|
-
|
855
663
|
public static String getTimezoneStr() {
|
856
664
|
Calendar cal = Calendar.getInstance();
|
857
665
|
TimeZone tz = cal.getTimeZone();
|
@@ -860,7 +668,7 @@ public class RhodesService {
|
|
860
668
|
|
861
669
|
public static void runApplication(String appName, Object params) {
|
862
670
|
try {
|
863
|
-
Context ctx = RhodesService.
|
671
|
+
Context ctx = RhodesService.getContext();
|
864
672
|
PackageManager mgr = ctx.getPackageManager();
|
865
673
|
PackageInfo info = mgr.getPackageInfo(appName, PackageManager.GET_ACTIVITIES);
|
866
674
|
if (info.activities.length == 0) {
|
@@ -874,10 +682,11 @@ public class RhodesService {
|
|
874
682
|
|
875
683
|
Intent intent = new Intent();
|
876
684
|
intent.setClassName(appName, className);
|
685
|
+
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
877
686
|
if (params != null) {
|
878
687
|
Bundle startParams = new Bundle();
|
879
688
|
if (params instanceof String) {
|
880
|
-
startParams.putString(RHO_START_PARAMS_KEY, (String)params);
|
689
|
+
startParams.putString(RhodesActivity.RHO_START_PARAMS_KEY, (String)params);
|
881
690
|
}
|
882
691
|
/*
|
883
692
|
else if (params instanceof List<?>) {
|
@@ -908,13 +717,11 @@ public class RhodesService {
|
|
908
717
|
|
909
718
|
public static boolean isAppInstalled(String appName) {
|
910
719
|
try {
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
return false;
|
917
|
-
}
|
720
|
+
RhodesService.getContext().getPackageManager().getPackageInfo(appName, 0);
|
721
|
+
return true;
|
722
|
+
}
|
723
|
+
catch (NameNotFoundException ne) {
|
724
|
+
return false;
|
918
725
|
}
|
919
726
|
catch (Exception e) {
|
920
727
|
Logger.E(TAG, "Can't check is app " + appName + " installed: " + e.getMessage());
|
@@ -922,40 +729,269 @@ public class RhodesService {
|
|
922
729
|
}
|
923
730
|
}
|
924
731
|
|
732
|
+
private void updateDownloadNotification(String url, int totalBytes, int currentBytes) {
|
733
|
+
Context context = RhodesActivity.getContext();
|
734
|
+
|
735
|
+
Notification n = new Notification();
|
736
|
+
n.icon = android.R.drawable.stat_sys_download;
|
737
|
+
n.flags |= Notification.FLAG_ONGOING_EVENT;
|
738
|
+
|
739
|
+
RemoteViews expandedView = new RemoteViews(context.getPackageName(),
|
740
|
+
AndroidR.layout.status_bar_ongoing_event_progress_bar);
|
741
|
+
|
742
|
+
StringBuilder newUrl = new StringBuilder();
|
743
|
+
if (url.length() < 17)
|
744
|
+
newUrl.append(url);
|
745
|
+
else {
|
746
|
+
newUrl.append(url.substring(0, 7));
|
747
|
+
newUrl.append("...");
|
748
|
+
newUrl.append(url.substring(url.length() - 7, url.length()));
|
749
|
+
}
|
750
|
+
expandedView.setTextViewText(AndroidR.id.title, newUrl.toString());
|
751
|
+
|
752
|
+
StringBuffer downloadingText = new StringBuffer();
|
753
|
+
if (totalBytes > 0) {
|
754
|
+
long progress = currentBytes*100/totalBytes;
|
755
|
+
downloadingText.append(progress);
|
756
|
+
downloadingText.append('%');
|
757
|
+
}
|
758
|
+
expandedView.setTextViewText(AndroidR.id.progress_text, downloadingText.toString());
|
759
|
+
expandedView.setProgressBar(AndroidR.id.progress_bar,
|
760
|
+
totalBytes < 0 ? 100 : totalBytes,
|
761
|
+
currentBytes,
|
762
|
+
totalBytes < 0);
|
763
|
+
n.contentView = expandedView;
|
764
|
+
|
765
|
+
Intent intent = new Intent(ACTION_ASK_CANCEL_DOWNLOAD);
|
766
|
+
n.contentIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
|
767
|
+
intent = new Intent(ACTION_CANCEL_DOWNLOAD);
|
768
|
+
n.deleteIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
|
769
|
+
|
770
|
+
mNM.notify(DOWNLOAD_PACKAGE_ID, n);
|
771
|
+
}
|
772
|
+
|
773
|
+
private File downloadPackage(String url) throws IOException {
|
774
|
+
final Context ctx = RhodesActivity.getContext();
|
775
|
+
|
776
|
+
final Thread thisThread = Thread.currentThread();
|
777
|
+
|
778
|
+
final Runnable cancelAction = new Runnable() {
|
779
|
+
public void run() {
|
780
|
+
thisThread.interrupt();
|
781
|
+
}
|
782
|
+
};
|
783
|
+
|
784
|
+
BroadcastReceiver downloadReceiver = new BroadcastReceiver() {
|
785
|
+
@Override
|
786
|
+
public void onReceive(Context context, Intent intent) {
|
787
|
+
String action = intent.getAction();
|
788
|
+
if (action.equals(ACTION_ASK_CANCEL_DOWNLOAD)) {
|
789
|
+
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
|
790
|
+
builder.setMessage("Cancel download?");
|
791
|
+
AlertDialog dialog = builder.create();
|
792
|
+
dialog.setButton(AlertDialog.BUTTON_POSITIVE, ctx.getText(android.R.string.yes),
|
793
|
+
new DialogInterface.OnClickListener() {
|
794
|
+
public void onClick(DialogInterface dialog, int which) {
|
795
|
+
cancelAction.run();
|
796
|
+
}
|
797
|
+
});
|
798
|
+
dialog.setButton(AlertDialog.BUTTON_NEGATIVE, ctx.getText(android.R.string.no),
|
799
|
+
new DialogInterface.OnClickListener() {
|
800
|
+
public void onClick(DialogInterface dialog, int which) {
|
801
|
+
// Nothing
|
802
|
+
}
|
803
|
+
});
|
804
|
+
dialog.show();
|
805
|
+
}
|
806
|
+
else if (action.equals(ACTION_CANCEL_DOWNLOAD)) {
|
807
|
+
cancelAction.run();
|
808
|
+
}
|
809
|
+
}
|
810
|
+
};
|
811
|
+
IntentFilter filter = new IntentFilter();
|
812
|
+
filter.addAction(ACTION_ASK_CANCEL_DOWNLOAD);
|
813
|
+
filter.addAction(ACTION_CANCEL_DOWNLOAD);
|
814
|
+
ctx.registerReceiver(downloadReceiver, filter);
|
815
|
+
|
816
|
+
File tmpFile = null;
|
817
|
+
InputStream is = null;
|
818
|
+
OutputStream os = null;
|
819
|
+
try {
|
820
|
+
updateDownloadNotification(url, -1, 0);
|
821
|
+
|
822
|
+
/*
|
823
|
+
List<File> folders = new ArrayList<File>();
|
824
|
+
folders.add(Environment.getDownloadCacheDirectory());
|
825
|
+
folders.add(Environment.getDataDirectory());
|
826
|
+
folders.add(ctx.getCacheDir());
|
827
|
+
folders.add(ctx.getFilesDir());
|
828
|
+
try {
|
829
|
+
folders.add(new File(ctx.getPackageManager().getApplicationInfo(ctx.getPackageName(), 0).dataDir));
|
830
|
+
} catch (NameNotFoundException e1) {
|
831
|
+
// Ignore
|
832
|
+
}
|
833
|
+
folders.add(Environment.getExternalStorageDirectory());
|
834
|
+
|
835
|
+
for (File folder : folders) {
|
836
|
+
File tmpRootFolder = new File(folder, "rhodownload");
|
837
|
+
File tmpFolder = new File(tmpRootFolder, ctx.getPackageName());
|
838
|
+
if (tmpFolder.exists())
|
839
|
+
deleteFilesInFolder(tmpFolder.getAbsolutePath());
|
840
|
+
else
|
841
|
+
tmpFolder.mkdirs();
|
842
|
+
|
843
|
+
File of = new File(tmpFolder, UUID.randomUUID().toString() + ".apk");
|
844
|
+
Logger.D(TAG, "Check path " + of.getAbsolutePath() + "...");
|
845
|
+
try {
|
846
|
+
os = new FileOutputStream(of);
|
847
|
+
}
|
848
|
+
catch (FileNotFoundException e) {
|
849
|
+
Logger.D(TAG, "Can't open file " + of.getAbsolutePath() + ", check next path");
|
850
|
+
continue;
|
851
|
+
}
|
852
|
+
Logger.D(TAG, "File " + of.getAbsolutePath() + " succesfully opened for write, start download app");
|
853
|
+
|
854
|
+
tmpFile = of;
|
855
|
+
break;
|
856
|
+
}
|
857
|
+
*/
|
858
|
+
|
859
|
+
tmpFile = ctx.getFileStreamPath(UUID.randomUUID().toString() + ".apk");
|
860
|
+
os = ctx.openFileOutput(tmpFile.getName(), Context.MODE_WORLD_READABLE);
|
861
|
+
|
862
|
+
Logger.D(TAG, "Download " + url + " to " + tmpFile.getAbsolutePath() + "...");
|
863
|
+
|
864
|
+
URL u = new URL(url);
|
865
|
+
URLConnection conn = u.openConnection();
|
866
|
+
int totalBytes = -1;
|
867
|
+
if (conn instanceof HttpURLConnection) {
|
868
|
+
HttpURLConnection httpConn = (HttpURLConnection)conn;
|
869
|
+
totalBytes = httpConn.getContentLength();
|
870
|
+
}
|
871
|
+
is = conn.getInputStream();
|
872
|
+
|
873
|
+
int downloaded = 0;
|
874
|
+
updateDownloadNotification(url, totalBytes, downloaded);
|
875
|
+
|
876
|
+
long prevProgress = 0;
|
877
|
+
byte[] buf = new byte[65536];
|
878
|
+
for (;;) {
|
879
|
+
if (thisThread.isInterrupted()) {
|
880
|
+
tmpFile.delete();
|
881
|
+
Logger.D(TAG, "Download of " + url + " was canceled");
|
882
|
+
return null;
|
883
|
+
}
|
884
|
+
int nread = is.read(buf);
|
885
|
+
if (nread == -1)
|
886
|
+
break;
|
887
|
+
|
888
|
+
//Logger.D(TAG, "Downloading " + url + ": got " + nread + " bytes...");
|
889
|
+
os.write(buf, 0, nread);
|
890
|
+
|
891
|
+
downloaded += nread;
|
892
|
+
if (totalBytes > 0) {
|
893
|
+
// Update progress view only if current progress is greater than
|
894
|
+
// previous by more than 10%. Otherwise, if update it very frequently,
|
895
|
+
// user will no have chance to click on notification view and cancel if need
|
896
|
+
long progress = downloaded*10/totalBytes;
|
897
|
+
if (progress > prevProgress) {
|
898
|
+
updateDownloadNotification(url, totalBytes, downloaded);
|
899
|
+
prevProgress = progress;
|
900
|
+
}
|
901
|
+
}
|
902
|
+
}
|
903
|
+
|
904
|
+
Logger.D(TAG, "File stored to " + tmpFile.getAbsolutePath());
|
905
|
+
|
906
|
+
return tmpFile;
|
907
|
+
}
|
908
|
+
catch (IOException e) {
|
909
|
+
if (tmpFile != null)
|
910
|
+
tmpFile.delete();
|
911
|
+
throw e;
|
912
|
+
}
|
913
|
+
finally {
|
914
|
+
try {
|
915
|
+
if (is != null)
|
916
|
+
is.close();
|
917
|
+
} catch (IOException e) {}
|
918
|
+
try {
|
919
|
+
if (os != null)
|
920
|
+
os.close();
|
921
|
+
} catch (IOException e) {}
|
922
|
+
|
923
|
+
mNM.cancel(DOWNLOAD_PACKAGE_ID);
|
924
|
+
ctx.unregisterReceiver(downloadReceiver);
|
925
|
+
}
|
926
|
+
}
|
927
|
+
|
928
|
+
public static void installApplication(final String url) {
|
929
|
+
Thread bgThread = new Thread(new Runnable() {
|
930
|
+
public void run() {
|
931
|
+
try {
|
932
|
+
final RhodesService r = RhodesService.getInstance();
|
933
|
+
final File tmpFile = r.downloadPackage(url);
|
934
|
+
if (tmpFile != null) {
|
935
|
+
PerformOnUiThread.exec(new Runnable() {
|
936
|
+
public void run() {
|
937
|
+
try {
|
938
|
+
Logger.D(TAG, "Install package " + tmpFile.getAbsolutePath());
|
939
|
+
Uri uri = Uri.fromFile(tmpFile);
|
940
|
+
Intent intent = new Intent(Intent.ACTION_VIEW);
|
941
|
+
intent.setDataAndType(uri, "application/vnd.android.package-archive");
|
942
|
+
r.startActivity(intent);
|
943
|
+
}
|
944
|
+
catch (Exception e) {
|
945
|
+
Log.e(TAG, "Can't install file from " + tmpFile.getAbsolutePath(), e);
|
946
|
+
Logger.E(TAG, "Can't install file from " + tmpFile.getAbsolutePath() + ": " + e.getMessage());
|
947
|
+
}
|
948
|
+
}
|
949
|
+
}, false);
|
950
|
+
}
|
951
|
+
}
|
952
|
+
catch (IOException e) {
|
953
|
+
Log.e(TAG, "Can't download package from " + url, e);
|
954
|
+
Logger.E(TAG, "Can't download package from " + url + ": " + e.getMessage());
|
955
|
+
}
|
956
|
+
}
|
957
|
+
});
|
958
|
+
bgThread.setPriority(Thread.MIN_PRIORITY);
|
959
|
+
bgThread.start();
|
960
|
+
}
|
961
|
+
|
925
962
|
public static void uninstallApplication(String appName) {
|
926
963
|
try {
|
927
964
|
Uri packageUri = Uri.parse("package:" + appName);
|
928
965
|
Intent intent = new Intent(Intent.ACTION_DELETE, packageUri);
|
929
|
-
RhodesService.
|
966
|
+
RhodesService.getContext().startActivity(intent);
|
930
967
|
}
|
931
968
|
catch (Exception e) {
|
932
969
|
Logger.E(TAG, "Can't uninstall application " + appName + ": " + e.getMessage());
|
933
970
|
}
|
934
971
|
}
|
935
|
-
|
972
|
+
|
936
973
|
public static void openExternalUrl(String url) {
|
937
974
|
try {
|
938
|
-
Context ctx = RhodesService.
|
975
|
+
Context ctx = RhodesService.getContext();
|
939
976
|
Uri uri = Uri.parse(url);
|
940
977
|
|
941
978
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
942
979
|
intent.setData(uri);
|
943
|
-
|
980
|
+
|
944
981
|
ctx.startActivity(Intent.createChooser(intent, "Open in..."));
|
945
982
|
}
|
946
983
|
catch (Exception e) {
|
947
984
|
Logger.E(TAG, "Can't open url :" + url + ": " + e.getMessage());
|
948
985
|
}
|
949
986
|
}
|
950
|
-
|
951
|
-
|
987
|
+
|
988
|
+
private native void setPushRegistrationId(String id);
|
952
989
|
|
953
990
|
private native boolean callPushCallback(String data);
|
954
991
|
|
955
|
-
|
992
|
+
private void handlePushMessage(Bundle extras) {
|
956
993
|
Logger.D(TAG, "Receive PUSH message");
|
957
994
|
|
958
|
-
Bundle extras = intent.getExtras();
|
959
995
|
if (extras == null) {
|
960
996
|
Logger.W(TAG, "Empty PUSH message received");
|
961
997
|
return;
|
@@ -1026,4 +1062,150 @@ public class RhodesService {
|
|
1026
1062
|
}
|
1027
1063
|
}
|
1028
1064
|
|
1065
|
+
private void restartGeoLocationIfNeeded() {
|
1066
|
+
if (mNeedGeoLocationRestart) {
|
1067
|
+
GeoLocation.isKnownPosition();
|
1068
|
+
mNeedGeoLocationRestart = false;
|
1069
|
+
}
|
1070
|
+
}
|
1071
|
+
|
1072
|
+
private void stopGeoLocation() {
|
1073
|
+
mNeedGeoLocationRestart = GeoLocation.isAvailable();
|
1074
|
+
GeoLocation.stop();
|
1075
|
+
}
|
1076
|
+
|
1077
|
+
private void restoreWakeLockIfNeeded() {
|
1078
|
+
PerformOnUiThread.exec( new Runnable() {
|
1079
|
+
public void run() {
|
1080
|
+
if (wakeLockEnabled) {
|
1081
|
+
if (wakeLockObject == null) {
|
1082
|
+
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
|
1083
|
+
if (pm != null) {
|
1084
|
+
Logger.I(TAG, "activityStarted() restore wakeLock object");
|
1085
|
+
wakeLockObject = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, TAG);
|
1086
|
+
wakeLockObject.acquire();
|
1087
|
+
}
|
1088
|
+
else {
|
1089
|
+
Logger.E(TAG, "activityStarted() - Can not get PowerManager !!!");
|
1090
|
+
}
|
1091
|
+
}
|
1092
|
+
}
|
1093
|
+
}
|
1094
|
+
}, false);
|
1095
|
+
}
|
1096
|
+
|
1097
|
+
private void stopWakeLock() {
|
1098
|
+
PerformOnUiThread.exec( new Runnable() {
|
1099
|
+
public void run() {
|
1100
|
+
if (wakeLockObject != null) {
|
1101
|
+
Logger.I(TAG, "activityStopped() temporary destroy wakeLock object");
|
1102
|
+
wakeLockObject.release();
|
1103
|
+
wakeLockObject = null;
|
1104
|
+
}
|
1105
|
+
}
|
1106
|
+
}, false);
|
1107
|
+
}
|
1108
|
+
|
1109
|
+
public static int rho_sys_set_sleeping(int enable) {
|
1110
|
+
Logger.I(TAG, "rho_sys_set_sleeping("+enable+")");
|
1111
|
+
int wasEnabled = 1;
|
1112
|
+
if (wakeLockObject != null) {
|
1113
|
+
wasEnabled = 0;
|
1114
|
+
}
|
1115
|
+
if (enable != 0) {
|
1116
|
+
// disable lock device
|
1117
|
+
PerformOnUiThread.exec( new Runnable() {
|
1118
|
+
public void run() {
|
1119
|
+
if (wakeLockObject != null) {
|
1120
|
+
wakeLockObject.release();
|
1121
|
+
wakeLockObject = null;
|
1122
|
+
wakeLockEnabled = false;
|
1123
|
+
}
|
1124
|
+
}
|
1125
|
+
}, false);
|
1126
|
+
}
|
1127
|
+
else {
|
1128
|
+
// lock device from sleep
|
1129
|
+
PerformOnUiThread.exec( new Runnable() {
|
1130
|
+
public void run() {
|
1131
|
+
if (wakeLockObject == null) {
|
1132
|
+
PowerManager pm = (PowerManager)getInstance().getContext().getSystemService(Context.POWER_SERVICE);
|
1133
|
+
if (pm != null) {
|
1134
|
+
wakeLockObject = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, TAG);
|
1135
|
+
wakeLockObject.acquire();
|
1136
|
+
wakeLockEnabled = true;
|
1137
|
+
}
|
1138
|
+
else {
|
1139
|
+
Logger.E(TAG, "rho_sys_set_sleeping() - Can not get PowerManager !!!");
|
1140
|
+
}
|
1141
|
+
}
|
1142
|
+
}
|
1143
|
+
}, false);
|
1144
|
+
}
|
1145
|
+
return wasEnabled;
|
1146
|
+
}
|
1147
|
+
|
1148
|
+
|
1149
|
+
|
1150
|
+
private void handleAppActivation() {
|
1151
|
+
if (DEBUG)
|
1152
|
+
Log.d(TAG, "handle app activation");
|
1153
|
+
restartGeoLocationIfNeeded();
|
1154
|
+
restoreWakeLockIfNeeded();
|
1155
|
+
callActivationCallback(true);
|
1156
|
+
}
|
1157
|
+
|
1158
|
+
private void handleAppDeactivation() {
|
1159
|
+
if (DEBUG)
|
1160
|
+
Log.d(TAG, "handle app deactivation");
|
1161
|
+
stopWakeLock();
|
1162
|
+
stopGeoLocation();
|
1163
|
+
callActivationCallback(false);
|
1164
|
+
}
|
1165
|
+
|
1166
|
+
public static void activityStarted() {
|
1167
|
+
if (DEBUG)
|
1168
|
+
Log.d(TAG, "activityStarted (1): sActivitiesActive=" + sActivitiesActive);
|
1169
|
+
if (sActivitiesActive == 0) {
|
1170
|
+
RhodesService r = RhodesService.getInstance();
|
1171
|
+
if (DEBUG)
|
1172
|
+
Log.d(TAG, "first activity started; r=" + r);
|
1173
|
+
if (r != null)
|
1174
|
+
r.handleAppActivation();
|
1175
|
+
}
|
1176
|
+
++sActivitiesActive;
|
1177
|
+
if (DEBUG)
|
1178
|
+
Log.d(TAG, "activityStarted (2): sActivitiesActive=" + sActivitiesActive);
|
1179
|
+
}
|
1180
|
+
|
1181
|
+
public static void activityStopped() {
|
1182
|
+
if (DEBUG)
|
1183
|
+
Log.d(TAG, "activityStopped (1): sActivitiesActive=" + sActivitiesActive);
|
1184
|
+
--sActivitiesActive;
|
1185
|
+
if (sActivitiesActive == 0) {
|
1186
|
+
RhodesService r = RhodesService.getInstance();
|
1187
|
+
if (DEBUG)
|
1188
|
+
Log.d(TAG, "last activity stopped; r=" + r);
|
1189
|
+
if (r != null)
|
1190
|
+
r.handleAppDeactivation();
|
1191
|
+
}
|
1192
|
+
if (DEBUG)
|
1193
|
+
Log.d(TAG, "activityStopped (2): sActivitiesActive=" + sActivitiesActive);
|
1194
|
+
}
|
1195
|
+
|
1196
|
+
@Override
|
1197
|
+
public void startActivity(Intent intent) {
|
1198
|
+
RhodesActivity ra = RhodesActivity.getInstance();
|
1199
|
+
if (ra == null)
|
1200
|
+
throw new IllegalStateException("Trying to start activity, but main activity is empty (we are in background, no UI active)");
|
1201
|
+
ra.startActivity(intent);
|
1202
|
+
}
|
1203
|
+
|
1204
|
+
public static Context getContext() {
|
1205
|
+
RhodesService r = RhodesService.getInstance();
|
1206
|
+
if (r == null)
|
1207
|
+
throw new IllegalStateException("No rhodes service instance at this moment");
|
1208
|
+
return r;
|
1209
|
+
}
|
1210
|
+
|
1029
1211
|
}
|