Update conversation item style.
1) Don't print sender/recipient name in message body. 2) Do the split conversation icon view. 3) Adjust font sizes and colors.pull/1/head
parent
eeeeac126c
commit
a7cc47d259
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
@ -1,159 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
<!--<org.thoughtcrime.securesms.ConversationItem-->
|
|
||||||
<LinearLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/conversation_item"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingLeft="10px"
|
|
||||||
android:paddingTop="5px"
|
|
||||||
android:paddingRight="10px"
|
|
||||||
android:paddingBottom="10px"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<!-- <android.widget.QuickContactBadge android:id="@+id/contact_photo"-->
|
|
||||||
<!-- android:layout_width="60dp"-->
|
|
||||||
<!-- android:layout_height="60dp"-->
|
|
||||||
<!-- android:cropToPadding="true"-->
|
|
||||||
<!-- android:layout_marginRight="10px"-->
|
|
||||||
<!-- android:scaleType="centerCrop"-->
|
|
||||||
<!-- android:visibility="gone" />-->
|
|
||||||
|
|
||||||
<ImageView android:id="@+id/contact_photo"
|
|
||||||
android:layout_width="60dp"
|
|
||||||
android:layout_height="60dp"
|
|
||||||
android:cropToPadding="true"
|
|
||||||
android:layout_marginRight="10px"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<LinearLayout android:id="@+id/conversation_item_parent"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical" >
|
|
||||||
|
|
||||||
<TextView android:id="@+id/conversation_item_body"
|
|
||||||
android:autoLink="all"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:linksClickable="true"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
|
||||||
android:textColor="#ff000000"
|
|
||||||
android:textSize="18sp" />
|
|
||||||
|
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/mms_view"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:paddingTop="7dip"
|
|
||||||
android:paddingBottom="7dip">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/image_view"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:maxWidth="178dip"
|
|
||||||
android:maxHeight="178dip"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:background="@android:drawable/picture_frame"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/play_slideshow_button"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:src="@drawable/mms_play_btn"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/mms_download_controls"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<Button android:id="@+id/mms_download_button"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:text="Download"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<TextView android:id="@+id/mms_label_downloading"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_marginRight="5dp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="Downloading"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
|
|
||||||
<TextView android:id="@+id/conversation_item_date"
|
|
||||||
android:autoLink="all"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:linksClickable="false"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
|
||||||
android:textColor="#bf000000"
|
|
||||||
android:paddingTop="3px"
|
|
||||||
android:textSize="12sp" />
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
<LinearLayout android:id="@+id/indicators_parent"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/key_exchange_indicator"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:src="@drawable/key"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/sms_pending_indicator"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:src="@drawable/ic_sms_mms_pending"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/sms_secure_indicator"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:src="@drawable/ic_lock_small"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/sms_failed_indicator"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:src="@drawable/ic_sms_mms_not_delivered"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
<!--</org.thoughtcrime.securesms.ConversationItem>-->
|
|
||||||
</LinearLayout>
|
|
||||||
@ -0,0 +1,147 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<org.thoughtcrime.securesms.ConversationItem
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/conversation_item"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingRight="10dip"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<view xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
class="org.thoughtcrime.securesms.components.ImageDivet"
|
||||||
|
position="right"
|
||||||
|
android:id="@id/contact_photo"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_width="60dp"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:cropToPadding="true"
|
||||||
|
android:layout_marginRight="10dip"
|
||||||
|
android:scaleType="centerCrop" />
|
||||||
|
|
||||||
|
<LinearLayout android:id="@+id/conversation_item_parent"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_toLeftOf="@+id/indicators_parent"
|
||||||
|
android:layout_toRightOf="@id/contact_photo"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<TextView android:id="@+id/conversation_item_body"
|
||||||
|
android:autoLink="all"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:linksClickable="true"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:textColor="#ff000000"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/mms_view"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:paddingTop="7dip"
|
||||||
|
android:paddingBottom="7dip">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/image_view"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:maxWidth="178dip"
|
||||||
|
android:maxHeight="178dip"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:background="@android:drawable/picture_frame"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/play_slideshow_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/mms_play_btn"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/mms_download_controls"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Button android:id="@+id/mms_download_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:text="Download"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<TextView android:id="@+id/mms_label_downloading"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:layout_marginRight="5dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="Downloading"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView android:id="@+id/conversation_item_date"
|
||||||
|
android:autoLink="all"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:linksClickable="false"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:gravity="left"
|
||||||
|
android:textColor="#ffcccccc"
|
||||||
|
android:paddingTop="1dip"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout android:id="@+id/indicators_parent"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_alignParentRight="true">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/key_exchange_indicator"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:src="@drawable/key"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/sms_pending_indicator"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:src="@drawable/ic_sms_mms_pending"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/sms_secure_indicator"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:src="@drawable/ic_lock_small"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/sms_failed_indicator"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:src="@drawable/ic_sms_mms_not_delivered"
|
||||||
|
android:visibility="gone" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
</org.thoughtcrime.securesms.ConversationItem>
|
||||||
@ -0,0 +1,151 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<org.thoughtcrime.securesms.ConversationItem
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/conversation_item"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="10dip"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<LinearLayout android:id="@+id/indicators_parent"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_alignParentLeft="true">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/key_exchange_indicator"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:src="@drawable/key"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/sms_pending_indicator"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:src="@drawable/ic_sms_mms_pending"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/sms_secure_indicator"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:src="@drawable/ic_lock_small"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/sms_failed_indicator"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:src="@drawable/ic_sms_mms_not_delivered"
|
||||||
|
android:visibility="gone" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout android:id="@+id/conversation_item_parent"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_toRightOf="@id/indicators_parent"
|
||||||
|
android:layout_toLeftOf="@+id/contact_photo"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<TextView android:id="@+id/conversation_item_body"
|
||||||
|
android:autoLink="all"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:linksClickable="true"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:gravity="right"
|
||||||
|
android:textColor="#ff000000"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/mms_view"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:paddingTop="7dip"
|
||||||
|
android:paddingBottom="7dip">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/image_view"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:maxWidth="178dip"
|
||||||
|
android:maxHeight="178dip"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:background="@android:drawable/picture_frame"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/play_slideshow_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/mms_play_btn"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/mms_download_controls"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Button android:id="@+id/mms_download_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:text="Download"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<TextView android:id="@+id/mms_label_downloading"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:layout_marginRight="5dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="Downloading"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView android:id="@+id/conversation_item_date"
|
||||||
|
android:autoLink="all"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:linksClickable="false"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:gravity="right"
|
||||||
|
android:textColor="#ffcccccc"
|
||||||
|
android:paddingTop="1dip"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<view xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
class="org.thoughtcrime.securesms.components.ImageDivet"
|
||||||
|
position="left"
|
||||||
|
android:id="@id/contact_photo"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_width="60dp"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:cropToPadding="true"
|
||||||
|
android:layout_marginLeft="10dip"
|
||||||
|
android:layout_marginRight="0dip"
|
||||||
|
android:padding="0dip"
|
||||||
|
android:scaleType="centerCrop" />
|
||||||
|
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
</org.thoughtcrime.securesms.ConversationItem>
|
||||||
@ -0,0 +1,118 @@
|
|||||||
|
package org.thoughtcrime.securesms.components;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.R;
|
||||||
|
|
||||||
|
public class ImageDivet extends ImageView {
|
||||||
|
private static final float CORNER_OFFSET = 12F;
|
||||||
|
private static final String[] POSITIONS = new String[] {"left", "right"};
|
||||||
|
|
||||||
|
private Drawable drawable;
|
||||||
|
|
||||||
|
private int drawableIntrinsicWidth;
|
||||||
|
private int drawableIntrinsicHeight;
|
||||||
|
private int position;
|
||||||
|
private float density;
|
||||||
|
|
||||||
|
public ImageDivet(Context context, AttributeSet attrs, int defStyle) {
|
||||||
|
super(context, attrs, defStyle);
|
||||||
|
initialize(attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImageDivet(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
initialize(attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImageDivet(Context context) {
|
||||||
|
super(context);
|
||||||
|
initialize(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialize(AttributeSet attrs) {
|
||||||
|
if (attrs != null) {
|
||||||
|
position = attrs.getAttributeListValue(null, "position", POSITIONS, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
density = getContext().getResources().getDisplayMetrics().density;
|
||||||
|
setDrawable();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setDrawable() {
|
||||||
|
Resources r = getContext().getResources();
|
||||||
|
|
||||||
|
switch (position) {
|
||||||
|
case 0:
|
||||||
|
drawable = r.getDrawable(R.drawable.divet_right);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
drawable = r.getDrawable(R.drawable.divet_left);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
drawableIntrinsicWidth = drawable.getIntrinsicWidth();
|
||||||
|
drawableIntrinsicHeight = drawable.getIntrinsicHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDraw(Canvas c) {
|
||||||
|
super.onDraw(c);
|
||||||
|
c.save();
|
||||||
|
computeBounds(c);
|
||||||
|
drawable.draw(c);
|
||||||
|
c.restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosition(int position) {
|
||||||
|
this.position = position;
|
||||||
|
setDrawable();
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPosition() {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getCloseOffset() {
|
||||||
|
return CORNER_OFFSET * density;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImageView asImageView() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getFarOffset() {
|
||||||
|
return getCloseOffset() + drawableIntrinsicHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void computeBounds(Canvas c) {
|
||||||
|
final int left = 0;
|
||||||
|
final int top = 0;
|
||||||
|
final int right = getWidth();
|
||||||
|
|
||||||
|
final int cornerOffset = (int) getCloseOffset();
|
||||||
|
|
||||||
|
switch (position) {
|
||||||
|
case 1:
|
||||||
|
drawable.setBounds(
|
||||||
|
right - drawableIntrinsicWidth,
|
||||||
|
top + cornerOffset,
|
||||||
|
right,
|
||||||
|
top + cornerOffset + drawableIntrinsicHeight);
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
drawable.setBounds(
|
||||||
|
left,
|
||||||
|
top + cornerOffset,
|
||||||
|
left + drawableIntrinsicWidth,
|
||||||
|
top + cornerOffset + drawableIntrinsicHeight);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue