Device battery indicators on your Lock Screen
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

129 lines
3.4KB

  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 *battery;
  13. @property (nonatomic, assign) BOOL hasKai;
  14. @property (nonatomic, assign) NSInteger previousKaiCount;
  15. -(void)KaiUpdate;
  16. @end
  17. @interface CSMainPageView : UIView
  18. -(void)updateForPresentation:(id)arg1;
  19. @end
  20. @interface _CSSingleBatteryChargingView : UIView
  21. @end
  22. /*
  23. @interface NCNotificationListView : UIView
  24. @property (nonatomic, assign) BOOL hasKai;
  25. @property (nonatomic, assign) NSInteger previousKaiCount;
  26. @end*/
  27. BOOL setFrame = NO;
  28. CGRect original;
  29. CGRect originalBattery;
  30. %hook CSAdjunctListView
  31. %property (nonatomic, strong) KAIBattery *battery;
  32. %property (nonatomic, assign) BOOL hasKai;
  33. %property (nonatomic, assign) NSInteger previousKaiCount;
  34. -(id)initWithFrame:(CGRect)arg1 {
  35. original = self.frame;
  36. self.battery = [[KAIBattery alloc] initWithFrame:CGRectMake(8, 0, self.frame.size.width - 16, UIScreen.mainScreen.bounds.size.width)];
  37. originalBattery = self.battery.frame;
  38. [self addSubview:self.battery];
  39. setFrame = YES;
  40. self.previousKaiCount = 0;
  41. [[NSNotificationCenter defaultCenter] addObserver:self
  42. selector:@selector(KaiUpdate)
  43. name:@"KaiInfoChanged"
  44. object:nil];
  45. //[self KaiUpdate];
  46. [self.battery darkLightMode];
  47. return %orig;
  48. }
  49. %new
  50. -(void)KaiUpdate {
  51. if(self.battery) {
  52. [self.battery updateBattery];
  53. dispatch_async(dispatch_get_main_queue(), ^{
  54. [UIView animateWithDuration:0.3 animations:^{
  55. self.translatesAutoresizingMaskIntoConstraints = NO;
  56. [self.topAnchor constraintEqualToAnchor:self.superview.topAnchor constant:(self.battery.number * 85)].active = YES;
  57. self.battery.frame = CGRectMake(
  58. originalBattery.origin.x,
  59. originalBattery.origin.y - (self.battery.number * 85),
  60. originalBattery.size.width,
  61. originalBattery.size.height
  62. );
  63. }];
  64. [self.battery darkLightMode];
  65. });
  66. }
  67. }
  68. %end
  69. %hook BCBatteryDevice
  70. - (id)initWithIdentifier:(id)arg1 vendor:(long long)arg2 productIdentifier:(long long)arg3 parts:(unsigned long long)arg4 matchIdentifier:(id)arg5 {
  71. [self addObserver:self forKeyPath:@"name" options:NSKeyValueObservingOptionNew context:nil];
  72. [self addObserver:self forKeyPath:@"charging" options:NSKeyValueObservingOptionNew context:nil];
  73. [self addObserver:self forKeyPath:@"powerSourceState" options:NSKeyValueObservingOptionNew context:nil];
  74. [self addObserver:self forKeyPath:@"batterySaverModeActive" options:NSKeyValueObservingOptionNew context:nil];
  75. [self addObserver:self forKeyPath:@"percentCharge" options:NSKeyValueObservingOptionNew context:nil];
  76. //[self setValue:@"crash" forKeyPath:@"euhidehuud"];
  77. return %orig;
  78. }
  79. -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
  80. dispatch_async(dispatch_get_main_queue(), ^{
  81. [[NSNotificationCenter defaultCenter] postNotificationName:@"KaiInfoChanged" object:nil userInfo:nil];
  82. });
  83. }
  84. %end
  85. %hook _CSSingleBatteryChargingView
  86. -(void)initWithFrame:(CGRect)arg1 {
  87. %orig;
  88. [self removeFromSuperview];
  89. }
  90. -(CGFloat)desiredVisibilityDuration {
  91. return 0;
  92. }
  93. -(void)setBatteryVisible:(BOOL)arg1 {
  94. %orig(NO);
  95. }
  96. %end