X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/3c83edeec2fcc5eac8847a3fe996b18de7e2a72e..766b71dd4f1e125f68905d928c6735f2346cb5ea:/Cydia.mm diff --git a/Cydia.mm b/Cydia.mm index 01258df4..f42afe3e 100644 --- a/Cydia.mm +++ b/Cydia.mm @@ -342,6 +342,18 @@ static _finline NSString *CydiaURL(NSString *path) { } return self; } +- (void)_updateFrameForDisplay { + [super _updateFrameForDisplay]; + if ([self cancelButtonIndex] == -1) { + NSArray *buttons = [self buttons]; + if ([buttons count]) { + UIImage *background = [[buttons objectAtIndex:0] backgroundForState:0]; + for (UIThreePartButton *button in buttons) + [button setBackground:background forState:0]; + } + } +} + - (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { button_ = buttonIndex + 1; } @@ -351,11 +363,9 @@ static _finline NSString *CydiaURL(NSString *path) { } - (int) yieldToPopupAlertAnimated:(BOOL)animated { + [self setRunsModal:YES]; button_ = 0; [self show]; - NSRunLoop *loop([NSRunLoop currentRunLoop]); - NSDate *future([NSDate distantFuture]); - while (button_ == 0 && [loop runMode:NSDefaultRunLoopMode beforeDate:future]); return button_; } @@ -1221,10 +1231,10 @@ bool isSectionVisible(NSString *section) { - (void) setConfigurationData:(NSString *)data; @end -@class PackageView; +@class PackageController; @protocol CydiaDelegate -- (void) setPackageView:(PackageView *)view; +- (void) setPackageController:(PackageController *)view; - (void) clearPackage:(Package *)package; - (void) installPackage:(Package *)package; - (void) installPackages:(NSArray *)packages; @@ -1236,7 +1246,7 @@ bool isSectionVisible(NSString *section) { - (UIProgressHUD *) addProgressHUD; - (void) removeProgressHUD:(UIProgressHUD *)hud; - (UIViewController *) pageForPackage:(NSString *)name; -- (PackageView *) packageView; +- (PackageController *) packageController; @end /* }}} */ @@ -3616,7 +3626,7 @@ static NSString *Warning_; @end /* }}} */ -/* Confirmation View {{{ */ +/* Confirmation Controller {{{ */ bool DepSubstrate(const pkgCache::VerIterator &iterator) { if (!iterator.end()) for (pkgCache::DepIterator dep(iterator.DependsList()); !dep.end(); ++dep) { @@ -3889,7 +3899,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @end /* }}} */ -@interface CYBrowserController : BrowserView { +@interface CYBrowserController : BrowserController { CydiaObject *cydia_; } @@ -3979,13 +3989,13 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @end -@protocol ConfirmationViewDelegate +@protocol ConfirmationControllerDelegate - (void) cancelAndClear:(bool)clear; - (void) confirmWithNavigationController:(UINavigationController *)navigation; - (void) queue; @end -@interface ConfirmationView : CYBrowserController { +@interface ConfirmationController : CYBrowserController { _transient Database *database_; UIAlertView *essential_; NSArray *changes_; @@ -3998,7 +4008,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @end -@implementation ConfirmationView +@implementation ConfirmationController - (void) dealloc { [changes_ release]; @@ -4152,7 +4162,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } return self; } -- (void) didFinishLoading { +- (void) applyRightButton { UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithTitle:UCLocalize("CONFIRM") style:UIBarButtonItemStylePlain @@ -4160,8 +4170,10 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { action:@selector(confirmButtonClicked) ]; #if !AlwaysReload && !IgnoreInstall - if (issues_ == nil) [[self navigationItem] setRightBarButtonItem:rightItem]; - else [[self navigationItem] setRightBarButtonItem:nil]; + if (issues_ == nil && ![self isLoading]) [[self navigationItem] setRightBarButtonItem:rightItem]; + else [super applyRightButton]; +#else + [[self navigationItem] setRightBarButtonItem:nil]; #endif [rightItem release]; } @@ -4239,8 +4251,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @end /* }}} */ -/* Progress View {{{ */ -@interface ProgressView : CYViewController < +/* Progress Controller {{{ */ +@interface ProgressController : CYViewController < ConfigurationDelegate, ProgressDelegate > { @@ -4265,11 +4277,11 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @end -@protocol ProgressViewDelegate -- (void) progressViewIsComplete:(ProgressView *)sender; +@protocol ProgressControllerDelegate +- (void) progressControllerIsComplete:(ProgressController *)sender; @end -@implementation ProgressView +@implementation ProgressController - (void) dealloc { [database_ setDelegate:nil]; @@ -4420,7 +4432,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [status_ removeFromSuperview]; [database_ popErrorWithTitle:title_]; - [delegate_ progressViewIsComplete:self]; + [delegate_ progressControllerIsComplete:self]; if (Finish_ < 4) { FileFd file; @@ -5140,8 +5152,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @end /* }}} */ -/* Package View {{{ */ -@interface PackageView : CYBrowserController { +/* Package Controller {{{ */ +@interface PackageController : CYBrowserController { _transient Database *database_; Package *package_; NSString *name_; @@ -5154,7 +5166,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @end -@implementation PackageView +@implementation PackageController - (void) dealloc { if (package_ != nil) @@ -5167,7 +5179,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { - (void) release { if ([self retainCount] == 1) - [delegate_ setPackageView:self]; + [delegate_ setPackageController:self]; [super release]; } @@ -5246,11 +5258,18 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } - (void) actionButtonClicked { - if (commercial_ && [self isLoading]) - [super _rightButtonClicked]; - else + // Wait until it's done loading. + if (![self isLoading]) [self _actionButtonClicked]; } + +- (void) reloadButtonClicked { + // Don't reload a package view by clicking the button. +} + +- (void) applyLoadingTitle { + // Don't show "Loading" as the title. Ever. +} #endif - (id) initWithDatabase:(Database *)database { @@ -5318,7 +5337,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } } -- (void) didFinishLoading { +- (void) applyRightButton { int count = [buttons_ count]; UIBarButtonItem *actionItem = [[UIBarButtonItem alloc] initWithTitle:count == 0 ? nil : count != 1 ? UCLocalize("MODIFY") : [buttons_ objectAtIndex:0] @@ -5326,7 +5345,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { target:self action:@selector(actionButtonClicked) ]; - [[self navigationItem] setRightBarButtonItem:actionItem]; + if (![self isLoading]) [[self navigationItem] setRightBarButtonItem:actionItem]; + else [super applyRightButton]; [actionItem release]; } @@ -5592,8 +5612,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @end /* }}} */ -/* Filtered Package View {{{ */ -@interface FilteredPackageView : CYViewController { +/* Filtered Package Controller {{{ */ +@interface FilteredPackageController : CYViewController { _transient Database *database_; FilteredPackageTable *packages_; NSString *title_; @@ -5603,7 +5623,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @end -@implementation FilteredPackageView +@implementation FilteredPackageController - (void) dealloc { [packages_ release]; @@ -5618,7 +5638,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } - (void) didSelectPackage:(Package *)package { - PackageView *view([delegate_ packageView]); + PackageController *view([delegate_ packageController]); [view setPackage:package]; [view setDelegate:delegate_]; [[self navigationController] pushViewController:view animated:YES]; @@ -5659,8 +5679,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { /* }}} */ -/* Add Source View {{{ */ -@interface AddSourceView : CYViewController { +/* Add Source Controller {{{ */ +@interface AddSourceController : CYViewController { _transient Database *database_; } @@ -5668,7 +5688,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @end -@implementation AddSourceView +@implementation AddSourceController - (id) initWithDatabase:(Database *)database { if ((self = [super init]) != nil) { @@ -5886,7 +5906,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { - (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { Source *source = [self sourceAtIndexPath:indexPath]; - FilteredPackageView *packages = [[[FilteredPackageView alloc] + FilteredPackageController *packages = [[[FilteredPackageController alloc] initWithDatabase:database_ title:[source label] filter:@selector(isVisibleInSource:) @@ -6155,7 +6175,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } - (void) addButtonClicked { - /*[book_ pushPage:[[[AddSourceView alloc] + /*[book_ pushPage:[[[AddSourceController alloc] initWithBook:book_ database:database_ ] autorelease]];*/ @@ -6213,8 +6233,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @end /* }}} */ -/* Installed View {{{ */ -@interface InstalledView : FilteredPackageView { +/* Installed Controller {{{ */ +@interface InstalledController : FilteredPackageController { BOOL expert_; } @@ -6222,7 +6242,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @end -@implementation InstalledView +@implementation InstalledController - (void) dealloc { [super dealloc]; @@ -6290,13 +6310,13 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @end /* }}} */ -/* Home View {{{ */ -@interface HomeView : CYBrowserController { +/* Home Controller {{{ */ +@interface HomeController : CYBrowserController { } @end -@implementation HomeView +@implementation HomeController - (void) _setMoreHeaders:(NSMutableURLRequest *)request { [super _setMoreHeaders:request]; @@ -6347,13 +6367,13 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @end /* }}} */ -/* Manage View {{{ */ -@interface ManageView : CYBrowserController { +/* Manage Controller {{{ */ +@interface ManageController : CYBrowserController { } @end -@implementation ManageView +@implementation ManageController - (id) init { if ((self = [super init]) != nil) { @@ -6424,6 +6444,38 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { @implementation RefreshBar +- (void) positionViews { + CGRect frame = [cancel_ frame]; + frame.origin.x = [self frame].size.width - frame.size.width - 5; + frame.origin.y = ([self frame].size.height - frame.size.height) / 2; + [cancel_ setFrame:frame]; + + CGSize prgsize = {75, 100}; + CGRect prgrect = {{ + [self frame].size.width - prgsize.width - 10, + ([self frame].size.height - prgsize.height) / 2 + } , prgsize}; + [progress_ setFrame:prgrect]; + + CGSize indsize([UIProgressIndicator defaultSizeForStyle:[indicator_ activityIndicatorViewStyle]]); + unsigned indoffset = ([self frame].size.height - indsize.height) / 2; + CGRect indrect = {{indoffset, indoffset}, indsize}; + [indicator_ setFrame:indrect]; + + CGSize prmsize = {215, indsize.height + 4}; + CGRect prmrect = {{ + indoffset * 2 + indsize.width, + unsigned([self frame].size.height - prmsize.height) / 2 - 1 + }, prmsize}; + [prompt_ setFrame:prmrect]; +} + +- (void)setFrame:(CGRect)frame { + [super setFrame:frame]; + + [self positionViews]; +} + - (id) initWithFrame:(CGRect)frame delegate:(id)delegate { if ((self = [super initWithFrame:frame])) { [self setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; @@ -6438,57 +6490,28 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { UIProgressIndicatorStyleMediumBrown : UIProgressIndicatorStyleMediumWhite; - CGSize indsize([UIProgressIndicator defaultSizeForStyle:style]); - unsigned indoffset = ([self frame].size.height - indsize.height) / 2; - CGRect indrect = {{indoffset, indoffset}, indsize}; - - indicator_ = [[UIProgressIndicator alloc] initWithFrame:indrect]; + indicator_ = [[UIProgressIndicator alloc] initWithFrame:CGRectZero]; [indicator_ setStyle:style]; + [indicator_ startAnimation]; [self addSubview:indicator_]; - CGSize prmsize = {215, indsize.height + 4}; - - CGRect prmrect = {{ - indoffset * 2 + indsize.width, - unsigned([self frame].size.height - prmsize.height) / 2 - 1 - }, prmsize}; - - UIFont *font([UIFont systemFontOfSize:15]); - - prompt_ = [[UITextLabel alloc] initWithFrame:prmrect]; - + prompt_ = [[UITextLabel alloc] initWithFrame:CGRectZero]; [prompt_ setColor:[UIColor colorWithCGColor:(ugly ? Blueish_ : Off_)]]; [prompt_ setBackgroundColor:[UIColor clearColor]]; - [prompt_ setFont:font]; - + [prompt_ setFont:[UIFont systemFontOfSize:15]]; [self addSubview:prompt_]; - CGSize prgsize = {75, 100}; - - CGRect prgrect = {{ - [self frame].size.width - prgsize.width - 10, - ([self frame].size.height - prgsize.height) / 2 - } , prgsize}; - - progress_ = [[UIProgressBar alloc] initWithFrame:prgrect]; - [progress_ setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; - [self addSubview:progress_]; - + progress_ = [[UIProgressBar alloc] initWithFrame:CGRectZero]; + [progress_ setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin]; [progress_ setStyle:0]; - + [self addSubview:progress_]; + cancel_ = [[UINavigationButton alloc] initWithTitle:UCLocalize("CANCEL") style:UINavigationButtonStyleHighlighted]; - [progress_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin]; [cancel_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin]; [cancel_ addTarget:delegate action:@selector(cancelPressed) forControlEvents:UIControlEventTouchUpInside]; - - CGRect frame = [cancel_ frame]; - frame.origin.x = [self frame].size.width - frame.size.width - 5; - frame.origin.y = ([self frame].size.height - frame.size.height) / 2; - [cancel_ setFrame:frame]; - - [cancel_ setBarStyle:barstyle]; - - [indicator_ startAnimation]; + [cancel_ setBarStyle:barstyle]; + + [self positionViews]; } return self; } @@ -6696,8 +6719,8 @@ freeing the view controllers on tab change */ @end /* }}} */ -/* Sections View {{{ */ -@interface SectionsView : CYViewController { +/* Sections Controller {{{ */ +@interface SectionsController : CYViewController { _transient Database *database_; NSMutableArray *sections_; NSMutableArray *filtered_; @@ -6712,7 +6735,7 @@ freeing the view controllers on tab change */ @end -@implementation SectionsView +@implementation SectionsController - (void) dealloc { [list_ setDataSource:nil]; @@ -6772,7 +6795,7 @@ freeing the view controllers on tab change */ } } - FilteredPackageView *table = [[[FilteredPackageView alloc] + FilteredPackageController *table = [[[FilteredPackageController alloc] initWithDatabase:database_ title:title filter:@selector(isVisibleInSection:) @@ -6895,7 +6918,7 @@ freeing the view controllers on tab change */ target:self action:@selector(editButtonClicked) ]; - [[self navigationItem] setRightBarButtonItem:rightItem]; + [[self navigationItem] setRightBarButtonItem:rightItem animated:[[self navigationItem] rightBarButtonItem] != nil]; [rightItem release]; [list_ reloadData]; @@ -6924,13 +6947,14 @@ freeing the view controllers on tab change */ @end /* }}} */ -/* Changes View {{{ */ -@interface ChangesView : CYViewController { +/* Changes Controller {{{ */ +@interface ChangesController : CYViewController { _transient Database *database_; NSMutableArray *packages_; NSMutableArray *sections_; UITableView *list_; unsigned upgrades_; + BOOL hasSentFirstLoad_; } - (id) initWithDatabase:(Database *)database delegate:(id)delegate; @@ -6938,7 +6962,7 @@ freeing the view controllers on tab change */ @end -@implementation ChangesView +@implementation ChangesController - (void) dealloc { [list_ setDelegate:nil]; @@ -6952,7 +6976,12 @@ freeing the view controllers on tab change */ - (void) viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; - [list_ deselectRowAtIndexPath:[list_ indexPathForSelectedRow] animated:animated]; + if (!hasSentFirstLoad_) { + hasSentFirstLoad_ = YES; + [self performSelector:@selector(reloadData) withObject:nil afterDelay:0.0]; + } else { + [list_ deselectRowAtIndexPath:[list_ indexPathForSelectedRow] animated:animated]; + } } - (NSInteger) numberOfSectionsInTableView:(UITableView *)list { @@ -6993,7 +7022,7 @@ freeing the view controllers on tab change */ - (NSIndexPath *) tableView:(UITableView *)table willSelectRowAtIndexPath:(NSIndexPath *)path { Package *package([self packageAtIndexPath:path]); - PackageView *view([delegate_ packageView]); + PackageController *view([delegate_ packageController]); [view setDelegate:delegate_]; [view setPackage:package]; [[self navigationController] pushViewController:view animated:YES]; @@ -7027,7 +7056,6 @@ freeing the view controllers on tab change */ [list_ setDelegate:self]; delegate_ = delegate; - [self reloadData]; } return self; } @@ -7077,7 +7105,7 @@ freeing the view controllers on tab change */ unseens = true; NSDate *seen; - _profile(ChangesView$reloadData$Remember) + _profile(ChangesController$reloadData$Remember) seen = [package seen]; _end @@ -7092,7 +7120,7 @@ freeing the view controllers on tab change */ [name autorelease]; } - _profile(ChangesView$reloadData$Allocate) + _profile(ChangesController$reloadData$Allocate) name = [NSString stringWithFormat:UCLocalize("NEW_AT"), name]; section = [[[Section alloc] initWithName:name row:offset localize:NO] autorelease]; [sections_ addObject:section]; @@ -7146,8 +7174,8 @@ freeing the view controllers on tab change */ @end /* }}} */ -/* Search View {{{ */ -@interface SearchView : FilteredPackageView { +/* Search Controller {{{ */ +@interface SearchController : FilteredPackageController { id search_; } @@ -7156,7 +7184,7 @@ freeing the view controllers on tab change */ @end -@implementation SearchView +@implementation SearchController - (void) dealloc { [search_ release]; @@ -7177,31 +7205,43 @@ freeing the view controllers on tab change */ - (id) title { return nil; } - (id) initWithDatabase:(Database *)database { - if ((self = [super initWithDatabase:database title:UCLocalize("SEARCH") filter:@selector(isUnfilteredAndSearchedForBy:) with:nil]) != nil) { - search_ = [[objc_getClass("UISearchBar") alloc] initWithFrame:CGRectMake(0, 0, [[self view] frame].size.width, 44.0f)]; + return [super initWithDatabase:database title:UCLocalize("SEARCH") filter:@selector(isUnfilteredAndSearchedForBy:) with:nil]; +} + +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + if (!search_) { + search_ = [[objc_getClass("UISearchBar") alloc] initWithFrame:CGRectMake(0, 0, [[self view] bounds].size.width, 44.0f)]; + [search_ layoutSubviews]; [search_ setPlaceholder:UCLocalize("SEARCH_EX")]; - [search_ setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight]; + UITextField *textField = [search_ searchField]; + [textField setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin]; [search_ setDelegate:self]; - [[search_ searchField] setEnablesReturnKeyAutomatically:NO]; - [[self navigationItem] setTitleView:search_]; - } return self; + [textField setEnablesReturnKeyAutomatically:NO]; + [[self navigationItem] setTitleView:textField]; + } } - (void) _reloadData { } - (void) reloadData { - _profile(SearchView$reloadData) + _profile(SearchController$reloadData) [packages_ reloadData]; _end PrintTimes(); [packages_ resetCursor]; } +- (void) didSelectPackage:(Package *)package { + [search_ resignFirstResponder]; + [super didSelectPackage:package]; +} + @end /* }}} */ -/* Settings View {{{ */ -@interface SettingsView : CYViewController { +/* Settings Controller {{{ */ +@interface SettingsController : CYViewController { _transient Database *database_; NSString *name_; Package *package_; @@ -7216,7 +7256,7 @@ freeing the view controllers on tab change */ @end -@implementation SettingsView +@implementation SettingsController - (void) dealloc { [table_ setDataSource:nil]; @@ -7389,8 +7429,8 @@ freeing the view controllers on tab change */ @end /* }}} */ -/* Signature View {{{ */ -@interface SignatureView : CYBrowserController { +/* Signature Controller {{{ */ +@interface SignatureController : CYBrowserController { _transient Database *database_; NSString *package_; } @@ -7399,7 +7439,7 @@ freeing the view controllers on tab change */ @end -@implementation SignatureView +@implementation SignatureController - (void) dealloc { [package_ release]; @@ -7582,8 +7622,8 @@ freeing the view controllers on tab change */ if (animated) [UIView beginAnimations:nil context:NULL]; CGRect barframe = [refreshbar_ frame]; CGRect viewframe = [[root_ view] frame]; - viewframe.origin.y += barframe.size.height; - viewframe.size.height -= barframe.size.height; + viewframe.origin.y += barframe.size.height + 20.0f; + viewframe.size.height -= barframe.size.height + 20.0f; [[root_ view] setFrame:viewframe]; if (animated) [UIView commitAnimations]; @@ -7604,8 +7644,8 @@ freeing the view controllers on tab change */ if (animated) [UIView beginAnimations:nil context:NULL]; CGRect barframe = [refreshbar_ frame]; CGRect viewframe = [[root_ view] frame]; - viewframe.origin.y -= barframe.size.height; - viewframe.size.height += barframe.size.height; + viewframe.origin.y -= barframe.size.height + 20.0f; + viewframe.size.height += barframe.size.height + 20.0f; [[root_ view] setFrame:viewframe]; if (animated) [UIView commitAnimations]; @@ -7613,6 +7653,12 @@ freeing the view controllers on tab change */ [[root_ selectedViewController] _updateLayoutForStatusBarAndInterfaceOrientation]; } +- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration +{ + // XXX: fix Apple's layout bug + [[root_ selectedViewController] _updateLayoutForStatusBarAndInterfaceOrientation]; +} + - (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { if (dropped_) { [self raiseBar:NO]; @@ -7621,11 +7667,6 @@ freeing the view controllers on tab change */ // XXX: fix Apple's layout bug [[root_ selectedViewController] _updateLayoutForStatusBarAndInterfaceOrientation]; - - // Resize refresh bar to fit the new size - CGRect barframe = [refreshbar_ frame]; - barframe.size.width = [[self view] frame].size.width; - [refreshbar_ setFrame:barframe]; } - (void) dealloc { @@ -7657,8 +7698,8 @@ typedef enum { } CYTabTag; @interface Cydia : UIApplication < - ConfirmationViewDelegate, - ProgressViewDelegate, + ConfirmationControllerDelegate, + ProgressControllerDelegate, CydiaDelegate > { UIWindow *window_; @@ -7676,12 +7717,12 @@ typedef enum { UIKeyboard *keyboard_; UIProgressHUD *hud_; - SectionsView *sections_; - ChangesView *changes_; - ManageView *manage_; - SearchView *search_; + SectionsController *sections_; + ChangesController *changes_; + ManageController *manage_; + SearchController *search_; SourceTable *sources_; - InstalledView *installed_; + InstalledController *installed_; id queueDelegate_; #if RecyclePackageViews @@ -7697,7 +7738,7 @@ typedef enum { @end static _finline void _setHomePage(Cydia *self) { - [self setPage:[self _pageForURL:[NSURL URLWithString:CydiaURL(@"")] withClass:[HomeView class]]]; + [self setPage:[self _pageForURL:[NSURL URLWithString:CydiaURL(@"")] withClass:[HomeController class]]]; } @implementation Cydia @@ -7894,7 +7935,7 @@ static _finline void _setHomePage(Cydia *self) { [self _saveConfig]; - ProgressView *progress = [[[ProgressView alloc] initWithDatabase:database_ delegate:self] autorelease]; + ProgressController *progress = [[[ProgressController alloc] initWithDatabase:database_ delegate:self] autorelease]; UINavigationController *navigation = [[[CYNavigationController alloc] initWithRootViewController:progress] autorelease]; if (IsWildcat_) [navigation setModalPresentationStyle:UIModalPresentationFormSheet]; [container_ presentModalViewController:navigation animated:YES]; @@ -7929,7 +7970,7 @@ static _finline void _setHomePage(Cydia *self) { if (![database_ prepare]) return false; - ConfirmationView *page([[[ConfirmationView alloc] initWithDatabase:database_] autorelease]); + ConfirmationController *page([[[ConfirmationController alloc] initWithDatabase:database_] autorelease]); [page setDelegate:self]; id confirm_ = [[CYNavigationController alloc] initWithRootViewController:page]; [confirm_ setDelegate:self]; @@ -7994,7 +8035,7 @@ static _finline void _setHomePage(Cydia *self) { } - (void) confirmWithNavigationController:(UINavigationController *)navigation { - ProgressView *progress = [[[ProgressView alloc] initWithDatabase:database_ delegate:self] autorelease]; + ProgressController *progress = [[[ProgressController alloc] initWithDatabase:database_ delegate:self] autorelease]; if (navigation != nil) { [navigation pushViewController:progress animated:YES]; @@ -8012,7 +8053,7 @@ static _finline void _setHomePage(Cydia *self) { ]; } -- (void) progressViewIsComplete:(ProgressView *)progress { +- (void) progressControllerIsComplete:(ProgressController *)progress { [self complete]; } @@ -8032,44 +8073,44 @@ static _finline void _setHomePage(Cydia *self) { return browser; } -- (SectionsView *) sectionsView { +- (SectionsController *) sectionsController { if (sections_ == nil) - sections_ = [[SectionsView alloc] initWithDatabase:database_]; + sections_ = [[SectionsController alloc] initWithDatabase:database_]; return sections_; } -- (ChangesView *) changesView { +- (ChangesController *) changesController { if (changes_ == nil) - changes_ = [[ChangesView alloc] initWithDatabase:database_ delegate:self]; + changes_ = [[ChangesController alloc] initWithDatabase:database_ delegate:self]; return changes_; } -- (ManageView *) manageView { +- (ManageController *) manageController { if (manage_ == nil) { - manage_ = (ManageView *) [[self + manage_ = (ManageController *) [[self _pageForURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"manage" ofType:@"html"]] - withClass:[ManageView class] + withClass:[ManageController class] ] retain]; if (!IsWildcat_) queueDelegate_ = manage_; } return manage_; } -- (SearchView *) searchView { +- (SearchController *) searchController { if (search_ == nil) - search_ = [[SearchView alloc] initWithDatabase:database_]; + search_ = [[SearchController alloc] initWithDatabase:database_]; return search_; } -- (SourceTable *) sourcesView { +- (SourceTable *) sourcesController { if (sources_ == nil) sources_ = [[SourceTable alloc] initWithDatabase:database_]; return sources_; } -- (InstalledView *) installedView { +- (InstalledController *) installedController { if (installed_ == nil) { - installed_ = [[InstalledView alloc] initWithDatabase:database_]; + installed_ = [[InstalledController alloc] initWithDatabase:database_]; if (IsWildcat_) queueDelegate_ = installed_; } return installed_; @@ -8081,18 +8122,18 @@ static _finline void _setHomePage(Cydia *self) { [[tabbar_ selectedViewController] popToRootViewControllerAnimated:YES]; return; } else if (tag_ == 1) { - [[self sectionsView] resetView]; + [[self sectionsController] resetView]; } switch (tag) { case kCydiaTag: _setHomePage(self); break; - case kSectionsTag: [self setPage:[self sectionsView]]; break; - case kChangesTag: [self setPage:[self changesView]]; break; - case kManageTag: [self setPage:[self manageView]]; break; - case kInstalledTag: [self setPage:[self installedView]]; break; - case kSourcesTag: [self setPage:[self sourcesView]]; break; - case kSearchTag: [self setPage:[self searchView]]; break; + case kSectionsTag: [self setPage:[self sectionsController]]; break; + case kChangesTag: [self setPage:[self changesController]]; break; + case kManageTag: [self setPage:[self manageController]]; break; + case kInstalledTag: [self setPage:[self installedController]]; break; + case kSourcesTag: [self setPage:[self sourcesController]]; break; + case kSearchTag: [self setPage:[self searchController]]; break; _nodefault } @@ -8136,7 +8177,7 @@ static _finline void _setHomePage(Cydia *self) { [role dismiss]; } -- (void) setPackageView:(PackageView *)view { +- (void) setPackageController:(PackageController *)view { WebThreadLock(); [view setPackage:nil]; #if RecyclePackageViews @@ -8146,19 +8187,19 @@ static _finline void _setHomePage(Cydia *self) { WebThreadUnlock(); } -- (PackageView *) _packageView { - return [[[PackageView alloc] initWithDatabase:database_] autorelease]; +- (PackageController *) _packageController { + return [[[PackageController alloc] initWithDatabase:database_] autorelease]; } -- (PackageView *) packageView { +- (PackageController *) packageController { #if RecyclePackageViews - PackageView *view; + PackageController *view; size_t count([details_ count]); if (count == 0) { - view = [self _packageView]; + view = [self _packageController]; renew: - [details_ addObject:[self _packageView]]; + [details_ addObject:[self _packageController]]; } else { view = [[[details_ lastObject] retain] autorelease]; [details_ removeLastObject]; @@ -8168,7 +8209,7 @@ static _finline void _setHomePage(Cydia *self) { return view; #else - return [self _packageView]; + return [self _packageController]; #endif } @@ -8252,6 +8293,8 @@ static _finline void _setHomePage(Cydia *self) { } - (void) applicationSuspend:(__GSEvent *)event { + // FIXME: This needs to be fixed, but we no longer have a progress_. + // What's the best solution? if (hud_ == nil)// && ![progress_ isRunning]) [super applicationSuspend:event]; } @@ -8272,7 +8315,7 @@ static _finline void _setHomePage(Cydia *self) { [window_ setUserInteractionEnabled:NO]; [hud show:YES]; - [window_ addSubview:hud]; + [[container_ view] addSubview:hud]; return hud; } @@ -8284,7 +8327,7 @@ static _finline void _setHomePage(Cydia *self) { - (UIViewController *) pageForPackage:(NSString *)name { if (Package *package = [database_ packageWithName:name]) { - PackageView *view([self packageView]); + PackageController *view([self packageController]); [view setPackage:package]; return view; } else { @@ -8313,21 +8356,21 @@ static _finline void _setHomePage(Cydia *self) { path = [@"/" stringByAppendingString:path]; if ([path isEqualToString:@"/add-source"]) - return [[[AddSourceView alloc] initWithDatabase:database_] autorelease]; + return [[[AddSourceController alloc] initWithDatabase:database_] autorelease]; else if ([path isEqualToString:@"/storage"]) return [self _pageForURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"storage" ofType:@"html"]] withClass:[CYBrowserController class]]; else if ([path isEqualToString:@"/sources"]) return [[[SourceTable alloc] initWithDatabase:database_] autorelease]; else if ([path isEqualToString:@"/packages"]) - return [[[InstalledView alloc] initWithDatabase:database_] autorelease]; + return [[[InstalledController alloc] initWithDatabase:database_] autorelease]; else if ([path hasPrefix:@"/url/"]) return [self _pageForURL:[NSURL URLWithString:[path substringFromIndex:5]] withClass:[CYBrowserController class]]; else if ([path hasPrefix:@"/launch/"]) [self launchApplicationWithIdentifier:[path substringFromIndex:8] suspended:NO]; else if ([path hasPrefix:@"/package-settings/"]) - return [[[SettingsView alloc] initWithDatabase:database_ package:[path substringFromIndex:18]] autorelease]; + return [[[SettingsController alloc] initWithDatabase:database_ package:[path substringFromIndex:18]] autorelease]; else if ([path hasPrefix:@"/package-signature/"]) - return [[[SignatureView alloc] initWithDatabase:database_ package:[path substringFromIndex:19]] autorelease]; + return [[[SignatureController alloc] initWithDatabase:database_ package:[path substringFromIndex:19]] autorelease]; else if ([path hasPrefix:@"/package/"]) return [self pageForPackage:[path substringFromIndex:9]]; else if ([path hasPrefix:@"/files/"]) { @@ -8448,10 +8491,10 @@ static _finline void _setHomePage(Cydia *self) { [tabbar_ setSelectedIndex:0]; container_ = [[CYContainer alloc] initWithDatabase:database_]; - [[container_ view] setFrame:[window_ bounds]]; [container_ setUpdateDelegate:self]; [container_ setRootController:tabbar_]; [window_ addSubview:[container_ view]]; + [[tabbar_ view] setFrame:CGRectMake(0, -20.0f, [window_ bounds].size.width, [window_ bounds].size.height)]; [UIKeyboard initImplementationNow]; @@ -8459,8 +8502,8 @@ static _finline void _setHomePage(Cydia *self) { #if RecyclePackageViews details_ = [[NSMutableArray alloc] initWithCapacity:4]; - [details_ addObject:[self _packageView]]; - [details_ addObject:[self _packageView]]; + [details_ addObject:[self _packageController]]; + [details_ addObject:[self _packageController]]; #endif PrintTimes(); @@ -8500,6 +8543,26 @@ MSHook(void, UIWebDocumentView$_setUIKitDelegate$, UIWebDocumentView *self, SEL return _UIWebDocumentView$_setUIKitDelegate$(self, _cmd, delegate); } +static NSNumber *shouldPlayKeyboardSounds; + +Class $UIHardware; + +MSHook(void, UIHardware$_playSystemSound$, Class self, SEL _cmd, int soundIndex) { + switch (soundIndex) { + case 1104: // Keyboard Button Clicked + case 1105: // Keyboard Delete Repeated + if (!shouldPlayKeyboardSounds) { + NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.apple.preferences.sounds.plist"]; + shouldPlayKeyboardSounds = [[dict objectForKey:@"keyboard"] ?: (id)kCFBooleanTrue retain]; + [dict release]; + } + if (![shouldPlayKeyboardSounds boolValue]) + break; + default: + _UIHardware$_playSystemSound$(self, _cmd, soundIndex); + } +} + int main(int argc, char *argv[]) { _pooled _trace(); @@ -8521,6 +8584,13 @@ int main(int argc, char *argv[]) { _pooled _UIWebDocumentView$_setUIKitDelegate$ = reinterpret_cast(method_getImplementation(UIWebDocumentView$_setUIKitDelegate$)); method_setImplementation(UIWebDocumentView$_setUIKitDelegate$, reinterpret_cast(&$UIWebDocumentView$_setUIKitDelegate$)); } + + $UIHardware = objc_getClass("UIHardware"); + Method UIHardware$_playSystemSound$(class_getClassMethod($UIHardware, @selector(_playSystemSound:))); + if (UIHardware$_playSystemSound$ != NULL) { + _UIHardware$_playSystemSound$ = reinterpret_cast(method_getImplementation(UIHardware$_playSystemSound$)); + method_setImplementation(UIHardware$_playSystemSound$, reinterpret_cast(&$UIHardware$_playSystemSound$)); + } /* }}} */ /* Set Locale {{{ */ Locale_ = CFLocaleCopyCurrent();