mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
MessageView: Theme fix when global and message view theme differ
- Since the split-view change, MessageView is only a fragment, so we
can't call setTheme() anymore so easily.
Instead, use a ContextThemeWrapper and use that to inflate the
layout. This way the message header and attachment view
are styled correctly.
- The HTC WebView fix in SingleMessageView was returning the wrong
background color, when message view theme and global theme differ,
because it always used the global theme to retrieve it.
Fix: Specifically put the light/dark values in the themes.xml,
and get them using getContext().getTheme().resolveAttribute().
getContext() will use the ContextThemeWrapper from above, so
even if the global and message view themes differ, it aleays
returns the correct one.
The getThemeBackgroundColor() method added to the K9ActivityMagic
interface in 309eeb72ac
is now not
needed anymore, and was removed.
This commit is contained in:
parent
2c87efe5f3
commit
a74d57cb71
@ -50,6 +50,7 @@
|
||||
<attr name="messageListThreadCountBackground" format="reference|color"/>
|
||||
<attr name="messageListActiveItemBackgroundColor" format="reference|color"/>
|
||||
<attr name="messageListDividerColor" format="reference|color"/>
|
||||
<attr name="messageViewHeaderBackgroundColor" format="reference|color"/>
|
||||
|
||||
</declare-styleable>
|
||||
|
||||
|
@ -49,6 +49,7 @@
|
||||
<item name="messageListThreadCountBackground">@drawable/thread_count_box_light</item>
|
||||
<item name="messageListActiveItemBackgroundColor">#ff2ea7d1</item>
|
||||
<item name="messageListDividerColor">#ffcccccc</item>
|
||||
<item name="messageViewHeaderBackgroundColor">#ffffffff</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.K9.Dark.Base" parent="Theme.Sherlock">
|
||||
@ -100,6 +101,7 @@
|
||||
<item name="messageListThreadCountBackground">@drawable/thread_count_box_dark</item>
|
||||
<item name="messageListActiveItemBackgroundColor">#ff33b5e5</item>
|
||||
<item name="messageListDividerColor">#ff333333</item>
|
||||
<item name="messageViewHeaderBackgroundColor">#000000</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.K9.Light" parent="Theme.K9.Light.Base">
|
||||
|
@ -25,11 +25,6 @@ public class K9Activity extends SherlockActivity implements K9ActivityMagic {
|
||||
return super.dispatchTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getThemeBackgroundColor() {
|
||||
return mBase.getThemeBackgroundColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupGestureDetector(OnSwipeGestureListener listener) {
|
||||
mBase.setupGestureDetector(listener);
|
||||
|
@ -62,7 +62,6 @@ public class K9ActivityCommon {
|
||||
* in {@link K9ActivityCommon}.</p>
|
||||
*/
|
||||
public interface K9ActivityMagic {
|
||||
int getThemeBackgroundColor();
|
||||
void setupGestureDetector(OnSwipeGestureListener listener);
|
||||
}
|
||||
|
||||
|
@ -25,11 +25,6 @@ public class K9FragmentActivity extends SherlockFragmentActivity implements K9Ac
|
||||
return super.dispatchTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getThemeBackgroundColor() {
|
||||
return mBase.getThemeBackgroundColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupGestureDetector(OnSwipeGestureListener listener) {
|
||||
mBase.setupGestureDetector(listener);
|
||||
|
@ -54,11 +54,6 @@ public class K9ListActivity extends SherlockListActivity implements K9ActivityMa
|
||||
mDateFormat = DateFormatter.getDateFormat(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getThemeBackgroundColor() {
|
||||
return mBase.getThemeBackgroundColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupGestureDetector(OnSwipeGestureListener listener) {
|
||||
mBase.setupGestureDetector(listener);
|
||||
|
@ -12,6 +12,7 @@ import android.os.Handler;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.util.Log;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -169,8 +170,10 @@ public class MessageViewFragment extends SherlockFragment implements OnClickList
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
||||
View view = inflater.inflate(R.layout.message, container, false);
|
||||
Context context = new ContextThemeWrapper(getActivity().getApplicationContext(),
|
||||
K9.getK9ThemeResourceId(K9.getK9MessageViewTheme()));
|
||||
LayoutInflater localInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
View view = localInflater.inflate(R.layout.message, container, false);
|
||||
|
||||
|
||||
mMessageView = (SingleMessageView) view.findViewById(R.id.message_view);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.fsck.k9.view;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
@ -14,6 +15,7 @@ import android.os.Parcelable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.KeyEvent;
|
||||
@ -32,7 +34,6 @@ import android.widget.Toast;
|
||||
import com.fsck.k9.Account;
|
||||
import com.fsck.k9.K9;
|
||||
import com.fsck.k9.R;
|
||||
import com.fsck.k9.activity.K9ActivityCommon.K9ActivityMagic;
|
||||
import com.fsck.k9.controller.MessagingController;
|
||||
import com.fsck.k9.controller.MessagingListener;
|
||||
import com.fsck.k9.crypto.CryptoProvider;
|
||||
@ -159,7 +160,9 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
|
||||
mHeaderPlaceHolder.removeView(mHeaderContainer);
|
||||
// the HTC version of WebView tries to force the background of the
|
||||
// titlebar, which is really unfair.
|
||||
mHeaderContainer.setBackgroundColor(((K9ActivityMagic)activity).getThemeBackgroundColor());
|
||||
TypedValue outValue = new TypedValue();
|
||||
getContext().getTheme().resolveAttribute(R.attr.messageViewHeaderBackgroundColor, outValue, true);
|
||||
mHeaderContainer.setBackgroundColor(outValue.data);
|
||||
|
||||
mTitleBarHeaderContainer = new LinearLayout(activity);
|
||||
mMessageContentView.setEmbeddedTitleBarCompat(mTitleBarHeaderContainer);
|
||||
|
Loading…
Reference in New Issue
Block a user