@property (nonatomic, strong) UILabel *percentLabel; | @property (nonatomic, strong) UILabel *percentLabel; | ||||
@property (nonatomic, strong) UIImageView *glyphView; | @property (nonatomic, strong) UIImageView *glyphView; | ||||
@property (nonatomic, strong) _UIBatteryView *battery; | @property (nonatomic, strong) _UIBatteryView *battery; | ||||
@property (nonatomic, strong) NSLayoutConstraint *width; | |||||
@property (nonatomic, strong) NSLayoutConstraint *height; | |||||
-(instancetype)initWithFrame:(CGRect)arg1 device:(BCBatteryDevice *)device; | -(instancetype)initWithFrame:(CGRect)arg1 device:(BCBatteryDevice *)device; | ||||
-(void)updateInfo; | -(void)updateInfo; | ||||
@end | @end |
[self.label.rightAnchor constraintEqualToAnchor:self.battery.leftAnchor constant:-4.5].active = YES; | [self.label.rightAnchor constraintEqualToAnchor:self.battery.leftAnchor constant:-4.5].active = YES; | ||||
} | } | ||||
[self.heightAnchor constraintEqualToConstant:(bannerHeight + spacing)].active = YES; | |||||
[self.widthAnchor constraintEqualToConstant:(self.frame.size.width)].active = YES; | |||||
} | } | ||||
return self; | return self; | ||||
self.battery.chargePercent = (batteryPercentage*0.01); | self.battery.chargePercent = (batteryPercentage*0.01); | ||||
[self.glyphView setImage:[self.device glyph]]; | [self.glyphView setImage:[self.device glyph]]; | ||||
//[self.heightAnchor constraintEqualToConstant:(bannerHeight + spacing)].active = YES; | |||||
if(!self.height) { | |||||
self.height.active = NO; | |||||
self.height = [self.heightAnchor constraintEqualToConstant:(bannerHeight + spacing)]; | |||||
self.height.active = YES; | |||||
} else { | |||||
int height = (bannerHeight + spacing); | |||||
self.height.constant = height; | |||||
} | |||||
if(!self.width) { | |||||
self.width.active = NO; | |||||
self.width = [self.widthAnchor constraintEqualToConstant:(self.frame.size.width)]; | |||||
self.width.active = YES; | |||||
} //else { | |||||
//int width = self.frame.size.width; | |||||
//self.width.constant = width; | |||||
//} | |||||
} | } | ||||
@interface KAIBatteryStack : UIStackView | @interface KAIBatteryStack : UIStackView | ||||
@property (nonatomic, strong) NSMutableArray *displayingDevices; | |||||
@property (nonatomic, assign) NSInteger number; | @property (nonatomic, assign) NSInteger number; | ||||
@property (nonatomic, assign) NSInteger oldCountOfDevices; | @property (nonatomic, assign) NSInteger oldCountOfDevices; | ||||
@property (nonatomic, strong) NSLayoutConstraint *heightConstraint; | @property (nonatomic, strong) NSLayoutConstraint *heightConstraint; |
KAIBatteryStack *instance; | KAIBatteryStack *instance; | ||||
NSTimer *queueTimer = nil; | NSTimer *queueTimer = nil; | ||||
//NSMutableArray *showingCells = [[NSMutableArray alloc] init]; | |||||
@implementation KAIBatteryStack | @implementation KAIBatteryStack | ||||
self = [super init]; | self = [super init]; | ||||
instance = self; | instance = self; | ||||
if (self) { | if (self) { | ||||
self.displayingDevices = [[NSMutableArray alloc] init]; | |||||
self.axis = 1; | self.axis = 1; | ||||
self.distribution = 0; | self.distribution = 0; | ||||
self.spacing = 0; | self.spacing = 0; | ||||
self.oldCountOfDevices = -100; | self.oldCountOfDevices = -100; | ||||
self.queued = NO; | self.queued = NO; | ||||
[self updateBattery]; | [self updateBattery]; | ||||
//self.clipsToBounds = YES; | |||||
self.userInteractionEnabled = NO; | self.userInteractionEnabled = NO; | ||||
} | } | ||||
return self; | return self; | ||||
} | } | ||||
queueTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(dispatchQueue) userInfo:nil repeats:NO]; | queueTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(dispatchQueue) userInfo:nil repeats:NO]; | ||||
self.isUpdating = NO; | |||||
//self.isUpdating = NO; | |||||
} else if(self.isUpdating) { | } else if(self.isUpdating) { | ||||
self.queued = YES; | self.queued = YES; | ||||
self.heightConstraint.active = YES; | self.heightConstraint.active = YES; | ||||
} else { | } else { | ||||
int height; | |||||
if([self.superview.subviews objectAtIndex:([self.superview.subviews count] - 1)] == self) { | |||||
height = (self.number * (bannerHeight + spacing)); | |||||
} else { | |||||
height = (self.number * (bannerHeight + spacing)) - spacing; | |||||
} | |||||
int height = (self.number * (bannerHeight + spacing)) - spacing; | |||||
self.heightConstraint.constant = height; | self.heightConstraint.constant = height; | ||||
UIStackView *s = (UIStackView *)(self.superview); | UIStackView *s = (UIStackView *)(self.superview); |
if(self && self.kaiCell == nil) { | if(self && self.kaiCell == nil) { | ||||
self.kaiCell = [[KAIBatteryCell alloc] initWithFrame:CGRectMake(0,0,[KAIBatteryStack sharedInstance].frame.size.width,0) device:self]; } | self.kaiCell = [[KAIBatteryCell alloc] initWithFrame:CGRectMake(0,0,[KAIBatteryStack sharedInstance].frame.size.width,0) device:self]; } | ||||
((KAIBatteryCell *)self.kaiCell).translatesAutoresizingMaskIntoConstraints = NO; | ((KAIBatteryCell *)self.kaiCell).translatesAutoresizingMaskIntoConstraints = NO; | ||||
[((KAIBatteryCell *)self.kaiCell).heightAnchor constraintEqualToConstant:bannerHeight + spacing].active = YES; | |||||
[(KAIBatteryCell *)self.kaiCell updateInfo]; | [(KAIBatteryCell *)self.kaiCell updateInfo]; | ||||
return self.kaiCell; | return self.kaiCell; | ||||
-(void)resetKaiCellForNewPrefs { | -(void)resetKaiCellForNewPrefs { | ||||
self.kaiCell = [[KAIBatteryCell alloc] initWithFrame:CGRectMake(0,0,[KAIBatteryStack sharedInstance].frame.size.width,0) device:self]; | self.kaiCell = [[KAIBatteryCell alloc] initWithFrame:CGRectMake(0,0,[KAIBatteryStack sharedInstance].frame.size.width,0) device:self]; | ||||
((KAIBatteryCell *)self.kaiCell).translatesAutoresizingMaskIntoConstraints = NO; | ((KAIBatteryCell *)self.kaiCell).translatesAutoresizingMaskIntoConstraints = NO; | ||||
[((KAIBatteryCell *)self.kaiCell).heightAnchor constraintEqualToConstant:bannerHeight + spacing].active = YES; | |||||
[(KAIBatteryCell *)self.kaiCell updateInfo]; | [(KAIBatteryCell *)self.kaiCell updateInfo]; | ||||
} | } | ||||
%end | %end |
Package: com.burritoz.kai | Package: com.burritoz.kai | ||||
Name: Kai | Name: Kai | ||||
Version: 0.9.9~2 | |||||
Version: 0.9.9~3 | |||||
Architecture: iphoneos-arm | Architecture: iphoneos-arm | ||||
Description: Show charging banners on your lock screen! | Description: Show charging banners on your lock screen! | ||||
Maintainer: burrit0z | Maintainer: burrit0z |