From a7a83194db1d2c72c59a9573b1dcb4d3f7ffc424 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20Hru=C5=A1ka?= <phru@dhcp-212.office.nic.cz>
Date: Thu, 22 Sep 2011 15:04:09 +0200
Subject: [PATCH] iPad bugs fixed

---
 AccountViewController_iPad.m            | 14 +++++++++++---
 Classes/DeactivatePinViewController.m   |  2 +-
 Classes/Estimate.m                      |  7 +++++--
 Classes/ISDSTask.h                      |  1 +
 Classes/ISDSTask.m                      | 21 +++++++++++++++++++++
 Classes/OtpTask.m                       |  2 ++
 Classes/ProgressToolbar.h               |  3 +++
 Classes/ProgressToolbar.m               | 25 +++++++++++++++++--------
 Classes/RootViewController_Shared.m     |  4 ++++
 Classes/SOAPTask.m                      | 19 ++-----------------
 Classes/SettingsViewController_Shared.m |  2 ++
 Classes/TokenViewController.m           |  8 +++++---
 Estimates.plist                         | 18 ++++++++----------
 Tests.txt                               |  4 ++++
 cs.lproj/Localizable.strings            |  2 +-
 15 files changed, 87 insertions(+), 45 deletions(-)

diff --git a/AccountViewController_iPad.m b/AccountViewController_iPad.m
index c6abca5..75aad81 100644
--- a/AccountViewController_iPad.m
+++ b/AccountViewController_iPad.m
@@ -29,6 +29,15 @@
 	return 0;
 }
 
+- (void)setRemoveButtonPosition:(BOOL)animated
+{
+    CGRect frame = self.removeButton.frame;
+    frame.origin.y = self.tableView.frame.origin.y + [self tableView:self.tableView numberOfRowsInSection:TEXTFIELDS_SECTION] * CELL_HEIGHT + REMOVEBUTTON_OFFSET;
+    if (animated)
+        [UIView animateWithDuration:0.3 animations:^{ self.removeButton.frame = frame; }];
+    else
+        self.removeButton.frame = frame;
+}
 
 - (void)setupAliasCell
 {
@@ -44,9 +53,7 @@
     else
         [self.tableView deleteRowsAtIndexPaths:aliasRow withRowAnimation:UITableViewRowAnimationTop];
     
-    CGRect frame = self.removeButton.frame;
-    frame.origin.y = self.tableView.frame.origin.y + [self tableView:self.tableView numberOfRowsInSection:TEXTFIELDS_SECTION] * CELL_HEIGHT + REMOVEBUTTON_OFFSET;
-    [UIView animateWithDuration:0.3 animations:^{ self.removeButton.frame = frame; }];
+    [self setRemoveButtonPosition:YES];
 }
 
 
@@ -93,6 +100,7 @@
     
     self.autoAliasCell.on = !self.account.useAlias;
     self.aliasTextField.text = self.account.alias;
+    [self setRemoveButtonPosition:YES];
     [super viewWillAppear:animated];
 }
 
