Fix teaser minor issues
Sectioned inbox teaser and sender images teaser should animate away when a
conversation item is clicked.
Both teasers should have darker background when swiping.
Set arrow to visible after its position has been set correctly.
Bug: 8829350
Change-Id: I2dac049c2fe8f45607c60b4dbddaaa8595fa02e5
diff --git a/res/layout/conversation_photo_teaser_view.xml b/res/layout/conversation_photo_teaser_view.xml
index d5a3245..0f10aef 100644
--- a/res/layout/conversation_photo_teaser_view.xml
+++ b/res/layout/conversation_photo_teaser_view.xml
@@ -1,33 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2013 Google Inc. -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<com.google.android.gm.ui.GmailConversationPhotoTeaserView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:background="@drawable/conversation_read_selector"
- android:orientation="horizontal"
- android:paddingLeft="16dp"
- android:paddingRight="16dp" >
+ android:background="@color/swiped_bg_color" >
- <ImageView
- android:id="@+id/arrow"
- android:layout_width="48dp"
- android:layout_height="wrap_content"
- android:layout_marginBottom="12dp"
- android:layout_marginRight="12dp"
- android:duplicateParentState="true"
- android:src="@drawable/ic_arrow" />
-
- <TextView
- android:id="@+id/text"
+ <LinearLayout
+ android:id="@+id/swipeable_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:layout_marginBottom="12dp"
- android:layout_marginTop="12dp"
- android:duplicateParentState="true"
- android:fontFamily="sans-serif-light"
- android:text="@string/conversation_photo_welcome_text"
- android:textColor="@color/teaser_main_text"
- android:textSize="16sp" />
+ android:background="@drawable/conversation_read_selector"
+ android:orientation="horizontal"
+ android:paddingLeft="16dp"
+ android:paddingRight="16dp" >
-</LinearLayout>
\ No newline at end of file
+ <ImageView
+ android:id="@+id/arrow"
+ android:layout_width="48dp"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="12dp"
+ android:layout_marginRight="12dp"
+ android:duplicateParentState="true"
+ android:src="@drawable/ic_arrow"
+ android:visibility="invisible" />
+
+ <TextView
+ android:id="@+id/text"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:layout_marginBottom="12dp"
+ android:layout_marginTop="12dp"
+ android:duplicateParentState="true"
+ android:fontFamily="sans-serif-light"
+ android:text="@string/conversation_photo_welcome_text"
+ android:textColor="@color/teaser_main_text"
+ android:textSize="16sp" />
+ </LinearLayout>
+
+</com.google.android.gm.ui.GmailConversationPhotoTeaserView>
\ No newline at end of file
diff --git a/src/com/android/mail/ui/ConversationPhotoTeaserView.java b/src/com/android/mail/ui/ConversationPhotoTeaserView.java
index 9f567da..84b710d 100644
--- a/src/com/android/mail/ui/ConversationPhotoTeaserView.java
+++ b/src/com/android/mail/ui/ConversationPhotoTeaserView.java
@@ -4,7 +4,8 @@
import android.app.LoaderManager;
import android.content.Context;
import android.content.res.Resources;
-import android.view.LayoutInflater;
+import android.util.AttributeSet;
+import android.view.View;
import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
@@ -27,13 +28,24 @@
private final MailPrefs mMailPrefs;
private AnimatedAdapter mAdapter;
+ private View mSwipeableContent;
+
private boolean mShown;
private int mAnimatedHeight = -1;
private boolean mNeedLayout;
private int mTextTop;
public ConversationPhotoTeaserView(final Context context) {
- super(context);
+ this(context, null);
+ }
+
+ public ConversationPhotoTeaserView(final Context context, final AttributeSet attrs) {
+ this(context, attrs, -1);
+ }
+
+ public ConversationPhotoTeaserView(
+ final Context context, final AttributeSet attrs, final int defStyle) {
+ super(context, attrs, defStyle);
final Resources resources = context.getResources();
@@ -47,37 +59,42 @@
mMailPrefs = MailPrefs.get(context);
- LayoutInflater.from(context).inflate(R.layout.conversation_photo_teaser_view, this);
-
mNeedLayout = true;
}
@Override
+ protected void onFinishInflate() {
+ mSwipeableContent = findViewById(R.id.swipeable_content);
+ }
+
+ @Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
final TextView text = (TextView) findViewById(R.id.text);
final ImageView arrow = (ImageView) findViewById(R.id.arrow);
- // The text top is changed when we move the arrow, so we need to do
- // multiple passes
- int textTop = text.getTop();
- if (mNeedLayout || textTop != mTextTop) {
- mNeedLayout = false;
- mTextTop = textTop;
+ // We post to avoid calling layout within layout
+ arrow.post(new Runnable() {
+ @Override
+ public void run() {
- // We post to avoid calling layout within layout
- arrow.post(new Runnable() {
- @Override
- public void run() {
+ // The text top is changed when we move the arrow, so we need to
+ // do multiple passes
+ int textTop = text.getTop();
+ if (mNeedLayout || textTop != mTextTop) {
+ mNeedLayout = false;
+ mTextTop = textTop;
+
final int lineHeight = text.getLineHeight();
final LinearLayout.LayoutParams arrowParams = (LinearLayout.LayoutParams) arrow
.getLayoutParams();
arrowParams.topMargin = mTextTop + lineHeight / 2;
arrow.setLayoutParams(arrowParams);
}
- });
- }
+ arrow.setVisibility(View.VISIBLE);
+ }
+ });
}
@Override
@@ -114,7 +131,7 @@
@Override
public void onConversationSelected() {
- setDismissed();
+ dismiss();
}
@Override
@@ -136,7 +153,7 @@
@Override
public SwipeableView getSwipeableView() {
- return SwipeableView.from(this);
+ return SwipeableView.from(mSwipeableContent);
}
@Override