UI: change date formatting, still work to do

This commit is contained in:
Gautier Pelloux-Prayer 2015-10-26 14:58:24 +01:00
parent 54625e3c4c
commit 828917bef9
17 changed files with 31 additions and 68 deletions

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"/>
@ -10,6 +10,7 @@
<outlet property="avatarImage" destination="B6X-C9-2vm" id="tQc-xv-nJg"/>
<outlet property="backButton" destination="9" id="50"/>
<outlet property="cancelButton" destination="bPQ-aJ-Lk6" id="QHN-qi-QNv"/>
<outlet property="deleteButton" destination="MuB-yy-R9o" id="cni-lk-awn"/>
<outlet property="editButton" destination="8" id="31"/>
<outlet property="nameLabel" destination="moZ-Bg-zcv" id="Lt9-h0-2o1"/>
<outlet property="tableController" destination="20" id="27"/>
@ -108,21 +109,21 @@
<attributedString key="attributedText">
<fragment content="John">
<attributes>
<color key="NSColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="NSColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<font key="NSFont" size="27" name="HelveticaNeue"/>
<paragraphStyle key="NSParagraphStyle" alignment="center" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
</attributes>
</fragment>
<fragment content=" ">
<attributes>
<color key="NSColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="NSColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<font key="NSFont" size="17" name="HelveticaNeue"/>
<paragraphStyle key="NSParagraphStyle" alignment="center" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
</attributes>
</fragment>
<fragment content="Doe">
<attributes>
<color key="NSColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="NSColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<font key="NSFont" size="27" name="HelveticaNeue-Bold"/>
<paragraphStyle key="NSParagraphStyle" alignment="center" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
</attributes>
@ -167,8 +168,8 @@
<image name="back_disabled.png" width="24" height="21"/>
<image name="cancel_edit_default.png" width="29" height="29"/>
<image name="cancel_edit_disabled.png" width="29" height="29"/>
<image name="color_E.png" width="1" height="1"/>
<image name="color_F.png" width="1" height="1"/>
<image name="color_E.png" width="2" height="2"/>
<image name="color_F.png" width="2" height="2"/>
<image name="delete_default.png" width="21" height="27"/>
<image name="delete_disabled.png" width="21" height="27"/>
<image name="edit_default.png" width="28" height="28"/>

View file

