Skip to content

Commit

Permalink
broke up headers, removed unneeded new methods
Browse files Browse the repository at this point in the history
also added screenie and made things much more specific around the
codebase. unfortunately, also currently causes safe mode on respring
  • Loading branch information
insanj committed Jul 14, 2014
1 parent d36d8e2 commit c0192c3
Show file tree
Hide file tree
Showing 13 changed files with 145 additions and 146 deletions.
27 changes: 0 additions & 27 deletions CRHeaders.h
Expand Up @@ -6,33 +6,6 @@

#import "Reachability/Reachability.h"
#import "substrate.h"
#import "CRPrefsManager.h"

#define CRTITLETOCOLOR @{@"Aqua" : [UIColor colorWithRed:127.0/255.0 green:219.0/255.0 blue:255/255.0 alpha:1.0], @"Black" : [UIColor colorWithRed:17.0/255.0 green:17.0/255.0 blue:17.0/255.0 alpha:1.0], @"Black (Default)" : [UIColor colorWithRed:17.0/255.0 green:17.0/255.0 blue:17.0/255.0 alpha:1.0], @"Blue" : [UIColor colorWithRed:0.0/255.0 green:116.0/255.0 blue:217.0/255.0 alpha:1.0], @"Clear" : [UIColor clearColor], @"Fuchsia" : [UIColor colorWithRed:240.0/255.0 green:18.0/255.0 blue:190.0/255.0 alpha:1.0], @"Grey" : [UIColor colorWithRed:170.0/255.0 green:170.0/255.0 blue:170.0/255.0 alpha:1.0], @"Green" : [UIColor colorWithRed:46.0/255.0 green:204.0/255.0 blue:64.0/255.0 alpha:1.0], @"Green (Default)" : [UIColor colorWithRed:46.0/255.0 green:204.0/255.0 blue:64.0/255.0 alpha:1.0], @"Lime" : [UIColor colorWithRed:1.0/255.0 green:255.0/255.0 blue:112.0/255.0 alpha:1.0], @"Maroon" : [UIColor colorWithRed:133.0/255.0 green:20.0/255.0 blue:75.0/255.0 alpha:1.0], @"Navy" : [UIColor colorWithRed:0.0 green:31.0/255.0 blue:63.0/255.0 alpha:1.0], @"Olive" : [UIColor colorWithRed:61.0/255.0 green:153.0/255.0 blue:112.0/255.0 alpha:1.0], @"Orange" : [UIColor colorWithRed:255.0/255.0 green:133.0/255.0 blue:27.0/255.0 alpha:1.0], @"Purple" : [UIColor colorWithRed:177.0/255.0 green:13.0/255.0 blue:201.0/255.0 alpha:1.0], @"Red" : [UIColor colorWithRed:255.0/255.0 green:65.0/255.0 blue:54.0/255.0 alpha:1.0], @"Red (Default)" : [UIColor colorWithRed:255.0/255.0 green:65.0/255.0 blue:54.0/255.0 alpha:1.0], @"Silver" : [UIColor colorWithRed:221.0/255.0 green:221.0/255.0 blue:221.0/255.0 alpha:1.0], @"Teal" : [UIColor colorWithRed:57.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha:1.0], @"White" : [UIColor whiteColor], @"White (Default)" : [UIColor whiteColor], @"Yellow" : [UIColor colorWithRed:255.0/255.0 green:220.0/255.0 blue:0.0 alpha:1.0]}
/*
#define CRPATH @"/var/mobile/Library/Preferences/com.insanj.circlet.plist"
#define CRSETTINGS [NSDictionary dictionaryWithContentsOfFile:CRPATH]
#define CRVALUE(key) [[NSUserDefaults standardUserDefaults] objectForKey:key inDomain:@"com.insanj.circlet"]
#define CRLegacyVALUE(key) [[NSDictionary dictionaryWithContentsOfFile:CRPATH] objectForKey:key]
#define CRSETVALUEFORKEY(value, key) [[NSUserDefaults standardUserDefaults] setObject:value forKey:key inDomain:@"com.insanj.circlet"]
#define CRLegacySETVALUEFORKEY(value, key) NSMutableDictionary *settings = [[NSMutableDictionary alloc] initWithDictionary:CRSETTINGS]; \
[settings setObject:value forKey:key];\
[settings writeToFile:CRPATH atomically:YES]
*/
#define WIFI_CONNECTED [[Reachability reachabilityForLocalWiFi] currentReachabilityStatus] == ReachableViaWiFi

#define CRDEFAULTRADIUS 5.0
#define CRBOLTLEEWAY 7.0

#define NEWEST_IOS ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.1)
#define MODERN_IOS ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
#define IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

#ifdef DEBUG
#define CRLOG(fmt, ...) NSLog((@"[Circlet] %s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
#define CRLOG(fmt, ...)
#endif

@interface SBUIController
- (void)_deviceLockStateChanged:(NSNotification *)changed;
Expand Down
2 changes: 1 addition & 1 deletion CRPrefs/CRCells.m
Expand Up @@ -6,7 +6,7 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr
self = [super initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseIdentifier specifier:specifier];

