Use the UIxMailSizeFormatter in messages listing

This commit is contained in:
Francis Lachapelle
2013-12-18 08:38:03 -05:00
parent 59ce12a51b
commit a8e3418a4c
5 changed files with 25 additions and 24 deletions
+14 -9
View File
@@ -25,7 +25,8 @@
@implementation UIxMailSizeFormatter
+ (id)sharedMailSizeFormatter {
+ (id) sharedMailSizeFormatter
{
static UIxMailSizeFormatter *fmt = nil; // THREAD
if (fmt == nil) fmt = [[self alloc] init];
return fmt;
@@ -33,20 +34,24 @@
/* formatting */
- (NSString *)stringForSize:(unsigned int)size {
- (NSString *) stringForSize: (unsigned int) size
{
char buf[128];
if (size < 1024)
sprintf(buf, "%d", size);
else if (size < 1024 * 1024)
sprintf(buf, "%.1fK", ((double)size / 1024));
if (size > 1024*1024)
sprintf(buf, "%.1f MiB", ((double)size / 1024 / 1024));
else if (size > 1024*100)
sprintf(buf, "%d KiB", (size / 1024));
else if (size > 1024)
sprintf(buf, "%.1f KiB", ((double)size / 1024));
else
sprintf(buf, "%.1fM", ((double)size / 1024 / 1024));
sprintf(buf, "%d B", size);
return [NSString stringWithCString:buf];
}
- (NSString *)stringForObjectValue:(id)_object {
- (NSString *) stringForObjectValue: (id) _object
{
return [self stringForSize:[_object unsignedIntValue]];
}
+2
View File
@@ -27,6 +27,7 @@
@class NSDictionary;
@class EOQualifier;
@class SOGoDateFormatter;
@class UIxMailSizeFormatter;
@interface UIxMailListActions : WODirectAction
{
@@ -35,6 +36,7 @@
id message;
SOGoDateFormatter *dateFormatter;
NSTimeZone *userTimeZone;
UIxMailSizeFormatter *sizeFormatter;
BOOL sortByThread;
int folderType;
int specificMessageNumber;
+4 -14
View File
@@ -60,6 +60,7 @@
#import <SOGo/SOGoUserSettings.h>
#import <UI/Common/WODirectAction+SOGo.h>
#import <UI/MailPartViewers/UIxMailSizeFormatter.h>
#import "WOContext+UIxMailer.h"
#import "UIxMailFormatter.h"
@@ -120,20 +121,9 @@
return [dateFormatter formattedDateAndTime: messageDate];
}
- (NSString *) messageSize
- (UIxMailSizeFormatter *) sizeFormatter
{
NSString *rc;
int size;
size = [[message valueForKey: @"size"] intValue];
if (size > 1024*1024)
rc = [NSString stringWithFormat: @"%.1f MB", (float) size/1024/1024];
else if (size > 1024*100)
rc = [NSString stringWithFormat: @"%d KB", size/1024];
else
rc = [NSString stringWithFormat: @"%.1f KB", (float) size/1024];
return rc;
return [UIxMailSizeFormatter sharedMailSizeFormatter];
}
//
@@ -806,7 +796,7 @@
[msg addObject: msgDate];
// Size
[msg addObject: [self messageSize]];
[msg addObject: [[self sizeFormatter] stringForObjectValue: [message objectForKey: @"size"]]];
// rowClasses
[msg addObject: [self messageRowStyleClass]];
@@ -14,7 +14,7 @@
</a>
<div class="linked_attachment_meta">
<var:string value="filenameForDisplay"
/> (<var:string value="bodyInfo.size" formatter="sizeFormatter" />)
/> <span class="muted">(<var:string value="bodyInfo.size" formatter="sizeFormatter" />)</span>
</div>
<!-- debug
+4
View File
@@ -49,6 +49,10 @@ DIV#pageContent
{ clear: both;
padding-top: 1em; }
.muted,
.muted a
{ color: #888 !important; }
A
{ text-decoration: none;
-moz-outline: 0px; }