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.3KB

  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. @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 "KAIStackView.mm"
  54. #import "KAIBatteryPlatter.mm"
  55. #define PLIST_PATH @"/User/Library/Preferences/com.burritoz.kaiprefs.plist"
  56. #define kIdentifier @"com.burritoz.kaiprefs"
  57. #define kSettingsChangedNotification (CFStringRef)@"com.burritoz.kaiprefs/reload"
  58. #define kSettingsPath @"/var/mobile/Library/Preferences/com.burritoz.kaiprefs.plist"
  59. NSDictionary *prefs = nil;
  60. static void *observer = NULL;
  61. static void reloadPrefs()
  62. {
  63. if ([NSHomeDirectory() isEqualToString:@"/var/mobile"])
  64. {
  65. CFArrayRef keyList = CFPreferencesCopyKeyList((CFStringRef)kIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
  66. if (keyList)
  67. {
  68. prefs = (NSDictionary *)CFBridgingRelease(CFPreferencesCopyMultiple(keyList, (CFStringRef)kIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost));
  69. if (!prefs)
  70. {
  71. prefs = [NSDictionary new];
  72. }
  73. CFRelease(keyList);
  74. }
  75. }
  76. else
  77. {
  78. prefs = [NSDictionary dictionaryWithContentsOfFile:kSettingsPath];
  79. }
  80. }
  81. static BOOL boolValueForKey(NSString *key, BOOL defaultValue) {
  82. return (prefs && [prefs objectForKey:key] ? [[prefs objectForKey:key] boolValue] : defaultValue);
  83. }
  84. static double numberForValue(NSString *key, double defaultValue) {
  85. return (prefs && [prefs objectForKey:key] ? [[prefs objectForKey:key] doubleValue] : defaultValue);
  86. }
  87. static void preferencesChanged()
  88. {
  89. CFPreferencesAppSynchronize((CFStringRef)kIdentifier);
  90. reloadPrefs();
  91. enabled = boolValueForKey(@"enabled", YES);
  92. spacing = numberForValue(@"spacing", 5);
  93. glyphSize = numberForValue(@"glyphSize", 30);
  94. bannerHeight = numberForValue(@"bannerHeight", 80);
  95. cornerRadius = numberForValue(@"cornerRadius", 13);
  96. disableGlyphs = boolValueForKey(@"disableGlyphs", NO);
  97. hidePercent = boolValueForKey(@"hidePercent", NO);
  98. bannerStyle = numberForValue(@"bannerStyle", 1);
  99. showAll = boolValueForKey(@"showAll", NO);
  100. bannerWidthFactor = numberForValue(@"bannerWidthFactor", 0);
  101. hideDeviceLabel = boolValueForKey(@"hideDeviceLabel", NO);
  102. bannerAlign = numberForValue(@"bannerAlign", 2);
  103. horizontalOffset = numberForValue(@"horizontalOffset", 0);
  104. belowMusic = boolValueForKey(@"belowMusic", NO);
  105. hideChargingAnimation = boolValueForKey(@"hideChargingAnimation", YES);
  106. textColor = numberForValue(@"textColor", 0);
  107. bannerAlpha = numberForValue(@"bannerAlpha", 1);
  108. showAllMinusInternal = boolValueForKey(@"showAllMinusInternal", NO);
  109. if(disableGlyphs) {
  110. glyphSize = 0;
  111. }
  112. }
  113. static void applyPrefs()
  114. {
  115. preferencesChanged();
  116. isUpdating = YES;
  117. [[KAIBatteryPlatter sharedInstance] refreshForPrefs]; //so hard (not)
  118. [(CSAdjunctListView *)([KAIBatteryPlatter sharedInstance].superview.superview) _layoutStackView];
  119. isUpdating = NO;
  120. }