1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Issue 6372: Add preference for setting timezone to UTC.

This is a privacy preference to avoid leaking your current location while
replying to email.
This commit is contained in:
Mike Perry 2014-05-26 17:14:07 -07:00
parent 87802a01ef
commit 38c90146e1
6 changed files with 31 additions and 0 deletions

View File

@ -332,6 +332,7 @@ Please submit bug reports, contribute new features and ask questions at
<string name="global_settings_confirm_action_delete_notif">Delete (from notification)</string>
<string name="global_settings_privacy_hide_useragent">Remove K-9 User-Agent from mail headers</string>
<string name="global_settings_privacy_hide_timezone">Use UTC as time zone in mail headers</string>
<string name="global_settings_notification_hide_subject_title">Hide subject in notifications</string>
<string name="global_settings_notification_hide_subject_never">Never</string>
<string name="global_settings_notification_hide_subject_when_locked">When device is locked</string>

View File

@ -383,6 +383,11 @@
android:key="privacy_hide_useragent"
android:title="@string/global_settings_privacy_hide_useragent"/>
<CheckBoxPreference
android:persistent="false"
android:key="privacy_hide_timezone"
android:title="@string/global_settings_privacy_hide_timezone"/>
</PreferenceScreen>
<PreferenceScreen

View File

@ -263,6 +263,7 @@ public class K9 extends Application {
private static String mAttachmentDefaultPath = "";
private static boolean mWrapFolderNames = false;
private static boolean mHideUserAgent = false;
private static boolean mHideTimeZone = false;
private static boolean useGalleryBugWorkaround = false;
private static boolean galleryBuggy;
@ -537,6 +538,7 @@ public class K9 extends Application {
editor.putBoolean("messageViewShowNext", mMessageViewShowNext);
editor.putBoolean("wrapFolderNames", mWrapFolderNames);
editor.putBoolean("hideUserAgent", mHideUserAgent);
editor.putBoolean("hideTimeZone", mHideTimeZone);
editor.putString("language", language);
editor.putInt("theme", theme.ordinal());
@ -748,6 +750,7 @@ public class K9 extends Application {
mMessageViewShowNext = sprefs.getBoolean("messageViewShowNext", false);
mWrapFolderNames = sprefs.getBoolean("wrapFolderNames", false);
mHideUserAgent = sprefs.getBoolean("hideUserAgent", false);
mHideTimeZone = sprefs.getBoolean("hideTimeZone", false);
useGalleryBugWorkaround = sprefs.getBoolean("useGalleryBugWorkaround", K9.isGalleryBuggy());
@ -1284,6 +1287,13 @@ public class K9 extends Application {
mHideUserAgent = state;
}
public static boolean hideTimeZone() {
return mHideTimeZone;
}
public static void setHideTimeZone(final boolean state) {
mHideTimeZone = state;
}
public static String getAttachmentDefaultPath() {
return mAttachmentDefaultPath;
}

View File

@ -86,6 +86,7 @@ public class Prefs extends K9PreferenceActivity {
private static final String PREFERENCE_QUIET_TIME_ENDS = "quiet_time_ends";
private static final String PREFERENCE_NOTIF_QUICK_DELETE = "notification_quick_delete";
private static final String PREFERENCE_HIDE_USERAGENT = "privacy_hide_useragent";
private static final String PREFERENCE_HIDE_TIMEZONE = "privacy_hide_timezone";
private static final String PREFERENCE_MESSAGEVIEW_MOBILE_LAYOUT = "messageview_mobile_layout";
private static final String PREFERENCE_AUTOFIT_WIDTH = "messageview_autofit_width";
@ -142,6 +143,7 @@ public class Prefs extends K9PreferenceActivity {
private CheckBoxPreference mDebugLogging;
private CheckBoxPreference mSensitiveLogging;
private CheckBoxPreference mHideUserAgent;
private CheckBoxPreference mHideTimeZone;
private CheckBoxPreference mWrapFolderNames;
private CheckBoxListPreference mVisibleRefileActions;
@ -385,10 +387,12 @@ public class Prefs extends K9PreferenceActivity {
mDebugLogging = (CheckBoxPreference)findPreference(PREFERENCE_DEBUG_LOGGING);
mSensitiveLogging = (CheckBoxPreference)findPreference(PREFERENCE_SENSITIVE_LOGGING);
mHideUserAgent = (CheckBoxPreference)findPreference(PREFERENCE_HIDE_USERAGENT);
mHideTimeZone = (CheckBoxPreference)findPreference(PREFERENCE_HIDE_TIMEZONE);
mDebugLogging.setChecked(K9.DEBUG);
mSensitiveLogging.setChecked(K9.DEBUG_SENSITIVE);
mHideUserAgent.setChecked(K9.hideUserAgent());
mHideTimeZone.setChecked(K9.hideTimeZone());
mAttachmentPathPreference = findPreference(PREFERENCE_ATTACHMENT_DEF_PATH);
mAttachmentPathPreference.setSummary(K9.getAttachmentDefaultPath());
@ -537,6 +541,7 @@ public class Prefs extends K9PreferenceActivity {
K9.DEBUG = mDebugLogging.isChecked();
K9.DEBUG_SENSITIVE = mSensitiveLogging.isChecked();
K9.setHideUserAgent(mHideUserAgent.isChecked());
K9.setHideTimeZone(mHideTimeZone.isChecked());
Editor editor = preferences.edit();
K9.save(editor);

View File

@ -8,6 +8,7 @@ import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import java.util.LinkedList;
import java.util.Locale;
import java.util.Set;
@ -33,6 +34,7 @@ import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Multipart;
import com.fsck.k9.mail.Part;
import com.fsck.k9.mail.store.UnavailableStorageException;
import com.fsck.k9.K9;
/**
* An implementation of Message that stores all of it's metadata in RFC 822 and
@ -150,6 +152,11 @@ public class MimeMessage extends Message {
if (mDateFormat == null) {
mDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US);
}
if (K9.hideTimeZone()) {
mDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
}
addHeader("Date", mDateFormat.format(sentDate));
setInternalSentDate(sentDate);
}

View File

@ -252,6 +252,9 @@ public class GlobalSettings {
s.put("hideUserAgent", Settings.versions(
new V(32, new BooleanSetting(false))
));
s.put("hideTimeZone", Settings.versions(
new V(32, new BooleanSetting(false))
));
SETTINGS = Collections.unmodifiableMap(s);