소스 검색

woah, new beta i think

pull/1/head
Burrit0z 4 년 전
부모
커밋
026f01f638
4개의 변경된 파일76개의 추가작업 그리고 22개의 파일을 삭제
  1. +2
    -0
      KAIBatteryStack.h
  2. +37
    -18
      KAIBatteryStack.mm
  3. +3
    -0
      Kai.h
  4. +34
    -4
      Kai.xm

+ 2
- 0
KAIBatteryStack.h 파일 보기

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

+ 37
- 18
KAIBatteryStack.mm 파일 보기

@@ -1,6 +1,7 @@
#import "KAIBatteryStack.h"

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

@implementation KAIBatteryStack
@@ -14,6 +15,8 @@ KAIBatteryStack *instance;
self.distribution = 0;
self.spacing = 0;
self.alignment = 0;
self.oldCountOfDevices = -100;
self.queued = NO;
[self updateBattery];
//self.clipsToBounds = YES;
self.userInteractionEnabled = NO;
@@ -25,24 +28,29 @@ long long batteryPercentage;
long long lastPercentage;

-(void)updateBattery {
self.spacing = spacing;
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");
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) {
KAIBatteryCell *cell = [device kaiCellForDevice];
BOOL charging = MSHookIvar<long long>(device, "_charging");

[cell updateInfo];
BOOL shouldAdd = NO;

if(showAll) {
@@ -70,15 +78,16 @@ long long lastPercentage;
}

}
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 {
@@ -99,6 +108,16 @@ long long lastPercentage;
[self updateBattery];
}

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

+(KAIBatteryStack *)sharedInstance {
return instance;
}

+ 3
- 0
Kai.h 파일 보기

@@ -19,6 +19,9 @@
@property (nonatomic, assign) BOOL continuousCorners;
@end

@interface SBIconController : UIViewController
@end

BOOL isUpdating = NO;

//prefs

+ 34
- 4
Kai.xm 파일 보기

@@ -1,5 +1,7 @@
#import "Kai.h"

%group main

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

%property (nonatomic, assign) BOOL hasKai;
@@ -139,7 +141,7 @@
if(self && self.kaiCell == nil) {
self.kaiCell = [[KAIBatteryCell alloc] initWithFrame:CGRectMake(0,0,[KAIBatteryStack sharedInstance].frame.size.width,0) device:self]; }
((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];

@@ -150,7 +152,7 @@
-(void)resetKaiCellForNewPrefs {
self.kaiCell = [[KAIBatteryCell alloc] initWithFrame:CGRectMake(0,0,[KAIBatteryStack sharedInstance].frame.size.width,0) device:self];
((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];
}
@@ -174,6 +176,32 @@

%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 {
preferencesChanged();
CFNotificationCenterAddObserver(
@@ -190,7 +218,9 @@

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…
취소
저장