X-Git-Url: https://git.saurik.com/winterboard.git/blobdiff_plain/024f98ea589529f42b26fa62fcb5913a6aee6a57..900dc9a5d6341928f9190bb8840fdf61df65b59b:/Settings.mm diff --git a/Settings.mm b/Settings.mm index 89231a0..614a0b7 100644 --- a/Settings.mm +++ b/Settings.mm @@ -1,39 +1,23 @@ /* WinterBoard - Theme Manager for the iPhone - * Copyright (C) 2009-2010 Jay Freeman (saurik) + * Copyright (C) 2008-2014 Jay Freeman (saurik) */ +/* GNU Lesser General Public License, Version 3 {{{ */ /* - * Redistribution and use in source and binary - * forms, with or without modification, are permitted - * provided that the following conditions are met: + * WinterBoard is free software: you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. * - * 1. Redistributions of source code must retain the - * above copyright notice, this list of conditions - * and the following disclaimer. - * 2. Redistributions in binary form must reproduce the - * above copyright notice, this list of conditions - * and the following disclaimer in the documentation - * and/or other materials provided with the - * distribution. - * 3. The name of the author may not be used to endorse - * or promote products derived from this software - * without specific prior written permission. + * WinterBoard is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * You should have received a copy of the GNU Lesser General Public License + * along with WinterBoard. If not, see . +**/ +/* }}} */ #import #import @@ -51,7 +35,7 @@ static BOOL (*IsIconHiddenDisplayId)(NSString *); static BOOL (*HideIconViaDisplayId)(NSString *); static BOOL (*UnHideIconViaDisplayId)(NSString *); -static const NSString *WinterBoardDisplayID = @"com.saurik.WinterBoard"; +static NSString *WinterBoardDisplayID = @"com.saurik.WinterBoard"; extern NSString *PSTableCellKey; extern "C" UIImage *_UIImageWithName(NSString *); @@ -371,18 +355,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 +387,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 +429,29 @@ static NSString *_plist; UnHideIconViaDisplayId = reinterpret_cast(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; } @@ -494,16 +492,20 @@ static NSString *_plist; system("rm -rf /User/Library/Caches/com.apple.newsstand"); system("rm -rf /User/Library/Caches/com.apple.springboard.sharedimagecache"); - system("killall lsd SpringBoard"); + system("killall -9 lsd"); + + if (kCFCoreFoundationVersionNumber > 700) // XXX: iOS 6.x + system("killall backboardd"); + else + system("killall SpringBoard"); } - (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];