Device battery indicators on your Lock Screen
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Kai.xm 6.3KB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. #import "Kai.h"
  2. CSAdjunctListView *list;
  3. %group main
  4. %hook KAITarget //This class is defined in %ctor, KAITarget is not a class name.
  5. %property (nonatomic, assign) BOOL hasKai;
  6. -(void)_layoutStackView {
  7. %orig;
  8. //this code is used to determine if kai is at the bottom of the stack view
  9. @try {
  10. if([[self stackView].subviews objectAtIndex:([[self stackView].subviews count] -1)] != [KAIBatteryPlatter sharedInstance] && belowMusic) {
  11. //if it is not, but the option to have kai below music is on, i simply remove from it's current pos.
  12. //and insert into last slot.
  13. [[self stackView] removeArrangedSubview:[KAIBatteryPlatter sharedInstance]];
  14. [[self stackView] insertArrangedSubview:[KAIBatteryPlatter sharedInstance] atIndex:([[self stackView].subviews count] -1)];
  15. }
  16. } @catch (NSException *exc) {}
  17. if([KAISelf.superview respondsToSelector:@selector(fixComplicationsViewFrame)]) {
  18. [(NCNotificationListView *)(KAISelf.superview) fixComplicationsViewFrame];
  19. }
  20. [[KAIBatteryPlatter sharedInstance] calculateHeight];
  21. }
  22. -(void)setStackView:(UIStackView *)arg1 {
  23. if(!KAISelf.hasKai) {
  24. list = self;
  25. KAIBatteryPlatter *battery = [[KAIBatteryPlatter alloc] initWithFrame:[self stackView].frame];
  26. //Add noti observer
  27. [[NSNotificationCenter defaultCenter] addObserver:self
  28. selector:@selector(KaiInfo)
  29. name:@"KaiInfoChanged"
  30. object:nil];
  31. KAISelf.hasKai = YES;
  32. if(![arg1.subviews containsObject:battery]) { //if not added
  33. //add kai to the stack view
  34. [arg1 addArrangedSubview:battery];
  35. }
  36. [battery updateBattery];
  37. //send the adjusted stackview as arg1
  38. %orig(arg1);
  39. }
  40. }
  41. %new
  42. -(void)KaiInfo {
  43. if(!isUpdating) {
  44. isUpdating = YES;
  45. //NSLog(@"kai: kai info will update");
  46. dispatch_async(dispatch_get_main_queue(), ^{
  47. [[KAIBatteryPlatter sharedInstance] updateBattery];
  48. if([KAIBatteryPlatter sharedInstance].number == 0) {
  49. [[KAIBatteryPlatter sharedInstance] removeFromSuperview];
  50. [[self stackView] removeArrangedSubview:[KAIBatteryPlatter sharedInstance]];
  51. } else if(![[self stackView].subviews containsObject:[KAIBatteryPlatter sharedInstance]]) {
  52. [[self stackView] addSubview:[KAIBatteryPlatter sharedInstance]];
  53. [[self stackView] addArrangedSubview:[KAIBatteryPlatter sharedInstance]];
  54. }
  55. if([KAISelf.superview respondsToSelector:@selector(fixComplicationsViewFrame)]) {
  56. [KAISelf.superview performSelector:@selector(fixComplicationsViewFrame) withObject:KAISelf.superview afterDelay:0.35];
  57. }
  58. isUpdating = NO;
  59. });
  60. }
  61. }
  62. %new
  63. +(id)sharedListViewForKai {
  64. return list;
  65. }
  66. %end
  67. %hook BCBatteryDevice
  68. %property (nonatomic, strong) KAIBatteryCell *kaiCell;
  69. -(void)setCharging:(BOOL)arg1 {
  70. //sends the noti to update battery info
  71. [[NSNotificationCenter defaultCenter] postNotificationName:@"KaiInfoChanged" object:nil userInfo:nil];
  72. %orig;
  73. }
  74. -(void)setBatterySaverModeActive:(BOOL)arg1 {
  75. //sends the noti to update battery info
  76. [[NSNotificationCenter defaultCenter] postNotificationName:@"KaiInfoChanged" object:nil userInfo:nil];
  77. %orig;
  78. }
  79. -(void)setPercentCharge:(NSInteger)arg1 {
  80. //sends the noti to update battery info
  81. if(arg1!=0) {
  82. [[NSNotificationCenter defaultCenter] postNotificationName:@"KaiInfoChanged" object:nil userInfo:nil];
  83. }
  84. %orig;
  85. }
  86. %new
  87. -(id)kaiCellForDevice {
  88. if(self && self.kaiCell == nil) {
  89. self.kaiCell = [[KAIBatteryCell alloc] initWithFrame:CGRectMake(0,0,[KAIBatteryPlatter sharedInstance].frame.size.width,0) device:self]; }
  90. ((KAIBatteryCell *)self.kaiCell).translatesAutoresizingMaskIntoConstraints = NO;
  91. [(KAIBatteryCell *)self.kaiCell updateInfo];
  92. return self.kaiCell;
  93. }
  94. %new
  95. -(void)resetKaiCellForNewPrefs {
  96. self.kaiCell = [[KAIBatteryCell alloc] initWithFrame:CGRectMake(0,0,[KAIBatteryPlatter sharedInstance].frame.size.width,0) device:self];
  97. ((KAIBatteryCell *)self.kaiCell).translatesAutoresizingMaskIntoConstraints = NO;
  98. [(KAIBatteryCell *)self.kaiCell updateInfo];
  99. }
  100. %end
  101. %hook KAICSTarget //Again, not a class
  102. -(void)_transitionChargingViewToVisible:(BOOL)arg1 showBattery:(BOOL)arg2 animated:(BOOL)arg3 {
  103. if(hideChargingAnimation) {
  104. //Yeah bro this just makes the method never call to show the charging thing
  105. %orig(NO,NO,NO);
  106. }
  107. }
  108. -(void)_transitionChargingViewToVisible:(BOOL)arg1 showBattery:(BOOL)arg2 animated:(BOOL)arg3 force:(BOOL)arg4 { //might just be ios12
  109. if(hideChargingAnimation) {
  110. //Same idea
  111. %orig(NO,NO,NO,NO);
  112. }
  113. }
  114. %end
  115. %end
  116. %group drm
  117. %hook SBIconController
  118. -(void)viewDidAppear:(BOOL)arg1 {
  119. %orig;
  120. UIAlertController* alert2 = [UIAlertController alertControllerWithTitle:@"kai"
  121. message:@"Woops! Chariz is saying your device has not purchased Multipla! You must have purchased Multipla to use the kai beta. Please make sure to link your device to your Chariz account!"
  122. preferredStyle:UIAlertControllerStyleAlert];
  123. UIAlertAction* yes = [UIAlertAction actionWithTitle:@"I understand" style:UIAlertActionStyleDestructive
  124. handler:^(UIAlertAction * action) {
  125. }];
  126. [alert2 addAction:yes];
  127. [self presentViewController:alert2 animated:YES completion:nil];
  128. }
  129. %end
  130. %end
  131. %ctor {
  132. preferencesChanged();
  133. CFNotificationCenterAddObserver(
  134. CFNotificationCenterGetDarwinNotifyCenter(),
  135. &observer,
  136. (CFNotificationCallback)applyPrefs,
  137. kSettingsChangedNotification,
  138. NULL,
  139. CFNotificationSuspensionBehaviorDeliverImmediately
  140. );
  141. //Bro Muirey helped me figure out a logical way to do this because iOS 12-13 classes have changed
  142. Class cls = kCFCoreFoundationVersionNumber > 1600 ? ([objc_getClass("CSAdjunctListView") class]) : ([objc_getClass("SBDashBoardAdjunctListView") class]);
  143. Class CSCls = kCFCoreFoundationVersionNumber > 1600 ? ([objc_getClass("CSCoverSheetViewController") class]) : ([objc_getClass("SBDashBoardViewController") class]);
  144. //BOOL bypass = YES;
  145. BOOL bypass = NO;
  146. 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"]) || bypass) {
  147. %init(main, KAITarget = cls, KAICSTarget = CSCls); //BIG BRAIN BRO!!
  148. } else if(!bypass && !([[NSFileManager defaultManager] fileExistsAtPath:@"/var/lib/dpkg/info/xyz.burritoz.thomz.multipla.list"] && [[NSFileManager defaultManager] fileExistsAtPath:@"/var/lib/dpkg/info/xyz.burritoz.thomz.multipla.md5sums"])) {
  149. //if(0==1)
  150. %init(drm);
  151. }
  152. }