diff --git a/Classes/DeactivatePinViewController.m b/Classes/DeactivatePinViewController.m
index a01f78c..779d7f2 100644
--- a/Classes/DeactivatePinViewController.m
+++ b/Classes/DeactivatePinViewController.m
@@ -51,7 +51,7 @@
 
 - (void)lastDigitEntered:(id)sender {
 	ISDSDefaults* defaults = [ISDSDefaults sharedDefaults];
-	NSLog(@"%@\n", defaults.pin);
+	//NSLog(@"%@\n", defaults.pin);
 	if ([defaults.pin isEqualToString:self.pinEditViewController.pin]) {
 		defaults.pin = nil;
         [PinEditViewController resetFailureCount];
diff --git a/Classes/Estimate.m b/Classes/Estimate.m
index 9dad184..067a2cf 100644
--- a/Classes/Estimate.m
+++ b/Classes/Estimate.m
@@ -9,7 +9,7 @@
 #import "Estimate.h"
 
 
-#define DEFAULT_DELAY 1000
+#define DEFAULT_DELAY 1.0
 #define ESTIMATE_RIGIDITY 0.3
 
 
@@ -104,7 +104,10 @@
 	if (!plist) return DEFAULT_DELAY;
 	
 	NSNumber *delay = [plist objectForKey:className];
-	if (!delay) return DEFAULT_DELAY;
+	if (!delay) {
+        NSLog(@"Can't find default delay for class '%@'", className);
+        return DEFAULT_DELAY;
+    }
 	return [delay floatValue];
 }
 
diff --git a/Classes/ISDSTask.h b/Classes/ISDSTask.h
index 826fdcc..fda8a7e 100644
--- a/Classes/ISDSTask.h
+++ b/Classes/ISDSTask.h
@@ -49,6 +49,7 @@
 - (void)sendFailure;
 - (NSString*)taskDescription;
 
+- (void)setErrorDescriptionForError:(NSError*)error;
 - (void)failWithDescription:(NSString*)errorDescription;
 
 - (void)start;
diff --git a/Classes/ISDSTask.m b/Classes/ISDSTask.m
index f722599..e4b9195 100644
--- a/Classes/ISDSTask.m
+++ b/Classes/ISDSTask.m
@@ -106,6 +106,26 @@
 	return testing ? ISDS_SUBJECT_TESTING : ISDS_SUBJECT_RELEASE;
 }
 
+- (void)setErrorDescriptionForError:(NSError*)error
+{
+    NSString* errDescr;
+	if (error.code == -1012) {
+        if (self.errorDescription) {
+            errDescr = self.errorDescription;
+        } else {
+            errDescr = NSLocalizedString(@"Cannot access databox. Please check databox settings.", @"Cannot access databox. Please check databox settings.");
+        }
+	} else {
+        if ([self networkUnavailable])
+            errDescr = NSLocalizedString(@"Network not available.", @"Network not available.");
+        else
+            errDescr = NSLocalizedString(@"Cannot connect to ISDS server.", @"Cannot connect to ISDS server.");
+    }
+    
+    self.errorDescription = errDescr;
+}
+
+
 - (void)failWithDescription:(NSString*)errorDescription
 {
     [self cancel];
@@ -232,6 +252,7 @@
 
 - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
     
+    [self setErrorDescriptionForError:error];
     [self sendFailure];
 }
 
diff --git a/Classes/OtpTask.m b/Classes/OtpTask.m
index 296e7bf..dd98453 100644
--- a/Classes/OtpTask.m
+++ b/Classes/OtpTask.m
@@ -92,6 +92,8 @@
 }
 
 - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
+    
+    [self setErrorDescriptionForError:error];
     [self sendResult];
 }
 
diff --git a/Classes/ProgressToolbar.h b/Classes/ProgressToolbar.h
index 52efa5f..9b96415 100644
--- a/Classes/ProgressToolbar.h
+++ b/Classes/ProgressToolbar.h
@@ -21,12 +21,15 @@
 @property (nonatomic, retain) UIProgressView* bar;
 @property (nonatomic, retain) NSArray* items;
 @property (nonatomic, retain) UIActivityIndicatorView* activityIndicator;
+@property (nonatomic, retain) UIView* progressView;
 
 
 - (id)initWithText:(NSString*)text andFrame:(CGRect)frame;
 - (id)initWithText:(NSString*)text;
 - (void)willShowInSplitView;
 - (void)willHideInSplitView;
+- (void)setFrame:(CGRect)frame;
+
 
 
 @end
diff --git a/Classes/ProgressToolbar.m b/Classes/ProgressToolbar.m
index 585a0e9..2b164c5 100644
--- a/Classes/ProgressToolbar.m
+++ b/Classes/ProgressToolbar.m
@@ -15,13 +15,14 @@
 @synthesize bar;
 @synthesize items;
 @synthesize activityIndicator=_activityIndicator;
+@synthesize progressView=_progressView;
 
 
 - (id)initWithText:(NSString*)text andFrame:(CGRect)frame {
 	if ((self = [super init])) {
 		
-		UIView* progressView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 30)];
-        progressView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
+		self.progressView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 30)];
+        self.progressView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
         
 		self.label = [[UILabel alloc] initWithFrame:CGRectMake(25, 0, 260, 12)];
 		[self.label release];
