1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-24 08:38:51 -05:00

Enabled dark theme for MessageCompose and MessageView

This commit is contained in:
cketti 2012-04-03 03:41:44 +02:00
parent d1c065230f
commit 4612ceb3c8
8 changed files with 33 additions and 30 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 434 B

After

Width:  |  Height:  |  Size: 570 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 436 B

After

Width:  |  Height:  |  Size: 570 B

View File

@ -2,8 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#ffffff" >
android:orientation="vertical">
<ScrollView
android:layout_width="fill_parent"
@ -23,7 +22,7 @@
android:layout_marginBottom="4dp"
android:paddingTop="6dp"
android:orientation="vertical"
android:background="#ededed" >
android:background="#45bcbcbc">
<Button
android:id="@+id/identity"
@ -47,7 +46,6 @@
android:inputType="textEmailAddress|textMultiLine"
android:imeOptions="actionNext"
android:hint="@string/message_compose_to_hint"
android:textColor="@android:color/primary_text_light"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="0dp"
android:layout_marginRight="6dip"
@ -81,7 +79,6 @@
android:inputType="textEmailAddress|textMultiLine"
android:imeOptions="actionNext"
android:hint="@string/message_compose_cc_hint"
android:textColor="@android:color/primary_text_light"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<ImageButton
@ -112,7 +109,6 @@
android:inputType="textEmailAddress|textMultiLine"
android:imeOptions="actionNext"
android:hint="@string/message_compose_bcc_hint"
android:textColor="@android:color/primary_text_light"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<ImageButton
@ -144,7 +140,6 @@
<CheckBox
android:text="@string/btn_crypto_sign"
android:id="@+id/cb_crypto_signature"
android:textColor="@android:color/primary_text_light"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
@ -160,7 +155,6 @@
android:id="@+id/userId"
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/primary_text_light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
@ -168,7 +162,6 @@
android:id="@+id/userIdRest"
android:textSize="10sp"
android:ellipsize="end"
android:textColor="@android:color/primary_text_light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
@ -179,7 +172,6 @@
<CheckBox
android:text="@string/btn_encrypt"
android:id="@+id/cb_encrypt"
android:textColor="@android:color/primary_text_light"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -197,7 +189,6 @@
android:inputType="textEmailSubject|textAutoCorrect|textCapSentences|textImeMultiLine"
android:imeOptions="actionNext"
android:singleLine="true"
android:textColor="@android:color/primary_text_light"
android:textAppearance="?android:attr/textAppearanceMedium" />
<!--
@ -229,7 +220,6 @@
android:inputType="textMultiLine|textAutoCorrect|textCapSentences"
android:imeOptions="actionDone|flagNoEnterAction"
android:minLines="3"
android:textColor="@android:color/primary_text_light"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
@ -243,7 +233,6 @@
android:capitalize="sentences"
android:hint="@string/message_compose_signature_hint"
android:inputType="textMultiLine|textAutoCorrect|textCapSentences"
android:textColor="@android:color/primary_text_light"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
@ -270,7 +259,6 @@
android:autoText="true"
android:capitalize="sentences"
android:inputType="textMultiLine|textAutoCorrect|textCapSentences"
android:textColor="@android:color/primary_text_light"
android:textAppearance="?android:attr/textAppearanceMedium" />
<com.fsck.k9.view.MessageWebView
@ -315,7 +303,6 @@
android:capitalize="sentences"
android:hint="@string/message_compose_signature_hint"
android:inputType="textMultiLine|textAutoCorrect|textCapSentences"
android:textColor="@android:color/primary_text_light"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>

View File

