Fix for inconsistent thumbnail aspect ratio

Problems arose from any app that targets below API 19 and uses
views that rely on RelativeLayouts giving correct measurement specs to
their onMeasure().

Resolves #2676
Closes #2712
// FREEBIE
This commit is contained in:
Jake McGinty 2015-03-17 14:01:37 -07:00 committed by Moxie Marlinspike
parent 7a023b9fdc
commit 761ccf4b3f
4 changed files with 59 additions and 23 deletions

View File

@ -12,28 +12,34 @@
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<org.thoughtcrime.securesms.components.ForegroundImageView
android:id="@+id/image_view"
android:layout_width="wrap_content"
android:layout_height="@dimen/media_bubble_height"
android:layout_marginRight="@dimen/message_bubble_end_padding"
android:visibility="gone"
android:layout_toRightOf="@id/triangle_tick"
android:layout_toEndOf="@id/triangle_tick"
android:layout_gravity="center"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:contentDescription="@string/conversation_item__mms_image_description"
app:riv_corner_radius="@dimen/message_bubble_corner_radius"
app:riv_border_width="@dimen/media_bubble_border_width"
tools:src="@drawable/ic_video_light" />
<LinearLayout android:id="@+id/thumbnail_container"
android:layout_toRightOf="@id/triangle_tick"
android:layout_toEndOf="@id/triangle_tick"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<org.thoughtcrime.securesms.components.ForegroundImageView
android:id="@+id/image_view"
android:layout_width="wrap_content"
android:layout_height="@dimen/media_bubble_height"
android:layout_marginRight="@dimen/message_bubble_end_padding"
android:visibility="gone"
android:layout_gravity="center"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:contentDescription="@string/conversation_item__mms_image_description"
app:riv_corner_radius="@dimen/message_bubble_corner_radius"
app:riv_border_width="@dimen/media_bubble_border_width"
tools:src="@drawable/ic_video_light" />
</LinearLayout>
<LinearLayout android:id="@+id/body_bubble"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/triangle_tick"
android:layout_toEndOf="@id/triangle_tick"
android:layout_below="@id/image_view"
android:layout_below="@id/thumbnail_container"
android:orientation="vertical">
<TextView android:id="@+id/conversation_item_body"

View File

@ -11,12 +11,17 @@
android:layout_alignParentRight="true"
android:layout_marginTop="12dp" />
<org.thoughtcrime.securesms.components.ForegroundImageView
<LinearLayout android:id="@+id/thumbnail_container"
android:layout_width="wrap_content"
android:layout_toLeftOf="@id/triangle_tick"
android:layout_gravity="center"
android:layout_height="wrap_content">
<org.thoughtcrime.securesms.components.ForegroundImageView
android:id="@+id/image_view"
android:layout_width="wrap_content"
android:layout_height="@dimen/media_bubble_height"
android:layout_marginLeft="@dimen/message_bubble_end_padding"
android:layout_toLeftOf="@id/triangle_tick"
android:layout_gravity="center"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
@ -26,13 +31,13 @@
app:riv_border_width="@dimen/media_bubble_border_width"
tools:src="@drawable/ic_video_light"
tools:visibility="visible" />
</LinearLayout>
<LinearLayout android:id="@+id/body_bubble"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/image_view"
android:layout_below="@id/thumbnail_container"
android:layout_alignParentRight="true"
android:layout_alignBottom="@id/image_view"
android:paddingRight="10dip"
android:paddingLeft="10dip"
android:layout_marginLeft="50dp"

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="210dp">
<org.thoughtcrime.securesms.components.ForegroundImageView
android:id="@+id/image_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:visibility="gone"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:contentDescription="@string/conversation_item__mms_image_description"
app:riv_corner_radius="@dimen/message_bubble_corner_radius"
app:riv_border_width="@dimen/media_bubble_border_width"
tools:src="@drawable/ic_video_light"
tools:visibility="visible" />
</LinearLayout>

View File

@ -148,11 +148,14 @@ public abstract class BubbleContainer extends RelativeLayout {
private void setAlignment(@MediaState int mediaState) {
RelativeLayout.LayoutParams parentParams = (RelativeLayout.LayoutParams) bodyBubble.getLayoutParams();
if (mediaState != MEDIA_STATE_CAPTIONED) {
if (mediaState == MEDIA_STATE_CAPTIONLESS) {
parentParams.addRule(RelativeLayout.BELOW, 0);
parentParams.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.image_view);
parentParams.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.thumbnail_container);
} else if (mediaState == MEDIA_STATE_CAPTIONED) {
parentParams.addRule(RelativeLayout.BELOW, R.id.thumbnail_container);
parentParams.addRule(RelativeLayout.ALIGN_BOTTOM, 0);
} else {
parentParams.addRule(RelativeLayout.BELOW, R.id.image_view);
parentParams.addRule(RelativeLayout.BELOW, 0);
parentParams.addRule(RelativeLayout.ALIGN_BOTTOM, 0);
}
bodyBubble.setLayoutParams(parentParams);