} return self;
}
-- (void)_updateFrameForDisplay {
+- (void) _updateFrameForDisplay {
[super _updateFrameForDisplay];
if ([self cancelButtonIndex] == -1) {
NSArray *buttons = [self buttons];
- (void) dropBar:(BOOL)animated;
- (void) beginUpdate;
- (void) raiseBar:(BOOL)animated;
+- (BOOL) updating;
@end
@implementation CYContainer
+- (BOOL) _reallyWantsFullScreenLayout {
+ return YES;
+}
+
// NOTE: UIWindow only sends the top controller these messages,
// So we have to forward them on.
updatedelegate_ = delegate;
}
+- (CGFloat) statusBarHeight {
+ if (UIInterfaceOrientationIsPortrait([self interfaceOrientation])) {
+ return [[UIApplication sharedApplication] statusBarFrame].size.height;
+ } else {
+ return [[UIApplication sharedApplication] statusBarFrame].size.width;
+ }
+}
+
- (void) dropBar:(BOOL)animated {
if (dropped_) return;
dropped_ = true;
[[self view] addSubview:refreshbar_];
+ CGFloat sboffset = [self statusBarHeight];
+
+ CGRect barframe = [refreshbar_ frame];
+ barframe.origin.y = sboffset;
+ [refreshbar_ setFrame:barframe];
+
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 + sboffset;
+ viewframe.size.height -= barframe.size.height + sboffset;
[[root_ view] setFrame:viewframe];
if (animated) [UIView commitAnimations];
[refreshbar_ removeFromSuperview];
+ CGFloat sboffset = [self statusBarHeight];
+
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 + sboffset;
+ viewframe.size.height += barframe.size.height + sboffset;
[[root_ view] setFrame:viewframe];
if (animated) [UIView commitAnimations];
[[root_ selectedViewController] _updateLayoutForStatusBarAndInterfaceOrientation];
}
+- (void) statusBarFrameChanged:(NSNotification *)notification {
+ if (dropped_) {
+ [self raiseBar:NO];
+ [self dropBar:NO];
+ }
+}
+
- (void) dealloc {
[refreshbar_ release];
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
-- (id) initWithDatabase: (Database *)database {
+- (id) initWithDatabase:(Database *)database {
if ((self = [super init]) != nil) {
database_ = database;
[[self view] setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameChanged:) name:UIApplicationDidChangeStatusBarFrameNotification object:nil];
refreshbar_ = [[RefreshBar alloc] initWithFrame:CGRectMake(0, 0, [[self view] frame].size.width, [UINavigationBar defaultSize].height) delegate:self];
} return self;
#endif
}
+// Returns the navigation controller for the queuing badge.
+- (id) queueBadgeController {
+ int index = [self indexOfTabWithTag:kManageTag];
+ if (index == -1) index = [self indexOfTabWithTag:kInstalledTag];
+
+ return [[tabbar_ viewControllers] objectAtIndex:index];
+}
+
- (void) cancelAndClear:(bool)clear {
@synchronized (self) {
if (clear) {
- /* XXX: clear marks instead of reloading data */
- /*pkgCacheFile &cache([database_ cache]);
+ // Clear all marks.
+ pkgCacheFile &cache([database_ cache]);
for (pkgCache::PkgIterator iterator = cache->PkgBegin(); !iterator.end(); ++iterator) {
- if (!cache[iterator].Keep()) cache->MarkKeep(iterator, false, false);
+ // Unmark method taken from Synaptic Package Manager.
+ // Thanks for being sane, unlike Aptitude.
+ if (!cache[iterator].Keep()) {
+ cache->MarkKeep(iterator, false);
+ cache->SetReInstall(iterator, false);
+ }
}
- [self updateData];
-
+ // Stop queuing.
Queuing_ = false;
- [[[[tabbar_ viewControllers] objectAtIndex:[self indexOfTabWithTag:kManageTag] != -1 ? [self indexOfTabWithTag:kManageTag] : [self indexOfTabWithTag:kInstalledTag]] tabBarItem] setBadgeValue:nil];
- [queueDelegate_ queueStatusDidChange];*/
- [self reloadData];
+ [[[self queueBadgeController] tabBarItem] setBadgeValue:nil];
} else {
+ // Start queuing.
Queuing_ = true;
-
- [[[[tabbar_ viewControllers] objectAtIndex:[self indexOfTabWithTag:kManageTag] != -1 ? [self indexOfTabWithTag:kManageTag] : [self indexOfTabWithTag:kInstalledTag]] tabBarItem] setBadgeValue:UCLocalize("Q_D")];
- [(CYNavigationController *)[tabbar_ selectedViewController] reloadData];
-
- [queueDelegate_ queueStatusDidChange];
- }
+ [[[self queueBadgeController] tabBarItem] setBadgeValue:UCLocalize("Q_D")];
+ }
+
+ // Show the changes in the current view.
+ [(CYNavigationController *) [tabbar_ selectedViewController] reloadData];
+ [queueDelegate_ queueStatusDidChange];
}
}