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.

146 lines
4.2KB

  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 KAIBatteryStack 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. @end
  17. @interface CALayer (kai)
  18. @property (nonatomic, assign) BOOL continuousCorners;
  19. @end
  20. @interface SBIconController : UIViewController
  21. @end
  22. @interface SBCoverSheetPrimarySlidingViewController : UIViewController
  23. @end
  24. @interface UIDevice (kai)
  25. -(id)sf_udidString;
  26. -(id)_currentProduct;
  27. @end
  28. @interface NCNotificationListView : UIView
  29. -(void)fixComplicationsViewFrame;
  30. @end
  31. BOOL isUpdating = NO;
  32. //prefs
  33. BOOL enabled;
  34. BOOL disableGlyphs;
  35. BOOL hidePercent;
  36. BOOL showAll;
  37. BOOL belowMusic;
  38. BOOL hideDeviceLabel;
  39. BOOL hideChargingAnimation;
  40. BOOL showAllMinusInternal;
  41. NSInteger bannerStyle;
  42. NSInteger bannerAlign;
  43. NSInteger textColor;
  44. double spacing;
  45. double glyphSize;
  46. double bannerHeight;
  47. double cornerRadius;
  48. double bannerWidthFactor;
  49. double horizontalOffset;
  50. double bannerAlpha;
  51. //by importing here, I can use vars in the .mm files
  52. #import "KAIBatteryCell.mm"
  53. #import "KAIBatteryStack.mm"
  54. #define PLIST_PATH @"/User/Library/Preferences/com.burritoz.kaiprefs.plist"
  55. #define kIdentifier @"com.burritoz.kaiprefs"
  56. #define kSettingsChangedNotification (CFStringRef)@"com.burritoz.kaiprefs/reload"
  57. #define kSettingsPath @"/var/mobile/Library/Preferences/com.burritoz.kaiprefs.plist"
  58. NSDictionary *prefs = nil;
  59. static void *observer = NULL;
  60. static void reloadPrefs()
  61. {
  62. if ([NSHomeDirectory() isEqualToString:@"/var/mobile"])
  63. {
  64. CFArrayRef keyList = CFPreferencesCopyKeyList((CFStringRef)kIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
  65. if (keyList)
  66. {
  67. prefs = (NSDictionary *)CFBridgingRelease(CFPreferencesCopyMultiple(keyList, (CFStringRef)kIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost));
  68. if (!prefs)
  69. {
  70. prefs = [NSDictionary new];
  71. }
  72. CFRelease(keyList);
  73. }
  74. }
  75. else
  76. {
  77. prefs = [NSDictionary dictionaryWithContentsOfFile:kSettingsPath];
  78. }
  79. }
  80. static BOOL boolValueForKey(NSString *key, BOOL defaultValue) {
  81. return (prefs && [prefs objectForKey:key] ? [[prefs objectForKey:key] boolValue] : defaultValue);
  82. }
  83. static double numberForValue(NSString *key, double defaultValue) {
  84. return (prefs && [prefs objectForKey:key] ? [[prefs objectForKey:key] doubleValue] : defaultValue);
  85. }
  86. static void preferencesChanged()
  87. {
  88. CFPreferencesAppSynchronize((CFStringRef)kIdentifier);
  89. reloadPrefs();
  90. enabled = boolValueForKey(@"enabled", YES);
  91. spacing = numberForValue(@"spacing", 5);
  92. glyphSize = numberForValue(@"glyphSize", 30);
  93. bannerHeight = numberForValue(@"bannerHeight", 80);
  94. cornerRadius = numberForValue(@"cornerRadius", 13);
  95. disableGlyphs = boolValueForKey(@"disableGlyphs", NO);
  96. hidePercent = boolValueForKey(@"hidePercent", NO);
  97. bannerStyle = numberForValue(@"bannerStyle", 1);
  98. showAll = boolValueForKey(@"showAll", NO);
  99. bannerWidthFactor = numberForValue(@"bannerWidthFactor", 0);
  100. hideDeviceLabel = boolValueForKey(@"hideDeviceLabel", NO);
  101. bannerAlign = numberForValue(@"bannerAlign", 2);
  102. horizontalOffset = numberForValue(@"horizontalOffset", 0);
  103. belowMusic = boolValueForKey(@"belowMusic", NO);
  104. hideChargingAnimation = boolValueForKey(@"hideChargingAnimation", YES);
  105. textColor = numberForValue(@"textColor", 0);
  106. bannerAlpha = numberForValue(@"bannerAlpha", 1);
  107. showAllMinusInternal = boolValueForKey(@"showAllMinusInternal", NO);
  108. if(disableGlyphs) {
  109. glyphSize = 0;
  110. }
  111. }
  112. static void applyPrefs()
  113. {
  114. preferencesChanged();
  115. isUpdating = YES;
  116. [[KAIBatteryStack sharedInstance] refreshForPrefs]; //so hard (not)
  117. [(CSAdjunctListView *)([KAIBatteryStack sharedInstance].superview.superview) _layoutStackView];
  118. isUpdating = NO;
  119. }