sidemenu: display local primary contact when no account configured

This commit is contained in:
Gautier Pelloux-Prayer 2016-04-29 11:49:15 +02:00
parent 1407d41533
commit e5ae91cc2b
3 changed files with 30 additions and 18 deletions

View file

@ -1,16 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="SideMenuView">
<connections>
<outlet property="addressButton" destination="MFj-XQ-w5V" id="EPi-6H-59a"/>
<outlet property="addressLabel" destination="V8A-tK-4iV" id="YMm-ry-yJa"/>
<outlet property="avatarImage" destination="BNQ-7N-NGT" id="LXr-Yr-zSK"/>
<outlet property="grayBackground" destination="ccB-VK-LF9" id="Rbz-Ix-k62"/>
<outlet property="nameLabel" destination="XbU-2B-u1b" id="rKF-4e-1HA"/>
<outlet property="presenceImage" destination="C88-Ag-nm7" id="LH2-Mq-xLz"/>
<outlet property="sideMenuTableViewController" destination="Yyh-z6-IGO" id="6Xq-OQ-vYm"/>
<outlet property="swipeGestureRecognizer" destination="JRs-i1-zCl" id="YA3-UP-6Dc"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
@ -54,17 +55,19 @@
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" lineBreakMode="tailTruncation" id="MFj-XQ-w5V" userLabel="adressButton" customClass="UIRightImageButton">
<rect key="frame" x="76" y="54" width="224" height="22"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="john.doe@sip.linphone.org" textAlignment="natural" lineBreakMode="middleTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" id="V8A-tK-4iV" userLabel="addressLabel">
<rect key="frame" x="76" y="54" width="208" height="38"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<inset key="titleEdgeInsets" minX="3" minY="0.0" maxX="0.0" maxY="0.0"/>
<state key="normal" title="john.doe@sip.linphone.org" image="led_connected.png">
<color key="titleColor" red="1" green="0.36862745099999999" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
</button>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="1" green="0.36862745099999999" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="led_connected.png" id="C88-Ag-nm7" userLabel="presenceImage">
<rect key="frame" x="284" y="58" width="16" height="29"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
</imageView>
<imageView contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="avatar.png" id="BNQ-7N-NGT" userLabel="avatarImage" customClass="UIRoundedImageView">
<rect key="frame" x="8" y="20" width="60" height="60"/>
<rect key="frame" x="3" y="15" width="68" height="77"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<connections>
<outletCollection property="gestureRecognizers" destination="Kej-uL-ntg" appends="YES" id="eog-XV-xok"/>

View file

@ -16,7 +16,8 @@
@property(strong, nonatomic) IBOutlet UISwipeGestureRecognizer *swipeGestureRecognizer;
@property(weak, nonatomic) IBOutlet UIRoundedImageView *avatarImage;
@property(weak, nonatomic) IBOutlet UILabel *nameLabel;
@property(weak, nonatomic) IBOutlet UIButton *addressButton;
@property(weak, nonatomic) IBOutlet UILabel *addressLabel;
@property(weak, nonatomic) IBOutlet UIImageView *presenceImage;
@property(strong, nonatomic) IBOutlet SideMenuTableView *sideMenuTableViewController;
@property(weak, nonatomic) IBOutlet UIView *grayBackground;
- (IBAction)onLateralSwipe:(id)sender;

View file

@ -56,14 +56,22 @@
const LinphoneAddress *addr = linphone_proxy_config_get_identity_address(default_proxy);
[ContactDisplay setDisplayNameLabel:_nameLabel forAddress:addr];
char *as_string = linphone_address_as_string_uri_only(addr);
[_addressButton setTitle:[NSString stringWithUTF8String:as_string] forState:UIControlStateNormal];
_addressLabel.text = [NSString stringWithUTF8String:as_string];
ms_free(as_string);
[_addressButton setImage:[StatusBarView imageForState:linphone_proxy_config_get_state(default_proxy)]
forState:UIControlStateNormal];
_presenceImage.image = [StatusBarView imageForState:linphone_proxy_config_get_state(default_proxy)];
} else {
_nameLabel.text = @"No account";
[_addressButton setTitle:NSLocalizedString(@"No address", nil) forState:UIControlStateNormal];
[_addressButton setImage:nil forState:UIControlStateNormal];
// display direct IP:port address so that we can be reached
LinphoneAddress *addr = linphone_core_get_primary_contact_parsed(LC);
if (addr) {
char *as_string = linphone_address_as_string_uri_only(addr);
_addressLabel.text = [NSString stringWithFormat:@"%s", as_string];
ms_free(as_string);
linphone_address_destroy(addr);
} else {
_addressLabel.text = NSLocalizedString(@"No address", nil);
}
_presenceImage.image = nil;
}
_avatarImage.image = [LinphoneUtils selfAvatar];
}