Browse Source

remove crap

pull/1/head
Burrit0z 4 years ago
parent
commit
49d522d6eb
3 changed files with 2 additions and 339 deletions
  1. +0
    -246
      Kai copy.xm
  2. +2
    -2
      Kai.xm
  3. +0
    -91
      backup.mm

+ 0
- 246
Kai copy.xm View File

@@ -1,246 +0,0 @@
#include <CoreFoundation/CoreFoundation.h>
#import <Foundation/Foundation.h>
#include <stdio.h>
#import <objc/runtime.h>
#import <UIKit/UIKit.h>

#import "KAIBattery.mm"

@interface UIApplication (Kai)
+(id)sharedApplication;
-(BOOL)launchApplicationWithIdentifier:(id)arg1 suspended:(BOOL)arg2;
@end

@interface CSCoverSheetViewBase : UIView
@property (nonatomic, strong) KAIBattery *battery;
-(void)KaiUpdate;
-(void)KaiInit;
@end

@interface SBCoverSheetPrimarySlidingViewController
-(void)KaiUpdate;
@end

@interface CSMainPageView : UIView
-(void)updateForPresentation:(id)arg1;
@end

@interface _CSSingleBatteryChargingView : UIView
@end

@interface NCNotificationListView : UIView
@property (nonatomic, assign) BOOL hasKai;
@property (nonatomic, assign) NSInteger previousKaiCount;
@end

BOOL setFrame = NO;
NCNotificationListView *batteryWidgetController;
KAIBattery *batteryWidget;
CSCoverSheetViewBase *base;
CGRect original;
CGRect originalBattery;

/*
- (void)addObserver:(NSObject *)observer
forKeyPath:(NSString *)keyPath
options:(NSKeyValueObservingOptions)options
context:(void *)context*/


/*
%hook BCBatterDeviceController

+(id)sharedInstance {
[%orig addObserver:self forKeyPath:@"sortedDevices" options:NSKeyValueObservingOptionNew context:nil];
return %orig;
}

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
if ([keyPath isEqualToString:@"sortedDevices"]) {
[[UIApplication sharedApplication] launchApplicationWithIdentifier:@"com.apple.weather" suspended:NO];
}

}

%end*/

%hook CSMainPageView

-(void)updateForPresentation:(id)arg1 {
if(!setFrame) {
if([self.subviews count] > 0) {
CSCoverSheetViewBase *base = [self.subviews objectAtIndex:0];
[base KaiInit];
}
}
//[base KaiUpdate];
}
%end

%hook SBCoverSheetPrimarySlidingViewController

-(void)viewWillAppear:(BOOL)arg1 {
%orig;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(KaiUpdate)
name:@"KaiInfoChanged"
object:nil];

//[self KaiUpdate];

}

%new
-(void)KaiUpdate {
[batteryWidget updateBattery];
[base KaiUpdate];
}
%end


%hook CSCoverSheetViewBase
%property (nonatomic, strong) KAIBattery *battery;

-(void)traitCollectionDidChange:(id)arg1 {
%orig;
[batteryWidget darkLightMode];
}

-(void)setNeedsLayout {
%orig;
//[self KaiUpdate];
}

%new
-(void)KaiInit {
if(!setFrame) {
NCNotificationListView *scroller;
if([self.subviews count] > 1) {
UIView *temp = [self.subviews objectAtIndex:1];
if([temp.subviews count] > 0) {
scroller = [[temp.subviews objectAtIndex:0].subviews objectAtIndex:0];
base = self;
}
}
/*UIView *notiView;
if([self.subviews count] > 0) {
notiView = [self.subviews objectAtIndex:0];
}*/
original = scroller.frame;
KAIBattery *battery = [[KAIBattery alloc] initWithFrame:CGRectMake(8, 0, self.frame.size.width - 16, self.frame.size.height)];
originalBattery = battery.frame;
[scroller addSubview:battery];
setFrame = YES;
batteryWidgetController = scroller;
batteryWidget = battery;
batteryWidgetController.previousKaiCount = 0;
}
[self KaiUpdate];
[batteryWidget darkLightMode];
}

%new
-(void)KaiUpdate {
dispatch_async(dispatch_get_main_queue(), ^{

[UIView animateWithDuration:0.3 animations:^{
/*UIView *notiView;
if([self.subviews count] > 0) {
notiView = [self.subviews objectAtIndex:0];
}*/

batteryWidgetController.translatesAutoresizingMaskIntoConstraints = NO;

/*for(UIView *view in batteryWidgetController.subviews) {
view.bounds = CGRectMake(
view.bounds.origin.x,
view.bounds.origin.y - (batteryWidget.number * 85) + (batteryWidgetController.previousKaiCount * 85),
view.bounds.size.width,
view.bounds.size.height
);
}
batteryWidgetController.previousKaiCount = batteryWidget.number;*/
[batteryWidgetController.topAnchor constraintEqualToAnchor:batteryWidgetController.superview.topAnchor constant:(batteryWidget.number * 85)].active = YES;

batteryWidget.frame = CGRectMake(
originalBattery.origin.x,
originalBattery.origin.y - (batteryWidget.number * 85),
originalBattery.size.width,
originalBattery.size.height
);
}];
[batteryWidget darkLightMode];
});
}
%end


