Browse Source

woah, new beta i think

pull/1/head
Burrit0z 4 years ago
parent
commit
026f01f638
4 changed files with 76 additions and 22 deletions
  1. +2
    -0
      KAIBatteryStack.h
  2. +37
    -18
      KAIBatteryStack.mm
  3. +3
    -0
      Kai.h
  4. +34
    -4
      Kai.xm

+ 2
- 0
KAIBatteryStack.h View File

@interface KAIBatteryStack : UIStackView @interface KAIBatteryStack : UIStackView
@property (nonatomic, strong) NSMutableArray *displayingDevices; @property (nonatomic, strong) NSMutableArray *displayingDevices;
@property (nonatomic, assign) NSInteger number; @property (nonatomic, assign) NSInteger number;
@property (nonatomic, assign) NSInteger oldCountOfDevices;
@property (nonatomic, strong) NSLayoutConstraint *heightConstraint; @property (nonatomic, strong) NSLayoutConstraint *heightConstraint;
@property (nonatomic, assign) BOOL isUpdating; @property (nonatomic, assign) BOOL isUpdating;
@property (nonatomic, assign) BOOL queued;
+(KAIBatteryStack *)sharedInstance; +(KAIBatteryStack *)sharedInstance;
-(instancetype)init; -(instancetype)init;
-(void)refreshForPrefs; -(void)refreshForPrefs;

+ 37
- 18
KAIBatteryStack.mm View File

#import "KAIBatteryStack.h" #import "KAIBatteryStack.h"


KAIBatteryStack *instance; KAIBatteryStack *instance;
NSTimer *queueTimer = nil;
//NSMutableArray *showingCells = [[NSMutableArray alloc] init]; //NSMutableArray *showingCells = [[NSMutableArray alloc] init];


@implementation KAIBatteryStack @implementation KAIBatteryStack
self.distribution = 0; self.distribution = 0;
self.spacing = 0; self.spacing = 0;
self.alignment = 0; self.alignment = 0;
self.oldCountOfDevices = -100;
self.queued = NO;
[self updateBattery]; [self updateBattery];
//self.clipsToBounds = YES; //self.clipsToBounds = YES;
self.userInteractionEnabled = NO; self.userInteractionEnabled = NO;
long long lastPercentage; long long lastPercentage;


-(void)updateBattery { -(void)updateBattery {
self.spacing = spacing;
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
//NSLog(@"kai: battery platter called to update");
if(!self.isUpdating) {
//NSLog(@"kai: IS Updating");
self.isUpdating = YES;
//self.number = 0;
//float y = 0;
BCBatteryDeviceController *bcb = [BCBatteryDeviceController sharedInstance];
BCBatteryDeviceController *bcb = [BCBatteryDeviceController sharedInstance];
NSArray *devices = MSHookIvar<NSArray *>(bcb, "_sortedDevices"); NSArray *devices = MSHookIvar<NSArray *>(bcb, "_sortedDevices");
if(self.oldCountOfDevices == -100) {
self.oldCountOfDevices = [devices count] + 1;
}
self.oldCountOfDevices = [devices count];

for (BCBatteryDevice *device in devices) {
KAIBatteryCell *cell = [device kaiCellForDevice];

[cell updateInfo];
}

if(!self.isUpdating && self.oldCountOfDevices != 0 && ([devices count] + 1 == self.oldCountOfDevices || [devices count] - 1 == self.oldCountOfDevices || [devices count] == self.oldCountOfDevices)) {

self.isUpdating = YES;


//NSLog(@"kai: devices are %@", devices);
for (BCBatteryDevice *device in devices) { for (BCBatteryDevice *device in devices) {
KAIBatteryCell *cell = [device kaiCellForDevice]; KAIBatteryCell *cell = [device kaiCellForDevice];
BOOL charging = MSHookIvar<long long>(device, "_charging"); BOOL charging = MSHookIvar<long long>(device, "_charging");

[cell updateInfo];
BOOL shouldAdd = NO; BOOL shouldAdd = NO;


if(showAll) { if(showAll) {
} }


} }
self.number = [self.subviews count];

queueTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(dispatchQueue) userInfo:nil repeats:NO];
} else if(self.isUpdating) {
self.queued = YES;
} }
self.isUpdating = NO;
//NSLog(@"kai: finished update");
//[(CSAdjunctListView *)self.superview.superview KaiUpdate];
[(CSAdjunctListView *)self.superview.superview performSelector:@selector(KaiUpdate) withObject:(CSAdjunctListView *)self.superview.superview afterDelay:0.2];
self.number = [self.subviews count];
[(CSAdjunctListView *)self.superview.superview KaiUpdate];

}); });
self.number = [self.subviews count];
} }


-(void)refreshForPrefs { -(void)refreshForPrefs {
[self updateBattery]; [self updateBattery];
} }


-(void)dispatchQueue {
self.isUpdating = NO;
if(self.queued) {
[self updateBattery];
self.queued = NO;
}
[queueTimer invalidate];
queueTimer = nil;
}

