├── BatteryBar.plist ├── BatteryColorPrefs.h ├── BatteryColorPrefs.m ├── Makefile ├── README.md ├── Tweak.xm ├── batterybar ├── BBGradientListController.h ├── BBGradientListController.m ├── BBRootListController.h ├── BBRootListController.m ├── BBSliderCell.h ├── BBSliderCell.m ├── BBSolidColorListController.h ├── BBSolidColorListController.m ├── Makefile ├── Resources │ ├── Gradient.plist │ ├── Info.plist │ ├── Root.plist │ ├── SolidColor.plist │ ├── icon.png │ ├── icon@2x.png │ └── icon@3x.png └── entry.plist └── control /BatteryBar.plist: -------------------------------------------------------------------------------- 1 | { Filter = { Bundles = ( "com.apple.springboard", "com.apple.UIKit" ); }; } 2 | -------------------------------------------------------------------------------- /BatteryColorPrefs.h: -------------------------------------------------------------------------------- 1 | @interface BatteryColorPrefs : NSObject 2 | @property (nonatomic, retain) NSString *solidLowPowerModeColor; 3 | @property (nonatomic, retain) NSString *solidChargingColor; 4 | @property (nonatomic, retain) NSString *solidLessThan20Color; 5 | @property (nonatomic, retain) NSString *solidGreaterThan20Color; 6 | @property (nonatomic, retain) NSString *gradientLowPowerModeColor; 7 | @property (nonatomic, retain) NSString *gradientChargingColor; 8 | @property (nonatomic, retain) NSArray *gradientColor; 9 | @property (nonatomic, retain) NSArray *defaultGradientColor; 10 | +(BatteryColorPrefs *)sharedInstance; 11 | -(void)updatePreferences; 12 | @end 13 | -------------------------------------------------------------------------------- /BatteryColorPrefs.m: -------------------------------------------------------------------------------- 1 | #import "BatteryColorPrefs.h" 2 | 3 | #define kColorPath @"/var/mobile/Library/Preferences/com.dgh0st.batterybar.color.plist" 4 | 5 | @implementation BatteryColorPrefs 6 | +(BatteryColorPrefs *)sharedInstance { 7 | static BatteryColorPrefs *sharedObject = nil; 8 | static dispatch_once_t token = 0; 9 | dispatch_once(&token, ^{ 10 | sharedObject = [self new]; 11 | }); 12 | return sharedObject; 13 | } 14 | 15 | -(id)init { 16 | self = [super init]; 17 | if (self != nil) { 18 | self.solidLowPowerModeColor = @"#FFD700"; 19 | self.solidChargingColor = @"#00FF00"; 20 | self.solidLessThan20Color = @"#FF0000"; 21 | self.solidGreaterThan20Color = @"#808080"; 22 | 23 | self.gradientLowPowerModeColor = @"#FFD700"; 24 | self.gradientChargingColor = @"00FF00"; 25 | self.defaultGradientColor = [NSArray arrayWithObjects:@"#FF0500", @"#FF1E00", @"#FF3700", @"#FF5000", @"#FF6900", @"#FF8200", @"#FF9B00", @"#FFB400", @"#FFCD00", @"#FFE600", @"#FFFF00", @"#E6FF00", @"#CDFF00", @"#B4FF00", @"#9BFF00", @"#82FF00", @"#69FF00", @"#50FF00", @"#37FF00", @"#1EFF00", @"#00FF00", nil]; 26 | self.gradientColor = self.defaultGradientColor; 27 | 28 | [self updatePreferences]; 29 | } 30 | return self; 31 | } 32 | 33 | -(void)updatePreferences { 34 | NSDictionary *preferences = [NSDictionary dictionaryWithContentsOfFile:kColorPath]; 35 | 36 | self.solidLowPowerModeColor = [preferences objectForKey:@"solidColorLowPower"] ?: @"#FFD700"; 37 | self.solidChargingColor = [preferences objectForKey:@"solidColorCharging"] ?: @"#00FF00"; 38 | self.solidLessThan20Color = [preferences objectForKey:@"solidColorLessThan20"] ?: @"#FF0000"; 39 | self.solidGreaterThan20Color = [preferences objectForKey:@"solidColorGreaterThan20"] ?: @"#808080"; 40 | 41 | self.gradientLowPowerModeColor = [preferences objectForKey:@"gradientColorLowPower"] ?: @"#FFD700"; 42 | self.gradientChargingColor = [preferences objectForKey:@"gradientColorCharging"] ?: @"00FF00"; 43 | self.gradientColor = [NSMutableArray arrayWithCapacity:[self.defaultGradientColor count]]; 44 | for (NSUInteger i = 0; i < [self.defaultGradientColor count]; i++) { 45 | NSString *key = [NSString stringWithFormat:@"gradientColor%zd", i]; 46 | NSString *currentGradientColor = [preferences objectForKey:key] ?: [self.defaultGradientColor objectAtIndex:i]; 47 | [((NSMutableArray *)self.gradientColor) insertObject:currentGradientColor atIndex:i]; 48 | } 49 | } 50 | @end -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | export ARCHS = armv7 arm64 2 | export TARGET = iphone:clang:9.3:latest 3 | 4 | include $(THEOS)/makefiles/common.mk 5 | 6 | TWEAK_NAME = BatteryBar 7 | BatteryBar_FILES = Tweak.xm BatteryColorPrefs.m 8 | BatteryBar_FRAMEWORKS = UIKit CoreGraphics 9 | BatteryBar_LIBRARIES = colorpicker 10 | 11 | include $(THEOS_MAKE_PATH)/tweak.mk 12 | 13 | after-install:: 14 | install.exec "killall -9 SpringBoard" 15 | SUBPROJECTS += batterybar 16 | include $(THEOS_MAKE_PATH)/aggregate.mk 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BatteryBar 2 | Add a bar to the status bar that represents the current battery level. 3 | -------------------------------------------------------------------------------- /Tweak.xm: -------------------------------------------------------------------------------- 1 | #import "BatteryColorPrefs.h" 2 | #import 3 | 4 | @interface UIStatusBarNewUIStyleAttributes : NSObject { 5 | UIColor* _foregroundColor; // iOS 7 - 11 6 | } 7 | @property (nonatomic, assign) BOOL doesRequireStatusBarBackground; 8 | @end 9 | 10 | @interface UIStatusBarForegroundStyleAttributes : NSObject 11 | -(id)_batteryColorForCapacity:(NSInteger)arg1 lowCapacity:(NSInteger)arg2 style:(NSUInteger)arg3; // iOS 9 - 10 12 | -(id)_batteryColorForCapacity:(NSInteger)arg1 lowCapacity:(NSInteger)arg2 style:(NSUInteger)arg3 usingTintColor:(BOOL)arg4; // iOS 11 13 | @end 14 | 15 | @interface UIStatusBarNewUIForegroundStyleAttributes : UIStatusBarForegroundStyleAttributes // iOS 7 - 8 16 | -(id)_batteryColorForCapacity:(CGFloat)arg1 lowCapacity:(CGFloat)arg2 charging:(BOOL)arg3; // iOS 7 - 8 17 | @end 18 | 19 | @interface UIStatusBarForegroundView : UIView 20 | @end 21 | 22 | @interface UIStatusBarItemView : UIView 23 | -(UIStatusBarForegroundStyleAttributes *)foregroundStyle; // iOS 7 - 11 24 | @end 25 | 26 | @interface UIStatusBarBatteryItemView : UIStatusBarItemView { 27 | NSInteger _capacity; // iOS 4 - 11 28 | NSInteger _state; // iOS 4 - 11 29 | BOOL _batterySaverModeActive; // iOS 9 - 11 30 | } 31 | @property (nonatomic, retain) UIView *batteryPercentBarView; 32 | @property (nonatomic, retain) UIView *statusBarBackgroundView; 33 | @property (nonatomic, assign) BOOL isAnimatingCharging; 34 | -(void)resetupBatteryPercentBarViewAnimated:(BOOL)animated; 35 | -(void)doChargingAnimation; 36 | -(void)updateStatusBarBackgroundViewBarHiddenAnimated:(BOOL)animated; 37 | -(BOOL)_needsAccessoryImage; // iOS 7 - 11 38 | -(UIImage *)_accessoryImage; // iOS 7 - 11 39 | -(NSUInteger)cachedBatteryStyle; // iOS 10 - 11 40 | -(NSInteger)cachedCapacity; // iOS 10 - 11 41 | -(id)cachedImageSet; // iOS 10 - 11 42 | @end 43 | 44 | @interface UIStatusBar : UIView { 45 | UIInterfaceOrientation _orientation; // iOS 7 - 10 (iOS 11 inherited) 46 | } 47 | +(NSInteger)lowBatteryLevel; // iOS 5 - 11 48 | -(id)_currentStyleAttributes; // iOS 7 - 11 49 | -(CGFloat)heightForOrientation:(UIInterfaceOrientation)arg1; // iOS 3 - 11 50 | @end 51 | 52 | @interface UIApplication (Private) 53 | +(id)sharedApplication; // iOS 4 - 11 54 | @end 55 | 56 | @interface FBSystemService 57 | +(id)sharedInstance; // iOS 8 - 11 58 | -(void)exitAndRelaunch:(BOOL)arg1; // iOS 8 - 11 59 | @end 60 | 61 | @interface SpringBoard : UIApplication 62 | -(void)_relaunchSpringBoardNow; // iOS 3 - 9 63 | @end 64 | 65 | // battery styles used by apple 66 | #define kNormalBatteryStyle 0 67 | #define kChargingBatteryStyle 1 68 | #define kLowPowerModeBatteryStyle 2 69 | #define kLowPowerModeAndChargingStyle 3 70 | 71 | #define kIdentifier @"com.dgh0st.batterybar" 72 | #define kSettingsPath @"/var/mobile/Library/Preferences/com.dgh0st.batterybar.plist" 73 | #define kSettingsChangedNotification (CFStringRef)@"com.dgh0st.batterybar/settingschanged" 74 | #define kColorChangedNotification (CFStringRef)@"com.dgh0st.batterybar/colorchanged" 75 | #define kRespringNotification (CFStringRef)@"com.dgh0st.batterybar/respring" 76 | 77 | typedef enum StatusBarColorType : NSInteger { 78 | kDefaultStatusColor = 0, 79 | kAlwaysWhite, 80 | kAlwaysBlack 81 | } StatusBarColorType; 82 | 83 | typedef enum BarType : NSInteger { 84 | kSkinny = 0, 85 | kThick, 86 | kBackground 87 | } BarType; 88 | 89 | typedef enum BarAlignment : NSInteger { 90 | kLeft = 0, 91 | kCenter, 92 | kRight 93 | } BarAlignment; 94 | 95 | typedef enum BatteryColorStyle : NSInteger { 96 | kDefaultBatteryColor = 0, 97 | kSolid, 98 | kGradient 99 | } BatteryColorStyle; 100 | 101 | typedef enum ChargingAnimationStyle : NSInteger { 102 | kNoChargingAnimation = 0, 103 | kPulse, 104 | kSway 105 | } ChargingAnimationStyle; 106 | 107 | static BOOL isEnabled = YES; 108 | static BOOL isUseActualBatteryLevelEnabled = YES; 109 | static StatusBarColorType statusBarForegroundColor = kDefaultStatusColor; 110 | static BOOL isHomescreenBackgroundEnabled = NO; 111 | static BOOL isBatteryIconHidden = YES; 112 | static BOOL isChargingIconHidden = YES; 113 | static BarType batteryBarType = kSkinny; 114 | static BOOL isBottomBarEnabled = NO; 115 | static CGFloat normalBarHeight = 3.0; 116 | static BarAlignment batteryBarAlignment = kLeft; 117 | static BatteryColorStyle batteryColorStyle = kDefaultBatteryColor; 118 | static CGFloat batteryBarOpacity = 1.0; 119 | static BOOL isGradientLowPowerEnabled = NO; 120 | static BOOL isGradientChargingEnabled = NO; 121 | static ChargingAnimationStyle chargingAnimationStyle = kNoChargingAnimation; 122 | 123 | static CGFloat kAnimationSpeed = 0.5; 124 | static BOOL kUseBlur = NO; 125 | static CGFloat kWhiteBackgroundGrayness = 0.7; 126 | static CGFloat kBlackBackgroundGrayness = 0.3; 127 | 128 | %group AlwaysWhiteOrBlack 129 | %hook UIStatusBarNewUIStyleAttributes 130 | %property (nonatomic, assign) BOOL doesRequireStatusBarBackground; 131 | 132 | -(id)initWithRequest:(id)arg1 backgroundColor:(id)arg2 foregroundColor:(id)arg3 { 133 | // change status bar color for apps and figure out if background is needed or not 134 | BOOL isBackgroundRequired = NO; 135 | NSString *appIdentifier = [NSBundle mainBundle].bundleIdentifier; 136 | if (appIdentifier != nil && [appIdentifier isEqualToString:@"com.apple.springboard"]) { 137 | isBackgroundRequired = isHomescreenBackgroundEnabled; 138 | } else if (arg3 != nil) { 139 | if (statusBarForegroundColor == kAlwaysWhite && [arg3 isEqual:[UIColor blackColor]]) { 140 | arg3 = [UIColor whiteColor]; 141 | isBackgroundRequired = YES; 142 | } else if (statusBarForegroundColor == kAlwaysBlack && [arg3 isEqual:[UIColor whiteColor]]) { 143 | arg3 = [UIColor blackColor]; 144 | isBackgroundRequired = YES; 145 | } 146 | } 147 | 148 | // update the saved data for this instance 149 | self = %orig(arg1, arg2, arg3); 150 | if (self != nil) 151 | self.doesRequireStatusBarBackground = isBackgroundRequired; 152 | return self; 153 | } 154 | %end 155 | 156 | %hook UIStatusBar 157 | -(void)layoutSubviews { 158 | // fix status bar not displaying in fullscreen videos when foreground color is always white (for some reason the status bar height is set to 0 internally) 159 | NSString *appIdentifier = [NSBundle mainBundle].bundleIdentifier; 160 | if (appIdentifier != nil && ![appIdentifier isEqualToString:@"com.apple.springboard"] && self.superview != nil && ![self.superview isKindOfClass:%c(UIStatusBarWindow)] && statusBarForegroundColor == kAlwaysWhite) { 161 | CGRect frame = self.frame; 162 | UIInterfaceOrientation _orientation = MSHookIvar(self, "_orientation"); 163 | frame.size.height = [self heightForOrientation:_orientation]; 164 | self.frame = frame; 165 | } 166 | 167 | %orig(); 168 | } 169 | 170 | -(UIColor *)foregroundColor { 171 | // change homescreen/lockscreen color 172 | UIColor *result = %orig(); 173 | NSString *appIdentifier = [NSBundle mainBundle].bundleIdentifier; 174 | if (appIdentifier != nil && [appIdentifier isEqualToString:@"com.apple.springboard"]) { 175 | if (statusBarForegroundColor == kAlwaysWhite) 176 | result = [UIColor whiteColor]; 177 | else if (statusBarForegroundColor == kAlwaysBlack) 178 | result = [UIColor blackColor]; 179 | } 180 | return result; 181 | } 182 | %end 183 | %end 184 | 185 | %hook UIStatusBarBatteryItemView 186 | %property (nonatomic, retain) UIView *batteryPercentBarView; // bttery bar 187 | %property (nonatomic, retain) UIView *statusBarBackgroundView; // status bar background (only added when needed) 188 | %property (nonatomic, assign) BOOL isAnimatingCharging; // is charging animation current running or not 189 | 190 | -(id)initWithItem:(id)arg1 data:(id)arg2 actions:(NSInteger)arg3 style:(id)arg4 { 191 | self = %orig(arg1, arg2, arg3, arg4); 192 | if (self != nil) { // setup bar on initialization 193 | [self resetupBatteryPercentBarViewAnimated:NO]; 194 | 195 | self.isAnimatingCharging = NO; 196 | } 197 | return self; 198 | } 199 | 200 | -(CGRect)frame { 201 | CGRect result = %orig(); 202 | 203 | // hide batter or charging icon 204 | if (isBatteryIconHidden) { 205 | if (isChargingIconHidden || ![self _needsAccessoryImage]) 206 | result.size.width = 0; 207 | else 208 | result.size.width = [self _accessoryImage].size.width; 209 | } 210 | 211 | // move status bar down for Thick type bar 212 | if (self.superview != nil && batteryBarType == kThick && !isBottomBarEnabled) { 213 | UIStatusBarForegroundView *_foregroundView = (UIStatusBarForegroundView *)self.superview; 214 | CGRect foregroundFrame = _foregroundView.frame; 215 | foregroundFrame.origin.y = normalBarHeight; 216 | _foregroundView.frame = foregroundFrame; 217 | } 218 | 219 | // to correctly hide the battery/charing icons 220 | self.clipsToBounds = isBatteryIconHidden || isChargingIconHidden; 221 | return result; 222 | } 223 | 224 | -(BOOL)updateForNewData:(id)arg1 actions:(NSInteger)arg2 { 225 | NSInteger _previousState = MSHookIvar(self, "_state"); 226 | BOOL result = %orig(arg1, arg2); 227 | NSInteger _newState = MSHookIvar(self, "_state"); 228 | if ((_previousState == kChargingBatteryStyle || _previousState == kLowPowerModeAndChargingStyle) && (_newState == kNormalBatteryStyle || _newState == kLowPowerModeBatteryStyle) && self.batteryPercentBarView != nil && chargingAnimationStyle != kNoChargingAnimation) { // Charging -> Not Charging 229 | self.isAnimatingCharging = NO; 230 | [self.batteryPercentBarView.layer removeAllAnimations]; 231 | self.batteryPercentBarView.transform = CGAffineTransformMakeTranslation(0.0, 0.0); 232 | self.batteryPercentBarView.alpha = 1.0; 233 | } 234 | if (result) // only resetup bar when needed 235 | [self resetupBatteryPercentBarViewAnimated:YES]; 236 | return result; 237 | } 238 | 239 | -(CGFloat)extraRightPadding { 240 | // called on rotation and initial setup 241 | [self resetupBatteryPercentBarViewAnimated:YES]; 242 | return %orig(); 243 | } 244 | 245 | -(void)layoutSubviews { 246 | %orig(); 247 | // fix issues in safari where background of the status bar would disappear 248 | if (statusBarForegroundColor != kDefaultStatusColor || batteryBarType == kBackground) 249 | [self updateStatusBarBackgroundViewBarHiddenAnimated:YES]; 250 | } 251 | 252 | %new 253 | -(void)resetupBatteryPercentBarViewAnimated:(BOOL)animated { 254 | if (self.superview != nil) { 255 | BOOL shouldRetrieveBackupInfo = [self respondsToSelector:@selector(cachedImageSet)] && ([self cachedImageSet] == nil || MSHookIvar(self, "_cachedImageSet") == nil); 256 | NSInteger _capacity = !shouldRetrieveBackupInfo && [self respondsToSelector:@selector(cachedCapacity)] ? [self cachedCapacity] : MSHookIvar(self, "_capacity"); 257 | if (_capacity > 100 || _capacity < 0 || isUseActualBatteryLevelEnabled) { // Getting some error sometime so just get another way of finding battery level (most likely not finding capacity) 258 | if (![UIDevice currentDevice].batteryMonitoringEnabled) 259 | [UIDevice currentDevice].batteryMonitoringEnabled = YES; 260 | _capacity = (NSInteger)([UIDevice currentDevice].batteryLevel * 100); // iOS 5 - 11 261 | } 262 | NSInteger _state = MSHookIvar(self, "_state"); 263 | if (_state != kNormalBatteryStyle || _state != kChargingBatteryStyle) { // back up when it can't find _state 264 | if (![UIDevice currentDevice].batteryMonitoringEnabled) 265 | [UIDevice currentDevice].batteryMonitoringEnabled = YES; 266 | if ([UIDevice currentDevice].batteryState == UIDeviceBatteryStateCharging || [UIDevice currentDevice].batteryState == UIDeviceBatteryStateFull) 267 | _state = kChargingBatteryStyle; // iOS 7 - 11 268 | else 269 | _state = kNormalBatteryStyle; 270 | } 271 | NSUInteger _cachedBatteryStyle; 272 | if (!shouldRetrieveBackupInfo && [self respondsToSelector:@selector(cachedBatteryStyle)]) { 273 | _cachedBatteryStyle = [self cachedBatteryStyle]; 274 | } else { 275 | NSProcessInfo *processInfo = [NSProcessInfo processInfo]; 276 | BOOL doesDeviceSupportLowPowerMode = [processInfo respondsToSelector:@selector(isLowPowerModeEnabled)]; 277 | BOOL _batterySaverModeActive = doesDeviceSupportLowPowerMode ? (MSHookIvar(self, "_batterySaverModeActive") || [processInfo isLowPowerModeEnabled]) : NO; 278 | _cachedBatteryStyle = _batterySaverModeActive ? kLowPowerModeBatteryStyle : _state; 279 | } 280 | 281 | if (![self.superview isKindOfClass:%c(UIStatusBarForegroundView)]) 282 | return; // battery icon isn't part of status bar's foreground view 283 | UIStatusBarForegroundView *_foregroundView = (UIStatusBarForegroundView *)self.superview; 284 | if (_foregroundView == nil || _foregroundView.superview == nil || ![_foregroundView.superview isKindOfClass:%c(UIStatusBar)]) 285 | return; // foreground view isn't part of status bar 286 | UIStatusBar *_statusBar = (UIStatusBar *)_foregroundView.superview; 287 | UIInterfaceOrientation _orientation = MSHookIvar(_statusBar, "_orientation"); 288 | CGFloat statusBarHeight = [_statusBar heightForOrientation:_orientation]; 289 | 290 | // calculate the frame for the bar and background 291 | CGRect foregroundFrame = _foregroundView.frame; 292 | if (foregroundFrame.size.width == 0) 293 | return; // fix animations issues on initial launch 294 | CGFloat percentage = _capacity / 100.0; 295 | CGFloat xPosition; 296 | if (batteryBarAlignment == kRight) 297 | xPosition = foregroundFrame.size.width * (1.0 - percentage); 298 | else if (batteryBarAlignment == kCenter) 299 | xPosition = foregroundFrame.size.width * (1.0 - percentage) / 2.0; 300 | else 301 | xPosition = 0; 302 | CGRect barFrame; 303 | CGRect backgroundViewFrame; 304 | if (batteryBarType == kThick) { 305 | if (isBottomBarEnabled) { 306 | barFrame = CGRectMake(xPosition, statusBarHeight - normalBarHeight, foregroundFrame.size.width * percentage, normalBarHeight * 2); 307 | backgroundViewFrame = CGRectMake(0, 0, foregroundFrame.size.width, statusBarHeight + normalBarHeight); 308 | } else { 309 | barFrame = CGRectMake(xPosition, -normalBarHeight, foregroundFrame.size.width * percentage, normalBarHeight * 2); 310 | backgroundViewFrame = CGRectMake(0, -normalBarHeight, foregroundFrame.size.width, statusBarHeight + normalBarHeight); 311 | } 312 | } else if (batteryBarType == kBackground) { 313 | barFrame = CGRectMake(xPosition, 0, foregroundFrame.size.width * percentage, statusBarHeight); 314 | backgroundViewFrame = CGRectMake(0, 0, foregroundFrame.size.width, statusBarHeight); 315 | } else { 316 | if (isBottomBarEnabled) 317 | barFrame = CGRectMake(xPosition, statusBarHeight - normalBarHeight, foregroundFrame.size.width * percentage, normalBarHeight); 318 | else 319 | barFrame = CGRectMake(xPosition, 0, foregroundFrame.size.width * percentage, normalBarHeight); 320 | backgroundViewFrame = CGRectMake(0, 0, foregroundFrame.size.width, statusBarHeight); 321 | } 322 | 323 | // create a new bar if needed 324 | if (self.batteryPercentBarView == nil) { 325 | self.batteryPercentBarView = [[UIView alloc] initWithFrame:barFrame]; 326 | [_foregroundView insertSubview:self.batteryPercentBarView atIndex:0]; 327 | } 328 | 329 | // create a status bar background view if needed 330 | if (self.statusBarBackgroundView == nil && (statusBarForegroundColor != kDefaultStatusColor || batteryBarType == kBackground)) { 331 | if (kUseBlur && %c(UIVisualEffectView)) // iOS 8 - 11 332 | self.statusBarBackgroundView = [[UIVisualEffectView alloc] initWithFrame:backgroundViewFrame]; 333 | else 334 | self.statusBarBackgroundView = [[UIView alloc] initWithFrame:backgroundViewFrame]; 335 | [_foregroundView insertSubview:self.statusBarBackgroundView atIndex:0]; 336 | } 337 | 338 | // get the color of the bar 339 | UIStatusBarForegroundStyleAttributes *foregroundStyle = self.foregroundStyle; 340 | UIColor *barColor; 341 | if ([foregroundStyle isKindOfClass:%c(UIStatusBarNewUIForegroundStyleAttributes)] && [foregroundStyle respondsToSelector:@selector(_batteryColorForCapacity:lowCapacity:charging:)]) 342 | barColor = [(UIStatusBarNewUIForegroundStyleAttributes *)foregroundStyle _batteryColorForCapacity:_capacity / 100.0 lowCapacity:[%c(UIStatusBar) lowBatteryLevel] charging:(_state == kChargingBatteryStyle)]; 343 | else if ([foregroundStyle respondsToSelector:@selector(_batteryColorForCapacity:lowCapacity:style:usingTintColor:)]) 344 | barColor = [foregroundStyle _batteryColorForCapacity:_capacity lowCapacity:[%c(UIStatusBar) lowBatteryLevel] style:_cachedBatteryStyle usingTintColor:YES]; 345 | else 346 | barColor = [foregroundStyle _batteryColorForCapacity:_capacity lowCapacity:[%c(UIStatusBar) lowBatteryLevel] style:_cachedBatteryStyle]; 347 | 348 | // set the blur effect or color of status bar background 349 | if (batteryBarType == kBackground) { 350 | if (%c(UIVisualEffectView) && [self.statusBarBackgroundView isKindOfClass:%c(UIVisualEffectView)]) { 351 | if (statusBarForegroundColor == kAlwaysWhite) { 352 | ((UIVisualEffectView *)self.statusBarBackgroundView).effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; 353 | } else if (statusBarForegroundColor == kAlwaysBlack) { 354 | ((UIVisualEffectView *)self.statusBarBackgroundView).effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; 355 | } else { 356 | UIStatusBarNewUIStyleAttributes *_currentStyleAttributes = [_statusBar _currentStyleAttributes]; 357 | if (_currentStyleAttributes != nil) { 358 | UIColor *_foregroundColor = MSHookIvar(_currentStyleAttributes, "_foregroundColor"); 359 | if (_foregroundColor != nil && [_foregroundColor isEqual:[UIColor whiteColor]]) 360 | ((UIVisualEffectView *)self.statusBarBackgroundView).effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; 361 | else if (_foregroundColor != nil && [_foregroundColor isEqual:[UIColor blackColor]]) 362 | ((UIVisualEffectView *)self.statusBarBackgroundView).effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; 363 | else 364 | ((UIVisualEffectView *)self.statusBarBackgroundView).effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; 365 | } else { 366 | ((UIVisualEffectView *)self.statusBarBackgroundView).effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; 367 | } 368 | } 369 | } else { 370 | if (statusBarForegroundColor == kAlwaysWhite) { 371 | self.statusBarBackgroundView.backgroundColor = [UIColor colorWithRed:kBlackBackgroundGrayness green:kBlackBackgroundGrayness blue:kBlackBackgroundGrayness alpha:1.0]; // dark gray 372 | } else if (statusBarForegroundColor == kAlwaysBlack) { 373 | self.statusBarBackgroundView.backgroundColor = [UIColor colorWithRed:kWhiteBackgroundGrayness green:kWhiteBackgroundGrayness blue:kWhiteBackgroundGrayness alpha:1.0]; // light gray 374 | } else { 375 | UIStatusBarNewUIStyleAttributes *_currentStyleAttributes = [_statusBar _currentStyleAttributes]; 376 | if (_currentStyleAttributes != nil) { 377 | UIColor *_foregroundColor = MSHookIvar(_currentStyleAttributes, "_foregroundColor"); 378 | if (_foregroundColor != nil && [_foregroundColor isEqual:[UIColor whiteColor]]) 379 | self.statusBarBackgroundView.backgroundColor = [UIColor colorWithRed:kBlackBackgroundGrayness green:kBlackBackgroundGrayness blue:kBlackBackgroundGrayness alpha:1.0]; // dark gray 380 | else if (_foregroundColor != nil && [_foregroundColor isEqual:[UIColor blackColor]]) 381 | self.statusBarBackgroundView.backgroundColor = [UIColor colorWithRed:kWhiteBackgroundGrayness green:kWhiteBackgroundGrayness blue:kWhiteBackgroundGrayness alpha:1.0]; // light gray 382 | else 383 | self.statusBarBackgroundView.backgroundColor = [UIColor colorWithRed:kBlackBackgroundGrayness green:kBlackBackgroundGrayness blue:kBlackBackgroundGrayness alpha:1.0]; // dark gray 384 | } else { 385 | self.statusBarBackgroundView.backgroundColor = [UIColor colorWithRed:kBlackBackgroundGrayness green:kBlackBackgroundGrayness blue:kBlackBackgroundGrayness alpha:1.0]; // dark gray 386 | } 387 | } 388 | } 389 | 390 | // fix bar color since it is in the background 391 | if (batteryColorStyle == kDefaultBatteryColor) { 392 | if ([barColor isEqual:[UIColor whiteColor]]) 393 | barColor = [UIColor blackColor]; 394 | else if ([barColor isEqual:[UIColor blackColor]]) 395 | barColor = [UIColor whiteColor]; 396 | } 397 | } else if (statusBarForegroundColor == kAlwaysWhite) { 398 | if (%c(UIVisualEffectView) && [self.statusBarBackgroundView isKindOfClass:%c(UIVisualEffectView)]) 399 | ((UIVisualEffectView *)self.statusBarBackgroundView).effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; 400 | else 401 | self.statusBarBackgroundView.backgroundColor = [UIColor blackColor]; 402 | } else if (statusBarForegroundColor == kAlwaysBlack) { 403 | if (%c(UIVisualEffectView) && [self.statusBarBackgroundView isKindOfClass:%c(UIVisualEffectView)]) 404 | ((UIVisualEffectView *)self.statusBarBackgroundView).effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; 405 | else 406 | self.statusBarBackgroundView.backgroundColor = [UIColor whiteColor]; 407 | } 408 | if (statusBarForegroundColor != kDefaultStatusColor || batteryBarType == kBackground) { 409 | [self updateStatusBarBackgroundViewBarHiddenAnimated:YES]; 410 | self.statusBarBackgroundView.frame = backgroundViewFrame; 411 | } 412 | 413 | // set battery bar opacity if it is default status color 414 | if (batteryColorStyle == kDefaultBatteryColor) 415 | barColor = [barColor colorWithAlphaComponent:batteryBarOpacity]; 416 | 417 | // start/stop charging animation 418 | if (chargingAnimationStyle != kNoChargingAnimation) 419 | [self doChargingAnimation]; 420 | 421 | // animate percent change 422 | [UIView animateWithDuration:(animated ? kAnimationSpeed : 0.0) animations:^{ 423 | self.batteryPercentBarView.frame = barFrame; 424 | self.batteryPercentBarView.backgroundColor = barColor; 425 | } completion:nil]; 426 | } 427 | } 428 | 429 | %new 430 | -(void)doChargingAnimation { 431 | if (MSHookIvar(self, "_state") == kChargingBatteryStyle) { 432 | if (!self.isAnimatingCharging) { 433 | self.isAnimatingCharging = YES; 434 | if (chargingAnimationStyle == kPulse) { 435 | self.batteryPercentBarView.alpha = 1.0; 436 | [UIView animateKeyframesWithDuration:kAnimationSpeed * 6.0 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ 437 | [UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.5 animations:^{ 438 | self.batteryPercentBarView.alpha = 0.0; 439 | }]; 440 | [UIView addKeyframeWithRelativeStartTime:0.5 relativeDuration:0.5 animations:^{ 441 | self.batteryPercentBarView.alpha = 1.0; 442 | }]; 443 | } completion:^(BOOL finished) { 444 | self.isAnimatingCharging = NO; 445 | if (finished) 446 | [self doChargingAnimation]; 447 | }]; 448 | } else if (chargingAnimationStyle == kSway){ 449 | CGFloat rightTranslation = self.superview.frame.size.width - self.batteryPercentBarView.frame.size.width - self.batteryPercentBarView.frame.origin.x; 450 | CGFloat leftTranslation = -self.batteryPercentBarView.frame.origin.x; 451 | self.batteryPercentBarView.transform = CGAffineTransformMakeTranslation(0.0, 0.0); 452 | if (batteryBarAlignment == kLeft) 453 | [UIView animateKeyframesWithDuration:kAnimationSpeed * 6.0 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ 454 | [UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.5 animations:^{ 455 | self.batteryPercentBarView.transform = CGAffineTransformMakeTranslation(rightTranslation, 0.0); 456 | }]; 457 | [UIView addKeyframeWithRelativeStartTime:0.5 relativeDuration:0.5 animations:^{ 458 | self.batteryPercentBarView.transform = CGAffineTransformMakeTranslation(0.0, 0.0); 459 | }]; 460 | } completion:^(BOOL finished) { 461 | self.isAnimatingCharging = NO; 462 | if (finished) 463 | [self doChargingAnimation]; 464 | }]; 465 | else if (batteryBarAlignment == kRight) 466 | [UIView animateKeyframesWithDuration:kAnimationSpeed * 6.0 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ 467 | [UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.5 animations:^{ 468 | self.batteryPercentBarView.transform = CGAffineTransformMakeTranslation(leftTranslation, 0.0); 469 | }]; 470 | [UIView addKeyframeWithRelativeStartTime:0.5 relativeDuration:0.5 animations:^{ 471 | self.batteryPercentBarView.transform = CGAffineTransformMakeTranslation(0.0, 0.0); 472 | }]; 473 | } completion:^(BOOL finished) { 474 | self.isAnimatingCharging = NO; 475 | if (finished) 476 | [self doChargingAnimation]; 477 | }]; 478 | else 479 | [UIView animateKeyframesWithDuration:kAnimationSpeed * 6.0 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ 480 | [UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.25 animations:^{ 481 | self.batteryPercentBarView.transform = CGAffineTransformMakeTranslation(leftTranslation, 0.0); 482 | }]; 483 | [UIView addKeyframeWithRelativeStartTime:0.25 relativeDuration:0.25 animations:^{ 484 | self.batteryPercentBarView.transform = CGAffineTransformMakeTranslation(0.0, 0.0); 485 | }]; 486 | [UIView addKeyframeWithRelativeStartTime:0.5 relativeDuration:0.25 animations:^{ 487 | self.batteryPercentBarView.transform = CGAffineTransformMakeTranslation(rightTranslation, 0.0); 488 | }]; 489 | [UIView addKeyframeWithRelativeStartTime:0.75 relativeDuration:0.25 animations:^{ 490 | self.batteryPercentBarView.transform = CGAffineTransformMakeTranslation(0.0, 0.0); 491 | }]; 492 | } completion:^(BOOL finished) { 493 | self.isAnimatingCharging = NO; 494 | if (finished) 495 | [self doChargingAnimation]; 496 | }]; 497 | } 498 | } 499 | } 500 | } 501 | 502 | %new 503 | -(void)updateStatusBarBackgroundViewBarHiddenAnimated:(BOOL)animated { 504 | UIStatusBarForegroundView *_foregroundView = (UIStatusBarForegroundView *)self.superview; 505 | if (_foregroundView == nil) 506 | return; 507 | UIStatusBar *_statusBar = (UIStatusBar *)_foregroundView.superview; 508 | if (_statusBar == nil) 509 | return; 510 | UIStatusBarNewUIStyleAttributes *_currentStyleAttributes = [_statusBar _currentStyleAttributes]; 511 | BOOL shouldHideBackground = NO; 512 | if (_currentStyleAttributes != nil && [_currentStyleAttributes respondsToSelector:@selector(doesRequireStatusBarBackground)]) 513 | shouldHideBackground = ![_currentStyleAttributes doesRequireStatusBarBackground]; 514 | if (batteryBarType == kBackground) 515 | shouldHideBackground = NO; 516 | 517 | if (animated) 518 | [UIView animateWithDuration:kAnimationSpeed animations:^{ 519 | self.statusBarBackgroundView.hidden = shouldHideBackground; 520 | } completion:nil]; 521 | else 522 | self.statusBarBackgroundView.hidden = shouldHideBackground; 523 | } 524 | 525 | -(void)dealloc { 526 | if (self.batteryPercentBarView != nil) { 527 | [self.batteryPercentBarView release]; 528 | self.batteryPercentBarView = nil; 529 | } 530 | 531 | if (self.statusBarBackgroundView != nil) { 532 | [self.statusBarBackgroundView release]; 533 | self.statusBarBackgroundView = nil; 534 | } 535 | 536 | %orig(); 537 | } 538 | %end 539 | 540 | %group CustomBatteryColors 541 | static UIColor *getColorForCapacity(NSInteger capacity, NSInteger lowCapacity, NSUInteger style) { 542 | UIColor *result = nil; 543 | BatteryColorPrefs *colorPrefs = [BatteryColorPrefs sharedInstance]; 544 | if (batteryColorStyle == kSolid) { 545 | if (style == kLowPowerModeBatteryStyle || style == kLowPowerModeAndChargingStyle) { // yellow-orange battery (Low Power Mode) 546 | result = [LCPParseColorString(colorPrefs.solidLowPowerModeColor, colorPrefs.solidLowPowerModeColor) retain]; 547 | } else if (style == kChargingBatteryStyle) { // green battery (Charging Mode) 548 | result = [LCPParseColorString(colorPrefs.solidChargingColor, colorPrefs.solidChargingColor) retain]; 549 | } else if (style == kNormalBatteryStyle) { // Normal Mode 550 | if (capacity <= lowCapacity) // red battery 551 | result = [LCPParseColorString(colorPrefs.solidLessThan20Color, colorPrefs.solidLessThan20Color) retain]; 552 | else // white or black battery 553 | result = [LCPParseColorString(colorPrefs.solidGreaterThan20Color, colorPrefs.solidGreaterThan20Color) retain]; 554 | } 555 | } else if (batteryColorStyle == kGradient) { 556 | if (isGradientLowPowerEnabled && (style == kLowPowerModeBatteryStyle || style == kLowPowerModeAndChargingStyle)) { 557 | result = [LCPParseColorString(colorPrefs.gradientLowPowerModeColor, colorPrefs.gradientLowPowerModeColor) retain]; 558 | } else if (isGradientChargingEnabled && (style == kChargingBatteryStyle || style == kLowPowerModeAndChargingStyle)) { 559 | result = [LCPParseColorString(colorPrefs.gradientChargingColor, colorPrefs.gradientChargingColor) retain]; 560 | } else { 561 | NSInteger colorOffset = capacity / 5; // get color within 5% ranges 562 | if (colorOffset < 0) 563 | colorOffset = 0; 564 | else if (colorOffset > [colorPrefs.gradientColor count]) 565 | colorOffset = [colorPrefs.gradientColor count] - 1; 566 | result = [LCPParseColorString([colorPrefs.gradientColor objectAtIndex:colorOffset], [colorPrefs.defaultGradientColor objectAtIndex:colorOffset]) retain]; 567 | } 568 | } 569 | return result; 570 | } 571 | 572 | %hook UIStatusBarForegroundStyleAttributes 573 | -(id)_batteryColorForCapacity:(NSInteger)arg1 lowCapacity:(NSInteger)arg2 style:(NSUInteger)arg3 { 574 | id result = %orig(arg1, arg2, arg3); 575 | UIColor *newColor = getColorForCapacity(arg1, arg2, arg3); 576 | if (newColor != nil) 577 | result = newColor; 578 | return result; 579 | } 580 | 581 | -(id)_batteryColorForCapacity:(NSInteger)arg1 lowCapacity:(NSInteger)arg2 style:(NSUInteger)arg3 usingTintColor:(BOOL)arg4 { 582 | id result = %orig(arg1, arg2, arg3, arg4); 583 | UIColor *newColor = getColorForCapacity(arg1, arg2, arg3); 584 | if (newColor != nil) 585 | result = newColor; 586 | return result; 587 | } 588 | %end 589 | 590 | %hook UIStatusBarNewUIForegroundStyleAttributes 591 | -(id)_batteryColorForCapacity:(CGFloat)arg1 lowCapacity:(CGFloat)arg2 charging:(BOOL)arg3 { 592 | id result = %orig(arg1, arg2, arg3); 593 | UIColor *newColor; 594 | if (arg1 <= 1.0 && arg2 < 1.0) 595 | newColor = getColorForCapacity(arg1 * 100, arg2 * 100, arg3 ? kChargingBatteryStyle : kNormalBatteryStyle); 596 | else 597 | newColor = getColorForCapacity(arg1, arg2, arg3 ? kChargingBatteryStyle : kNormalBatteryStyle); 598 | if (newColor != nil) 599 | result = newColor; 600 | return result; 601 | } 602 | %end 603 | %end 604 | 605 | static void reloadPrefs() { 606 | CFPreferencesAppSynchronize((CFStringRef)kIdentifier); 607 | 608 | NSDictionary *prefs = nil; 609 | if ([NSHomeDirectory() isEqualToString:@"/var/mobile"]) { 610 | CFArrayRef keyList = CFPreferencesCopyKeyList((CFStringRef)kIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); 611 | if (keyList != nil) { 612 | prefs = (NSDictionary *)CFPreferencesCopyMultiple(keyList, (CFStringRef)kIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); 613 | if (prefs == nil) 614 | prefs = [NSDictionary dictionary]; 615 | CFRelease(keyList); 616 | } 617 | } 618 | 619 | // needed to do this for photos app (it doesn't seem to create a copy of prefs) 620 | if (prefs == nil) { 621 | prefs = [[NSDictionary alloc] initWithContentsOfFile:kSettingsPath]; 622 | } 623 | 624 | isEnabled = [prefs objectForKey:@"isEnabled"] ? [[prefs objectForKey:@"isEnabled"] boolValue] : YES; 625 | 626 | isUseActualBatteryLevelEnabled = [prefs objectForKey:@"isUseActualBatteryLevelEnabled"] ? [[prefs objectForKey:@"isUseActualBatteryLevelEnabled"] boolValue] : YES; 627 | statusBarForegroundColor = [prefs objectForKey:@"statusBarForegroundColor"] ? (StatusBarColorType)[[prefs objectForKey:@"statusBarForegroundColor"] intValue] : kDefaultStatusColor; 628 | isHomescreenBackgroundEnabled = [prefs objectForKey:@"isHomescreenBackgroundEnabled"] ? [[prefs objectForKey:@"isHomescreenBackgroundEnabled"] boolValue] : NO; 629 | isBatteryIconHidden = [prefs objectForKey:@"isBatteryIconHidden"] ? [[prefs objectForKey:@"isBatteryIconHidden"] boolValue] : YES; 630 | isChargingIconHidden = [prefs objectForKey:@"isChargingIconHidden"] ? [[prefs objectForKey:@"isChargingIconHidden"] boolValue] : YES; 631 | batteryBarType = [prefs objectForKey:@"batteryBarType"] ? (BarType)[[prefs objectForKey:@"batteryBarType"] intValue] : kSkinny; 632 | isBottomBarEnabled = [prefs objectForKey:@"isBottomBarEnabled"] ? [[prefs objectForKey:@"isBottomBarEnabled"] boolValue] : NO; 633 | normalBarHeight = [prefs objectForKey:@"barHeight"] ? (CGFloat)[[prefs objectForKey:@"barHeight"] floatValue] : 3.0; 634 | batteryBarAlignment = [prefs objectForKey:@"batteryBarAlignment"] ? (BarAlignment)[[prefs objectForKey:@"batteryBarAlignment"] intValue] : kLeft; 635 | batteryColorStyle = [prefs objectForKey:@"batteryColorStyle"] ? (BatteryColorStyle)[[prefs objectForKey:@"batteryColorStyle"] intValue] : kDefaultBatteryColor; 636 | batteryBarOpacity = [prefs objectForKey:@"batteryBarOpacity"] ? (CGFloat)[[prefs objectForKey:@"batteryBarOpacity"] floatValue] : 1.0; 637 | isGradientLowPowerEnabled = [prefs objectForKey:@"isGradientLowPowerEnabled"] ? [[prefs objectForKey:@"isGradientLowPowerEnabled"] boolValue] : NO; 638 | isGradientChargingEnabled = [prefs objectForKey:@"isGradientChargingEnabled"] ? [[prefs objectForKey:@"isGradientChargingEnabled"] boolValue] : NO; 639 | chargingAnimationStyle = [prefs objectForKey:@"chargingAnimationStyle"] ? (ChargingAnimationStyle)[[prefs objectForKey:@"chargingAnimationStyle"] intValue] : kNoChargingAnimation; 640 | 641 | kAnimationSpeed = [prefs objectForKey:@"animationSpeed"] ? (CGFloat)[[prefs objectForKey:@"animationSpeed"] floatValue] : 0.5; 642 | kUseBlur = [prefs objectForKey:@"isBlurBackgroundEnabled"] ? [[prefs objectForKey:@"isBlurBackgroundEnabled"] boolValue] : NO; 643 | kWhiteBackgroundGrayness = [prefs objectForKey:@"WhiteBackgroundGrayness"] ? (CGFloat)[[prefs objectForKey:@"WhiteBackgroundGrayness"] floatValue] : 0.7; 644 | kBlackBackgroundGrayness = [prefs objectForKey:@"BlackBackgroundGrayness"] ? (CGFloat)[[prefs objectForKey:@"BlackBackgroundGrayness"] floatValue] : 0.3; 645 | 646 | [[BatteryColorPrefs sharedInstance] updatePreferences]; // update color prefs 647 | 648 | [prefs release]; 649 | } 650 | 651 | static void reloadColorPrefs() { 652 | [[BatteryColorPrefs sharedInstance] updatePreferences]; // update color prefs 653 | } 654 | 655 | static void respringDevice() { 656 | if (%c(FBSystemService)) 657 | [[%c(FBSystemService) sharedInstance] exitAndRelaunch:YES]; 658 | else if ([[%c(SpringBoard) sharedApplication] respondsToSelector:@selector(_relaunchSpringBoardNow)]) 659 | [[%c(SpringBoard) sharedApplication] _relaunchSpringBoardNow]; 660 | } 661 | 662 | %dtor { 663 | // becauses Amazon app generates crashes for some reason when launching 664 | if (![[NSBundle mainBundle].bundleIdentifier isEqualToString:@"com.amazon.Amazon"]) { 665 | CFNotificationCenterRemoveObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, kSettingsChangedNotification, NULL); 666 | CFNotificationCenterRemoveObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, kColorChangedNotification, NULL); 667 | CFNotificationCenterRemoveObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, kRespringNotification, NULL); 668 | } 669 | } 670 | 671 | %ctor { 672 | reloadPrefs(); 673 | CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)reloadPrefs, kSettingsChangedNotification, NULL, CFNotificationSuspensionBehaviorDeliverImmediately); 674 | CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)reloadColorPrefs, kColorChangedNotification, NULL, CFNotificationSuspensionBehaviorDeliverImmediately); 675 | 676 | // Only initialize tweak if it is enabled and if the current process is homescreen or an app 677 | NSArray *args = [[NSProcessInfo processInfo] arguments]; 678 | if (args != nil && args.count != 0) { 679 | NSString *execPath = args[0]; 680 | if (execPath) { 681 | BOOL isSpringBoard = [[execPath lastPathComponent] isEqualToString:@"SpringBoard"]; 682 | BOOL isApplication = [execPath rangeOfString:@"/Application"].location != NSNotFound; 683 | if ((isSpringBoard || isApplication) && isEnabled) { 684 | %init(); 685 | 686 | // inject portions as needed (optomize performance slightly) 687 | if (statusBarForegroundColor != kDefaultStatusColor) 688 | %init(AlwaysWhiteOrBlack); 689 | 690 | if (batteryColorStyle != kDefaultBatteryColor) 691 | %init(CustomBatteryColors); 692 | } 693 | 694 | if (isSpringBoard) 695 | CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)respringDevice, kRespringNotification, NULL, CFNotificationSuspensionBehaviorDeliverImmediately); 696 | } 697 | } 698 | } -------------------------------------------------------------------------------- /batterybar/BBGradientListController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | @interface PSListController (BBGPrivate) 6 | -(void)clearCache; 7 | -(BOOL)containsSpecifier:(id)arg1; 8 | @end 9 | 10 | @interface BBGradientListController : PSListController { 11 | BOOL _isCurrentlyDisablingSpecifiers; 12 | PSSpecifier *_gradientLowPowerModeColorSpecifier; 13 | PSSpecifier *_gradientChargingColorSpecifier; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /batterybar/BBGradientListController.m: -------------------------------------------------------------------------------- 1 | #include "BBGradientListController.h" 2 | 3 | @implementation BBGradientListController 4 | 5 | - (id)initForContentSize:(CGSize)size { 6 | self = [super initForContentSize:size]; 7 | if (self != nil) 8 | _isCurrentlyDisablingSpecifiers = NO; 9 | return self; 10 | } 11 | 12 | - (NSArray *)specifiers { 13 | if (!_specifiers) { 14 | _specifiers = [[self loadSpecifiersFromPlistName:@"Gradient" target:self] retain]; 15 | } 16 | return _specifiers; 17 | } 18 | 19 | - (void)viewWillAppear:(BOOL)animated { 20 | [self clearCache]; 21 | [self reload]; 22 | [super viewWillAppear:animated]; 23 | } 24 | 25 | - (void)setPreferenceValue:(id)value specifier:(id)specifier { 26 | [super setPreferenceValue:value specifier:specifier]; 27 | 28 | if (!_isCurrentlyDisablingSpecifiers) { 29 | [self removeSpecifiersIfNeededAnimated:[NSNumber numberWithBool:YES]]; 30 | self.navigationItem.rightBarButtonItem.enabled = YES; 31 | } 32 | } 33 | 34 | - (void)viewDidLoad { 35 | [super viewDidLoad]; 36 | 37 | [self removeSpecifiersIfNeededAnimated:[NSNumber numberWithBool:NO]]; 38 | } 39 | 40 | - (void)reloadSpecifiers { 41 | [super reloadSpecifiers]; 42 | 43 | [self removeSpecifiersIfNeededAnimated:[NSNumber numberWithBool:NO]]; 44 | } 45 | 46 | - (void)removeSpecifiersIfNeededAnimated:(NSNumber *)animatedObject { 47 | BOOL animated = [animatedObject boolValue]; 48 | 49 | _isCurrentlyDisablingSpecifiers = YES; 50 | 51 | if ([self specifierForID:@"LowPowerColor"] != nil) 52 | _gradientLowPowerModeColorSpecifier = [self specifierForID:@"LowPowerColor"]; 53 | if ([self specifierForID:@"ChargingColor"] != nil) 54 | _gradientChargingColorSpecifier = [self specifierForID:@"ChargingColor"]; 55 | 56 | // Add/Remove the low power mode color specifier 57 | if (_gradientLowPowerModeColorSpecifier != nil) { 58 | PSSpecifier *lowPowerSwitchSpecifier = [self specifierForID:@"LowPowerSwitch"]; 59 | id lowPowerSwitchValue = [self readPreferenceValue:lowPowerSwitchSpecifier]; 60 | if ([lowPowerSwitchValue boolValue]) { 61 | if (![self containsSpecifier:_gradientLowPowerModeColorSpecifier]) { 62 | [self insertSpecifier:_gradientLowPowerModeColorSpecifier afterSpecifier:lowPowerSwitchSpecifier animated:animated]; 63 | [_gradientLowPowerModeColorSpecifier release]; 64 | } 65 | } else { 66 | if ([self containsSpecifier:_gradientLowPowerModeColorSpecifier]) 67 | [self removeSpecifier:[_gradientLowPowerModeColorSpecifier retain] animated:animated]; 68 | } 69 | } 70 | 71 | // Add/Remove the charging color specifier 72 | if (_gradientChargingColorSpecifier != nil) { 73 | PSSpecifier *chargingSwitchSpecifier = [self specifierForID:@"ChargingSwitch"]; 74 | id chargingSwitchValue = [self readPreferenceValue:chargingSwitchSpecifier]; 75 | if ([chargingSwitchValue boolValue]) { 76 | if (![self containsSpecifier:_gradientChargingColorSpecifier]) { 77 | [self insertSpecifier:_gradientChargingColorSpecifier afterSpecifier:chargingSwitchSpecifier animated:animated]; 78 | [_gradientChargingColorSpecifier release]; 79 | } 80 | } else { 81 | if ([self containsSpecifier:_gradientChargingColorSpecifier]) 82 | [self removeSpecifier:[_gradientChargingColorSpecifier retain] animated:animated]; 83 | } 84 | } 85 | 86 | _isCurrentlyDisablingSpecifiers = NO; 87 | } 88 | 89 | @end -------------------------------------------------------------------------------- /batterybar/BBRootListController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | #import 5 | 6 | @interface PSListController (BBRPrivate) 7 | -(BOOL)containsSpecifier:(id)arg1; 8 | @end 9 | 10 | @interface BBRootListController : PSListController { 11 | BOOL _isCurrentlyDisablingSpecifiers; 12 | PSSpecifier *_bottomBarSpecifier; 13 | PSSpecifier *_barHeightSpecifier; 14 | PSSpecifier *_hideChargingIconSpecifier; 15 | PSSpecifier *_homescreenBackgroundSpecifier; 16 | PSSpecifier *_customSolidBatteryColor; 17 | PSSpecifier *_customGradientBatteryColor; 18 | PSSpecifier *_batteryBarOpacity; 19 | } 20 | @end 21 | -------------------------------------------------------------------------------- /batterybar/BBRootListController.m: -------------------------------------------------------------------------------- 1 | #include "BBRootListController.h" 2 | #import "BBSolidColorListController.h" 3 | #import "BBGradientListController.h" 4 | 5 | @implementation BBRootListController 6 | 7 | - (id)initForContentSize:(CGSize)size { 8 | self = [super initForContentSize:size]; 9 | if (self != nil) { 10 | UIImageView *iconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon" inBundle:[self bundle] compatibleWithTraitCollection:nil]]; 11 | iconView.contentMode = UIViewContentModeScaleAspectFit; 12 | iconView.frame = CGRectMake(0, 0, 29, 29); 13 | [self.navigationItem setTitleView:iconView]; 14 | [iconView release]; 15 | UIBarButtonItem *respringItem = [[UIBarButtonItem alloc] initWithTitle:@"Respring" style:UIBarButtonItemStyleDone target:self action:@selector(respring)]; 16 | [self.navigationItem setRightBarButtonItem:respringItem animated:NO]; 17 | self.navigationItem.rightBarButtonItem.enabled = NO; 18 | [respringItem release]; 19 | 20 | _isCurrentlyDisablingSpecifiers = NO; 21 | } 22 | return self; 23 | } 24 | 25 | - (NSArray *)specifiers { 26 | if (!_specifiers) { 27 | _specifiers = [[self loadSpecifiersFromPlistName:@"Root" target:self] retain]; 28 | } 29 | return _specifiers; 30 | } 31 | 32 | - (void)email { 33 | if ([MFMailComposeViewController canSendMail]) { 34 | MFMailComposeViewController *email = [[MFMailComposeViewController alloc] initWithNibName:nil bundle:nil]; 35 | [email setSubject:@"BatteryBar Support"]; 36 | [email setToRecipients:[NSArray arrayWithObjects:@"deeppwnage@yahoo.com", nil]]; 37 | [email addAttachmentData:[NSData dataWithContentsOfFile:@"/var/mobile/Library/Preferences/com.dgh0st.batterybar.plist"] mimeType:@"application/xml" fileName:@"Prefs.plist"]; 38 | #pragma GCC diagnostic push 39 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 40 | system("/usr/bin/dpkg -l > /tmp/dpkgl.log"); 41 | #pragma GCC diagnostic pop 42 | [email addAttachmentData:[NSData dataWithContentsOfFile:@"/tmp/dpkgl.log"] mimeType:@"text/plain" fileName:@"dpkgl.txt"]; 43 | [self.navigationController presentViewController:email animated:YES completion:nil]; 44 | [email setMailComposeDelegate:self]; 45 | [email release]; 46 | } 47 | } 48 | 49 | - (void)mailComposeController:(id)controller didFinishWithResult:(MFMailComposeResult)result error:(id)error { 50 | [self dismissViewControllerAnimated:YES completion: nil]; 51 | } 52 | 53 | - (void)donate { 54 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://paypal.me/DGhost"]]; 55 | } 56 | 57 | - (void)follow { 58 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://mobile.twitter.com/D_Gh0st"]]; 59 | } 60 | 61 | - (void)respring { 62 | UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"BatteryBar" message:@"Are you sure you want to respring?" preferredStyle:UIAlertControllerStyleAlert]; 63 | 64 | UIAlertAction *respringAction = [UIAlertAction actionWithTitle:@"Yes, Respring" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { 65 | CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.dgh0st.batterybar/respring"), NULL, NULL, YES); 66 | }]; 67 | 68 | UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { 69 | [self dismissViewControllerAnimated:YES completion:nil]; 70 | }]; 71 | 72 | [alert addAction:respringAction]; 73 | [alert addAction:cancelAction]; 74 | 75 | [self presentViewController:alert animated:YES completion:nil]; 76 | } 77 | 78 | - (void)setPreferenceValue:(id)value specifier:(id)specifier { 79 | [super setPreferenceValue:value specifier:specifier]; 80 | 81 | if (!_isCurrentlyDisablingSpecifiers) { 82 | [self removeSpecifiersIfNeededAnimated:[NSNumber numberWithBool:YES]]; 83 | self.navigationItem.rightBarButtonItem.enabled = YES; 84 | } 85 | } 86 | 87 | - (void)viewDidLoad { 88 | [super viewDidLoad]; 89 | 90 | [self removeSpecifiersIfNeededAnimated:[NSNumber numberWithBool:NO]]; 91 | } 92 | 93 | -(void)dealloc { 94 | [self clearPreviousSpecifiers]; 95 | 96 | [super dealloc]; 97 | } 98 | 99 | - (void)reloadSpecifiers { 100 | [super reloadSpecifiers]; 101 | 102 | [self removeSpecifiersIfNeededAnimated:[NSNumber numberWithBool:NO]]; 103 | } 104 | 105 | - (void)clearPreviousSpecifiers { 106 | if (_bottomBarSpecifier != nil) 107 | [_bottomBarSpecifier release]; 108 | _bottomBarSpecifier = nil; 109 | if (_barHeightSpecifier != nil) 110 | [_barHeightSpecifier release]; 111 | _barHeightSpecifier = nil; 112 | if (_hideChargingIconSpecifier != nil) 113 | [_hideChargingIconSpecifier release]; 114 | _hideChargingIconSpecifier = nil; 115 | if (_homescreenBackgroundSpecifier != nil) 116 | [_homescreenBackgroundSpecifier release]; 117 | _homescreenBackgroundSpecifier = nil; 118 | if (_customSolidBatteryColor != nil) 119 | [_customSolidBatteryColor release]; 120 | _customSolidBatteryColor = nil; 121 | if (_customGradientBatteryColor != nil) 122 | [_customGradientBatteryColor release]; 123 | _customGradientBatteryColor = nil; 124 | if (_batteryBarOpacity != nil) 125 | [_batteryBarOpacity release]; 126 | _batteryBarOpacity = nil; 127 | } 128 | 129 | - (void)removeSpecifiersIfNeededAnimated:(NSNumber *)animatedObject { 130 | BOOL animated = [animatedObject boolValue]; 131 | 132 | _isCurrentlyDisablingSpecifiers = YES; 133 | 134 | PSSpecifier *bottomBarSpecifier = [self specifierForID:@"BottomBar"]; 135 | PSSpecifier *barHeightSpecifier = [self specifierForID:@"BarHeight"]; 136 | PSSpecifier *hideChargingIconSpecifier = [self specifierForID:@"HideChargingIcon"]; 137 | PSSpecifier *homescreenBackgroundSpecifier = [self specifierForID:@"HomescreenBackground"]; 138 | PSSpecifier *customSolidBatteryColor = [self specifierForID:@"CustomSolidBatteryColor"]; 139 | PSSpecifier *customGradientBatteryColor = [self specifierForID:@"CustomGradientBatteryColor"]; 140 | PSSpecifier *batteryBarOpacity = [self specifierForID:@"BarOpacity"]; 141 | 142 | // Add/Remove the bottom bar switch and bar height slider 143 | PSSpecifier *batteryBarTypeSpecifier = [self specifierForID:@"BarType"]; 144 | PSSpecifier *type = [self specifierForID:@"Type"]; 145 | id batteryBarTypeValue = [self readPreferenceValue:batteryBarTypeSpecifier]; 146 | if ([batteryBarTypeValue intValue] == 2) { 147 | if (bottomBarSpecifier != nil && [self containsSpecifier:bottomBarSpecifier]) { 148 | [self setPreferenceValue:@NO specifier:bottomBarSpecifier]; 149 | _bottomBarSpecifier = [bottomBarSpecifier retain]; 150 | [self removeSpecifier:_bottomBarSpecifier animated:animated]; 151 | } 152 | if (barHeightSpecifier != nil && [self containsSpecifier:barHeightSpecifier]) { 153 | _barHeightSpecifier = [barHeightSpecifier retain]; 154 | [self removeSpecifier:_barHeightSpecifier animated:animated]; 155 | } 156 | [type setProperty:@"" forKey:@"footerText"]; 157 | [self reloadSpecifier:type animated:animated]; 158 | } else { 159 | if (_barHeightSpecifier != nil && ![self containsSpecifier:_barHeightSpecifier]) { 160 | [self insertSpecifier:_barHeightSpecifier afterSpecifier:batteryBarTypeSpecifier]; 161 | [_barHeightSpecifier release]; 162 | _barHeightSpecifier = nil; 163 | } 164 | if (_bottomBarSpecifier != nil && ![self containsSpecifier:_bottomBarSpecifier]) { 165 | [self insertSpecifier:_bottomBarSpecifier afterSpecifier:batteryBarTypeSpecifier]; 166 | [_bottomBarSpecifier release]; 167 | _bottomBarSpecifier = nil; 168 | } 169 | 170 | if ([batteryBarTypeValue intValue] == 0) // skinny 171 | [type setProperty:@"Set the height of the bar" forKey:@"footerText"]; 172 | else if ([batteryBarTypeValue intValue] == 1) // thick 173 | [type setProperty:@"Set the height of the bar (Thick type will make the bar twice as big and move down the status bar by the height)" forKey:@"footerText"]; 174 | else 175 | [type setProperty:@"" forKey:@"footerText"]; 176 | [self reloadSpecifier:type animated:animated]; 177 | } 178 | 179 | 180 | // Add/Remove the battery/charging icon switches 181 | PSSpecifier *hideBatteryIconSpecifier = [self specifierForID:@"HideBatteryIcon"]; 182 | id batteryIconValue = [self readPreferenceValue:hideBatteryIconSpecifier]; 183 | if (![batteryIconValue boolValue]) { 184 | if (hideChargingIconSpecifier != nil && [self containsSpecifier:hideChargingIconSpecifier]) { 185 | [self setPreferenceValue:@NO specifier:hideChargingIconSpecifier]; 186 | _hideChargingIconSpecifier = [hideChargingIconSpecifier retain]; 187 | [self removeSpecifier:_hideChargingIconSpecifier animated:animated]; 188 | } 189 | } else if (_hideChargingIconSpecifier != nil && ![self containsSpecifier:_hideChargingIconSpecifier]) { 190 | [self insertSpecifier:_hideChargingIconSpecifier afterSpecifier:hideBatteryIconSpecifier animated:animated]; 191 | [_hideChargingIconSpecifier release]; 192 | _hideChargingIconSpecifier = nil; 193 | } 194 | 195 | // Add/Remove the status bar color and homescreen background specifiers 196 | PSSpecifier *colorStatusBarSpecifier = [self specifierForID:@"ColorStatusBar"]; 197 | id statusBarStyleValue = [self readPreferenceValue:colorStatusBarSpecifier]; 198 | if ([statusBarStyleValue intValue] == 0) { // Default Status Bar Style 199 | if (homescreenBackgroundSpecifier != nil && [self containsSpecifier:homescreenBackgroundSpecifier]) { 200 | [self setPreferenceValue:@NO specifier:homescreenBackgroundSpecifier]; 201 | _homescreenBackgroundSpecifier = [homescreenBackgroundSpecifier retain]; 202 | [self removeSpecifier:_homescreenBackgroundSpecifier animated:animated]; 203 | } 204 | } else if (_homescreenBackgroundSpecifier != nil && ![self containsSpecifier:_homescreenBackgroundSpecifier]) { 205 | [self insertSpecifier:_homescreenBackgroundSpecifier afterSpecifier:colorStatusBarSpecifier animated:animated]; 206 | [_homescreenBackgroundSpecifier release]; 207 | _homescreenBackgroundSpecifier = nil; 208 | } 209 | 210 | // Add/Remove the colors sub-preferences 211 | PSSpecifier *batteryColorSpecifier = [self specifierForID:@"BatteryColor"]; 212 | PSSpecifier *barColor = [self specifierForID:@"BarColor"]; 213 | id batteryColorStyleValue = [self readPreferenceValue:batteryColorSpecifier]; 214 | if ([batteryColorStyleValue intValue] == 0) { 215 | if (_batteryBarOpacity != nil && ![self containsSpecifier:_batteryBarOpacity]) { 216 | if (animated) { 217 | if (customSolidBatteryColor != nil && [self containsSpecifier:customSolidBatteryColor]) { 218 | _customSolidBatteryColor = [customSolidBatteryColor retain]; 219 | [self replaceContiguousSpecifiers:[NSArray arrayWithObjects:_customSolidBatteryColor, nil] withSpecifiers:[NSArray arrayWithObjects:_batteryBarOpacity, nil] animated:YES]; 220 | } else if (customGradientBatteryColor != nil && [self containsSpecifier:customGradientBatteryColor]) { 221 | _customGradientBatteryColor = [customGradientBatteryColor retain]; 222 | [self replaceContiguousSpecifiers:[NSArray arrayWithObjects:_customGradientBatteryColor, nil] withSpecifiers:[NSArray arrayWithObjects:_batteryBarOpacity, nil] animated:YES]; 223 | } 224 | } else { 225 | [self insertSpecifier:_batteryBarOpacity afterSpecifier:batteryColorSpecifier animated:animated]; 226 | } 227 | [_batteryBarOpacity release]; 228 | _batteryBarOpacity = nil; 229 | } else { 230 | if (customSolidBatteryColor != nil && [self containsSpecifier:customSolidBatteryColor]) { 231 | _customSolidBatteryColor = [customSolidBatteryColor retain]; 232 | [self removeSpecifier:_customSolidBatteryColor animated:animated]; 233 | } 234 | if (customGradientBatteryColor != nil && [self containsSpecifier:customGradientBatteryColor]) { 235 | _customGradientBatteryColor = [customGradientBatteryColor retain]; 236 | [self removeSpecifier:_customGradientBatteryColor animated:animated]; 237 | } 238 | } 239 | [barColor setProperty:@"Set the opacity of the batter bar" forKey:@"footerText"]; 240 | [self reloadSpecifier:barColor animated:animated]; 241 | } else if ([batteryColorStyleValue intValue] == 1) { 242 | if (_customSolidBatteryColor != nil && ![self containsSpecifier:_customSolidBatteryColor]) { 243 | if (animated) { 244 | if (batteryBarOpacity != nil && [self containsSpecifier:batteryBarOpacity]) { 245 | _batteryBarOpacity = [batteryBarOpacity retain]; 246 | [self replaceContiguousSpecifiers:[NSArray arrayWithObjects:_batteryBarOpacity, nil] withSpecifiers:[NSArray arrayWithObjects:_customSolidBatteryColor, nil] animated:YES]; 247 | } else if (customGradientBatteryColor != nil && [self containsSpecifier:customGradientBatteryColor]) { 248 | _customGradientBatteryColor = [customGradientBatteryColor retain]; 249 | [self replaceContiguousSpecifiers:[NSArray arrayWithObjects:_customGradientBatteryColor, nil] withSpecifiers:[NSArray arrayWithObjects:_customSolidBatteryColor, nil] animated:YES]; 250 | } 251 | } else { 252 | [self insertSpecifier:_customSolidBatteryColor afterSpecifier:batteryColorSpecifier animated:animated]; 253 | } 254 | [_customSolidBatteryColor release]; 255 | _customSolidBatteryColor = nil; 256 | } else { 257 | if (batteryBarOpacity != nil && [self containsSpecifier:batteryBarOpacity]) { 258 | _batteryBarOpacity = [batteryBarOpacity retain]; 259 | [self removeSpecifier:_batteryBarOpacity animated:animated]; 260 | } 261 | if (customGradientBatteryColor != nil && [self containsSpecifier:customGradientBatteryColor]) { 262 | _customGradientBatteryColor = [customGradientBatteryColor retain]; 263 | [self removeSpecifier:_customGradientBatteryColor animated:animated]; 264 | } 265 | } 266 | [barColor setProperty:@"Set the custom solid color for the battery icon and the bar" forKey:@"footerText"]; 267 | [self reloadSpecifier:barColor animated:animated]; 268 | } else if ([batteryColorStyleValue intValue] == 2) { 269 | if (_customGradientBatteryColor != nil && ![self containsSpecifier:_customGradientBatteryColor]) { 270 | if (animated) { 271 | if (batteryBarOpacity != nil && [self containsSpecifier:batteryBarOpacity]) { 272 | _batteryBarOpacity = [batteryBarOpacity retain]; 273 | [self replaceContiguousSpecifiers:[NSArray arrayWithObjects:_batteryBarOpacity, nil] withSpecifiers:[NSArray arrayWithObjects:_customGradientBatteryColor, nil] animated:YES]; 274 | } else if (customSolidBatteryColor != nil && [self containsSpecifier:customSolidBatteryColor]) { 275 | _customSolidBatteryColor = [customSolidBatteryColor retain]; 276 | [self replaceContiguousSpecifiers:[NSArray arrayWithObjects:_customSolidBatteryColor, nil] withSpecifiers:[NSArray arrayWithObjects:_customGradientBatteryColor, nil] animated:YES]; 277 | } 278 | } else { 279 | [self insertSpecifier:_customGradientBatteryColor afterSpecifier:batteryColorSpecifier animated:animated]; 280 | } 281 | [_customGradientBatteryColor release]; 282 | _customGradientBatteryColor = nil; 283 | } else { 284 | if (batteryBarOpacity != nil && [self containsSpecifier:batteryBarOpacity]) { 285 | _batteryBarOpacity = [batteryBarOpacity retain]; 286 | [self removeSpecifier:_batteryBarOpacity animated:animated]; 287 | } 288 | if (customSolidBatteryColor != nil && [self containsSpecifier:customSolidBatteryColor]) { 289 | _customSolidBatteryColor = [customSolidBatteryColor retain]; 290 | [self removeSpecifier:_customSolidBatteryColor animated:animated]; 291 | } 292 | } 293 | [barColor setProperty:@"Set the custom gradient color for the battery icon and the bar" forKey:@"footerText"]; 294 | [self reloadSpecifier:barColor animated:animated]; 295 | } 296 | 297 | _isCurrentlyDisablingSpecifiers = NO; 298 | } 299 | 300 | @end 301 | -------------------------------------------------------------------------------- /batterybar/BBSliderCell.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | @interface PSRootController (BBPrivate) 6 | +(void)setPreferenceValue:(id)arg1 specifier:(id)arg2; 7 | @end 8 | 9 | @interface BBSliderCell : PSSliderTableCell { 10 | CGFloat minValue; 11 | CGFloat maxValue; 12 | } 13 | -(void)presentAlert; 14 | @end -------------------------------------------------------------------------------- /batterybar/BBSliderCell.m: -------------------------------------------------------------------------------- 1 | #include "BBSliderCell.h" 2 | 3 | @implementation BBSliderCell 4 | 5 | - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(id)identifier specifier:(PSSpecifier *)specifier { 6 | self = [super initWithStyle:style reuseIdentifier:identifier specifier:specifier]; 7 | if (self != nil) { 8 | CGRect frame = [self frame]; 9 | UIButton *alertButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 10 | alertButton.frame = CGRectMake(frame.size.width - 50, 0, 50, frame.size.height); 11 | alertButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin; 12 | [alertButton setTitle:@"" forState:UIControlStateNormal]; 13 | [alertButton addTarget:self action:@selector(presentAlert) forControlEvents:UIControlEventTouchUpInside]; 14 | [self addSubview:alertButton]; 15 | } 16 | return self; 17 | } 18 | 19 | - (void)presentAlert { 20 | minValue = [[self.specifier propertyForKey:@"min"] floatValue]; 21 | maxValue = [[self.specifier propertyForKey:@"max"] floatValue]; 22 | 23 | NSString *rangeString = [NSString stringWithFormat:@"Please enter a value between %.2f and %.2f", minValue, maxValue]; 24 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:self.specifier.name message:rangeString delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Enter", nil]; 25 | alert.alertViewStyle = UIAlertViewStylePlainTextInput; 26 | alert.tag = 342879; 27 | [alert show]; 28 | 29 | [[alert textFieldAtIndex:0] setDelegate:self]; 30 | [[alert textFieldAtIndex:0] resignFirstResponder]; 31 | [[alert textFieldAtIndex:0] setKeyboardType:UIKeyboardTypeDecimalPad]; 32 | [[alert textFieldAtIndex:0] becomeFirstResponder]; 33 | [alert release]; 34 | } 35 | 36 | - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { 37 | if (alertView.tag == 342879 && buttonIndex == 1) { 38 | CGFloat value = [[alertView textFieldAtIndex:0].text floatValue]; 39 | [[alertView textFieldAtIndex:0] resignFirstResponder]; 40 | 41 | if (value <= [[self.specifier propertyForKey:@"max"] floatValue] && value >= [[self.specifier propertyForKey:@"min"] floatValue]) { 42 | [self setValue:[NSNumber numberWithFloat:value]]; 43 | [PSRootController setPreferenceValue:[NSNumber numberWithFloat:value] specifier:self.specifier]; 44 | } else { 45 | UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"The value entered is not valid. Try again." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; 46 | errorAlert.tag = 85230234; 47 | [errorAlert show]; 48 | [errorAlert release]; 49 | } 50 | } else if (alertView.tag == 85230234) { 51 | [self presentAlert]; 52 | } 53 | } 54 | 55 | @end -------------------------------------------------------------------------------- /batterybar/BBSolidColorListController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface PSListController (BBSPrivate) 4 | -(void)clearCache; 5 | @end 6 | 7 | @interface BBSolidColorListController : PSListController 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /batterybar/BBSolidColorListController.m: -------------------------------------------------------------------------------- 1 | #include "BBSolidColorListController.h" 2 | 3 | @implementation BBSolidColorListController 4 | 5 | - (NSArray *)specifiers { 6 | if (!_specifiers) { 7 | _specifiers = [[self loadSpecifiersFromPlistName:@"SolidColor" target:self] retain]; 8 | } 9 | return _specifiers; 10 | } 11 | 12 | - (void)viewWillAppear:(BOOL)animated { 13 | [self clearCache]; 14 | [self reload]; 15 | [super viewWillAppear:animated]; 16 | } 17 | 18 | @end -------------------------------------------------------------------------------- /batterybar/Makefile: -------------------------------------------------------------------------------- 1 | export TARGET = iphone:clang:8.1:latest 2 | 3 | include $(THEOS)/makefiles/common.mk 4 | 5 | BUNDLE_NAME = BatteryBar 6 | BatteryBar_FILES = BBRootListController.m BBSolidColorListController.m BBGradientListController.m BBSliderCell.m 7 | BatteryBar_INSTALL_PATH = /Library/PreferenceBundles 8 | BatteryBar_FRAMEWORKS = UIKit MessageUI 9 | BatteryBar_PRIVATE_FRAMEWORKS = Preferences 10 | BatteryBar_LIBRARIES = colorpicker 11 | 12 | include $(THEOS_MAKE_PATH)/bundle.mk 13 | 14 | internal-stage:: 15 | $(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences$(ECHO_END) 16 | $(ECHO_NOTHING)cp entry.plist $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/BatteryBar.plist$(ECHO_END) 17 | -------------------------------------------------------------------------------- /batterybar/Resources/Gradient.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | items 6 | 7 | 8 | cell 9 | PSGroupCell 10 | 11 | 12 | cell 13 | PSSwitchCell 14 | id 15 | LowPowerSwitch 16 | default 17 | 18 | defaults 19 | com.dgh0st.batterybar 20 | key 21 | isGradientLowPowerEnabled 22 | label 23 | Enable Low Power Mode Color 24 | PostNotification 25 | com.dgh0st.batterybar/settingschanged 26 | 27 | 28 | cell 29 | PSLinkCell 30 | cellClass 31 | PFSimpleLiteColorCell 32 | id 33 | LowPowerColor 34 | libcolorpicker 35 | 36 | defaults 37 | com.dgh0st.batterybar.color 38 | key 39 | gradientColorLowPower 40 | fallback 41 | #FFD700 42 | PostNotification 43 | com.dgh0st.batterybar/colorchanged 44 | alpha 45 | 46 | 47 | label 48 | Low Power Mode 49 | 50 | 51 | cell 52 | PSGroupCell 53 | 54 | 55 | cell 56 | PSSwitchCell 57 | id 58 | ChargingSwitch 59 | default 60 | 61 | defaults 62 | com.dgh0st.batterybar 63 | key 64 | isGradientChargingEnabled 65 | label 66 | Enable Charging Color 67 | PostNotification 68 | com.dgh0st.batterybar/settingschanged 69 | 70 | 71 | cell 72 | PSLinkCell 73 | cellClass 74 | PFSimpleLiteColorCell 75 | id 76 | ChargingColor 77 | libcolorpicker 78 | 79 | defaults 80 | com.dgh0st.batterybar.color 81 | key 82 | gradientColorCharging 83 | fallback 84 | #00FF00 85 | PostNotification 86 | com.dgh0st.batterybar/colorchanged 87 | alpha 88 | 89 | 90 | label 91 | Charging Mode 92 | 93 | 94 | cell 95 | PSGroupCell 96 | label 97 | Gradient 98 | 99 | 100 | cell 101 | PSLinkCell 102 | cellClass 103 | PFSimpleLiteColorCell 104 | libcolorpicker 105 | 106 | defaults 107 | com.dgh0st.batterybar.color 108 | key 109 | gradientColor0 110 | fallback 111 | #FF0500 112 | PostNotification 113 | com.dgh0st.batterybar/colorchanged 114 | alpha 115 | 116 | 117 | label 118 | Battery 0% 119 | 120 | 121 | cell 122 | PSLinkCell 123 | cellClass 124 | PFSimpleLiteColorCell 125 | libcolorpicker 126 | 127 | defaults 128 | com.dgh0st.batterybar.color 129 | key 130 | gradientColor1 131 | fallback 132 | #FF1E00 133 | PostNotification 134 | com.dgh0st.batterybar/colorchanged 135 | alpha 136 | 137 | 138 | label 139 | Battery 5% 140 | 141 | 142 | cell 143 | PSLinkCell 144 | cellClass 145 | PFSimpleLiteColorCell 146 | libcolorpicker 147 | 148 | defaults 149 | com.dgh0st.batterybar.color 150 | key 151 | gradientColor2 152 | fallback 153 | #FF3700 154 | PostNotification 155 | com.dgh0st.batterybar/colorchanged 156 | alpha 157 | 158 | 159 | label 160 | Battery 10% 161 | 162 | 163 | cell 164 | PSLinkCell 165 | cellClass 166 | PFSimpleLiteColorCell 167 | libcolorpicker 168 | 169 | defaults 170 | com.dgh0st.batterybar.color 171 | key 172 | gradientColor3 173 | fallback 174 | #FF5000 175 | PostNotification 176 | com.dgh0st.batterybar/colorchanged 177 | alpha 178 | 179 | 180 | label 181 | Battery 15% 182 | 183 | 184 | cell 185 | PSLinkCell 186 | cellClass 187 | PFSimpleLiteColorCell 188 | libcolorpicker 189 | 190 | defaults 191 | com.dgh0st.batterybar.color 192 | key 193 | gradientColor4 194 | fallback 195 | #FF6900 196 | PostNotification 197 | com.dgh0st.batterybar/colorchanged 198 | alpha 199 | 200 | 201 | label 202 | Battery 20% 203 | 204 | 205 | cell 206 | PSLinkCell 207 | cellClass 208 | PFSimpleLiteColorCell 209 | libcolorpicker 210 | 211 | defaults 212 | com.dgh0st.batterybar.color 213 | key 214 | gradientColor5 215 | fallback 216 | #FF8200 217 | PostNotification 218 | com.dgh0st.batterybar/colorchanged 219 | alpha 220 | 221 | 222 | label 223 | Battery 25% 224 | 225 | 226 | cell 227 | PSLinkCell 228 | cellClass 229 | PFSimpleLiteColorCell 230 | libcolorpicker 231 | 232 | defaults 233 | com.dgh0st.batterybar.color 234 | key 235 | gradientColor6 236 | fallback 237 | #FF9B00 238 | PostNotification 239 | com.dgh0st.batterybar/colorchanged 240 | alpha 241 | 242 | 243 | label 244 | Battery 30% 245 | 246 | 247 | cell 248 | PSLinkCell 249 | cellClass 250 | PFSimpleLiteColorCell 251 | libcolorpicker 252 | 253 | defaults 254 | com.dgh0st.batterybar.color 255 | key 256 | gradientColor7 257 | fallback 258 | #FFB400 259 | PostNotification 260 | com.dgh0st.batterybar/colorchanged 261 | alpha 262 | 263 | 264 | label 265 | Battery 35% 266 | 267 | 268 | cell 269 | PSLinkCell 270 | cellClass 271 | PFSimpleLiteColorCell 272 | libcolorpicker 273 | 274 | defaults 275 | com.dgh0st.batterybar.color 276 | key 277 | gradientColor8 278 | fallback 279 | #FFCD00 280 | PostNotification 281 | com.dgh0st.batterybar/colorchanged 282 | alpha 283 | 284 | 285 | label 286 | Battery 40% 287 | 288 | 289 | cell 290 | PSLinkCell 291 | cellClass 292 | PFSimpleLiteColorCell 293 | libcolorpicker 294 | 295 | defaults 296 | com.dgh0st.batterybar.color 297 | key 298 | gradientColor9 299 | fallback 300 | #FFE600 301 | PostNotification 302 | com.dgh0st.batterybar/colorchanged 303 | alpha 304 | 305 | 306 | label 307 | Battery 45% 308 | 309 | 310 | cell 311 | PSLinkCell 312 | cellClass 313 | PFSimpleLiteColorCell 314 | libcolorpicker 315 | 316 | defaults 317 | com.dgh0st.batterybar.color 318 | key 319 | gradientColor10 320 | fallback 321 | #FFFF00 322 | PostNotification 323 | com.dgh0st.batterybar/colorchanged 324 | alpha 325 | 326 | 327 | label 328 | Battery 50% 329 | 330 | 331 | cell 332 | PSLinkCell 333 | cellClass 334 | PFSimpleLiteColorCell 335 | libcolorpicker 336 | 337 | defaults 338 | com.dgh0st.batterybar.color 339 | key 340 | gradientColor11 341 | fallback 342 | #E6FF00 343 | PostNotification 344 | com.dgh0st.batterybar/colorchanged 345 | alpha 346 | 347 | 348 | label 349 | Battery 55% 350 | 351 | 352 | cell 353 | PSLinkCell 354 | cellClass 355 | PFSimpleLiteColorCell 356 | libcolorpicker 357 | 358 | defaults 359 | com.dgh0st.batterybar.color 360 | key 361 | gradientColor12 362 | fallback 363 | #CDFF00 364 | PostNotification 365 | com.dgh0st.batterybar/colorchanged 366 | alpha 367 | 368 | 369 | label 370 | Battery 60% 371 | 372 | 373 | cell 374 | PSLinkCell 375 | cellClass 376 | PFSimpleLiteColorCell 377 | libcolorpicker 378 | 379 | defaults 380 | com.dgh0st.batterybar.color 381 | key 382 | gradientColor13 383 | fallback 384 | #B4FF00 385 | PostNotification 386 | com.dgh0st.batterybar/colorchanged 387 | alpha 388 | 389 | 390 | label 391 | Battery 65% 392 | 393 | 394 | cell 395 | PSLinkCell 396 | cellClass 397 | PFSimpleLiteColorCell 398 | libcolorpicker 399 | 400 | defaults 401 | com.dgh0st.batterybar.color 402 | key 403 | gradientColor14 404 | fallback 405 | #9BFF00 406 | PostNotification 407 | com.dgh0st.batterybar/colorchanged 408 | alpha 409 | 410 | 411 | label 412 | Battery 70% 413 | 414 | 415 | cell 416 | PSLinkCell 417 | cellClass 418 | PFSimpleLiteColorCell 419 | libcolorpicker 420 | 421 | defaults 422 | com.dgh0st.batterybar.color 423 | key 424 | gradientColor15 425 | fallback 426 | #82FF00 427 | PostNotification 428 | com.dgh0st.batterybar/colorchanged 429 | alpha 430 | 431 | 432 | label 433 | Battery 75% 434 | 435 | 436 | cell 437 | PSLinkCell 438 | cellClass 439 | PFSimpleLiteColorCell 440 | libcolorpicker 441 | 442 | defaults 443 | com.dgh0st.batterybar.color 444 | key 445 | gradientColor16 446 | fallback 447 | #69FF00 448 | PostNotification 449 | com.dgh0st.batterybar/colorchanged 450 | alpha 451 | 452 | 453 | label 454 | Battery 80% 455 | 456 | 457 | cell 458 | PSLinkCell 459 | cellClass 460 | PFSimpleLiteColorCell 461 | libcolorpicker 462 | 463 | defaults 464 | com.dgh0st.batterybar.color 465 | key 466 | gradientColor17 467 | fallback 468 | #50FF00 469 | PostNotification 470 | com.dgh0st.batterybar/colorchanged 471 | alpha 472 | 473 | 474 | label 475 | Battery 85% 476 | 477 | 478 | cell 479 | PSLinkCell 480 | cellClass 481 | PFSimpleLiteColorCell 482 | libcolorpicker 483 | 484 | defaults 485 | com.dgh0st.batterybar.color 486 | key 487 | gradientColor18 488 | fallback 489 | #37FF00 490 | PostNotification 491 | com.dgh0st.batterybar/colorchanged 492 | alpha 493 | 494 | 495 | label 496 | Battery 90% 497 | 498 | 499 | cell 500 | PSLinkCell 501 | cellClass 502 | PFSimpleLiteColorCell 503 | libcolorpicker 504 | 505 | defaults 506 | com.dgh0st.batterybar.color 507 | key 508 | gradientColor19 509 | fallback 510 | #1EFF00 511 | PostNotification 512 | com.dgh0st.batterybar/colorchanged 513 | alpha 514 | 515 | 516 | label 517 | Battery 95% 518 | 519 | 520 | cell 521 | PSLinkCell 522 | cellClass 523 | PFSimpleLiteColorCell 524 | libcolorpicker 525 | 526 | defaults 527 | com.dgh0st.batterybar.color 528 | key 529 | gradientColor20 530 | fallback 531 | #00FF00 532 | PostNotification 533 | com.dgh0st.batterybar/colorchanged 534 | alpha 535 | 536 | 537 | label 538 | Battery 100% 539 | 540 | 541 | cell 542 | PSGroupCell 543 | footerAlignment 544 | 1 545 | footerText 546 | BatteryBar © 2017 DGh0st 547 | 548 | 549 | title 550 | Gradient 551 | 552 | -------------------------------------------------------------------------------- /batterybar/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | BatteryBar 9 | CFBundleIdentifier 10 | com.dgh0st.batterybar 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1.0 21 | NSPrincipalClass 22 | BBRootListController 23 | 24 | 25 | -------------------------------------------------------------------------------- /batterybar/Resources/Root.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | items 6 | 7 | 8 | cell 9 | PSGroupCell 10 | footerText 11 | Enable/Disable the tweak (respring required for any changes) 12 | 13 | 14 | cell 15 | PSSwitchCell 16 | default 17 | 18 | defaults 19 | com.dgh0st.batterybar 20 | key 21 | isEnabled 22 | label 23 | Enable 24 | PostNotification 25 | com.dgh0st.batterybar/settingschanged 26 | 27 | 28 | cell 29 | PSGroupCell 30 | footerText 31 | Update battery bar at every percent instead of every 5 percent 32 | 33 | 34 | cell 35 | PSSwitchCell 36 | default 37 | 38 | defaults 39 | com.dgh0st.batterybar 40 | key 41 | isUseActualBatteryLevelEnabled 42 | label 43 | Actual Battery Level 44 | PostNotification 45 | com.dgh0st.batterybar/settingschanged 46 | 47 | 48 | cell 49 | PSGroupCell 50 | label 51 | Status Bar Text Color 52 | footerText 53 | Always White and Black will add a Black or White (respectively) background when needed 54 | 55 | 56 | cell 57 | PSSegmentCell 58 | id 59 | ColorStatusBar 60 | key 61 | statusBarForegroundColor 62 | validTitles 63 | 64 | Default 65 | Always White 66 | Always Black 67 | 68 | validValues 69 | 70 | 0 71 | 1 72 | 2 73 | 74 | default 75 | 0 76 | defaults 77 | com.dgh0st.batterybar 78 | PostNotification 79 | com.dgh0st.batterybar/settingschanged 80 | 81 | 82 | cell 83 | PSSwitchCell 84 | id 85 | HomescreenBackground 86 | default 87 | 88 | defaults 89 | com.dgh0st.batterybar 90 | key 91 | isHomescreenBackgroundEnabled 92 | label 93 | Enable Homescreen Background 94 | PostNotification 95 | com.dgh0st.batterybar/settingschanged 96 | 97 | 98 | cell 99 | PSGroupCell 100 | label 101 | Status Bar Item 102 | 103 | 104 | cell 105 | PSSwitchCell 106 | id 107 | HideBatteryIcon 108 | default 109 | 110 | defaults 111 | com.dgh0st.batterybar 112 | key 113 | isBatteryIconHidden 114 | label 115 | Hide Battery Icon 116 | PostNotification 117 | com.dgh0st.batterybar/settingschanged 118 | 119 | 120 | cell 121 | PSSwitchCell 122 | id 123 | HideChargingIcon 124 | default 125 | 126 | defaults 127 | com.dgh0st.batterybar 128 | key 129 | isChargingIconHidden 130 | label 131 | Hide Charging Icon 132 | PostNotification 133 | com.dgh0st.batterybar/settingschanged 134 | 135 | 136 | cell 137 | PSGroupCell 138 | id 139 | Type 140 | label 141 | Bar Type 142 | footerText 143 | Set the height of the bar 144 | 145 | 146 | cell 147 | PSSegmentCell 148 | id 149 | BarType 150 | key 151 | batteryBarType 152 | validTitles 153 | 154 | Skinny 155 | Thick 156 | Background 157 | 158 | validValues 159 | 160 | 0 161 | 1 162 | 2 163 | 164 | default 165 | 0 166 | defaults 167 | com.dgh0st.batterybar 168 | PostNotification 169 | com.dgh0st.batterybar/settingschanged 170 | 171 | 172 | cell 173 | PSSwitchCell 174 | id 175 | BottomBar 176 | default 177 | 178 | defaults 179 | com.dgh0st.batterybar 180 | key 181 | isBottomBarEnabled 182 | label 183 | Enable Bottom Bar 184 | PostNotification 185 | com.dgh0st.batterybar/settingschanged 186 | 187 | 188 | cell 189 | PSSliderCell 190 | cellClass 191 | BBSliderCell 192 | id 193 | BarHeight 194 | min 195 | 0.1 196 | max 197 | 20.0 198 | showValue 199 | 200 | default 201 | 3.0 202 | defaults 203 | com.dgh0st.batterybar 204 | key 205 | barHeight 206 | PostNotification 207 | com.dgh0st.batterybar/settingschanged 208 | 209 | 210 | cell 211 | PSGroupCell 212 | label 213 | Bar Alignment 214 | 215 | 216 | cell 217 | PSSegmentCell 218 | key 219 | batteryBarAlignment 220 | validTitles 221 | 222 | Left 223 | Center 224 | Right 225 | 226 | validValues 227 | 228 | 0 229 | 1 230 | 2 231 | 232 | default 233 | 0 234 | defaults 235 | com.dgh0st.batterybar 236 | PostNotification 237 | com.dgh0st.batterybar/settingschanged 238 | 239 | 240 | cell 241 | PSGroupCell 242 | id 243 | BarColor 244 | label 245 | Battery/Bar Color 246 | footerText 247 | Set the opacity of the batter bar 248 | 249 | 250 | cell 251 | PSSegmentCell 252 | id 253 | BatteryColor 254 | key 255 | batteryColorStyle 256 | validTitles 257 | 258 | Default 259 | Solid 260 | Gradient 261 | 262 | validValues 263 | 264 | 0 265 | 1 266 | 2 267 | 268 | default 269 | 0 270 | defaults 271 | com.dgh0st.batterybar 272 | PostNotification 273 | com.dgh0st.batterybar/settingschanged 274 | 275 | 276 | cell 277 | PSSliderCell 278 | cellClass 279 | BBSliderCell 280 | id 281 | BarOpacity 282 | min 283 | 0.1 284 | max 285 | 1.0 286 | showValue 287 | 288 | default 289 | 1.0 290 | defaults 291 | com.dgh0st.batterybar 292 | key 293 | batteryBarOpacity 294 | PostNotification 295 | com.dgh0st.batterybar/settingschanged 296 | 297 | 298 | cell 299 | PSLinkCell 300 | id 301 | CustomSolidBatteryColor 302 | label 303 | Custom Solid Color 304 | detail 305 | BBSolidColorListController 306 | isController 307 | 308 | 309 | 310 | cell 311 | PSLinkCell 312 | id 313 | CustomGradientBatteryColor 314 | label 315 | Custom Gradient Color 316 | detail 317 | BBGradientListController 318 | isController 319 | 320 | 321 | 322 | cell 323 | PSGroupCell 324 | Label 325 | Charging Animations 326 | 327 | 328 | cell 329 | PSSegmentCell 330 | key 331 | chargingAnimationStyle 332 | validTitles 333 | 334 | None 335 | Pulse 336 | Sway 337 | 338 | validValues 339 | 340 | 0 341 | 1 342 | 2 343 | 344 | default 345 | 0 346 | defaults 347 | com.dgh0st.batterybar 348 | PostNotification 349 | com.dgh0st.batterybar/settingschanged 350 | 351 | 352 | cell 353 | PSGroupCell 354 | label 355 | Credits 356 | footerText 357 | Enjoy the tweak :) 358 | 359 | 360 | cell 361 | PSButtonCell 362 | action 363 | email 364 | label 365 | Email Support 366 | 367 | 368 | cell 369 | PSButtonCell 370 | action 371 | donate 372 | label 373 | Donate 374 | 375 | 376 | cell 377 | PSButtonCell 378 | action 379 | follow 380 | label 381 | Follow on twitter (@D_Gh0st) 382 | 383 | 384 | cell 385 | PSGroupCell 386 | footerAlignment 387 | 1 388 | footerText 389 | BatteryBar © 2018 DGh0st 390 | 391 | 392 | title 393 | BatteryBar 394 | 395 | 396 | -------------------------------------------------------------------------------- /batterybar/Resources/SolidColor.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | items 6 | 7 | 8 | cell 9 | PSGroupCell 10 | 11 | 12 | cell 13 | PSLinkCell 14 | cellClass 15 | PFSimpleLiteColorCell 16 | libcolorpicker 17 | 18 | defaults 19 | com.dgh0st.batterybar.color 20 | key 21 | solidColorLowPower 22 | fallback 23 | #FFD700 24 | PostNotification 25 | com.dgh0st.batterybar/colorchanged 26 | alpha 27 | 28 | 29 | label 30 | Low Power Mode 31 | 32 | 33 | cell 34 | PSLinkCell 35 | cellClass 36 | PFSimpleLiteColorCell 37 | libcolorpicker 38 | 39 | defaults 40 | com.dgh0st.batterybar.color 41 | key 42 | solidColorCharging 43 | fallback 44 | #00FF00 45 | PostNotification 46 | com.dgh0st.batterybar/colorchanged 47 | alpha 48 | 49 | 50 | label 51 | Charging Mode 52 | 53 | 54 | cell 55 | PSLinkCell 56 | cellClass 57 | PFSimpleLiteColorCell 58 | libcolorpicker 59 | 60 | defaults 61 | com.dgh0st.batterybar.color 62 | key 63 | solidColorLessThan20 64 | fallback 65 | #FF0000 66 | PostNotification 67 | com.dgh0st.batterybar/colorchanged 68 | alpha 69 | 70 | 71 | label 72 | Battery less than 20% 73 | 74 | 75 | cell 76 | PSLinkCell 77 | cellClass 78 | PFSimpleLiteColorCell 79 | libcolorpicker 80 | 81 | defaults 82 | com.dgh0st.batterybar.color 83 | key 84 | solidColorGreaterThan20 85 | fallback 86 | #808080 87 | PostNotification 88 | com.dgh0st.batterybar/colorchanged 89 | alpha 90 | 91 | 92 | label 93 | Battery greater than 20% 94 | 95 | 96 | cell 97 | PSGroupCell 98 | footerAlignment 99 | 1 100 | footerText 101 | BatteryBar © 2017 DGh0st 102 | 103 | 104 | title 105 | Solid Colors 106 | 107 | -------------------------------------------------------------------------------- /batterybar/Resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DGh0st/BatteryBar/db605c8bb87052f6390c85351f7869e07026f8d1/batterybar/Resources/icon.png -------------------------------------------------------------------------------- /batterybar/Resources/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DGh0st/BatteryBar/db605c8bb87052f6390c85351f7869e07026f8d1/batterybar/Resources/icon@2x.png -------------------------------------------------------------------------------- /batterybar/Resources/icon@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DGh0st/BatteryBar/db605c8bb87052f6390c85351f7869e07026f8d1/batterybar/Resources/icon@3x.png -------------------------------------------------------------------------------- /batterybar/entry.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | entry 6 | 7 | bundle 8 | BatteryBar 9 | cell 10 | PSLinkCell 11 | detail 12 | BBRootListController 13 | icon 14 | icon.png 15 | isController 16 | 17 | label 18 | BatteryBar 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /control: -------------------------------------------------------------------------------- 1 | Package: com.dgh0st.batterybar 2 | Name: BatteryBar 3 | Depends: mobilesubstrate, preferenceloader, org.thebigboss.libcolorpicker 4 | Conflicts: com.skylerk99.powerbar, org.thebigboss.batterystatusbar 5 | Version: 0.0.3 6 | Architecture: iphoneos-arm 7 | Description: Display a bar that represents the battery percentage in the status bar. 8 | Maintainer: DGh0st 9 | Author: DGh0st 10 | Section: Tweaks 11 | --------------------------------------------------------------------------------