fixed Sync

This commit is contained in:
Patrick Santana 2013-03-06 13:29:33 +01:00
parent bcc049f369
commit 7d001c9d16
9 changed files with 139 additions and 139 deletions

View file

@ -50,16 +50,25 @@
{
[super viewDidLoad];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Menu" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(toggleLeftView)];
// menu
UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *leftButtonImage = [UIImage imageNamed:@"button-navigation-menu.png"] ;
[leftButton setImage:leftButtonImage forState:UIControlStateNormal];
leftButton.frame = CGRectMake(0, 0, leftButtonImage.size.width, leftButtonImage.size.height);
[leftButton addTarget:self.viewDeckController action:@selector(toggleLeftView) forControlEvents:UIControlEventTouchUpInside];
if ([self.navigationItem respondsToSelector:@selector(rightBarButtonItems)]) {
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:
[[UIBarButtonItem alloc] initWithTitle:@"Sync" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(toggleRightView)],
nil];
}
else {
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Sync" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(toggleRightView)];
}
UIBarButtonItem *customLeftButton = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
self.navigationItem.leftBarButtonItem = customLeftButton;
// camera
UIButton *buttonRight = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *buttonRightImage = [UIImage imageNamed:@"button-navigation-camera.png"] ;
[buttonRight setImage:buttonRightImage forState:UIControlStateNormal];
buttonRight.frame = CGRectMake(0, 0, buttonRightImage.size.width, buttonRightImage.size.height);
[buttonRight addTarget:self action:@selector(capturePhoto) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *customRightButton = [[UIBarButtonItem alloc] initWithCustomView:buttonRight];
self.navigationItem.rightBarButtonItem = customRightButton;
// title
self.navigationItem.title = NSLocalizedString(@"Albums", @"Menu - title for Albums");
@ -83,6 +92,8 @@
[self.navigationController.navigationBar insertSubview:imageView atIndex:0];
}
}
}

View file

@ -41,16 +41,25 @@
{
[super viewDidLoad];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Menu" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(toggleLeftView)];
// menu
UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *leftButtonImage = [UIImage imageNamed:@"button-navigation-menu.png"] ;
[leftButton setImage:leftButtonImage forState:UIControlStateNormal];
leftButton.frame = CGRectMake(0, 0, leftButtonImage.size.width, leftButtonImage.size.height);
[leftButton addTarget:self.viewDeckController action:@selector(toggleLeftView) forControlEvents:UIControlEventTouchUpInside];
if ([self.navigationItem respondsToSelector:@selector(rightBarButtonItems)]) {
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:
[[UIBarButtonItem alloc] initWithTitle:@"Sync" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(toggleRightView)],
nil];
}
else {
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Sync" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(toggleRightView)];
}
UIBarButtonItem *customLeftButton = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
self.navigationItem.leftBarButtonItem = customLeftButton;
// camera
UIButton *buttonRight = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *buttonRightImage = [UIImage imageNamed:@"button-navigation-camera.png"] ;
[buttonRight setImage:buttonRightImage forState:UIControlStateNormal];
buttonRight.frame = CGRectMake(0, 0, buttonRightImage.size.width, buttonRightImage.size.height);
[buttonRight addTarget:self action:@selector(capturePhoto) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *customRightButton = [[UIBarButtonItem alloc] initWithCustomView:buttonRight];
self.navigationItem.rightBarButtonItem = customRightButton;
// image for the navigator
if([[UINavigationBar class] respondsToSelector:@selector(appearance)]){
@ -65,7 +74,7 @@
[self.navigationController.navigationBar insertSubview:imageView atIndex:0];
}
}
self.view.backgroundColor = UIColorFromRGB(0xFFCC00);
}

View file

@ -128,8 +128,7 @@
[self.navigationController.navigationBar insertSubview:imageView atIndex:0];
}
}
// check if needs to update the profile
[self needsUpdateProfileDetails];
}
@ -177,12 +176,6 @@
// title
self.navigationItem.title = @"";
UIImage *backgroundImage = [UIImage imageNamed:@"Background.png"];
// color separator
self.tableView.backgroundColor = [[UIColor alloc] initWithPatternImage:backgroundImage];
self.tableView.separatorColor = UIColorFromRGB(0xC8BEA0);
}

View file