@ -439,7 +439,10 @@ static void hideSpinner(LinphoneCall *call, void *user_data) {
#pragma mark - UI modification
- (void)callDurationUpdate {
_durationLabel.text = [LinphoneUtils durationForCall:linphone_core_get_current_call([LinphoneManager getLc])];
int duration = linphone_core_get_current_call([LinphoneManager getLc])
? linphone_call_get_duration(linphone_core_get_current_call([LinphoneManager getLc]))
: 0;
_durationLabel.text = [LinphoneUtils durationToString:duration];
}
- (void)onCurrentCallChange {

View file

@ -42,7 +42,6 @@
@property(weak, nonatomic) IBOutlet UITextView *messageField;
@property(nonatomic, strong) IBOutlet UIButton *sendButton;
@property(nonatomic, strong) IBOutlet UILabel *addressLabel;
@property(nonatomic, strong) IBOutlet UIRoundedImageView *avatarImage;
@property(nonatomic, strong) IBOutlet UIView *headerView;
@property(nonatomic, strong) IBOutlet UIView *chatView;
@property(nonatomic, strong) IBOutlet UIView *messageView;

View file

@ -200,7 +200,6 @@ static UICompositeViewDescription *compositeDescription = nil;
}
[ContactDisplay setDisplayNameLabel:_addressLabel forAddress:addr];
_addressLabel.accessibilityValue = _addressLabel.text;
[_avatarImage setImage:[FastAddressBook imageForAddress:addr thumbnail:YES] bordered:NO withRoundedRadius:YES];
}
static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState state, void *ud) {

View file

@ -39,6 +39,7 @@
@property(nonatomic, strong) IBOutlet UIButton *cancelButton;
@property(weak, nonatomic) IBOutlet UIRoundedImageView *avatarImage;
@property(weak, nonatomic) IBOutlet UILabel *nameLabel;
@property(weak, nonatomic) IBOutlet UIToggleButton *deleteButton;
- (IBAction)onBackClick:(id)event;
- (IBAction)onCancelClick:(id)event;

View file

@ -210,7 +210,6 @@ static UICompositeViewDescription *compositeDescription = nil;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
}
[_tableController setEditing:editing animated:animated];
if (editing) {
[_editButton setOn];

View file

@ -65,9 +65,10 @@
time_t callTime = linphone_call_log_get_start_date(log);
cell.textLabel.textAlignment = NSTextAlignmentCenter;
[cell.textLabel
setText:[NSString stringWithFormat:@"%@ - %d sec",
[LinphoneUtils timeToString:callTime withStyle:NSDateFormatterMediumStyle],
duration]];
setText:[NSString stringWithFormat:@"%@ - %@", [LinphoneUtils timeToString:callTime
withFormat:NSLocalizedString(
@"yyyy/MM/dd '-' HH'h'mm", nil)],
[LinphoneUtils durationToString:duration]]];
BOOL outgoing = (linphone_call_log_get_dir(log) == LinphoneCallOutgoing);
if (linphone_call_log_get_status(log) == LinphoneCallMissed) {

View file

@ -28,7 +28,6 @@
@interface HistoryDetailsView : UIViewController <UICompositeViewDelegate> {
@private
LinphoneCallLog *callLog;
NSDateFormatter *dateFormatter;
}
@property(weak, nonatomic) IBOutlet UILabel *contactLabel;
@property(nonatomic, strong) IBOutlet UIRoundedImageView *avatarImage;

View file

@ -21,26 +21,7 @@
#import "PhoneMainView.h"
#import "FastAddressBook.h"
@implementation HistoryDetailsView {
}
#pragma mark - LifeCycle Functions
- (id)init {
self = [super initWithNibName:NSStringFromClass(self.class) bundle:[NSBundle mainBundle]];
if (self != nil) {
dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeStyle:NSDateFormatterMediumStyle];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
NSLocale *locale = [NSLocale currentLocale];
[dateFormatter setLocale:locale];
}
return self;
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
@implementation HistoryDetailsView
#pragma mark - UICompositeViewDelegate Functions
@ -97,10 +78,7 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[[NSNotificationCenter defaultCenter] removeObserver:self name:kLinphoneAddressBookUpdate object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:kLinphoneCoreUpdate object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
#pragma mark - Event Functions
@ -162,7 +140,7 @@ static UICompositeViewDescription *compositeDescription = nil;
ABRecordRef contact = [FastAddressBook getContactWithAddress:addr];
_addContactButton.hidden = (contact != nil);
[ContactDisplay setDisplayNameLabel:_contactLabel forAddress:addr];
[_avatarImage setImage:[FastAddressBook imageForContact:contact thumbnail:NO] bordered:YES withRoundedRadius:YES];
[_avatarImage setImage:[FastAddressBook imageForContact:contact thumbnail:NO] bordered:NO withRoundedRadius:YES];
char *addrURI = linphone_address_as_string_uri_only(addr);
_addressLabel.text = [NSString stringWithUTF8String:addrURI];
ms_free(addrURI);

View file

@ -158,8 +158,8 @@
} else if ([eventDate isEqualToDate:[currentDate dateByAddingTimeInterval:-3600 * 24]]) {
tempLabel.text = NSLocalizedString(@"YESTERDAY", nil);
} else {
tempLabel.text =
[LinphoneUtils timeToString:eventDate.timeIntervalSince1970 withStyle:NSDateFormatterMediumStyle];
tempLabel.text = [LinphoneUtils timeToString:eventDate.timeIntervalSince1970
withFormat:NSLocalizedString(@"yyyy/MM/dd", nil)];
}
tempLabel.textAlignment = NSTextAlignmentCenter;
tempLabel.font = [UIFont boldSystemFontOfSize:17];

View file

@ -39,7 +39,7 @@
[_avatarImage setImage:[FastAddressBook imageForAddress:addr thumbnail:YES] bordered:NO withRoundedRadius:YES];
_durationLabel.text = [LinphoneUtils durationForCall:linphone_core_get_current_call([LinphoneManager getLc])];
_durationLabel.text = [LinphoneUtils durationToString:linphone_call_get_duration(call)];
}
- (IBAction)onKickClick:(id)sender {

View file

@ -41,7 +41,7 @@
[_avatarImage setImage:[FastAddressBook imageForAddress:addr thumbnail:NO] bordered:YES withRoundedRadius:YES];
_durationLabel.text = [LinphoneUtils durationForCall:linphone_core_get_current_call([LinphoneManager getLc])];
_durationLabel.text = [LinphoneUtils durationToString:linphone_call_get_duration(call)];
}
@end

