]> git.saurik.com Git - cydia.git/commitdiff
Added custom depictions and better webview support.
authorJay Freeman (saurik) <saurik@saurk.com>
Tue, 19 Aug 2008 11:24:01 +0000 (11:24 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Thu, 30 Sep 2010 07:08:24 +0000 (07:08 +0000)
Cydia.app/menes/menes.js
Cydia.app/menes/style.css
Cydia.app/package.html
Cydia.app/package.js
Cydia.mm
UICaboodle/BrowserView.h
makefile

index 64ec5d0c0082da1d0e596ab9ffc7a4e10e6a12f4..f0070bcd167d19fc96dd1730ee757614b1345815 100644 (file)
@@ -27,9 +27,10 @@ var $ = function (arg, doc) {
         if (arg.charAt(0) == '#') {
             var node = doc.getElementById(arg.substring(1));
             return $(node == null ? [] : [node]);
-        } else if (arg.charAt(0) == '.')
-            return new $(doc.getElementsByClassName(arg.substring(1)));
-        else
+        } else if (arg.charAt(0) == '.') {
+            var nodes = doc.getElementsByClassName(arg.substring(1));
+            return $(nodes == null ? [] : nodes);
+        } else
             return $([doc]).descendants(arg);
     } else {
         _assert(doc == undefined);
@@ -184,6 +185,15 @@ $.inject = function (a, b) {
 };
 
 $.inject({
+    display: {
+        get: function (node) {
+            return node.style.display;
+        },
+        set: function (node, value) {
+            node.style.display = value;
+        }
+    },
+
     html: {
         get: function (node) {
             return node.innerHTML;
index ffae7216c0b2e46541beb5cc9024deb7b3fba6bc..e5e2264e3e92d04dcb73940598aa4239d2aae615 100644 (file)
@@ -44,7 +44,7 @@ body {
 }
 
 hr {
-    margin-top: 10px;
+    margin: 0;
 }
 
 .dialog > .panel {
@@ -155,7 +155,7 @@ strong {
 }
 
 .dialog > .panel > fieldset > div > p {
-    margin-top: .5em;
+    margin: 11px 0;
     text-align: center;
 }
 
@@ -163,6 +163,10 @@ strong {
     margin-top: 0;
 }
 
+.dialog > .panel > fieldset > div > p:last-child {
+    margin-bottom: 0;
+}
+
 .dialog > .panel > fieldset > a {
     background: 275px 11px no-repeat url(listArrow.png);
     color: inherit;
index c5458028589df57eea00cfad9e7e9d8f0e982776..c5acc6a843eb9e54969f35daa8f40963f01e3de3 100644 (file)
@@ -7,6 +7,61 @@
     <script type="text/javascript" src="menes/menes.js"></script>
     <script type="text/javascript" src="package.js"></script>
     <base target="_blank"/>
+
+    <script type="text/javascript">
+        var count = -1;
+        var loaded = function() {
+            if (count++ != 0)
+                return;
+            $("#depiction-load").remove();
+            $.each($("#depiction-src"), function (node) {
+                node.style.display = "block";
+            });
+        }
+
+        var remove = function() {
+            $(".description").display("block");
+            $(".depiction").remove();
+        }
+    </script>
+
+    <style>
+        body {
+            background: #c8c8c8 url(menes/pinstripes.png);
+        }
+
+        #remove {
+            margin-top: 7px;
+            text-align: center;
+        }
+
+        #indicator {
+            left: 20px;
+            position: relative;
+            top: -5px;
+        }
+
+        #notice {
+            margin-bottom: -14px;
+            overflow: hidden;
+            width: 320px;
+        }
+
+        #remove > a {
+            color: #335588;
+            text-decoration: none;
+        }
+
+        #upper-bar {
+            margin-bottom: 0;
+            margin-top: 10px;
+        }
+
+        #lower-bar {
+            margin-bottom: 10px;
+            margin-top: 0;
+        }
+    </style>
 </head><body><div class="page">
 <div class="dialog">
     <div class="panel">
     </a>
 </fieldset>
 
+<div id="notice" class="notice"><iframe
+    id="notice-src"
+    frameborder="0"
+    width="320"
+    height="0"
+    target="_top"
+></iframe></div>
+
+<div id="remove" class="depiction">
+    <a href="javascript:remove()">Remove Custom Depiction</a>
+</div>
+
+<hr id="upper-bar" class="depiction"/>
+
 <div style="width: 320px; overflow: hidden" class="depiction"><iframe
     id="depiction-src"
     frameborder="0"
-    width="300"
+    width="320"
+    height="0"
     target="_top"
+    onLoad="loaded()"
 ></iframe></div>
 
+<hr id="lower-bar" class="depiction"/>
+
 <fieldset class="description">
     <div id="description"></div>
 
-    <a id="homepage-href">
+    <a class="homepage" id="homepage-href">
         <label>More Information</label>
     </a>
 </fieldset>
 <label class="source">Source Infomation</label>
 <fieldset class="source">
     <div><label id="source-name"></label></div>
-    <div id="source-description"></div>
+    <div class="source-description" id="source-description"></div>
 </fieldset>
 
     </div>
index aec81416fee118217d0fcdd97b0d47a3fa4331eb..0dfa6dc9c1d7f3c03aced59c52d756fdc604e35c 100644 (file)
@@ -5,10 +5,10 @@
         "name": "Allen Porter",
         "address": "allen.porter@gmail.com"
     },
