]> git.saurik.com Git - cydia.git/blobdiff - Cydia.mm
Commit (chpwn): packages-cell-landscape.patch
[cydia.git] / Cydia.mm
index c967c5c0e7d118d134fb8d765fbbc0df89532220..53ea2eac7c71617722a92b5e8d9d7aea8a5fd653 100644 (file)
--- a/Cydia.mm
+++ b/Cydia.mm
@@ -281,7 +281,7 @@ static _finline NSString *CydiaURL(NSString *path) {
 @end
 /* }}} */
 
-@interface CYActionSheet : UIActionSheet {
+@interface CYActionSheet : UIAlertView {
     unsigned button_;
 }
 
@@ -291,12 +291,15 @@ static _finline NSString *CydiaURL(NSString *path) {
 @implementation CYActionSheet
 
 - (id) initWithTitle:(NSString *)title buttons:(NSArray *)buttons defaultButtonIndex:(int)index {
-    if ((self = [super initWithTitle:title buttons:buttons defaultButtonIndex:index delegate:self context:nil]) != nil) {
+    if ((self = [super init])) {
+               [self setDelegate:self];
+               for (NSString *button in buttons) [self addButtonWithTitle:button];
+               [self setCancelButtonIndex:index];
     } return self;
 }
 
-- (void) alertSheet:(UIActionSheet *)sheet buttonClicked:(int)button {
-    button_ = button;
+- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
+    button_ = buttonIndex + 1;
 }
 
 - (int) yieldToPopupAlertAnimated:(BOOL)animated {
@@ -380,7 +383,7 @@ static const CFStringCompareFlags LaxCompareFlags_ = kCFCompareCaseInsensitive |
 
 #define lprintf(args...) fprintf(stderr, args)
 
-#define ForRelease 1
+#define ForRelease 0
 #define TraceLogging (1 && !ForRelease)
 #define HistogramInsertionSort (0 && !ForRelease)
 #define ProfileTimes (0 && !ForRelease)
@@ -392,7 +395,7 @@ static const CFStringCompareFlags LaxCompareFlags_ = kCFCompareCaseInsensitive |
 #define IgnoreInstall (0 && !ForRelease)
 #define RecycleWebViews 0
 #define RecyclePackageViews (1 && ForRelease)
-#define AlwaysReload (0 && !ForRelease)
+#define AlwaysReload (1 && !ForRelease)
 
 #if !TraceLogging
 #undef _trace
@@ -713,11 +716,8 @@ NSUInteger DOMNodeList$countByEnumeratingWithState$objects$count$(DOMNodeList *s
 
 - (NSString *) stringByCachingURLWithCurrentCDN {
     return [self
-        stringByReplacingOccurrencesOfString:@"://"
-        withString:@"://wpc.03A4.edgecastcdn.net/8003A4/"
-        options:0
-        /* XXX: this is somewhat inaccurate */
-        range:NSMakeRange(0, 10)
+        stringByReplacingOccurrencesOfString:@"://cydia.saurik.com/"
+        withString:@"://cache.cydia.saurik.com/"
     ];
 }
 
@@ -3938,7 +3938,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
     if ((self = [super initWithBook:book forWidth:width ofClass:[CydiaBrowserView class]]) != nil) {
         cydia_ = [[CydiaObject alloc] initWithDelegate:indirect_];
 
-        WebView *webview([webview_ webView]);
+        WebView *webview([document_ webView]);
 
         Package *package([[Database sharedInstance] packageWithName:@"cydia"]);
 
@@ -4700,6 +4700,12 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
     delegate_ = delegate;
 }
 
+/* Fix landscape: redraw when frame changes. */
+- (void) setFrame:(CGRect)frame {
+       [super setFrame:frame];
+       [self setNeedsDisplay];
+}
+
 - (void) drawRect:(CGRect)rect {
     [super drawRect:rect];
     [delegate_ drawContentRect:rect];
@@ -5098,6 +5104,9 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
         [list_ addTableColumn:column];
         [list_ setDelegate:self];
         [list_ setReusesTableCells:YES];
+
+               [list_ setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
+        [self setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
     } return self;
 }
 
@@ -5321,10 +5330,10 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
             [buttons_ addObject:UCLocalize("REMOVE")];
 
         if (special_ != NULL) {
-            CGRect frame([webview_ frame]);
+            CGRect frame([document_ frame]);
             frame.size.width = 320;
             frame.size.height = 0;
-            [webview_ setFrame:frame];
+            [document_ setFrame:frame];
 
             if ([scroller_ respondsToSelector:@selector(scrollPointVisibleAtTopLeft:)])
                 [scroller_ scrollPointVisibleAtTopLeft:CGPointZero];
@@ -5332,7 +5341,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
                 [scroller_ scrollRectToVisible:CGRectZero animated:NO];
 
             WebThreadLock();
-            [[[webview_ webView] windowScriptObject] setValue:package_ forKey:@"package"];
+            [[[document_ webView] windowScriptObject] setValue:package_ forKey:@"package"];
 
             [self setButtonTitle:nil withStyle:nil toFunction:nil];
 
@@ -6256,32 +6265,19 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
 }
 
 - (void) _leftButtonClicked {
-    UIActionSheet *sheet = [[[UIActionSheet alloc]
-        initWithTitle:UCLocalize("ABOUT_CYDIA")
-        buttons:[NSArray arrayWithObjects:UCLocalize("CLOSE"), nil]
-        defaultButtonIndex:0
-        delegate:self
-        context:@"about"
-    ] autorelease];
-
-    [sheet setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
+    UIAlertView *alert = [[[UIAlertView alloc] init] autorelease];
+    [alert setTitle:UCLocalize("ABOUT_CYDIA")];
+    [alert addButtonWithTitle:UCLocalize("CLOSE")];
+    [alert setCancelButtonIndex:0];
 
-    [sheet setBodyText:
+    [alert setMessage:
         @"Copyright (C) 2008-2010\n"
         "Jay Freeman (saurik)\n"
         "saurik@saurik.com\n"
-        "http://www.saurik.com/\n"
-        "\n"
-        "The Okori Group\n"
-        "http://www.theokorigroup.com/\n"
-        "\n"
-        "College of Creative Studies,\n"
-        "University of California,\n"
-        "Santa Barbara\n"
-        "http://www.ccs.ucsb.edu/"
+        "http://www.saurik.com/"
     ];
 
-    [sheet popupAlertAnimated:YES];
+    [alert show];
 }
 
 - (NSString *) leftButtonTitle {
@@ -7635,7 +7631,9 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
     UIView *underlay_;
     UIView *overlay_;
     CYBook *book_;
-    UIToolbar *toolbar_;
+
+    NSArray *items_;
+    UITabBar *toolbar_;
 
     RVBook *confirm_;
 
@@ -7645,7 +7643,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
     Database *database_;
     ProgressView *progress_;
 
-    unsigned tag_;
+    int tag_;
 
     UIKeyboard *keyboard_;
     UIProgressHUD *hud_;
@@ -7739,11 +7737,11 @@ static _finline void _setHomePage(Cydia *self) {
     [self _saveConfig];
 
     /* XXX: this is just stupid */
-    if (tag_ != 2 && sections_ != nil)
+    if (tag_ != 1 && sections_ != nil)
         [sections_ reloadData];
-    if (tag_ != 3 && changes_ != nil)
+    if (tag_ != 2 && changes_ != nil)
         [changes_ reloadData];
-    if (tag_ != 5 && search_ != nil)
+    if (tag_ != 4 && search_ != nil)
         [search_ reloadData];
 
     [book_ reloadData];
@@ -7779,17 +7777,17 @@ static _finline void _setHomePage(Cydia *self) {
 
     if (changes != 0) {
         NSString *badge([[NSNumber numberWithInt:changes] stringValue]);
-        [toolbar_ setBadgeValue:badge forButton:3];
+               [[[toolbar_ items] objectAtIndex:2] setBadgeValue:badge];
         if ([toolbar_ respondsToSelector:@selector(setBadgeAnimated:forButton:)])
-            [toolbar_ setBadgeAnimated:([essential_ count] != 0) forButton:3];
+                       [[[toolbar_ items] objectAtIndex:2] setAnimatedBadge:YES];
         if ([self respondsToSelector:@selector(setApplicationBadge:)])
             [self setApplicationBadge:badge];
         else
             [self setApplicationBadgeString:badge];
     } else {
-        [toolbar_ setBadgeValue:nil forButton:3];
+               [[[toolbar_ items] objectAtIndex:2] setBadgeValue:nil];
         if ([toolbar_ respondsToSelector:@selector(setBadgeAnimated:forButton:)])
-            [toolbar_ setBadgeAnimated:NO forButton:3];
+            [[[toolbar_ items] objectAtIndex:2] setAnimatedBadge:NO];
         if ([self respondsToSelector:@selector(removeApplicationBadge)])
             [self removeApplicationBadge];
         else // XXX: maybe use setApplicationBadgeString also?
@@ -7797,7 +7795,7 @@ static _finline void _setHomePage(Cydia *self) {
     }
 
     Queuing_ = false;
-    [toolbar_ setBadgeValue:nil forButton:4];
+    [[[toolbar_ items] objectAtIndex:3] setBadgeValue:nil];
 
     [self _updateData];
 
@@ -8021,21 +8019,21 @@ static _finline void _setHomePage(Cydia *self) {
     return search_;
 }
 
-- (void) buttonBarItemTapped:(id)sender {
-    unsigned tag = [sender tag];
+- (void) tabBar:(UITabBar *)sender didSelectItem:(UITabBarItem *)item {
+    int tag = [item tag];
     if (tag == tag_) {
         [book_ resetViewAnimated:YES];
         return;
-    } else if (tag_ == 2)
+    } else if (tag_ == 1)
         [[self sectionsView] resetView];
 
     switch (tag) {
-        case 1: _setHomePage(self); break;
+        case 0: _setHomePage(self); break;
 
-        case 2: [self setPage:[self sectionsView]]; break;
-        case 3: [self setPage:[self changesView]]; break;
-        case 4: [self setPage:[self manageView]]; break;
-        case 5: [self setPage:[self searchView]]; break;
+        case 1: [self setPage:[self sectionsView]]; break;
+        case 2: [self setPage:[self changesView]]; break;
+        case 3: [self setPage:[self manageView]]; break;
+        case 4: [self setPage:[self searchView]]; break;
 
         _nodefault
     }
@@ -8142,7 +8140,7 @@ static _finline void _setHomePage(Cydia *self) {
                 [self _reloadData];
             else {
                 Queuing_ = true;
-                [toolbar_ setBadgeValue:UCLocalize("Q_D") forButton:4];
+                [[[toolbar_ items] objectAtIndex:3] setBadgeValue:UCLocalize("Q_D")];
                 [book_ reloadData];
             }
 
@@ -8260,7 +8258,7 @@ static _finline void _setHomePage(Cydia *self) {
 
 - (RVPage *) pageForURL:(NSURL *)url hasTag:(int *)tag {
     if (tag != NULL)
-        tag = 0;
+        *tag = -1;
 
     NSString *href([url absoluteString]);
     if ([href hasPrefix:@"apptapp://package/"])
@@ -8312,8 +8310,8 @@ static _finline void _setHomePage(Cydia *self) {
     int tag;
     if (RVPage *page = [self pageForURL:url hasTag:&tag]) {
         [self setPage:page];
-        [toolbar_ showSelectionForButton:tag];
         tag_ = tag;
+        [toolbar_ setSelectedItem:(tag_ == -1 ? nil : [items_ objectAtIndex:tag_])];
     }
 }
 
@@ -8328,7 +8326,7 @@ static _finline void _setHomePage(Cydia *self) {
     Font18Bold_ = [[UIFont boldSystemFontOfSize:18] retain];
     Font22Bold_ = [[UIFont boldSystemFontOfSize:22] retain];
 
-    tag_ = 1;
+    tag_ = 0;
 
     essential_ = [[NSMutableArray alloc] initWithCapacity:4];
     broken_ = [[NSMutableArray alloc] initWithCapacity:4];
@@ -8407,75 +8405,29 @@ static _finline void _setHomePage(Cydia *self) {
 
     [book_ setDelegate:self];
 
-    NSArray *buttonitems = [NSArray arrayWithObjects:
-        [NSDictionary dictionaryWithObjectsAndKeys:
-            @"buttonBarItemTapped:", kUIButtonBarButtonAction,
-            @"home-up.png", kUIButtonBarButtonInfo,
-            @"home-dn.png", kUIButtonBarButtonSelectedInfo,
-            [NSNumber numberWithInt:1], kUIButtonBarButtonTag,
-            self, kUIButtonBarButtonTarget,
-            @"Cydia", kUIButtonBarButtonTitle,
-            @"0", kUIButtonBarButtonType,
-        nil],
-
-        [NSDictionary dictionaryWithObjectsAndKeys:
-            @"buttonBarItemTapped:", kUIButtonBarButtonAction,
-            @"install-up.png", kUIButtonBarButtonInfo,
-            @"install-dn.png", kUIButtonBarButtonSelectedInfo,
-            [NSNumber numberWithInt:2], kUIButtonBarButtonTag,
-            self, kUIButtonBarButtonTarget,
-            UCLocalize("SECTIONS"), kUIButtonBarButtonTitle,
-            @"0", kUIButtonBarButtonType,
-        nil],
-
-        [NSDictionary dictionaryWithObjectsAndKeys:
-            @"buttonBarItemTapped:", kUIButtonBarButtonAction,
-            @"changes-up.png", kUIButtonBarButtonInfo,
-            @"changes-dn.png", kUIButtonBarButtonSelectedInfo,
-            [NSNumber numberWithInt:3], kUIButtonBarButtonTag,
-            self, kUIButtonBarButtonTarget,
-            UCLocalize("CHANGES"), kUIButtonBarButtonTitle,
-            @"0", kUIButtonBarButtonType,
-        nil],
-
-        [NSDictionary dictionaryWithObjectsAndKeys:
-            @"buttonBarItemTapped:", kUIButtonBarButtonAction,
-            @"manage-up.png", kUIButtonBarButtonInfo,
-            @"manage-dn.png", kUIButtonBarButtonSelectedInfo,
-            [NSNumber numberWithInt:4], kUIButtonBarButtonTag,
-            self, kUIButtonBarButtonTarget,
-            UCLocalize("MANAGE"), kUIButtonBarButtonTitle,
-            @"0", kUIButtonBarButtonType,
-        nil],
-
-        [NSDictionary dictionaryWithObjectsAndKeys:
-            @"buttonBarItemTapped:", kUIButtonBarButtonAction,
-            @"search-up.png", kUIButtonBarButtonInfo,
-            @"search-dn.png", kUIButtonBarButtonSelectedInfo,
-            [NSNumber numberWithInt:5], kUIButtonBarButtonTag,
-            self, kUIButtonBarButtonTarget,
-            UCLocalize("SEARCH"), kUIButtonBarButtonTitle,
-            @"0", kUIButtonBarButtonType,
-        nil],
-    nil];
+    items_ = [[NSArray arrayWithObjects:
+        [[[UITabBarItem alloc] initWithTitle:@"Cydia" image:[UIImage applicationImageNamed:@"home.png"] tag:0] autorelease],
+        [[[UITabBarItem alloc] initWithTitle:UCLocalize("SECTIONS") image:[UIImage applicationImageNamed:@"install.png"] tag:1] autorelease],
+        [[[UITabBarItem alloc] initWithTitle:UCLocalize("CHANGES") image:[UIImage applicationImageNamed:@"changes.png"] tag:2] autorelease],
+        [[[UITabBarItem alloc] initWithTitle:UCLocalize("MANAGE") image:[UIImage applicationImageNamed:@"manage.png"] tag:3] autorelease],
+        [[[UITabBarItem alloc] initWithTitle:UCLocalize("SEARCH") image:[UIImage applicationImageNamed:@"search.png"] tag:4] autorelease],
+    nil] retain];
 
-    toolbar_ = [[UIToolbar alloc]
-        initInView:overlay_
-        withFrame:CGRectMake(
+    toolbar_ = [[UITabBar alloc]
+        initWithFrame:CGRectMake(
             0, screenrect.size.height - ButtonBarHeight_,
             screenrect.size.width, ButtonBarHeight_
         )
-        withItemList:buttonitems
     ];
 
+    [toolbar_ setItems:items_];
+
     [toolbar_ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin)];
     [overlay_ addSubview:toolbar_];
 
     [toolbar_ setDelegate:self];
-    [toolbar_ setBarStyle:1];
-    [toolbar_ setButtonBarTrackingMode:2];
 
-    int buttons[5] = {1, 2, 3, 4, 5};
+    /*int buttons[5] = {1, 2, 3, 4, 5};
     [toolbar_ registerButtonGroup:0 withButtons:buttons withCount:5];
     [toolbar_ showButtonGroup:0 withDuration:0];
 
@@ -8488,9 +8440,9 @@ static _finline void _setHomePage(Cydia *self) {
         )];
 
         [button setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];
-    }
+    }*/
 
-    [toolbar_ showSelectionForButton:1];
+    [toolbar_ setSelectedItem:[items_ objectAtIndex:0]];
 
     [UIKeyboard initImplementationNow];
     /*CGSize keysize = [UIKeyboard defaultSize];