View file

@ -100,7 +100,7 @@
// Date
_contactDateLabel.text = [NSString
stringWithFormat:@"%@ - %@", [LinphoneUtils timeToString:linphone_chat_message_get_time(_message)
withStyle:NSDateFormatterShortStyle],
withFormat:NSLocalizedString(@"yyyy/MM/dd '-' HH'h'mm", nil)],
[FastAddressBook displayNameForAddress:linphone_chat_message_get_peer_address(_message)]];
LinphoneChatMessageState state = linphone_chat_message_get_state(_message);

View file

@ -87,7 +87,7 @@
}
_chatLatestTimeLabel.text = [LinphoneUtils timeToString:linphone_chat_message_get_time(last_message)
withStyle:NSDateFormatterShortStyle];
withFormat:NSLocalizedString(@"MM/dd", nil)];
_chatLatestTimeLabel.hidden = NO;
} else {
_chatContentLabel.text = nil;

View file

@ -9,6 +9,7 @@
<connections>
<outlet property="addressLabel" destination="frB-ep-LWi" id="g8q-qs-S9y"/>
<outlet property="defaultView" destination="SR2-3m-6t5" id="ZvK-H1-inh"/>
<outlet property="deleteButton" destination="C2f-aP-xjR" id="sxr-th-6rq"/>
<outlet property="editTextfield" destination="dTn-Hc-bGM" id="bkN-xg-S9D"/>
<outlet property="editView" destination="rAa-qu-PDc" id="cGz-D2-GiI"/>
</connections>

View file

@ -36,12 +36,12 @@ void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
+ (void)buttonMultiViewApplyAttributes:(NSDictionary*)attributes button:(UIButton*)button;
+ (NSString *)deviceName;
+ (NSString *)timeToString:(time_t)time withStyle:(NSDateFormatterStyle)style;
+ (NSString *)timeToString:(time_t)time withFormat:(NSString *)format;
+ (BOOL)hasAvatar;
+ (void)setSelfAvatar:(UIImageView *)avatar;
+ (NSString *)durationForCall:(LinphoneCall *)call;
+ (NSString *)durationToString:(int)duration;
@end

View file

@ -105,8 +105,7 @@ void linphone_iphone_log_handler(int lev, const char *fmt, va_list args) {
}
}
+ (NSString *)durationForCall:(LinphoneCall *)call {
int duration = call ? linphone_call_get_duration(call) : 0;
+ (NSString *)durationToString:(int)duration {
NSMutableString *result = [[NSMutableString alloc] init];
if (duration / 3600 > 0) {
[result appendString:[NSString stringWithFormat:@"%02i:", duration / 3600]];
@ -115,28 +114,11 @@ void linphone_iphone_log_handler(int lev, const char *fmt, va_list args) {
return [result stringByAppendingString:[NSString stringWithFormat:@"%02i:%02i", (duration / 60), (duration % 60)]];
}
+ (NSString *)timeToString:(time_t)time withStyle:(NSDateFormatterStyle)style {
+ (NSString *)timeToString:(time_t)time withFormat:(NSString *)format {
NSDate *todayDate = [[NSDate alloc] init];
NSDate *messageDate = (time == 0) ? todayDate : [NSDate dateWithTimeIntervalSince1970:time];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:style];
if (style == NSDateFormatterShortStyle) {
// UGLY but single line code!
BOOL sameDay =
[[dateFormatter stringFromDate:todayDate] isEqualToString:[dateFormatter stringFromDate:messageDate]];
if (sameDay) {
[dateFormatter setDateStyle:NSDateFormatterNoStyle];
[dateFormatter setTimeStyle:style];
} else {
[dateFormatter setTimeStyle:NSDateFormatterNoStyle];
}
} else {
[dateFormatter setTimeStyle:style];
}
NSLocale *locale = [NSLocale currentLocale];
[dateFormatter setLocale:locale];
[dateFormatter setDateFormat:format];
return [dateFormatter stringFromDate:messageDate];
}