Merge branch 'new_ui' of git.linphone.org:linphone-iphone into new_ui

This commit is contained in:
Jehan Monnier 2012-09-17 11:23:55 +02:00
commit bacdc8f270
10 changed files with 84 additions and 90 deletions

View file

@ -24,10 +24,11 @@
#import "ChatRoomTableViewController.h"
#import "HPGrowingTextView.h"
#import "ChatModel.h"
#import "ImagePickerViewController.h"
#include "linphonecore.h"
@interface ChatRoomViewController : UIViewController<HPGrowingTextViewDelegate, UICompositeViewDelegate, NSURLConnectionDataDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate> {
@interface ChatRoomViewController : UIViewController<HPGrowingTextViewDelegate, UICompositeViewDelegate, NSURLConnectionDataDelegate, ImagePickerDelegate> {
@private
LinphoneChatRoom *chatRoom;
NSURLConnection* uploadContext;

View file

@ -19,10 +19,12 @@
#import "ChatRoomViewController.h"
#import "PhoneMainView.h"
#import "DTActionSheet.h"
#import <MobileCoreServices/UTCoreTypes.h>
#import <NinePatch.h>
#import <AssetsLibrary/ALAssetsLibrary.h>
#import "DTActionSheet.h"
@implementation ChatRoomViewController
@ -411,45 +413,24 @@ static void message_status(LinphoneChatMessage* msg,LinphoneChatMessageState sta
- (IBAction)onPictureClick:(id)event {
[messageField resignFirstResponder];
DTActionSheet *sheet = [[[DTActionSheet alloc] initWithTitle:NSLocalizedString(@"Select picture source",nil)] autorelease];
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
[sheet addButtonWithTitle:NSLocalizedString(@"Camera",nil) block:^(){
UIImagePickerController *mediaUI = [[UIImagePickerController alloc] init];
mediaUI.sourceType = UIImagePickerControllerSourceTypeCamera;
[ImagePickerViewController promptSelectSource:^(UIImagePickerControllerSourceType type) {
UICompositeViewDescription *description = [[[ImagePickerViewController compositeViewDescription] copy] autorelease];
description.tabBar = nil; // Disable default tarbar
description.tabBarEnabled = false;
ImagePickerViewController *controller = DYNAMIC_CAST([[PhoneMainView instance] changeCurrentView:description push:TRUE], ImagePickerViewController);
if(controller != nil) {
controller.sourceType = type;
// Displays a control that allows the user to choose picture or
// movie capture, if both are available:
mediaUI.mediaTypes =
[UIImagePickerController availableMediaTypesForSourceType:
UIImagePickerControllerSourceTypeCamera];
controller.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:type];
// Hides the controls for moving & scaling pictures, or for
// trimming movies. To instead show the controls, use YES.
mediaUI.allowsEditing = NO;
mediaUI.delegate = self;
[self presentModalViewController: mediaUI animated: YES];
}];
}
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
[sheet addButtonWithTitle:NSLocalizedString(@"Photo library",nil) block:^(){
UIImagePickerController *mediaUI = [[UIImagePickerController alloc] init];
mediaUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
// Displays saved pictures and movies, if both are available, from the
// Camera Roll album.
mediaUI.mediaTypes =
[UIImagePickerController availableMediaTypesForSourceType:
UIImagePickerControllerSourceTypePhotoLibrary];
// Hides the controls for moving & scaling pictures, or for
// trimming movies. To instead show the controls, use YES.
mediaUI.allowsEditing = NO;
mediaUI.delegate = self;
[self presentModalViewController: mediaUI animated: YES];
}];
}
[sheet addCancelButtonWithTitle:NSLocalizedString(@"Cancel",nil)];
[sheet showInView:self.view];
controller.allowsEditing = NO;
controller.imagePickerDelegate = self;
}
}];
}
- (IBAction)onTransferCancelClick:(id)event {
@ -663,36 +644,16 @@ static void message_status(LinphoneChatMessage* msg,LinphoneChatMessageState sta
return [NSURLConnection connectionWithRequest:(NSURLRequest *)request delegate:self];
}
#pragma mark UIImagePickerControllerDelegate
- (void)imagePickerControllerDidCancel:(UIImagePickerController *) picker {
[self dismissModalViewControllerAnimated: YES];
[picker release];
}
#pragma mark ImpagePickerDelegate
- (void)imagePickerController: (UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info {
NSURL *imageURL = [info valueForKey: UIImagePickerControllerReferenceURL];
UIImage* imageToUse = (UIImage *) [info objectForKey: UIImagePickerControllerOriginalImage];
NSString* imageName;
if (imageURL) {
// extract id from asset-url ex: assets-library://asset/asset.JPG?id=1645156-6151-1513&ext=JPG
NSArray *parameters = [[imageURL query] componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"=&"]];
for (int i = 0; i < [parameters count]; i=i+2) {
if ([(NSString*)[parameters objectAtIndex:i] isEqualToString:@"id"]) {
imageName=[NSString stringWithFormat:@"%@.jpg",(NSString*)[parameters objectAtIndex:i+1]];
}
}
} else {
// must be "unique"
imageName=[NSString stringWithFormat:@"%i.jpg",[imageToUse hash]];
}
uploadContext = [self uploadImage:imageToUse Named: imageName];
- (void)imagePickerDelegateImage:(UIImage*)image {
NSString *imageName = [NSString stringWithFormat:@"%i.jpg", [image hash]];
uploadContext = [self uploadImage:image Named: imageName];
[self startUpload];
[picker.presentingViewController dismissModalViewControllerAnimated: YES];
[picker release];
}
#pragma mark - Keyboard Event Functions
- (void)keyboardWillHide:(NSNotification *)notif {

View file

@ -19,15 +19,17 @@
#import "UICompositeViewController.h"
@protocol ContactDetailsImagePickerDelegate <NSObject>
@protocol ImagePickerDelegate <NSObject>
- (void)changeContactImage:(UIImage*)image;
- (void)imagePickerDelegateImage:(UIImage*)image;
@end
@interface ContactDetailsImagePickerController : UIImagePickerController <UICompositeViewDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate> {
@interface ImagePickerViewController : UIImagePickerController <UICompositeViewDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate> {
}
@property (nonatomic, retain) id<ContactDetailsImagePickerDelegate> imagePickerDelegate;
@property (nonatomic, retain) id<ImagePickerDelegate> imagePickerDelegate;
+ (void)promptSelectSource:(void (^)(UIImagePickerControllerSourceType))block;
@end

View file

@ -17,10 +17,11 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#import "ContactDetailsImagePickerController.h"
#import "ImagePickerViewController.h"
#import "PhoneMainView.h"
#import "DTActionSheet.h"
@implementation ContactDetailsImagePickerController
@implementation ImagePickerViewController
@synthesize imagePickerDelegate;
@ -31,8 +32,8 @@ static UICompositeViewDescription *compositeDescription = nil;
+ (UICompositeViewDescription *)compositeViewDescription {
if(compositeDescription == nil) {
compositeDescription = [[UICompositeViewDescription alloc] init:@"ContactDetailsImage"
content:@"ContactDetailsImagePickerController"
compositeDescription = [[UICompositeViewDescription alloc] init:@"ImagePicker"
content:@"ImagePickerViewController"
stateBar:nil
stateBarEnabled:false
tabBar:@"UIMainBar"
@ -56,11 +57,28 @@ static UICompositeViewDescription *compositeDescription = nil;
#pragma mark -
- (void)dismiss {
if([[[PhoneMainView instance] currentView] equal:[ContactDetailsImagePickerController compositeViewDescription]]) {
if([[[PhoneMainView instance] currentView] equal:[ImagePickerViewController compositeViewDescription]]) {
[[PhoneMainView instance] popCurrentView];
}
}
+ (void)promptSelectSource:(void (^)(UIImagePickerControllerSourceType))block {
DTActionSheet *sheet = [[[DTActionSheet alloc] initWithTitle:NSLocalizedString(@"Select picture source",nil)] autorelease];
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
[sheet addButtonWithTitle:NSLocalizedString(@"Camera",nil) block:^(){
block(UIImagePickerControllerSourceTypeCamera);
}];
}
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
[sheet addButtonWithTitle:NSLocalizedString(@"Photo library",nil) block:^(){
block(UIImagePickerControllerSourceTypePhotoLibrary);
}];
}
[sheet addCancelButtonWithTitle:NSLocalizedString(@"Cancel",nil)];
[sheet showInView:[PhoneMainView instance].view];
}
#pragma mark - UIImagePickerControllerDelegate Functions
@ -69,8 +87,8 @@ static UICompositeViewDescription *compositeDescription = nil;
if(image == nil) {
image = [info objectForKey:UIImagePickerControllerOriginalImage];
}
if(image != nil) {
[imagePickerDelegate changeContactImage:image];
if(image != nil && imagePickerDelegate != nil) {
[imagePickerDelegate imagePickerDelegateImage:image];
}
[self dismiss];
}

View file

@ -30,6 +30,7 @@
@synthesize backButton;
@synthesize image;
#pragma mark - UICompositeViewDelegate Functions
static UICompositeViewDescription *compositeDescription = nil;
@ -49,6 +50,7 @@ static UICompositeViewDescription *compositeDescription = nil;
return compositeDescription;
}
#pragma mark - Property Functions
- (void)setImage:(UIImage *)aimage {

View file

@ -20,10 +20,10 @@
#import <UIKit/UIKit.h>
#import <AddressBook/AddressBook.h>
#import "ContactDetailsImagePickerController.h"
#import "ImagePickerViewController.h"
#import "ContactDetailsDelegate.h"
@interface UIContactDetailsHeader : UIViewController<UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate, ContactDetailsImagePickerDelegate> {
@interface UIContactDetailsHeader : UIViewController<UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate, ImagePickerDelegate> {
@private
NSArray *propertyList;
BOOL editing;

View file

@ -243,19 +243,28 @@
- (IBAction)onAvatarClick:(id)event {
if(self.isEditing) {
ContactDetailsImagePickerController *controller = DYNAMIC_CAST([[PhoneMainView instance] changeCurrentView:[ContactDetailsImagePickerController compositeViewDescription] push:TRUE], ContactDetailsImagePickerController);
if(controller != nil) {
[controller setAllowsEditing:TRUE];
[controller setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[controller setImagePickerDelegate:self];
}
[ImagePickerViewController promptSelectSource:^(UIImagePickerControllerSourceType type) {
ImagePickerViewController *controller = DYNAMIC_CAST([[PhoneMainView instance] changeCurrentView:[ImagePickerViewController compositeViewDescription] push:TRUE], ImagePickerViewController);
if(controller != nil) {
controller.sourceType = type;
// Displays a control that allows the user to choose picture or
// movie capture, if both are available:
controller.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:type];
// Hides the controls for moving & scaling pictures, or for
// trimming movies. To instead show the controls, use YES.
controller.allowsEditing = NO;
controller.imagePickerDelegate = self;
}
}];
}
}
#pragma mark - ContactDetailsImagePickerDelegate Functions
- (void)changeContactImage:(UIImage*)image {
- (void)imagePickerDelegateImage:(UIImage*)image {
NSError* error = NULL;
if(!ABPersonRemoveImageData(contact, (CFErrorRef*)error)) {
[LinphoneLogger log:LinphoneLoggerLog format:@"Can't add entry: %@", [error localizedDescription]];

View file

@ -30,7 +30,7 @@
#import "ContactsViewController.h"
#import "ContactDetailsViewController.h"
#import "ContactDetailsLabelViewController.h"
#import "ContactDetailsImagePickerController.h"
#import "ImagePickerViewController.h"
#import "HistoryViewController.h"
#import "HistoryDetailsViewController.h"
#import "InCallViewController.h"

View file

@ -17,7 +17,8 @@ show_local=0
enabled=1
size=qvga
display_filter_auto_rotate=1
automatically_initiate=0
automatically_accept=0
[net]
firewall_policy=0

View file

@ -655,8 +655,8 @@
D377BBFA15A19DA6002B696B /* video_on_disabled.png in Resources */ = {isa = PBXBuildFile; fileRef = D377BBF915A19DA6002B696B /* video_on_disabled.png */; };
D378906515AC373B00BD776C /* ContactDetailsLabelViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D378906315AC373B00BD776C /* ContactDetailsLabelViewController.m */; };
D378906615AC373B00BD776C /* ContactDetailsLabelViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D378906315AC373B00BD776C /* ContactDetailsLabelViewController.m */; };
D378AB2A15DCDB4A0098505D /* ContactDetailsImagePickerController.m in Sources */ = {isa = PBXBuildFile; fileRef = D378AB2915DCDB490098505D /* ContactDetailsImagePickerController.m */; };
D378AB2B15DCDB4A0098505D /* ContactDetailsImagePickerController.m in Sources */ = {isa = PBXBuildFile; fileRef = D378AB2915DCDB490098505D /* ContactDetailsImagePickerController.m */; };
D378AB2A15DCDB4A0098505D /* ImagePickerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D378AB2915DCDB490098505D /* ImagePickerViewController.m */; };
D378AB2B15DCDB4A0098505D /* ImagePickerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D378AB2915DCDB490098505D /* ImagePickerViewController.m */; };
D37B96B715A1A6F20005CCD2 /* call_state_delete_default.png in Resources */ = {isa = PBXBuildFile; fileRef = D37B96B515A1A6F20005CCD2 /* call_state_delete_default.png */; };
D37B96B915A1A6F20005CCD2 /* call_state_delete_over.png in Resources */ = {isa = PBXBuildFile; fileRef = D37B96B615A1A6F20005CCD2 /* call_state_delete_over.png */; };
D37C638E15AAD251009D0BAC /* contact_number_over.png in Resources */ = {isa = PBXBuildFile; fileRef = D37C638C15AAD251009D0BAC /* contact_number_over.png */; };
@ -1707,8 +1707,8 @@
D377BBF915A19DA6002B696B /* video_on_disabled.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = video_on_disabled.png; path = Resources/video_on_disabled.png; sourceTree = "<group>"; };
D378906215AC373B00BD776C /* ContactDetailsLabelViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContactDetailsLabelViewController.h; sourceTree = "<group>"; };
D378906315AC373B00BD776C /* ContactDetailsLabelViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContactDetailsLabelViewController.m; sourceTree = "<group>"; };
D378AB2815DCDB480098505D /* ContactDetailsImagePickerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContactDetailsImagePickerController.h; sourceTree = "<group>"; };
D378AB2915DCDB490098505D /* ContactDetailsImagePickerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContactDetailsImagePickerController.m; sourceTree = "<group>"; };
D378AB2815DCDB480098505D /* ImagePickerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImagePickerViewController.h; sourceTree = "<group>"; };
D378AB2915DCDB490098505D /* ImagePickerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImagePickerViewController.m; sourceTree = "<group>"; };
D37B96B515A1A6F20005CCD2 /* call_state_delete_default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = call_state_delete_default.png; path = Resources/call_state_delete_default.png; sourceTree = "<group>"; };
D37B96B615A1A6F20005CCD2 /* call_state_delete_over.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = call_state_delete_over.png; path = Resources/call_state_delete_over.png; sourceTree = "<group>"; };
D37C638C15AAD251009D0BAC /* contact_number_over.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = contact_number_over.png; path = Resources/contact_number_over.png; sourceTree = "<group>"; };
@ -2236,8 +2236,6 @@
22E0A81F111C44E100B04932 /* ConsoleViewController.m */,
22E0A81E111C44E100B04932 /* ConsoleViewController.xib */,
D30BBD1215D3EFEB000F93DD /* ContactDetailsDelegate.h */,
D378AB2815DCDB480098505D /* ContactDetailsImagePickerController.h */,
D378AB2915DCDB490098505D /* ContactDetailsImagePickerController.m */,
D378906215AC373B00BD776C /* ContactDetailsLabelViewController.h */,
D378906315AC373B00BD776C /* ContactDetailsLabelViewController.m */,
D38187B815FE341B00C3EDCA /* ContactDetailsLabelViewController.xib */,
@ -2266,6 +2264,8 @@
D3ED3EB515873928006C0DE4 /* HistoryViewController.h */,
D3ED3EB615873929006C0DE4 /* HistoryViewController.m */,
D38187D415FE346B00C3EDCA /* HistoryViewController.xib */,
D378AB2815DCDB480098505D /* ImagePickerViewController.h */,
D378AB2915DCDB490098505D /* ImagePickerViewController.m */,
22405EFD1601C19000B92522 /* ImageViewController.h */,
22405EFE1601C19100B92522 /* ImageViewController.m */,
D37EE11016035793003608A6 /* ImageViewController.xib */,
@ -4458,7 +4458,7 @@
D380800215C2894A005BE9BC /* IASKTextField.m in Sources */,
D380800515C28A7A005BE9BC /* UILinphone.m in Sources */,
D380801315C299D0005BE9BC /* ColorSpaceUtilites.m in Sources */,
D378AB2A15DCDB4A0098505D /* ContactDetailsImagePickerController.m in Sources */,
D378AB2A15DCDB4A0098505D /* ImagePickerViewController.m in Sources */,
22405F001601C19200B92522 /* ImageViewController.m in Sources */,
D3ED40191602172200BF332B /* HPGrowingTextView.m in Sources */,
D3ED401B1602172200BF332B /* HPTextViewInternal.m in Sources */,
@ -4552,7 +4552,7 @@
D380800315C2894A005BE9BC /* IASKTextField.m in Sources */,
D380800615C28A7A005BE9BC /* UILinphone.m in Sources */,
D380801415C299D0005BE9BC /* ColorSpaceUtilites.m in Sources */,
D378AB2B15DCDB4A0098505D /* ContactDetailsImagePickerController.m in Sources */,
D378AB2B15DCDB4A0098505D /* ImagePickerViewController.m in Sources */,
22405F011601C19200B92522 /* ImageViewController.m in Sources */,
D3ED401A1602172200BF332B /* HPGrowingTextView.m in Sources */,
D3ED401C1602172200BF332B /* HPTextViewInternal.m in Sources */,