Device battery indicators on your Lock Screen
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

155 lines
4.8KB

  1. #include <CoreFoundation/CoreFoundation.h>
  2. #import <Foundation/Foundation.h>
  3. #import <UIKit/UIKit.h>
  4. #import <objc/runtime.h>
  5. #define KAISelf ((CSAdjunctListView *)self) // for use when calling self in KAITarget
  6. @interface CSAdjunctListView : UIView
  7. @property (nonatomic, assign) BOOL hasKai;
  8. - (UIStackView *)stackView;
  9. - (void)_layoutStackView;
  10. - (void)setStackView:(UIStackView *)arg1;
  11. + (id)sharedListViewForKai;
  12. + (void)reorderKai;
  13. @end
  14. @interface SBMediaController : NSObject
  15. @property (nonatomic, strong) id nowPlayingApplication;
  16. - (BOOL)isPlaying;
  17. @end
  18. @interface CALayer (kai)
  19. @property (nonatomic, assign) BOOL continuousCorners;
  20. @end
  21. @interface SBCoverSheetPrimarySlidingViewController : UIViewController
  22. @end
  23. @interface APEPlatter : UIView
  24. @property (nonatomic, assign) BOOL removed;
  25. + (APEPlatter *)sharedInstance;
  26. @end
  27. @interface NCNotificationListView : UIView
  28. - (void)fixComplicationsViewFrame;
  29. @end
  30. BOOL ios13 = NO;
  31. BOOL isUpdating = NO;
  32. BOOL shouldBeAdded = YES;
  33. // prefs
  34. BOOL enabled;
  35. BOOL disableGlyphs;
  36. BOOL hidePercent;
  37. BOOL showAll;
  38. BOOL belowMusic;
  39. BOOL hideDeviceLabel;
  40. BOOL hideChargingAnimation;
  41. BOOL showAllMinusInternal;
  42. BOOL hideBatteryIcon;
  43. BOOL reAlignSelf;
  44. BOOL showPhone;
  45. BOOL removeForMedia;
  46. BOOL extraPaddingAfter;
  47. NSInteger bannerStyle;
  48. NSInteger bannerAlign;
  49. NSInteger textColor;
  50. double spacing;
  51. double glyphSize;
  52. double bannerHeight;
  53. double cornerRadius;
  54. double bannerWidthFactor;
  55. double horizontalOffset;
  56. double bannerAlpha;
  57. double kaiAlign;
  58. double spacingHorizontal;
  59. // by importing here, I can use vars in the .mm files
  60. #import "KAIBatteryCell.mm"
  61. #import "KAIBatteryPlatter.mm"
  62. #import "KAIStackView.mm"
  63. #define PLIST_PATH @"/User/Library/Preferences/com.burritoz.kaiprefs.plist"
  64. #define kIdentifier @"com.burritoz.kaiprefs"
  65. #define kSettingsChangedNotification (CFStringRef) @"com.burritoz.kaiprefs/reload"
  66. #define kSettingsPath @"/var/mobile/Library/Preferences/com.burritoz.kaiprefs.plist"
  67. NSDictionary *prefs = nil;
  68. static void *observer = NULL;
  69. static void reloadPrefs() {
  70. if ([NSHomeDirectory() isEqualToString:@"/var/mobile"]) {
  71. CFArrayRef keyList = CFPreferencesCopyKeyList((CFStringRef)kIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
  72. if (keyList) {
  73. prefs = (NSDictionary *)CFBridgingRelease(CFPreferencesCopyMultiple(keyList, (CFStringRef)kIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost));
  74. if (!prefs) {
  75. prefs = [NSDictionary new];
  76. }
  77. CFRelease(keyList);
  78. }
  79. } else {
  80. prefs = [NSDictionary dictionaryWithContentsOfFile:kSettingsPath];
  81. }
  82. }
  83. static BOOL boolValueForKey(NSString *key, BOOL defaultValue) {
  84. return (prefs && [prefs objectForKey:key] ? [[prefs objectForKey:key] boolValue] : defaultValue);
  85. }
  86. static double numberForValue(NSString *key, double defaultValue) {
  87. return (prefs && [prefs objectForKey:key] ? [[prefs objectForKey:key] doubleValue] : defaultValue);
  88. }
  89. static void preferencesChanged() {
  90. CFPreferencesAppSynchronize((CFStringRef)kIdentifier);
  91. reloadPrefs();
  92. enabled = boolValueForKey(@"enabled", YES);
  93. spacing = numberForValue(@"spacing", 5);
  94. glyphSize = numberForValue(@"glyphSize", 30);
  95. bannerHeight = numberForValue(@"bannerHeight", 80);
  96. cornerRadius = numberForValue(@"cornerRadius", 13);
  97. disableGlyphs = boolValueForKey(@"disableGlyphs", NO);
  98. hidePercent = boolValueForKey(@"hidePercent", NO);
  99. bannerStyle = numberForValue(@"bannerStyle", 1);
  100. showAll = boolValueForKey(@"showAll", YES);
  101. bannerWidthFactor = numberForValue(@"bannerWidthFactor", 0);
  102. hideDeviceLabel = boolValueForKey(@"hideDeviceLabel", NO);
  103. bannerAlign = numberForValue(@"bannerAlign", 2);
  104. horizontalOffset = numberForValue(@"horizontalOffset", 0);
  105. belowMusic = boolValueForKey(@"belowMusic", NO);
  106. hideChargingAnimation = boolValueForKey(@"hideChargingAnimation", YES);
  107. textColor = numberForValue(@"textColor", 0);
  108. bannerAlpha = numberForValue(@"bannerAlpha", 1);
  109. showAllMinusInternal = boolValueForKey(@"showAllMinusInternal", NO);
  110. kaiAlign = numberForValue(@"kaiAlign", 0);
  111. spacingHorizontal = numberForValue(@"spacingHorizontal", 8);
  112. hideBatteryIcon = boolValueForKey(@"hideBatteryIcon", NO);
  113. reAlignSelf = boolValueForKey(@"reAlignSelf", YES);
  114. extraPaddingAfter = boolValueForKey(@"extraPaddingAfter", NO);
  115. showPhone = boolValueForKey(@"showPhone", YES);
  116. removeForMedia = boolValueForKey(@"removeForMedia", NO);
  117. if (disableGlyphs) {
  118. glyphSize = 0;
  119. }
  120. }
  121. static void applyPrefs() {
  122. preferencesChanged();
  123. isUpdating = YES;
  124. [[KAIBatteryPlatter sharedInstance] refreshForPrefs]; // so hard (not)
  125. [(CSAdjunctListView *)([KAIBatteryPlatter sharedInstance].superview.superview) _layoutStackView];
  126. [[NSNotificationCenter defaultCenter] postNotificationName:@"KaiResetOffset" object:nil userInfo:nil];
  127. isUpdating = NO;
  128. }