]> git.saurik.com Git - winterboard.git/blobdiff - Settings.mm
Automatically detect text color in WB style machine.
[winterboard.git] / Settings.mm
index 89231a0fe229e313c61390ee326b213f8bcc6ee7..6ba7b41261dd53e5cc8a657c764377f92661196a 100644 (file)
@@ -371,18 +371,17 @@ static NSString *_plist;
 }
 
 - (void) optimizeThemes {
-    UIActionSheet *sheet([[[UIActionSheet alloc]
+    UIAlertView *alert([[[UIAlertView alloc]
         initWithTitle:@"Optimize Themes"
-        buttons:[NSArray arrayWithObjects:@"Optimize", @"Cancel", nil]
-        defaultButtonIndex:1
+        message:@"Please note that this setting /replaces/ the PNG files that came with the theme. PNG files that have been iPhone-optimized cannot be viewed on a normal computer unless they are first deoptimized. You can use Cydia to reinstall themes that have been optimized in order to revert to the original PNG files."
         delegate:self
-        context:@"optimize"
+        cancelButtonTitle:@"Cancel"
+        otherButtonTitles:@"Optimize", nil
     ] autorelease]);
 
-    [sheet setBodyText:@"Please note that this setting /replaces/ the PNG files that came with the theme. PNG files that have been iPhone-optimized cannot be viewed on a normal computer unless they are first deoptimized. You can use Cydia to reinstall themes that have been optimized in order to revert to the original PNG files."];
-    [sheet setNumberOfRows:1];
-    [sheet setDestructiveButtonIndex:0];
-    [sheet popupAlertAnimated:YES];
+    [alert setContext:@"optimize"];
+    [alert setNumberOfRows:1];
+    [alert show];
 }
 
 - (void) _optimizeThemes {
@@ -404,20 +403,18 @@ static NSString *_plist;
     [self settingsChanged];
 }
 
-- (void) alertSheet:(UIActionSheet *)sheet buttonClicked:(int)button {
-    NSString *context([sheet context]);
+- (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)button {
+    NSString *context([alert context]);
 
     if ([context isEqualToString:@"optimize"]) {
-        switch (button) {
-            case 1:
-                [self performSelector:@selector(_optimizeThemes) withObject:nil afterDelay:0];
-            break;
+        if (button == [alert firstOtherButtonIndex]) {
+            [self performSelector:@selector(_optimizeThemes) withObject:nil afterDelay:0];
         }
 
-        [sheet dismiss];
-    } else
-        [super alertSheet:sheet buttonClicked:button];
-
+        [alert dismissWithClickedButtonIndex:-1 animated:YES];
+    }
+    /*else if ([super respondsToSelector:@selector(alertView:clickedButtonAtIndex:)])
+        [super alertView:alert clickedButtonAtIndex:button];*/
 }
 
 @end
@@ -448,12 +445,29 @@ static NSString *_plist;
     UnHideIconViaDisplayId = reinterpret_cast<BOOL (*)(NSString *)>(dlsym(libhide, "UnHideIconViaDisplayId"));
 }
 
+- (void) _wb$loadSettings {
+    _plist = [[NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.WinterBoard.plist", NSHomeDirectory()] retain];
+    _settings = [NSMutableDictionary dictionaryWithContentsOfFile:_plist];
+
+    bool set;
+    if (_settings != nil)
+        set = true;
+    else {
+        set = false;
+        _settings = [NSMutableDictionary dictionary];
+    }
+
+    _settings = [_settings retain];
+
+    if ([_settings objectForKey:@"SummerBoard"] == nil)
+        [_settings setObject:[NSNumber numberWithBool:set] forKey:@"SummerBoard"];
+
+    [_settings setObject:[NSNumber numberWithBool:IsIconHiddenDisplayId(WinterBoardDisplayID)] forKey:@"IconHidden"];
+}
+
 - (id) initForContentSize:(CGSize)size {
     if ((self = [super initForContentSize:size]) != nil) {
-        _plist = [[NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.WinterBoard.plist", NSHomeDirectory()] retain];
-        _settings = [([NSMutableDictionary dictionaryWithContentsOfFile:_plist] ?: [NSMutableDictionary dictionary]) retain];
-
-        [_settings setObject:[NSNumber numberWithBool:IsIconHiddenDisplayId(WinterBoardDisplayID)] forKey:@"IconHidden"];
+        [self _wb$loadSettings];
     } return self;
 }
 
@@ -500,10 +514,9 @@ static NSString *_plist;
 - (void) cancelChanges {
     [_settings release];
     [_plist release];
-    _plist = [[NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.WinterBoard.plist", NSHomeDirectory()] retain];
-    _settings = [([NSMutableDictionary dictionaryWithContentsOfFile:_plist] ?: [NSMutableDictionary dictionary]) retain];
 
-    [_settings setObject:[NSNumber numberWithBool:IsIconHiddenDisplayId(WinterBoardDisplayID)] forKey:@"IconHidden"];
+    [self _wb$loadSettings];
+
     [self reloadSpecifiers];
     if (![[PSViewController class] instancesRespondToSelector:@selector(showLeftButton:withStyle:rightButton:withStyle:)]) {
         [[self navigationItem] setLeftBarButtonItem:nil];