From d32f96beabb726c84dfeaa3a51bb365eded7f8f9 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 23 Dec 2013 16:18:02 -0800 Subject: [PATCH] Fix background color so it works on all iOS builds. --- CyteKit/ViewController.h | 5 +++++ CyteKit/ViewController.mm | 11 +++++++++++ CyteKit/WebViewController.h | 3 --- CyteKit/WebViewController.mm | 31 ++++++++++++++----------------- 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/CyteKit/ViewController.h b/CyteKit/ViewController.h index e3712688..b1372491 100644 --- a/CyteKit/ViewController.h +++ b/CyteKit/ViewController.h @@ -26,6 +26,8 @@ #include +#include + @interface UIViewController (Cydia) - (BOOL) hasLoaded; - (void) reloadData; @@ -36,6 +38,7 @@ @interface CyteViewController : UIViewController { _transient id delegate_; BOOL loaded_; + _H color_; } // The default implementation of this method is essentially a no-op, @@ -62,6 +65,8 @@ // just happens not to be visible. - (void) releaseSubviews; +- (void) setPageColor:(UIColor *)color; + @end #endif//CyteKit_ViewController_H diff --git a/CyteKit/ViewController.mm b/CyteKit/ViewController.mm index a0365956..df2ba616 100644 --- a/CyteKit/ViewController.mm +++ b/CyteKit/ViewController.mm @@ -24,6 +24,8 @@ #include #include +#include "iPhonePrivate.h" + extern bool IsWildcat_; @implementation UIViewController (Cydia) @@ -110,4 +112,13 @@ extern bool IsWildcat_; return IsWildcat_ || orientation == UIInterfaceOrientationPortrait; } +- (void) setPageColor:(UIColor *)color { + if (color == nil) { + color = [UIColor groupTableViewBackgroundColor]; + if ([color isEqual:[UIColor clearColor]]) + color = [UIColor pinStripeColor]; + //color = [UIColor colorWithRed:(215.0/255.0) green:(217.0/255.0) blue:(223.0/255.0) alpha:1.0]; + } color_ = color; +} + @end diff --git a/CyteKit/WebViewController.h b/CyteKit/WebViewController.h index c8d9d512..cb1bf610 100644 --- a/CyteKit/WebViewController.h +++ b/CyteKit/WebViewController.h @@ -71,7 +71,6 @@ float width_; Class class_; - _H color_; _H reloaditem_; _H loadingitem_; @@ -103,8 +102,6 @@ - (id) initWithWidth:(float)width; - (id) initWithWidth:(float)width ofClass:(Class)_class; -- (void) setColor:(UIColor *)color; - - (void) callFunction:(WebScriptObject *)function; - (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame; diff --git a/CyteKit/WebViewController.mm b/CyteKit/WebViewController.mm index f5ec0609..c4931cbe 100644 --- a/CyteKit/WebViewController.mm +++ b/CyteKit/WebViewController.mm @@ -418,12 +418,12 @@ float CYScrollViewDecelerationRateNormal; if (page == nil) { CyteWebViewController *browser([[[class_ alloc] init] autorelease]); - [browser setColor:color_]; [browser setRequest:request]; page = browser; } [page setDelegate:delegate_]; + [page setPageColor:color_]; if (!pop) { [[self navigationItem] setTitle:title_]; @@ -579,20 +579,18 @@ float CYScrollViewDecelerationRateNormal; float blue([[rgb blue] getFloatValue:DOM_CSS_NUMBER]); float alpha([[rgb alpha] getFloatValue:DOM_CSS_NUMBER]); - uic = [UIColor - colorWithRed:(red / 255) - green:(green / 255) - blue:(blue / 255) - alpha:alpha - ]; + if (alpha == 1) + uic = [UIColor + colorWithRed:(red / 255) + green:(green / 255) + blue:(blue / 255) + alpha:alpha + ]; } } - if (uic == nil) - uic = [UIColor groupTableViewBackgroundColor]; - - color_ = uic; - [scroller_ setBackgroundColor:uic]; + [self setPageColor:uic]; + [scroller_ setBackgroundColor:color_]; break; } } @@ -838,7 +836,7 @@ float CYScrollViewDecelerationRateNormal; width_ = width; class_ = _class; - color_ = [UIColor groupTableViewBackgroundColor]; + [self setPageColor:nil]; allowsNavigationAction_ = true; @@ -956,6 +954,9 @@ float CYScrollViewDecelerationRateNormal; //[scroller setAllowsRubberBanding:YES]; } + [webview_ setOpaque:NO]; + [webview_ setBackgroundColor:color_]; + [scroller_ setFixedBackgroundPattern:YES]; [scroller_ setBackgroundColor:color_]; [scroller_ setClipsSubviews:YES]; @@ -1000,10 +1001,6 @@ float CYScrollViewDecelerationRateNormal; } return self; } -- (void) setColor:(UIColor *)color { - color_ = color; -} - - (void) callFunction:(WebScriptObject *)function { WebThreadLocked lock; -- 2.45.2