mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
handle avatar
This commit is contained in:
parent
f43bed58e6
commit
ec0d6c8b3d
20 changed files with 156 additions and 99 deletions
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
#import "PhoneMainView.h"
|
||||
#import "UILinphone.h"
|
||||
#import "Utils/FileTransferDelegate.h"
|
||||
#import <MobileCoreServices/UTCoreTypes.h>
|
||||
#import "UIChatRoomCell.h"
|
||||
|
||||
@implementation ChatRoomViewController
|
||||
|
|
@ -461,56 +460,8 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
|
|||
|
||||
- (IBAction)onPictureClick:(id)event {
|
||||
[messageField resignFirstResponder];
|
||||
|
||||
void (^block)(UIImagePickerControllerSourceType) = ^(UIImagePickerControllerSourceType type) {
|
||||
UICompositeViewDescription *description = [ImagePickerViewController compositeViewDescription];
|
||||
ImagePickerViewController *controller;
|
||||
if ([LinphoneManager runningOnIpad]) {
|
||||
controller =
|
||||
DYNAMIC_CAST([[PhoneMainView instance].mainViewController getCachedController:description.content],
|
||||
ImagePickerViewController);
|
||||
} else {
|
||||
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:
|
||||
controller.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeImage];
|
||||
|
||||
// Hides the controls for moving & scaling pictures, or for
|
||||
// trimming movies. To instead show the controls, use YES.
|
||||
controller.allowsEditing = NO;
|
||||
controller.imagePickerDelegate = self;
|
||||
|
||||
if ([LinphoneManager runningOnIpad]) {
|
||||
CGRect rect = [self.messageView convertRect:[pictureButton frame] toView:self.view];
|
||||
[controller.popoverController presentPopoverFromRect:rect
|
||||
inView:self.view
|
||||
permittedArrowDirections:UIPopoverArrowDirectionAny
|
||||
animated:FALSE];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
DTActionSheet *sheet = [[DTActionSheet alloc] initWithTitle:NSLocalizedString(@"Select picture source", nil)];
|
||||
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) block:nil];
|
||||
|
||||
[sheet showInView:[PhoneMainView instance].view];
|
||||
CGRect rect = [self.messageView convertRect:[pictureButton frame] toView:self.view];
|
||||
[ImagePickerViewController SelectImageFromDevice:self atPosition:rect inView:self.view];
|
||||
}
|
||||
|
||||
#pragma mark ChatRoomDelegate
|
||||
|
|
|
|||
|
|
@ -36,4 +36,8 @@
|
|||
@property(nonatomic) BOOL allowsEditing;
|
||||
@property(nonatomic, readonly) UIPopoverController *popoverController;
|
||||
|
||||
+ (void)SelectImageFromDevice:(id<ImagePickerDelegate>)delegate
|
||||
atPosition:(CGRect)ipadPopoverPosition
|
||||
inView:(UIView *)view;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import <MobileCoreServices/UTCoreTypes.h>
|
||||
|
||||
#import "ImagePickerViewController.h"
|
||||
#import "PhoneMainView.h"
|
||||
|
||||
|
|
@ -161,4 +163,57 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
}
|
||||
}
|
||||
|
||||
+ (void)SelectImageFromDevice:(id<ImagePickerDelegate>)delegate
|
||||
atPosition:(CGRect)ipadPopoverPosition
|
||||
inView:(UIView *)view {
|
||||
void (^block)(UIImagePickerControllerSourceType) = ^(UIImagePickerControllerSourceType type) {
|
||||
UICompositeViewDescription *description = [ImagePickerViewController compositeViewDescription];
|
||||
ImagePickerViewController *controller;
|
||||
if ([LinphoneManager runningOnIpad] && view) {
|
||||
controller =
|
||||
DYNAMIC_CAST([[PhoneMainView instance].mainViewController getCachedController:description.content],
|
||||
ImagePickerViewController);
|
||||
} else {
|
||||
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:
|
||||
controller.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeImage];
|
||||
|
||||
// Hides the controls for moving & scaling pictures, or for
|
||||
// trimming movies. To instead show the controls, use YES.
|
||||
controller.allowsEditing = NO;
|
||||
controller.imagePickerDelegate = delegate;
|
||||
|
||||
if ([LinphoneManager runningOnIpad] && view) {
|
||||
[controller.popoverController presentPopoverFromRect:ipadPopoverPosition
|
||||
inView:view
|
||||
permittedArrowDirections:UIPopoverArrowDirectionAny
|
||||
animated:FALSE];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
DTActionSheet *sheet = [[DTActionSheet alloc] initWithTitle:NSLocalizedString(@"Select picture source", nil)];
|
||||
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) block:nil];
|
||||
|
||||
[sheet showInView:[PhoneMainView instance].view];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
|
||||
<data>
|
||||
<int key="IBDocument.SystemTarget">1536</int>
|
||||
<int key="IBDocument.SystemTarget">2048</int>
|
||||
<string key="IBDocument.SystemVersion">14D136</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">7706</string>
|
||||
<string key="IBDocument.AppKitVersion">1347.57</string>
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
<object class="IBUIView" id="675878782">
|
||||
<reference key="NSNextResponder"/>
|
||||
<nil key="NSNextResponder"/>
|
||||
<int key="NSvFlags">274</int>
|
||||
<array class="NSMutableArray" key="NSSubviews">
|
||||
<object class="IBUIImageView" id="275930832">
|
||||
|
|
@ -41,7 +41,6 @@
|
|||
<int key="NSvFlags">300</int>
|
||||
<string key="NSFrame">{{6, 6}, {32, 32}}</string>
|
||||
<reference key="NSSuperview" ref="675878782"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="505648338"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<bool key="IBUIUserInteractionEnabled">NO</bool>
|
||||
|
|
@ -56,7 +55,6 @@
|
|||
<int key="NSvFlags">274</int>
|
||||
<string key="NSFrame">{{46, 0}, {273, 44}}</string>
|
||||
<reference key="NSSuperview" ref="675878782"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="647977481"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:328</string>
|
||||
<object class="NSColor" key="IBUIBackgroundColor" id="497796648">
|
||||
|
|
@ -115,7 +113,6 @@
|
|||
<int key="NSvFlags">297</int>
|
||||
<string key="NSFrame">{{327, 11}, {25, 22}}</string>
|
||||
<reference key="NSSuperview" ref="675878782"/>
|
||||
<reference key="NSWindow"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<bool key="IBUIUserInteractionEnabled">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
|
|
@ -126,8 +123,6 @@
|
|||
</object>
|
||||
</array>
|
||||
<string key="NSFrameSize">{360, 44}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="275930832"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<reference key="IBUIBackgroundColor" ref="497796648"/>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
|
|
|
|||
|
|
@ -159,8 +159,7 @@ static UIFont *CELL_FONT = nil;
|
|||
messageText.hidden = YES;
|
||||
[messageImageView startLoading];
|
||||
__block LinphoneChatMessage *achat = chat;
|
||||
[[LinphoneManager instance]
|
||||
.photoLibrary assetForURL:imageUrl
|
||||
[LinphoneManager.instance.photoLibrary assetForURL:imageUrl
|
||||
resultBlock:^(ALAsset *asset) {
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, (unsigned long)NULL),
|
||||
^(void) {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#import "UIRoundedImageView.h"
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import "Utils.h"
|
||||
|
||||
@implementation UIRoundedImageView
|
||||
|
||||
|
|
@ -25,6 +26,9 @@
|
|||
|
||||
- (void)setImage:(UIImage *)image withRoundedRadius:(BOOL)rounded {
|
||||
[super setImage:image];
|
||||
if (image.size.width != image.size.height) {
|
||||
LOGI(@"Image is not squared (%dx%d) - cropping it", image.size.width, image.size.height);
|
||||
}
|
||||
[self setRoundRadius:rounded];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@
|
|||
ms_list_nth_data(linphone_core_get_proxy_config_list([LinphoneManager getLc]), (int)indexPath.row);
|
||||
cell.textLabel.text = [NSString
|
||||
stringWithUTF8String:linphone_address_get_username(linphone_proxy_config_get_identity_address(proxy))];
|
||||
cell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"color_F"]];
|
||||
} else {
|
||||
SideMenuEntry *entry = [_sideMenuEntries objectAtIndex:indexPath.row];
|
||||
cell.textLabel.text = entry->title;
|
||||
|
|
|
|||
|
|
@ -9,13 +9,16 @@
|
|||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "SideMenuTableViewController.h"
|
||||
#import "PhoneMainView.h"
|
||||
|
||||
@interface SideMenuViewController : UIViewController
|
||||
@property(weak, nonatomic) IBOutlet UIImageView *avatarImage;
|
||||
@interface SideMenuViewController : UIViewController <ImagePickerDelegate>
|
||||
|
||||
@property(weak, nonatomic) IBOutlet UIRoundedImageView *avatarImage;
|
||||
@property(weak, nonatomic) IBOutlet UILabel *nameLabel;
|
||||
@property(weak, nonatomic) IBOutlet UILabel *addressLabel;
|
||||
@property(strong, nonatomic) IBOutlet SideMenuTableViewController *sideMenuTableViewController;
|
||||
- (IBAction)onLateralSwipe:(id)sender;
|
||||
- (IBAction)onHeaderClick:(id)sender;
|
||||
- (IBAction)onAvatarClick:(id)sender;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
//
|
||||
//
|
||||
|
||||
#import <AssetsLibrary/ALAsset.h>
|
||||
|
||||
#import "SideMenuViewController.h"
|
||||
#import "LinphoneManager.h"
|
||||
#import "PhoneMainView.h"
|
||||
|
|
@ -28,6 +30,23 @@
|
|||
ms_free(as_string);
|
||||
[FastAddressBook getContactImage:[FastAddressBook getContactWithLinphoneAddress:addr] thumbnail:NO];
|
||||
}
|
||||
NSURL *url = [NSURL URLWithString:[LinphoneManager.instance lpConfigStringForKey:@"avatar"]];
|
||||
if (url) {
|
||||
[LinphoneManager.instance.photoLibrary assetForURL:url
|
||||
resultBlock:^(ALAsset *asset) {
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, (unsigned long)NULL), ^(void) {
|
||||
UIImage *decodedImage = [[UIImage alloc] initWithCGImage:[asset thumbnail]];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[_avatarImage setImage:decodedImage];
|
||||
});
|
||||
});
|
||||
}
|
||||
failureBlock:^(NSError *error) {
|
||||
LOGE(@"Can't read image");
|
||||
}];
|
||||
} else {
|
||||
[_avatarImage setImage:[UIImage imageNamed:@"avatar"]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
|
|
@ -43,4 +62,19 @@
|
|||
[PhoneMainView.instance changeCurrentView:SettingsViewController.compositeViewDescription];
|
||||
[PhoneMainView.instance.mainViewController hideSideMenu:YES];
|
||||
}
|
||||
|
||||
- (IBAction)onAvatarClick:(id)sender {
|
||||
// hide ourself because we are on top of image picker
|
||||
[PhoneMainView.instance.mainViewController hideSideMenu:YES];
|
||||
[ImagePickerViewController SelectImageFromDevice:self atPosition:CGRectNull inView:nil];
|
||||
}
|
||||
|
||||
#pragma mark - Image picker delegate
|
||||
|
||||
- (void)imagePickerDelegateImage:(UIImage *)image info:(NSDictionary *)info {
|
||||
NSURL *url = [info valueForKey:UIImagePickerControllerReferenceURL];
|
||||
[LinphoneManager.instance lpConfigSetString:url.absoluteString forKey:@"avatar"];
|
||||
[PhoneMainView.instance.mainViewController hideSideMenu:NO];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
</connections>
|
||||
</placeholder>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<swipeGestureRecognizer direction="left" id="JRs-i1-zCl">
|
||||
<swipeGestureRecognizer direction="left" id="JRs-i1-zCl" userLabel="OnLateralSwipe">
|
||||
<connections>
|
||||
<action selector="onLateralSwipe:" destination="-1" id="5td-pZ-6Vc"/>
|
||||
<outlet property="delegate" destination="-1" id="yhK-9x-aT0"/>
|
||||
|
|
@ -33,13 +33,16 @@
|
|||
<rect key="frame" x="0.0" y="0.0" width="300" height="100"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="color_F.png" id="90B-Re-hmt" userLabel="backgroundColor">
|
||||
<imageView contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="color_F.png" id="90B-Re-hmt" userLabel="backgroundColor">
|
||||
<rect key="frame" x="0.0" y="0.0" width="300" height="100"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||
</imageView>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="avatar.png" id="BNQ-7N-NGT" userLabel="avatarImage">
|
||||
<rect key="frame" x="0.0" y="15" width="90" height="61"/>
|
||||
<imageView contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="avatar.png" id="BNQ-7N-NGT" userLabel="avatarImage" customClass="UIRoundedImageView">
|
||||
<rect key="frame" x="0.0" y="5" width="90" height="90"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<connections>
|
||||
<outletCollection property="gestureRecognizers" destination="Kej-uL-ntg" appends="YES" id="eog-XV-xok"/>
|
||||
</connections>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Joghn Doe" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="19" id="XbU-2B-u1b" userLabel="nameLabel">
|
||||
<rect key="frame" x="98" y="15" width="194" height="31"/>
|
||||
|
|
@ -58,7 +61,7 @@
|
|||
</subviews>
|
||||
<gestureRecognizers/>
|
||||
<connections>
|
||||
<outletCollection property="gestureRecognizers" destination="1kD-az-BAx" appends="YES" id="GzA-ju-Hpx"/>
|
||||
<outletCollection property="gestureRecognizers" destination="1kD-az-BAx" appends="YES" id="OGc-fj-HQy"/>
|
||||
</connections>
|
||||
</view>
|
||||
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="Ttt-1k-jAm">
|
||||
|
|
@ -89,7 +92,12 @@
|
|||
</connections>
|
||||
<point key="canvasLocation" x="815" y="194"/>
|
||||
</tableViewController>
|
||||
<tapGestureRecognizer id="1kD-az-BAx">
|
||||
<tapGestureRecognizer id="Kej-uL-ntg" userLabel="OnAvatarClicked">
|
||||
<connections>
|
||||
<action selector="onAvatarClick:" destination="-1" id="KyX-RA-m6A"/>
|
||||
</connections>
|
||||
</tapGestureRecognizer>
|
||||
<tapGestureRecognizer id="1kD-az-BAx" userLabel="OnHeaderClicked">
|
||||
<connections>
|
||||
<action selector="onHeaderClick:" destination="-1" id="yqn-58-lbb"/>
|
||||
</connections>
|
||||
|
|
|
|||
|
|
@ -34,29 +34,6 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info
|
|||
return retString;
|
||||
}
|
||||
|
||||
+ (UIImage *)squareImageCrop:(UIImage *)image {
|
||||
UIImage *ret = nil;
|
||||
|
||||
// This calculates the crop area.
|
||||
|
||||
float originalWidth = image.size.width;
|
||||
float originalHeight = image.size.height;
|
||||
|
||||
float edge = fminf(originalWidth, originalHeight);
|
||||
|
||||
float posX = (originalWidth - edge) / 2.0f;
|
||||
float posY = (originalHeight - edge) / 2.0f;
|
||||
|
||||
CGRect cropSquare = CGRectMake(posX, posY, edge, edge);
|
||||
|
||||
CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], cropSquare);
|
||||
ret = [UIImage imageWithCGImage:imageRef scale:image.scale orientation:image.imageOrientation];
|
||||
|
||||
CGImageRelease(imageRef);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
+ (UIImage *)getContactImage:(ABRecordRef)contact thumbnail:(BOOL)thumbnail {
|
||||
UIImage *retImage = nil;
|
||||
if (contact && ABPersonHasImageData(contact)) {
|
||||
|
|
@ -70,7 +47,7 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info
|
|||
}
|
||||
if (retImage.size.width != retImage.size.height) {
|
||||
LOGW(@"Image is not square (%@): cropping it.", retImage.size);
|
||||
retImage = [self squareImageCrop:retImage];
|
||||
retImage = [retImage squareCrop];
|
||||
}
|
||||
return retImage;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,12 @@ void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
|
|||
|
||||
@end
|
||||
|
||||
@interface UIImage (squareCrop)
|
||||
|
||||
- (UIImage *)squareCrop;
|
||||
|
||||
@end
|
||||
|
||||
@interface ContactDisplay : NSObject
|
||||
+ (void)setDisplayNameLabel:(UILabel *)label forContact:(ABRecordRef)contact;
|
||||
+ (void)setDisplayNameLabel:(UILabel *)label forAddress:(const LinphoneAddress *)addr;
|
||||
|
|
|
|||
|
|
@ -353,4 +353,31 @@ void linphone_iphone_log_handler(int lev, const char *fmt, va_list args) {
|
|||
label.text = [FastAddressBook displayNameForAddress:addr];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UIImage (squareCrop)
|
||||
|
||||
- (UIImage *)squareCrop {
|
||||
UIImage *ret = nil;
|
||||
|
||||
// This calculates the crop area.
|
||||
|
||||
float originalWidth = self.size.width;
|
||||
float originalHeight = self.size.height;
|
||||
|
||||
float edge = fminf(originalWidth, originalHeight);
|
||||
|
||||
float posX = (originalWidth - edge) / 2.0f;
|
||||
float posY = (originalHeight - edge) / 2.0f;
|
||||
|
||||
CGRect cropSquare = CGRectMake(posX, posY, edge, edge);
|
||||
|
||||
CGImageRef imageRef = CGImageCreateWithImageInRect([self CGImage], cropSquare);
|
||||
ret = [UIImage imageWithCGImage:imageRef scale:self.scale orientation:self.imageOrientation];
|
||||
|
||||
CGImageRelease(imageRef);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@end
|
||||
Loading…
Add table
Reference in a new issue