1
0
mirror of https://github.com/Burrit0z/kai synced 2025-07-01 10:36:47 +00:00
This commit is contained in:
Burrit0z
2020-05-20 18:58:19 -04:00
parent 5f8b36d198
commit b461e525f5
7 changed files with 38 additions and 21 deletions

View File

@ -14,6 +14,7 @@
@interface MTMaterialView : UIView @interface MTMaterialView : UIView
@property (nonatomic, assign) BOOL recipeDynamic; @property (nonatomic, assign) BOOL recipeDynamic;
-(id)_initWithRecipe:(NSInteger)arg1 configuration:(NSInteger)arg2 initialWeighting:(CGFloat)arg3 scaleAdjustment:(id)arg4; -(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 @end
@interface BCBatteryDeviceController @interface BCBatteryDeviceController

View File

@ -7,14 +7,8 @@ KAIBattery *instance;
self = [super init]; self = [super init];
instance = self; instance = self;
if (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 updateBattery];
self.userInteractionEnabled = NO; self.userInteractionEnabled = NO;
//[self addSubview:self.batteryLabel];
} }
return self; return self;
} }
@ -56,7 +50,11 @@ long long lastPercentage;
if(shouldAdd) { if(shouldAdd) {
UIView *blank; UIView *blank;
if(bannerStyle==1) { 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) { } else if(bannerStyle==2) {
blank = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]]; blank = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]];
} else if(bannerStyle==3) { } else if(bannerStyle==3) {

4
Kai.h
View File

@ -47,6 +47,7 @@ BOOL enabled;
BOOL disableGlyphs; BOOL disableGlyphs;
BOOL hidePercent; BOOL hidePercent;
BOOL showAll; BOOL showAll;
BOOL belowMusic;
BOOL hideDeviceLabel; BOOL hideDeviceLabel;
NSInteger bannerStyle; NSInteger bannerStyle;
NSInteger bannerAlign; NSInteger bannerAlign;
@ -107,7 +108,7 @@ static void preferencesChanged()
enabled = boolValueForKey(@"enabled", YES); enabled = boolValueForKey(@"enabled", YES);
spacing = numberForValue(@"spacing", 5); spacing = numberForValue(@"spacing", 5);
glyphSize = numberForValue(@"glyphSize", 35); glyphSize = numberForValue(@"glyphSize", 30);
bannerHeight = numberForValue(@"bannerHeight", 80); bannerHeight = numberForValue(@"bannerHeight", 80);
cornerRadius = numberForValue(@"cornerRadius", 13); cornerRadius = numberForValue(@"cornerRadius", 13);
disableGlyphs = boolValueForKey(@"disableGlyphs", NO); disableGlyphs = boolValueForKey(@"disableGlyphs", NO);
@ -118,6 +119,7 @@ static void preferencesChanged()
hideDeviceLabel = boolValueForKey(@"hideDeviceLabel", NO); hideDeviceLabel = boolValueForKey(@"hideDeviceLabel", NO);
bannerAlign = numberForValue(@"bannerAlign", 2); bannerAlign = numberForValue(@"bannerAlign", 2);
horizontalOffset = numberForValue(@"horizontalOffset", 0); horizontalOffset = numberForValue(@"horizontalOffset", 0);
belowMusic = boolValueForKey(@"belowMusic", NO);
if(disableGlyphs) { if(disableGlyphs) {
glyphSize = 0; glyphSize = 0;

18
Kai.xm
View File

@ -5,7 +5,11 @@
-(void)_layoutStackView { -(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]; [self KaiUpdate];
@ -42,14 +46,12 @@
if(!battery.heightConstraint) { if(!battery.heightConstraint) {
battery.heightConstraint.active = NO; battery.heightConstraint.active = NO;
NSLog(@"kai: 1st time, assigning to %d", 500); battery.heightConstraint = [battery.heightAnchor constraintEqualToConstant:85];
battery.heightConstraint = [battery.heightAnchor constraintEqualToConstant:500];
battery.heightConstraint.active = YES; battery.heightConstraint.active = YES;
} else { } else {
int height = (battery.number * (bannerHeight + spacing)); int height = (battery.number * ((bannerHeight + spacing) - spacing + 5));
battery.heightConstraint.active = NO; battery.heightConstraint.active = NO;
NSLog(@"kai: setting to %d", height);
battery.heightConstraint.constant = height; battery.heightConstraint.constant = height;
battery.heightConstraint.active = YES; battery.heightConstraint.active = YES;
@ -104,12 +106,14 @@
%hook CSBatteryChargingView %hook CSBatteryChargingView
+(id)batteryChargingViewWithSingleBattery { +(id)batteryChargingViewWithSingleBattery {
//NSLog(@"kai: here bro: %@", [NSThread callStackSymbols]); NSLog(@"kai: here bro: %@", [NSThread callStackSymbols]);
//[UIPasteboard generalPasteboard].string = [NSString stringWithFormat:@"kai: here bro: %@", [NSThread callStackSymbols]]; [UIPasteboard generalPasteboard].string = [NSString stringWithFormat:@"kai: here bro: %@", [NSThread callStackSymbols]];
return nil; return nil;
} }
+(id)batteryChargingViewWithDoubleBattery { +(id)batteryChargingViewWithDoubleBattery {
NSLog(@"kai: here bro: %@", [NSThread callStackSymbols]);
[UIPasteboard generalPasteboard].string = [NSString stringWithFormat:@"kai: here bro: %@", [NSThread callStackSymbols]];
return nil; return nil;
} }

View File

@ -1,6 +1,6 @@
Package: com.burritoz.kai Package: com.burritoz.kai
Name: Kai Name: Kai
Version: 0.1.1~alpha Version: 0.1.2~alpha
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

View File

@ -70,7 +70,7 @@ NSBundle *tweakBundle;
CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.burritoz.kaiprefs/reload"), nil, nil, true); CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.burritoz.kaiprefs/reload"), nil, nil, true);
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Kai" 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]; preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"Amazing!" style:UIAlertActionStyleDefault UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"Amazing!" style:UIAlertActionStyleDefault

View File

@ -132,6 +132,18 @@
<string>Right</string> <string>Right</string>
</array> </array>
</dict> </dict>
<dict>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
<false/>
<key>defaults</key>
<string>com.burritoz.kaiprefs</string>
<key>key</key>
<string>belowMusic</string>
<key>label</key>
<string>Show kai Below Music</string>
</dict>
<dict> <dict>
<key>cell</key> <key>cell</key>
<string>PSGroupCell</string> <string>PSGroupCell</string>
@ -232,17 +244,17 @@
<key>cell</key> <key>cell</key>
<string>PSGroupCell</string> <string>PSGroupCell</string>
<key>label</key> <key>label</key>
<string>Glyph Size (35)</string> <string>Glyph Size (30)</string>
</dict> </dict>
<dict> <dict>
<key>default</key> <key>default</key>
<real>35</real> <real>30</real>
<key>cell</key> <key>cell</key>
<string>PSSliderCell</string> <string>PSSliderCell</string>
<key>min</key> <key>min</key>
<real>10</real> <real>10</real>
<key>max</key> <key>max</key>
<real>100</real> <real>60</real>
<key>isSegmented</key> <key>isSegmented</key>
<false/> <false/>
<key>showValue</key> <key>showValue</key>