mirror of
https://github.com/Burrit0z/kai
synced 2025-07-01 17:26:47 +00:00
start ios 14 work
This commit is contained in:
@ -9,8 +9,8 @@
|
|||||||
|
|
||||||
NSString *deviceName = device.name;
|
NSString *deviceName = device.name;
|
||||||
double batteryPercentage = device.percentCharge;
|
double batteryPercentage = device.percentCharge;
|
||||||
BOOL charging = MSHookIvar<long long>(device, "_charging");
|
BOOL charging = [device isCharging];
|
||||||
BOOL LPM = MSHookIvar<BOOL>(device, "_batterySaverModeActive");
|
BOOL LPM = [device isBatterySaverModeActive];
|
||||||
|
|
||||||
UIView *blur;
|
UIView *blur;
|
||||||
UIView *blurPlatter = [[UIView alloc] init];
|
UIView *blurPlatter = [[UIView alloc] init];
|
||||||
@ -75,7 +75,7 @@
|
|||||||
[self.battery setPinColorAlpha:1.0];
|
[self.battery setPinColorAlpha:1.0];
|
||||||
}
|
}
|
||||||
|
|
||||||
UIImage *glyph = [device glyph];
|
UIImage *glyph = ios13 ? [device glyph] : [device batteryWidgetGlyph];
|
||||||
self.glyphView = [[UIImageView alloc] init];
|
self.glyphView = [[UIImageView alloc] init];
|
||||||
self.glyphView.contentMode = UIViewContentModeScaleAspectFit;
|
self.glyphView.contentMode = UIViewContentModeScaleAspectFit;
|
||||||
[self.glyphView setImage:glyph];
|
[self.glyphView setImage:glyph];
|
||||||
@ -193,10 +193,10 @@
|
|||||||
|
|
||||||
- (void)updateInfo {
|
- (void)updateInfo {
|
||||||
if (self.device != nil) {
|
if (self.device != nil) {
|
||||||
NSString *deviceName = MSHookIvar<NSString *>(self.device, "_name");
|
NSString *deviceName = [self.device name];
|
||||||
double batteryPercentage = MSHookIvar<long long>(self.device, "_percentCharge");
|
double batteryPercentage = [self.device percentCharge];
|
||||||
BOOL charging = MSHookIvar<long long>(self.device, "_charging");
|
BOOL charging = [self.device isCharging];
|
||||||
BOOL LPM = MSHookIvar<BOOL>(self.device, "_batterySaverModeActive");
|
BOOL LPM = [self.device isBatterySaverModeActive];
|
||||||
|
|
||||||
self.label.text = [NSString stringWithFormat:@"%@", deviceName];
|
self.label.text = [NSString stringWithFormat:@"%@", deviceName];
|
||||||
[self.percentLabel setText:[NSString stringWithFormat:@"%ld%%", (long)((NSInteger)batteryPercentage)]];
|
[self.percentLabel setText:[NSString stringWithFormat:@"%ld%%", (long)((NSInteger)batteryPercentage)]];
|
||||||
@ -219,7 +219,7 @@
|
|||||||
[self.percentLabel setText:[NSString stringWithFormat:@"%ld%%", (long)((NSInteger)batteryPercentage)]];
|
[self.percentLabel setText:[NSString stringWithFormat:@"%ld%%", (long)((NSInteger)batteryPercentage)]];
|
||||||
self.battery.chargePercent = (batteryPercentage * 0.01);
|
self.battery.chargePercent = (batteryPercentage * 0.01);
|
||||||
|
|
||||||
[self.glyphView setImage:[self.device glyph]];
|
[self.glyphView setImage:ios13 ? [self.device glyph] : [self.device batteryWidgetGlyph]];
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ NSMutableArray *cellsForDeviceNames = [[NSMutableArray alloc] init];
|
|||||||
- (void)updateBattery {
|
- (void)updateBattery {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
BCBatteryDeviceController *bcb = [BCBatteryDeviceController sharedInstance];
|
BCBatteryDeviceController *bcb = [BCBatteryDeviceController sharedInstance];
|
||||||
NSArray *devices = MSHookIvar<NSArray *>(bcb, "_sortedDevices");
|
NSArray *devices = ios13 ? [bcb sortedDevices] : [bcb connectedDevices];
|
||||||
|
|
||||||
if (self.oldCountOfDevices == -100) {
|
if (self.oldCountOfDevices == -100) {
|
||||||
self.oldCountOfDevices = [devices count] + 1;
|
self.oldCountOfDevices = [devices count] + 1;
|
||||||
@ -119,11 +119,11 @@ NSMutableArray *cellsForDeviceNames = [[NSMutableArray alloc] init];
|
|||||||
|
|
||||||
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 = [device isCharging];
|
||||||
BOOL internal = MSHookIvar<BOOL>(device, "_internal");
|
BOOL internal = [device isInternal];
|
||||||
BOOL shouldAdd = NO;
|
BOOL shouldAdd = NO;
|
||||||
BOOL fake = MSHookIvar<BOOL>(device, "_fake");
|
BOOL fake = [device isFake];
|
||||||
NSString *deviceName = MSHookIvar<NSString *>(device, "_name");
|
NSString *deviceName = [device name];
|
||||||
|
|
||||||
if (!fake) {
|
if (!fake) {
|
||||||
if (showAll) {
|
if (showAll) {
|
||||||
@ -187,7 +187,7 @@ NSMutableArray *cellsForDeviceNames = [[NSMutableArray alloc] init];
|
|||||||
[self.stack removeArrangedSubview:cell];
|
[self.stack removeArrangedSubview:cell];
|
||||||
cell.alpha = 1;
|
cell.alpha = 1;
|
||||||
}];
|
}];
|
||||||
NSString *deviceName = MSHookIvar<NSString *>(cell.device, "_name");
|
NSString *deviceName = [cell.device name];
|
||||||
[deviceNames removeObject:deviceName];
|
[deviceNames removeObject:deviceName];
|
||||||
[cellsForDeviceNames removeObject:cell];
|
[cellsForDeviceNames removeObject:cell];
|
||||||
}
|
}
|
||||||
@ -311,7 +311,7 @@ NSMutableArray *cellsForDeviceNames = [[NSMutableArray alloc] init];
|
|||||||
}
|
}
|
||||||
|
|
||||||
BCBatteryDeviceController *bcb = [BCBatteryDeviceController sharedInstance];
|
BCBatteryDeviceController *bcb = [BCBatteryDeviceController sharedInstance];
|
||||||
NSArray *devices = MSHookIvar<NSArray *>(bcb, "_sortedDevices");
|
NSArray *devices = ios13 ? [bcb sortedDevices] : [bcb connectedDevices];
|
||||||
for (BCBatteryDevice *device in devices) {
|
for (BCBatteryDevice *device in devices) {
|
||||||
[device resetKaiCellForNewPrefs];
|
[device resetKaiCellForNewPrefs];
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
@interface BCBatteryDeviceController : NSObject
|
@interface BCBatteryDeviceController : NSObject
|
||||||
@property (nonatomic, strong) NSArray *sortedDevices;
|
@property (nonatomic, strong) NSArray *sortedDevices;
|
||||||
- (id)_sortedDevices;
|
- (id)_sortedDevices;
|
||||||
|
- (id)connectedDevices; //ios 14
|
||||||
+ (id)sharedInstance;
|
+ (id)sharedInstance;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -27,12 +28,13 @@
|
|||||||
@property (nonatomic, strong) id kaiCell;
|
@property (nonatomic, strong) id kaiCell;
|
||||||
@property (nonatomic, strong) NSString *name;
|
@property (nonatomic, strong) NSString *name;
|
||||||
@property (nonatomic, assign) long long percentCharge;
|
@property (nonatomic, assign) long long percentCharge;
|
||||||
@property (nonatomic, assign) BOOL charging;
|
@property (nonatomic, assign, getter=isCharging) BOOL charging;
|
||||||
@property (nonatomic, assign) BOOL fake;
|
@property (nonatomic, assign, getter=isFake) BOOL fake;
|
||||||
@property (nonatomic, assign) BOOL internal;
|
@property (nonatomic, assign, getter=isInternal) BOOL internal;
|
||||||
@property (nonatomic, assign) BOOL batterySaverModeActive;
|
@property (nonatomic, assign, getter=isBatterySaverModeActive) BOOL batterySaverModeActive;
|
||||||
@property (nonatomic, strong) NSString *identifier;
|
@property (nonatomic, strong) NSString *identifier;
|
||||||
- (id)glyph;
|
- (id)glyph; //ios 13
|
||||||
|
- (id)batteryWidgetGlyph; //ios 14
|
||||||
- (id)kaiCellForDevice;
|
- (id)kaiCellForDevice;
|
||||||
- (void)resetKaiCellForNewPrefs;
|
- (void)resetKaiCellForNewPrefs;
|
||||||
@end
|
@end
|
||||||
|
2
Kai.h
2
Kai.h
@ -30,6 +30,8 @@
|
|||||||
- (void)fixComplicationsViewFrame;
|
- (void)fixComplicationsViewFrame;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
BOOL ios13 = NO;
|
||||||
|
|
||||||
BOOL isUpdating = NO;
|
BOOL isUpdating = NO;
|
||||||
BOOL shouldBeAdded = YES;
|
BOOL shouldBeAdded = YES;
|
||||||
|
|
||||||
|
10
Kai.xm
10
Kai.xm
@ -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
|
//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) {
|
if(enabled) {
|
||||||
%init(main, Media = mediaClass, KAITarget = cls, KAICSTarget = CSCls); //BIG BRAIN BRO!!
|
%init(main, Media = mediaClass, KAITarget = cls, KAICSTarget = CSCls); //BIG BRAIN BRO!!
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
Package: com.burritoz.kai
|
Package: com.burritoz.kai
|
||||||
Name: Kai
|
Name: Kai
|
||||||
Version: 1.3.1
|
Version: 1.4.0
|
||||||
Architecture: iphoneos-arm
|
Architecture: iphoneos-arm
|
||||||
Description: Device battery indicators on your lock screen!
|
Description: Device battery indicators on your lock screen!
|
||||||
Maintainer: burrit0z
|
Maintainer: burrit0z
|
||||||
|
Reference in New Issue
Block a user