]> git.saurik.com Git - cydia.git/blobdiff - Cydia.mm
Use a static value for the width of the confirm prompt to prevent it from scrolling...
[cydia.git] / Cydia.mm
index b8bdb0ef305ffd13d24788665f5d246ee62467eb..eb17d6a13ceed4f7565099b47dd606f64da0a6c7 100644 (file)
--- a/Cydia.mm
+++ b/Cydia.mm
@@ -6222,6 +6222,21 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
     ];
     [[self navigationItem] setRightBarButtonItem:rightItem animated:animated];
     [rightItem release];
+    
+    if (IsWildcat_ && !editing) {
+        UIBarButtonItem *settingsItem = [[UIBarButtonItem alloc]
+            initWithTitle:UCLocalize("SETTINGS")
+            style:UIBarButtonItemStylePlain
+            target:self
+            action:@selector(settingsButtonClicked)
+            ];
+        [[self navigationItem] setLeftBarButtonItem:settingsItem];
+        [settingsItem release];
+    }
+}
+
+- (void) settingsButtonClicked {
+    [delegate_ showSettings];
 }
 
 - (void) editButtonClicked {
@@ -7503,8 +7518,6 @@ freeing the view controllers on tab change */
         segment_ = [[UISegmentedControl alloc] initWithItems:items];
         container_ = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [[self view] frame].size.width, 44.0f)];
         [container_ addSubview:segment_];
-        CGFloat width = [[self view] frame].size.width;
-        [segment_ setFrame:CGRectMake(width / 32.0f, 0, width - (width / 32.0f * 2.0f), 44.0f)];
         
         int index = -1;
         if ([Role_ isEqualToString:@"User"]) index = 0;
@@ -7516,6 +7529,7 @@ freeing the view controllers on tab change */
         }
         
         [segment_ addTarget:self action:@selector(segmentChanged:) forControlEvents:UIControlEventValueChanged];
+        [self resizeSegmentedControl];
         
         table_ = [[UITableView alloc] initWithFrame:[[self view] bounds] style:UITableViewStyleGrouped];
         [table_ setAutoresizingMask:UIViewAutoresizingFlexibleBoth];
@@ -7526,24 +7540,49 @@ freeing the view controllers on tab change */
     } return self;
 }
 
+- (void) resizeSegmentedControl {
+    CGFloat width = [[self view] frame].size.width;
+    [segment_ setFrame:CGRectMake(width / 32.0f, 0, width - (width / 32.0f * 2.0f), 44.0f)];
+}
+
+- (void) viewWillAppear:(BOOL)animated {
+    [super viewWillAppear:animated];
+    
+    [self resizeSegmentedControl];
+}
+
+- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {
+    [self resizeSegmentedControl];
+}
+
+- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
+    [self resizeSegmentedControl];
+}
+
 - (void) save {
+    NSString *role = nil;
+    
     switch ([segment_ selectedSegmentIndex]) {
-        case 0: Role_ = @"User"; break;
-        case 1: Role_ = @"Hacker"; break;
-        case 2: Role_ = @"Developer"; break;
+        case 0: role = @"User"; break;
+        case 1: role = @"Hacker"; break;
+        case 2: role = @"Developer"; break;
 
         _nodefault
     }
 
-    Settings_ = [NSMutableDictionary dictionaryWithObjectsAndKeys:
-        Role_, @"Role",
-    nil];
+    if (![role isEqualToString:Role_]) {
+        Role_ = role;
+        
+        Settings_ = [NSMutableDictionary dictionaryWithObjectsAndKeys:
+            Role_, @"Role",
+        nil];
 
-    [Metadata_ setObject:Settings_ forKey:@"Settings"];
+        [Metadata_ setObject:Settings_ forKey:@"Settings"];
 
-    Changed_ = true;
+        Changed_ = true;
     
-    [delegate_ updateData];
+        [roledelegate_ updateData];
+    }
 }
 
 - (void) segmentChanged:(UISegmentedControl *)control {
@@ -7567,7 +7606,8 @@ freeing the view controllers on tab change */
 }
 
 - (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
-    return 5;
+    // XXX: For not having a single cell in the table, this sure is a lot of sections.
+    return 6;
 }
 
 - (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
@@ -7791,8 +7831,7 @@ freeing the view controllers on tab change */
     [[root_ selectedViewController] _updateLayoutForStatusBarAndInterfaceOrientation];
 }
 
-- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
-{
+- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {
     // XXX: fix Apple's layout bug
     [[root_ selectedViewController] _updateLayoutForStatusBarAndInterfaceOrientation];
 }
@@ -8281,7 +8320,8 @@ static _finline void _setHomePage(Cydia *self) {
 
 - (void) showSettings {
     RoleController *role = [[RoleController alloc] initWithDatabase:database_ delegate:self];
-    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:role];
+    CYNavigationController *nav = [[CYNavigationController alloc] initWithRootViewController:role];
+    if (IsWildcat_) [nav setModalPresentationStyle:UIModalPresentationFormSheet];
     [container_ presentModalViewController:nav animated:YES];
 }
 
@@ -8507,8 +8547,6 @@ static _finline void _setHomePage(Cydia *self) {
 - (void) applicationWillResignActive:(UIApplication *)application {
     // Stop refreshing if you get a phone call or lock the device.
     if ([container_ updating]) [container_ cancelUpdate];
-    
-    [super applicationWillResignActive:application];
 }
 
 - (void) applicationDidFinishLaunching:(id)unused {
@@ -8836,8 +8874,7 @@ int main(int argc, char *argv[]) { _pooled
     if (Metadata_ == NULL)
         Metadata_ = [NSMutableDictionary dictionaryWithCapacity:2];
     else {
-        
-        Role_ = [Metadata_ objectForKey:@"Settings"];
+        Settings_ = [Metadata_ objectForKey:@"Settings"];
 
         Packages_ = [Metadata_ objectForKey:@"Packages"];
         Sections_ = [Metadata_ objectForKey:@"Sections"];