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.

152 lines
4.4KB

  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. #import "MobileGestalt.h"
  7. #import "NSTask.h"
  8. #define KAISelf ((CSAdjunctListView *)self) //for use when calling self in KAITarget
  9. //#define KAIBatteryPlatter UHDUEIHGCEBCHYDEICVKEVSAGJKBCXAHJGKVXHAS //lmao
  10. //#define KAIBatteryCell HDEIUOGEUBGUYOEXHNOPUSZIOJIGECEXIUSHXJXBE //very good
  11. @interface CSAdjunctListView : UIView
  12. @property (nonatomic, assign) BOOL hasKai;
  13. -(UIStackView *)stackView;
  14. -(void)_layoutStackView;
  15. -(void)setStackView:(UIStackView *)arg1;
  16. +(id)sharedListViewForKai;
  17. @end
  18. @interface CALayer (kai)
  19. @property (nonatomic, assign) BOOL continuousCorners;
  20. @end
  21. @interface SBIconController : UIViewController
  22. @end
  23. @interface SBCoverSheetPrimarySlidingViewController : UIViewController
  24. @end
  25. @interface UIDevice (kai)
  26. -(id)sf_udidString;
  27. -(id)_currentProduct;
  28. @end
  29. @interface NCNotificationListView : UIView
  30. -(void)fixComplicationsViewFrame;
  31. @end
  32. BOOL isUpdating = NO;
  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. 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 "KAIStackView.mm"
  57. #import "KAIBatteryPlatter.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. {
  66. if ([NSHomeDirectory() isEqualToString:@"/var/mobile"])
  67. {
  68. CFArrayRef keyList = CFPreferencesCopyKeyList((CFStringRef)kIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
  69. if (keyList)
  70. {
  71. prefs = (NSDictionary *)CFBridgingRelease(CFPreferencesCopyMultiple(keyList, (CFStringRef)kIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost));
  72. if (!prefs)
  73. {
  74. prefs = [NSDictionary new];
  75. }
  76. CFRelease(keyList);
  77. }
  78. }
  79. else
  80. {
  81. prefs = [NSDictionary dictionaryWithContentsOfFile:kSettingsPath];
  82. }
  83. }
  84. static BOOL boolValueForKey(NSString *key, BOOL defaultValue) {
  85. return (prefs && [prefs objectForKey:key] ? [[prefs objectForKey:key] boolValue] : defaultValue);
  86. }
  87. static double numberForValue(NSString *key, double defaultValue) {
  88. return (prefs && [prefs objectForKey:key] ? [[prefs objectForKey:key] doubleValue] : defaultValue);
  89. }
  90. static void preferencesChanged()
  91. {
  92. CFPreferencesAppSynchronize((CFStringRef)kIdentifier);
  93. reloadPrefs();
  94. enabled = boolValueForKey(@"enabled", YES);
  95. spacing = numberForValue(@"spacing", 5);
  96. glyphSize = numberForValue(@"glyphSize", 30);
  97. bannerHeight = numberForValue(@"bannerHeight", 80);
  98. cornerRadius = numberForValue(@"cornerRadius", 13);
  99. disableGlyphs = boolValueForKey(@"disableGlyphs", NO);
  100. hidePercent = boolValueForKey(@"hidePercent", NO);
  101. bannerStyle = numberForValue(@"bannerStyle", 1);
  102. showAll = boolValueForKey(@"showAll", NO);
  103. bannerWidthFactor = numberForValue(@"bannerWidthFactor", 0);
  104. hideDeviceLabel = boolValueForKey(@"hideDeviceLabel", NO);
  105. bannerAlign = numberForValue(@"bannerAlign", 2);
  106. horizontalOffset = numberForValue(@"horizontalOffset", 0);
  107. belowMusic = boolValueForKey(@"belowMusic", NO);
  108. hideChargingAnimation = boolValueForKey(@"hideChargingAnimation", YES);
  109. textColor = numberForValue(@"textColor", 0);
  110. bannerAlpha = numberForValue(@"bannerAlpha", 1);
  111. showAllMinusInternal = boolValueForKey(@"showAllMinusInternal", NO);
  112. kaiAlign = numberForValue(@"kaiAlign", 0);
  113. spacingHorizontal = numberForValue(@"spacingHorizontal", 8);
  114. if(disableGlyphs) {
  115. glyphSize = 0;
  116. }
  117. }
  118. static void applyPrefs()
  119. {
  120. preferencesChanged();
  121. isUpdating = YES;
  122. [[KAIBatteryPlatter sharedInstance] refreshForPrefs]; //so hard (not)
  123. [(CSAdjunctListView *)([KAIBatteryPlatter sharedInstance].superview.superview) _layoutStackView];
  124. isUpdating = NO;
  125. }