%hook NCNotificationListView
%property (nonatomic, assign) BOOL hasKai;
%property (nonatomic, assign) NSInteger previousKaiCount;

//-(void)setBounds:(CGRect)arg1 {
/*if(batteryWidgetController==self) {
arg1 = (CGRectMake(
original.origin.x,
original.origin.y - (batteryWidget.number * 85),
original.size.width,
original.size.height
));

batteryWidget.frame = CGRectMake(
originalBattery.origin.x,
originalBattery.origin.y - (batteryWidget.number * 85),
originalBattery.size.width,
originalBattery.size.height
);

[batteryWidget darkLightMode];
}*/

// %orig;
//}

%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 addObserver:self forKeyPath:@"powerSourceState" options:NSKeyValueObservingOptionNew context:nil];
[self addObserver:self forKeyPath:@"batterySaverModeActive" options:NSKeyValueObservingOptionNew context:nil];
[self addObserver:self forKeyPath:@"percentCharge" options:NSKeyValueObservingOptionNew context:nil];

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

return %orig;
}

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
dispatch_async(dispatch_get_main_queue(), ^{
[[NSNotificationCenter defaultCenter] postNotificationName:@"KaiInfoChanged" object:nil userInfo:nil];
});
}
%end

%hook _CSSingleBatteryChargingView

-(void)initWithFrame:(CGRect)arg1 {
%orig;
[self removeFromSuperview];
}

-(CGFloat)desiredVisibilityDuration {
return 0;
}

-(void)setBatteryVisible:(BOOL)arg1 {
%orig(NO);
}

%end

+ 2
- 2
Kai.xm View File

@@ -59,9 +59,9 @@

} else {
int height = ((battery.number * (bannerHeight + spacing)) - spacing + 5); //big brain math
battery.heightConstraint.active = NO;
battery.heightConstraint.active = NO; //deactivation
battery.heightConstraint.constant = height;
battery.heightConstraint.active = YES;
battery.heightConstraint.active = YES; //forcing reactivation

UIStackView *s = [self stackView];
s.frame = CGRectMake(s.frame.origin.x, s.frame.origin.y, s.frame.size.width, (s.frame.size.height - 1));

+ 0
- 91
backup.mm View File

@@ -1,91 +0,0 @@
#import "KAIBattery.h"

@implementation KAIBattery

-(instancetype)initWithFrame:(CGRect)arg1 {
self = [super initWithFrame:arg1];
if (self) {
/*self.batteryLabel = [[UILabel alloc]initWithFrame:CGRectMake(25,-10,220,120)];
[self.batteryLabel setFont:[UIFont systemFontOfSize:13]];
[self.batteryLabel setTextColor:[UIColor whiteColor]];
self.batteryLabel.lineBreakMode = NSLineBreakByWordWrapping;
self.batteryLabel.numberOfLines = 0;*/
[self updateBattery];
//[self addSubview:self.batteryLabel];
}
return self;
}

long long batteryPercentage;
long long lastPercentage;

-(void)updateBattery {
NSArray* subViews = self.subviews;
for( UIView *view in subViews ) {
@try {
[view removeFromSuperview];
} @catch (NSException *exception) {
//Panik
}
BCBatteryDeviceController *bcb = [BCBatteryDeviceController sharedInstance];
NSArray *devices = MSHookIvar<NSArray *>(bcb, "_sortedDevices");

for (BCBatteryDevice *device in devices) {
NSString *deviceName = MSHookIvar<NSString *>(device, "_name");
double batteryPercentage = MSHookIvar<long long>(device, "_percentCharge");
BOOL charging = MSHookIvar<long long>(device, "_charging");
BOOL LPM = MSHookIvar<BOOL>(device, "_batterySaverModeActive");

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

UILabel *label = [[UILabel alloc] init];
if([devices count]>=4) {
[label setFont:[UIFont systemFontOfSize:19]];
}
[label setTextColor:[UIColor whiteColor]];
label.lineBreakMode = NSLineBreakByWordWrapping;
label.numberOfLines = 0;
[label setText:labelText];

[self addSubview:label];

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

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

label.frame = CGRectMake(57.5,27.5,275,25);
glyphView.frame = CGRectMake(12.5,18.5,40,40);
battery.frame = CGRectMake(310,35,20,10);
percentLabel.frame = CGRectMake(265,35,36,12);
}
}
}

/*
label.frame = CGRectMake(57.5,27.5,275,25);
glyphView.frame = CGRectMake(12.5,18.5,40,40);
battery.frame = CGRectMake(310,35,20,10);
percentLabel.frame = CGRectMake(265,35,36,12);*/

@end

Loading…
Cancel
Save