Merge "Simplify the hierarchy for the leave behind." into jb-ub-mail
diff --git a/res/layout/swipe_leavebehind.xml b/res/layout/swipe_leavebehind.xml
index 9406d03..3aa7c40 100644
--- a/res/layout/swipe_leavebehind.xml
+++ b/res/layout/swipe_leavebehind.xml
@@ -32,14 +32,17 @@
<TextView
android:id="@+id/undo_descriptionview"
android:layout_width="0dip"
- android:layout_height="wrap_content"
+ android:layout_height="match_parent"
android:layout_weight="1"
android:ellipsize="end"
android:singleLine="true"
android:text="@string/no_conversations"
android:textColor="@android:color/white"
android:textAppearance="?android:attr/textAppearanceMedium"
- android:paddingLeft="16dip" />
+ android:paddingLeft="16dip"
+ android:clickable="true"
+ android:layout_gravity="center_vertical"
+ android:gravity="center_vertical" />
<View
android:id="@+id/undo_separator"
@@ -49,31 +52,27 @@
android:layout_marginTop="20dip"
android:background="@android:color/white" />
- <RelativeLayout
+ <ImageView
+ android:id="@+id/undo_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
- android:id="@+id/undo_button"
- android:clickable="true"
- android:background="?android:attr/selectableItemBackground">
- <ImageView
- android:id="@+id/undo_icon"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_marginLeft="12dip"
- android:layout_marginRight="8dip"
- android:src="@drawable/ic_menu_revert_holo_dark" />
+ android:paddingLeft="12dip"
+ android:paddingRight="8dip"
+ android:src="@drawable/ic_menu_revert_holo_dark"
+ android:background="?android:attr/selectableItemBackground"
+ android:duplicateParentState="true" />
- <TextView
- android:id="@+id/undo_text"
- style="@style/UndoTextStyle"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:paddingRight="16dip"
- android:text="@string/undo"
- android:textAllCaps="true"
- android:gravity="center_vertical"
- android:textColor="@android:color/white"
- android:layout_toRightOf="@id/undo_icon" />
- </RelativeLayout>
+ <TextView
+ android:id="@+id/undo_text"
+ style="@style/UndoTextStyle"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:paddingRight="16dip"
+ android:text="@string/undo"
+ android:textAllCaps="true"
+ android:gravity="center_vertical"
+ android:textColor="@android:color/white"
+ android:background="?android:attr/selectableItemBackground"
+ android:duplicateParentState="true"/>
</LinearLayout>
</com.android.mail.ui.LeaveBehindItem>
\ No newline at end of file
diff --git a/src/com/android/mail/ui/LeaveBehindItem.java b/src/com/android/mail/ui/LeaveBehindItem.java
index ebd730d..dcfcd66 100644
--- a/src/com/android/mail/ui/LeaveBehindItem.java
+++ b/src/com/android/mail/ui/LeaveBehindItem.java
@@ -28,7 +28,6 @@
import android.view.View.OnClickListener;
import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout;
-import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.mail.R;
@@ -50,7 +49,6 @@
private View mSwipeableContent;
private static int sShrinkAnimationDuration = -1;
private static int sFadeInAnimationDuration = -1;
- private static int sSwipedBgColor = -1;
public LeaveBehindItem(Context context) {
this(context, null);
@@ -67,7 +65,6 @@
R.integer.shrink_animation_duration);
sFadeInAnimationDuration = context.getResources().getInteger(
R.integer.fade_in_animation_duration);
- sSwipedBgColor = context.getResources().getColor(R.color.swiped_bg_color);
}
}
@@ -75,7 +72,7 @@
public void onClick(View v) {
int id = v.getId();
switch (id) {
- case R.id.undo_button:
+ case R.id.swipeable_content:
if (mAccount.undoUri != null) {
// NOTE: We might want undo to return the messages affected,
// in which case the resulting cursor might be interesting...
@@ -86,6 +83,10 @@
mConversationCursor.undo(getContext(), mAccount.undoUri);
}
break;
+ case R.id.undo_descriptionview:
+ // Essentially, makes sure that tapping description view doesn't highlight
+ // either the undo button icon or text.
+ break;
}
}
@@ -97,10 +98,13 @@
mConversationCursor = (ConversationCursor) adapter.getCursor();
setData(target);
mSwipeableContent = findViewById(R.id.swipeable_content);
+ // Listen on swipeable content so that we can show both the undo icon
+ // and button text as selected since they set duplicateParentState to true
+ mSwipeableContent.setOnClickListener(this);
mText = ((TextView) findViewById(R.id.undo_descriptionview));
mText.setText(Html.fromHtml(mUndoOp
.getSingularDescription(getContext(), folder)));
- findViewById(R.id.undo_button).setOnClickListener(this);
+ mText.setOnClickListener(this);
}
public void commit() {