@end
/* }}} */
-@interface CYActionSheet : UIActionSheet {
+@interface CYActionSheet : UIAlertView {
unsigned button_;
}
@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 {
#define lprintf(args...) fprintf(stderr, args)
-#define ForRelease 1
+#define ForRelease 0
#define TraceLogging (1 && !ForRelease)
#define HistogramInsertionSort (0 && !ForRelease)
#define ProfileTimes (0 && !ForRelease)
#define IgnoreInstall (0 && !ForRelease)
#define RecycleWebViews 0
#define RecyclePackageViews (1 && ForRelease)
-#define AlwaysReload (0 && !ForRelease)
+#define AlwaysReload (1 && !ForRelease)
#if !TraceLogging
#undef _trace
- (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/"
];
}
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"]);
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];
[list_ addTableColumn:column];
[list_ setDelegate:self];
[list_ setReusesTableCells:YES];
+
+ [list_ setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
+ [self setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
} return self;
}
[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];
[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];
}
- (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 {
UIView *underlay_;
UIView *overlay_;
CYBook *book_;
- UIToolbar *toolbar_;
+
+ NSArray *items_;
+ UITabBar *toolbar_;
RVBook *confirm_;
Database *database_;
ProgressView *progress_;
- unsigned tag_;
+ int tag_;
UIKeyboard *keyboard_;
UIProgressHUD *hud_;
[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];
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?
}
Queuing_ = false;
- [toolbar_ setBadgeValue:nil forButton:4];
+ [[[toolbar_ items] objectAtIndex:3] setBadgeValue:nil];
[self _updateData];
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
}
[self _reloadData];
else {
Queuing_ = true;
- [toolbar_ setBadgeValue:UCLocalize("Q_D") forButton:4];
+ [[[toolbar_ items] objectAtIndex:3] setBadgeValue:UCLocalize("Q_D")];
[book_ reloadData];
}
- (RVPage *) pageForURL:(NSURL *)url hasTag:(int *)tag {
if (tag != NULL)
- tag = 0;
+ *tag = -1;
NSString *href([url absoluteString]);
if ([href hasPrefix:@"apptapp://package/"])
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_])];
}
}
Font18Bold_ = [[UIFont boldSystemFontOfSize:18] retain];
Font22Bold_ = [[UIFont boldSystemFontOfSize:22] retain];
- tag_ = 1;
+ tag_ = 0;
essential_ = [[NSMutableArray alloc] initWithCapacity:4];
broken_ = [[NSMutableArray alloc] initWithCapacity:4];
[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];
)];
[button setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];
- }
+ }*/
- [toolbar_ showSelectionForButton:1];
+ [toolbar_ setSelectedItem:[items_ objectAtIndex:0]];
[UIKeyboard initImplementationNow];
/*CGSize keysize = [UIKeyboard defaultSize];