Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 7 compatibilty for the sales view #249

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
260 changes: 238 additions & 22 deletions AppSales.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>066951A8-270B-4F2C-9BB2-0FEC04627C15</string>
<key>IDESourceControlProjectName</key>
<string>AppSales</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>8D0DA2FA-57F1-4545-B575-CCD4C65A5BDD</key>
<string>https://github.com/plaincode/AppSales-Mobile.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>AppSales.xcodeproj/project.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>8D0DA2FA-57F1-4545-B575-CCD4C65A5BDD</key>
<string>../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>https://github.com/plaincode/AppSales-Mobile.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>8D0DA2FA-57F1-4545-B575-CCD4C65A5BDD</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>8D0DA2FA-57F1-4545-B575-CCD4C65A5BDD</string>
<key>IDESourceControlWCCName</key>
<string>AppSales-Mobile</string>
</dict>
</array>
</dict>
</plist>
2 changes: 1 addition & 1 deletion Classes/AccountsViewController+VendorID.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ - (void)findVendorIDsWithLogin:(NSDictionary *)loginInfo

NSString *ittsBaseURL = @"https://itunesconnect.apple.com";
NSString *ittsLoginPageAction = @"/WebObjects/iTunesConnect.woa";
NSString *signoutSentinel = @"menu-item sign-out";
NSString *signoutSentinel = @"name=\"signOutForm\"";

NSURL *loginURL = [NSURL URLWithString:[ittsBaseURL stringByAppendingString:ittsLoginPageAction]];
NSHTTPURLResponse *loginPageResponse = nil;
Expand Down
77 changes: 65 additions & 12 deletions Classes/AccountsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "AccountsViewController.h"
#import "SalesViewController.h"
#import "ReviewsViewController.h"
#import "SSKeychain.h"
#import "ASAccount.h"
#import "Report.h"
Expand All @@ -16,13 +17,17 @@
#import "ReportDownloadCoordinator.h"
#import "MBProgressHUD.h"
#import "ReportImportOperation.h"
#import "PaymentsViewController.h"
#import "BadgedCell.h"
#import "UIImage+Tinting.h"
#import "AboutViewController.h"
#import "AccountStatusView.h"
#import "PromoCodesViewController.h"
#import "PromoCodesLicenseViewController.h"
#import "KKPasscodeLock.h"
#import "ZipFile.h"
#import "ZipWriteStream.h"
#import "IconManager.h"

#define kAddNewAccountEditorIdentifier @"AddNewAccountEditorIdentifier"
#define kEditAccountEditorIdentifier @"EditAccountEditorIdentifier"
Expand Down Expand Up @@ -67,6 +72,8 @@ - (void)viewDidLoad

[[ReportDownloadCoordinator sharedReportDownloadCoordinator] addObserver:self forKeyPath:@"isBusy" options:NSKeyValueObservingOptionNew context:nil];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iconCleared:) name:IconManagerClearedIconNotification object:nil];

[self reloadAccounts];
}

