rhodes 2.2.3 → 2.2.4.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. data/CHANGELOG +13 -0
  2. data/Rakefile +1 -1
  3. data/bin/c2dm.rb +59 -0
  4. data/lib/extensions/barcode/ext/barcode/platform/iphone/Rakefile +4 -0
  5. data/lib/framework/rho/rho.rb +2 -0
  6. data/lib/framework/rho/rhoapplication.rb +1 -0
  7. data/lib/framework/rhodes.rb +1 -1
  8. data/lib/framework/version.rb +1 -1
  9. data/lib/rhodes.rb +1 -1
  10. data/platform/android/Rhodes/AndroidManifest.xml +1 -1
  11. data/platform/android/Rhodes/jni/src/callbacks.cpp +21 -0
  12. data/platform/android/Rhodes/jni/src/nativebar.cpp +4 -0
  13. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoActivity.java +3 -1
  14. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +68 -7
  15. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +113 -10
  16. data/platform/android/Rhodes/src/com/rhomobile/rhodes/SplashScreen.java +34 -3
  17. data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothManager.java +21 -17
  18. data/platform/android/Rhodes/src/com/rhomobile/rhodes/datetime/DateTimePickerScreen.java +29 -5
  19. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +7 -0
  20. data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/ExternalHttpHandler.java +37 -0
  21. data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java +0 -1
  22. data/platform/android/build/RhodesSRC_build.files +24 -23
  23. data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBStorage.java +6 -0
  24. data/platform/bb/RubyVM/src/com/rho/RhoLogger.java +42 -20
  25. data/platform/bb/RubyVM/src/com/rho/db/DBAdapter.java +111 -19
  26. data/platform/bb/RubyVM/src/com/rho/db/IDBStorage.java +2 -0
  27. data/platform/bb/RubyVM/src/com/rho/net/NetRequest.java +2 -1
  28. data/platform/bb/RubyVM/src/com/rho/net/URI.java +80 -0
  29. data/platform/bb/RubyVM/src/com/rho/sync/SyncEngine.java +21 -1
  30. data/platform/bb/RubyVM/src/com/rho/sync/SyncNotify.java +6 -1
  31. data/platform/bb/RubyVM/src/com/rho/sync/SyncSource.java +139 -46
  32. data/platform/bb/build/bb.rake +8 -3
  33. data/platform/bb/rhodes/platform/5.0/com/rho/RhodesApplicationPlatform.java +32 -21
  34. data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +31 -14
  35. data/platform/bb/rhodes/src/com/rho/file/Jsr75File.java +3 -2
  36. data/platform/bb/rhodes/src/com/rho/rubyext/Alert.java +3 -2
  37. data/platform/bb/rhodes/src/com/rho/rubyext/System.java +28 -0
  38. data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +111 -26
  39. data/platform/iphone/Classes/AppManager/AppManager.m +22 -0
  40. data/platform/iphone/Classes/DateTimePickerDelegate.m +3 -0
  41. data/platform/iphone/Classes/MapView/MapViewController.h +8 -3
  42. data/platform/iphone/Classes/MapView/MapViewController.m +63 -12
  43. data/platform/iphone/Classes/NativeBar.h +4 -3
  44. data/platform/iphone/Classes/NativeBar.m +28 -1
  45. data/platform/iphone/Classes/Rhodes.m +87 -20
  46. data/platform/iphone/Classes/Signature/SignatureView.m +16 -10
  47. data/platform/iphone/Classes/Signature/SignatureViewController.m +2 -0
  48. data/platform/iphone/Classes/SimpleMainView.h +2 -0
  49. data/platform/iphone/Classes/SimpleMainView.m +120 -35
  50. data/platform/iphone/Classes/SplashViewController.h +8 -1
  51. data/platform/iphone/Classes/SplashViewController.m +233 -11
  52. data/platform/iphone/Classes/SplitView/LeftViewController.h +30 -0
  53. data/platform/iphone/Classes/SplitView/LeftViewController.m +189 -0
  54. data/platform/iphone/Classes/SplitView/RightViewController.h +54 -0
  55. data/platform/iphone/Classes/SplitView/RightViewController.m +268 -0
  56. data/platform/iphone/Classes/SplitView/SplitViewDelegate.h +22 -0
  57. data/platform/iphone/Classes/SplitView/SplitViewDelegate.m +92 -0
  58. data/platform/iphone/Classes/SplitView/SplittedMainView.h +65 -0
  59. data/platform/iphone/Classes/SplitView/SplittedMainView.m +304 -0
  60. data/platform/iphone/Classes/TabbedMainView.m +23 -6
  61. data/platform/iphone/Classes/WebView.m +1 -1
  62. data/platform/iphone/Info.plist +11 -2
  63. data/platform/iphone/rbuild/iphone.rake +80 -3
  64. data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +50 -3
  65. data/platform/shared/common/RhoConf.cpp +5 -5
  66. data/platform/shared/db/DBAdapter.cpp +81 -3
  67. data/platform/shared/db/DBAdapter.h +1 -0
  68. data/platform/shared/json/JSONIterator.cpp +5 -0
  69. data/platform/shared/json/JSONIterator.h +1 -0
  70. data/platform/shared/net/CURLNetRequest.cpp +2 -2
  71. data/platform/shared/net/URI.cpp +53 -0
  72. data/platform/shared/net/URI.h +5 -1
  73. data/platform/shared/ruby/ext/system/system.i +9 -1
  74. data/platform/shared/ruby/ext/system/system_wrap.c +2632 -2574
  75. data/platform/shared/ruby/win32/win32.c +2 -0
  76. data/platform/shared/ruby/wince/direct.c +4 -0
  77. data/platform/shared/sync/SyncEngine.cpp +20 -1
  78. data/platform/shared/sync/SyncEngine.h +6 -1
  79. data/platform/shared/sync/SyncNotify.cpp +6 -1
  80. data/platform/shared/sync/SyncSource.cpp +130 -74
  81. data/platform/shared/sync/SyncSource.h +3 -1
  82. data/platform/wm/rhodes.sln +30 -22
  83. data/platform/wm/rhodes/Alert.cpp +4 -3
  84. data/platform/wm/rhodes/MainWindow.cpp +73 -20
  85. data/platform/wm/rhodes/RingtoneManager.cpp +4 -4
  86. data/platform/wm/rhodes/RingtoneManager.h +2 -1
  87. data/platform/wm/rhodes/Vibrate.cpp +1 -2
  88. data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +37 -0
  89. data/platform/wm/rhodes/rhodes.vcproj +219 -5
  90. data/platform/wm/rhodes/stdafx.h +1 -0
  91. data/platform/wm/rubylib/rubylib.vcproj +10 -8
  92. data/platform/wm/sqlite3/sqlite3.vcproj +6 -4
  93. data/platform/wm/syncengine/syncengine.vcproj +7 -5
  94. data/platform/wm/tcmalloc/tcmalloc.vcproj +11 -8
  95. data/rakefile.rb +1 -1
  96. data/res/generators/templates/application/public/jqtouch/jqtouch.js +9 -1
  97. data/rhodes.gemspec +1 -1
  98. data/spec/phone_spec/app/spec/bulksync_spec.rb +71 -1
  99. metadata +17 -5
