Tags loading from server

This commit is contained in:
Patrick Santana 2012-10-08 20:32:23 +02:00
parent cdd3a1c121
commit 5d601d1b6a
14 changed files with 594 additions and 7 deletions

6
.gitmodules vendored
View file

@ -13,3 +13,9 @@
[submodule "Frameworks/ShareKit"] [submodule "Frameworks/ShareKit"]
path = Frameworks/ShareKit path = Frameworks/ShareKit
url = git://github.com/ShareKit/ShareKit url = git://github.com/ShareKit/ShareKit
[submodule "Frameworks/MBProgressHUD"]
path = Frameworks/MBProgressHUD
url = https://github.com/jdg/MBProgressHUD.git
[submodule "Frameworks/TSAlertView"]
path = Frameworks/TSAlertView
url = git://github.com/TomSwift/TSAlertView.git

View file

@ -53,6 +53,18 @@
CD899287161F08AB00026DBB /* OpenPhotoService.m in Sources */ = {isa = PBXBuildFile; fileRef = CD899284161F08AB00026DBB /* OpenPhotoService.m */; }; CD899287161F08AB00026DBB /* OpenPhotoService.m in Sources */ = {isa = PBXBuildFile; fileRef = CD899284161F08AB00026DBB /* OpenPhotoService.m */; };
CD899288161F08AB00026DBB /* OpenPhotoServiceFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = CD899286161F08AB00026DBB /* OpenPhotoServiceFactory.m */; }; CD899288161F08AB00026DBB /* OpenPhotoServiceFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = CD899286161F08AB00026DBB /* OpenPhotoServiceFactory.m */; };
CD8992F2161F4E4F00026DBB /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = CD8992F1161F4E4F00026DBB /* Reachability.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; CD8992F2161F4E4F00026DBB /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = CD8992F1161F4E4F00026DBB /* Reachability.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
CD8D9CBA162341FF00A76811 /* Tag.m in Sources */ = {isa = PBXBuildFile; fileRef = CD8D9CB7162341FF00A76811 /* Tag.m */; };
CD8D9CBE162343E400A76811 /* TagViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = CD8D9CBD162343E400A76811 /* TagViewController.m */; };
CD91157316234A5A0099204B /* MBProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = CD91157216234A5A0099204B /* MBProgressHUD.m */; };
CD91157C16234A820099204B /* TSAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = CD91157516234A820099204B /* TSAlertView.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
CD91157D16234A820099204B /* TSAlertViewBackground.png in Resources */ = {isa = PBXBuildFile; fileRef = CD91157616234A820099204B /* TSAlertViewBackground.png */; };
CD91157E16234A820099204B /* TSAlertViewBackground2.png in Resources */ = {isa = PBXBuildFile; fileRef = CD91157716234A820099204B /* TSAlertViewBackground2.png */; };
CD91157F16234A820099204B /* TSAlertViewButtonBackground_Highlighted.png in Resources */ = {isa = PBXBuildFile; fileRef = CD91157816234A820099204B /* TSAlertViewButtonBackground_Highlighted.png */; };
CD91158016234A820099204B /* TSAlertViewButtonBackground.png in Resources */ = {isa = PBXBuildFile; fileRef = CD91157916234A820099204B /* TSAlertViewButtonBackground.png */; };
CD91158116234A820099204B /* TSAlertViewCancelButtonBackground.png in Resources */ = {isa = PBXBuildFile; fileRef = CD91157A16234A820099204B /* TSAlertViewCancelButtonBackground.png */; };
CD91158216234A820099204B /* TSAlertViewMessageListViewShadow.png in Resources */ = {isa = PBXBuildFile; fileRef = CD91157B16234A820099204B /* TSAlertViewMessageListViewShadow.png */; };
CD91158516234D7D0099204B /* Background.png in Resources */ = {isa = PBXBuildFile; fileRef = CD91158316234D7D0099204B /* Background.png */; };
CD91158616234D7D0099204B /* Background@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = CD91158416234D7D0099204B /* Background@2x.png */; };
CDAFB9D316122262002D6E86 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDAFB9D216122262002D6E86 /* UIKit.framework */; }; CDAFB9D316122262002D6E86 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDAFB9D216122262002D6E86 /* UIKit.framework */; };
CDAFB9D516122262002D6E86 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDAFB9D416122262002D6E86 /* Foundation.framework */; }; CDAFB9D516122262002D6E86 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDAFB9D416122262002D6E86 /* Foundation.framework */; };
CDAFB9D716122262002D6E86 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDAFB9D616122262002D6E86 /* CoreGraphics.framework */; }; CDAFB9D716122262002D6E86 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDAFB9D616122262002D6E86 /* CoreGraphics.framework */; };
@ -415,6 +427,22 @@
CD899286161F08AB00026DBB /* OpenPhotoServiceFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OpenPhotoServiceFactory.m; sourceTree = "<group>"; }; CD899286161F08AB00026DBB /* OpenPhotoServiceFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OpenPhotoServiceFactory.m; sourceTree = "<group>"; };
CD8992F0161F4E4F00026DBB /* Reachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Reachability.h; path = Frameworks/ASIHTTPRequest/External/Reachability/Reachability.h; sourceTree = "<group>"; }; CD8992F0161F4E4F00026DBB /* Reachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Reachability.h; path = Frameworks/ASIHTTPRequest/External/Reachability/Reachability.h; sourceTree = "<group>"; };
CD8992F1161F4E4F00026DBB /* Reachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Reachability.m; path = Frameworks/ASIHTTPRequest/External/Reachability/Reachability.m; sourceTree = "<group>"; }; CD8992F1161F4E4F00026DBB /* Reachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Reachability.m; path = Frameworks/ASIHTTPRequest/External/Reachability/Reachability.m; sourceTree = "<group>"; };
CD8D9CB6162341FF00A76811 /* Tag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Tag.h; sourceTree = "<group>"; };
CD8D9CB7162341FF00A76811 /* Tag.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Tag.m; sourceTree = "<group>"; };
CD8D9CBC162343E400A76811 /* TagViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TagViewController.h; sourceTree = "<group>"; };
CD8D9CBD162343E400A76811 /* TagViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TagViewController.m; sourceTree = "<group>"; };
CD91157116234A5A0099204B /* MBProgressHUD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MBProgressHUD.h; path = Frameworks/MBProgressHUD/MBProgressHUD.h; sourceTree = "<group>"; };
CD91157216234A5A0099204B /* MBProgressHUD.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MBProgressHUD.m; path = Frameworks/MBProgressHUD/MBProgressHUD.m; sourceTree = "<group>"; };
CD91157416234A820099204B /* TSAlertView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TSAlertView.h; path = Frameworks/TSAlertView/TSAlertView/TSAlertView.h; sourceTree = "<group>"; };
CD91157516234A820099204B /* TSAlertView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TSAlertView.m; path = Frameworks/TSAlertView/TSAlertView/TSAlertView.m; sourceTree = "<group>"; };
CD91157616234A820099204B /* TSAlertViewBackground.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = TSAlertViewBackground.png; path = Frameworks/TSAlertView/TSAlertView/TSAlertViewBackground.png; sourceTree = "<group>"; };
CD91157716234A820099204B /* TSAlertViewBackground2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = TSAlertViewBackground2.png; path = Frameworks/TSAlertView/TSAlertView/TSAlertViewBackground2.png; sourceTree = "<group>"; };
CD91157816234A820099204B /* TSAlertViewButtonBackground_Highlighted.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = TSAlertViewButtonBackground_Highlighted.png; path = Frameworks/TSAlertView/TSAlertView/TSAlertViewButtonBackground_Highlighted.png; sourceTree = "<group>"; };
CD91157916234A820099204B /* TSAlertViewButtonBackground.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = TSAlertViewButtonBackground.png; path = Frameworks/TSAlertView/TSAlertView/TSAlertViewButtonBackground.png; sourceTree = "<group>"; };
CD91157A16234A820099204B /* TSAlertViewCancelButtonBackground.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = TSAlertViewCancelButtonBackground.png; path = Frameworks/TSAlertView/TSAlertView/TSAlertViewCancelButtonBackground.png; sourceTree = "<group>"; };
CD91157B16234A820099204B /* TSAlertViewMessageListViewShadow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = TSAlertViewMessageListViewShadow.png; path = Frameworks/TSAlertView/TSAlertView/TSAlertViewMessageListViewShadow.png; sourceTree = "<group>"; };
CD91158316234D7D0099204B /* Background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Background.png; path = images/Background.png; sourceTree = "<group>"; };
CD91158416234D7D0099204B /* Background@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Background@2x.png"; path = "images/Background@2x.png"; sourceTree = "<group>"; };
CDAFB9CE16122262002D6E86 /* Photo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Photo.app; sourceTree = BUILT_PRODUCTS_DIR; }; CDAFB9CE16122262002D6E86 /* Photo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Photo.app; sourceTree = BUILT_PRODUCTS_DIR; };
CDAFB9D216122262002D6E86 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; CDAFB9D216122262002D6E86 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
CDAFB9D416122262002D6E86 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; CDAFB9D416122262002D6E86 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@ -589,6 +617,8 @@
CD4613DD161C7C7C0028619D /* Default-568h@2x.png */, CD4613DD161C7C7C0028619D /* Default-568h@2x.png */,
CD4613DE161C7C7C0028619D /* Default.png */, CD4613DE161C7C7C0028619D /* Default.png */,
CD4613DF161C7C7C0028619D /* Default@2x.png */, CD4613DF161C7C7C0028619D /* Default@2x.png */,
CD91158316234D7D0099204B /* Background.png */,
CD91158416234D7D0099204B /* Background@2x.png */,
); );
name = Images; name = Images;
sourceTree = "<group>"; sourceTree = "<group>";
@ -719,6 +749,39 @@
name = Products; name = Products;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
CD8D9CBF1623446B00A76811 /* TSAlertView */ = {
isa = PBXGroup;
children = (
CD91157416234A820099204B /* TSAlertView.h */,
CD91157516234A820099204B /* TSAlertView.m */,
CD91157616234A820099204B /* TSAlertViewBackground.png */,
CD91157716234A820099204B /* TSAlertViewBackground2.png */,
CD91157816234A820099204B /* TSAlertViewButtonBackground_Highlighted.png */,
CD91157916234A820099204B /* TSAlertViewButtonBackground.png */,
CD91157A16234A820099204B /* TSAlertViewCancelButtonBackground.png */,
CD91157B16234A820099204B /* TSAlertViewMessageListViewShadow.png */,
);
name = TSAlertView;
sourceTree = "<group>";
};
CD8D9CC01623447C00A76811 /* Reachability */ = {
isa = PBXGroup;
children = (
CD8992F0161F4E4F00026DBB /* Reachability.h */,
CD8992F1161F4E4F00026DBB /* Reachability.m */,
);
name = Reachability;
sourceTree = "<group>";
};
CD8D9CC1162344A700A76811 /* MBProgressHUD */ = {
isa = PBXGroup;
children = (
CD91157116234A5A0099204B /* MBProgressHUD.h */,
CD91157216234A5A0099204B /* MBProgressHUD.m */,
);
name = MBProgressHUD;
sourceTree = "<group>";
};
CDAFB9C316122262002D6E86 = { CDAFB9C316122262002D6E86 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@ -741,8 +804,9 @@
CDAFB9D116122262002D6E86 /* Frameworks */ = { CDAFB9D116122262002D6E86 /* Frameworks */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
CD8992F0161F4E4F00026DBB /* Reachability.h */, CD8D9CC1162344A700A76811 /* MBProgressHUD */,
CD8992F1161F4E4F00026DBB /* Reachability.m */, CD8D9CC01623447C00A76811 /* Reachability */,
CD8D9CBF1623446B00A76811 /* TSAlertView */,
CD76435F161EFE4C00E0B657 /* ShareKit */, CD76435F161EFE4C00E0B657 /* ShareKit */,
CD7642B3161EDF0D00E0B657 /* TestFlight */, CD7642B3161EDF0D00E0B657 /* TestFlight */,
CD76428A161ED9E600E0B657 /* ASIHTTPRequest */, CD76428A161ED9E600E0B657 /* ASIHTTPRequest */,
@ -823,6 +887,10 @@
CDE0B11E1622DB1A00CB4FBC /* Tag */ = { CDE0B11E1622DB1A00CB4FBC /* Tag */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
CD8D9CB6162341FF00A76811 /* Tag.h */,
CD8D9CB7162341FF00A76811 /* Tag.m */,
CD8D9CBC162343E400A76811 /* TagViewController.h */,
CD8D9CBD162343E400A76811 /* TagViewController.m */,
); );
name = Tag; name = Tag;
path = ..; path = ..;
@ -1192,6 +1260,14 @@
CD7642CC161EE1F600E0B657 /* register-button-login@2x.png in Resources */, CD7642CC161EE1F600E0B657 /* register-button-login@2x.png in Resources */,
CD7642CD161EE1F600E0B657 /* register-input-server.png in Resources */, CD7642CD161EE1F600E0B657 /* register-input-server.png in Resources */,
CD7642CE161EE1F600E0B657 /* register-input-server@2x.png in Resources */, CD7642CE161EE1F600E0B657 /* register-input-server@2x.png in Resources */,
CD91157D16234A820099204B /* TSAlertViewBackground.png in Resources */,
CD91157E16234A820099204B /* TSAlertViewBackground2.png in Resources */,
CD91157F16234A820099204B /* TSAlertViewButtonBackground_Highlighted.png in Resources */,
CD91158016234A820099204B /* TSAlertViewButtonBackground.png in Resources */,
CD91158116234A820099204B /* TSAlertViewCancelButtonBackground.png in Resources */,
CD91158216234A820099204B /* TSAlertViewMessageListViewShadow.png in Resources */,
CD91158516234D7D0099204B /* Background.png in Resources */,
CD91158616234D7D0099204B /* Background@2x.png in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -1253,6 +1329,10 @@
CD899287161F08AB00026DBB /* OpenPhotoService.m in Sources */, CD899287161F08AB00026DBB /* OpenPhotoService.m in Sources */,
CD899288161F08AB00026DBB /* OpenPhotoServiceFactory.m in Sources */, CD899288161F08AB00026DBB /* OpenPhotoServiceFactory.m in Sources */,
CD8992F2161F4E4F00026DBB /* Reachability.m in Sources */, CD8992F2161F4E4F00026DBB /* Reachability.m in Sources */,
CD8D9CBA162341FF00A76811 /* Tag.m in Sources */,
CD8D9CBE162343E400A76811 /* TagViewController.m in Sources */,
CD91157316234A5A0099204B /* MBProgressHUD.m in Sources */,
CD91157C16234A820099204B /* TSAlertView.m in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

View file

@ -20,6 +20,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "AuthenticationService.h" #import "AuthenticationService.h"
#import "TagViewController.h"
@interface MenuViewController : UITableViewController @interface MenuViewController : UITableViewController

View file

@ -32,6 +32,11 @@
selector:@selector(eventHandler:) selector:@selector(eventHandler:)
name:kNotificationNeededsUpdate name:kNotificationNeededsUpdate
object:nil ]; object:nil ];
self.tableView.backgroundColor = [[[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"Background.png"]] autorelease];
// color separator
self.tableView.separatorColor = UIColorFromRGB(0xC8BEA0);
} }
return self; return self;
} }
@ -244,9 +249,11 @@
AuthenticationViewController *controller = [[AuthenticationViewController alloc]initWithNibName:@"AuthenticationViewController" bundle:nil]; AuthenticationViewController *controller = [[AuthenticationViewController alloc]initWithNibName:@"AuthenticationViewController" bundle:nil];
[cc presentViewController:controller animated:YES completion:nil]; [cc presentViewController:controller animated:YES completion:nil];
} }
}else if ( indexPath.section == 1 && indexPath.row == 4){ }else if ( indexPath.section == 0 && indexPath.row == 3){
// Tags // Tags
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:[[TagViewController alloc] init]];
nav.title=[tableView cellForRowAtIndexPath:indexPath].textLabel.text;
controller.centerController = nav;
} }
if ([cc respondsToSelector:@selector(tableView)]) { if ([cc respondsToSelector:@selector(tableView)]) {

View file

@ -55,4 +55,10 @@
+ (BOOL) isMessageValid:(NSDictionary *)response; + (BOOL) isMessageValid:(NSDictionary *)response;
// get pictures to be used in the gallery
- (NSArray*) loadGallery:(int) pageSize onPage:(int) page;
// get pictures by tag
- (NSArray*) loadGallery:(int) pageSize withTag:(NSString*) tag onPage:(int) page;
@end @end

View file

@ -311,6 +311,19 @@
signatureProvider:nil] autorelease]; signatureProvider:nil] autorelease];
} }
// get 25 pictures
- (NSArray*) loadGallery:(int) pageSize onPage:(int) page
{
return nil;
}
// get pictures by tag
-(NSArray*) loadGallery:(int) pageSize withTag:(NSString*) tag onPage:(int) page
{
return nil;
}
+ (BOOL) isMessageValid:(NSDictionary *)response{ + (BOOL) isMessageValid:(NSDictionary *)response{
// get the content of code // get the content of code
NSString* code = [response objectForKey:@"code"]; NSString* code = [response objectForKey:@"code"];

View file

@ -24,11 +24,11 @@
+ (OpenPhotoService*) createOpenPhotoService{ + (OpenPhotoService*) createOpenPhotoService{
NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
return [[[OpenPhotoService alloc] initForServer:[standardUserDefaults valueForKey:kOpenPhotoServer] return [[OpenPhotoService alloc] initForServer:[standardUserDefaults valueForKey:kOpenPhotoServer]
oAuthKey:[standardUserDefaults valueForKey:kAuthenticationOAuthToken] oAuthKey:[standardUserDefaults valueForKey:kAuthenticationOAuthToken]
oAuthSecret:[standardUserDefaults valueForKey:kAuthenticationOAuthSecret] oAuthSecret:[standardUserDefaults valueForKey:kAuthenticationOAuthSecret]
consumerKey:[standardUserDefaults valueForKey:kAuthenticationConsumerKey] consumerKey:[standardUserDefaults valueForKey:kAuthenticationConsumerKey]
consumerSecret:[standardUserDefaults valueForKey:kAuthenticationConsumerSecret]] autorelease] ; consumerSecret:[standardUserDefaults valueForKey:kAuthenticationConsumerSecret]] ;
} }
@end @end

View file

@ -16,7 +16,6 @@
{ {
self = [super initWithStyle:style]; self = [super initWithStyle:style];
if (self) { if (self) {
// Custom initialization
} }
return self; return self;
} }
@ -45,6 +44,13 @@
else { else {
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Sync" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(toggleRightView)]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Sync" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(toggleRightView)];
} }
// Custom initialization
self.tableView.backgroundColor = [[[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"Background.png"]] autorelease];
// color separator
self.tableView.separatorColor = UIColorFromRGB(0xC8BEA0);
} }
- (void)viewDidUnload - (void)viewDidUnload

BIN
Photo/images/Background.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

29
Tag.h Normal file
View file

@ -0,0 +1,29 @@
//
// Tag.h
// OpenPhoto
//
// Created by Patrick Santana on 11/08/11.
// Copyright 2012 OpenPhoto
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
@interface Tag : NSObject
// constructor with tag name
- (id)initWithTagName:(NSString*) name Quantity:(NSInteger) qtd;
@property (nonatomic, copy) NSString *tagName;
@property (nonatomic) NSInteger quantity;
@property (nonatomic) BOOL selected;
@end

39
Tag.m Normal file
View file

@ -0,0 +1,39 @@
//
// Tag.m
// OpenPhoto
//
// Created by Patrick Santana on 11/08/11.
// Copyright 2012 OpenPhoto
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#import "Tag.h"
@implementation Tag
@synthesize tagName=_tagName,quantity=_quantity,selected=_selected;
- (id)initWithTagName:(NSString*) name Quantity:(NSInteger) qtd{
self = [super init];
if (self) {
// Initialization code here.
self.tagName=name;
self.quantity = qtd;
// by default no tag is selected. This is used for READ ONLY proposal
self.selected = NO;
}
return self;
}
@end

35
TagViewController.h Normal file
View file

@ -0,0 +1,35 @@
//
// TagViewController.h
// OpenPhoto
//
// Created by Patrick Santana on 11/08/11.
// Copyright 2012 OpenPhoto
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#import "Tag.h"
//#import "GalleryViewController.h"
#import "TSAlertView.h"
#import "OpenPhotoServiceFactory.h"
#import "MBProgressHUD.h"
#import "PhotoAlertView.h"
@interface TagViewController : UITableViewController<TSAlertViewDelegate, UINavigationControllerDelegate>
@property (nonatomic, strong) NSMutableArray *tags;
-(void) setReadOnly;
-(NSArray*) getSelectedTags;
-(NSString *) getSelectedTagsInJsonFormat;
@end

365
TagViewController.m Normal file
View file

@ -0,0 +1,365 @@
//
// TagViewController.m
// OpenPhoto
//
// Created by Patrick Santana on 11/08/11.
// Copyright 2012 OpenPhoto
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#import "TagViewController.h"
@interface TagViewController()
- (void) loadTags;
@property (nonatomic) BOOL readOnly;
// to avoid multiples loading
@property (nonatomic) BOOL isLoading;
@end
@implementation TagViewController
@synthesize tags = _tags;
@synthesize readOnly = _readOnly;
@synthesize isLoading = _isLoading;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
self.tableView.backgroundColor = [[[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"Background.png"]] autorelease];
// initialize the object tags
self.tags = [NSMutableArray array];
// set the read only by default as NO
self.readOnly = NO;
// color separator
self.tableView.separatorColor = UIColorFromRGB(0xC8BEA0);
// is loading tags
self.isLoading = NO;
}
return self;
}
- (void) setReadOnly
{
self.readOnly = YES;
}
// this method return only the tag's name.
- (NSArray*) getSelectedTags
{
NSMutableArray *array = [NSMutableArray array];
for (id object in self.tags) {
Tag *tag = (Tag*) object;
if (tag.selected == YES){
[array addObject:tag.tagName];
}
}
return array;
}
// this method return the tag's name but in the format to send to openphoto server
- (NSString *) getSelectedTagsInJsonFormat
{
NSMutableString *result = [NSMutableString string];
NSArray *array = [self getSelectedTags];
int counter = 1;
if (array != nil && [array count]>0){
for (id string in array) {
[result appendFormat:@"%@",string];
// add the ,
if ( counter < [array count]){
[result appendFormat:@", "];
}
counter++;
}
}
return result;
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Menu" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(toggleLeftView)];
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)];
}
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// load all tags
[self loadTags];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}
/*
-(void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// Uncomment the following line to preserve selection between presentations.
self.clearsSelectionOnViewWillAppear = NO;
// wanna add new tag name
if (self.readOnly == YES){
UIBarButtonItem *addNewTagButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addNewTag)];
self.navigationItem.rightBarButtonItem = addNewTagButton;
[addNewTagButton release];
if ([self.tags count] == 0 ){
// just load in case there is no tags.
// we do that to keep the past selection
[self loadTags];
}
}else{
UIBarButtonItem *refreshButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(loadTags)];
self.navigationItem.rightBarButtonItem = refreshButton;
[refreshButton release];
// load all tags
[self loadTags];
}
}
*/
-(void) addNewTag
{
#ifdef DEVELOPMENT_ENABLED
NSLog(@"Adding new tag");
#endif
TSAlertView* av = [[TSAlertView alloc] initWithTitle:@"Enter new tag name" message:nil delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK",nil];
av.style = TSAlertViewStyleInput;
[av show];
[av release];
}
// after animation
- (void) alertView: (TSAlertView *) alertView didDismissWithButtonIndex: (NSInteger) buttonIndex
{
// cancel
if( buttonIndex == 0 || alertView.inputTextField.text == nil || alertView.inputTextField.text.length==0)
return;
// add the new tag in the list and select it
Tag *newTag = [[Tag alloc]initWithTagName:alertView.inputTextField.text Quantity:0];
newTag.selected = YES;
[self.tags addObject:newTag];
// we don't need it anymore.
[newTag release];
[self.tableView reloadData];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return self.tags.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
}
NSUInteger row = [indexPath row];
Tag *tag = [self.tags objectAtIndex:row];
cell.textLabel.text=tag.tagName;
if (self.readOnly == NO){
// details quantity
cell.detailTextLabel.text=[NSString stringWithFormat:@"%d", tag.quantity];
cell.detailTextLabel.textColor = UIColorFromRGB(0xE6501E);
cell.accessoryType = UITableViewCellAccessoryNone;
}else{
// check if it selected or not
if(tag.selected == YES)
cell.accessoryType = UITableViewCellAccessoryCheckmark;
else
cell.accessoryType = UITableViewCellAccessoryNone;
}
return cell;
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// get the tag
NSUInteger row = [indexPath row];
Tag *tag = [self.tags objectAtIndex:row];
if (tag.quantity >0 && self.readOnly == NO){
/*
// open the gallery with a tag that contains at least one picture.
GalleryViewController *galleryController = [[GalleryViewController alloc]initWithTagName:[tag.tagName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[self.navigationController pushViewController:galleryController animated:YES];
[galleryController release];
*/
}
if (self.readOnly == YES){
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSUInteger row = [indexPath row];
Tag *tag = [self.tags objectAtIndex:row];
if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {
cell.accessoryType = UITableViewCellAccessoryNone;
tag.selected = NO;
} else {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
tag.selected = YES;
}
}
}
#pragma mark
#pragma mark - Methods to get Tags via json
- (void) loadTags
{
if (self.isLoading == NO){
self.isLoading = YES;
// if there isn't netwok
/*
if ( [AppDelegate internetActive] == NO ){
// problem with internet, show message to user
PhotoAlertView *alert = [[PhotoAlertView alloc] initWithMessage:@"Failed! Check your internet connection" duration:5000];
[alert showAlert];
self.isLoading = NO;
}else {
*/
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.labelText = @"Loading";
dispatch_queue_t loadTags = dispatch_queue_create("loadTags", NULL);
dispatch_async(loadTags, ^{
// call the method and get the details
@try {
// get factory for OpenPhoto Service
OpenPhotoService *service = [OpenPhotoServiceFactory createOpenPhotoService];
NSArray *result = [service getTags];
dispatch_async(dispatch_get_main_queue(), ^{
[self.tags removeAllObjects];
if ([result class] != [NSNull class]) {
// Loop through each entry in the dictionary and create an array Tags
for (NSDictionary *tagDetails in result){
// tag name
NSString *name = [tagDetails objectForKey:@"id"];
name = [name stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
// how many images
NSString *qtd = [tagDetails objectForKey:@"count"];
// create a tag and add to the list
Tag *tag = [[Tag alloc]initWithTagName:name Quantity:[qtd integerValue]];
tag.selected = NO;
[self.tags addObject:tag];
// we don't need it anymore.
[tag release];
}}
[self.tableView reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES];
self.isLoading = NO;
});
}@catch (NSException *exception) {
dispatch_async(dispatch_get_main_queue(), ^{
[MBProgressHUD hideHUDForView:self.navigationController.view animated:YES];
PhotoAlertView *alert = [[PhotoAlertView alloc] initWithMessage:exception.description duration:5000];
[alert showAlert];
self.isLoading = NO;
});
}
});
dispatch_release(loadTags);
//}
}
}
@end