summaryrefslogtreecommitdiff
path: root/UICaboodle
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2009-01-26 10:31:46 +0000
committerJay Freeman (saurik) <saurik@saurik.com>2010-09-30 07:09:40 +0000
commit3e9c9e85a99a501aa15c04f48262bc159d3197af (patch)
treedc5b96f3bc22c10ebbbe482ebf36a7f6bf68ebc3 /UICaboodle
parente8389e3e47bf2b9bfb5441e57c749a8673bcf6db (diff)
Polished browser and finished repotagging.
Diffstat (limited to 'UICaboodle')
-rw-r--r--UICaboodle/BrowserView.h6
-rw-r--r--UICaboodle/BrowserView.m84
2 files changed, 79 insertions, 11 deletions
diff --git a/UICaboodle/BrowserView.h b/UICaboodle/BrowserView.h
index 09680e3..cbb407f 100644
--- a/UICaboodle/BrowserView.h
+++ b/UICaboodle/BrowserView.h
@@ -57,6 +57,9 @@
WebScriptObject *function_;
bool pushed_;
+
+ float width_;
+ bool popup_;
}
- (void) alertSheet:(UIActionSheet *)sheet buttonClicked:(int)button;
@@ -71,8 +74,11 @@
- (UIWebDocumentView *) documentView;
- (id) initWithBook:(RVBook *)book;
+- (id) initWithBook:(RVBook *)book forWidth:(float)width;
- (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame;
- (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame;
++ (float) defaultWidth;
+
@end
diff --git a/UICaboodle/BrowserView.m b/UICaboodle/BrowserView.m
index fa41f2e..d2a97c8 100644
--- a/UICaboodle/BrowserView.m
+++ b/UICaboodle/BrowserView.m
@@ -73,6 +73,8 @@
+ (NSString *) webScriptNameForSelector:(SEL)selector {
if (selector == @selector(getPackageById:))
return @"getPackageById";
+ else if (selector == @selector(setAutoPopup:))
+ return @"setAutoPopup";
else if (selector == @selector(setButtonImage:withStyle:toFunction:))
return @"setButtonImage";
else if (selector == @selector(setButtonTitle:withStyle:toFunction:))
@@ -155,6 +157,10 @@
return value;
}
+- (void) setAutoPopup:(BOOL)popup {
+ [indirect_ setAutoPopup:popup];
+}
+
- (void) setButtonImage:(NSString *)button withStyle:(NSString *)style toFunction:(id)function {
[indirect_ setButtonImage:button withStyle:style toFunction:function];
}
@@ -173,7 +179,9 @@
#endif
- (void) dealloc {
- NSLog(@"deallocating WebView");
+#if ForSaurik
+ NSLog(@"[BrowserView dealloc]");
+#endif
if (challenge_ != nil)
[challenge_ release];
@@ -339,7 +347,14 @@
/* XXX: this is where I cry myself to sleep */
}
+- (bool) _allowJavaScriptPanel {
+ return true;
+}
+
- (void) webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
+ if ([self _allowJavaScriptPanel])
+ return;
+
UIActionSheet *sheet = [[[UIActionSheet alloc]
initWithTitle:nil
buttons:[NSArray arrayWithObjects:@"OK", nil]
@@ -353,6 +368,9 @@
}
- (BOOL) webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
+ if (![self _allowJavaScriptPanel])
+ return NO;
+
UIActionSheet *sheet = [[[UIActionSheet alloc]
initWithTitle:nil
buttons:[NSArray arrayWithObjects:@"OK", @"Cancel", nil]
@@ -375,6 +393,10 @@
return [confirm boolValue];
}
+- (void) setAutoPopup:(BOOL)popup {
+ popup_ = popup;
+}
+
- (void) setButtonImage:(NSString *)button withStyle:(NSString *)style toFunction:(id)function {
if (button_ != nil)
[button_ autorelease];
@@ -416,7 +438,9 @@
}
- (void) webView:(WebView *)sender decidePolicyForNewWindowAction:(NSDictionary *)action request:(NSURLRequest *)request newFrameName:(NSString *)name decisionListener:(id<WebPolicyDecisionListener>)listener {
+#if ForSaurik
NSLog(@"nwa:%@", name);
+#endif
if (NSURL *url = [request URL]) {
if (name == nil) unknown: {
@@ -433,7 +457,7 @@
RVPage *page([delegate_ pageForURL:url hasTag:NULL]);
if (page == nil) {
- /* XXX: call createWebViewWithRequest instead */
+ /* XXX: call createWebViewWithRequest instead? */
[self setBackButtonTitle:title_];
@@ -505,7 +529,10 @@
int store(_not(int));
if (NSURL *itms = [url itmsURL:&store]) {
+#if ForSaurik
NSLog(@"itms#%@#%u#%@", url, store, itms);
+#endif
+
if (
store == 1 && [capability containsObject:@"com.apple.MobileStore"] ||
store == 2 && [capability containsObject:@"com.apple.AppStore"]
@@ -648,13 +675,29 @@
}
- (WebView *) webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request windowFeatures:(NSDictionary *)features {
+//- (WebView *) webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request userGesture:(BOOL)gesture {
#if ForSaurik
- NSLog(@"cwv:%@ (%@)", request, title_);
+ NSLog(@"cwv:%@ (%@): %@", request, title_, features == nil ? @"{}" : [features description]);
+ //NSLog(@"cwv:%@ (%@): %@", request, title_, gesture ? @"Yes" : @"No");
#endif
- BrowserView *browser = [[[BrowserView alloc] initWithBook:book_] autorelease];
+ NSNumber *value([features objectForKey:@"width"]);
+ float width(value == nil ? [BrowserView defaultWidth] : [value floatValue]);
+
+ RVBook *book(!popup_ ? book_ : [[[RVPopUpBook alloc] initWithFrame:[delegate_ popUpBounds]] autorelease]);
+
+ /* XXX: deal with cydia:// pages */
+ BrowserView *browser([[[BrowserView alloc] initWithBook:book forWidth:width] autorelease]);
+
+ if (features == nil && popup_) {
+ [book setDelegate:delegate_];
+ [browser setDelegate:delegate_];
+
+ [browser loadRequest:request];
- if (request == nil) {
+ [book setPage:browser];
+ [book_ pushBook:book];
+ } else if (request == nil) {
[self setBackButtonTitle:title_];
[browser setDelegate:delegate_];
[browser retain];
@@ -668,6 +711,7 @@
- (WebView *) webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request {
return [self webView:sender createWebViewWithRequest:request windowFeatures:nil];
+ //return [self webView:sender createWebViewWithRequest:request userGesture:YES];
}
- (void) webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame {
@@ -823,9 +867,11 @@
#endif
}
-- (id) initWithBook:(RVBook *)book {
+- (id) initWithBook:(RVBook *)book forWidth:(float)width {
if ((self = [super initWithBook:book]) != nil) {
loading_ = false;
+ width_ = width;
+ popup_ = false;
struct CGRect bounds = [self bounds];
@@ -878,12 +924,13 @@
[webview_ setAutoresizes:YES];
[webview_ setMinimumScale:0.25f forDocumentTypes:0x10];
+ [webview_ setMaximumScale:5.00f forDocumentTypes:0x10];
[webview_ setInitialScale:UIWebViewScalesToFitScale forDocumentTypes:0x10];
- [webview_ setViewportSize:CGSizeMake(980, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
+ //[webview_ setViewportSize:CGSizeMake(980, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
[webview_ setViewportSize:CGSizeMake(320, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x2];
- [webview_ setMinimumScale:1.0f forDocumentTypes:0x8];
+ [webview_ setMinimumScale:1.00f forDocumentTypes:0x8];
[webview_ setInitialScale:UIWebViewScalesToFitScale forDocumentTypes:0x8];
[webview_ setViewportSize:CGSizeMake(320, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x8];
@@ -896,12 +943,15 @@
[webview_ setValue:[NSNumber numberWithBool:YES] forGestureAttribute:UIGestureAttributeUpdatesScroller];
[webview_ setSmoothsFonts:YES];
-
+ [webview_ setAllowsImageSheet:YES];
[webview _setUsesLoaderCache:YES];
- [webview setGroupName:@"Cydia"];
+
+ [webview setGroupName:@"CydiaGroup"];
[webview _setLayoutInterval:0];
}
+ [webview_ setViewportSize:CGSizeMake(width_, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
+
[webview_ setDelegate:self];
[webview_ setGestureDelegate:self];
[scroller_ addSubview:webview_];
@@ -918,8 +968,12 @@
[package installed]
];
+ if (Product_ != nil)
+ application = [NSString stringWithFormat:@"%@ Version/%@", application, Product_];
if (Build_ != nil)
- application = [NSString stringWithFormat:@"Mobile/%@ %@", Build_, application];
+ application = [NSString stringWithFormat:@"%@ Mobile/%@", application, Build_];
+ if (Safari_ != nil)
+ application = [NSString stringWithFormat:@"%@ Safari/%@", application, Safari_];
/* XXX: lookup application directory? */
/*if (NSDictionary *safari = [NSDictionary dictionaryWithContentsOfFile:@"/Applications/MobileSafari.app/Info.plist"])
@@ -942,6 +996,10 @@
} return self;
}
+- (id) initWithBook:(RVBook *)book {
+ return [self initWithBook:book forWidth:[[self class] defaultWidth]];
+}
+
- (void) didFinishGesturesInView:(UIView *)view forEvent:(id)event {
[webview_ redrawScaledDocument];
}
@@ -1020,4 +1078,8 @@
pushed_ = pushed;
}
++ (float) defaultWidth {
+ return 980;
+}
+
@end