Browse Source

KOV

pull/1/head
Burrit0z 4 years ago
parent
commit
b126746a46
3 changed files with 45 additions and 11 deletions
  1. +1
    -1
      KAIBattery.h
  2. +24
    -7
      KAIBattery.mm
  3. +20
    -3
      Kai.xm

+ 1
- 1
KAIBattery.h View File

+(id)sharedInstance; +(id)sharedInstance;
@end @end


@interface BCBatteryDevice : BCBatteryDeviceController
@interface BCBatteryDevice : NSObject
-(id)glyph; -(id)glyph;
@end @end



+ 24
- 7
KAIBattery.mm View File

BCBatteryDeviceController *bcb = [BCBatteryDeviceController sharedInstance]; BCBatteryDeviceController *bcb = [BCBatteryDeviceController sharedInstance];
NSArray *devices = MSHookIvar<NSArray *>(bcb, "_sortedDevices"); NSArray *devices = MSHookIvar<NSArray *>(bcb, "_sortedDevices");


for( UIView *view in self.subviews ) {
@try {
[view removeFromSuperview];
} @catch (NSException *exception) {
//Panik
}
}

for (BCBatteryDevice *device in devices) { for (BCBatteryDevice *device in devices) {
NSString *deviceName = MSHookIvar<NSString *>(device, "_name"); NSString *deviceName = MSHookIvar<NSString *>(device, "_name");
double batteryPercentage = MSHookIvar<long long>(device, "_percentCharge"); double batteryPercentage = MSHookIvar<long long>(device, "_percentCharge");
blank.frame = CGRectMake(0, 0 + y, self.frame.size.width, 80); blank.frame = CGRectMake(0, 0 + y, self.frame.size.width, 80);
blank.layer.masksToBounds = YES; blank.layer.masksToBounds = YES;
blank.layer.cornerRadius = 13; blank.layer.cornerRadius = 13;
blank.alpha = 0.8;
blank.alpha = 0;
//[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]];
[self addSubview:blank];


NSString *labelText = [NSString stringWithFormat:@"%@", deviceName]; NSString *labelText = [NSString stringWithFormat:@"%@", deviceName];


[label setTextColor:[UIColor whiteColor]]; [label setTextColor:[UIColor whiteColor]];
label.lineBreakMode = NSLineBreakByWordWrapping; label.lineBreakMode = NSLineBreakByWordWrapping;
label.numberOfLines = 0; label.numberOfLines = 0;
label.alpha = 0;
[label setText:labelText]; [label setText:labelText];


[self addSubview:label];

_UIBatteryView *battery = [[_UIBatteryView alloc] init]; _UIBatteryView *battery = [[_UIBatteryView alloc] init];
battery.chargePercent = (batteryPercentage*0.01); battery.chargePercent = (batteryPercentage*0.01);
UILabel *percentLabel = [[UILabel alloc] init]; UILabel *percentLabel = [[UILabel alloc] init];
percentLabel.alpha = 0;
battery.alpha = 0;
battery.showsPercentage = NO; battery.showsPercentage = NO;
[percentLabel setFont:[UIFont systemFontOfSize:14]]; [percentLabel setFont:[UIFont systemFontOfSize:14]];
[percentLabel setTextColor:[UIColor whiteColor]]; [percentLabel setTextColor:[UIColor whiteColor]];
[percentLabel setTextAlignment:NSTextAlignmentRight]; [percentLabel setTextAlignment:NSTextAlignmentRight];
percentLabel.numberOfLines = 0; percentLabel.numberOfLines = 0;
[percentLabel setText:[NSString stringWithFormat:@"%ld%%", (long)((NSInteger) batteryPercentage)]]; [percentLabel setText:[NSString stringWithFormat:@"%ld%%", (long)((NSInteger) batteryPercentage)]];
[self addSubview:percentLabel];
if(charging) battery.chargingState = 1; if(charging) battery.chargingState = 1;
battery.showsInlineChargingIndicator = YES; battery.showsInlineChargingIndicator = YES;
if(LPM) battery.saverModeActive = YES; if(LPM) battery.saverModeActive = YES;
[battery setBodyColorAlpha:1.0]; [battery setBodyColorAlpha:1.0];
[battery setPinColorAlpha:1.0]; [battery setPinColorAlpha:1.0];
} }
[self addSubview:battery];


UIImage *glyph = [device glyph]; UIImage *glyph = [device glyph];
UIImageView *glyphView = [[UIImageView alloc] init]; UIImageView *glyphView = [[UIImageView alloc] init];
glyphView.alpha = 0;
glyphView.contentMode = UIViewContentModeScaleAspectFit; glyphView.contentMode = UIViewContentModeScaleAspectFit;
[glyphView setImage:glyph]; [glyphView setImage:glyph];
[self addSubview:glyphView];


label.frame = CGRectMake(57.5,27.5 + y,275,25); label.frame = CGRectMake(57.5,27.5 + y,275,25);
glyphView.frame = CGRectMake(12.5,18.5 + y,40,40); glyphView.frame = CGRectMake(12.5,18.5 + y,40,40);


y+=85; y+=85;
self.number +=1; self.number +=1;

[self addSubview:blank];
[self addSubview:percentLabel];
[self addSubview:label];
[self addSubview:battery];
[self addSubview:glyphView];
blank.alpha = 0.8;
percentLabel.alpha = 1;
battery.alpha = 1;
label.alpha = 1;
glyphView.alpha = 1;
} }
} }
self.isUpdating = NO; self.isUpdating = NO;

+ 20
- 3
Kai.xm View File

} }


%end*/ %end*/
/*
%hook SBCoverSheetPrimarySlidingViewController %hook SBCoverSheetPrimarySlidingViewController


-(void)viewWillAppear:(BOOL)arg1 { -(void)viewWillAppear:(BOOL)arg1 {
[batteryWidget.battery updateBattery]; [batteryWidget.battery updateBattery];
[batteryWidget KaiUpdate]; [batteryWidget KaiUpdate];
}*/ }*/
%end
//%end




%hook CSMainPageView %hook CSMainPageView
setFrame = YES; setFrame = YES;
batteryWidget = self; batteryWidget = self;
} }
[self.battery updateBattery];
[self KaiUpdate]; [self KaiUpdate];


} }
originalBattery.size.height originalBattery.size.height
); );
} }
%end

%hook BCBatteryDevice

- (id)initWithIdentifier:(id)arg1 vendor:(long long)arg2 productIdentifier:(long long)arg3 parts:(unsigned long long)arg4 matchIdentifier:(id)arg5 {

[self addObserver:self forKeyPath:@"name" options:NSKeyValueObservingOptionNew context:nil];
[self addObserver:self forKeyPath:@"charging" options:NSKeyValueObservingOptionNew context:nil];

//[self setValue:@"crash" forKeyPath:@"euhidehuud"];

return %orig;
}

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
NSLog(@"It works");
}
%end %end

Loading…
Cancel
Save