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 4.2KB

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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. #include <CoreFoundation/CoreFoundation.h>
  2. #import <Foundation/Foundation.h>
  3. #include <stdio.h>
  4. #import <objc/runtime.h>
  5. #import <UIKit/UIKit.h>
  6. #import "KAIBattery.mm"
  7. @interface UIApplication (Kai)
  8. +(id)sharedApplication;
  9. -(BOOL)launchApplicationWithIdentifier:(id)arg1 suspended:(BOOL)arg2;
  10. @end
  11. @interface CSCoverSheetViewBase : UIView
  12. @property (nonatomic, strong) KAIBattery *battery;
  13. -(void)KaiUpdate;
  14. -(void)KaiInit;
  15. @end
  16. @interface SBCoverSheetPrimarySlidingViewController
  17. -(void)KaiUpdate;
  18. @end
  19. @interface CSMainPageView : UIView
  20. @end
  21. @interface _CSSingleBatteryChargingView : UIView
  22. @end
  23. BOOL setFrame = NO;
  24. UIView *batteryWidgetController;
  25. KAIBattery *batteryWidget;
  26. CSCoverSheetViewBase *base;
  27. CGRect original;
  28. CGRect originalBattery;
  29. /*
  30. - (void)addObserver:(NSObject *)observer
  31. forKeyPath:(NSString *)keyPath
  32. options:(NSKeyValueObservingOptions)options
  33. context:(void *)context*/
  34. /*
  35. %hook BCBatterDeviceController
  36. +(id)sharedInstance {
  37. [%orig addObserver:self forKeyPath:@"sortedDevices" options:NSKeyValueObservingOptionNew context:nil];
  38. return %orig;
  39. }
  40. -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
  41. if ([keyPath isEqualToString:@"sortedDevices"]) {
  42. [[UIApplication sharedApplication] launchApplicationWithIdentifier:@"com.apple.weather" suspended:NO];
  43. }
  44. }
  45. %end*/
  46. %hook CSMainPageView
  47. -(void)updateForPresentation:(id)arg1 {
  48. if(!setFrame) {
  49. if([self.subviews count] > 0) {
  50. CSCoverSheetViewBase *base = [self.subviews objectAtIndex:0];
  51. [base KaiInit];
  52. }
  53. }
  54. }
  55. %end
  56. %hook SBCoverSheetPrimarySlidingViewController
  57. -(void)viewWillAppear:(BOOL)arg1 {
  58. %orig;
  59. [[NSNotificationCenter defaultCenter] addObserver:self
  60. selector:@selector(KaiUpdate)
  61. name:@"KaiInfoChanged"
  62. object:nil];
  63. }
  64. %new
  65. -(void)KaiUpdate {
  66. [batteryWidget updateBattery];
  67. [base KaiUpdate];
  68. }
  69. /*
  70. -(void)viewWillDisappear:(BOOL)arg1 {
  71. %orig;
  72. [batteryWidget.battery updateBattery];
  73. [batteryWidget KaiUpdate];
  74. }*/
  75. %end
  76. %hook CSCoverSheetViewBase
  77. %property (nonatomic, strong) KAIBattery *battery;
  78. -(void)traitCollectionDidChange:(id)arg1 {
  79. %orig;
  80. [batteryWidget darkLightMode];
  81. }
  82. %new
  83. -(void)KaiInit {
  84. if(!setFrame) {
  85. original = self.frame;
  86. UIView *scroller;
  87. if([self.subviews count] > 1) {
  88. UIView *temp = [self.subviews objectAtIndex:1];
  89. if([temp.subviews count] > 0) {
  90. scroller = [temp.subviews objectAtIndex:0];
  91. base = self;
  92. }
  93. }
  94. KAIBattery *battery = [[KAIBattery alloc] initWithFrame:CGRectMake(8, 0, self.frame.size.width - 16, self.frame.size.height)];
  95. originalBattery = battery.frame;
  96. [scroller addSubview:battery];
  97. setFrame = YES;
  98. batteryWidgetController = scroller;
  99. batteryWidget = battery;
  100. }
  101. [self KaiUpdate];
  102. [batteryWidget darkLightMode];
  103. }
  104. %new
  105. -(void)KaiUpdate {
  106. [UIView animateWithDuration:0.3 animations:^{
  107. batteryWidgetController.frame = CGRectMake(
  108. original.origin.x,
  109. original.origin.y + (batteryWidget.number * 85),
  110. original.size.width,
  111. original.size.height
  112. );
  113. batteryWidget.frame = CGRectMake(
  114. originalBattery.origin.x,
  115. originalBattery.origin.y - (batteryWidget.number * 85),
  116. originalBattery.size.width,
  117. originalBattery.size.height
  118. );
  119. }];
  120. [batteryWidget darkLightMode];
  121. }
  122. %end
  123. %hook BCBatteryDevice
  124. - (id)initWithIdentifier:(id)arg1 vendor:(long long)arg2 productIdentifier:(long long)arg3 parts:(unsigned long long)arg4 matchIdentifier:(id)arg5 {
  125. [self addObserver:self forKeyPath:@"name" options:NSKeyValueObservingOptionNew context:nil];
  126. [self addObserver:self forKeyPath:@"charging" options:NSKeyValueObservingOptionNew context:nil];
  127. //[self setValue:@"crash" forKeyPath:@"euhidehuud"];
  128. return %orig;
  129. }
  130. -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
  131. dispatch_async(dispatch_get_main_queue(), ^{
  132. [[NSNotificationCenter defaultCenter] postNotificationName:@"KaiInfoChanged" object:nil userInfo:nil];
  133. });
  134. }
  135. %end
  136. %hook _CSSingleBatteryChargingView
  137. -(void)initWithFrame:(CGRect)arg1 {
  138. %orig;
  139. [self removeFromSuperview];
  140. }
  141. -(CGFloat)desiredVisibilityDuration {
  142. return 0;
  143. }
  144. -(void)setBatteryVisible:(BOOL)arg1 {
  145. %orig(NO);
  146. }
  147. %end