Expand Down Expand Up @@ -173,7 +180,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
if ([self.accounts count] == 0) {
return 0;
}
return 2;
return 5;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
Expand All @@ -196,11 +203,32 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell.imageView.image = [UIImage imageNamed:@"Sales.png"];
cell.imageView.highlightedImage = [UIImage as_tintedImageNamed:@"Sales.png" color:[UIColor whiteColor]];
} else if (indexPath.row == 1) {
NSInteger badge = [[[self.accounts objectAtIndex:indexPath.section] paymentsBadge] integerValue];
cell.textLabel.text = NSLocalizedString(@"Payments", nil);
cell.badgeCount = badge;
cell.imageView.image = [UIImage imageNamed:@"Payments.png"];
cell.imageView.highlightedImage = [UIImage as_tintedImageNamed:@"Payments.png" color:[UIColor whiteColor]];
} else if (indexPath.row == 2) {
cell.textLabel.text = NSLocalizedString(@"Customer Reviews", nil);
cell.imageView.image = [UIImage imageNamed:@"Reviews.png"];
cell.imageView.highlightedImage = [UIImage as_tintedImageNamed:@"Reviews.png" color:[UIColor whiteColor]];

ASAccount *account = [self.accounts objectAtIndex:indexPath.section];
NSFetchRequest *unreadReviewsRequest = [[[NSFetchRequest alloc] init] autorelease];
[unreadReviewsRequest setEntity:[NSEntityDescription entityForName:@"Review" inManagedObjectContext:[self managedObjectContext]]];
[unreadReviewsRequest setPredicate:[NSPredicate predicateWithFormat:@"product.account == %@ AND unread == TRUE", account]];
cell.badgeCount = [[self managedObjectContext] countForFetchRequest:unreadReviewsRequest error:NULL];
} else if (indexPath.row == 3) {
cell.textLabel.text = NSLocalizedString(@"Promo Codes", nil);
cell.imageView.image = [UIImage imageNamed:@"PromoCodes.png"];
cell.imageView.highlightedImage = [UIImage as_tintedImageNamed:@"PromoCodes.png" color:[UIColor whiteColor]];
cell.badgeCount = 0;
} else if (indexPath.row == 4) {
cell.textLabel.text = NSLocalizedString(@"Account", nil);
cell.imageView.image = [UIImage imageNamed:@"Account.png"];
cell.imageView.highlightedImage = [UIImage as_tintedImageNamed:@"Account.png" color:[UIColor whiteColor]];
cell.badgeCount = 0;
}
}
return cell;
}

