Device battery indicators on your Lock Screen
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

165 Zeilen
4.7KB

  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 CSAdjunctListView : UIView
  12. @property (nonatomic, strong) KAIBattery *batteryView;
  13. @property (nonatomic, assign) BOOL hasKai;
  14. @property (nonatomic, assign) NSInteger previousKaiCount;
  15. -(UIView *)stackView;
  16. -(void)setStackView:(UIStackView *)arg1;
  17. -(void)KaiUpdate;
  18. @end
  19. @interface CSMainPageView : UIView
  20. -(void)updateForPresentation:(id)arg1;
  21. @end
  22. @interface _CSSingleBatteryChargingView : UIView
  23. @end
  24. @interface NCNotificationListView : UIView
  25. @end
  26. BOOL setFrame = NO;
  27. CGRect original = CGRectMake(0,0,0,0);
  28. CGRect originalBattery;
  29. %hook CSAdjunctListView
  30. %property (nonatomic, strong) KAIBattery *batteryView;
  31. %property (nonatomic, assign) BOOL hasKai;
  32. %property (nonatomic, assign) NSInteger previousKaiCount;
  33. -(void)_layoutStackView {
  34. NSLog(@"Kai: Laying out stack view");
  35. //%orig;
  36. if(!self.hasKai) {
  37. //original = self.superview.superview.frame;
  38. self.batteryView = [[KAIBattery alloc] initWithFrame:CGRectMake(UIScreen.mainScreen.bounds.origin.x, 0, UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height)];
  39. originalBattery = self.batteryView.frame;
  40. //[[self stackView] addSubview:self.batteryView];
  41. setFrame = YES;
  42. self.previousKaiCount = 0;
  43. self.hasKai = YES;
  44. [[NSNotificationCenter defaultCenter] addObserver:self
  45. selector:@selector(KaiInfo)
  46. name:@"KaiInfoChanged"
  47. object:nil];
  48. [self.batteryView darkLightMode];
  49. //[self setStackView:self.batteryView];
  50. }
  51. [self KaiUpdate];
  52. %orig;
  53. }
  54. -(void)setStackView:(UIStackView *)arg1 {
  55. NSLog(@"Kai: Updating setting stack view");
  56. if(!self.hasKai) {
  57. //original = self.superview.superview.frame;
  58. self.batteryView = [[KAIBattery alloc] initWithFrame:CGRectMake(0, 0, UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height)];
  59. originalBattery = self.batteryView.frame;
  60. //[[self stackView] addSubview:self.batteryView];
  61. setFrame = YES;
  62. self.previousKaiCount = 0;
  63. self.hasKai = YES;
  64. [[NSNotificationCenter defaultCenter] addObserver:self
  65. selector:@selector(KaiInfo)
  66. name:@"KaiInfoChanged"
  67. object:nil];
  68. [self.batteryView darkLightMode];
  69. //[self setStackView:self.batteryView];
  70. }
  71. UIStackView *newView = arg1;
  72. if(![arg1.subviews containsObject:self.batteryView]) {
  73. //[newView addSubview:self.batteryView];
  74. [newView addArrangedSubview:self.batteryView];
  75. }
  76. newView.frame = CGRectMake(newView.frame.origin.x, newView.frame.origin.y, newView.frame.size.width, newView.frame.size.height + self.batteryView.frame.size.height);
  77. original = newView.frame;
  78. %orig(newView);
  79. }
  80. %new
  81. -(void)KaiUpdate {
  82. NSLog(@"Kai: Updating Pos.");
  83. dispatch_async(dispatch_get_main_queue(), ^{
  84. [UIView animateWithDuration:0.3 animations:^{
  85. self.batteryView.frame = CGRectMake(UIScreen.mainScreen.bounds.origin.x, 0, UIScreen.mainScreen.bounds.size.width, (self.batteryView.number * 85));
  86. self.batteryView.hidden = YES;
  87. self.batteryView.hidden = NO;
  88. //self.batteryView.superview.frame = CGRectMake(original.origin.x, original.origin.y, original.size.width, original.size.height + (self.batteryView.number * 85));
  89. }];
  90. [self.batteryView darkLightMode];
  91. });
  92. }
  93. %new
  94. -(void)KaiInfo {
  95. NSLog(@"Kai: Updating Info");
  96. [self.batteryView updateBattery];
  97. [self KaiUpdate];
  98. }
  99. %end
  100. %hook BCBatteryDevice
  101. - (id)initWithIdentifier:(id)arg1 vendor:(long long)arg2 productIdentifier:(long long)arg3 parts:(unsigned long long)arg4 matchIdentifier:(id)arg5 {
  102. [self addObserver:self forKeyPath:@"name" options:NSKeyValueObservingOptionNew context:nil];
  103. [self addObserver:self forKeyPath:@"charging" options:NSKeyValueObservingOptionNew context:nil];
  104. [self addObserver:self forKeyPath:@"powerSourceState" options:NSKeyValueObservingOptionNew context:nil];
  105. [self addObserver:self forKeyPath:@"batterySaverModeActive" options:NSKeyValueObservingOptionNew context:nil];
  106. [self addObserver:self forKeyPath:@"percentCharge" options:NSKeyValueObservingOptionNew context:nil];
  107. //[self setValue:@"crash" forKeyPath:@"euhidehuud"];
  108. return %orig;
  109. }
  110. -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
  111. dispatch_async(dispatch_get_main_queue(), ^{
  112. [[NSNotificationCenter defaultCenter] postNotificationName:@"KaiInfoChanged" object:nil userInfo:nil];
  113. });
  114. }
  115. %end
  116. %hook _CSSingleBatteryChargingView
  117. -(void)initWithFrame:(CGRect)arg1 {
  118. %orig;
  119. [self removeFromSuperview];
  120. }
  121. -(CGFloat)desiredVisibilityDuration {
  122. return 0;
  123. }
  124. -(void)setBatteryVisible:(BOOL)arg1 {
  125. %orig(NO);
  126. }
  127. %end