From aac3b69c4f5a40ac3f1bca62d9fd163bd98a3868 Mon Sep 17 00:00:00 2001 From: ndew623 Date: Sat, 25 Mar 2017 14:51:40 -0500 Subject: [PATCH 1/3] UTC time in quotes (Issue #2403) Before, the time in the quoted message of a reply was always in the local timezone, even when the "Hide timezone" setting was selected. Now, when the option is enabled, that is changed to UTC just like the time in headers. I also changed the description for the option in the English strings.xml to better describe the new different behavior. --- .../main/java/com/fsck/k9/message/quote/QuoteHelper.java | 9 +++++++-- k9mail/src/main/res/values/strings.xml | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/k9mail/src/main/java/com/fsck/k9/message/quote/QuoteHelper.java b/k9mail/src/main/java/com/fsck/k9/message/quote/QuoteHelper.java index 8ce47c9b1..830d3eff7 100644 --- a/k9mail/src/main/java/com/fsck/k9/message/quote/QuoteHelper.java +++ b/k9mail/src/main/java/com/fsck/k9/message/quote/QuoteHelper.java @@ -4,9 +4,11 @@ package com.fsck.k9.message.quote; import java.text.DateFormat; import java.util.Date; import java.util.Locale; +import java.util.TimeZone; import android.content.res.Resources; +import com.fsck.k9.K9; import com.fsck.k9.mail.Message; @@ -27,8 +29,11 @@ class QuoteHelper { final int timeStyle = DateFormat.LONG; Date date = message.getSentDate(); Locale locale = resources.getConfiguration().locale; - return DateFormat.getDateTimeInstance(dateStyle, timeStyle, locale) - .format(date); + DateFormat dateFormat = DateFormat.getDateTimeInstance(dateStyle, timeStyle, locale); + if (K9.hideTimeZone()) { + dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + } + return dateFormat.format(date); } catch (Exception e) { return ""; } diff --git a/k9mail/src/main/res/values/strings.xml b/k9mail/src/main/res/values/strings.xml index aff490574..c6d0d2a76 100644 --- a/k9mail/src/main/res/values/strings.xml +++ b/k9mail/src/main/res/values/strings.xml @@ -342,7 +342,7 @@ Please submit bug reports, contribute new features and ask questions at Hide mail client Remove K-9 User-Agent from mail headers Hide timezone - Use UTC instead of local timezone in mail headers + Use UTC instead of local timezone in mail headers and reply quotes Hide subject in notifications Never When device is locked From b1f9b9ac6cb3e37344410cc5935be50d3cd50f78 Mon Sep 17 00:00:00 2001 From: ndew623 Date: Sun, 26 Mar 2017 13:52:12 -0500 Subject: [PATCH 2/3] Changed string in options to say "reply header" instead of "reply quotes". Normalized locale in reply header when Hide timezone option is selected. --- .../main/java/com/fsck/k9/message/quote/QuoteHelper.java | 9 +++++++-- k9mail/src/main/res/values/strings.xml | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/k9mail/src/main/java/com/fsck/k9/message/quote/QuoteHelper.java b/k9mail/src/main/java/com/fsck/k9/message/quote/QuoteHelper.java index 830d3eff7..599bb2526 100644 --- a/k9mail/src/main/java/com/fsck/k9/message/quote/QuoteHelper.java +++ b/k9mail/src/main/java/com/fsck/k9/message/quote/QuoteHelper.java @@ -28,10 +28,15 @@ class QuoteHelper { final int dateStyle = DateFormat.LONG; final int timeStyle = DateFormat.LONG; Date date = message.getSentDate(); - Locale locale = resources.getConfiguration().locale; - DateFormat dateFormat = DateFormat.getDateTimeInstance(dateStyle, timeStyle, locale); + DateFormat dateFormat; + Locale locale; if (K9.hideTimeZone()) { + locale=Locale.ROOT; + dateFormat = DateFormat.getDateTimeInstance(dateStyle, timeStyle, locale); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + } else { + locale = resources.getConfiguration().locale; + dateFormat = DateFormat.getDateTimeInstance(dateStyle, timeStyle, locale); } return dateFormat.format(date); } catch (Exception e) { diff --git a/k9mail/src/main/res/values/strings.xml b/k9mail/src/main/res/values/strings.xml index c6d0d2a76..512c8b7d3 100644 --- a/k9mail/src/main/res/values/strings.xml +++ b/k9mail/src/main/res/values/strings.xml @@ -342,7 +342,7 @@ Please submit bug reports, contribute new features and ask questions at Hide mail client Remove K-9 User-Agent from mail headers Hide timezone - Use UTC instead of local timezone in mail headers and reply quotes + Use UTC instead of local timezone in mail headers and reply header Hide subject in notifications Never When device is locked From 756863c7313e6b17812b9ca89fca3d6281564b61 Mon Sep 17 00:00:00 2001 From: cketti Date: Sun, 26 Mar 2017 22:23:23 +0200 Subject: [PATCH 3/3] Cleanup --- .../main/java/com/fsck/k9/message/quote/QuoteHelper.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/k9mail/src/main/java/com/fsck/k9/message/quote/QuoteHelper.java b/k9mail/src/main/java/com/fsck/k9/message/quote/QuoteHelper.java index 599bb2526..80efc1753 100644 --- a/k9mail/src/main/java/com/fsck/k9/message/quote/QuoteHelper.java +++ b/k9mail/src/main/java/com/fsck/k9/message/quote/QuoteHelper.java @@ -28,14 +28,13 @@ class QuoteHelper { final int dateStyle = DateFormat.LONG; final int timeStyle = DateFormat.LONG; Date date = message.getSentDate(); + DateFormat dateFormat; - Locale locale; if (K9.hideTimeZone()) { - locale=Locale.ROOT; - dateFormat = DateFormat.getDateTimeInstance(dateStyle, timeStyle, locale); + dateFormat = DateFormat.getDateTimeInstance(dateStyle, timeStyle, Locale.ROOT); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); } else { - locale = resources.getConfiguration().locale; + Locale locale = resources.getConfiguration().locale; dateFormat = DateFormat.getDateTimeInstance(dateStyle, timeStyle, locale); } return dateFormat.format(date);