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.

136 lines
4.1KB

  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. #define KAISelf ((CSAdjunctListView *)self) //for use when calling self in KAITarget
  7. #define KAIBattery UHDUEIHGCEBCHYDEICVKEVSAGJKBCXAHJGKVXHAS //lmao
  8. @interface CSAdjunctListView : UIView
  9. @property (nonatomic, assign) BOOL hasKai;
  10. -(UIStackView *)stackView;
  11. -(void)setStackView:(UIStackView *)arg1;
  12. -(void)KaiUpdate;
  13. @end
  14. @interface CALayer (kai)
  15. @property (nonatomic, assign) BOOL continuousCorners;
  16. @end
  17. BOOL isUpdating = NO;
  18. //prefs
  19. BOOL enabled;
  20. BOOL disableGlyphs;
  21. BOOL hidePercent;
  22. BOOL showAll;
  23. BOOL belowMusic;
  24. BOOL hideDeviceLabel;
  25. BOOL hideChargingAnimation;
  26. NSInteger bannerStyle;
  27. NSInteger bannerAlign;
  28. double spacing;
  29. double glyphSize;
  30. double bannerHeight;
  31. double cornerRadius;
  32. double bannerWidthFactor;
  33. double horizontalOffset;
  34. //by importing here, I can use vars in the .mm files
  35. #import "KAIBatteryCell.mm"
  36. #import "KAIBattery.mm"
  37. #define PLIST_PATH @"/User/Library/Preferences/com.burritoz.kaiprefs.plist"
  38. #define kIdentifier @"com.burritoz.kaiprefs"
  39. #define kSettingsChangedNotification (CFStringRef)@"com.burritoz.kaiprefs/reload"
  40. #define kSettingsPath @"/var/mobile/Library/Preferences/com.burritoz.kaiprefs.plist"
  41. NSDictionary *prefs = nil;
  42. static void *observer = NULL;
  43. static void reloadPrefs()
  44. {
  45. if ([NSHomeDirectory() isEqualToString:@"/var/mobile"])
  46. {
  47. CFArrayRef keyList = CFPreferencesCopyKeyList((CFStringRef)kIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
  48. if (keyList)
  49. {
  50. prefs = (NSDictionary *)CFBridgingRelease(CFPreferencesCopyMultiple(keyList, (CFStringRef)kIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost));
  51. if (!prefs)
  52. {
  53. prefs = [NSDictionary new];
  54. }
  55. CFRelease(keyList);
  56. }
  57. }
  58. else
  59. {
  60. prefs = [NSDictionary dictionaryWithContentsOfFile:kSettingsPath];
  61. }
  62. }
  63. static BOOL boolValueForKey(NSString *key, BOOL defaultValue) {
  64. return (prefs && [prefs objectForKey:key] ? [[prefs objectForKey:key] boolValue] : defaultValue);
  65. }
  66. static double numberForValue(NSString *key, double defaultValue) {
  67. return (prefs && [prefs objectForKey:key] ? [[prefs objectForKey:key] doubleValue] : defaultValue);
  68. }
  69. static void preferencesChanged()
  70. {
  71. CFPreferencesAppSynchronize((CFStringRef)kIdentifier);
  72. reloadPrefs();
  73. enabled = boolValueForKey(@"enabled", YES);
  74. spacing = numberForValue(@"spacing", 5);
  75. glyphSize = numberForValue(@"glyphSize", 30);
  76. bannerHeight = numberForValue(@"bannerHeight", 80);
  77. cornerRadius = numberForValue(@"cornerRadius", 13);
  78. disableGlyphs = boolValueForKey(@"disableGlyphs", NO);
  79. hidePercent = boolValueForKey(@"hidePercent", NO);
  80. bannerStyle = numberForValue(@"bannerStyle", 1);
  81. showAll = boolValueForKey(@"showAll", NO);
  82. bannerWidthFactor = numberForValue(@"bannerWidthFactor", 0);
  83. hideDeviceLabel = boolValueForKey(@"hideDeviceLabel", NO);
  84. bannerAlign = numberForValue(@"bannerAlign", 2);
  85. horizontalOffset = numberForValue(@"horizontalOffset", 0);
  86. belowMusic = boolValueForKey(@"belowMusic", NO);
  87. hideChargingAnimation = boolValueForKey(@"hideChargingAnimation", YES);
  88. if(disableGlyphs) {
  89. glyphSize = 0;
  90. }
  91. }
  92. static void applyPrefs()
  93. {
  94. preferencesChanged();
  95. isUpdating = YES;
  96. [[KAIBattery sharedInstance] removeAllAndRefresh];
  97. [(CSAdjunctListView *)([KAIBattery sharedInstance].superview.superview) KaiUpdate];
  98. isUpdating = NO;
  99. //here I remotely refresh the KAIView.
  100. /*isUpdating = YES;
  101. [UIView animateWithDuration:0.3 animations:^{
  102. [KAIBattery sharedInstance].alpha = 0;
  103. } completion:^(BOOL finished){
  104. [[KAIBattery sharedInstance] updateBattery];
  105. [(CSAdjunctListView *)([KAIBattery sharedInstance].superview.superview) KaiUpdate];
  106. [UIView animateWithDuration:0.35 animations:^{
  107. [KAIBattery sharedInstance].alpha = 1;
  108. } completion:^(BOOL finished){
  109. isUpdating = NO;
  110. }];
  111. }];*/
  112. }