@@ -116,8 +116,11 @@
116
116
 
117
117
  - (UIImage*)makeUIImage {
118
118
 
119
- CGRect bound_box = CGPathGetBoundingBox(mPath);
120
- CGRect rect = self.frame;
119
+ CGRect bound_box = self.bounds;
120
+ if (!CGPathIsEmpty(mPath)) {
121
+ bound_box = CGPathGetBoundingBox(mPath);
122
+ }
123
+ CGRect rect = self.bounds;
121
124
  if (rect.size.width < (bound_box.origin.x+bound_box.size.width)) {
122
125
  rect.size.width = (bound_box.origin.x+bound_box.size.width)+2;
123
126
  }
@@ -134,18 +137,21 @@
134
137
  CGContextFillRect(context, rect);
135
138
 
136
139
  // draw signature
137
- CGContextSetLineWidth(context, 3);
138
- CGContextTranslateCTM (context, 0, rect.size.height);
139
- CGContextScaleCTM(context, 1, -1);
140
- CGContextBeginPath(context);
141
- CGContextAddPath(context,mPath);
142
- CGContextDrawPath(context, kCGPathStroke);
140
+ if (!CGPathIsEmpty(mPath)) {
141
+ CGContextSetLineWidth(context, 3);
142
+ CGContextTranslateCTM (context, 0, rect.size.height);
143
+ CGContextScaleCTM(context, 1, -1);
144
+ CGContextBeginPath(context);
145
+ CGContextAddPath(context,mPath);
146
+ CGContextDrawPath(context, kCGPathStroke);
147
+ }
143
148
 
144
149
  CGImageRef cg_image = CGBitmapContextCreateImage(context);
145
150
  UIImage* ui_image = [[UIImage alloc] initWithCGImage:cg_image];// scale:1 orientation:UIImageOrientationDownMirrored];
146
- [cg_image release];
151
+
152
+ CGImageRelease(cg_image);
147
153
 
148
- [context release];
154
+ CGContextRelease(context);
149
155
 
150
156
  return ui_image;
151
157
  }
@@ -70,7 +70,9 @@
70
70
  srect.origin.y = 0;
71
71
  trect.origin.x = 0;
72
72
  trect.origin.y = srect.origin.y+srect.size.height;
73
+ trect.size.width = srect.size.width;
73
74
  toolbar.frame = trect;
75
+ toolbar.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth;
74
76
 
75
77
  signatureView = [[SignatureView alloc] initWithFrame:CGRectZero];
76
78
  signatureView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
