Device battery indicators on your Lock Screen
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

145 Zeilen
4.2KB

  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. #define KAISelf ((CSAdjunctListView *)self)
  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 SBDashBoardAdjunctListView : UIView
  18. @property (nonatomic, assign) BOOL hasKai;
  19. -(UIStackView *)stackView;
  20. -(void)setStackView:(UIStackView *)arg1;
  21. -(void)KaiUpdate;
  22. @end
  23. @interface CSMainPageView : UIView
  24. -(void)updateForPresentation:(id)arg1;
  25. @end
  26. @interface _CSSingleBatteryChargingView : UIView
  27. @end
  28. @interface NSLayoutConstraint (Kai)
  29. +(id)constraintWithAnchor:(id)arg1 relatedBy:(long long)arg2 toAnchor:(id)arg3 multiplier:(double)arg4 constant:(double)arg5 ;
  30. @end
  31. @interface CALayer (kai)
  32. @property (nonatomic, assign) BOOL continuousCorners;
  33. @end
  34. BOOL isUpdating = NO;
  35. //prefs
  36. BOOL enabled;
  37. BOOL disableGlyphs;
  38. BOOL hidePercent;
  39. BOOL showAll;
  40. BOOL belowMusic;
  41. BOOL hideDeviceLabel;
  42. NSInteger bannerStyle;
  43. NSInteger bannerAlign;
  44. double spacing;
  45. double glyphSize;
  46. double bannerHeight;
  47. double cornerRadius;
  48. double bannerWidthFactor;
  49. double horizontalOffset;
  50. #import "KAIBattery.mm"
  51. #define PLIST_PATH @"/User/Library/Preferences/com.burritoz.kaiprefs.plist"
  52. #define kIdentifier @"com.burritoz.kaiprefs"
  53. #define kSettingsChangedNotification (CFStringRef)@"com.burritoz.kaiprefs/reload"
  54. #define kSettingsPath @"/var/mobile/Library/Preferences/com.burritoz.kaiprefs.plist"
  55. NSDictionary *prefs = nil;
  56. static void *observer = NULL;
  57. static void reloadPrefs()
  58. {
  59. if ([NSHomeDirectory() isEqualToString:@"/var/mobile"])
  60. {
  61. CFArrayRef keyList = CFPreferencesCopyKeyList((CFStringRef)kIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
  62. if (keyList)
  63. {
  64. prefs = (NSDictionary *)CFBridgingRelease(CFPreferencesCopyMultiple(keyList, (CFStringRef)kIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost));
  65. if (!prefs)
  66. {
  67. prefs = [NSDictionary new];
  68. }
  69. CFRelease(keyList);
  70. }
  71. }
  72. else
  73. {
  74. prefs = [NSDictionary dictionaryWithContentsOfFile:kSettingsPath];
  75. }
  76. }
  77. static BOOL boolValueForKey(NSString *key, BOOL defaultValue) {
  78. return (prefs && [prefs objectForKey:key] ? [[prefs objectForKey:key] boolValue] : defaultValue);
  79. }
  80. static double numberForValue(NSString *key, double defaultValue) {
  81. return (prefs && [prefs objectForKey:key] ? [[prefs objectForKey:key] doubleValue] : defaultValue);
  82. }
  83. static void preferencesChanged()
  84. {
  85. CFPreferencesAppSynchronize((CFStringRef)kIdentifier);
  86. reloadPrefs();
  87. enabled = boolValueForKey(@"enabled", YES);
  88. spacing = numberForValue(@"spacing", 5);
  89. glyphSize = numberForValue(@"glyphSize", 30);
  90. bannerHeight = numberForValue(@"bannerHeight", 80);
  91. cornerRadius = numberForValue(@"cornerRadius", 13);
  92. disableGlyphs = boolValueForKey(@"disableGlyphs", NO);
  93. hidePercent = boolValueForKey(@"hidePercent", NO);
  94. bannerStyle = numberForValue(@"bannerStyle", 1);
  95. showAll = boolValueForKey(@"showAll", NO);
  96. bannerWidthFactor = numberForValue(@"bannerWidthFactor", 0);
  97. hideDeviceLabel = boolValueForKey(@"hideDeviceLabel", NO);
  98. bannerAlign = numberForValue(@"bannerAlign", 2);
  99. horizontalOffset = numberForValue(@"horizontalOffset", 0);
  100. belowMusic = boolValueForKey(@"belowMusic", NO);
  101. if(disableGlyphs) {
  102. glyphSize = 0;
  103. }
  104. }
  105. static void applyPrefs()
  106. {
  107. preferencesChanged();
  108. isUpdating = YES;
  109. [UIView animateWithDuration:0.3 animations:^{
  110. [KAIBattery sharedInstance].alpha = 0;
  111. } completion:^(BOOL finished){
  112. [[KAIBattery sharedInstance] updateBattery];
  113. [(CSAdjunctListView *)([KAIBattery sharedInstance].superview.superview) KaiUpdate];
  114. [UIView animateWithDuration:0.35 animations:^{
  115. [KAIBattery sharedInstance].alpha = 1;
  116. } completion:^(BOOL finished){
  117. isUpdating = NO;
  118. }];
  119. }];
  120. }