From e4788921d1548a52b18100e1f06989bc3b4fb451 Mon Sep 17 00:00:00 2001 From: Burrit0z Date: Sat, 30 May 2020 19:11:50 -0400 Subject: [PATCH] still a bit buggy but much improved --- KAIBatteryCell.h | 2 -- KAIBatteryCell.mm | 26 +++----------------------- KAIBatteryStack.h | 1 - KAIBatteryStack.mm | 12 ++---------- Kai.xm | 4 ---- Layout/DEBIAN/control | 2 +- 6 files changed, 6 insertions(+), 41 deletions(-) diff --git a/KAIBatteryCell.h b/KAIBatteryCell.h index 66c3667..ae23be6 100755 --- a/KAIBatteryCell.h +++ b/KAIBatteryCell.h @@ -42,8 +42,6 @@ @property (nonatomic, strong) UILabel *percentLabel; @property (nonatomic, strong) UIImageView *glyphView; @property (nonatomic, strong) _UIBatteryView *battery; -@property (nonatomic, strong) NSLayoutConstraint *width; -@property (nonatomic, strong) NSLayoutConstraint *height; -(instancetype)initWithFrame:(CGRect)arg1 device:(BCBatteryDevice *)device; -(void)updateInfo; @end \ No newline at end of file diff --git a/KAIBatteryCell.mm b/KAIBatteryCell.mm index dbb9972..efa21a0 100755 --- a/KAIBatteryCell.mm +++ b/KAIBatteryCell.mm @@ -134,6 +134,9 @@ [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; @@ -176,29 +179,6 @@ self.battery.chargePercent = (batteryPercentage*0.01); [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; - //} } diff --git a/KAIBatteryStack.h b/KAIBatteryStack.h index 210a95f..941d02d 100755 --- a/KAIBatteryStack.h +++ b/KAIBatteryStack.h @@ -1,5 +1,4 @@ @interface KAIBatteryStack : UIStackView -@property (nonatomic, strong) NSMutableArray *displayingDevices; @property (nonatomic, assign) NSInteger number; @property (nonatomic, assign) NSInteger oldCountOfDevices; @property (nonatomic, strong) NSLayoutConstraint *heightConstraint; diff --git a/KAIBatteryStack.mm b/KAIBatteryStack.mm index 7752975..3401881 100755 --- a/KAIBatteryStack.mm +++ b/KAIBatteryStack.mm @@ -2,7 +2,6 @@ KAIBatteryStack *instance; NSTimer *queueTimer = nil; -//NSMutableArray *showingCells = [[NSMutableArray alloc] init]; @implementation KAIBatteryStack @@ -10,7 +9,6 @@ NSTimer *queueTimer = nil; self = [super init]; instance = self; if (self) { - self.displayingDevices = [[NSMutableArray alloc] init]; self.axis = 1; self.distribution = 0; self.spacing = 0; @@ -18,7 +16,6 @@ NSTimer *queueTimer = nil; self.oldCountOfDevices = -100; self.queued = NO; [self updateBattery]; - //self.clipsToBounds = YES; self.userInteractionEnabled = NO; } return self; @@ -89,7 +86,7 @@ long long lastPercentage; } queueTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(dispatchQueue) userInfo:nil repeats:NO]; - self.isUpdating = NO; + //self.isUpdating = NO; } else if(self.isUpdating) { self.queued = YES; @@ -116,12 +113,7 @@ long long lastPercentage; self.heightConstraint.active = YES; } 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; UIStackView *s = (UIStackView *)(self.superview); diff --git a/Kai.xm b/Kai.xm index 224b9a3..2aa4ccd 100755 --- a/Kai.xm +++ b/Kai.xm @@ -109,8 +109,6 @@ if(self && self.kaiCell == nil) { self.kaiCell = [[KAIBatteryCell alloc] initWithFrame:CGRectMake(0,0,[KAIBatteryStack sharedInstance].frame.size.width,0) device:self]; } ((KAIBatteryCell *)self.kaiCell).translatesAutoresizingMaskIntoConstraints = NO; - [((KAIBatteryCell *)self.kaiCell).heightAnchor constraintEqualToConstant:bannerHeight + spacing].active = YES; - [(KAIBatteryCell *)self.kaiCell updateInfo]; return self.kaiCell; @@ -120,8 +118,6 @@ -(void)resetKaiCellForNewPrefs { self.kaiCell = [[KAIBatteryCell alloc] initWithFrame:CGRectMake(0,0,[KAIBatteryStack sharedInstance].frame.size.width,0) device:self]; ((KAIBatteryCell *)self.kaiCell).translatesAutoresizingMaskIntoConstraints = NO; - [((KAIBatteryCell *)self.kaiCell).heightAnchor constraintEqualToConstant:bannerHeight + spacing].active = YES; - [(KAIBatteryCell *)self.kaiCell updateInfo]; } %end diff --git a/Layout/DEBIAN/control b/Layout/DEBIAN/control index bd7a75b..4539cee 100644 --- a/Layout/DEBIAN/control +++ b/Layout/DEBIAN/control @@ -1,6 +1,6 @@ Package: com.burritoz.kai Name: Kai -Version: 0.9.9~2 +Version: 0.9.9~3 Architecture: iphoneos-arm Description: Show charging banners on your lock screen! Maintainer: burrit0z