소스 검색

start ios 14 work

pull/3/head
Burrit0z 3 년 전
부모
커밋
1ef3ed3576
6개의 변경된 파일32개의 추가작업 그리고 24개의 파일을 삭제
  1. +8
    -8
      KAIBatteryCell.mm
  2. +7
    -7
      KAIBatteryPlatter.mm
  3. +7
    -5
      KAIClassHeaders.h
  4. +2
    -0
      Kai.h
  5. +7
    -3
      Kai.xm
  6. +1
    -1
      Layout/DEBIAN/control

+ 8
- 8
KAIBatteryCell.mm 파일 보기



NSString *deviceName = device.name; NSString *deviceName = device.name;
double batteryPercentage = device.percentCharge; 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 *blur;
UIView *blurPlatter = [[UIView alloc] init]; UIView *blurPlatter = [[UIView alloc] init];
[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];


- (void)updateInfo { - (void)updateInfo {
if (self.device != nil) { 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.label.text = [NSString stringWithFormat:@"%@", deviceName];
[self.percentLabel setText:[NSString stringWithFormat:@"%ld%%", (long)((NSInteger)batteryPercentage)]]; [self.percentLabel setText:[NSString stringWithFormat:@"%ld%%", (long)((NSInteger)batteryPercentage)]];
[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 {
} }
} }

+ 7
- 7
KAIBatteryPlatter.mm 파일 보기

- (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;


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 internal = MSHookIvar<BOOL>(device, "_internal");
BOOL charging = [device isCharging];
BOOL internal = [device isInternal];
BOOL shouldAdd = NO; 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 (!fake) {
if (showAll) { if (showAll) {
[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];
} }
} }


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];
} }

+ 7
- 5
KAIClassHeaders.h 파일 보기

@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


@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) 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; @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
- 0
Kai.h 파일 보기

- (void)fixComplicationsViewFrame; - (void)fixComplicationsViewFrame;
@end @end


BOOL ios13 = NO;

BOOL isUpdating = NO; BOOL isUpdating = NO;
BOOL shouldBeAdded = YES; BOOL shouldBeAdded = YES;



+ 7
- 3
Kai.xm 파일 보기



//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 ? %c(CSCoverSheetViewController) : %c(SBDashBoardViewController);


Class CSCls = kCFCoreFoundationVersionNumber > 1600 ? ([objc_getClass("CSCoverSheetViewController") class]) : ([objc_getClass("SBDashBoardViewController") class]);
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
- 1
Layout/DEBIAN/control 파일 보기

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

Loading…
취소
저장