mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-30 14:50:14 -05:00
Switch to using NonLockingScrollView
This implements the AOSP Email solution for incorporating a Webview inside a ScrollView, while still being able to scroll diagonally. This replaces the functionality of TitleBarWebView (which is now removed).
This commit is contained in:
parent
f4de21187d
commit
94a4585317
@ -7,64 +7,62 @@
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="1">
|
||||
|
||||
<!-- Header area -->
|
||||
<LinearLayout
|
||||
android:id="@+id/message_view_header_container"
|
||||
android:layout_width="wrap_content"
|
||||
<com.fsck.k9.view.NonLockingScrollView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<include layout="@layout/message_view_header"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Content area -->
|
||||
<com.fsck.k9.view.MessageWebView
|
||||
android:id="@+id/message_content"
|
||||
android:layout_height="0dip"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="fill_parent"/>
|
||||
|
||||
<com.fsck.k9.view.AccessibleWebView
|
||||
android:id="@+id/accessible_message_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"/>
|
||||
|
||||
<!-- Attachments area -->
|
||||
<ScrollView
|
||||
android:id="@+id/attachments_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/inside_attachments_container"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/attachments"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dip" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/show_hidden_attachments"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/message_view_show_more_attachments_action"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/hidden_attachments"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dip"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
<!-- Header area -->
|
||||
<include layout="@layout/message_view_header"/>
|
||||
|
||||
<!-- Content area -->
|
||||
<com.fsck.k9.view.MessageWebView
|
||||
android:id="@+id/message_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"/>
|
||||
|
||||
<com.fsck.k9.view.AccessibleWebView
|
||||
android:id="@+id/accessible_message_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"/>
|
||||
|
||||
<!-- Attachments area -->
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/attachments_container"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/attachments"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dip" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/show_hidden_attachments"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/message_view_show_more_attachments_action"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/hidden_attachments"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dip"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.fsck.k9.view.NonLockingScrollView>
|
||||
|
||||
<Button android:id="@+id/download_remainder"
|
||||
android:text="@string/message_view_download_remainder"
|
||||
|
@ -1,262 +1,255 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.fsck.k9.view.MessageHeader
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/header_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/header_container"
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<!-- Color chip -->
|
||||
<View
|
||||
android:id="@+id/chip"
|
||||
android:layout_width="8dip"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
<TextView
|
||||
android:id="@+id/subject"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<!-- Color chip -->
|
||||
<View
|
||||
android:id="@+id/chip"
|
||||
android:layout_width="8dip"
|
||||
android:layout_height="match_parent"/>
|
||||
android:maxLines="3"
|
||||
android:ellipsize="end"
|
||||
android:textStyle="bold"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="@string/general_no_subject"
|
||||
android:padding="8dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<QuickContactBadge
|
||||
android:id="@+id/contact_badge"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginLeft="8dp" />
|
||||
|
||||
<!-- State icons -->
|
||||
<LinearLayout
|
||||
android:id="@+id/icon_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dip"
|
||||
android:layout_marginBottom="2dip"
|
||||
android:layout_below="@+id/contact_badge"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<View
|
||||
android:id="@+id/answered"
|
||||
android:layout_width="32sp"
|
||||
android:layout_height="32sp"
|
||||
android:paddingRight="2dip"
|
||||
android:background="@drawable/ic_email_answered_small" />
|
||||
|
||||
<View
|
||||
android:id="@+id/forwarded"
|
||||
android:layout_width="22sp"
|
||||
android:layout_height="22sp"
|
||||
android:paddingRight="4dip"
|
||||
android:background="@drawable/ic_email_forwarded_small" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:padding="6dip"
|
||||
android:layout_marginLeft="2dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subject"
|
||||
android:layout_width="match_parent"
|
||||
<!-- From -->
|
||||
<TextView
|
||||
android:id="@+id/from"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="3"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_toLeftOf="@+id/flagged"
|
||||
android:paddingTop="0dp"
|
||||
android:paddingRight="6dip"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="end"
|
||||
android:textStyle="bold"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="@string/general_no_subject"
|
||||
android:padding="8dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/general_no_sender" />
|
||||
|
||||
<!-- To -->
|
||||
<TextView
|
||||
android:id="@+id/to_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
android:layout_alignLeft="@+id/from"
|
||||
android:layout_alignBaseline="@+id/to"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingRight="4dp"
|
||||
android:text="@string/message_to_label"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textAppearance="@android:style/TextAppearance.Medium"
|
||||
android:textStyle="bold" />
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<QuickContactBadge
|
||||
android:id="@+id/contact_badge"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginLeft="8dp" />
|
||||
|
||||
<!-- State icons -->
|
||||
<LinearLayout
|
||||
android:id="@+id/icon_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dip"
|
||||
android:layout_marginBottom="2dip"
|
||||
android:layout_below="@+id/contact_badge"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:id="@+id/answered"
|
||||
android:layout_width="32sp"
|
||||
android:layout_height="32sp"
|
||||
android:paddingRight="2dip"
|
||||
android:background="@drawable/ic_email_answered_small"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/forwarded"
|
||||
android:layout_width="22sp"
|
||||
android:layout_height="22sp"
|
||||
android:paddingRight="4dip"
|
||||
android:background="@drawable/ic_email_forwarded_small"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="6dip"
|
||||
android:layout_marginLeft="2dp">
|
||||
|
||||
<!-- From -->
|
||||
<TextView
|
||||
android:id="@+id/from"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_toLeftOf="@+id/flagged"
|
||||
android:paddingTop="0dp"
|
||||
android:paddingRight="6dip"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="end"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/general_no_sender" />
|
||||
|
||||
<!-- To -->
|
||||
<TextView
|
||||
android:id="@+id/to_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@+id/from"
|
||||
android:layout_alignBaseline="@+id/to"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingRight="4dp"
|
||||
android:text="@string/message_to_label"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textAppearance="@android:style/TextAppearance.Medium"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/to"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@+id/to_label"
|
||||
android:layout_below="@+id/from"
|
||||
android:layout_toLeftOf="@+id/flagged"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:paddingTop="2dp"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textAppearance="@android:style/TextAppearance.Medium" />
|
||||
|
||||
<!-- CC -->
|
||||
<TextView
|
||||
android:id="@+id/cc_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/to_label"
|
||||
android:layout_alignLeft="@+id/to_label"
|
||||
android:layout_alignBaseline="@+id/cc"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingRight="4dp"
|
||||
android:text="@string/message_view_cc_label"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textStyle="bold"
|
||||
android:textAppearance="@android:style/TextAppearance.Medium" /> -->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/cc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@+id/cc_label"
|
||||
android:layout_below="@+id/to"
|
||||
android:layout_toLeftOf="@+id/flagged"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:paddingTop="2dp"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textAppearance="@android:style/TextAppearance.Medium" />
|
||||
|
||||
<!-- Date -->
|
||||
<TextView
|
||||
android:id="@+id/date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/cc"
|
||||
android:layout_alignParentRight="true"
|
||||
android:paddingTop="8dp"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="none"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorSecondary" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/flagged"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignTop="@id/from"
|
||||
android:focusable="false"
|
||||
style="?android:attr/starStyle"
|
||||
android:checked="false" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/additional_headers_view"
|
||||
android:layout_width="match_parent"
|
||||
<TextView
|
||||
android:id="@+id/to"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="8dp"
|
||||
android:layout_marginRight="6dip"
|
||||
android:singleLine="false"
|
||||
android:ellipsize="none"
|
||||
android:layout_toRightOf="@+id/to_label"
|
||||
android:layout_below="@+id/from"
|
||||
android:layout_toLeftOf="@+id/flagged"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:paddingTop="2dp"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textAppearance="@android:style/TextAppearance.Medium" />
|
||||
|
||||
<!-- CC -->
|
||||
<TextView
|
||||
android:id="@+id/cc_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/to_label"
|
||||
android:layout_alignLeft="@+id/to_label"
|
||||
android:layout_alignBaseline="@+id/cc"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingRight="4dp"
|
||||
android:text="@string/message_view_cc_label"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textStyle="bold"
|
||||
android:textAppearance="@android:style/TextAppearance.Medium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/cc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@+id/cc_label"
|
||||
android:layout_below="@+id/to"
|
||||
android:layout_toLeftOf="@+id/flagged"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:paddingTop="2dp"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textAppearance="@android:style/TextAppearance.Medium" />
|
||||
|
||||
<!-- Date -->
|
||||
<TextView
|
||||
android:id="@+id/date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/cc"
|
||||
android:layout_alignParentRight="true"
|
||||
android:paddingTop="8dp"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="none"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textIsSelectable="true" />
|
||||
android:textColor="?android:attr/textColorSecondary" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/flagged"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignTop="@id/from"
|
||||
android:focusable="false"
|
||||
style="?android:attr/starStyle"
|
||||
android:checked="false" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_height="1dip"
|
||||
<TextView
|
||||
android:id="@+id/additional_headers_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:background="@drawable/divider_horizontal_email"/>
|
||||
|
||||
<!-- Button area -->
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right"
|
||||
android:paddingLeft="6dip"
|
||||
android:paddingRight="6dip"
|
||||
android:paddingTop="4dip"
|
||||
android:baselineAligned="false">
|
||||
|
||||
<Button
|
||||
android:id="@+id/show_pictures"
|
||||
android:layout_width="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:layout_marginLeft="6dip"
|
||||
android:layout_marginBottom="4dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/message_view_show_pictures_action"
|
||||
style="?android:attr/buttonStyleSmall"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/show_attachments"
|
||||
android:visibility="gone"
|
||||
android:layout_marginLeft="6dip"
|
||||
android:layout_marginBottom="4dip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/message_view_show_attachments_action"
|
||||
style="?android:attr/buttonStyleSmall"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/show_message"
|
||||
android:visibility="gone"
|
||||
android:layout_marginLeft="6dip"
|
||||
android:layout_marginBottom="4dip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/message_view_show_message_action"
|
||||
style="?android:attr/buttonStyleSmall"/>
|
||||
android:layout_margin="8dp"
|
||||
android:layout_marginRight="6dip"
|
||||
android:singleLine="false"
|
||||
android:ellipsize="none"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textIsSelectable="true" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/message_view_crypto_layout"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_height="1dip"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:background="@drawable/divider_horizontal_email" />
|
||||
|
||||
<!-- Button area -->
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right"
|
||||
android:paddingLeft="6dip"
|
||||
android:paddingRight="6dip"
|
||||
android:paddingTop="4dip"
|
||||
android:baselineAligned="false" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/show_pictures"
|
||||
android:layout_width="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:layout_marginLeft="6dip"
|
||||
android:layout_marginBottom="4dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/message_view_show_pictures_action"
|
||||
style="?android:attr/buttonStyleSmall" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/show_attachments"
|
||||
android:visibility="gone"
|
||||
android:layout_marginLeft="6dip"
|
||||
android:layout_marginBottom="4dip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/message_view_show_attachments_action"
|
||||
style="?android:attr/buttonStyleSmall" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/show_message"
|
||||
android:visibility="gone"
|
||||
android:layout_marginLeft="6dip"
|
||||
android:layout_marginBottom="4dip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/message_view_show_message_action"
|
||||
style="?android:attr/buttonStyleSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/message_view_crypto_layout" />
|
||||
|
||||
</com.fsck.k9.view.MessageHeader>
|
||||
|
@ -1,14 +0,0 @@
|
||||
package android.webkit;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* Trojan class for getting access to a hidden API level 16 interface
|
||||
*/
|
||||
public class WebViewClassic {
|
||||
public interface TitleBarDelegate {
|
||||
int getTitleHeight();
|
||||
|
||||
public void onSetEmbeddedTitleBar(final View title);
|
||||
}
|
||||
}
|
@ -16,8 +16,8 @@ import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.CheckBox;
|
||||
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.QuickContactBadge;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import com.fsck.k9.FontSizes;
|
||||
@ -40,7 +40,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class MessageHeader extends ScrollView implements OnClickListener {
|
||||
public class MessageHeader extends LinearLayout implements OnClickListener {
|
||||
private Context mContext;
|
||||
private TextView mFromView;
|
||||
private TextView mDateView;
|
||||
|
@ -8,15 +8,16 @@ import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.fsck.k9.K9;
|
||||
import com.fsck.k9.R;
|
||||
import com.fsck.k9.helper.HtmlConverter;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import com.nobu_games.android.view.web.TitleBarWebView;
|
||||
|
||||
public class MessageWebView extends TitleBarWebView {
|
||||
public class MessageWebView extends WebView {
|
||||
|
||||
|
||||
/**
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
|
||||
package com.android.email.view;
|
||||
package com.fsck.k9.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
@ -23,6 +23,7 @@ import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.ScrollView;
|
||||
|
||||
@ -60,6 +61,8 @@ public class NonLockingScrollView extends ScrollView {
|
||||
*/
|
||||
private final ArrayList<View> mChildrenNeedingAllTouches = new ArrayList<View>();
|
||||
|
||||
private boolean mSkipWebViewScroll = true;
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
final int action = ev.getActionMasked();
|
||||
@ -136,4 +139,26 @@ public class NonLockingScrollView extends ScrollView {
|
||||
private static boolean canViewReceivePointerEvents(View child) {
|
||||
return child.getVisibility() == VISIBLE || (child.getAnimation() != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestChildFocus(View child, View focused) {
|
||||
/*
|
||||
* Normally a ScrollView will scroll the child into view.
|
||||
* Prevent this when a MessageWebView is first touched,
|
||||
* assuming it already is at least partially in view.
|
||||
*
|
||||
*/
|
||||
if (mSkipWebViewScroll &&
|
||||
focused instanceof MessageWebView &&
|
||||
focused.getGlobalVisibleRect(new Rect())) {
|
||||
mSkipWebViewScroll = false;
|
||||
super.requestChildFocus(child, child);
|
||||
ViewParent parent = getParent();
|
||||
if (parent != null) {
|
||||
parent.requestChildFocus(this, focused);
|
||||
}
|
||||
} else {
|
||||
super.requestChildFocus(child, focused);
|
||||
}
|
||||
}
|
||||
}
|
@ -101,10 +101,7 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
|
||||
private LayoutInflater mInflater;
|
||||
private Contacts mContacts;
|
||||
private AttachmentView.AttachmentFileDownloadCallback attachmentCallback;
|
||||
private LinearLayout mHeaderPlaceHolder;
|
||||
private LinearLayout mTitleBarHeaderContainer;
|
||||
private View mAttachmentsContainer;
|
||||
private LinearLayout mInsideAttachmentsContainer;
|
||||
private SavedState mSavedState;
|
||||
private ClipboardManager mClipboardManager;
|
||||
private String mText;
|
||||
@ -118,13 +115,10 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
|
||||
activity.registerForContextMenu(mMessageContentView);
|
||||
mMessageContentView.setOnCreateContextMenuListener(this);
|
||||
|
||||
mHeaderPlaceHolder = (LinearLayout) findViewById(R.id.message_view_header_container);
|
||||
|
||||
mHeaderContainer = (MessageHeader) findViewById(R.id.header_container);
|
||||
mHeaderContainer.setOnLayoutChangedListener(this);
|
||||
|
||||
mAttachmentsContainer = findViewById(R.id.attachments_container);
|
||||
mInsideAttachmentsContainer = (LinearLayout) findViewById(R.id.inside_attachments_container);
|
||||
mAttachments = (LinearLayout) findViewById(R.id.attachments);
|
||||
mHiddenAttachments = (LinearLayout) findViewById(R.id.hidden_attachments);
|
||||
mHiddenAttachments.setVisibility(View.GONE);
|
||||
@ -157,7 +151,6 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
|
||||
mMessageContentView.setVisibility(View.VISIBLE);
|
||||
mScreenReaderEnabled = false;
|
||||
|
||||
mHeaderPlaceHolder.removeView(mHeaderContainer);
|
||||
// the HTC version of WebView tries to force the background of the
|
||||
// titlebar, which is really unfair.
|
||||
TypedValue outValue = new TypedValue();
|
||||
@ -165,10 +158,6 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
|
||||
mHeaderContainer.setBackgroundColor(outValue.data);
|
||||
// also set background of the whole view (including the attachments view)
|
||||
setBackgroundColor(outValue.data);
|
||||
|
||||
mTitleBarHeaderContainer = new LinearLayout(activity);
|
||||
mMessageContentView.setEmbeddedTitleBarCompat(mTitleBarHeaderContainer);
|
||||
mTitleBarHeaderContainer.addView(mHeaderContainer);
|
||||
}
|
||||
|
||||
mShowHiddenAttachments.setOnClickListener(this);
|
||||
@ -647,12 +636,6 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
|
||||
boolean showHidden = (show && mHiddenAttachments.getVisibility() == View.GONE &&
|
||||
mHiddenAttachments.getChildCount() > 0);
|
||||
mShowHiddenAttachments.setVisibility(showHidden ? View.VISIBLE : View.GONE);
|
||||
|
||||
if (show) {
|
||||
moveHeaderToLayout();
|
||||
} else {
|
||||
moveHeaderToWebViewTitleBar();
|
||||
}
|
||||
}
|
||||
|
||||
public void showMessageWebView(boolean show) {
|
||||
@ -753,20 +736,6 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
|
||||
this.attachmentCallback = attachmentCallback;
|
||||
}
|
||||
|
||||
private void moveHeaderToLayout() {
|
||||
if (mTitleBarHeaderContainer != null && mTitleBarHeaderContainer.getChildCount() != 0) {
|
||||
mTitleBarHeaderContainer.removeView(mHeaderContainer);
|
||||
mInsideAttachmentsContainer.addView(mHeaderContainer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private void moveHeaderToWebViewTitleBar() {
|
||||
if (mTitleBarHeaderContainer != null && mTitleBarHeaderContainer.getChildCount() == 0) {
|
||||
mInsideAttachmentsContainer.removeView(mHeaderContainer);
|
||||
mTitleBarHeaderContainer.addView(mHeaderContainer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Parcelable onSaveInstanceState() {
|
||||
Parcelable superState = super.onSaveInstanceState();
|
||||
|
@ -1,367 +0,0 @@
|
||||
package com.nobu_games.android.view.web;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012 Thomas Werner
|
||||
* Portions Copyright (C) 2006 The Android Open Source Project
|
||||
* Portions Copyright (C) 2012 The K-9 Dog Walkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClassic.TitleBarDelegate;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
/**
|
||||
* WebView derivative with custom setEmbeddedTitleBar implementation for Android
|
||||
* versions that do not support that feature anymore.
|
||||
* <p>
|
||||
* <b>Usage</b>
|
||||
* <p>
|
||||
* Call {@link #setEmbeddedTitleBarCompat(View)} for setting a view as embedded
|
||||
* title bar on top of the displayed WebView page.
|
||||
*/
|
||||
public class TitleBarWebView extends WebView implements TitleBarDelegate {
|
||||
/**
|
||||
* Internally used view wrapper for suppressing unwanted touch events on the
|
||||
* title bar view when WebView contents is being touched.
|
||||
*/
|
||||
private class TouchBlockView extends FrameLayout {
|
||||
public TouchBlockView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent ev) {
|
||||
if(!mTouchInTitleBar) {
|
||||
return false;
|
||||
} else {
|
||||
switch(ev.getAction() & MotionEvent.ACTION_MASK) {
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
mTouchInTitleBar = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
}
|
||||
|
||||
return super.dispatchTouchEvent(ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final String TAG = "TitleBarWebView";
|
||||
View mTitleBar;
|
||||
int mTitleBarOffs;
|
||||
boolean mTouchInTitleBar;
|
||||
boolean mTouchMove;
|
||||
private Rect mClipBounds = new Rect();
|
||||
private Matrix mMatrix = new Matrix();
|
||||
private static boolean checkedForNativeGetVisibleTitleHeightMethod = false;
|
||||
private static Method nativeGetVisibleTitleHeightMethod;
|
||||
private static Method nativeSetEmbeddedTitleBarMethod;
|
||||
private static boolean checkedForNativeSetEmbeddedTitleBarMethod = false;
|
||||
|
||||
/**
|
||||
* This will always contain a reference to the title bar view no matter if
|
||||
* {@code setEmbeddedTitleBar()} or the Jelly Bean workaround is used. We use this in
|
||||
* {@link #getTitleHeight()}.
|
||||
*/
|
||||
private View mTitleBarView;
|
||||
|
||||
public TitleBarWebView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public TitleBarWebView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public TitleBarWebView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* <i>Corrects the visual displacement caused by the title bar view.</i>
|
||||
* <p>
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent event) {
|
||||
if(mTitleBar != null) {
|
||||
final int sy = getScrollY();
|
||||
final int visTitleHeight = getVisibleTitleHeightCompat();
|
||||
final float x = event.getX();
|
||||
float y = event.getY();
|
||||
|
||||
switch(event.getAction() & MotionEvent.ACTION_MASK) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
if(y <= visTitleHeight) {
|
||||
mTouchInTitleBar = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
mTouchMove = true;
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
mTouchMove = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
|
||||
if(mTouchInTitleBar) {
|
||||
y += sy;
|
||||
event.setLocation(x, y);
|
||||
|
||||
return mTitleBar.dispatchTouchEvent(event);
|
||||
} else {
|
||||
if(Build.VERSION.SDK_INT < 16) {
|
||||
if(!mTouchMove) {
|
||||
mTitleBarOffs = getVisibleTitleHeightCompat();
|
||||
}
|
||||
|
||||
y -= mTitleBarOffs;
|
||||
if(y < 0) y = 0;
|
||||
event.setLocation(x, y);
|
||||
}
|
||||
|
||||
return super.dispatchTouchEvent(event);
|
||||
}
|
||||
} else {
|
||||
return super.dispatchTouchEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a {@link View} as an embedded title bar to appear on top of the
|
||||
* WebView page.
|
||||
* <p>
|
||||
* This method tries to call the hidden API method setEmbeddedTitleBar if
|
||||
* present. On failure the custom implementation provided by this class will
|
||||
* be used instead.
|
||||
*
|
||||
* @param v The view to set or null for removing the title bar view.
|
||||
*/
|
||||
public void setEmbeddedTitleBarCompat(View v) {
|
||||
if(checkedForNativeSetEmbeddedTitleBarMethod && nativeSetEmbeddedTitleBarMethod == null) {
|
||||
setEmbeddedTitleBarJellyBean(v);
|
||||
} else {
|
||||
try {
|
||||
|
||||
if (nativeSetEmbeddedTitleBarMethod == null) {
|
||||
nativeSetEmbeddedTitleBarMethod = getClass().getMethod("setEmbeddedTitleBar",
|
||||
View.class);
|
||||
checkedForNativeSetEmbeddedTitleBarMethod = true;
|
||||
}
|
||||
nativeSetEmbeddedTitleBarMethod.invoke(this, v);
|
||||
} catch(Exception e) {
|
||||
Log.d(TAG,
|
||||
"Native setEmbeddedTitleBar not available. Starting workaround");
|
||||
setEmbeddedTitleBarJellyBean(v);
|
||||
}
|
||||
}
|
||||
mTitleBarView = v;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int computeVerticalScrollExtent() {
|
||||
if(mTitleBar == null) return super.computeVerticalScrollExtent();
|
||||
return getViewHeightWithTitle() - getVisibleTitleHeightCompat();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int computeVerticalScrollOffset() {
|
||||
if(mTitleBar == null) return super.computeVerticalScrollOffset();
|
||||
return Math.max(getScrollY() - getTitleHeight(), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
|
||||
canvas.save();
|
||||
|
||||
if(child == mTitleBar) {
|
||||
mTitleBar.offsetLeftAndRight(getScrollX() - mTitleBar.getLeft());
|
||||
|
||||
if(Build.VERSION.SDK_INT < 16) {
|
||||
mMatrix.set(canvas.getMatrix());
|
||||
mMatrix.postTranslate(0, -getScrollY());
|
||||
canvas.setMatrix(mMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
boolean result = super.drawChild(canvas, child, drawingTime);
|
||||
canvas.restore();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the currently visible height of the title bar view if set.
|
||||
*
|
||||
* @return Visible height of title bar view or 0 if not set.
|
||||
*/
|
||||
protected int getVisibleTitleHeightCompat() {
|
||||
if(mTitleBar == null && nativeGetVisibleTitleHeightMethod != null) {
|
||||
try {
|
||||
return (Integer) nativeGetVisibleTitleHeightMethod
|
||||
.invoke(this);
|
||||
} catch(Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
return Math.max(getTitleHeight() - Math.max(0, getScrollY()), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (Build.VERSION.SDK_INT >= 16) {
|
||||
super.onDraw(canvas);
|
||||
return;
|
||||
}
|
||||
|
||||
canvas.save();
|
||||
|
||||
if(mTitleBar != null) {
|
||||
final int sy = getScrollY();
|
||||
final int sx = getScrollX();
|
||||
mClipBounds.top = sy;
|
||||
mClipBounds.left = sx;
|
||||
mClipBounds.right = mClipBounds.left + getWidth();
|
||||
mClipBounds.bottom = mClipBounds.top + getHeight();
|
||||
canvas.clipRect(mClipBounds);
|
||||
mMatrix.set(canvas.getMatrix());
|
||||
int titleBarOffs = getVisibleTitleHeightCompat();
|
||||
if(titleBarOffs < 0) titleBarOffs = 0;
|
||||
mMatrix.postTranslate(0, titleBarOffs);
|
||||
canvas.setMatrix(mMatrix);
|
||||
}
|
||||
|
||||
super.onDraw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides a hidden method by replicating the behavior of the original
|
||||
* WebView class from Android 2.3.4.
|
||||
* <p>
|
||||
* The worst that could happen is that this method never gets called, which
|
||||
* isn't too bad because this does not harm the functionality of this class.
|
||||
*/
|
||||
protected void onDrawVerticalScrollBar(Canvas canvas, Drawable scrollBar,
|
||||
int l, int t, int r, int b) {
|
||||
int sy = getScrollY();
|
||||
|
||||
if(sy < 0) {
|
||||
t -= sy;
|
||||
}
|
||||
scrollBar.setBounds(l, t + getVisibleTitleHeightCompat(), r, b);
|
||||
scrollBar.draw(canvas);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height of the title bar view.
|
||||
*
|
||||
* <p>
|
||||
* In the Jelly Bean workaround we need this method because we have to implement the
|
||||
* {@link TitleBarDelegate} interface. But by implementing this method we override the hidden
|
||||
* {@code getTitleHeight()} of the {@link WebView}s in older Android versions.
|
||||
* <br>
|
||||
* What we should do, is return the title height on Jelly Bean and call through to the parent
|
||||
* class on older Android versions. But this would require even more trickery, so we just
|
||||
* inline the parent functionality which simply calls {@link View#getHeight()}. This is exactly
|
||||
* what we do on Jelly Bean anyway.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public int getTitleHeight() {
|
||||
if (mTitleBarView != null) {
|
||||
return mTitleBarView.getHeight();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int getViewHeightWithTitle() {
|
||||
int height = getHeight();
|
||||
if(isHorizontalScrollBarEnabled() && !overlayHorizontalScrollbar()) {
|
||||
height -= getHorizontalScrollbarHeight();
|
||||
}
|
||||
return height;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (checkedForNativeGetVisibleTitleHeightMethod == false) {
|
||||
try {
|
||||
nativeGetVisibleTitleHeightMethod = WebView.class
|
||||
.getDeclaredMethod("getVisibleTitleHeight");
|
||||
} catch(NoSuchMethodException e) {
|
||||
Log.w(TAG,
|
||||
"Could not retrieve native hidden getVisibleTitleHeight method");
|
||||
}
|
||||
checkedForNativeGetVisibleTitleHeightMethod = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The hidden method setEmbeddedTitleBar has been removed from Jelly Bean.
|
||||
* This method replicates the functionality.
|
||||
*
|
||||
* @param v
|
||||
*/
|
||||
private void setEmbeddedTitleBarJellyBean(View v) {
|
||||
if(mTitleBar == v) return;
|
||||
|
||||
if(mTitleBar != null) {
|
||||
removeView(mTitleBar);
|
||||
}
|
||||
|
||||
if(null != v) {
|
||||
LayoutParams vParams = new LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0);
|
||||
|
||||
TouchBlockView tbv = new TouchBlockView(getContext());
|
||||
FrameLayout.LayoutParams tbvParams = new FrameLayout.LayoutParams(
|
||||
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
|
||||
tbv.addView(v, tbvParams);
|
||||
addView(tbv, vParams);
|
||||
v = tbv;
|
||||
}
|
||||
|
||||
mTitleBar = v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetEmbeddedTitleBar(View title) { /* unused */ }
|
||||
}
|
Loading…
Reference in New Issue
Block a user