@ -18,7 +18,6 @@
// limitations under the License.
//
#import <UIKit/UIKit.h>
#import "AuthenticationService.h"
#import "TagViewController.h"
@ -30,6 +29,15 @@
#import "GalleryViewController.h"
#import "DisplayUtilities.h"
@interface MenuViewController : UITableViewController
// for settings
#import "IASKAppSettingsViewController.h"
#import "IASKSettingsStoreFile.h"
@interface MenuViewController : UITableViewController<IASKSettingsDelegate>
{
OpenPhotoIASKAppSettingsViewController *appSettingsViewController;
}
@property (nonatomic, strong) OpenPhotoIASKAppSettingsViewController *appSettingsViewController;
@end

View file

@ -23,6 +23,7 @@
#import "IIViewDeckController.h"
@implementation MenuViewController
@synthesize appSettingsViewController;
- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle
{
@ -73,10 +74,10 @@
{
if (section == 0){
// your photos menu
return 4;
return 5;
}else{
// settings
return 3;
return 2;
}
}
@ -86,7 +87,7 @@
return NSLocalizedString(@"Your Photos", @"Used to title your photos in Menu");
}else{
// settings
return NSLocalizedString(@"Settings", @"Used to title Settings in Menu");
return NSLocalizedString(@"PREFERENCES", @"Used to title Preferences in Menu");
}
}
@ -104,7 +105,7 @@
// your photos menu
switch (indexPath.row) {
case 0:
cell.textLabel.text = NSLocalizedString(@"Home", @"Menu - title for Home");
cell.textLabel.text = NSLocalizedString(@"Latest Activity", @"Menu - title for Home");
break;
case 1:
cell.textLabel.text = NSLocalizedString(@"Gallery", @"Menu - title for Gallery");
@ -115,6 +116,9 @@
case 3:
cell.textLabel.text = NSLocalizedString(@"Tags", @"Menu - title for Tags");
break;
case 4:
cell.textLabel.text = NSLocalizedString(@"Upload & Sync", @"Menu - title for Upload & Sync");
break;
default:
cell.textLabel.text = @"not defined";
break;
@ -122,19 +126,10 @@
}else{
switch (indexPath.row) {
case 0:
cell.textLabel.text = NSLocalizedString(@"Account", @"Menu - title for Account");
cell.textLabel.text = NSLocalizedString(@"My Account", @"Menu - title for Account");
break;
case 1:
cell.textLabel.text = ([AuthenticationService isLogged] ? NSLocalizedString(@"Log out", @"Menu - title for Log out") : NSLocalizedString(@"Login", @"Menu - title for Login"));
break;
case 2:
cell.textLabel.text = NSLocalizedString(@"Upgrade", @"Menu - title for Upgrade");
break;
case 3:
cell.textLabel.text = NSLocalizedString(@"Properties", @"Menu - title for Properties");
break;
case 4:
cell.textLabel.text = NSLocalizedString(@"Contact Us", @"Menu - title for Contact us");
cell.textLabel.text = NSLocalizedString(@"Settings", @"Menu - title for Settings");
break;
default:
cell.textLabel.text = @"not defined";
@ -159,7 +154,7 @@
cc.navigationItem.title = [tableView cellForRowAtIndexPath:indexPath].textLabel.text;
if ( indexPath.section == 0 && indexPath.row == 0){
// Home
// Latest activity
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:[[HomeTableViewController alloc] init]];
nav.title=[tableView cellForRowAtIndexPath:indexPath].textLabel.text;
controller.centerController = nav;
@ -178,24 +173,19 @@
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:[[TagViewController alloc] init]];
nav.title=[tableView cellForRowAtIndexPath:indexPath].textLabel.text;
controller.centerController = nav;
}else if ( indexPath.section == 0 && indexPath.row == 4){
// Upload & Sync
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:[[SyncViewController alloc] init]];
nav.title=[tableView cellForRowAtIndexPath:indexPath].textLabel.text;
controller.centerController = nav;
}else if ( indexPath.section == 1 && indexPath.row == 0){
// Account
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:[[AccountViewController alloc] init]];
// Account - Profile
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:[[ProfileViewController alloc] init]];
nav.title=[tableView cellForRowAtIndexPath:indexPath].textLabel.text;
controller.centerController = nav;
}else if ( indexPath.section == 1 && indexPath.row == 1){
// Log out
if ([AuthenticationService isLogged]){
// do the log out
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Are you sure?", @"Message when logging out") message:nil delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel",@"General") otherButtonTitles:NSLocalizedString(@"Log out",@"General"),nil] ;
[alert show];
}else{
// open the login
[self openLoginViewController];
}
}else if ( indexPath.section == 1 && indexPath.row == 2){
// Profile
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:[[ProfileViewController alloc] init]];
// Settings
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:self.appSettingsViewController];
nav.title=[tableView cellForRowAtIndexPath:indexPath].textLabel.text;
controller.centerController = nav;
}
@ -210,22 +200,6 @@
}
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1){
#ifdef DEVELOPMENT_ENABLED
NSLog(@"Log out");
#endif
AuthenticationService *service = [[AuthenticationService alloc]init];
[service logout];
[self.tableView reloadData];
// open the login
[self openLoginViewController];
}
}
- (void) openLoginViewController
{
// open the login
@ -247,6 +221,37 @@
}
}
- (OpenPhotoIASKAppSettingsViewController*)appSettingsViewController {
if (!appSettingsViewController) {
appSettingsViewController = [[OpenPhotoIASKAppSettingsViewController alloc] initWithNibName:@"IASKAppSettingsView" bundle:nil];
appSettingsViewController.delegate = self;
[appSettingsViewController setShowCreditsFooter:NO];
appSettingsViewController.showDoneButton = NO;
}
return appSettingsViewController;
}
- (void)settingsViewController:(IASKAppSettingsViewController*)sender buttonTappedForKey:(NSString*)key {
if ([key isEqualToString:@"CleanCache"]){
[Timeline deleteAllTimelineInManagedObjectContext:[SharedAppDelegate managedObjectContext]];
[Synced deleteAllSyncedPhotosInManagedObjectContext:[SharedAppDelegate managedObjectContext]];
NSError *saveError = nil;
if (![[SharedAppDelegate managedObjectContext] save:&saveError]){
NSLog(@"Error to save context = %@",[saveError localizedDescription]);
}
//remove cache
SDImageCache *imageCache = [SDImageCache sharedImageCache];
[imageCache clearMemory];
[imageCache clearDisk];
[imageCache cleanDisk];
}
}
- (void)settingsViewControllerDidEnd:(IASKAppSettingsViewController*)sender {
[self dismissModalViewControllerAnimated:YES];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];