@@ -37,4 +37,6 @@
37
37
 
38
38
  - (UIWebView*)getWebView:(int)tab_index;
39
39
 
40
+ + (void) disableHiddenOnStart;
41
+
40
42
  @end
@@ -63,6 +63,13 @@ int rho_sys_get_screen_height();
63
63
  @synthesize webView, toolbar, navbar, nativeViewType, nativeViewView;
64
64
 
65
65
 
66
+ static BOOL makeHiddenUntilLoadContent = YES;
67
+
68
+
69
+ + (void) disableHiddenOnStart {
70
+ makeHiddenUntilLoadContent = NO;
71
+ }
72
+
66
73
  -(CGRect)getContentRect {
67
74
  if (nativeViewView != nil) {
68
75
  return nativeViewView.frame;
@@ -78,8 +85,36 @@ int rho_sys_get_screen_height();
78
85
  webView.frame = rect;
79
86
  }
80
87
 
88
+ - (UIBarButtonItem*)makeUIBarButtonWithCustomImage:(UIImage*)image name:(NSString*)name target:(id)target action:(SEL)action colored_icon:(BOOL)colored_icon {
89
+ UIBarButtonItem *btn = nil;
90
+ //load the image
91
+ if (image == nil) {
92
+ image = [UIImage imageNamed:name];
93
+ }
94
+
95
+ if (!colored_icon) {
96
+ btn = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:target action:action];
97
+ return btn;
98
+ }
99
+
100
+ //create the button and assign the image
101
+ UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
102
+ [button setImage:image forState:UIControlStateNormal];
103
+ [button addTarget:target action:action forControlEvents:UIControlEventTouchDown];
104
+
105
+ //set the frame of the button to the size of the image (see note below)
106
+ button.frame = CGRectMake(0, 0, image.size.width, image.size.height);
107
+
108
+ //create a UIBarButtonItem with the button as a custom view
109
+ btn = [[UIBarButtonItem alloc] initWithCustomView:button];
110
+
111
+ btn.target = target;
112
+ btn.action = action;
113
+
114
+ return btn;
115
+ }
81
116
 