-    "depiction": "http://planet-iphones.com/repository/info/chromium1.3.php",
+    //"depiction": "http://planet-iphones.com/repository/info/chromium1.3.php",
+    "depiction": "http://cydia.saurik.com/terminal.html",
     "description": "this is a sample description",
-    //"homepage": "http://cydia.saurik.com/terminal.html",
-    "homepage": "http://planet-iphones.com/repository/info/chromium1.3.php",
+    "homepage": "http://cydia.saurik.com/terminal.html",
     "installed": "286u-4",
     "id": "mobileterminal",
     "section": "Terminal Support",
@@ -39,21 +39,23 @@ $(function () {
         $("#author-href").href("mailto:" + author.address + "?subject=" + regarding);
     }
 
+    $("#notice-src").src("http://cydia.saurik.com/notice/" + encodeURIComponent(id) + ".html");
+
     var depiction = package.depiction;
-    if (depiction != null) {
-        $(".description").remove();
-        $("#depiction-src").src(depiction);
-    } else {
+    if (depiction == null)
         $(".depiction").remove();
-
-        var description = package.description;
-        if (description == null)
-            description = package.tagline;
-        else
-            description = description.replace(/\n/g, "<br/>");
-        $("#description").html(description);
+    else {
+        $(".description").display("none");
+        $("#depiction-src").src(depiction);
     }
 
+    var description = package.description;
+    if (description == null)
+        description = package.tagline;
+    else
+        description = description.replace(/\n/g, "<br/>");
+    $("#description").html(description);
+
     var homepage = package.homepage;
     if (homepage == null)
         $(".homepage").remove();
index fccb591f18ef29031252f707917f5cdeafd0e926..b8cf99387458bd43fd1524cd78c3e2f54707f075 100644 (file)
--- a/Cydia.mm
+++ b/Cydia.mm
@@ -42,7 +42,9 @@
 #include <CoreGraphics/CoreGraphics.h>
 #include <GraphicsServices/GraphicsServices.h>
 #include <Foundation/Foundation.h>
+
 #include <WebCore/DOMHTML.h>
+#import <QuartzCore/CALayer.h>
 
 #import <UIKit/UIActionSheet.h>
 #import <UIKit/UIAnimator.h>
 #import <UIKit/UIWindow.h>
 
 #import <UIKit/UIView-Geometry.h>
+#import <UIKit/UIView-Gestures.h>
 #import <UIKit/UIView-Hierarchy.h>
 #import <UIKit/UIView-Rendering.h>
 
+#import <UIKit/UIWebDocumentView-Forms.h>
+
 #import <UIKit/NSString-UIStringDrawing.h>
 
 // XXX: remove
@@ -144,6 +149,10 @@ extern "C" {
 #import "UICaboodle.h"
 /* }}} */
 
+@interface WebView (Cydia)
+- (void) _setLayoutInterval:(float)interval;
+@end
+
 /* iPhoneOS 2.0 Compatibility {{{ */
 #ifdef __OBJC2__
 @interface UICGColor : NSObject {
@@ -461,6 +470,7 @@ static CGColor Red_;
 static CGColor White_;
 static CGColor Gray_;
 
+static NSString *App_;
 static NSString *Home_;
 static BOOL Sounds_Keyboard_;
 
@@ -1082,6 +1092,7 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
 - (BOOL) upgradableAndEssential:(BOOL)essential;
 - (BOOL) essential;
 - (BOOL) broken;
+- (BOOL) unfiltered;
 - (BOOL) visible;
 
 - (BOOL) half;
@@ -1116,8 +1127,8 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
 - (void) install;
 - (void) remove;
 
-- (NSNumber *) isVisiblySearchedForBy:(NSString *)search;
-- (NSNumber *) isInstalledAndVisible:(NSNumber *)number;
+- (NSNumber *) isUnfilteredAndSearchedForBy:(NSString *)search;
+- (NSNumber *) isInstalledAndUnfiltered:(NSNumber *)number;
 - (NSNumber *) isVisiblyUninstalledInSection:(NSString *)section;
 - (NSNumber *) isVisibleInSource:(Source *)source;
 
@@ -1342,9 +1353,13 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
     return [database_ cache][iterator_].InstBroken();
 }
 
-- (BOOL) visible {
+- (BOOL) unfiltered {
     NSString *section = [self section];
-    return [self hasSupportingRole] && (section == nil || isSectionVisible(section));
+    return section == nil || isSectionVisible(section);
+}
+
+- (BOOL) visible {
+    return [self hasSupportingRole] && [self unfiltered];
 }
 
 - (BOOL) half {
@@ -1585,15 +1600,15 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
     [database_ cache]->MarkDelete(iterator_, true);
 }
 
-- (NSNumber *) isVisiblySearchedForBy:(NSString *)search {
+- (NSNumber *) isUnfilteredAndSearchedForBy:(NSString *)search {
     return [NSNumber numberWithBool:(
-        [self valid] && [self visible] && [self matches:search]
+        [self unfiltered] && [self matches:search]
     )];
 }
 
-- (NSNumber *) isInstalledAndVisible:(NSNumber *)number {
+- (NSNumber *) isInstalledAndUnfiltered:(NSNumber *)number {
     return [NSNumber numberWithBool:(
-        (![number boolValue] || [self visible]) && [self installed] != nil
+        (![number boolValue] || [self unfiltered]) && [self installed] != nil
     )];
 }
 
@@ -1601,7 +1616,7 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
     NSString *section = [self section];
 
     return [NSNumber numberWithBool:(
-        [self valid] && [self visible] &&
+        [self visible] &&
         [self installed] == nil && (
             name == nil ||
             section == nil && [name length] == 0 ||
@@ -2914,7 +2929,7 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
     if (NSString *icon = [package icon])
         icon_ = [UIImage imageAtPath:[icon substringFromIndex:6]];
     if (icon_ == nil) if (NSString *section = [package section])
-        icon_ = [UIImage applicationImageNamed:[NSString stringWithFormat:@"Sections/%@.png", Simplify(section)]];
+        icon_ = [UIImage imageAtPath:[NSString stringWithFormat:@"%@/Sections/%@.png", App_, Simplify(section)]];
     /*if (icon_ == nil) if (NSString *icon = [source defaultIcon])
         icon_ = [UIImage imageAtPath:[icon substringFromIndex:6]];*/
     if (icon_ == nil)
@@ -3299,6 +3314,13 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
     [sheet dismiss];
 }
 
+#include "internals.h"
+
+- (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
+    [[frame windowObject] evaluateWebScript:@"document.base.target = '_top'"];
+    return [super webView:sender didFinishLoadForFrame:frame];
+}
+
 - (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
     [window setValue:package_ forKey:@"package"];
 }
@@ -3514,7 +3536,7 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
 
     for (size_t i(0); i != [packages count]; ++i) {
         Package *package([packages objectAtIndex:i]);
-        if ([[package performSelector:filter_ withObject:object_] boolValue])
+        if ([package valid] && [[package performSelector:filter_ withObject:object_] boolValue])
             [packages_ addObject:package];
     }
 
@@ -4036,7 +4058,7 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
             initWithBook:book
             database:database
             title:nil
-            filter:@selector(isInstalledAndVisible:)
+            filter:@selector(isInstalledAndUnfiltered:)
             with:[NSNumber numberWithBool:YES]
         ];
 
@@ -4360,7 +4382,7 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
     NSString *href = [webview mainFrameURL];
     [urls_ addObject:[NSURL URLWithString:href]];
 
-    CGRect webrect = [scroller_ frame];
+    CGRect webrect = [scroller_ bounds];
     webrect.size.height = 0;
     [webview_ setFrame:webrect];
 }
@@ -4373,10 +4395,31 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
     }
 }
 
+- (BOOL) webView:(WebView *)sender shouldScrollToPoint:(struct CGPoint)point forFrame:(WebFrame *)frame {
+    _trace();
+    return [webview_ webView:sender shouldScrollToPoint:point forFrame:frame];
+}
+
+- (void) webView:(WebView *)sender didReceiveViewportArguments:(id)arguments forFrame:(WebFrame *)frame {
+    return [webview_ webView:sender didReceiveViewportArguments:arguments forFrame:frame];
+}
+
+- (void) webView:(WebView *)sender needsScrollNotifications:(id)notifications forFrame:(WebFrame *)frame {
+    return [webview_ webView:sender needsScrollNotifications:notifications forFrame:frame];
+}
+
+- (void) webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame {
+    return [webview_ webView:sender didCommitLoadForFrame:frame];
+}
+
+- (void) webView:(WebView *)sender didReceiveDocTypeForFrame:(WebFrame *)frame {
+    return [webview_ webView:sender didReceiveDocTypeForFrame:frame];
+}
+
 - (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
-    if ([frame parentFrame] != nil)
-        return;
-    [self _finishLoading];
+    if ([frame parentFrame] == nil)
+        [self _finishLoading];
+    return [webview_ webView:sender didFinishLoadForFrame:frame];
 }
 
 - (void) webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
@@ -4417,11 +4460,26 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
         webview_ = [[UIWebView alloc] initWithFrame:webrect];
         [scroller_ addSubview:webview_];
 
-        [webview_ setTilingEnabled:YES];
         [webview_ setTileSize:CGSizeMake(webrect.size.width, 500)];
+
+        [webview_ setTilingEnabled:YES];
+        [webview_ setTileMinificationFilter:kCAFilterNearest];
         [webview_ setAutoresizes:YES];
+
+        [webview_ setViewportSize:CGSizeMake(980, -1) forDocumentTypes:0x10];
+        [webview_ setViewportSize:CGSizeMake(320, -1) forDocumentTypes:0x2];
+        [webview_ setViewportSize:CGSizeMake(320, -1) forDocumentTypes:0x8];
+
+        [webview_ _setDocumentType:0x4];
+
+        [webview_ setZoomsFocusedFormControl:YES];
+        [webview_ setContentsPosition:7];
+        [webview_ setEnabledGestures:0xa];
+        [webview_ setValue:[NSNumber numberWithBool:YES] forGestureAttribute:0x4];
+        [webview_ setValue:[NSNumber numberWithBool:YES] forGestureAttribute:0x7];
         [webview_ setDelegate:self];
-        //[webview_ setEnabledGestures:2];
+        [webview_ setGestureDelegate:self];
+        [webview_ setSmoothsFonts:YES];
 
         CGSize indsize = [UIProgressIndicator defaultSizeForStyle:kUIProgressIndicatorStyleMediumWhite];
         indicator_ = [[UIProgressIndicator alloc] initWithFrame:CGRectMake(281, 42, indsize.width, indsize.height)];
@@ -4439,10 +4497,16 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
         [webview setResourceLoadDelegate:self];
         [webview setUIDelegate:self];
 
+        //[webview _setLayoutInterval:0.5];
+
         urls_ = [[NSMutableArray alloc] initWithCapacity:16];
     } return self;
 }
 
+- (void) didFinishGesturesInView:(UIView *)view forEvent:(id)event {
+    [webview_ redrawScaledDocument];
+}
+
 - (void) _rightButtonClicked {
     reloading_ = true;
     [self reloadURL];
@@ -5056,7 +5120,7 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
             initWithBook:book
             database:database
             title:nil
-            filter:@selector(isVisiblySearchedForBy:)
+            filter:@selector(isUnfilteredAndSearchedForBy:)
             with:nil
         ];
 
@@ -6094,6 +6158,7 @@ int main(int argc, char *argv[]) {
 
     bootstrap_ = argc > 1 && strcmp(argv[1], "--bootstrap") == 0;
 
+    App_ = [[NSBundle mainBundle] bundlePath];
     Home_ = NSHomeDirectory();
 
     {
index 7c6cc505515db37e31907749c60961fb942b11e7..caafaa52e665410c0f0cc3d083ce5715442ce0b0 100644 (file)
@@ -37,4 +37,6 @@
 
 - (id) initWithBook:(RVBook *)book database:(Database *)database;
 
+- (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame;
+
 @end
index dc82734705a370a720882414e4a02aeeaddbb41e..6763d1d5931cb10a1a08a07da3f447ddca80975a 100644 (file)
--- a/makefile
+++ b/makefile
@@ -6,6 +6,10 @@ endif
 
 frameworks :=
 
+ifneq ($(wildcard $(PKG_ROOT)/System/Library/*Frameworks/QuartzCore.framework),)
+frameworks += -framework QuartzCore
+endif
+
 ifneq ($(wildcard $(PKG_ROOT)/System/Library/*Frameworks/LayerKit.framework),)
 frameworks += -framework LayerKit
 endif