View file

@ -33,6 +33,16 @@
[super viewWillAppear:animated];
// menu
UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *leftButtonImage = [UIImage imageNamed:@"button-navigation-menu.png"] ;
[leftButton setImage:leftButtonImage forState:UIControlStateNormal];
leftButton.frame = CGRectMake(0, 0, leftButtonImage.size.width, leftButtonImage.size.height);
[leftButton addTarget:self.viewDeckController action:@selector(toggleLeftView) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *customLeftButton = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
self.navigationItem.leftBarButtonItem = customLeftButton;
// add log out
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *buttonImage = [UIImage imageNamed:@"logout.png"] ;

View file

@ -8,9 +8,6 @@
#import "WebService.h"
#import "OpenPhotoIASKAppSettingsViewController.h"
#import "IASKAppSettingsViewController.h"
#import "IASKSettingsStoreFile.h"
// image cache
#import <SDWebImage/UIImageView+WebCache.h>
@ -27,10 +24,7 @@
#import <QuartzCore/QuartzCore.h>
#import "WebViewController.h"
@interface ProfileViewController : GAITrackedViewController <UIAlertViewDelegate, IASKSettingsDelegate>
{
OpenPhotoIASKAppSettingsViewController *appSettingsViewController;
}
@interface ProfileViewController : GAITrackedViewController <UIAlertViewDelegate>
@property (nonatomic, weak) IBOutlet UILabel *labelAlbums;
@property (nonatomic, weak) IBOutlet UILabel *labelPhotos;
@ -47,6 +41,5 @@
- (IBAction)openFeaturesList:(id)sender;
@property (nonatomic, weak) IBOutlet UIButton *buttonFeatureList;
@property (nonatomic, retain) OpenPhotoIASKAppSettingsViewController *appSettingsViewController;
@end

View file

@ -15,8 +15,6 @@
@implementation ProfileViewController
@synthesize appSettingsViewController;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
@ -45,36 +43,6 @@
return self;
}
- (OpenPhotoIASKAppSettingsViewController*)appSettingsViewController {
if (!appSettingsViewController) {
appSettingsViewController = [[OpenPhotoIASKAppSettingsViewController alloc] initWithNibName:@"IASKAppSettingsView" bundle:nil];
appSettingsViewController.delegate = self;
}
return appSettingsViewController;
}
- (void)settingsViewController:(IASKAppSettingsViewController*)sender buttonTappedForKey:(NSString*)key {
if ([key isEqualToString:@"CleanCache"]){
[Timeline deleteAllTimelineInManagedObjectContext:[SharedAppDelegate managedObjectContext]];
[Synced deleteAllSyncedPhotosInManagedObjectContext:[SharedAppDelegate managedObjectContext]];
NSError *saveError = nil;
if (![[SharedAppDelegate managedObjectContext] save:&saveError]){
NSLog(@"Error to save context = %@",[saveError localizedDescription]);
}
//remove cache
SDImageCache *imageCache = [SDImageCache sharedImageCache];
[imageCache clearMemory];
[imageCache clearDisk];
[imageCache cleanDisk];
}
}
- (void)settingsViewControllerDidEnd:(IASKAppSettingsViewController*)sender {
[self dismissModalViewControllerAnimated:YES];
}
- (void)viewDidLoad
{
[super viewDidLoad];
@ -92,15 +60,16 @@
[super viewWillAppear:animated];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
UIButton *buttonSettings = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *buttonImageSettings = [UIImage imageNamed:@"settingsbtn.png"] ;
[buttonSettings setImage:buttonImageSettings forState:UIControlStateNormal];
buttonSettings.frame = CGRectMake(0, 0, buttonImageSettings.size.width, buttonImageSettings.size.height);
[buttonSettings addTarget:self action:@selector(settingsButton) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *customBarItemRefresh = [[UIBarButtonItem alloc] initWithCustomView:buttonSettings];
self.navigationItem.leftBarButtonItem = customBarItemRefresh;
// menu
UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *leftButtonImage = [UIImage imageNamed:@"button-navigation-menu.png"] ;
[leftButton setImage:leftButtonImage forState:UIControlStateNormal];
leftButton.frame = CGRectMake(0, 0, leftButtonImage.size.width, leftButtonImage.size.height);
[leftButton addTarget:self.viewDeckController action:@selector(toggleLeftView) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *customLeftButton = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
self.navigationItem.leftBarButtonItem = customLeftButton;
// add log out
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *buttonImage = [UIImage imageNamed:@"logout.png"] ;
@ -115,13 +84,6 @@
[self loadUserDetails];
}
- (void) settingsButton
{
[self.appSettingsViewController setShowCreditsFooter:NO];
self.appSettingsViewController.showDoneButton = NO;
[self.navigationController pushViewController:self.appSettingsViewController animated:YES];
}
- (void) logoutButton{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Log out. Are you sure?" message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Log out",nil] ;
[alert show];

View file

@ -106,16 +106,25 @@
{
[super viewDidLoad];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Menu" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(toggleLeftView)];
// menu
UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *leftButtonImage = [UIImage imageNamed:@"button-navigation-menu.png"] ;
[leftButton setImage:leftButtonImage forState:UIControlStateNormal];
leftButton.frame = CGRectMake(0, 0, leftButtonImage.size.width, leftButtonImage.size.height);
[leftButton addTarget:self.viewDeckController action:@selector(toggleLeftView) forControlEvents:UIControlEventTouchUpInside];
if ([self.navigationItem respondsToSelector:@selector(rightBarButtonItems)]) {
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:
[[UIBarButtonItem alloc] initWithTitle:@"Sync" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(toggleRightView)],
nil];
}
else {
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Sync" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(toggleRightView)];
}
UIBarButtonItem *customLeftButton = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
self.navigationItem.leftBarButtonItem = customLeftButton;
// camera
UIButton *buttonRight = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *buttonRightImage = [UIImage imageNamed:@"button-navigation-camera.png"] ;
[buttonRight setImage:buttonRightImage forState:UIControlStateNormal];
buttonRight.frame = CGRectMake(0, 0, buttonRightImage.size.width, buttonRightImage.size.height);
[buttonRight addTarget:self action:@selector(capturePhoto) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *customRightButton = [[UIBarButtonItem alloc] initWithCustomView:buttonRight];
self.navigationItem.rightBarButtonItem = customRightButton;
// title
self.navigationItem.title = NSLocalizedString(@"Tags", @"Menu - title for Tags");