1
0
mirror of https://github.com/Burrit0z/kai synced 2025-07-01 17:36:48 +00:00

start ios 14 work

This commit is contained in:
Burrit0z
2020-09-22 19:20:19 -04:00
parent 67bec552b4
commit 1ef3ed3576
6 changed files with 32 additions and 24 deletions

View File

@ -9,8 +9,8 @@
NSString *deviceName = device.name;
double batteryPercentage = device.percentCharge;
BOOL charging = MSHookIvar<long long>(device, "_charging");
BOOL LPM = MSHookIvar<BOOL>(device, "_batterySaverModeActive");
BOOL charging = [device isCharging];
BOOL LPM = [device isBatterySaverModeActive];
UIView *blur;
UIView *blurPlatter = [[UIView alloc] init];
@ -75,7 +75,7 @@
[self.battery setPinColorAlpha:1.0];
}
UIImage *glyph = [device glyph];
UIImage *glyph = ios13 ? [device glyph] : [device batteryWidgetGlyph];
self.glyphView = [[UIImageView alloc] init];
self.glyphView.contentMode = UIViewContentModeScaleAspectFit;
[self.glyphView setImage:glyph];
@ -193,10 +193,10 @@
- (void)updateInfo {
if (self.device != nil) {
NSString *deviceName = MSHookIvar<NSString *>(self.device, "_name");
double batteryPercentage = MSHookIvar<long long>(self.device, "_percentCharge");
BOOL charging = MSHookIvar<long long>(self.device, "_charging");
BOOL LPM = MSHookIvar<BOOL>(self.device, "_batterySaverModeActive");
NSString *deviceName = [self.device name];
double batteryPercentage = [self.device percentCharge];
BOOL charging = [self.device isCharging];
BOOL LPM = [self.device isBatterySaverModeActive];
self.label.text = [NSString stringWithFormat:@"%@", deviceName];
[self.percentLabel setText:[NSString stringWithFormat:@"%ld%%", (long)((NSInteger)batteryPercentage)]];
@ -219,7 +219,7 @@
[self.percentLabel setText:[NSString stringWithFormat:@"%ld%%", (long)((NSInteger)batteryPercentage)]];
self.battery.chargePercent = (batteryPercentage * 0.01);
[self.glyphView setImage:[self.device glyph]];
[self.glyphView setImage:ios13 ? [self.device glyph] : [self.device batteryWidgetGlyph]];
} else {
}
}

View File

