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

Subscriptions #65

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
40 changes: 34 additions & 6 deletions AppSales.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
/* Begin PBXBuildFile section */
4509175A23D030130028AF83 /* DarkModeCheck.m in Sources */ = {isa = PBXBuildFile; fileRef = 4509175923D030130028AF83 /* DarkModeCheck.m */; };
45C2B2232460296200C84374 /* csv.css in Resources */ = {isa = PBXBuildFile; fileRef = 45C2B2212460296200C84374 /* csv.css */; };
621713D428509E1F00E5E366 /* UINavigationBar+FixAppearance.m in Sources */ = {isa = PBXBuildFile; fileRef = 621713D328509E1F00E5E366 /* UINavigationBar+FixAppearance.m */; };
621D32432531C98C00D0EE97 /* UIViewController+Alert.m in Sources */ = {isa = PBXBuildFile; fileRef = 621D32422531C98C00D0EE97 /* UIViewController+Alert.m */; };
623021492965AFFC001AF90D /* Subscription.m in Sources */ = {isa = PBXBuildFile; fileRef = 623021482965AFFC001AF90D /* Subscription.m */; };
625ADAB72852028C005C28AD /* UIToolbar+FixAppearance.m in Sources */ = {isa = PBXBuildFile; fileRef = 625ADAB62852028C005C28AD /* UIToolbar+FixAppearance.m */; };
62CDEC88296728C600DD1667 /* ReportRecalculateCacheOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 62CDEC87296728C600DD1667 /* ReportRecalculateCacheOperation.m */; };
62E09F1B19E693F3002917FE /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 62E09F1A19E693F3002917FE /* Images.xcassets */; };
6D81575414CB3C2B005E8F3F /* KKKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D81574914CB3C2B005E8F3F /* KKKeychain.m */; };
6D81575514CB3C2B005E8F3F /* KKPasscodeLock.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D81574B14CB3C2B005E8F3F /* KKPasscodeLock.m */; };
Expand Down Expand Up @@ -129,8 +133,18 @@
4509175823D030130028AF83 /* DarkModeCheck.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DarkModeCheck.h; sourceTree = "<group>"; };
4509175923D030130028AF83 /* DarkModeCheck.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DarkModeCheck.m; sourceTree = "<group>"; };
45C2B2212460296200C84374 /* csv.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = csv.css; sourceTree = "<group>"; };
620255FA2B8F70DA00F01EAE /* AppSales 9.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "AppSales 9.xcdatamodel"; sourceTree = "<group>"; };
621713D228509E1F00E5E366 /* UINavigationBar+FixAppearance.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UINavigationBar+FixAppearance.h"; sourceTree = "<group>"; };
621713D328509E1F00E5E366 /* UINavigationBar+FixAppearance.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UINavigationBar+FixAppearance.m"; sourceTree = "<group>"; };
621D32412531C98C00D0EE97 /* UIViewController+Alert.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIViewController+Alert.h"; sourceTree = "<group>"; };
621D32422531C98C00D0EE97 /* UIViewController+Alert.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+Alert.m"; sourceTree = "<group>"; };
623021482965AFFC001AF90D /* Subscription.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Subscription.m; sourceTree = "<group>"; };
6230214A2965B005001AF90D /* Subscription.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Subscription.h; sourceTree = "<group>"; };
625ADAB52852028C005C28AD /* UIToolbar+FixAppearance.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIToolbar+FixAppearance.h"; sourceTree = "<group>"; };
625ADAB62852028C005C28AD /* UIToolbar+FixAppearance.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIToolbar+FixAppearance.m"; sourceTree = "<group>"; };
62CDEC852965B5BD00DD1667 /* AppSales 8.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "AppSales 8.xcdatamodel"; sourceTree = "<group>"; };
62CDEC86296728A600DD1667 /* ReportRecalculateCacheOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ReportRecalculateCacheOperation.h; sourceTree = "<group>"; };
62CDEC87296728C600DD1667 /* ReportRecalculateCacheOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ReportRecalculateCacheOperation.m; sourceTree = "<group>"; };
62E09F1A19E693F3002917FE /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = AppSales/Images.xcassets; sourceTree = "<group>"; };
6D81574814CB3C2B005E8F3F /* KKKeychain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KKKeychain.h; sourceTree = "<group>"; };
6D81574914CB3C2B005E8F3F /* KKKeychain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KKKeychain.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -372,6 +386,8 @@
7F1499CF13BE311600D89064 /* ReportDownloadOperation.m */,
7F1B153513C8029600243AA3 /* ReportImportOperation.h */,
7F1B153613C8029600243AA3 /* ReportImportOperation.m */,
62CDEC86296728A600DD1667 /* ReportRecalculateCacheOperation.h */,
62CDEC87296728C600DD1667 /* ReportRecalculateCacheOperation.m */,
);
name = "Report Download";
sourceTree = "<group>";
Expand Down Expand Up @@ -540,6 +556,8 @@
7F1B14F213C51AC900243AA3 /* CurrencyManager.m */,
7F398ED013DF21F1004BEC44 /* Transaction.h */,
7F398ED113DF21F2004BEC44 /* Transaction.m */,
6230214A2965B005001AF90D /* Subscription.h */,
623021482965AFFC001AF90D /* Subscription.m */,
7F0B8A6C13F7B941006E9151 /* PromoCode.h */,
7F0B8A6D13F7B941006E9151 /* PromoCode.m */,
);
Expand Down Expand Up @@ -636,6 +654,10 @@
7F454F9F13D5C24F00AE47D1 /* UIColor+Extensions.m */,
7FAEB66F13E6D3AB00750788 /* UIImage+Tinting.h */,
7FAEB67013E6D3AB00750788 /* UIImage+Tinting.m */,
621713D228509E1F00E5E366 /* UINavigationBar+FixAppearance.h */,
621713D328509E1F00E5E366 /* UINavigationBar+FixAppearance.m */,
625ADAB52852028C005C28AD /* UIToolbar+FixAppearance.h */,
625ADAB62852028C005C28AD /* UIToolbar+FixAppearance.m */,
DA4984451C12C85F009BFC8F /* UIViewController+Orientation.h */,
DA4984461C12C85F009BFC8F /* UIViewController+Orientation.m */,
621D32412531C98C00D0EE97 /* UIViewController+Alert.h */,
Expand Down Expand Up @@ -861,7 +883,7 @@
7F709D1E13BC98860008DBAD /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1200;
LastUpgradeCheck = 1330;
ORGANIZATIONNAME = "omz:software";
TargetAttributes = {
7F709D2613BC98860008DBAD = {
Expand Down Expand Up @@ -974,11 +996,13 @@
7FA2C58413E0370B00BA9875 /* ReviewListViewController.m in Sources */,
7F26DF9113E13319001D0F33 /* ReviewDetailViewController.m in Sources */,
DA3DF5FF1EF1D92900CBEF87 /* DeveloperResponse.m in Sources */,
623021492965AFFC001AF90D /* Subscription.m in Sources */,
DA4AC6A01EF9AB8F003CAF4D /* FilterTableViewCell.m in Sources */,
7F24E70713E40A0D0056EA97 /* DashboardViewController.m in Sources */,
DA4984391C129F95009BFC8F /* ioapi.c in Sources */,
DAFC5F931C16BFAD00261B16 /* Review.m in Sources */,
DA7D58F41C234D9700A3EA12 /* ReviewCell.m in Sources */,
621713D428509E1F00E5E366 /* UINavigationBar+FixAppearance.m in Sources */,
7F7F4A3F13E50A52006C6651 /* PaymentsViewController.m in Sources */,
7F7F4A4213E51A99006C6651 /* YearView.m in Sources */,
7FAEB66613E6D0EE00750788 /* BadgedCell.m in Sources */,
Expand All @@ -989,11 +1013,13 @@
7F7F1D0F13F6455A00F18143 /* PromoCodesAppViewController.m in Sources */,
7FA3EA9913F76E3500C80C07 /* DownloadStepOperation.m in Sources */,
DA49843C1C129F95009BFC8F /* zip.c in Sources */,
62CDEC88296728C600DD1667 /* ReportRecalculateCacheOperation.m in Sources */,
DA4AC6AC1EFB051F003CAF4D /* FilterDetailTableViewCell.m in Sources */,
DA4AC6B61EFB54D6003CAF4D /* ReviewDownloadOperation.m in Sources */,
7FA3EA9D13F77DF000C80C07 /* MultiOperation.m in Sources */,
7F0B8A6913F77F95006E9151 /* PromoCodeOperation.m in Sources */,
DAF2D89D203B5F8100F3C0CF /* ASProgressHUD.m in Sources */,
625ADAB72852028C005C28AD /* UIToolbar+FixAppearance.m in Sources */,
7F0B8A6E13F7B941006E9151 /* PromoCode.m in Sources */,
DA49843D1C129F95009BFC8F /* ZIPArchive.mm in Sources */,
DAFC5F801C16B29D00261B16 /* ReviewsViewController.m in Sources */,
Expand Down Expand Up @@ -1059,7 +1085,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-licucore";
SDKROOT = iphoneos;
Expand Down Expand Up @@ -1102,7 +1128,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
OTHER_LDFLAGS = "-licucore";
SDKROOT = iphoneos;
Expand All @@ -1120,7 +1146,7 @@
GCC_PREFIX_HEADER = "OtherSources/AppSales-Prefix.pch";
HEADER_SEARCH_PATHS = "";
INFOPLIST_FILE = "Support/AppSales-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = "de.omzsoftware.${PRODUCT_NAME:identifier}";
PRODUCT_NAME = AppSalesMobile;
Expand All @@ -1140,8 +1166,8 @@
GCC_PREFIX_HEADER = "OtherSources/AppSales-Prefix.pch";
HEADER_SEARCH_PATHS = "";
INFOPLIST_FILE = "Support/AppSales-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
PRODUCT_BUNDLE_IDENTIFIER = "de.omzsoftware.${PRODUCT_NAME:identifier}";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
PRODUCT_NAME = AppSalesMobile;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -1176,6 +1202,8 @@
7F709D3F13BC98860008DBAD /* AppSales.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
620255FA2B8F70DA00F01EAE /* AppSales 9.xcdatamodel */,
62CDEC852965B5BD00DD1667 /* AppSales 8.xcdatamodel */,
DA1BC9E62456123100A36B92 /* AppSales 7.xcdatamodel */,
DA3DF5F01EF1D6CA00CBEF87 /* AppSales 6.xcdatamodel */,
AE778A141E2EB6F200DAA6B7 /* AppSales 5.xcdatamodel */,
Expand All @@ -1184,7 +1212,7 @@
7F0B8A6B13F7B776006E9151 /* AppSales 2.xcdatamodel */,
7F709D4013BC98860008DBAD /* AppSales.xcdatamodel */,
);
currentVersion = DA1BC9E62456123100A36B92 /* AppSales 7.xcdatamodel */;
currentVersion = 620255FA2B8F70DA00F01EAE /* AppSales 9.xcdatamodel */;
path = AppSales.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
Expand Down
1 change: 1 addition & 0 deletions Classes/ASAccount.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
@property (nonatomic, strong) NSSet *paymentReports;
@property (nonatomic, strong) NSNumber *reportsBadge;
@property (nonatomic, strong) NSNumber *paymentsBadge;
@property (nonatomic, assign) BOOL downloadEnabled;

- (void)deletePassword;
- (void)deleteAccessToken;
Expand Down
2 changes: 1 addition & 1 deletion Classes/ASAccount.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

@implementation ASAccount

@dynamic username, providerID, vendorID, title, sortIndex, dailyReports, weeklyReports, products, payments, paymentReports, reportsBadge, paymentsBadge;
@dynamic username, providerID, vendorID, title, sortIndex, dailyReports, weeklyReports, products, payments, paymentReports, reportsBadge, paymentsBadge, downloadEnabled;
@synthesize isDownloadingReports, downloadStatus, downloadProgress;

- (NSString *)password {
Expand Down
4 changes: 3 additions & 1 deletion Classes/AccountStatusView.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ - (instancetype)initWithFrame:(CGRect)frame account:(ASAccount *)anAccount {

- (void)updateStatus {
if (account.isDownloadingReports) {
[activityIndicator startAnimating];
if (account.downloadEnabled) {
[activityIndicator startAnimating];
}
statusLabel.text = account.downloadStatus;
} else {
[activityIndicator stopAnimating];
Expand Down
44 changes: 39 additions & 5 deletions Classes/AccountsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@
#define kPasscodeLockButton @"PasscodeLockButton"
#define kImportReportsButton @"ImportReportsButton"
#define kExportReportsButton @"ExportReportsButton"
#define kReCalculateSalesCacheButton @"RecalculateSalesCacheButton"
#define kDeleteAccountButton @"DeleteAccount"
#define kAccountTitle @"title"
#define kKeychainServiceIdentifier @"iTunesConnect"
#define kAccountRefreshEnabled @"AccountRefreshEnabled"


@implementation AccountsViewController
Expand Down Expand Up @@ -141,6 +143,8 @@ - (void)downloadReports:(id)sender {
} else if ((account.vendorID == nil) || (account.vendorID.length == 0)) {
[[UIViewController topViewController] displayAlertWithTitle:NSLocalizedString(@"Vendor ID Missing", nil)
message:[NSString stringWithFormat:NSLocalizedString(@"You have not entered a vendor ID for the account \"%@\". Please go to the account's settings and fill in the missing information.", nil), account.displayName]];
} else if (account.downloadEnabled == FALSE) {
[[ReportDownloadCoordinator sharedReportDownloadCoordinator] skipReportsForAccount:account];
} else {
[[ReportDownloadCoordinator sharedReportDownloadCoordinator] downloadReportsForAccount:account];
}
Expand Down Expand Up @@ -368,11 +372,15 @@ - (void)editAccount:(ASAccount *)account {
titleField.placeholder = NSLocalizedString(@"optional", nil);

FieldSpecifier *loginSubsectionField = [FieldSpecifier subsectionFieldWithSections:[self accountSectionsFor:account] key:@"iTunesConnect" title:NSLocalizedString(@"iTunes Connect Login", nil)];
FieldSectionSpecifier *titleSection = [FieldSectionSpecifier sectionWithFields:@[titleField, loginSubsectionField] title:nil description:nil];

FieldSpecifier *enabledField = [FieldSpecifier switchFieldWithKey:kAccountRefreshEnabled title:NSLocalizedString(@"Refresh Enabled", nil) defaultValue:account.downloadEnabled];
FieldSectionSpecifier *titleSection = [FieldSectionSpecifier sectionWithFields:@[titleField, loginSubsectionField, enabledField] title:nil description:nil];

FieldSpecifier *importButtonField = [FieldSpecifier buttonFieldWithKey:kImportReportsButton title:NSLocalizedString(@"Import Reports...", nil)];
FieldSpecifier *exportButtonField = [FieldSpecifier buttonFieldWithKey:kExportReportsButton title:NSLocalizedString(@"Export Reports...", nil)];
FieldSectionSpecifier *importExportSection = [FieldSectionSpecifier sectionWithFields:@[importButtonField, exportButtonField] title:nil description:nil];

FieldSpecifier *recalculateButtonField = [FieldSpecifier buttonFieldWithKey:kReCalculateSalesCacheButton title:NSLocalizedString(@"Recalculate Sales Cache...", nil)];
FieldSectionSpecifier *recalculateSection = [FieldSectionSpecifier sectionWithFields:@[recalculateButtonField] title:nil description:nil];

NSMutableArray *productFields = [[NSMutableArray alloc] init];

Expand Down Expand Up @@ -441,7 +449,7 @@ - (void)editAccount:(ASAccount *)account {
FieldSpecifier *deleteAccountButtonField = [FieldSpecifier buttonFieldWithKey:kDeleteAccountButton title:NSLocalizedString(@"Delete Account...", nil)];
FieldSectionSpecifier *deleteAccountSection = [FieldSectionSpecifier sectionWithFields:@[deleteAccountButtonField] title:nil description:nil];

FieldEditorViewController *editAccountViewController = [[FieldEditorViewController alloc] initWithFieldSections:@[titleSection, importExportSection, manageProductsSection, deleteAccountSection] title:NSLocalizedString(@"Account Details",nil)];
FieldEditorViewController *editAccountViewController = [[FieldEditorViewController alloc] initWithFieldSections:@[titleSection, importExportSection, recalculateSection, manageProductsSection, deleteAccountSection] title:NSLocalizedString(@"Account Details",nil)];
editAccountViewController.doneButtonTitle = nil;
editAccountViewController.delegate = self;
editAccountViewController.editorIdentifier = kEditAccountEditorIdentifier;
Expand Down Expand Up @@ -565,6 +573,7 @@ - (void)fieldEditor:(FieldEditorViewController *)editor didFinishEditingWithValu
account.sortIndex = @(time(NULL));
account.password = password;
account.accessToken = accessToken;
account.downloadEnabled = [returnValues[kAccountRefreshEnabled] boolValue];
}
else if ([editor.editorIdentifier isEqualToString:kEditAccountEditorIdentifier]) {
ASAccount *account = (ASAccount *)editor.context;
Expand All @@ -575,6 +584,7 @@ - (void)fieldEditor:(FieldEditorViewController *)editor didFinishEditingWithValu
account.vendorID = vendorID;
account.password = password;
account.accessToken = accessToken;
account.downloadEnabled = [returnValues[kAccountRefreshEnabled] boolValue];

NSMutableDictionary *productsByID = [NSMutableDictionary dictionary];
for (Product *product in self.selectedAccount.products) {
Expand Down Expand Up @@ -659,8 +669,32 @@ - (void)fieldEditor:(FieldEditorViewController *)editor pressedButtonWithKey:(NS
[self presentViewController:confirmImportAlert animated:YES completion:nil];
}
}
} else if ([key isEqualToString:kExportReportsButton]) {
[self doExport];
} else if ([key isEqualToString:kExportReportsButton]) {
[self doExport];
} else if ([key isEqualToString:kReCalculateSalesCacheButton]) {
ASAccount *account = (ASAccount *)editor.context;
if (account.isDownloadingReports) {
[[UIViewController topViewController] displayAlertWithTitle:nil
message:NSLocalizedString(@"AppSales is already importing reports for this account. Please wait until the current import has finished.", nil)];
} else {
UIAlertController *confirmImportAlert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Begin recalculating sales cache?", nil)
message:NSLocalizedString(@"Do you want to start recalculating the sales cache for this account?", nil)
preferredStyle:UIAlertControllerStyleAlert];

[confirmImportAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil)
style:UIAlertActionStyleCancel
handler:nil]];

[confirmImportAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Start", nil)
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {

[[ReportDownloadCoordinator sharedReportDownloadCoordinator] recalculateSalesCacheForAccount:self.selectedAccount];
[self.navigationController popViewControllerAnimated:YES];
}]];

[self presentViewController:confirmImportAlert animated:YES completion:nil];
}
} else if ([key hasPrefix:@"product.appstore."]) {
NSString *productID = [key substringFromIndex:[@"product.appstore." length]];
NSString *appStoreURLString = [NSString stringWithFormat:@"https://apps.apple.com/app/id%@", productID];
Expand Down
7 changes: 7 additions & 0 deletions Classes/AppSalesAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,19 @@
#import "PromoCodesViewController.h"
#import "PromoCodesLicenseViewController.h"
#import "UIViewController+Alert.h"
#import "UINavigationBar+FixAppearance.h"
#import "UIToolbar+FixAppearance.h"

@implementation AppSalesAppDelegate

@synthesize window, accountsViewController, accountsPopover;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if (@available(iOS 13.0, *)) {
[UINavigationBar fixNavigationBarAppearance];
[UIToolbar fixToolbarAppearance];
}

[[KKPasscodeLock sharedLock] setDefaultSettings];
[[KKPasscodeLock sharedLock] setEraseOption:NO];

Expand Down
Loading