]> git.saurik.com Git - cydia.git/commitdiff
Factored out CYLoadingIndicator, fixed landscape launches wrt CYLoadingIndicator...
authorGrant Paul <chpwn@chpwn.com>
Sun, 12 Dec 2010 06:29:21 +0000 (22:29 -0800)
committerGrant Paul <chpwn@chpwn.com>
Sun, 12 Dec 2010 06:29:21 +0000 (22:29 -0800)
MobileCydia.mm

index 139b55b8a15536d5ac32b8044f806baa4aabda60..a3d0a836c1526fd58c76e014856775ceea67821a 100644 (file)
@@ -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 {