if (self) {
NSString *rawCredits = @"Circlet (1.2.3) was created by Julian Weiss with lots of love from Benno, A³Tweaks, and the entire Hashbang crew. Uses NKOColorPickerView and UIDiscreteSlider for finer settings control. Inspired by the awesome members of /r/jailbreak. To stay updated on Circlet (and many other projects), make sure to follow me on Twitter. Enjoy!";
NSString *rawCredits = @"Circlet (1.3) was created by Julian Weiss with lots of love from Benno, A³Tweaks, and the entire Hashbang crew. Uses NKOColorPickerView and UIDiscreteSlider for finer settings control. Inspired by the awesome members of /r/jailbreak. To stay updated on Circlet (and many other projects), make sure to follow me on Twitter. Enjoy!";

if (IPAD) {
[self setTitle:rawCredits];
Expand Down
21 changes: 21 additions & 0 deletions CRPrefs/CRItemPrefsListController.m
Expand Up @@ -19,6 +19,7 @@ - (void)viewWillAppear:(BOOL)animated {

- (void)sidesReplenish {
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"CRReloadPreferences" object:nil];

UIStatusBar *statusBar = (UIStatusBar *)[[UIApplication sharedApplication] statusBar];
UIView *fakeStatusBar;

Expand Down Expand Up @@ -68,6 +69,26 @@ - (void)middleReplenish {
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"CRRefreshTime" object:nil];
}

- (void)signalReplenish {
[self sidesReplenish];
}

- (void)carrierReplenish {
[self sidesReplenish];
}

- (void)dataReplenish {
[self sidesReplenish];
}

- (void)timeReplenish {
[self middleReplenish];
}

- (void)batteryReplenish {
[self sidesReplenish];
}

- (void)tableView:(id)arg1 didSelectRowAtIndexPath:(id)arg2 {
[super tableView:arg1 didSelectRowAtIndexPath:arg2];
[arg1 deselectRowAtIndexPath:arg2 animated:YES];
Expand Down
2 changes: 1 addition & 1 deletion CRPrefs/CRListControllers.m
Expand Up @@ -141,4 +141,4 @@ - (NSArray *)lowPowerColorValues:(id)target {
return [self lowPowerColorTitles:target];
}

@end
@end
2 changes: 1 addition & 1 deletion CRPrefs/CRPrefs.h
@@ -1,4 +1,4 @@
#include "../CRHeaders.h"
#include "../Circlet.h"
#import "../UIImage+Circlet.h"
#import "../CRPrefsManager.h"

Expand Down
9 changes: 4 additions & 5 deletions CRPrefs/CRPrefsListController.xm
Expand Up @@ -53,22 +53,21 @@ void circletAnimate() {
}];
}


void circletSignal(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
circletPrepareToAnimate();
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"CRRefreshSignal" object:nil];
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"CRRefreshStatusBar" object:nil];
circletAnimate();
}

void circletCarrier(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
circletPrepareToAnimate();
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"CRRefreshCarrier" object:nil];
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"CRRefreshStatusBar" object:nil];
circletAnimate();
}

void circletData(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
circletPrepareToAnimate();
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"CRRefreshData" object:nil];
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"CRRefreshStatusBar" object:nil];
circletAnimate();
}

Expand All @@ -80,7 +79,7 @@ void circletTime(CFNotificationCenterRef center, void *observer, CFStringRef nam

void circletBattery(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
circletPrepareToAnimate();
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"CRRefreshBattery" object:nil];
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"CRRefreshStatusBar" object:nil];
circletAnimate();
}

Expand Down
2 changes: 1 addition & 1 deletion CRPrefs/NKOColorPickerView.h
Expand Up @@ -9,7 +9,7 @@
#import <UIKit/UIKit.h>
#import <Preferences/PreferencesAppController.h>
#import <Preferences/PrefsRootController.h>
#import "../CRHeaders.h"
#import "../Circlet.h"

typedef void (^NKOColorPickerDidChangeColorBlock)(UIColor *color);

Expand Down
17 changes: 12 additions & 5 deletions CRPrefsManager.xm
Expand Up @@ -16,7 +16,10 @@ static CRPrefsManager *sharedManager;
self = [super init];

