mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-16 06:25:06 -05:00
Added fallback for when WebView.setEmbeddedTitleBar() is not available
The (undocumented) method WebView.setEmbeddedTitleBar() was removed in Android 4.1 which caused the message header to never be displayed. This fallback is only a temporary fix. We really need to come up with a solution that feels like the previous (setEmbeddedTitleBar) behavior.
This commit is contained in:
parent
a4677029be
commit
6073b9d3fa
@ -146,15 +146,9 @@ public class MessageWebView extends WebView {
|
||||
}
|
||||
}
|
||||
|
||||
public void wrapSetTitleBar(final View title) {
|
||||
try {
|
||||
public void wrapSetTitleBar(final View title) throws Exception {
|
||||
Class<?> webViewClass = Class.forName("android.webkit.WebView");
|
||||
Method setEmbeddedTitleBar = webViewClass.getMethod("setEmbeddedTitleBar", View.class);
|
||||
setEmbeddedTitleBar.invoke(this, title);
|
||||
}
|
||||
|
||||
catch (Exception e) {
|
||||
Log.v(K9.LOG_TAG, "failed to find the setEmbeddedTitleBar method",e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +159,19 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
|
||||
|
||||
mTitleBarHeaderContainer = new LinearLayout(activity);
|
||||
mTitleBarHeaderContainer.addView(mHeaderContainer);
|
||||
try {
|
||||
mMessageContentView.wrapSetTitleBar(mTitleBarHeaderContainer);
|
||||
} catch (Exception e) {
|
||||
// If wrapSetTitleBar() fails we put the header back. This isn't a very good
|
||||
// fall-back but better than not displaying the message header at all.
|
||||
|
||||
// FIXME: Get rid of the setEmbeddedTitleBar-method and come up with something that
|
||||
// feels just like it but doesn't use undocumented methods.
|
||||
|
||||
mTitleBarHeaderContainer.removeView(mHeaderContainer);
|
||||
mHeaderPlaceHolder.addView(mHeaderContainer);
|
||||
mTitleBarHeaderContainer = null;
|
||||
}
|
||||
}
|
||||
|
||||
mShowHiddenAttachments.setOnClickListener(this);
|
||||
|
Loading…
Reference in New Issue
Block a user