diff --git a/res/menu/message_view_option.xml b/res/menu/message_view_option.xml index c27a127c1..6aedc5846 100644 --- a/res/menu/message_view_option.xml +++ b/res/menu/message_view_option.xml @@ -72,4 +72,9 @@ android:title="@string/select_text_action" android:showAsAction="never" /> + diff --git a/res/values/strings.xml b/res/values/strings.xml index 26ae0cb63..b609fed61 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -164,6 +164,9 @@ http://k9mail.googlecode.com/ Hide full header Select text + Change background to black + Change background to white + Mark as unread Add Cc/Bcc Read receipt diff --git a/src/com/fsck/k9/K9.java b/src/com/fsck/k9/K9.java index e40fa6e1f..c3d4602a5 100644 --- a/src/com/fsck/k9/K9.java +++ b/src/com/fsck/k9/K9.java @@ -78,6 +78,7 @@ public class K9 extends Application { private static String language = ""; private static int theme = THEME_LIGHT; + private static int messageViewTheme = THEME_LIGHT; private static final FontSizes fontSizes = new FontSizes(); @@ -458,6 +459,7 @@ public class K9 extends Application { editor.putString("language", language); editor.putInt("theme", theme); + editor.putInt("messageViewTheme", messageViewTheme); editor.putBoolean("useGalleryBugWorkaround", useGalleryBugWorkaround); editor.putBoolean("confirmDelete", mConfirmDelete); @@ -661,6 +663,8 @@ public class K9 extends Application { theme = THEME_LIGHT; } K9.setK9Theme(theme); + + K9.setK9MessageViewTheme(sprefs.getInt("messageViewTheme", THEME_LIGHT)); } private void maybeSetupStrictMode() { @@ -727,6 +731,10 @@ public class K9 extends Application { return getK9ThemeResourceId(theme); } + public static int getK9MessageViewTheme() { + return messageViewTheme; + } + public static int getK9Theme() { return theme; } @@ -735,6 +743,10 @@ public class K9 extends Application { theme = ntheme; } + public static void setK9MessageViewTheme(int nMessageViewTheme) { + messageViewTheme = nMessageViewTheme; + } + public static BACKGROUND_OPS getBackgroundOps() { return backgroundOps; } diff --git a/src/com/fsck/k9/activity/MessageView.java b/src/com/fsck/k9/activity/MessageView.java index cc0aece75..7b0be8de3 100644 --- a/src/com/fsck/k9/activity/MessageView.java +++ b/src/com/fsck/k9/activity/MessageView.java @@ -9,7 +9,9 @@ import android.app.Dialog; import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences.Editor; import android.net.Uri; +import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.util.Log; @@ -72,6 +74,8 @@ public class MessageView extends K9Activity implements OnClickListener { private MessageViewHandler mHandler = new MessageViewHandler(); private StorageManager.StorageListener mStorageListener = new StorageListenerImplementation(); + private MenuItem mToggleMessageViewMenu; + /** this variable is used to save the calling AttachmentView * until the onActivityResult is called. * => with this reference we can identity the caller @@ -602,6 +606,26 @@ public class MessageView extends K9Activity implements OnClickListener { startRefileActivity(ACTIVITY_CHOOSE_FOLDER_COPY); } + private void onToggleColors() { + if (K9.getK9MessageViewTheme() == K9.THEME_DARK) { + K9.setK9MessageViewTheme(K9.THEME_LIGHT); + } else { + K9.setK9MessageViewTheme(K9.THEME_DARK); + } + + new AsyncTask() { + @Override + protected Object doInBackground(Object... params) { + Preferences prefs = Preferences.getPreferences(getApplicationContext()); + Editor editor = prefs.getPreferences().edit(); + K9.save(editor); + editor.commit(); + return null; + } + }.execute(); + displayMessage(mMessageReference); + } + private void startRefileActivity(int activity) { Intent intent = new Intent(this, ChooseFolder.class); intent.putExtra(ChooseFolder.EXTRA_ACCOUNT, mAccount.getUuid()); @@ -788,6 +812,9 @@ public class MessageView extends K9Activity implements OnClickListener { case R.id.select_text: mMessageView.beginSelectingText(); break; + case R.id.toggle_message_view_theme: + onToggleColors(); + break; default: return super.onOptionsItemSelected(item); } @@ -814,6 +841,14 @@ public class MessageView extends K9Activity implements OnClickListener { menu.findItem(R.id.move).setVisible(true); menu.findItem(R.id.archive).setVisible(true); menu.findItem(R.id.spam).setVisible(true); + + mToggleMessageViewMenu = menu.findItem(R.id.toggle_message_view_theme); + if (K9.getK9MessageViewTheme() == K9.THEME_DARK) { + mToggleMessageViewMenu.setTitle(R.string.message_view_theme_action_light); + } else { + mToggleMessageViewMenu.setTitle(R.string.message_view_theme_action_dark); + } + toggleActionsState(menu, true); if (mNextMessage != null) { diff --git a/src/com/fsck/k9/preferences/GlobalSettings.java b/src/com/fsck/k9/preferences/GlobalSettings.java index bb9d7bbe0..91ab24857 100644 --- a/src/com/fsck/k9/preferences/GlobalSettings.java +++ b/src/com/fsck/k9/preferences/GlobalSettings.java @@ -191,6 +191,9 @@ public class GlobalSettings { s.put("theme", Settings.versions( new V(1, new ThemeSetting(K9.THEME_LIGHT)) )); + s.put("messageViewTheme", Settings.versions( + new V(16, new ThemeSetting(K9.THEME_LIGHT)) + )); s.put("useGalleryBugWorkaround", Settings.versions( new V(1, new GalleryBugWorkaroundSetting()) )); diff --git a/src/com/fsck/k9/preferences/Settings.java b/src/com/fsck/k9/preferences/Settings.java index 99232af10..9ad150823 100644 --- a/src/com/fsck/k9/preferences/Settings.java +++ b/src/com/fsck/k9/preferences/Settings.java @@ -35,7 +35,7 @@ public class Settings { * * @see SettingsExporter */ - public static final int VERSION = 15; + public static final int VERSION = 16; public static Map validate(int version, Map> settings, diff --git a/src/com/fsck/k9/view/MessageWebView.java b/src/com/fsck/k9/view/MessageWebView.java index 8869a1d89..44c8559e7 100644 --- a/src/com/fsck/k9/view/MessageWebView.java +++ b/src/com/fsck/k9/view/MessageWebView.java @@ -94,10 +94,13 @@ public class MessageWebView extends TitleBarWebView { this.setScrollBarStyle(SCROLLBARS_INSIDE_OVERLAY); this.setLongClickable(true); - if (K9.getK9Theme() == K9.THEME_DARK) { + if (K9.getK9MessageViewTheme() == K9.THEME_DARK) { // Black theme should get a black webview background // we'll set the background of the messages on load this.setBackgroundColor(0xff000000); + } else { + // multitoggle requires reset to white + this.setBackgroundColor(0xffffffff); } final WebSettings webSettings = this.getSettings(); @@ -152,7 +155,7 @@ public class MessageWebView extends TitleBarWebView { public void setText(String text, String contentType) { String content = text; - if (K9.getK9Theme() == K9.THEME_DARK) { + if (K9.getK9MessageViewTheme() == K9.THEME_DARK) { // It's a little wrong to just throw in the