mirror of
				https://github.com/Burrit0z/kai
				synced 2025-10-31 19:36:19 +00:00 
			
		
		
		
	woah, new beta i think
This commit is contained in:
		| @ -1,8 +1,10 @@ | |||||||
| @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; | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| #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 | ||||||
| @ -14,6 +15,8 @@ KAIBatteryStack *instance; | |||||||
|         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; | ||||||
| @ -25,24 +28,29 @@ long long batteryPercentage; | |||||||
| 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"); |         BCBatteryDeviceController *bcb = [BCBatteryDeviceController sharedInstance]; | ||||||
|     if(!self.isUpdating) { |  | ||||||
|         //NSLog(@"kai: IS Updating"); |  | ||||||
|     self.isUpdating = YES; |  | ||||||
|     //self.number = 0; |  | ||||||
|     //float y = 0; |  | ||||||
|     BCBatteryDeviceController *bcb = [BCBatteryDeviceController sharedInstance]; |  | ||||||
|         NSArray *devices = MSHookIvar<NSArray *>(bcb, "_sortedDevices"); |         NSArray *devices = MSHookIvar<NSArray *>(bcb, "_sortedDevices"); | ||||||
|      |      | ||||||
|         //NSLog(@"kai: devices are %@", devices); |     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; | ||||||
|  |  | ||||||
|          |          | ||||||
|         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) { | ||||||
| @ -71,14 +79,15 @@ 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; |         self.number = [self.subviews count]; | ||||||
|         //NSLog(@"kai: finished update"); |         [(CSAdjunctListView *)self.superview.superview KaiUpdate]; | ||||||
|         //[(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]; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| -(void)refreshForPrefs { | -(void)refreshForPrefs { | ||||||
| @ -99,6 +108,16 @@ long long lastPercentage; | |||||||
|     [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
									
								
								Kai.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								Kai.h
									
									
									
									
									
								
							| @ -19,6 +19,9 @@ | |||||||
| @property (nonatomic, assign) BOOL continuousCorners; | @property (nonatomic, assign) BOOL continuousCorners; | ||||||
| @end | @end | ||||||
|  |  | ||||||
|  | @interface SBIconController : UIViewController | ||||||
|  | @end | ||||||
|  |  | ||||||
| BOOL isUpdating = NO; | BOOL isUpdating = NO; | ||||||
|  |  | ||||||
| //prefs | //prefs | ||||||
|  | |||||||
							
								
								
									
										38
									
								
								Kai.xm
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								Kai.xm
									
									
									
									
									
								
							| @ -1,5 +1,7 @@ | |||||||
| #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; | ||||||
| @ -139,7 +141,7 @@ | |||||||
| 	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]; | ||||||
|  |  | ||||||
| @ -150,7 +152,7 @@ | |||||||
| -(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]; | ||||||
| } | } | ||||||
| @ -174,6 +176,32 @@ | |||||||
|  |  | ||||||
| %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( | ||||||
| @ -190,7 +218,9 @@ | |||||||
|  |  | ||||||
| 	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) { | 	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(KAITarget = cls, KAICSTarget = CSCls); //BIG BRAIN BRO!! |     	%init(main, KAITarget = cls, KAICSTarget = CSCls); //BIG BRAIN BRO!! | ||||||
|  | 	} else { | ||||||
|  | 		%init(drm); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user