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.

180 lines
4.7KB

  1. #line 1 "Kai.xm"
  2. #include <CoreFoundation/CoreFoundation.h>
  3. #import <Foundation/Foundation.h>
  4. #include <stdio.h>
  5. #import <objc/runtime.h>
  6. #import <UIKit/UIKit.h>
  7. #import "KAIBattery.mm"
  8. BOOL setFrame = NO;
  9. KAIBattery *batteryWidget;
  10. CGRect original;
  11. @interface UIApplication (Kai)
  12. +(id)sharedApplication;
  13. -(BOOL)launchApplicationWithIdentifier:(id)arg1 suspended:(BOOL)arg2;
  14. @end
  15. @interface CSMainPageView : UIView
  16. @property (nonatomic, strong) KAIBattery *battery;
  17. -(void)updateForPresentation:(id)arg1;
  18. @end
  19. #include <substrate.h>
  20. #if defined(__clang__)
  21. #if __has_feature(objc_arc)
  22. #define _LOGOS_SELF_TYPE_NORMAL __unsafe_unretained
  23. #define _LOGOS_SELF_TYPE_INIT __attribute__((ns_consumed))
  24. #define _LOGOS_SELF_CONST const
  25. #define _LOGOS_RETURN_RETAINED __attribute__((ns_returns_retained))
  26. #else
  27. #define _LOGOS_SELF_TYPE_NORMAL
  28. #define _LOGOS_SELF_TYPE_INIT
  29. #define _LOGOS_SELF_CONST
  30. #define _LOGOS_RETURN_RETAINED
  31. #endif
  32. #else
  33. #define _LOGOS_SELF_TYPE_NORMAL
  34. #define _LOGOS_SELF_TYPE_INIT
  35. #define _LOGOS_SELF_CONST
  36. #define _LOGOS_RETURN_RETAINED
  37. #endif
  38. @class CSMainPageView; @class SBCoverSheetPrimarySlidingViewController;
  39. static void (*_logos_orig$_ungrouped$SBCoverSheetPrimarySlidingViewController$viewWillAppear$)(_LOGOS_SELF_TYPE_NORMAL SBCoverSheetPrimarySlidingViewController* _LOGOS_SELF_CONST, SEL, BOOL); static void _logos_method$_ungrouped$SBCoverSheetPrimarySlidingViewController$viewWillAppear$(_LOGOS_SELF_TYPE_NORMAL SBCoverSheetPrimarySlidingViewController* _LOGOS_SELF_CONST, SEL, BOOL); static void (*_logos_orig$_ungrouped$CSMainPageView$updateForPresentation$)(_LOGOS_SELF_TYPE_NORMAL CSMainPageView* _LOGOS_SELF_CONST, SEL, id); static void _logos_method$_ungrouped$CSMainPageView$updateForPresentation$(_LOGOS_SELF_TYPE_NORMAL CSMainPageView* _LOGOS_SELF_CONST, SEL, id);
  40. #line 47 "Kai.xm"
  41. static void _logos_method$_ungrouped$SBCoverSheetPrimarySlidingViewController$viewWillAppear$(_LOGOS_SELF_TYPE_NORMAL SBCoverSheetPrimarySlidingViewController* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, BOOL arg1) {
  42. _logos_orig$_ungrouped$SBCoverSheetPrimarySlidingViewController$viewWillAppear$(self, _cmd, arg1);
  43. [batteryWidget updateBattery];
  44. }
  45. __attribute__((used)) static KAIBattery * _logos_method$_ungrouped$CSMainPageView$battery(CSMainPageView * __unused self, SEL __unused _cmd) { return (KAIBattery *)objc_getAssociatedObject(self, (void *)_logos_method$_ungrouped$CSMainPageView$battery); }; __attribute__((used)) static void _logos_method$_ungrouped$CSMainPageView$setBattery(CSMainPageView * __unused self, SEL __unused _cmd, KAIBattery * rawValue) { objc_setAssociatedObject(self, (void *)_logos_method$_ungrouped$CSMainPageView$battery, rawValue, OBJC_ASSOCIATION_RETAIN_NONATOMIC); }
  46. static void _logos_method$_ungrouped$CSMainPageView$updateForPresentation$(_LOGOS_SELF_TYPE_NORMAL CSMainPageView* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, id arg1) {
  47. _logos_orig$_ungrouped$CSMainPageView$updateForPresentation$(self, _cmd, arg1);
  48. UIView *object = self;
  49. if(!setFrame) {
  50. original = self.frame;
  51. self.battery = [[KAIBattery alloc] initWithFrame:CGRectMake(8, 155, object.frame.size.width - 16, object.frame.size.height)];
  52. [self addSubview:self.battery];
  53. setFrame = YES;
  54. batteryWidget = self.battery;
  55. }
  56. object.frame = CGRectMake(
  57. original.origin.x,
  58. original.origin.y - (self.battery.number * 90),
  59. original.size.width,
  60. original.size.height + (self.battery.number * 90)
  61. );
  62. }
  63. static __attribute__((constructor)) void _logosLocalInit() {
  64. {Class _logos_class$_ungrouped$SBCoverSheetPrimarySlidingViewController = objc_getClass("SBCoverSheetPrimarySlidingViewController"); MSHookMessageEx(_logos_class$_ungrouped$SBCoverSheetPrimarySlidingViewController, @selector(viewWillAppear:), (IMP)&_logos_method$_ungrouped$SBCoverSheetPrimarySlidingViewController$viewWillAppear$, (IMP*)&_logos_orig$_ungrouped$SBCoverSheetPrimarySlidingViewController$viewWillAppear$);Class _logos_class$_ungrouped$CSMainPageView = objc_getClass("CSMainPageView"); MSHookMessageEx(_logos_class$_ungrouped$CSMainPageView, @selector(updateForPresentation:), (IMP)&_logos_method$_ungrouped$CSMainPageView$updateForPresentation$, (IMP*)&_logos_orig$_ungrouped$CSMainPageView$updateForPresentation$);{ char _typeEncoding[1024]; sprintf(_typeEncoding, "%s@:", @encode(KAIBattery *)); class_addMethod(_logos_class$_ungrouped$CSMainPageView, @selector(battery), (IMP)&_logos_method$_ungrouped$CSMainPageView$battery, _typeEncoding); sprintf(_typeEncoding, "v@:%s", @encode(KAIBattery *)); class_addMethod(_logos_class$_ungrouped$CSMainPageView, @selector(setBattery:), (IMP)&_logos_method$_ungrouped$CSMainPageView$setBattery, _typeEncoding); } } }
  65. #line 151 "Kai.xm"