82
- - (UIBarButtonItem*)newButton:(NSString*)url label:(NSString*)label icon:(NSString*)icon {
117
+ - (UIBarButtonItem*)newButton:(NSString*)url label:(NSString*)label icon:(NSString*)icon colored_icon:(BOOL)colored_icon{
83
118
  UIImage *img = nil;
84
119
  if ([icon length] > 0) {
85
120
  NSString *imagePath = [[AppManager getApplicationsRootPath] stringByAppendingPathComponent:icon];
@@ -88,38 +123,24 @@ int rho_sys_get_screen_height();
88
123
 
89
124
  UIBarButtonItem *btn = nil;
90
125
 
126
+
91
127
  if ([url compare:@"back"] == NSOrderedSame) {
92
- btn = [[UIBarButtonItem alloc]
93
- initWithImage:(img ? img : [UIImage imageNamed:@"back_btn.png"])
94
- style:UIBarButtonItemStylePlain target:self
95
- action:@selector(goBack:)];
128
+ btn = [self makeUIBarButtonWithCustomImage:img name:@"back_btn.png" target:self action:@selector(goBack:) colored_icon:colored_icon];
96
129
  }
97
130
  else if ([url compare:@"forward"] == NSOrderedSame)
98
131
  {
99
132
  if ( !rho_conf_getBool("jqtouch_mode") )
100
- btn = [[UIBarButtonItem alloc]
101
- initWithImage:(img ? img : [UIImage imageNamed:@"forward_btn.png"])
102
- style:UIBarButtonItemStylePlain target:self
103
- action:@selector(goForward:)];
133
+ btn = [self makeUIBarButtonWithCustomImage:img name:@"forward_btn.png" target:self action:@selector(goForward:) colored_icon:colored_icon];
104
134
  }
105
135
  else if ([url compare:@"home"] == NSOrderedSame) {
106
- btn = [[UIBarButtonItem alloc]
107
- initWithImage:(img ? img : [UIImage imageNamed:@"home_btn.png"])
108
- style:UIBarButtonItemStylePlain target:self
109
- action:@selector(goHome:)];
136
+ btn = [self makeUIBarButtonWithCustomImage:img name:@"home_btn.png" target:self action:@selector(goHome:) colored_icon:colored_icon];
110
137
  }
111
138
  else if ([url compare:@"options"] == NSOrderedSame) {
112
- btn = [[UIBarButtonItem alloc]
113
- initWithImage:(img ? img : [UIImage imageNamed:@"gears.png"])
114
- style:UIBarButtonItemStylePlain target:self
115
- action:@selector(goOptions:)];
139
+ btn = [self makeUIBarButtonWithCustomImage:img name:@"gears.png" target:self action:@selector(goOptions:) colored_icon:colored_icon];
116
140
  }
117
141
  else if ([url compare:@"refresh"] == NSOrderedSame) {
118
142
  if (img)
119
- btn = [[UIBarButtonItem alloc]
120
- initWithImage:img
121
- style:UIBarButtonItemStylePlain target:self
122
- action:@selector(onRefresh:)];
143
+ btn = [self makeUIBarButtonWithCustomImage:img name:nil target:self action:@selector(onRefresh:) colored_icon:colored_icon];
123
144
  else
124
145
  btn = [[UIBarButtonItem alloc]
125
146
  initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
@@ -133,9 +154,7 @@ int rho_sys_get_screen_height();
133
154
  else {
134
155
  id action = [[RhoToolbarButtonItemAction alloc] init:url];
135
156
  if (img) {
136
- btn = [[UIBarButtonItem alloc]
137
- initWithImage:img style:UIBarButtonItemStylePlain
138
- target:action action:@selector(onAction:)];
157
+ btn = [self makeUIBarButtonWithCustomImage:img name:nil target:action action:@selector(onAction:) colored_icon:colored_icon];
139
158
  }
140
159
  else if ([label length] > 0) {
141
160
  btn = [[UIBarButtonItem alloc]
@@ -148,7 +167,7 @@ int rho_sys_get_screen_height();
148
167
  }
149
168
 
150
169
  - (UIToolbar*)newToolbar:(NSArray*)items frame:(CGRect)mainFrame {
151
- if ([items count] % 4 != 0) {
170
+ if ([items count] % 5 != 0) {
152
171
  RAWLOG_ERROR("Illegal arguments for createNewToolbar");
153
172
  return nil;
154
173
  }
@@ -170,13 +189,16 @@ int rho_sys_get_screen_height();
170
189
  target:nil action:nil];
171
190
 
172
191
  NSMutableArray *btns = [NSMutableArray arrayWithCapacity:[items count]/4];
173
- for(int i = 0, lim = [items count]/4; i < lim; i++) {
174
- int index = i*4 - 1;
192
+ for(int i = 0, lim = [items count]/5; i < lim; i++) {
193
+ int index = i*5 - 1;
175
194
  NSString *label = (NSString*)[items objectAtIndex:++index];
176
195
  NSString *url = (NSString*)[items objectAtIndex:++index];
177
196
  NSString *icon = (NSString*)[items objectAtIndex:++index];
178
- //NSString *reload = (NSString*)[items objectAtIndex:++index];
197
+ NSString *reload = (NSString*)[items objectAtIndex:++index];
198
+ NSString *colored_icon = (NSString*)[items objectAtIndex:++index];
179
199
 
200
+ reload = nil;
201
+
180
202
  if ([url length] == 0) {
181
203
  RAWLOG_ERROR("Illegal arguments for createNewToolbar");
182
204
  [tb release];
@@ -184,7 +206,7 @@ int rho_sys_get_screen_height();
184
206
  return nil;
185
207
  }
186
208
 
187
- UIBarButtonItem *btn = [self newButton:url label:label icon:icon];
209
+ UIBarButtonItem *btn = [self newButton:url label:label icon:icon colored_icon:[colored_icon isEqualToString:@"true"]];
188
210
 
189
211
  if (btn) {
190
212
  [btns addObject:fixed];
@@ -248,13 +270,14 @@ int rho_sys_get_screen_height();
248
270
  w.scalesPageToFit = YES;
249
271
  w.userInteractionEnabled = YES;
250
272
  w.multipleTouchEnabled = YES;
251
- w.autoresizesSubviews = YES;
252
273
  w.clipsToBounds = NO;
253
274
  w.dataDetectorTypes = UIDataDetectorTypeNone;
254
275
  w.delegate = self;
276
+ w.autoresizesSubviews = YES;
277
+ //w.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
255
278
  w.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
256
279
  w.tag = RHO_TAG_WEBVIEW;
257
-
280
+
258
281
  assert([w retainCount] == 1);
259
282
  return w;
260
283
  }
@@ -272,7 +295,7 @@ int rho_sys_get_screen_height();
272
295
  self.webView = nil;
273
296
  webView = w;
274
297
  assert(!webView || [webView retainCount] == 1);
275
- if (!webView)
298
+ if (!webView)
276
299
  webView = [self newWebView:frame];
277
300
  assert(webView && [webView retainCount] == 1);
278
301
 
@@ -280,6 +303,9 @@ int rho_sys_get_screen_height();
280
303
  wFrame.origin.y = 0;
281
304
  webView.frame = wFrame;
282
305
 
306
+ webView.autoresizesSubviews = YES;
307
+ webView.autoresizingMask = /*UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin |*/ UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
308
+
283
309
  [root addSubview:webView];
284
310
  assert([webView retainCount] == 2);
285
311
 
@@ -300,7 +326,15 @@ int rho_sys_get_screen_height();
300
326
  - (void)loadView {
301
327
  UIView* root = [[UIView alloc] init];
302
328
  root.frame = rootFrame;
329
+ if (makeHiddenUntilLoadContent) {
330
+ root.hidden = YES;
331
+ }
332
+ root.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
333
+ root.autoresizesSubviews = YES;
334
+
335
+
303
336
  self.view = root;
337
+
304
338
  [root release];
305
339
  assert([root retainCount] == 1);
306
340
  }
@@ -408,6 +442,7 @@ int rho_sys_get_screen_height();
408
442
 
409
443
  - (id)initWithMainView:(id<RhoMainView>)v parent:(UIWindow*)p toolbar:(NSArray*)items {
410
444
  CGRect frame = [[v view] frame];
445
+ frame.origin.x = 0;
411
446
  //UIWebView *w = (UIWebView*)[Rhodes subviewWithTag:RHO_TAG_WEBVIEW ofView:[v view]];
412
447
  UIWebView *w = [v detachWebView];
413
448
  id result = [self init:p webView:w frame:frame toolbar:items];
@@ -605,6 +640,7 @@ int rho_sys_get_screen_height();
605
640
  }
606
641
 
607
642
  - (void)navigate:(NSString *)url tab:(int)index {
643
+ [SimpleMainView disableHiddenOnStart];
608
644
  NSString *encodedUrl = [self encodeUrl:url];
609
645
  NSString* cleared_url = [self processForNativeView:encodedUrl];
610
646
  if (cleared_url == nil) {
@@ -619,6 +655,7 @@ int rho_sys_get_screen_height();
619
655
  }
620
656
 
621
657
  - (void)navigateRedirect:(NSString *)url tab:(int)index {
658
+ [SimpleMainView disableHiddenOnStart];
622
659
  NSString *encodedUrl = [self encodeUrl:url];
623
660
  NSString* cleared_url = [self processForNativeView:encodedUrl];
624
661
  if (cleared_url == nil) {
@@ -644,6 +681,12 @@ int rho_sys_get_screen_height();
644
681
  }
645
682
 
646
683
  - (void)executeJs:(NSString*)js tab:(int)index {
684
+ [SimpleMainView disableHiddenOnStart];
685
+ if (self.view.hidden) {
686
+ [[Rhodes sharedInstance] hideSplash];
687
+ self.view.hidden = NO;
688
+ [self.view.superview bringSubviewToFront:self.view];
689
+ }
647
690
  RAWLOG_INFO1("Executing JS: %s", [js UTF8String]);
648
691
  [webView stringByEvaluatingJavaScriptFromString:js];
649
692
  }
@@ -688,6 +731,8 @@ int rho_sys_get_screen_height();
688
731
  - (void)addNavBar:(NSString*)title left:(NSArray*)left right:(NSArray*)right {
689
732
  UINavigationBar *nb = [[UINavigationBar alloc] initWithFrame:CGRectZero];
690
733
  nb.tag = RHO_TAG_NAVBAR;
734
+ nb.autoresizesSubviews = YES;
735
+ nb.autoresizingMask = UIViewAutoresizingFlexibleWidth;
691
736
  [nb sizeToFit];
692
737
 
693
738
  UINavigationItem *ni = [[UINavigationItem alloc] initWithTitle:title];
@@ -700,7 +745,7 @@ int rho_sys_get_screen_height();
700
745
  NSString *action = [btn objectAtIndex:0];
701
746
  NSString *label = [btn objectAtIndex:1];
702
747
  NSString *icon = [btn objectAtIndex:2];
703
- UIBarButtonItem *button = [self newButton:action label:label icon:icon];
748
+ UIBarButtonItem *button = [self newButton:action label:label icon:icon colored_icon:NO];
704
749
 
705
750
  if (btn == left)
706
751
  [ni setLeftBarButtonItem:button];
@@ -734,8 +779,36 @@ int rho_sys_get_screen_height();
734
779
  NSURL *url = [request URL];
735
780
  if (!url)
736
781
  return NO;
737
- if (![url.scheme isEqualToString:@"http"] && ![url.scheme isEqualToString:@"https"]) {
782
+
783
+ BOOL external = NO;
784
+
785
+ NSString *scheme = url.scheme;
786
+ if (![scheme isEqualToString:@"http"] && ![scheme isEqualToString:@"https"])
787
+ external = YES;
788
+ else {
789
+ NSString *ps = [url query];
790
+ NSArray *parameters = [ps componentsSeparatedByString:@"&"];
791
+ for (int i = 0, lim = [parameters count]; i < lim; ++i) {
792
+ NSString *param = [parameters objectAtIndex:i];
793
+ NSArray *nv = [param componentsSeparatedByString:@"="];
794
+ int size = [nv count];
795
+ if (size == 0 || size > 2)
796
+ continue;
797
+ NSString *name = [nv objectAtIndex:0];
798
+ NSString *value = nil;
799
+ if (size == 2)
800
+ value = [nv objectAtIndex:1];
801
+
802
+ if ([name isEqualToString:@"rho_open_target"] && [value isEqualToString:@"_blank"]) {
803
+ external = YES;
804
+ break;
805
+ }
806
+ }
807
+ }
808
+
809
+ if (external) {
738
810
  // This is not http url so try to open external application for it
811
+ RAWLOG_INFO1("Open url in external application: %s", [[url absoluteString] UTF8String]);
739
812
  [[UIApplication sharedApplication] openURL:url];
740
813
  return NO;
741
814
  }
@@ -763,7 +836,14 @@ int rho_sys_get_screen_height();
763
836
  NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
764
837
  [NSURLCache setSharedURLCache:sharedCache];
765
838
  [sharedCache release];
766
-
839
+
840
+ if (self.view.hidden) {
841
+ [[Rhodes sharedInstance] hideSplash];
842
+ self.view.hidden = NO;
843
+ [self.view.superview bringSubviewToFront:self.view];
844
+ }
845
+
846
+
767
847
  // TODO
768
848
  /*
769
849
  [self inactive];
@@ -789,6 +869,11 @@ int rho_sys_get_screen_height();
789
869
 
790
870
  - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
791
871
  // TODO
872
+ if (self.view.hidden) {
873
+ [[Rhodes sharedInstance] hideSplash];
874
+ self.view.hidden = NO;
875
+ [self.view.superview bringSubviewToFront:self.view];
876
+ }
792
877
  }
793
878
 
794
879
  @end
@@ -9,6 +9,12 @@
9
9
  #import <UIKit/UIKit.h>
10
10
  #import "RhoViewController.h"
11
11
 
12
+
13
+ @interface RhoSplashImageView : UIImageView {
14
+
15
+ }
16
+ @end
17
+
12
18
  @interface SplashViewController : RhoViewController {
13
19
  IBOutlet UIImageView *splashView;
14
20
 
@@ -17,8 +23,9 @@
17
23
  }
18
24
 
19
25
  - (id)initWithParentView:(UIView*)v;
20
- - (void)showSplash:(NSString *)imagePath;
21
26
  - (void)hideSplash;
22
27
  - (void)bringToFront;
28
+ + (NSString*)detectLoadingImage:(CGRect)myframe rotation_to_left:(BOOL*)rotation_to_left;
29
+ + (BOOL)hasLoadingImage;
23
30
 
24
31
  @end
@@ -10,27 +10,100 @@
10
10
 
11
11
  #import "rho/common/SplashScreenImpl.h"
12
12
 
13
+
14
+ @implementation RhoSplashImageView
15
+
16
+ - (void)layoutSubviews
17
+ {
18
+ [super layoutSubviews];
19
+
20
+ CGRect frame = self.frame;
21
+ CGRect rect = self.bounds;
22
+
23
+ float scales = 1;
24
+ #ifdef __IPHONE_4_0
25
+ if ( [[UIScreen mainScreen] respondsToSelector:@selector(scale)] ) {
26
+ scales = [[UIScreen mainScreen] scale];
27
+ }
28
+ #endif
29
+
30
+
31
+ BOOL is_need_left = NO;
32
+
33
+ NSString* imagePath = [SplashViewController detectLoadingImage:rect rotation_to_left:&is_need_left];
34
+
35
+ NSFileManager *fileManager = [NSFileManager defaultManager];
36
+ if (![fileManager fileExistsAtPath:imagePath])
37
+ return;
38
+
39
+ UIImage *img = [[UIImage alloc] initWithContentsOfFile:imagePath];
40
+
41
+ self.image = img;
42
+
43
+ {
44
+
45
+ float img_scale = 1;
46
+ #ifdef __IPHONE_4_0
47
+ if ( [img respondsToSelector:@selector(scale)] ) {
48
+ img_scale = [img scale];
49
+ }
50
+ #endif
51
+
52
+ int image_width = (int)([img size].width*img_scale);
53
+ int image_height = (int)([img size].height*img_scale);
54
+
55
+ CGRect appFrame = [[UIScreen mainScreen] applicationFrame];
56
+ CGRect srcrnBounds = [[UIScreen mainScreen] bounds];
57
+ CGRect sbFrame = [[UIApplication sharedApplication] statusBarFrame];
58
+
59
+ UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
60
+
61
+ int scrnWidth = 0;
62
+ int scrnHeight = 0;
63
+
64
+ if ((orientation == UIInterfaceOrientationPortrait) || (orientation == UIInterfaceOrientationPortraitUpsideDown)) {
65
+ scrnWidth = (int)(srcrnBounds.size.width*scales+0.5);
66
+ scrnHeight = (int)(srcrnBounds.size.height*scales+0.5);
67
+ }
68
+ else {
69
+ scrnWidth = (int)(srcrnBounds.size.height*scales+0.5);
70
+ scrnHeight = (int)(srcrnBounds.size.width*scales+0.5);
71
+ }
72
+
73
+
74
+ if ((image_width != scrnWidth) || (image_height != scrnHeight)) {
75
+ // scale to app frame
76
+ self.frame = appFrame;
77
+ }
78
+ else {
79
+ self.frame = srcrnBounds;
80
+ }
81
+ }
82
+ }
83
+
84
+
85
+
86
+ @end
87
+
88
+
89
+
90
+
13
91
  @implementation SplashViewController
14
92
 
15
93
  // Implement loadView to create a view hierarchy programmatically, without using a nib.
16
94
  - (id)initWithParentView:(UIView*)v {
95
+ self = [super init];
17
96
  parentView = v;
18
97
  CGRect frame = [[UIScreen mainScreen] bounds];
19
- splashView = [[UIImageView alloc] initWithFrame:frame];
98
+ splashView = [[RhoSplashImageView alloc] initWithFrame:frame];
99
+
100
+ splashView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
101
+ splashView.autoresizesSubviews = YES;
102
+ self.view = splashView;
20
103
  [parentView addSubview:splashView];
21
104
  return self;
22
105
  }
23
106
 
24
- - (void)showSplash:(NSString *)imagePath {
25
- NSFileManager *fileManager = [NSFileManager defaultManager];
26
- if (![fileManager fileExistsAtPath:imagePath])
27
- return;
28
-
29
- UIImage *img = [[UIImage alloc] initWithContentsOfFile:imagePath];
30
- splashView.image = img;
31
- [parentView bringSubviewToFront:splashView];
32
- rho_splash_screen_start();
33
- }
34
107
 
35
108
  - (void)hideSplash {
36
109
  rho_splash_screen_hide();
@@ -58,5 +131,154 @@
58
131
  [super dealloc];
59
132
  }
60
133
 
134
+ + (NSString*)detectLoadingImage:(CGRect)myframe rotation_to_left:(BOOL*)rotation_to_left {
135
+ NSFileManager *fileManager = [NSFileManager defaultManager];
136
+
137
+
138
+ NSString * result = nil;
139
+
140
+ NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
141
+
142
+ NSString *pngLoadingPath = [NSString stringWithFormat:@"%@/apps/app/loading.png", resourcePath];
143
+ NSString *pngDefaultPath = [NSString stringWithFormat:@"%@/Default.png", resourcePath];
144
+ NSString *pngDefault2xPath = [NSString stringWithFormat:@"%@/Default@2x.png", resourcePath];
145
+ NSString *pngDefaultPortraitPath = [NSString stringWithFormat:@"%@/Default-Portrait.png", resourcePath];
146
+ NSString *pngDefaultPortraitUpsideDownPath = [NSString stringWithFormat:@"%@/Default-PortraitUpsideDown.png", resourcePath];
147
+ NSString *pngDefaultLandscapePath = [NSString stringWithFormat:@"%@/Default-Landscape.png", resourcePath];
148
+ NSString *pngDefaultLandscapeLeftPath = [NSString stringWithFormat:@"%@/Default-LandscapeLeft.png", resourcePath];
149
+ NSString *pngDefaultLandscapeRightPath = [NSString stringWithFormat:@"%@/Default-LandscapeRight.png", resourcePath];
150
+
151
+ CGRect win_frame = [[[UIApplication sharedApplication] keyWindow] bounds];
152
+
153
+ CGRect frame = myframe;
154
+ float scales = 1;//[[UIScreen mainScreen] scale];
155
+ #ifdef __IPHONE_4_0
156
+ scales = [[UIScreen mainScreen] scale];
157
+ #endif
158
+
159
+ BOOL is_HiResolution = ((frame.size.width*scales) > 500);
160
+ BOOL is_iPad = NO;
161
+
162
+ NSString *model = [[UIDevice currentDevice] model]; // "iPad ..."
163
+ if ([model hasPrefix:@"iPad"]) {
164
+ is_iPad = YES;
165
+ }
166
+
167
+ UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
168
+
169
+ if (is_iPad) {
170
+ if ([fileManager fileExistsAtPath:pngDefaultPath]) {
171
+ result = pngDefaultPath;
172
+ }
173
+ if ([fileManager fileExistsAtPath:pngDefault2xPath]) {
174
+ result = pngDefault2xPath;
175
+ }
176
+ if ((orientation == UIInterfaceOrientationPortrait) || (orientation == UIInterfaceOrientationPortraitUpsideDown) ) {
177
+ if ([fileManager fileExistsAtPath:pngDefaultPortraitPath]) {
178
+ result = pngDefaultPortraitPath;
179
+ }
180
+ if (orientation == UIInterfaceOrientationPortraitUpsideDown) {
181
+ if ([fileManager fileExistsAtPath:pngDefaultPortraitUpsideDownPath]) {
182
+ result = pngDefaultPortraitUpsideDownPath;
183
+ }
184
+ }
185
+ }
186
+ else {
187
+ *rotation_to_left = YES;
188
+ if ([fileManager fileExistsAtPath:pngDefaultLandscapePath]) {
189
+ result = pngDefaultLandscapePath;
190
+ *rotation_to_left = NO;
191
+ }
192
+ if (orientation == UIInterfaceOrientationLandscapeLeft) {
193
+ if ([fileManager fileExistsAtPath:pngDefaultLandscapeLeftPath]) {
194
+ result = pngDefaultLandscapeLeftPath;
195
+ *rotation_to_left = NO;
196
+ }
197
+ }
198
+ else {
199
+ if ([fileManager fileExistsAtPath:pngDefaultLandscapeRightPath]) {
200
+ result = pngDefaultLandscapeRightPath;
201
+ *rotation_to_left = NO;
202
+ }
203
+ }
204
+ }
205
+ }
206
+ else {
207
+ if ([fileManager fileExistsAtPath:pngDefaultPath]) {
208
+ result = pngDefaultPath;
209
+ }
210
+ if (is_HiResolution) {
211
+ if ([fileManager fileExistsAtPath:pngDefault2xPath]) {
212
+ result = pngDefault2xPath;
213
+ }
214
+ }
215
+ }
216
+ if (result == nil) {
217
+ if ([fileManager fileExistsAtPath:pngDefaultPath]) {
218
+ result = pngDefaultPath;
219
+ }
220
+ else if ([fileManager fileExistsAtPath:pngDefault2xPath]) {
221
+ result = pngDefault2xPath;
222
+ }
223
+ else if ([fileManager fileExistsAtPath:pngDefaultPortraitPath]) {
224
+ result = pngDefaultPortraitPath;
225
+ }
226
+ else if ([fileManager fileExistsAtPath:pngDefaultLandscapePath]) {
227
+ result = pngDefaultLandscapePath;
228
+ }
229
+ else if ([fileManager fileExistsAtPath:pngDefaultPortraitUpsideDownPath]) {
230
+ result = pngDefaultPortraitUpsideDownPath;
231
+ }
232
+ else if ([fileManager fileExistsAtPath:pngDefaultLandscapeLeftPath]) {
233
+ result = pngDefaultLandscapeLeftPath;
234
+ }
235
+ else if ([fileManager fileExistsAtPath:pngDefaultLandscapeRightPath]) {
236
+ result = pngDefaultLandscapeRightPath;
237
+ }
238
+ }
239
+
240
+ return result;
241
+ }
242
+
243
+ + (BOOL)hasLoadingImage {
244
+ NSFileManager *fileManager = [NSFileManager defaultManager];
245
+ NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
246
+
247
+ //NSString *pngLoadingPath = [NSString stringWithFormat:@"%@/apps/app/loading.png", resourcePath];
248
+ NSString *pngDefaultPath = [NSString stringWithFormat:@"%@/Default.png", resourcePath];
249
+ NSString *pngDefault2xPath = [NSString stringWithFormat:@"%@/Default@2x.png", resourcePath];
250
+ NSString *pngDefaultPortraitPath = [NSString stringWithFormat:@"%@/Default-Portrait.png", resourcePath];
251
+ NSString *pngDefaultPortraitUpsideDownPath = [NSString stringWithFormat:@"%@/Default-PortraitUpsideDown.png", resourcePath];
252
+ NSString *pngDefaultLandscapePath = [NSString stringWithFormat:@"%@/Default-Landscape.png", resourcePath];
253
+ NSString *pngDefaultLandscapeLeftPath = [NSString stringWithFormat:@"%@/Default-LandscapeLeft.png", resourcePath];
254
+ NSString *pngDefaultLandscapeRightPath = [NSString stringWithFormat:@"%@/Default-LandscapeRight.png", resourcePath];
255
+
256
+ return (
257
+ //([fileManager fileExistsAtPath:pngLoadingPath]) ||
258
+ ([fileManager fileExistsAtPath:pngDefaultPath]) ||
259
+ ([fileManager fileExistsAtPath:pngDefault2xPath]) ||
260
+ ([fileManager fileExistsAtPath:pngDefaultPortraitPath]) ||
261
+ ([fileManager fileExistsAtPath:pngDefaultPortraitUpsideDownPath]) ||
262
+ ([fileManager fileExistsAtPath:pngDefaultLandscapeLeftPath]) ||
263
+ ([fileManager fileExistsAtPath:pngDefaultLandscapeRightPath]) ||
264
+ ([fileManager fileExistsAtPath:pngDefaultLandscapePath])
265
+ );
266
+
267
+
268
+ }
269
+
270
+ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
271
+ BOOL is_iPad = NO;
272
+
273
+ NSString *model = [[UIDevice currentDevice] model]; // "iPad ..."
274
+ if ([model hasPrefix:@"iPad"]) {
275
+ is_iPad = YES;
276
+ }
277
+ if (!is_iPad) {
278
+ return NO;
279
+ }
280
+ return YES;
281
+ }
282
+
61
283
 
62
284
  @end