Call: fix duration display

This commit is contained in:
Gautier Pelloux-Prayer 2015-10-26 09:40:40 +01:00
parent 49d8232372
commit 28beda18f5
9 changed files with 35 additions and 32 deletions

View file

@ -439,11 +439,7 @@ static void hideSpinner(LinphoneCall *call, void *user_data) {
#pragma mark - UI modification
- (void)callDurationUpdate {
LinphoneCall *call = linphone_core_get_current_call([LinphoneManager getLc]);
if (call) {
int duration = linphone_call_get_duration(call);
_durationLabel.text = [NSString stringWithFormat:@"%02i:%02i", (duration / 60), (duration % 60)];
}
_durationLabel.text = [LinphoneUtils durationForCall:linphone_core_get_current_call([LinphoneManager getLc])];
}
- (void)onCurrentCallChange {

View file

@ -1,5 +1,5 @@
<?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">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14F1021" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
@ -31,26 +31,12 @@
<color key="textColor" red="1" green="0.36862745099999999" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" tag="2" contentMode="left" usesAttributedText="YES" lineBreakMode="tailTruncation" minimumFontSize="10" adjustsFontSizeToFit="NO" id="20" userLabel="addressLabel">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" tag="2" contentMode="left" text="John Doe" lineBreakMode="tailTruncation" minimumFontSize="10" adjustsFontSizeToFit="NO" id="20" userLabel="addressLabel">
<rect key="frame" x="63" y="0.0" width="271" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Contact name"/>
<attributedString key="attributedText">
<fragment content="John ">
<attributes>
<color key="NSColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<font key="NSFont" size="25" name="HelveticaNeue"/>
<paragraphStyle key="NSParagraphStyle" alignment="left" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
</attributes>
</fragment>
<fragment content="Doe">
<attributes>
<color key="NSColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<font key="NSFont" size="25" name="HelveticaNeue-Bold"/>
<paragraphStyle key="NSParagraphStyle" alignment="left" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
</attributes>
</fragment>
</attributedString>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="25"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" tag="2" contentMode="left" text="This is a placeholder message" lineBreakMode="tailTruncation" numberOfLines="3" adjustsFontSizeToFit="NO" id="21" userLabel="chatContentLabel">

View file

@ -39,8 +39,7 @@
_avatarImage.image = [FastAddressBook imageForAddress:addr thumbnail:YES];
int duration = linphone_call_get_duration(call);
[_durationLabel setText:[NSString stringWithFormat:@"%02i:%02i", (duration / 60), (duration % 60), nil]];
_durationLabel.text = [LinphoneUtils durationForCall:linphone_core_get_current_call([LinphoneManager getLc])];
}
- (IBAction)onKickClick:(id)sender {

View file

@ -41,8 +41,7 @@
_avatarImage.image = [FastAddressBook imageForAddress:addr thumbnail:NO];
int duration = linphone_call_get_duration(call);
[_durationLabel setText:[NSString stringWithFormat:@"%02i:%02i", (duration / 60), (duration % 60), nil]];
_durationLabel.text = [LinphoneUtils durationForCall:linphone_core_get_current_call([LinphoneManager getLc])];
}
@end

View file

@ -102,6 +102,9 @@
int count = linphone_chat_room_get_unread_messages_count(chatRoom);
[unreadCountButton setTitle:[NSString stringWithFormat:@"%i", count] forState:UIControlStateNormal];
unreadCountButton.hidden = (count <= 0);
UIFont *addressFont = (count <= 0) ? [UIFont systemFontOfSize:25] : [UIFont boldSystemFontOfSize:25];
addressLabel.font = addressFont;
}
- (void)setEditing:(BOOL)editing {

View file

@ -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="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14F1021" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
</dependencies>
<objects>
@ -43,10 +44,10 @@
<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">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="John Doe" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="19" id="XbU-2B-u1b" userLabel="nameLabel">
<rect key="frame" x="98" y="15" width="194" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="25"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="25"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
@ -103,8 +104,8 @@
</tapGestureRecognizer>
</objects>
<resources>
<image name="avatar.png" width="261" height="261"/>
<image name="color_F.png" width="1" height="1"/>
<image name="avatar.png" width="255" height="255"/>
<image name="color_F.png" width="2" height="2"/>
</resources>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>

View file

@ -44,6 +44,7 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info
}
+ (UIImage *)imageForAddress:(const LinphoneAddress *)addr thumbnail:(BOOL)thumbnail {
// if ([LinphoneManager isMe:addr] && [LinphoneUtils hasAvatar])
return [FastAddressBook imageForContact:[FastAddressBook getContactWithAddress:addr] thumbnail:thumbnail];
}

View file

@ -37,8 +37,12 @@ void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
+ (NSString *)deviceName;
+ (NSString *)timeToString:(time_t)time withStyle:(NSDateFormatterStyle)style;
+ (BOOL)hasAvatar;
+ (void)setSelfAvatar:(UIImageView *)avatar;
+ (NSString *)durationForCall:(LinphoneCall *)call;
@end
@interface NSNumber (HumanReadableSize)

View file

@ -82,6 +82,9 @@ void linphone_iphone_log_handler(int lev, const char *fmt, va_list args) {
@implementation LinphoneUtils
+ (BOOL)hasAvatar {
return [NSURL URLWithString:[LinphoneManager.instance lpConfigStringForKey:@"avatar"]] != nil;
}
+ (void)setSelfAvatar:(UIImageView *)avatar {
NSURL *url = [NSURL URLWithString:[LinphoneManager.instance lpConfigStringForKey:@"avatar"]];
if (url) {
@ -101,6 +104,17 @@ void linphone_iphone_log_handler(int lev, const char *fmt, va_list args) {
avatar.image = [UIImage imageNamed:@"avatar.png"];
}
}
+ (NSString *)durationForCall:(LinphoneCall *)call {
int duration = call ? linphone_call_get_duration(call) : 0;
NSMutableString *result = [[NSMutableString alloc] init];
if (duration / 3600 > 0) {
[result appendString:[NSString stringWithFormat:@"%02i:", duration / 3600]];
duration = duration % 3600;
}
return [result stringByAppendingString:[NSString stringWithFormat:@"%02i:%02i", (duration / 60), (duration % 60)]];
}
+ (NSString *)timeToString:(time_t)time withStyle:(NSDateFormatterStyle)style {
NSDate *todayDate = [[NSDate alloc] init];
NSDate *messageDate = (time == 0) ? todayDate : [NSDate dateWithTimeIntervalSince1970:time];