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.

147 Zeilen
4.7KB

  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. #define afterMusicIndex(cls, obj) [[[cls sharedListViewForKai] stackView].subviews indexOfObject:obj]
  7. @interface CSAdjunctListView : UIView
  8. @property (nonatomic, assign) BOOL hasKai;
  9. - (UIStackView *)stackView;
  10. - (void)_layoutStackView;
  11. - (void)setStackView:(UIStackView *)arg1;
  12. + (id)sharedListViewForKai;
  13. @end
  14. @interface CALayer (kai)
  15. @property (nonatomic, assign) BOOL continuousCorners;
  16. @end
  17. @interface SBCoverSheetPrimarySlidingViewController : UIViewController
  18. @end
  19. @interface APEPlatter : UIView
  20. @property (nonatomic, assign) BOOL removed;
  21. + (APEPlatter *)sharedInstance;
  22. @end
  23. @interface NCNotificationListView : UIView
  24. - (void)fixComplicationsViewFrame;
  25. @end
  26. BOOL isUpdating = NO;
  27. BOOL shouldBeAdded = YES;
  28. //prefs
  29. BOOL enabled;
  30. BOOL disableGlyphs;
  31. BOOL hidePercent;
  32. BOOL showAll;
  33. BOOL belowMusic;
  34. BOOL hideDeviceLabel;
  35. BOOL hideChargingAnimation;
  36. BOOL showAllMinusInternal;
  37. BOOL hideBatteryIcon;
  38. BOOL reAlignSelf;
  39. BOOL showPhone;
  40. BOOL removeForMedia;
  41. BOOL extraPaddingAfter;
  42. NSInteger bannerStyle;
  43. NSInteger bannerAlign;
  44. NSInteger textColor;
  45. double spacing;
  46. double glyphSize;
  47. double bannerHeight;
  48. double cornerRadius;
  49. double bannerWidthFactor;
  50. double horizontalOffset;
  51. double bannerAlpha;
  52. double kaiAlign;
  53. double spacingHorizontal;
  54. //by importing here, I can use vars in the .mm files
  55. #import "KAIBatteryCell.mm"
  56. #import "KAIBatteryPlatter.mm"
  57. #import "KAIStackView.mm"
  58. #define PLIST_PATH @"/User/Library/Preferences/com.burritoz.kaiprefs.plist"
  59. #define kIdentifier @"com.burritoz.kaiprefs"
  60. #define kSettingsChangedNotification (CFStringRef) @"com.burritoz.kaiprefs/reload"
  61. #define kSettingsPath @"/var/mobile/Library/Preferences/com.burritoz.kaiprefs.plist"
  62. NSDictionary *prefs = nil;
  63. static void *observer = NULL;
  64. static void reloadPrefs() {
  65. if ([NSHomeDirectory() isEqualToString:@"/var/mobile"]) {
  66. CFArrayRef keyList = CFPreferencesCopyKeyList((CFStringRef)kIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
  67. if (keyList) {
  68. prefs = (NSDictionary *)CFBridgingRelease(CFPreferencesCopyMultiple(keyList, (CFStringRef)kIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost));
  69. if (!prefs) {
  70. prefs = [NSDictionary new];
  71. }
  72. CFRelease(keyList);
  73. }
  74. } else {
  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. 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. hideChargingAnimation = boolValueForKey(@"hideChargingAnimation", YES);
  102. textColor = numberForValue(@"textColor", 0);
  103. bannerAlpha = numberForValue(@"bannerAlpha", 1);
  104. showAllMinusInternal = boolValueForKey(@"showAllMinusInternal", NO);
  105. kaiAlign = numberForValue(@"kaiAlign", 0);
  106. spacingHorizontal = numberForValue(@"spacingHorizontal", 8);
  107. hideBatteryIcon = boolValueForKey(@"hideBatteryIcon", NO);
  108. reAlignSelf = boolValueForKey(@"reAlignSelf", YES);
  109. extraPaddingAfter = boolValueForKey(@"extraPaddingAfter", NO);
  110. showPhone = boolValueForKey(@"showPhone", YES);
  111. removeForMedia = boolValueForKey(@"removeForMedia", NO);
  112. if (disableGlyphs) {
  113. glyphSize = 0;
  114. }
  115. }
  116. static void applyPrefs() {
  117. preferencesChanged();
  118. isUpdating = YES;
  119. [[KAIBatteryPlatter sharedInstance] refreshForPrefs]; //so hard (not)
  120. [(CSAdjunctListView *)([KAIBatteryPlatter sharedInstance].superview.superview) _layoutStackView];
  121. [[NSNotificationCenter defaultCenter] postNotificationName:@"KaiResetOffset" object:nil userInfo:nil];
  122. isUpdating = NO;
  123. }