Bug 837113: Close button in tabs ui. [r=mfinkle]

--HG--
extra : rebase_source : 52af4d8e0316be67838fcd5a463a5fdcbac124c2
This commit is contained in:
Sriram Ramasubramanian 2013-02-14 13:23:15 -08:00
parent 949204faef
commit bc3974fc63
6 changed files with 57 additions and 12 deletions

View File

@ -76,6 +76,7 @@ public class TabsTray extends ListView
public void onMovedToScrapHeap(View view) {
TabRow row = (TabRow) view.getTag();
row.thumbnail.setImageDrawable(null);
row.close.setVisibility(View.VISIBLE);
}
});
}
@ -115,12 +116,14 @@ public class TabsTray extends ListView
int id;
TextView title;
ImageView thumbnail;
ImageButton close;
LinearLayout info;
public TabRow(View view) {
info = (LinearLayout) view;
title = (TextView) view.findViewById(R.id.title);
thumbnail = (ImageView) view.findViewById(R.id.thumbnail);
close = (ImageButton) view.findViewById(R.id.close);
}
}
@ -242,6 +245,7 @@ public class TabsTray extends ListView
row.thumbnail.setImageResource(R.drawable.tab_thumbnail_default);
row.title.setText(tab.getDisplayTitle());
row.close.setTag(row);
}
public View getView(int position, View convertView, ViewGroup parent) {
@ -250,6 +254,7 @@ public class TabsTray extends ListView
if (convertView == null) {
convertView = mInflater.inflate(R.layout.tabs_row, null);
row = new TabRow(convertView);
row.close.setOnClickListener(mOnCloseClickListener);
convertView.setTag(row);
} else {
row = (TabRow) convertView.getTag();
@ -322,6 +327,15 @@ public class TabsTray extends ListView
PropertyAnimator animator = new PropertyAnimator(ANIMATION_DURATION);
animator.attach(view, Property.ALPHA, 1);
animator.attach(view, Property.TRANSLATION_X, 0);
animator.setPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() {
public void onPropertyAnimationStart() { }
public void onPropertyAnimationEnd() {
TabRow tab = (TabRow) view.getTag();
tab.close.setVisibility(View.VISIBLE);
}
});
animator.start();
}
@ -483,6 +497,9 @@ public class TabsTray extends ListView
mSwiping = true;
TabsTray.this.requestDisallowInterceptTouchEvent(true);
TabRow tab = (TabRow) mSwipeView.getTag();
tab.close.setVisibility(View.INVISIBLE);
// Stops listview from highlighting the touched item
// in the list when swiping.
MotionEvent cancelEvent = MotionEvent.obtain(e);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 913 B

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1005 B

After

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 669 B

After

Width:  |  Height:  |  Size: 158 B

View File

@ -5,6 +5,7 @@
<Gecko.TabRow xmlns:android="http://schemas.android.com/apk/res/android"
android:focusable="true"
android:nextFocusRight="@+id/close"
android:id="@+id/info"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
@ -24,17 +25,35 @@
android:layout_height="@dimen/tab_thumbnail_height"
android:src="@drawable/tab_thumbnail_default"/>
<TextView android:id="@+id/title"
android:layout_width="@dimen/tab_thumbnail_width"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:padding="4dip"
style="@style/TabRowTextAppearance"
android:background="#B3FFFFFF"
android:textSize="12sp"
android:textColor="#FF222222"
android:singleLine="true"
android:duplicateParentState="true"/>
<LinearLayout android:layout_width="@dimen/tab_thumbnail_width"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#B3FFFFFF"
android:layout_alignParentBottom="true"
android:duplicateParentState="true">
<TextView android:id="@+id/title"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:padding="4dip"
style="@style/TabRowTextAppearance"
android:textSize="12sp"
android:textColor="#FF222222"
android:singleLine="true"
android:duplicateParentState="true"/>
<ImageButton android:id="@+id/close"
android:nextFocusLeft="@+id/info"
android:layout_width="32dip"
android:layout_height="fill_parent"
android:background="@drawable/action_bar_button"
android:scaleType="center"
android:contentDescription="@string/close_tab"
android:src="@drawable/tab_close"/>
</LinearLayout>
</RelativeLayout>

View File

@ -5,11 +5,11 @@
<Gecko.TabRow xmlns:android="http://schemas.android.com/apk/res/android"
android:focusable="true"
android:nextFocusRight="@+id/close"
android:id="@+id/info"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="12dip"
android:paddingRight="12dip"
android:paddingTop="6dip"
android:paddingBottom="6dip"
android:background="@drawable/tab_row">
@ -41,4 +41,13 @@
android:maxLines="4"
android:duplicateParentState="true"/>
<ImageButton android:id="@+id/close"
android:nextFocusLeft="@+id/info"
android:layout_width="34dip"
android:layout_height="fill_parent"
android:background="@drawable/action_bar_button"
android:scaleType="center"
android:contentDescription="@string/close_tab"
android:src="@drawable/tab_close"/>
</Gecko.TabRow>