Expand Down Expand Up @@ -247,6 +275,15 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
SalesViewController *salesViewController = [[[SalesViewController alloc] initWithAccount:account] autorelease];
[self.navigationController pushViewController:salesViewController animated:YES];
} else if (indexPath.row == 1) {
PaymentsViewController *paymentsViewController = [[[PaymentsViewController alloc] initWithAccount:account] autorelease];
[self.navigationController pushViewController:paymentsViewController animated:YES];
} else if (indexPath.row == 2) {
ReviewsViewController *reviewsViewController = [[[ReviewsViewController alloc] initWithAccount:account] autorelease];
[self.navigationController pushViewController:reviewsViewController animated:YES];
} else if (indexPath.row == 3) {
PromoCodesViewController *promoCodesViewController = [[[PromoCodesViewController alloc] initWithAccount:account] autorelease];
[self.navigationController pushViewController:promoCodesViewController animated:YES];
} else if (indexPath.row == 4) {
[self editAccount:account];
}
}
Expand Down Expand Up @@ -329,7 +366,8 @@ - (void)editAccount:(ASAccount *)account
for (Product *product in allProducts) {
FieldSpecifier *productNameField = [FieldSpecifier textFieldWithKey:[NSString stringWithFormat:@"product.name.%@", product.productID] title:NSLocalizedString(@"Name", nil) defaultValue:[product displayName]];
FieldSpecifier *hideProductField = [FieldSpecifier switchFieldWithKey:[NSString stringWithFormat:@"product.hidden.%@", product.productID] title:NSLocalizedString(@"Hide in Dashboard", nil) defaultValue:[product.hidden boolValue]];
FieldSectionSpecifier *productSection = [FieldSectionSpecifier sectionWithFields:[NSArray arrayWithObjects:productNameField, hideProductField, nil] title:nil description:nil];
FieldSpecifier *reloadProductInfoField = [FieldSpecifier buttonFieldWithKey:[NSString stringWithFormat:@"product.reload.%@", product.productID] title:NSLocalizedString(@"Reload App Icon...", nil)];
FieldSectionSpecifier *productSection = [FieldSectionSpecifier sectionWithFields:[NSArray arrayWithObjects:productNameField, hideProductField, reloadProductInfoField, nil] title:nil description:nil];
FieldSpecifier *showInAppStoreField = [FieldSpecifier buttonFieldWithKey:[NSString stringWithFormat:@"product.appstore.%@", product.productID] title:NSLocalizedString(@"Show in App Store...", nil)];
NSString *productFooter = [NSString stringWithFormat:@"Current version: %@\nApple ID: %@", ((product.currentVersion) ? product.currentVersion : @"N/A"), product.productID];
FieldSectionSpecifier *showInAppStoreSection = [FieldSectionSpecifier sectionWithFields:[NSArray arrayWithObject:showInAppStoreField] title:nil description:productFooter];
Expand Down Expand Up @@ -365,12 +403,12 @@ - (void)showSettings
{
// main section
passcodeLockField = [FieldSpecifier buttonFieldWithKey:kPasscodeLockButton title:NSLocalizedString(@"Passcode Lock", nil)];
if ([[KKPasscodeLock sharedLock] isPasscodeRequired]) {
passcodeLockField.defaultValue = @"On";
} else {
passcodeLockField.defaultValue = @"Off";
}
if ([[KKPasscodeLock sharedLock] isPasscodeRequired]) {
passcodeLockField.defaultValue = @"On";
} else {
passcodeLockField.defaultValue = @"Off";
}
NSString *baseCurrency = [[CurrencyManager sharedManager] baseCurrency];
NSArray *availableCurrencies = [[CurrencyManager sharedManager] availableCurrencies];
NSMutableArray *currencyFields = [NSMutableArray array];
Expand All @@ -383,8 +421,9 @@ - (void)showSettings
description:nil];
currencySection.exclusiveSelection = YES;
FieldSpecifier *currencySectionField = [FieldSpecifier subsectionFieldWithSection:currencySection key:@"currency"];
FieldSpecifier *updateExchangeRatesButtonField = [FieldSpecifier buttonFieldWithKey:kUpdateExchangeRatesButton title:NSLocalizedString(@"Update Exchange Rates Now", nil)];
FieldSectionSpecifier *mainSection = [FieldSectionSpecifier sectionWithFields:[NSArray arrayWithObjects:passcodeLockField, currencySectionField, updateExchangeRatesButtonField, nil]
FieldSpecifier *updateExchangeRatesButtonField = [FieldSpecifier buttonFieldWithKey:kUpdateExchangeRatesButton title:NSLocalizedString(@"Update Exchange Rates Now", nil)];
FieldSpecifier *downloadPaymentsField = [FieldSpecifier switchFieldWithKey:kSettingDownloadPayments title:NSLocalizedString(@"Download Payments", nil) defaultValue:[[NSUserDefaults standardUserDefaults] boolForKey:kSettingDownloadPayments]];
FieldSectionSpecifier *mainSection = [FieldSectionSpecifier sectionWithFields:[NSArray arrayWithObjects:passcodeLockField, currencySectionField, updateExchangeRatesButtonField, downloadPaymentsField, nil]
title:NSLocalizedString(@"General", nil)
description:NSLocalizedString(@"Exchange rates will automatically be refreshed periodically.", nil)];

Expand All @@ -396,7 +435,7 @@ - (void)showSettings
defaultValue:[productSortByValue isEqualToString:@"productId"]];
FieldSpecifier *productSortingByColorField = [FieldSpecifier checkFieldWithKey:@"sortby.color" title:@"Color"
defaultValue:[productSortByValue isEqualToString:@"color"]];
NSMutableArray *productSortingFields = [NSArray arrayWithObjects:productSortingByProductIdField, productSortingByColorField, nil];
NSMutableArray *productSortingFields = [NSMutableArray arrayWithObjects:productSortingByProductIdField, productSortingByColorField, nil];


FieldSectionSpecifier *productSortingSection = [FieldSectionSpecifier sectionWithFields:productSortingFields
Expand Down Expand Up @@ -498,6 +537,7 @@ - (void)fieldEditor:(FieldEditorViewController *)editor didFinishEditingWithValu
}
}
}
[[NSUserDefaults standardUserDefaults] setBool:[[returnValues objectForKey:kSettingDownloadPayments] boolValue] forKey:kSettingDownloadPayments];
[self dismissModalViewControllerAnimated:YES];

