From b461e525f5bcd4beeb9dbc239f66729b731df411 Mon Sep 17 00:00:00 2001 From: Burrit0z Date: Wed, 20 May 2020 18:58:19 -0400 Subject: [PATCH] yes bro --- KAIBattery.h | 1 + KAIBattery.mm | 12 +++++------- Kai.h | 4 +++- Kai.xm | 18 +++++++++++------- control | 2 +- kaiprefs/KAIRootListController.m | 4 ++-- kaiprefs/Resources/Root.plist | 18 +++++++++++++++--- 7 files changed, 38 insertions(+), 21 deletions(-) diff --git a/KAIBattery.h b/KAIBattery.h index 5c823ea..20a7c94 100644 --- a/KAIBattery.h +++ b/KAIBattery.h @@ -14,6 +14,7 @@ @interface MTMaterialView : UIView @property (nonatomic, assign) BOOL recipeDynamic; -(id)_initWithRecipe:(NSInteger)arg1 configuration:(NSInteger)arg2 initialWeighting:(CGFloat)arg3 scaleAdjustment:(id)arg4; ++(id)materialViewWithRecipe:(NSInteger)arg1 options:(NSInteger)arg2 initialWeighting:(CGFloat)arg3 scaleAdjustment:(id)arg4; @end @interface BCBatteryDeviceController diff --git a/KAIBattery.mm b/KAIBattery.mm index 4d913d0..4372636 100644 --- a/KAIBattery.mm +++ b/KAIBattery.mm @@ -7,14 +7,8 @@ KAIBattery *instance; self = [super init]; instance = self; if (self) { - /*self.translatesAutoresizingMaskIntoConstraints = NO; - [self.leftAnchor constraintEqualToAnchor:self.leftAnchor constant:8].active = YES; - [self.topAnchor constraintEqualToAnchor:self.topAnchor constant:arg1.origin.y].active = YES; - [self.widthAnchor constraintEqualToConstant:UIScreen.mainScreen.bounds.size.width - 16].active = YES; - [self.heightAnchor constraintEqualToConstant:(self.number * 85)].active = YES;*/ [self updateBattery]; self.userInteractionEnabled = NO; - //[self addSubview:self.batteryLabel]; } return self; } @@ -56,7 +50,11 @@ long long lastPercentage; if(shouldAdd) { UIView *blank; if(bannerStyle==1) { - blank = [[[objc_getClass("MTMaterialView") class] alloc] _initWithRecipe:1 configuration:1 initialWeighting:1 scaleAdjustment:nil]; + if(kCFCoreFoundationVersionNumber > 1600) { + blank = [[[objc_getClass("MTMaterialView") class] alloc] _initWithRecipe:1 configuration:1 initialWeighting:1 scaleAdjustment:nil]; + } else if(kCFCoreFoundationVersionNumber < 1600) { + blank = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]]; + } } else if(bannerStyle==2) { blank = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]]; } else if(bannerStyle==3) { diff --git a/Kai.h b/Kai.h index 0b96558..8323ceb 100644 --- a/Kai.h +++ b/Kai.h @@ -47,6 +47,7 @@ BOOL enabled; BOOL disableGlyphs; BOOL hidePercent; BOOL showAll; +BOOL belowMusic; BOOL hideDeviceLabel; NSInteger bannerStyle; NSInteger bannerAlign; @@ -107,7 +108,7 @@ static void preferencesChanged() enabled = boolValueForKey(@"enabled", YES); spacing = numberForValue(@"spacing", 5); - glyphSize = numberForValue(@"glyphSize", 35); + glyphSize = numberForValue(@"glyphSize", 30); bannerHeight = numberForValue(@"bannerHeight", 80); cornerRadius = numberForValue(@"cornerRadius", 13); disableGlyphs = boolValueForKey(@"disableGlyphs", NO); @@ -118,6 +119,7 @@ static void preferencesChanged() hideDeviceLabel = boolValueForKey(@"hideDeviceLabel", NO); bannerAlign = numberForValue(@"bannerAlign", 2); horizontalOffset = numberForValue(@"horizontalOffset", 0); + belowMusic = boolValueForKey(@"belowMusic", NO); if(disableGlyphs) { glyphSize = 0; diff --git a/Kai.xm b/Kai.xm index 90536b7..88eeae5 100644 --- a/Kai.xm +++ b/Kai.xm @@ -5,7 +5,11 @@ -(void)_layoutStackView { - //NSLog(@"Kai: Laying out stack view"); + NSInteger lastSlot = [[self stackView].subviews count] -1; + if([[self stackView].subviews objectAtIndex:lastSlot] != [KAIBattery sharedInstance] && belowMusic) { + [[self stackView] removeArrangedSubview:[KAIBattery sharedInstance]]; + [[self stackView] insertArrangedSubview:[KAIBattery sharedInstance] atIndex:lastSlot]; + } [self KaiUpdate]; @@ -42,14 +46,12 @@ if(!battery.heightConstraint) { battery.heightConstraint.active = NO; - NSLog(@"kai: 1st time, assigning to %d", 500); - battery.heightConstraint = [battery.heightAnchor constraintEqualToConstant:500]; + battery.heightConstraint = [battery.heightAnchor constraintEqualToConstant:85]; battery.heightConstraint.active = YES; } else { - int height = (battery.number * (bannerHeight + spacing)); + int height = (battery.number * ((bannerHeight + spacing) - spacing + 5)); battery.heightConstraint.active = NO; - NSLog(@"kai: setting to %d", height); battery.heightConstraint.constant = height; battery.heightConstraint.active = YES; @@ -104,12 +106,14 @@ %hook CSBatteryChargingView +(id)batteryChargingViewWithSingleBattery { - //NSLog(@"kai: here bro: %@", [NSThread callStackSymbols]); - //[UIPasteboard generalPasteboard].string = [NSString stringWithFormat:@"kai: here bro: %@", [NSThread callStackSymbols]]; + NSLog(@"kai: here bro: %@", [NSThread callStackSymbols]); + [UIPasteboard generalPasteboard].string = [NSString stringWithFormat:@"kai: here bro: %@", [NSThread callStackSymbols]]; return nil; } +(id)batteryChargingViewWithDoubleBattery { + NSLog(@"kai: here bro: %@", [NSThread callStackSymbols]); + [UIPasteboard generalPasteboard].string = [NSString stringWithFormat:@"kai: here bro: %@", [NSThread callStackSymbols]]; return nil; } diff --git a/control b/control index 41ce080..99530b3 100644 --- a/control +++ b/control @@ -1,6 +1,6 @@ Package: com.burritoz.kai Name: Kai -Version: 0.1.1~alpha +Version: 0.1.2~alpha Architecture: iphoneos-arm Description: Show charging banners on your lock screen! Maintainer: burrit0z diff --git a/kaiprefs/KAIRootListController.m b/kaiprefs/KAIRootListController.m index f0aad49..b547d3f 100644 --- a/kaiprefs/KAIRootListController.m +++ b/kaiprefs/KAIRootListController.m @@ -70,13 +70,13 @@ NSBundle *tweakBundle; CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.burritoz.kaiprefs/reload"), nil, nil, true); UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Kai" - message:@"Your settings have been applied. You can now go back to your lockscreen (CoverSheet) to see the changes." + message:@"Your settings have been applied. You can now go back to your lockscreen (CoverSheet) to see the changes. \n Note the option to put kai below music requires a respring." preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"Amazing!" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {}]; [alert addAction:defaultAction]; - + [self presentViewController:alert animated:YES completion:nil]; } diff --git a/kaiprefs/Resources/Root.plist b/kaiprefs/Resources/Root.plist index 195ebac..9509dd4 100644 --- a/kaiprefs/Resources/Root.plist +++ b/kaiprefs/Resources/Root.plist @@ -132,6 +132,18 @@ Right + + cell + PSSwitchCell + default + + defaults + com.burritoz.kaiprefs + key + belowMusic + label + Show kai Below Music + cell PSGroupCell @@ -232,17 +244,17 @@ cell PSGroupCell label - Glyph Size (35) + Glyph Size (30) default - 35 + 30 cell PSSliderCell min 10 max - 100 + 60 isSegmented showValue