forked from mirrors/linphone-iphone
contact details avatar
This commit is contained in:
parent
fb51ce75d0
commit
5e3f5203fb
6 changed files with 80 additions and 17 deletions
|
|
@ -1,11 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ContactDetailsView">
|
||||
<connections>
|
||||
<outlet property="avatarImage" destination="B6X-C9-2vm" id="tQc-xv-nJg"/>
|
||||
<outlet property="backButton" destination="9" id="50"/>
|
||||
<outlet property="editButton" destination="8" id="31"/>
|
||||
<outlet property="tableController" destination="20" id="27"/>
|
||||
|
|
@ -74,10 +76,17 @@
|
|||
</button>
|
||||
</subviews>
|
||||
</view>
|
||||
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="grouped" separatorStyle="default" allowsSelectionDuringEditing="YES" rowHeight="44" sectionHeaderHeight="10" sectionFooterHeight="10" id="19" userLabel="tableView">
|
||||
<rect key="frame" x="0.0" y="44" width="375" height="515"/>
|
||||
<imageView contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="avatar.png" id="B6X-C9-2vm" userLabel="avatarImage" customClass="UIRoundedImageView">
|
||||
<rect key="frame" x="142" y="42" width="90" height="90"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<connections>
|
||||
<outletCollection property="gestureRecognizers" destination="8bV-f4-pLL" appends="YES" id="4V5-Px-aHT"/>
|
||||
</connections>
|
||||
</imageView>
|
||||
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="grouped" separatorStyle="none" allowsSelectionDuringEditing="YES" rowHeight="44" sectionHeaderHeight="10" sectionFooterHeight="10" id="19" userLabel="tableView">
|
||||
<rect key="frame" x="0.0" y="132" width="375" height="427"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" red="0.93725490196078431" green="0.93725490196078431" blue="0.95686274509803926" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
|
||||
<inset key="contentInset" minX="0.0" minY="0.0" maxX="0.0" maxY="10"/>
|
||||
<inset key="scrollIndicatorInsets" minX="0.0" minY="0.0" maxX="0.0" maxY="10"/>
|
||||
<connections>
|
||||
|
|
@ -99,13 +108,19 @@
|
|||
<outlet property="view" destination="19" id="26"/>
|
||||
</connections>
|
||||
</tableViewController>
|
||||
<tapGestureRecognizer id="8bV-f4-pLL" userLabel="onAvatarClick">
|
||||
<connections>
|
||||
<action selector="onAvatarClick:" destination="-1" id="olM-C9-dHO"/>
|
||||
</connections>
|
||||
</tapGestureRecognizer>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="back.png" width="25" height="22"/>
|
||||
<image name="avatar.png" width="255" height="255"/>
|
||||
<image name="back.png" width="24" height="21"/>
|
||||
<image name="color_F.png" width="1" height="1"/>
|
||||
<image name="delete.png" width="22" height="28"/>
|
||||
<image name="edit.png" width="30" height="30"/>
|
||||
<image name="valid.png" width="28" height="19"/>
|
||||
<image name="delete.png" width="21" height="27"/>
|
||||
<image name="edit.png" width="28" height="28"/>
|
||||
<image name="valid.png" width="27" height="19"/>
|
||||
</resources>
|
||||
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
||||
<simulatedStatusBarMetrics key="statusBar"/>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
|
|
@ -77,7 +78,7 @@
|
|||
</subviews>
|
||||
</view>
|
||||
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="MZP-cb-ntf" userLabel="cancelButton" customClass="UIIconButton">
|
||||
<rect key="frame" x="0.0" y="1" width="75" height="40"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="75" height="40"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
|
||||
<accessibility key="accessibilityConfiguration" label="Delete all"/>
|
||||
<inset key="titleEdgeInsets" minX="0.0" minY="18" maxX="0.0" maxY="0.0"/>
|
||||
|
|
@ -91,7 +92,7 @@
|
|||
</connections>
|
||||
</button>
|
||||
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="tFB-Vf-lUX" userLabel="deleteButton" customClass="UIIconButton">
|
||||
<rect key="frame" x="300" y="1" width="75" height="40"/>
|
||||
<rect key="frame" x="300" y="0.0" width="75" height="40"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
|
||||
<accessibility key="accessibilityConfiguration" label="Delete all"/>
|
||||
<inset key="titleEdgeInsets" minX="0.0" minY="18" maxX="0.0" maxY="0.0"/>
|
||||
|
|
@ -104,7 +105,7 @@
|
|||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="DZc-zR-1Q7" userLabel="editButton" customClass="UIIconButton">
|
||||
<rect key="frame" x="225" y="1" width="75" height="40"/>
|
||||
<rect key="frame" x="300" y="0.0" width="75" height="40"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
|
||||
<accessibility key="accessibilityConfiguration" label="Edit"/>
|
||||
<inset key="titleEdgeInsets" minX="0.0" minY="18" maxX="0.0" maxY="0.0"/>
|
||||
|
|
@ -132,7 +133,7 @@
|
|||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="6" userLabel="addButton" customClass="UIIconButton">
|
||||
<rect key="frame" x="300" y="0.0" width="75" height="42"/>
|
||||
<rect key="frame" x="225" y="0.0" width="75" height="42"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
|
||||
<accessibility key="accessibilityConfiguration" label="Add contact"/>
|
||||
<inset key="titleEdgeInsets" minX="0.0" minY="18" maxX="0.0" maxY="0.0"/>
|
||||
|
|
|
|||
|
|
@ -23,8 +23,11 @@
|
|||
#import "UICompositeView.h"
|
||||
#import "UIToggleButton.h"
|
||||
#import "ContactDetailsTableView.h"
|
||||
#import "UIRoundedImageView.h"
|
||||
#import "ImagePickerView.h"
|
||||
|
||||
@interface ContactDetailsView : UIViewController <UICompositeViewDelegate, ContactDetailsDelegate> {
|
||||
@interface ContactDetailsView
|
||||
: UIViewController <UICompositeViewDelegate, ContactDetailsDelegate, ImagePickerDelegate> {
|
||||
ABAddressBookRef addressBook;
|
||||
BOOL inhibUpdate;
|
||||
}
|
||||
|
|
@ -34,11 +37,13 @@
|
|||
@property(nonatomic, strong) IBOutlet UIToggleButton *editButton;
|
||||
@property(nonatomic, strong) IBOutlet UIButton *backButton;
|
||||
@property(nonatomic, strong) IBOutlet UIButton *cancelButton;
|
||||
@property(weak, nonatomic) IBOutlet UIRoundedImageView *avatarImage;
|
||||
|
||||
- (IBAction)onBackClick:(id)event;
|
||||
- (IBAction)onCancelClick:(id)event;
|
||||
- (IBAction)onEditClick:(id)event;
|
||||
- (IBAction)onDeleteClick:(id)sender;
|
||||
- (IBAction)onAvatarClick:(id)sender;
|
||||
|
||||
- (void)newContact;
|
||||
- (void)newContact:(NSString *)address;
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info
|
|||
[PhoneMainView.instance popCurrentView];
|
||||
return;
|
||||
}
|
||||
_avatarImage.image = [FastAddressBook getContactImage:contact thumbnail:NO];
|
||||
[tableController setContact:contact];
|
||||
}
|
||||
|
||||
|
|
@ -117,6 +118,7 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info
|
|||
contact = NULL;
|
||||
[self resetData];
|
||||
contact = acontact;
|
||||
_avatarImage.image = [FastAddressBook getContactImage:contact thumbnail:NO];
|
||||
[tableController setContact:contact];
|
||||
|
||||
if (reload) {
|
||||
|
|
@ -255,6 +257,12 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
}];
|
||||
}
|
||||
|
||||
- (IBAction)onAvatarClick:(id)sender {
|
||||
if (tableController.isEditing) {
|
||||
[ImagePickerView SelectImageFromDevice:self atPosition:CGRectNull inView:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)onModification:(id)event {
|
||||
if (![tableController isEditing] || [tableController isValid]) {
|
||||
[editButton setEnabled:TRUE];
|
||||
|
|
@ -263,4 +271,27 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
}
|
||||
}
|
||||
|
||||
#pragma mark - Image picker delegate
|
||||
|
||||
- (void)imagePickerDelegateImage:(UIImage *)image info:(NSDictionary *)info {
|
||||
FastAddressBook *fab = [LinphoneManager instance].fastAddressBook;
|
||||
CFErrorRef error = NULL;
|
||||
if (!ABPersonRemoveImageData(contact, (CFErrorRef *)&error)) {
|
||||
LOGI(@"Can't remove entry: %@", [(__bridge NSError *)error localizedDescription]);
|
||||
}
|
||||
NSData *dataRef = UIImageJPEGRepresentation(image, 0.9f);
|
||||
CFDataRef cfdata = CFDataCreate(NULL, [dataRef bytes], [dataRef length]);
|
||||
|
||||
[fab saveAddressBook];
|
||||
|
||||
if (!ABPersonSetImageData(contact, cfdata, (CFErrorRef *)&error)) {
|
||||
LOGI(@"Can't add entry: %@", [(__bridge NSError *)error localizedDescription]);
|
||||
} else {
|
||||
[fab saveAddressBook];
|
||||
}
|
||||
|
||||
CFRelease(cfdata);
|
||||
|
||||
_avatarImage.image = [FastAddressBook getContactImage:contact thumbnail:NO];
|
||||
}
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -209,8 +209,19 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info
|
|||
return cell;
|
||||
}
|
||||
|
||||
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
|
||||
return nil; // [addressBookMap keyAtIndex:section];
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
|
||||
UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(0, 200, 300, 244)];
|
||||
tempView.backgroundColor = [UIColor clearColor];
|
||||
|
||||
UILabel *tempLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, 300, 44)];
|
||||
tempLabel.backgroundColor = [UIColor clearColor];
|
||||
tempLabel.textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"color_A"]];
|
||||
tempLabel.text = [addressBookMap keyAtIndex:section];
|
||||
tempLabel.textAlignment = NSTextAlignmentCenter;
|
||||
tempLabel.font = [UIFont boldSystemFontOfSize:17];
|
||||
[tempView addSubview:tempLabel];
|
||||
|
||||
return tempView;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@
|
|||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<view contentMode="scaleToFill" id="GmN-7v-uuO" userLabel="imageSubView">
|
||||
<rect key="frame" x="48" y="91" width="274" height="32.000000029802322"/>
|
||||
<rect key="frame" x="48" y="91" width="274" height="32"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<progressView opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" progress="0.5" id="USm-wC-GvG" userLabel="transferProgress">
|
||||
|
|
@ -84,7 +84,7 @@
|
|||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
</progressView>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="N75-gL-R6t" userLabel="transferButton" customClass="UIRoundBorderedButton">
|
||||
<rect key="frame" x="75" y="4.0000000298023224" width="124" height="27"/>
|
||||
<rect key="frame" x="75" y="4" width="124" height="27"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<state key="normal" title="DOWNLOAD">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
|
|
@ -94,7 +94,7 @@
|
|||
</connections>
|
||||
</button>
|
||||
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="6dl-Nz-rdv" userLabel="cancelButton" customClass="UIRoundBorderedButton">
|
||||
<rect key="frame" x="75" y="4.0000000298023224" width="124" height="27"/>
|
||||
<rect key="frame" x="75" y="4" width="124" height="27"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<state key="normal" title="CANCEL">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue