mirror of
https://github.com/Burrit0z/kai
synced 2025-07-01 13:46:47 +00:00
work
This commit is contained in:
@ -7,11 +7,11 @@ KAIBattery *instance;
|
|||||||
self = [super initWithFrame:arg1];
|
self = [super initWithFrame:arg1];
|
||||||
instance = self;
|
instance = self;
|
||||||
if (self) {
|
if (self) {
|
||||||
/*self.batteryLabel = [[UILabel alloc]initWithFrame:CGRectMake(25,-10,220,120)];
|
/*self.translatesAutoresizingMaskIntoConstraints = NO;
|
||||||
[self.batteryLabel setFont:[UIFont systemFontOfSize:13]];
|
[self.leftAnchor constraintEqualToAnchor:self.leftAnchor constant:8].active = YES;
|
||||||
[self.batteryLabel setTextColor:[UIColor whiteColor]];
|
[self.topAnchor constraintEqualToAnchor:self.topAnchor constant:arg1.origin.y].active = YES;
|
||||||
self.batteryLabel.lineBreakMode = NSLineBreakByWordWrapping;
|
[self.widthAnchor constraintEqualToConstant:UIScreen.mainScreen.bounds.size.width - 16].active = YES;
|
||||||
self.batteryLabel.numberOfLines = 0;*/
|
[self.heightAnchor constraintEqualToConstant:(self.number * 85)].active = YES;*/
|
||||||
[self updateBattery];
|
[self updateBattery];
|
||||||
[self darkLightMode];
|
[self darkLightMode];
|
||||||
self.userInteractionEnabled = NO;
|
self.userInteractionEnabled = NO;
|
||||||
@ -46,7 +46,7 @@ long long lastPercentage;
|
|||||||
BOOL charging = MSHookIvar<long long>(device, "_charging");
|
BOOL charging = MSHookIvar<long long>(device, "_charging");
|
||||||
BOOL LPM = MSHookIvar<BOOL>(device, "_batterySaverModeActive");
|
BOOL LPM = MSHookIvar<BOOL>(device, "_batterySaverModeActive");
|
||||||
|
|
||||||
if(charging) {
|
if(charging || !charging) {
|
||||||
|
|
||||||
UIVisualEffectView *blank;
|
UIVisualEffectView *blank;
|
||||||
if(@available(iOS 12.0, *)) {
|
if(@available(iOS 12.0, *)) {
|
||||||
@ -58,7 +58,7 @@ long long lastPercentage;
|
|||||||
} else {
|
} else {
|
||||||
blank = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
|
blank = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
|
||||||
}
|
}
|
||||||
blank.frame = CGRectMake(0, 0 + y, self.frame.size.width, 80);
|
blank.frame = CGRectMake(0, 0 + y, UIScreen.mainScreen.bounds.size.width - 16, 80);
|
||||||
blank.layer.masksToBounds = YES;
|
blank.layer.masksToBounds = YES;
|
||||||
blank.layer.cornerRadius = 13;
|
blank.layer.cornerRadius = 13;
|
||||||
//[blank setBackgroundColor:[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1]];
|
//[blank setBackgroundColor:[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1]];
|
||||||
@ -95,8 +95,8 @@ long long lastPercentage;
|
|||||||
glyphView.contentMode = UIViewContentModeScaleAspectFit;
|
glyphView.contentMode = UIViewContentModeScaleAspectFit;
|
||||||
[glyphView setImage:glyph];
|
[glyphView setImage:glyph];
|
||||||
|
|
||||||
label.frame = CGRectMake(57.5,27.5 + y,275,25);
|
label.frame = CGRectMake(65.5,27.5 + y,275,25);
|
||||||
glyphView.frame = CGRectMake(12.5,18.5 + y,40,40);
|
glyphView.frame = CGRectMake(20.5,18.5 + y,40,40);
|
||||||
battery.frame = CGRectMake(310,35 + y,20,10);
|
battery.frame = CGRectMake(310,35 + y,20,10);
|
||||||
percentLabel.frame = CGRectMake(265,35 + y,36,12);
|
percentLabel.frame = CGRectMake(265,35 + y,36,12);
|
||||||
|
|
||||||
@ -111,6 +111,7 @@ long long lastPercentage;
|
|||||||
//blank.alpha = 0.8;
|
//blank.alpha = 0.8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[self.heightAnchor constraintEqualToConstant:(self.number * 85)].active = YES;
|
||||||
self.isUpdating = NO;
|
self.isUpdating = NO;
|
||||||
[self darkLightMode];
|
[self darkLightMode];
|
||||||
}
|
}
|
||||||
|
92
Kai.xm
92
Kai.xm
@ -12,9 +12,11 @@
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
@interface CSAdjunctListView : UIView
|
@interface CSAdjunctListView : UIView
|
||||||
@property (nonatomic, strong) KAIBattery *battery;
|
@property (nonatomic, strong) KAIBattery *batteryView;
|
||||||
@property (nonatomic, assign) BOOL hasKai;
|
@property (nonatomic, assign) BOOL hasKai;
|
||||||
@property (nonatomic, assign) NSInteger previousKaiCount;
|
@property (nonatomic, assign) NSInteger previousKaiCount;
|
||||||
|
-(UIView *)stackView;
|
||||||
|
-(void)setStackView:(UIStackView *)arg1;
|
||||||
-(void)KaiUpdate;
|
-(void)KaiUpdate;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -25,76 +27,98 @@
|
|||||||
@interface _CSSingleBatteryChargingView : UIView
|
@interface _CSSingleBatteryChargingView : UIView
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/*
|
|
||||||
@interface NCNotificationListView : UIView
|
@interface NCNotificationListView : UIView
|
||||||
@property (nonatomic, assign) BOOL hasKai;
|
@end
|
||||||
@property (nonatomic, assign) NSInteger previousKaiCount;
|
|
||||||
@end*/
|
|
||||||
|
|
||||||
BOOL setFrame = NO;
|
BOOL setFrame = NO;
|
||||||
CGRect original;
|
CGRect original = CGRectMake(0,0,0,0);
|
||||||
CGRect originalBattery;
|
CGRect originalBattery;
|
||||||
|
|
||||||
|
|
||||||
%hook CSAdjunctListView
|
%hook CSAdjunctListView
|
||||||
%property (nonatomic, strong) KAIBattery *battery;
|
%property (nonatomic, strong) KAIBattery *batteryView;
|
||||||
%property (nonatomic, assign) BOOL hasKai;
|
%property (nonatomic, assign) BOOL hasKai;
|
||||||
%property (nonatomic, assign) NSInteger previousKaiCount;
|
%property (nonatomic, assign) NSInteger previousKaiCount;
|
||||||
|
|
||||||
-(void)layoutSubviews {
|
-(void)_layoutStackView {
|
||||||
|
NSLog(@"Kai: Laying out stack view");
|
||||||
//%orig;
|
//%orig;
|
||||||
|
|
||||||
if(!self.hasKai) {
|
if(!self.hasKai) {
|
||||||
original = self.superview.superview.frame;
|
//original = self.superview.superview.frame;
|
||||||
self.battery = [[KAIBattery alloc] initWithFrame:CGRectMake(8, 0, self.frame.size.width - 16, UIScreen.mainScreen.bounds.size.width)];
|
self.batteryView = [[KAIBattery alloc] initWithFrame:CGRectMake(UIScreen.mainScreen.bounds.origin.x, 0, UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height)];
|
||||||
originalBattery = self.battery.frame;
|
originalBattery = self.batteryView.frame;
|
||||||
[self addSubview:self.battery];
|
//[[self stackView] addSubview:self.batteryView];
|
||||||
setFrame = YES;
|
setFrame = YES;
|
||||||
self.previousKaiCount = 0;
|
self.previousKaiCount = 0;
|
||||||
self.hasKai = YES;
|
self.hasKai = YES;
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
selector:@selector(KaiUpdate)
|
selector:@selector(KaiInfo)
|
||||||
name:@"KaiInfoChanged"
|
name:@"KaiInfoChanged"
|
||||||
object:nil];
|
object:nil];
|
||||||
[self.battery darkLightMode];
|
[self.batteryView darkLightMode];
|
||||||
|
//[self setStackView:self.batteryView];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self KaiUpdate];
|
[self KaiUpdate];
|
||||||
|
|
||||||
return %orig;
|
%orig;
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)setStackView:(UIStackView *)arg1 {
|
||||||
|
NSLog(@"Kai: Updating setting stack view");
|
||||||
|
|
||||||
|
if(!self.hasKai) {
|
||||||
|
//original = self.superview.superview.frame;
|
||||||
|
self.batteryView = [[KAIBattery alloc] initWithFrame:CGRectMake(0, 0, UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height)];
|
||||||
|
originalBattery = self.batteryView.frame;
|
||||||
|
//[[self stackView] addSubview:self.batteryView];
|
||||||
|
setFrame = YES;
|
||||||
|
self.previousKaiCount = 0;
|
||||||
|
self.hasKai = YES;
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(KaiInfo)
|
||||||
|
name:@"KaiInfoChanged"
|
||||||
|
object:nil];
|
||||||
|
[self.batteryView darkLightMode];
|
||||||
|
//[self setStackView:self.batteryView];
|
||||||
|
}
|
||||||
|
|
||||||
|
UIStackView *newView = arg1;
|
||||||
|
|
||||||
|
if(![arg1.subviews containsObject:self.batteryView]) {
|
||||||
|
//[newView addSubview:self.batteryView];
|
||||||
|
[newView addArrangedSubview:self.batteryView];
|
||||||
|
}
|
||||||
|
newView.frame = CGRectMake(newView.frame.origin.x, newView.frame.origin.y, newView.frame.size.width, newView.frame.size.height + self.batteryView.frame.size.height);
|
||||||
|
original = newView.frame;
|
||||||
|
%orig(newView);
|
||||||
}
|
}
|
||||||
|
|
||||||
%new
|
%new
|
||||||
-(void)KaiUpdate {
|
-(void)KaiUpdate {
|
||||||
if(self.battery) {
|
NSLog(@"Kai: Updating Pos.");
|
||||||
|
|
||||||
[self.battery updateBattery];
|
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
|
||||||
[UIView animateWithDuration:0.3 animations:^{
|
[UIView animateWithDuration:0.3 animations:^{
|
||||||
|
|
||||||
//self.translatesAutoresizingMaskIntoConstraints = NO;
|
self.batteryView.frame = CGRectMake(UIScreen.mainScreen.bounds.origin.x, 0, UIScreen.mainScreen.bounds.size.width, (self.batteryView.number * 85));
|
||||||
// [self.topAnchor constraintEqualToAnchor:self.superview.topAnchor constant:(self.battery.number * 85)].active = YES;
|
self.batteryView.hidden = YES;
|
||||||
|
self.batteryView.hidden = NO;
|
||||||
|
//self.batteryView.superview.frame = CGRectMake(original.origin.x, original.origin.y, original.size.width, original.size.height + (self.batteryView.number * 85));
|
||||||
|
|
||||||
self.superview.superview.frame = CGRectMake(
|
|
||||||
original.origin.x,
|
|
||||||
original.origin.y + (self.battery.number * 85),
|
|
||||||
original.size.width,
|
|
||||||
original.size.height
|
|
||||||
);
|
|
||||||
|
|
||||||
/*self.battery.frame = CGRectMake(
|
|
||||||
originalBattery.origin.x,
|
|
||||||
originalBattery.origin.y - (self.battery.number * 85),
|
|
||||||
originalBattery.size.width,
|
|
||||||
originalBattery.size.height
|
|
||||||
);*/
|
|
||||||
}];
|
}];
|
||||||
[self.battery darkLightMode];
|
[self.batteryView darkLightMode];
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%new
|
||||||
|
-(void)KaiInfo {
|
||||||
|
NSLog(@"Kai: Updating Info");
|
||||||
|
[self.batteryView updateBattery];
|
||||||
|
[self KaiUpdate];
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
2
control
2
control
@ -1,6 +1,6 @@
|
|||||||
Package: com.burritoz.kai
|
Package: com.burritoz.kai
|
||||||
Name: Kai
|
Name: Kai
|
||||||
Version: 0.0.1
|
Version: 0.0.2
|
||||||
Architecture: iphoneos-arm
|
Architecture: iphoneos-arm
|
||||||
Description: An awesome MobileSubstrate tweak!
|
Description: An awesome MobileSubstrate tweak!
|
||||||
Maintainer: burrit0z
|
Maintainer: burrit0z
|
||||||
|
Reference in New Issue
Block a user