@@ -29,10 +30,10 @@
 		self.label.backgroundColor = [UIColor clearColor];
 		self.label.font = [UIFont boldSystemFontOfSize:[UIFont smallSystemFontSize]];
 		self.label.textColor = [UIColor whiteColor];
-		[progressView addSubview:self.label];
+		[self.progressView addSubview:self.label];
         
 		self.bar = [[UIProgressView alloc] initWithFrame:CGRectMake(25, 15, 260, 10)];
-		[progressView addSubview:self.bar];
+		[self.progressView addSubview:self.bar];
 		[self.bar release];
         self.bar.autoresizingMask = UIViewAutoresizingFlexibleWidth;
         
@@ -40,12 +41,12 @@
 		[self.activityIndicator release];
 		self.activityIndicator.hidden = NO;
 		[self.activityIndicator startAnimating];
-		[progressView addSubview:self.activityIndicator];
+		[self.progressView addSubview:self.activityIndicator];
         
-        if (!CGRectIsNull(frame)) progressView.frame = frame;
+        if (!CGRectIsNull(frame)) self.progressView.frame = frame;
         
-		UIBarButtonItem* toolbarItem = [[UIBarButtonItem alloc] initWithCustomView:progressView];
-		[progressView release];
+		UIBarButtonItem* toolbarItem = [[UIBarButtonItem alloc] initWithCustomView:self.progressView];
+		[self.progressView release];
         
 		self.items = [NSArray arrayWithObject: toolbarItem];
 		[toolbarItem release];
@@ -54,6 +55,13 @@
 	return self;
 }
 
+- (void)setFrame:(CGRect)frame
+{
+    CGRect f = self.progressView.frame;
+    f.size.width = frame.size.width;
+    self.progressView.frame = f;
+}
+
 - (id)initWithText:(NSString*)text {
 
     return [self initWithText:text andFrame:CGRectNull];
@@ -81,6 +89,7 @@
 	[bar release];
 	[items release];
     [_activityIndicator release];
+    [_progressView release];
     
 	[super dealloc];
 }
diff --git a/Classes/RootViewController_Shared.m b/Classes/RootViewController_Shared.m
index 091a791..0142dc9 100644
--- a/Classes/RootViewController_Shared.m
+++ b/Classes/RootViewController_Shared.m
@@ -51,8 +51,12 @@
 
 - (void)setupCookiesAndScheduleUpdate
 {
+    UIViewController* topViewController = [self.navigationController topViewController];
+    if ([topViewController isKindOfClass:[TokenViewController class]]) return;
+    
     TokenViewController* tokenViewController = [[NetworkUpdater networkUpdater] tokenViewController];
     if (tokenViewController) {
+        self.title = NSLocalizedString(@"Accounts", @"Accounts view title");
         tokenViewController.delegate = self;
         [self.navigationController pushViewController:tokenViewController animated:TRUE];
     } 
diff --git a/Classes/SOAPTask.m b/Classes/SOAPTask.m
index 9cf7a94..283b633 100644
--- a/Classes/SOAPTask.m
+++ b/Classes/SOAPTask.m
@@ -104,23 +104,8 @@
 	for (id key in error.userInfo) {
 		NSLog(@"                  key=%@, value=%@", key, [error.userInfo objectForKey:key]);
 	}
-	
-	NSString* errDescr;
-	if (error.code == -1012) {
-        if (self.errorDescription) {
-            errDescr = self.errorDescription;
-            [[errDescr retain] autorelease];
-        } else {
-            errDescr = NSLocalizedString(@"Cannot access databox. Please check databox settings.", @"Cannot access databox. Please check databox settings.");
-        }
-	} else {
-        if ([self networkUnavailable])
-            errDescr = NSLocalizedString(@"Network not available.", @"Network not available.");
-        else
-            errDescr = NSLocalizedString(@"Cannot connect to ISDS server.", @"Cannot connect to ISDS server.");
-    }
- 
-    self.errorDescription = errDescr;
+
+	[self setErrorDescriptionForError:error]; 
     [self.delegate taskFailed:self];
 }
 