[[NSNotificationCenter defaultCenter] postNotificationName:ASViewSettingsDidChangeNotification object:nil];
Expand Down Expand Up @@ -538,6 +578,10 @@ - (void)fieldEditor:(FieldEditorViewController *)editor pressedButtonWithKey:(NS
NSString *productID = [key substringFromIndex:[@"product.appstore." length]];
NSString *appStoreURLString = [NSString stringWithFormat:@"http://itunes.apple.com/app/id%@", productID];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:appStoreURLString]];
} else if ([key hasPrefix:@"product.reload."]) {
NSString *productID = [key substringFromIndex:[@"product.reload." length]];
IconManager *iconManager = [IconManager sharedManager];
[iconManager clearIconForAppID:productID];
} else if ([key isEqualToString:kDeleteAccountButton]) {
UIAlertView *confirmDeleteAlert = [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Delete Account?", nil)
message:NSLocalizedString(@"Do you really want to delete this account and all of its data?", nil)
Expand Down Expand Up @@ -718,6 +762,15 @@ - (void)didSettingsChanged:(KKPasscodeSettingsViewController*)viewController
[settingsViewController.tableView reloadData];
}

- (void)iconCleared:(NSNotification *)notification
{
NSString *productID = [[notification userInfo] objectForKey:kIconManagerClearedIconNotificationAppID];
if (productID) {
// reload Icon
[[IconManager sharedManager] iconForAppID:productID];
}
}

#pragma mark -

- (void)saveContext
Expand Down
8 changes: 8 additions & 0 deletions Classes/AppIconView.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ - (void)setProductID:(NSString *)newProductID
if ([newProductID isEqualToString:productID]) return;
if (!productID) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iconDownloaded:) name:IconManagerDownloadedIconNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iconCleared:) name:IconManagerClearedIconNotification object:nil];
}

[newProductID retain];
Expand All @@ -38,6 +39,13 @@ - (void)iconDownloaded:(NSNotification *)notification
}
}

- (void)iconCleared:(NSNotification *)notification
{
if ([[[notification userInfo] objectForKey:kIconManagerClearedIconNotificationAppID] isEqualToString:self.productID]) {
self.image = [UIImage imageNamed:@"GenericApp.png"];
}
}

- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
Expand Down
53 changes: 50 additions & 3 deletions Classes/AppSalesAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@
#import "CurrencyManager.h"
#import "ReportDownloadOperation.h"
#import "ReportDownloadCoordinator.h"
#import "PromoCodeOperation.h"
#import "SSKeychain.h"
#import "ASAccount.h"
#import "SalesViewController.h"
#import "ReviewsViewController.h"
#import "PaymentsViewController.h"
#import "PromoCodesViewController.h"
#import "PromoCodesLicenseViewController.h"

@implementation AppSalesAppDelegate

Expand All @@ -37,6 +42,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
currencyCode, @"CurrencyManagerBaseCurrency",
nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:defaults];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(promoCodeLicenseAgreementLoaded:) name:@"PromoCodeOperationLoadedLicenseAgreementNotification" object:nil];

BOOL iPad = [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad;
if (!iPad) {
Expand Down Expand Up @@ -73,6 +80,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
}

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reportDownloadFailed:) name:ASReportDownloadFailedNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(promoCodeDownloadFailed:) name:ASPromoCodeDownloadFailedNotification object:nil];

