Device battery indicators on your Lock Screen
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. #import "Kai.h"
  2. %group main
  3. %hook KAITarget //This class is defined in %ctor, KAITarget is not a class name.
  4. %property (nonatomic, assign) BOOL hasKai;
  5. -(void)_layoutStackView {
  6. NSInteger lastSlot = [[self stackView].subviews count] -1;
  7. //this code is used to determine if kai is at the bottom of the stack view
  8. if([[self stackView].subviews objectAtIndex:lastSlot] != [KAIBatteryPlatter sharedInstance] && belowMusic) {
  9. //if it is not, but the option to have kai below music is on, i simply remove from it's current pos.
  10. //and insert into last slot.
  11. [[self stackView] removeArrangedSubview:[KAIBatteryPlatter sharedInstance]];
  12. [[self stackView] insertArrangedSubview:[KAIBatteryPlatter sharedInstance] atIndex:lastSlot];
  13. } else if([[self stackView].subviews objectAtIndex:0] != [KAIBatteryPlatter sharedInstance] && !belowMusic) {
  14. [[self stackView] removeArrangedSubview:[KAIBatteryPlatter sharedInstance]];
  15. [[self stackView] insertArrangedSubview:[KAIBatteryPlatter sharedInstance] atIndex:0];
  16. }
  17. if([KAISelf.superview respondsToSelector:@selector(fixComplicationsViewFrame)]) {
  18. [(NCNotificationListView *)(KAISelf.superview) fixComplicationsViewFrame];
  19. }
  20. [[KAIBatteryPlatter sharedInstance] calculateHeight];
  21. %orig;
  22. }
  23. -(void)removeArrangedSubview:(id)arg1 {
  24. %orig;
  25. [[KAIBatteryPlatter sharedInstance] calculateHeight];
  26. }
  27. -(void)addArrangedSubview:(id)arg1 {
  28. %orig;
  29. [[KAIBatteryPlatter sharedInstance] calculateHeight];
  30. }
  31. -(void)setStackView:(UIStackView *)arg1 {
  32. if(!KAISelf.hasKai) {
  33. KAIBatteryPlatter *battery = [[KAIBatteryPlatter alloc] initWithFrame:[self stackView].frame];
  34. //Add noti observer
  35. [[NSNotificationCenter defaultCenter] addObserver:self
  36. selector:@selector(KaiInfo)
  37. name:@"KaiInfoChanged"
  38. object:nil];
  39. KAISelf.hasKai = YES;
  40. if(![arg1.subviews containsObject:battery]) { //if not added
  41. //add kai to the stack view
  42. [arg1 addArrangedSubview:battery];
  43. }
  44. [battery updateBattery];
  45. //send the adjusted stackview as arg1
  46. %orig(arg1);
  47. }
  48. }
  49. %new
  50. -(void)KaiInfo {
  51. if(!isUpdating) {
  52. isUpdating = YES;
  53. //NSLog(@"kai: kai info will update");
  54. dispatch_async(dispatch_get_main_queue(), ^{
  55. [[KAIBatteryPlatter sharedInstance] updateBattery];
  56. if([KAIBatteryPlatter sharedInstance].number == 0) {
  57. [[KAIBatteryPlatter sharedInstance] removeFromSuperview];
  58. [[self stackView] removeArrangedSubview:[KAIBatteryPlatter sharedInstance]];
  59. } else if(![[self stackView].subviews containsObject:[KAIBatteryPlatter sharedInstance]]) {
  60. [[self stackView] addSubview:[KAIBatteryPlatter sharedInstance]];
  61. [[self stackView] addArrangedSubview:[KAIBatteryPlatter sharedInstance]];
  62. }
  63. if([KAISelf.superview respondsToSelector:@selector(fixComplicationsViewFrame)]) {
  64. [KAISelf.superview performSelector:@selector(fixComplicationsViewFrame) withObject:KAISelf.superview afterDelay:0.35];
  65. //[KAISelf.superview performSelector:@selector(fixComplicationsViewFrame) withObject:KAISelf.superview afterDelay:0.5];
  66. }
  67. isUpdating = NO;
  68. });
  69. }
  70. }
  71. %end
  72. %hook BCBatteryDevice
  73. %property (nonatomic, strong) KAIBatteryCell *kaiCell;
  74. - (id)initWithIdentifier:(id)arg1 vendor:(long long)arg2 productIdentifier:(long long)arg3 parts:(unsigned long long)arg4 matchIdentifier:(id)arg5 {
  75. //Posts a notification to self when these keys change
  76. [self addObserver:self forKeyPath:@"charging" options:NSKeyValueObservingOptionNew context:nil];
  77. [self addObserver:self forKeyPath:@"batterySaverModeActive" options:NSKeyValueObservingOptionNew context:nil];
  78. [self addObserver:self forKeyPath:@"percentCharge" options:NSKeyValueObservingOptionNew context:nil];
  79. return %orig;
  80. }
  81. -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
  82. //if([self isMemberOfClass:[objc_getClass("BCBatteryDevice") class]] && [self respondsToSelector:@selector(_kaiCell)] && object == self && ([keyPath isEqualToString:@"charging"] || [keyPath isEqualToString:@"percentCharge"] || [keyPath isEqualToString:@"batterySaverModeActive"])) {
  83. //sends the noti to update battery info
  84. [[NSNotificationCenter defaultCenter] postNotificationName:@"KaiInfoChanged" object:nil userInfo:nil];
  85. //}
  86. }
  87. %new
  88. -(id)kaiCellForDevice {
  89. if(self && self.kaiCell == nil) {
  90. self.kaiCell = [[KAIBatteryCell alloc] initWithFrame:CGRectMake(0,0,[KAIBatteryPlatter sharedInstance].frame.size.width,0) device:self]; }
  91. ((KAIBatteryCell *)self.kaiCell).translatesAutoresizingMaskIntoConstraints = NO;
  92. [(KAIBatteryCell *)self.kaiCell updateInfo];
  93. return self.kaiCell;
  94. }
  95. %new
  96. -(void)resetKaiCellForNewPrefs {
  97. self.kaiCell = [[KAIBatteryCell alloc] initWithFrame:CGRectMake(0,0,[KAIBatteryPlatter sharedInstance].frame.size.width,0) device:self];
  98. ((KAIBatteryCell *)self.kaiCell).translatesAutoresizingMaskIntoConstraints = NO;
  99. [(KAIBatteryCell *)self.kaiCell updateInfo];
  100. }
  101. %end
  102. %hook KAICSTarget //Again, not a class
  103. -(void)_transitionChargingViewToVisible:(BOOL)arg1 showBattery:(BOOL)arg2 animated:(BOOL)arg3 {
  104. if(hideChargingAnimation) {
  105. //Yeah bro this just makes the method never call to show the charging thing
  106. %orig(NO,NO,NO);
  107. }
  108. }
  109. -(void)_transitionChargingViewToVisible:(BOOL)arg1 showBattery:(BOOL)arg2 animated:(BOOL)arg3 force:(BOOL)arg4 { //might just be ios12
  110. if(hideChargingAnimation) {
  111. //Same idea
  112. %orig(NO,NO,NO,NO);
  113. }
  114. }
  115. %end
  116. %end
  117. %group drm
  118. %hook SBIconController
  119. -(void)viewDidAppear:(BOOL)arg1 {
  120. %orig;
  121. UIAlertController* alert2 = [UIAlertController alertControllerWithTitle:@"kai"
  122. message:@"Woops! Chariz is saying your device has not purchased Multipla! You must have purchased Multipla to use the kai beta. Please make sure to link your device to your Chariz account!"
  123. preferredStyle:UIAlertControllerStyleAlert];
  124. UIAlertAction* yes = [UIAlertAction actionWithTitle:@"I understand" style:UIAlertActionStyleDestructive
  125. handler:^(UIAlertAction * action) {
  126. }];
  127. [alert2 addAction:yes];
  128. [self presentViewController:alert2 animated:YES completion:nil];
  129. }
  130. %end
  131. %end
  132. %ctor {
  133. preferencesChanged();
  134. CFNotificationCenterAddObserver(
  135. CFNotificationCenterGetDarwinNotifyCenter(),
  136. &observer,
  137. (CFNotificationCallback)applyPrefs,
  138. kSettingsChangedNotification,
  139. NULL,
  140. CFNotificationSuspensionBehaviorDeliverImmediately
  141. );
  142. //Bro Muirey helped me figure out a logical way to do this because iOS 12-13 classes have changed
  143. Class cls = kCFCoreFoundationVersionNumber > 1600 ? ([objc_getClass("CSAdjunctListView") class]) : ([objc_getClass("SBDashBoardAdjunctListView") class]);
  144. Class CSCls = kCFCoreFoundationVersionNumber > 1600 ? ([objc_getClass("CSCoverSheetViewController") class]) : ([objc_getClass("SBDashBoardViewController") class]);
  145. //BOOL bypass = YES;
  146. BOOL bypass = NO;
  147. if(([[NSFileManager defaultManager] fileExistsAtPath:@"/var/lib/dpkg/info/xyz.burritoz.thomz.multipla.list"] && [[NSFileManager defaultManager] fileExistsAtPath:@"/var/lib/dpkg/info/xyz.burritoz.thomz.multipla.md5sums"]) || bypass) {
  148. %init(main, KAITarget = cls, KAICSTarget = CSCls); //BIG BRAIN BRO!!
  149. } else if(!bypass && !([[NSFileManager defaultManager] fileExistsAtPath:@"/var/lib/dpkg/info/xyz.burritoz.thomz.multipla.list"] && [[NSFileManager defaultManager] fileExistsAtPath:@"/var/lib/dpkg/info/xyz.burritoz.thomz.multipla.md5sums"])) {
  150. //if(0==1)
  151. %init(drm);
  152. }
  153. }