+(KAIBatteryStack *)sharedInstance { +(KAIBatteryStack *)sharedInstance {
return instance; return instance;
} }

+ 3
- 0
Kai.h View File

@property (nonatomic, assign) BOOL continuousCorners; @property (nonatomic, assign) BOOL continuousCorners;
@end @end


@interface SBIconController : UIViewController
@end

BOOL isUpdating = NO; BOOL isUpdating = NO;


//prefs //prefs

+ 34
- 4
Kai.xm View File

#import "Kai.h" #import "Kai.h"


%group main

%hook KAITarget //This class is defined in %ctor, KAITarget is not a class name. %hook KAITarget //This class is defined in %ctor, KAITarget is not a class name.


%property (nonatomic, assign) BOOL hasKai; %property (nonatomic, assign) BOOL hasKai;
if(self && self.kaiCell == nil) { if(self && self.kaiCell == nil) {
self.kaiCell = [[KAIBatteryCell alloc] initWithFrame:CGRectMake(0,0,[KAIBatteryStack sharedInstance].frame.size.width,0) device:self]; } self.kaiCell = [[KAIBatteryCell alloc] initWithFrame:CGRectMake(0,0,[KAIBatteryStack sharedInstance].frame.size.width,0) device:self]; }
((KAIBatteryCell *)self.kaiCell).translatesAutoresizingMaskIntoConstraints = NO; ((KAIBatteryCell *)self.kaiCell).translatesAutoresizingMaskIntoConstraints = NO;
[((KAIBatteryCell *)self.kaiCell).heightAnchor constraintEqualToConstant:bannerHeight].active = YES;
[((KAIBatteryCell *)self.kaiCell).heightAnchor constraintEqualToConstant:bannerHeight + spacing].active = YES;


[(KAIBatteryCell *)self.kaiCell updateInfo]; [(KAIBatteryCell *)self.kaiCell updateInfo];


-(void)resetKaiCellForNewPrefs { -(void)resetKaiCellForNewPrefs {
self.kaiCell = [[KAIBatteryCell alloc] initWithFrame:CGRectMake(0,0,[KAIBatteryStack sharedInstance].frame.size.width,0) device:self]; self.kaiCell = [[KAIBatteryCell alloc] initWithFrame:CGRectMake(0,0,[KAIBatteryStack sharedInstance].frame.size.width,0) device:self];
((KAIBatteryCell *)self.kaiCell).translatesAutoresizingMaskIntoConstraints = NO; ((KAIBatteryCell *)self.kaiCell).translatesAutoresizingMaskIntoConstraints = NO;
[((KAIBatteryCell *)self.kaiCell).heightAnchor constraintEqualToConstant:bannerHeight].active = YES;
[((KAIBatteryCell *)self.kaiCell).heightAnchor constraintEqualToConstant:bannerHeight + spacing].active = YES;


[(KAIBatteryCell *)self.kaiCell updateInfo]; [(KAIBatteryCell *)self.kaiCell updateInfo];
} }


%end %end


%end

%group drm

%hook SBIconController

-(void)viewDidAppear:(BOOL)arg1 {
UIAlertController* alert2 = [UIAlertController alertControllerWithTitle:@"Unauthorized"
message:@"At this time, only paying users of Multipla have access to kai beta. If you are interested in getting access to kai beta, you can purchase and install Multipla from Chariz."
preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction* yes = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
}];
UIAlertAction* buy = [UIAlertAction actionWithTitle:@"Buy Multipla" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"https://chariz.com/buy/multipla"]];
}];
[alert2 addAction:yes];
[alert2 addAction:buy];
[self presentViewController:alert2 animated:YES completion:nil];
}
%end

%end

%ctor { %ctor {
preferencesChanged(); preferencesChanged();
CFNotificationCenterAddObserver( CFNotificationCenterAddObserver(


Class CSCls = kCFCoreFoundationVersionNumber > 1600 ? ([objc_getClass("CSCoverSheetViewController") class]) : ([objc_getClass("SBDashBoardViewController") class]); Class CSCls = kCFCoreFoundationVersionNumber > 1600 ? ([objc_getClass("CSCoverSheetViewController") class]) : ([objc_getClass("SBDashBoardViewController") class]);


if(enabled) {
%init(KAITarget = cls, KAICSTarget = CSCls); //BIG BRAIN BRO!!
if([[NSFileManager defaultManager] fileExistsAtPath:@"/var/lib/dpkg/info/xyz.burritoz.thomz.multipla.list"] && [[NSFileManager defaultManager] fileExistsAtPath:@"/var/lib/dpkg/info/xyz.burritoz.thomz.multipla.md5sums"] && enabled) {
%init(main, KAITarget = cls, KAICSTarget = CSCls); //BIG BRAIN BRO!!
} else {
%init(drm);
} }
} }

Loading…
Cancel
Save