@ -100,7 +100,7 @@ NSMutableArray *cellsForDeviceNames = [[NSMutableArray alloc] init];
- (void)updateBattery {
dispatch_async(dispatch_get_main_queue(), ^{
BCBatteryDeviceController *bcb = [BCBatteryDeviceController sharedInstance];
NSArray *devices = MSHookIvar<NSArray *>(bcb, "_sortedDevices");
NSArray *devices = ios13 ? [bcb sortedDevices] : [bcb connectedDevices];
if (self.oldCountOfDevices == -100) {
self.oldCountOfDevices = [devices count] + 1;
@ -119,11 +119,11 @@ NSMutableArray *cellsForDeviceNames = [[NSMutableArray alloc] init];
for (BCBatteryDevice *device in devices) {
KAIBatteryCell *cell = [device kaiCellForDevice];
BOOL charging = MSHookIvar<long long>(device, "_charging");
BOOL internal = MSHookIvar<BOOL>(device, "_internal");
BOOL charging = [device isCharging];
BOOL internal = [device isInternal];
BOOL shouldAdd = NO;
BOOL fake = MSHookIvar<BOOL>(device, "_fake");
NSString *deviceName = MSHookIvar<NSString *>(device, "_name");
BOOL fake = [device isFake];
NSString *deviceName = [device name];
if (!fake) {
if (showAll) {
@ -187,7 +187,7 @@ NSMutableArray *cellsForDeviceNames = [[NSMutableArray alloc] init];
[self.stack removeArrangedSubview:cell];
cell.alpha = 1;
}];
NSString *deviceName = MSHookIvar<NSString *>(cell.device, "_name");
NSString *deviceName = [cell.device name];
[deviceNames removeObject:deviceName];
[cellsForDeviceNames removeObject:cell];
}
@ -311,7 +311,7 @@ NSMutableArray *cellsForDeviceNames = [[NSMutableArray alloc] init];
}
BCBatteryDeviceController *bcb = [BCBatteryDeviceController sharedInstance];
NSArray *devices = MSHookIvar<NSArray *>(bcb, "_sortedDevices");
NSArray *devices = ios13 ? [bcb sortedDevices] : [bcb connectedDevices];
for (BCBatteryDevice *device in devices) {
[device resetKaiCellForNewPrefs];
}

View File

@ -20,6 +20,7 @@
@interface BCBatteryDeviceController : NSObject
@property (nonatomic, strong) NSArray *sortedDevices;
- (id)_sortedDevices;
- (id)connectedDevices; //ios 14
+ (id)sharedInstance;
@end
@ -27,12 +28,13 @@
@property (nonatomic, strong) id kaiCell;
@property (nonatomic, strong) NSString *name;
@property (nonatomic, assign) long long percentCharge;
@property (nonatomic, assign) BOOL charging;
@property (nonatomic, assign) BOOL fake;
@property (nonatomic, assign) BOOL internal;
@property (nonatomic, assign) BOOL batterySaverModeActive;
@property (nonatomic, assign, getter=isCharging) BOOL charging;
@property (nonatomic, assign, getter=isFake) BOOL fake;
@property (nonatomic, assign, getter=isInternal) BOOL internal;
@property (nonatomic, assign, getter=isBatterySaverModeActive) BOOL batterySaverModeActive;
@property (nonatomic, strong) NSString *identifier;
- (id)glyph;
- (id)glyph; //ios 13
- (id)batteryWidgetGlyph; //ios 14
- (id)kaiCellForDevice;
- (void)resetKaiCellForNewPrefs;
@end

2
Kai.h
View File

@ -30,6 +30,8 @@
- (void)fixComplicationsViewFrame;
@end
BOOL ios13 = NO;
BOOL isUpdating = NO;
BOOL shouldBeAdded = YES;

10
Kai.xm
View File

@ -215,11 +215,15 @@ Class mediaClass;
//Bro Muirey helped me figure out a logical way to do this because iOS 12-13 classes have changed
mediaClass = kCFCoreFoundationVersionNumber > 1600 ? ([objc_getClass("CSAdjunctItemView") class]) : ([objc_getClass("SBDashBoardAdjunctItemView") class]);
mediaClass = kCFCoreFoundationVersionNumber > 1600 ? %c(CSAdjunctItemView) : %c(SBDashBoardAdjunctItemView);
Class cls = kCFCoreFoundationVersionNumber > 1600 ? ([objc_getClass("CSAdjunctListView") class]) : ([objc_getClass("SBDashBoardAdjunctListView") class]);
Class cls = kCFCoreFoundationVersionNumber > 1600 ? %c(CSAdjunctListView) : %c(SBDashBoardAdjunctListView);
Class CSCls = kCFCoreFoundationVersionNumber > 1600 ? ([objc_getClass("CSCoverSheetViewController") class]) : ([objc_getClass("SBDashBoardViewController") class]);
Class CSCls = kCFCoreFoundationVersionNumber > 1600 ? %c(CSCoverSheetViewController) : %c(SBDashBoardViewController);
if(kCFCoreFoundationVersionNumber < 1740) {
ios13 = YES; //wow very pog version you have
}
if(enabled) {
%init(main, Media = mediaClass, KAITarget = cls, KAICSTarget = CSCls); //BIG BRAIN BRO!!

View File

@ -1,6 +1,6 @@
Package: com.burritoz.kai
Name: Kai
Version: 1.3.1
Version: 1.4.0
Architecture: iphoneos-arm
Description: Device battery indicators on your lock screen!
Maintainer: burrit0z