X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/7a11fbb993dd74d270f452507777595753458586..6995cc75744a56c2e552404a8de6181fd45ac562:/UICaboodle/BrowserView.mm diff --git a/UICaboodle/BrowserView.mm b/UICaboodle/BrowserView.mm index bacc40b2..2abc02ec 100644 --- a/UICaboodle/BrowserView.mm +++ b/UICaboodle/BrowserView.mm @@ -451,6 +451,8 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se if (title_ != nil) [title_ release]; + if ([loading_ count] != 0) + [delegate_ releaseNetworkActivityIndicator]; [loading_ release]; [reloaditem_ release]; @@ -636,7 +638,7 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se if ([scheme isEqualToString:@"mailto"]) [self _openMailToURL:url]; - CYViewController *page([delegate_ pageForURL:url hasTag:NULL]); + CYViewController *page([delegate_ pageForURL:url]); if (page == nil) { BrowserController *browser([[[class_ alloc] init] autorelease]); @@ -651,13 +653,11 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se [[self navigationController] pushViewController:page animated:YES]; } else { - UCNavigationController *navigation([[[UCNavigationController alloc] init] autorelease]); + UCNavigationController *navigation([[[UCNavigationController alloc] initWithRootViewController:page] autorelease]); [navigation setHook:indirect_]; [navigation setDelegate:delegate_]; - [navigation setViewControllers:[NSArray arrayWithObject:page]]; - [[page navigationItem] setLeftBarButtonItem:[[[UIBarButtonItem alloc] initWithTitle:UCLocalize("CLOSE") style:UIBarButtonItemStylePlain @@ -835,19 +835,13 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se [alert dismissWithClickedButtonIndex:-1 animated:YES]; } else if ([context isEqualToString:@"submit"]) { - switch (button) { - case 1: - break; - - case 2: - if (request_ != nil) { - WebThreadLock(); - [webview_ loadRequest:request_]; - WebThreadUnlock(); - } - break; - - _nodefault + if (button == [alert cancelButtonIndex]) { + } else if (button == [alert firstOtherButtonIndex]) { + if (request_ != nil) { + WebThreadLock(); + [webview_ loadRequest:request_]; + WebThreadUnlock(); + } } [alert dismissWithClickedButtonIndex:-1 animated:YES]; @@ -881,21 +875,43 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se [[self navigationItem] setTitle:UCLocalize("LOADING")]; } +- (void) layoutRightButton { + [[loadingitem_ view] addSubview:indicator_]; + [[loadingitem_ view] bringSubviewToFront:indicator_]; +} + - (void) applyRightButton { if ([self isLoading]) { [[self navigationItem] setRightBarButtonItem:loadingitem_ animated:YES]; - // XXX: why do we do this again here? (if we don't, just remove indicator_) - [[loadingitem_ view] addSubview:indicator_]; + [self performSelector:@selector(layoutRightButton) withObject:nil afterDelay:0]; + + [indicator_ startAnimating]; [self applyLoadingTitle]; - } else if (custom_ != nil) { - [[self navigationItem] setRightBarButtonItem:[self customButton] animated:YES]; } else { - [[self navigationItem] setRightBarButtonItem:[self rightButton] animated:YES]; + [indicator_ stopAnimating]; + + [[self navigationItem] setRightBarButtonItem:( + custom_ != nil ? [self customButton] : [self rightButton] + ) animated:YES]; } } +- (void) didStartLoading { + // Overridden in subclasses. +} + - (void) _didStartLoading { [self applyRightButton]; + + if ([loading_ count] != 1) + return; + + [delegate_ retainNetworkActivityIndicator]; + [self didStartLoading]; +} + +- (void) didFinishLoading { + // Overridden in subclasses. } - (void) _didFinishLoading { @@ -903,10 +919,10 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se return; [self applyRightButton]; + [[self navigationItem] setTitle:title_]; - // XXX: wtf? - if (![self isLoading]) - [[self navigationItem] setTitle:title_]; + [delegate_ releaseNetworkActivityIndicator]; + [self didFinishLoading]; } - (bool) isLoading { @@ -1005,8 +1021,6 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se indicator_ = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]; [indicator_ setFrame:CGRectMake(15, 5, [indicator_ frame].size.width, [indicator_ frame].size.height)]; - [indicator_ startAnimating]; - [[loadingitem_ view] addSubview:indicator_]; [webview_ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)]; [indicator_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];