if ([launchOptions objectForKey:UIApplicationLaunchOptionsURLKey]) {
[self.accountsViewController performSelector:@selector(downloadReports:) withObject:nil afterDelay:0.0];
Expand Down Expand Up @@ -126,13 +134,33 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger

- (void)loadAccount:(ASAccount *)account
{
UIBarButtonItem *selectAccountButtonItem = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Account", nil) style:UIBarButtonItemStyleBordered target:self action:@selector(selectAccount:)] autorelease];
UIBarButtonItem *selectAccountButtonItem1 = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Account", nil) style:UIBarButtonItemStyleBordered target:self action:@selector(selectAccount:)] autorelease];
UIBarButtonItem *selectAccountButtonItem2 = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Account", nil) style:UIBarButtonItemStyleBordered target:self action:@selector(selectAccount:)] autorelease];
UIBarButtonItem *selectAccountButtonItem3 = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Account", nil) style:UIBarButtonItemStyleBordered target:self action:@selector(selectAccount:)] autorelease];
UIBarButtonItem *selectAccountButtonItem4 = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Account", nil) style:UIBarButtonItemStyleBordered target:self action:@selector(selectAccount:)] autorelease];

SalesViewController *salesVC = [[[SalesViewController alloc] initWithAccount:account] autorelease];
salesVC.navigationItem.leftBarButtonItem = selectAccountButtonItem;
salesVC.navigationItem.leftBarButtonItem = selectAccountButtonItem1;
UINavigationController *salesNavController = [[[UINavigationController alloc] initWithRootViewController:salesVC] autorelease];

self.window.rootViewController = salesNavController;
ReviewsViewController *reviewsVC = [[[ReviewsViewController alloc] initWithAccount:account] autorelease];
reviewsVC.navigationItem.leftBarButtonItem = selectAccountButtonItem2;
UINavigationController *reviewsNavController = [[[UINavigationController alloc] initWithRootViewController:reviewsVC] autorelease];

PaymentsViewController *paymentsVC = [[[PaymentsViewController alloc] initWithAccount:account] autorelease];
paymentsVC.navigationItem.leftBarButtonItem = selectAccountButtonItem3;
UINavigationController *paymentsNavController = [[[UINavigationController alloc] initWithRootViewController:paymentsVC] autorelease];

PromoCodesViewController *promoVC = [[[PromoCodesViewController alloc] initWithAccount:account] autorelease];
promoVC.navigationItem.leftBarButtonItem = selectAccountButtonItem4;
UINavigationController *promoNavController = [[[UINavigationController alloc] initWithRootViewController:promoVC] autorelease];
promoNavController.toolbarHidden = NO;
promoNavController.toolbar.barStyle = UIBarStyleBlackOpaque;

UITabBarController *tabController = [[[UITabBarController alloc] initWithNibName:nil bundle:nil] autorelease];
[tabController setViewControllers:[NSArray arrayWithObjects:salesNavController, reviewsNavController, paymentsNavController, promoNavController, nil]];

self.window.rootViewController = tabController;
}

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
Expand Down Expand Up @@ -256,6 +284,14 @@ - (void)applicationWillTerminate:(UIApplication *)application
[self saveContext];
}

- (void)promoCodeLicenseAgreementLoaded:(NSNotification *)notification
{
NSString *licenseAgreement = [[notification userInfo] objectForKey:@"licenseAgreement"];
PromoCodesLicenseViewController *vc = [[[PromoCodesLicenseViewController alloc] initWithLicenseAgreement:licenseAgreement operation:[notification object]] autorelease];
UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:vc] autorelease];
[self.window.rootViewController presentModalViewController:navController animated:YES];
}

#pragma mark - Core Data

- (void)saveContext
Expand Down Expand Up @@ -352,6 +388,17 @@ - (void)reportDownloadFailed:(NSNotification *)notification
otherButtonTitles:nil] autorelease] show];
}

- (void)promoCodeDownloadFailed:(NSNotification *)notification
{
NSString *errorDescription = [[notification userInfo] objectForKey:kASPromoCodeDownloadFailedErrorDescription];
NSString *alertMessage = [NSString stringWithFormat:@"An error occured while downloading the promo codes (%@).", errorDescription];
[[[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", nil)
message:alertMessage
delegate:nil
cancelButtonTitle:NSLocalizedString(@"OK", nil)
otherButtonTitles:nil] autorelease] show];
}

- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
Expand Down
Loading