if (self) {
_cachedPreferences = [[NSDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.insanj.circlet.plist"];
_cachedPreferences = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.insanj.circlet.plist"];
if (!_cachedPreferences) {
_cachedPreferences = [NSDictionary dictionary];
}

// Maybe shift to kirb's NSUserDefaults solution someday...
// [[NSUserDefaults standardUserDefaults] boolForKey:@"didRun" inDomain:@"com.insanj.circlet"];
Expand All @@ -29,16 +32,19 @@ static CRPrefsManager *sharedManager;
}

- (void)reloadPreferences {
[_cachedPreferences release];
_cachedPreferences = [[NSDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.insanj.circlet.plist"];
_cachedPreferences = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.insanj.circlet.plist"];
if (!_cachedPreferences) {
_cachedPreferences = [NSDictionary dictionary];
}
}

- (void)setObject:(NSObject *)object forKey:(NSString *)key {
NSMutableDictionary *mutablePreferences = [[NSMutableDictionary alloc] initWithDictionary:_cachedPreferences];
[mutablePreferences setObject:object forKey:key];
[mutablePreferences writeToFile:@"/var/mobile/Library/Preferences/com.insanj.circlet.plist" atomically:YES];

_cachedPreferences = mutablePreferences;
// Ensures that all active preference managers stay in sync
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"CRReloadPreferences" object:nil];
}

- (NSObject *)objectForKey:(NSString *)key {
Expand All @@ -64,7 +70,8 @@ static CRPrefsManager *sharedManager;
- (void)dealloc {
[[NSDistributedNotificationCenter defaultCenter] removeObserver:self name:@"CRReloadPreferences" object:nil];
[_cachedPreferences release];

[super dealloc];
}

@end
@end
44 changes: 44 additions & 0 deletions Circlet.h
@@ -0,0 +1,44 @@
#import "CRHeaders.h"

#ifdef DEBUG
#define CRLOG(fmt, ...) NSLog((@"[Circlet] %s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
#define CRLOG(fmt, ...)
#endif

#define CRTITLETOCOLOR @{@"Aqua" : [UIColor colorWithRed:127.0/255.0 green:219.0/255.0 blue:255/255.0 alpha:1.0], @"Black" : [UIColor colorWithRed:17.0/255.0 green:17.0/255.0 blue:17.0/255.0 alpha:1.0], @"Black (Default)" : [UIColor colorWithRed:17.0/255.0 green:17.0/255.0 blue:17.0/255.0 alpha:1.0], @"Blue" : [UIColor colorWithRed:0.0/255.0 green:116.0/255.0 blue:217.0/255.0 alpha:1.0], @"Clear" : [UIColor clearColor], @"Fuchsia" : [UIColor colorWithRed:240.0/255.0 green:18.0/255.0 blue:190.0/255.0 alpha:1.0], @"Grey" : [UIColor colorWithRed:170.0/255.0 green:170.0/255.0 blue:170.0/255.0 alpha:1.0], @"Green" : [UIColor colorWithRed:46.0/255.0 green:204.0/255.0 blue:64.0/255.0 alpha:1.0], @"Green (Default)" : [UIColor colorWithRed:46.0/255.0 green:204.0/255.0 blue:64.0/255.0 alpha:1.0], @"Lime" : [UIColor colorWithRed:1.0/255.0 green:255.0/255.0 blue:112.0/255.0 alpha:1.0], @"Maroon" : [UIColor colorWithRed:133.0/255.0 green:20.0/255.0 blue:75.0/255.0 alpha:1.0], @"Navy" : [UIColor colorWithRed:0.0 green:31.0/255.0 blue:63.0/255.0 alpha:1.0], @"Olive" : [UIColor colorWithRed:61.0/255.0 green:153.0/255.0 blue:112.0/255.0 alpha:1.0], @"Orange" : [UIColor colorWithRed:255.0/255.0 green:133.0/255.0 blue:27.0/255.0 alpha:1.0], @"Purple" : [UIColor colorWithRed:177.0/255.0 green:13.0/255.0 blue:201.0/255.0 alpha:1.0], @"Red" : [UIColor colorWithRed:255.0/255.0 green:65.0/255.0 blue:54.0/255.0 alpha:1.0], @"Red (Default)" : [UIColor colorWithRed:255.0/255.0 green:65.0/255.0 blue:54.0/255.0 alpha:1.0], @"Silver" : [UIColor colorWithRed:221.0/255.0 green:221.0/255.0 blue:221.0/255.0 alpha:1.0], @"Teal" : [UIColor colorWithRed:57.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha:1.0], @"White" : [UIColor whiteColor], @"White (Default)" : [UIColor whiteColor], @"Yellow" : [UIColor colorWithRed:255.0/255.0 green:220.0/255.0 blue:0.0 alpha:1.0]}
#define WIFI_CONNECTED [[Reachability reachabilityForLocalWiFi] currentReachabilityStatus] == ReachableViaWiFi
#define MODERN_IOS ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
#define IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

// Tiny algorithm to cheat the Textual style of some of its overbearing outline thickness
#define LESSENED_THICKNESS(sty) ((sty == CircletStyleTextual || sty == CircletStyleTextualInverse) ? 1.0 / 8.0 : 0.0);

#define CRDEFAULTRADIUS 5.0
#define CRBOLTLEEWAY 7.0

typedef NS_ENUM(NSUInteger, CircletPosition) {
CircletPositionSignal = 0,
CircletPositionWifi,
CircletPositionData,
CircletPositionTimeMinute,
CircletPositionTimeHour,
CircletPositionBattery,
CircletPositionCharging,
CircletPositionLowBattery,
};


@interface UIStatusBarItemView (Circlet)

- (UIImage *)circletContentsImageForWhite:(BOOL)white;
- (UIImage *)circletContentsImageForWhite:(BOOL)white string:(NSString *)timeString;

@end

@interface CRAlertViewDelegate : NSObject <UIAlertViewDelegate>

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;

@end

0 comments on commit c0192c3

Please sign in to comment.