1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-08-13 17:03:48 -04: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:
cketti 2012-06-29 00:14:06 +02:00
parent a4677029be
commit 6073b9d3fa
2 changed files with 17 additions and 11 deletions

View File

@ -146,15 +146,9 @@ public class MessageWebView extends WebView {
}
}
public void wrapSetTitleBar(final View title) {
try {
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);
}
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);
}
}

View File

@ -159,7 +159,19 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
mTitleBarHeaderContainer = new LinearLayout(activity);
mTitleBarHeaderContainer.addView(mHeaderContainer);
mMessageContentView.wrapSetTitleBar(mTitleBarHeaderContainer);
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);