@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 |
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; | ||||
} | } | ||||
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) { |
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; | ||||
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); | ||||
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; |
-(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]; | ||||
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:500]; | |||||
battery.heightConstraint = [battery.heightAnchor constraintEqualToConstant:85]; | |||||
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; | ||||
%hook CSBatteryChargingView | %hook CSBatteryChargingView | ||||
+(id)batteryChargingViewWithSingleBattery { | +(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; | 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; | ||||
} | } | ||||
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 |
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 | ||||
handler:^(UIAlertAction * action) {}]; | handler:^(UIAlertAction * action) {}]; | ||||
[alert addAction:defaultAction]; | [alert addAction:defaultAction]; | ||||
[self presentViewController:alert animated:YES completion:nil]; | [self presentViewController:alert animated:YES completion:nil]; | ||||
} | } | ||||
<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> | ||||
<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> |