summaryrefslogtreecommitdiff
path: root/MobileCydia.mm
diff options
context:
space:
mode:
authorGrant Paul <chpwn@chpwn.com>2010-12-11 22:29:21 -0800
committerGrant Paul <chpwn@chpwn.com>2010-12-11 22:29:21 -0800
commitdd5f81612e2906f740d09566145cd1be72a4c227 (patch)
treef2d0e2819c1022eda2cc9b24b17195d97f09b8c2 /MobileCydia.mm
parentc91ec661ac82421232122d5b1e4a62f74205ab58 (diff)
Factored out CYLoadingIndicator, fixed landscape launches wrt CYLoadingIndicator positioning.
Diffstat (limited to 'MobileCydia.mm')
-rw-r--r--MobileCydia.mm112
1 files changed, 72 insertions, 40 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm
index 139b55b..a3d0a83 100644
--- a/MobileCydia.mm
+++ b/MobileCydia.mm
@@ -3933,6 +3933,71 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
@end
/* }}} */
+/* @ Loading... Indicator {{{ */
+@interface CYLoadingIndicator : UIView {
+ UIActivityIndicatorView *spinner_;
+ UILabel *label_;
+ UIView *container_;
+}
+
+@property (readonly, nonatomic) UILabel *label;
+@property (readonly, nonatomic) UIActivityIndicatorView *activityIndicatorView;
+
+@end
+
+@implementation CYLoadingIndicator
+
+- (id)initWithFrame:(CGRect)frame {
+ if ((self = [super initWithFrame:frame])) {
+ container_ = [[[UIView alloc] init] autorelease];
+ [container_ setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin];
+
+ spinner_ = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] autorelease];
+ [spinner_ startAnimating];
+ [container_ addSubview:spinner_];
+
+ label_ = [[[UILabel alloc] init] autorelease];
+ [label_ setFont:[UIFont boldSystemFontOfSize:15.0f]];
+ [label_ setBackgroundColor:[UIColor clearColor]];
+ [label_ setTextColor:[UIColor blackColor]];
+ [label_ setShadowColor:[UIColor whiteColor]];
+ [label_ setShadowOffset:CGSizeMake(0, 1)];
+ [label_ setText:[NSString stringWithFormat:Elision_, UCLocalize("LOADING"), nil]];
+ [container_ addSubview:label_];
+
+ CGSize viewsize = frame.size;
+ CGSize spinnersize = [spinner_ bounds].size;
+ CGSize textsize = [[label_ text] sizeWithFont:[label_ font]];
+ float bothwidth = spinnersize.width + textsize.width + 5.0f;
+
+ CGRect containrect = {
+ CGPointMake(floorf((viewsize.width / 2) - (bothwidth / 2)), floorf((viewsize.height / 2) - (spinnersize.height / 2))),
+ CGSizeMake(bothwidth, spinnersize.height)
+ };
+ CGRect textrect = {
+ CGPointMake(spinnersize.width + 5.0f, floorf((spinnersize.height / 2) - (textsize.height / 2))),
+ textsize
+ };
+ CGRect spinrect = {
+ CGPointZero,
+ spinnersize
+ };
+
+ [container_ setFrame:containrect];
+ [spinner_ setFrame:spinrect];
+ [label_ setFrame:textrect];
+ [self addSubview:container_];
+ }
+
+ return self;
+}
+
+- (UILabel *)label { return label_; }
+- (UIActivityIndicatorView *)activityIndicatorView { return spinner_; }
+
+@end
+/* }}} */
+
/* Cydia Browser Controller {{{ */
@interface CYBrowserController : BrowserController {
CydiaObject *cydia_;
@@ -8867,47 +8932,14 @@ _trace();
return;
}
+ CGRect fixframe = [[tabbar_ view] frame];
+ if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
+ fixframe.size = CGSizeMake(fixframe.size.height, fixframe.size.width);
+ CYLoadingIndicator *loading = [[[CYLoadingIndicator alloc] initWithFrame:fixframe] autorelease];
+ [loading setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
+ [[tabbar_ view] addSubview:loading];
[window_ setUserInteractionEnabled:NO];
- UIView *container = [[[UIView alloc] init] autorelease];
- [container setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin];
-
- UIActivityIndicatorView *spinner = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] autorelease];
- [spinner startAnimating];
- [container addSubview:spinner];
-
- UILabel *label = [[[UILabel alloc] init] autorelease];
- [label setFont:[UIFont boldSystemFontOfSize:15.0f]];
- [label setBackgroundColor:[UIColor clearColor]];
- [label setTextColor:[UIColor blackColor]];
- [label setShadowColor:[UIColor whiteColor]];
- [label setShadowOffset:CGSizeMake(0, 1)];
- [label setText:[NSString stringWithFormat:Elision_, UCLocalize("LOADING"), nil]];
- [container addSubview:label];
-
- CGSize viewsize = [[tabbar_ view] frame].size;
- CGSize spinnersize = [spinner bounds].size;
- CGSize textsize = [[label text] sizeWithFont:[label font]];
- float bothwidth = spinnersize.width + textsize.width + 5.0f;
-
- CGRect containrect = {
- CGPointMake(floorf((viewsize.width / 2) - (bothwidth / 2)), floorf((viewsize.height / 2) - (spinnersize.height / 2))),
- CGSizeMake(bothwidth, spinnersize.height)
- };
- CGRect textrect = {
- CGPointMake(spinnersize.width + 5.0f, floorf((spinnersize.height / 2) - (textsize.height / 2))),
- textsize
- };
- CGRect spinrect = {
- CGPointZero,
- spinnersize
- };
-
- [container setFrame:containrect];
- [spinner setFrame:spinrect];
- [label setFrame:textrect];
- [[tabbar_ view] addSubview:container];
-
[self reloadData];
PrintTimes();
@@ -8926,7 +8958,7 @@ _trace();
// XXX: does this actually slow anything down?
[[tabbar_ view] setBackgroundColor:[UIColor clearColor]];
- [container removeFromSuperview];
+ [loading removeFromSuperview];
}
- (void) showActionSheet:(UIActionSheet *)sheet fromItem:(UIBarButtonItem *)item {