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.

162 lines
5.0KB

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