Device battery indicators on your Lock Screen
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Kai.xm 5.3KB

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