Device battery indicators on your Lock Screen
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

147 rindas
4.3KB

  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. BOOL hideChargingAnimation;
  43. NSInteger bannerStyle;
  44. NSInteger bannerAlign;
  45. double spacing;
  46. double glyphSize;
  47. double bannerHeight;
  48. double cornerRadius;
  49. double bannerWidthFactor;
  50. double horizontalOffset;
  51. #import "KAIBattery.mm"
  52. #define PLIST_PATH @"/User/Library/Preferences/com.burritoz.kaiprefs.plist"
  53. #define kIdentifier @"com.burritoz.kaiprefs"
  54. #define kSettingsChangedNotification (CFStringRef)@"com.burritoz.kaiprefs/reload"
  55. #define kSettingsPath @"/var/mobile/Library/Preferences/com.burritoz.kaiprefs.plist"
  56. NSDictionary *prefs = nil;
  57. static void *observer = NULL;
  58. static void reloadPrefs()
  59. {
  60. if ([NSHomeDirectory() isEqualToString:@"/var/mobile"])
  61. {
  62. CFArrayRef keyList = CFPreferencesCopyKeyList((CFStringRef)kIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
  63. if (keyList)
  64. {
  65. prefs = (NSDictionary *)CFBridgingRelease(CFPreferencesCopyMultiple(keyList, (CFStringRef)kIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost));
  66. if (!prefs)
  67. {
  68. prefs = [NSDictionary new];
  69. }
  70. CFRelease(keyList);
  71. }
  72. }
  73. else
  74. {
  75. prefs = [NSDictionary dictionaryWithContentsOfFile:kSettingsPath];
  76. }
  77. }
  78. static BOOL boolValueForKey(NSString *key, BOOL defaultValue) {
  79. return (prefs && [prefs objectForKey:key] ? [[prefs objectForKey:key] boolValue] : defaultValue);
  80. }
  81. static double numberForValue(NSString *key, double defaultValue) {
  82. return (prefs && [prefs objectForKey:key] ? [[prefs objectForKey:key] doubleValue] : defaultValue);
  83. }
  84. static void preferencesChanged()
  85. {
  86. CFPreferencesAppSynchronize((CFStringRef)kIdentifier);
  87. reloadPrefs();
  88. enabled = boolValueForKey(@"enabled", YES);
  89. spacing = numberForValue(@"spacing", 5);
  90. glyphSize = numberForValue(@"glyphSize", 30);
  91. bannerHeight = numberForValue(@"bannerHeight", 80);
  92. cornerRadius = numberForValue(@"cornerRadius", 13);
  93. disableGlyphs = boolValueForKey(@"disableGlyphs", NO);
  94. hidePercent = boolValueForKey(@"hidePercent", NO);
  95. bannerStyle = numberForValue(@"bannerStyle", 1);
  96. showAll = boolValueForKey(@"showAll", NO);
  97. bannerWidthFactor = numberForValue(@"bannerWidthFactor", 0);
  98. hideDeviceLabel = boolValueForKey(@"hideDeviceLabel", NO);
  99. bannerAlign = numberForValue(@"bannerAlign", 2);
  100. horizontalOffset = numberForValue(@"horizontalOffset", 0);
  101. belowMusic = boolValueForKey(@"belowMusic", NO);
  102. hideChargingAnimation = boolValueForKey(@"hideChargingAnimation", YES);
  103. if(disableGlyphs) {
  104. glyphSize = 0;
  105. }
  106. }
  107. static void applyPrefs()
  108. {
  109. preferencesChanged();
  110. isUpdating = YES;
  111. [UIView animateWithDuration:0.3 animations:^{
  112. [KAIBattery sharedInstance].alpha = 0;
  113. } completion:^(BOOL finished){
  114. [[KAIBattery sharedInstance] updateBattery];
  115. [(CSAdjunctListView *)([KAIBattery sharedInstance].superview.superview) KaiUpdate];
  116. [UIView animateWithDuration:0.35 animations:^{
  117. [KAIBattery sharedInstance].alpha = 1;
  118. } completion:^(BOOL finished){
  119. isUpdating = NO;
  120. }];
  121. }];
  122. }