Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6073b9d3 authored by cketti's avatar cketti
Browse files

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.
parent a4677029
Loading
Loading
Loading
Loading
+4 −10
Original line number Original line Diff line number Diff line
@@ -146,15 +146,9 @@ public class MessageWebView extends WebView {
        }
        }
    }
    }


    public void wrapSetTitleBar(final View title) {
    public void wrapSetTitleBar(final View title) throws Exception {
        try {
        Class<?> webViewClass = Class.forName("android.webkit.WebView");
        Class<?> webViewClass = Class.forName("android.webkit.WebView");
        Method setEmbeddedTitleBar = webViewClass.getMethod("setEmbeddedTitleBar", View.class);
        Method setEmbeddedTitleBar = webViewClass.getMethod("setEmbeddedTitleBar", View.class);
        setEmbeddedTitleBar.invoke(this, title);
        setEmbeddedTitleBar.invoke(this, title);
    }
    }

        catch (Exception e) {
            Log.v(K9.LOG_TAG, "failed to find the  setEmbeddedTitleBar method",e);
        }
    }
}
}
+13 −1
Original line number Original line Diff line number Diff line
@@ -159,7 +159,19 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,


            mTitleBarHeaderContainer = new LinearLayout(activity);
            mTitleBarHeaderContainer = new LinearLayout(activity);
            mTitleBarHeaderContainer.addView(mHeaderContainer);
            mTitleBarHeaderContainer.addView(mHeaderContainer);
            try {
                mMessageContentView.wrapSetTitleBar(mTitleBarHeaderContainer);
                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);
        mShowHiddenAttachments.setOnClickListener(this);