diff --git a/Classes/SettingsViewController_Shared.m b/Classes/SettingsViewController_Shared.m
index cf2dfca..aa727b1 100644
--- a/Classes/SettingsViewController_Shared.m
+++ b/Classes/SettingsViewController_Shared.m
@@ -145,6 +145,8 @@
 		[self setToolbarItems:self.progressToolbar.items animated:YES];
 		self.navigationController.toolbarHidden = NO;
 	}
+    CGRect frame = CGRectMake(0, 0, self.view.frame.size.width - 20, 30);
+    [self.progressToolbar setFrame:frame];
 }
 
 
diff --git a/Classes/TokenViewController.m b/Classes/TokenViewController.m
index f536623..3fe0393 100644
--- a/Classes/TokenViewController.m
+++ b/Classes/TokenViewController.m
@@ -389,7 +389,7 @@
 - (void)showActionSheet
 {
     if (self.actionSheet) [self dismissActionSheet];
-    self.actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Some accounts are missing tokens. Do you with to continue?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) destructiveButtonTitle:NSLocalizedString(@"Continue", nil) otherButtonTitles: nil];
+    self.actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Some accounts are missing tokens. Do you wish to continue?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) destructiveButtonTitle:NSLocalizedString(@"Continue", nil) otherButtonTitles: nil];
     
     [self.actionSheet showInView:self.view];
     [self.actionSheet release];
@@ -542,8 +542,10 @@
 - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
 {
     self.actionSheet = nil;
-    [self.navigationController setToolbarHidden:NO];
-    [self.navigationController setToolbarHidden:YES];
+    if (buttonIndex != CONTINUE_BUTTON_INDEX) {
+        [self.navigationController setToolbarHidden:NO];
+        [self.navigationController setToolbarHidden:YES];
+    }
 }
 
 @end
diff --git a/Estimates.plist b/Estimates.plist
index 7125ec4..958444b 100644
--- a/Estimates.plist
+++ b/Estimates.plist
@@ -2,15 +2,13 @@
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
-	<key>GetOwnerInfoFromLogin</key>
-	<real>0.5</real>
-	<key>GetListOfSentMessages</key>
-	<real>0.5</real>
-	<key>GetListOfReceivedMessages</key>
-	<real>0.5</real>
-	<key>SignedSentMessageDownload</key>
-	<real>1.7</real>
-	<key>ReceivedMessageDownload</key>
-	<real>1.7</real>
+	<key>SmsTask</key>
+	<integer>1</integer>
+	<key>SOAPTask</key>
+	<integer>1</integer>
+	<key>HotpCookieTask</key>
+	<integer>1</integer>
+	<key>TotpCookieTask</key>
+	<integer>1</integer>
 </dict>
 </plist>
diff --git a/Tests.txt b/Tests.txt
index 1d0b9d1..2e2fb7a 100644
--- a/Tests.txt
+++ b/Tests.txt
@@ -177,6 +177,10 @@ T17	.	.	.	.
 
 -------------------
 
+21.9.2011
+
+-------------------
+
 23.5.2011
 
 	tel-cs	tel-en	pad-cs	pad-en
diff --git a/cs.lproj/Localizable.strings b/cs.lproj/Localizable.strings
index d35c23e..f629b7a 100644
--- a/cs.lproj/Localizable.strings
+++ b/cs.lproj/Localizable.strings
@@ -90,7 +90,7 @@
 
 /* Token table */
 "Authorization"="Autorizace";
-"Some accounts are missing tokens. Do you with to continue?"="Některým účtům chybí kódy. Přejete si pokračovat?";
+"Some accounts are missing tokens. Do you wish to continue?"="Některým účtům chybí kódy. Přejete si pokračovat?";
 "Verifying authorization code"="Ověřuji autorizační kód";
 "Requesting sms message"="Žádám o sms zprávu";
 
-- 
GitLab