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

4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 CSMainPageView : UIView
  12. @property (nonatomic, strong) KAIBattery *battery;
  13. -(void)updateForPresentation:(id)arg1;
  14. -(void)KaiUpdate;
  15. @end
  16. @interface SBCoverSheetPrimarySlidingViewController
  17. -(void)KaiUpdate;
  18. @end
  19. BOOL setFrame = NO;
  20. CSMainPageView *batteryWidget;
  21. CGRect original;
  22. CGRect originalBattery;
  23. /*
  24. - (void)addObserver:(NSObject *)observer
  25. forKeyPath:(NSString *)keyPath
  26. options:(NSKeyValueObservingOptions)options
  27. context:(void *)context*/
  28. /*
  29. %hook BCBatterDeviceController
  30. +(id)sharedInstance {
  31. [%orig addObserver:self forKeyPath:@"sortedDevices" options:NSKeyValueObservingOptionNew context:nil];
  32. return %orig;
  33. }
  34. -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
  35. if ([keyPath isEqualToString:@"sortedDevices"]) {
  36. [[UIApplication sharedApplication] launchApplicationWithIdentifier:@"com.apple.weather" suspended:NO];
  37. }
  38. }
  39. %end*/
  40. %hook SBCoverSheetPrimarySlidingViewController
  41. -(void)viewWillAppear:(BOOL)arg1 {
  42. %orig;
  43. [[NSNotificationCenter defaultCenter] addObserver:self
  44. selector:@selector(KaiUpdate)
  45. name:@"KaiInfoChanged"
  46. object:nil];
  47. }
  48. %new
  49. -(void)KaiUpdate {
  50. [batteryWidget.battery updateBattery];
  51. [batteryWidget KaiUpdate];
  52. }
  53. /*
  54. -(void)viewWillDisappear:(BOOL)arg1 {
  55. %orig;
  56. [batteryWidget.battery updateBattery];
  57. [batteryWidget KaiUpdate];
  58. }*/
  59. %end
  60. %hook CSMainPageView
  61. %property (nonatomic, strong) KAIBattery *battery;
  62. -(void)updateForPresentation:(id)arg1 {
  63. %orig;
  64. if(!setFrame) {
  65. original = self.frame;
  66. self.battery = [[KAIBattery alloc] initWithFrame:CGRectMake(8, self.frame.origin.y + 150, self.frame.size.width - 16, self.frame.size.height)];
  67. originalBattery = self.battery.frame;
  68. [self addSubview:self.battery];
  69. setFrame = YES;
  70. batteryWidget = self;
  71. }
  72. }
  73. %new
  74. -(void)KaiUpdate {
  75. self.frame = CGRectMake(
  76. original.origin.x,
  77. original.origin.y + (self.battery.number * 85),
  78. original.size.width,
  79. original.size.height
  80. );
  81. /*self.battery.frame = CGRectMake(
  82. originalBattery.origin.x,
  83. originalBattery.origin.y - (self.battery.number * 85) + 85,
  84. originalBattery.size.width,
  85. originalBattery.size.height
  86. );*/
  87. }
  88. %end
  89. %hook BCBatteryDevice
  90. - (id)initWithIdentifier:(id)arg1 vendor:(long long)arg2 productIdentifier:(long long)arg3 parts:(unsigned long long)arg4 matchIdentifier:(id)arg5 {
  91. [self addObserver:self forKeyPath:@"name" options:NSKeyValueObservingOptionNew context:nil];
  92. [self addObserver:self forKeyPath:@"charging" options:NSKeyValueObservingOptionNew context:nil];
  93. //[self setValue:@"crash" forKeyPath:@"euhidehuud"];
  94. return %orig;
  95. }
  96. -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
  97. dispatch_async(dispatch_get_main_queue(), ^{
  98. [[NSNotificationCenter defaultCenter] postNotificationName:@"KaiInfoChanged" object:nil userInfo:nil];
  99. });
  100. }
  101. %end