@ -23,14 +23,8 @@ public class K9Activity extends Activity {
@Override
public void onCreate(Bundle icicle) {
onCreate(icicle, true);
}
public void onCreate(Bundle icicle, boolean useTheme) {
setLanguage(this, K9.getK9Language());
if (useTheme) {
setTheme(K9.getK9ThemeResourceId());
}
setTheme(K9.getK9ThemeResourceId());
super.onCreate(icicle);
setupFormats();

View File

@ -19,12 +19,14 @@ import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.ContentResolver;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Parcelable;
@ -377,7 +379,6 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(K9.getK9ThemeResourceId(K9.THEME_LIGHT));
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.message_compose);
@ -952,7 +953,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
if (mQuotedTextMode != QuotedTextMode.NONE && mMessageFormat == MessageFormat.HTML) {
mQuotedHtmlContent = (InsertableHtmlContent) savedInstanceState.getSerializable(STATE_KEY_HTML_QUOTE);
if (mQuotedHtmlContent != null && mQuotedHtmlContent.getQuotedContent() != null) {
mQuotedHTML.loadDataWithBaseURL("http://", mQuotedHtmlContent.getQuotedContent(), "text/html", "utf-8", null);
mQuotedHTML.setText(mQuotedHtmlContent.getQuotedContent(), "text/html");
}
}
mDraftId = savedInstanceState.getLong(STATE_KEY_DRAFT_ID);
@ -2119,9 +2120,11 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
})
.create();
case DIALOG_CHOOSE_IDENTITY:
Builder builder = new AlertDialog.Builder(this);
Context context = new ContextWrapper(this);
context.setTheme(K9.getK9ThemeResourceId(K9.THEME_LIGHT));
Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.send_as);
final IdentityAdapter adapter = new IdentityAdapter(this, getLayoutInflater());
final IdentityAdapter adapter = new IdentityAdapter(context, getLayoutInflater());
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@ -2480,7 +2483,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
} else {
mQuotedHtmlContent.setFooterInsertionPoint(bodyOffset);
}
mQuotedHTML.loadDataWithBaseURL("http://", mQuotedHtmlContent.getQuotedContent(), "text/html", "utf-8", null);
mQuotedHTML.setText(mQuotedHtmlContent.getQuotedContent(), "text/html");
}
}
if (bodyPlainOffset != null && bodyPlainLength != null) {
@ -2663,7 +2666,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
// Add the HTML reply header to the top of the content.
mQuotedHtmlContent = quoteOriginalHtmlMessage(mSourceMessage, content, mQuoteStyle);
// Load the message with the reply header.
mQuotedHTML.loadDataWithBaseURL("http://", mQuotedHtmlContent.getQuotedContent(), "text/html", "utf-8", null);
mQuotedHTML.setText(mQuotedHtmlContent.getQuotedContent(), "text/html");
mQuotedText.setText(quoteOriginalTextMessage(mSourceMessage,
getBodyTextFromMessage(mSourceMessage, MessageFormat.TEXT), mQuoteStyle));

View File

@ -287,7 +287,7 @@ public class MessageView extends K9Activity implements OnClickListener {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle, false);
super.onCreate(icicle);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.message_view);

View File

@ -72,6 +72,12 @@ public class MessageWebView extends WebView {
this.setScrollBarStyle(SCROLLBARS_INSIDE_OVERLAY);
this.setLongClickable(true);
if (K9.getK9Theme() == K9.THEME_DARK) {
// Black theme should get a black webview background
// we'll set the background of the messages on load
this.setBackgroundColor(0xff000000);
}
final WebSettings webSettings = this.getSettings();
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
@ -104,6 +110,19 @@ public class MessageWebView extends WebView {
}
public void setText(String text, String contentType) {
String content = text;
if (K9.getK9Theme() == K9.THEME_DARK) {
// It's a little wrong to just throw in the <style> before the opening <html>
// but it's less wrong than trying to edit the html stream
content = "<style>* { background: black ! important; color: white !important }" +
":link, :link * { color: #CCFF33 !important }" +
":visited, :visited * { color: #551A8B !important }</style> "
+ content;
}
loadDataWithBaseURL("http://", content, contentType, "utf-8", null);
}
/*
* Emulate the shift key being pressed to trigger the text selection mode
* of a WebView.

View File

@ -600,7 +600,7 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
if (mScreenReaderEnabled) {
mAccessibleMessageContentView.loadDataWithBaseURL("http://", emailText, contentType, "utf-8", null);
} else {
mMessageContentView.loadDataWithBaseURL("http://", emailText, contentType, "utf-8", null);
mMessageContentView.setText(emailText, contentType);
mMessageContentView.scrollTo(0, 0);
}