diff options
-rw-r--r-- | res/layout/tab_view.xml | 63 | ||||
-rw-r--r-- | res/values/colors.xml | 1 | ||||
-rw-r--r-- | res/values/dimensions.xml | 1 | ||||
-rw-r--r-- | src/com/android/browser/ActiveTabsPage.java | 20 | ||||
-rw-r--r-- | src/com/android/browser/PhoneUi.java | 16 |
5 files changed, 70 insertions, 31 deletions
diff --git a/res/layout/tab_view.xml b/res/layout/tab_view.xml index 5426f61..8ffb73d 100644 --- a/res/layout/tab_view.xml +++ b/res/layout/tab_view.xml @@ -21,37 +21,50 @@ android:orientation="horizontal" android:gravity="center_vertical" android:paddingLeft="8dip" + android:paddingTop="4dip" + android:paddingBottom="4dip" > - <ImageView android:id="@+id/favicon" - android:layout_height="32dip" - android:layout_width="32dip" - android:layout_gravity="center_vertical" - android:background="@drawable/bookmark_list_favicon_bg" - android:scaleType="fitXY" /> - <LinearLayout + <RelativeLayout + android:id="@+id/list_item" android:layout_width="0dip" - android:layout_height="wrap_content" android:layout_weight="1" - android:orientation="vertical" - android:paddingLeft="8dip" - > - <TextView android:id="@+id/title" + android:layout_height="wrap_content" + android:background="@drawable/bookmark_list_favicon_bg"> + <ImageView + android:id="@+id/thumb" + android:src="@drawable/thumbnail_bookmarks_widget_no_bookmark_holo" android:layout_width="match_parent" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:maxLines="1" - android:singleLine="true" - android:ellipsize="end" - /> - <TextView android:id="@+id/url" + android:layout_height="@dimen/tab_view_thumbnail_height" + android:scaleType="fitXY" + android:cropToPadding="true" /> + <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceSmall" - android:maxLines="1" - android:singleLine="true" - android:ellipsize="end" - /> - </LinearLayout> + android:layout_alignBottom="@id/thumb" + android:background="@color/tabViewTitleBackground"> + <ImageView + android:id="@+id/favicon" + android:src="@drawable/app_web_browser_sm" + android:layout_width="@dimen/favicon_size" + android:layout_height="@dimen/favicon_size" + android:layout_gravity="center_vertical" + android:layout_marginLeft="4dip" + android:layout_marginRight="8dip" + android:layout_marginTop="4dip" + android:layout_marginBottom="4dip" + android:scaleType="fitXY" /> + <TextView + android:id="@+id/label" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:singleLine="true" + android:ellipsize="end" + android:textSize="12sp" + android:typeface="sans" + android:textColor="@android:color/white" /> + </LinearLayout> + </RelativeLayout> <View android:id="@+id/divider" android:background="?android:attr/dividerVertical" android:layout_width="1dp" diff --git a/res/values/colors.xml b/res/values/colors.xml index 6a7c578..15a5c87 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -36,4 +36,5 @@ <color name="qcMenuBackground">#C0000000</color> <color name="qc_normal">#C02447B2</color> <color name="qc_selected">#D0102052</color> + <color name="tabViewTitleBackground">#D0000000</color> </resources> diff --git a/res/values/dimensions.xml b/res/values/dimensions.xml index b695120..f1e7fb3 100644 --- a/res/values/dimensions.xml +++ b/res/values/dimensions.xml @@ -57,4 +57,5 @@ <dimen name="combo_paddingTop">10dip</dimen> <dimen name="combo_paddingLeftRight">8dip</dimen> <dimen name="combo_horizontalSpacing">6dip</dimen> + <dimen name="tab_view_thumbnail_height">76dip</dimen> </resources> diff --git a/src/com/android/browser/ActiveTabsPage.java b/src/com/android/browser/ActiveTabsPage.java index 5e27eab..52d943f 100644 --- a/src/com/android/browser/ActiveTabsPage.java +++ b/src/com/android/browser/ActiveTabsPage.java @@ -18,6 +18,7 @@ package com.android.browser; import android.content.Context; import android.graphics.Bitmap; +import android.text.TextUtils; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; @@ -141,23 +142,30 @@ public class ActiveTabsPage extends LinearLayout implements OnClickListener, view = mInflater.inflate(R.layout.tab_view, parent, false); } ImageView favicon = (ImageView) view.findViewById(R.id.favicon); - TextView title = (TextView) view.findViewById(R.id.title); - TextView url = (TextView) view.findViewById(R.id.url); + ImageView thumbnail = (ImageView) view.findViewById(R.id.thumb); + TextView title = (TextView) view.findViewById(R.id.label); Tab tab = getItem(position); - title.setText(tab.getTitle()); - url.setText(tab.getUrl()); + String label = tab.getTitle(); + if (TextUtils.isEmpty(label)) { + label = tab.getUrl(); + } + title.setText(label); + Bitmap thumbnailBitmap = tab.getScreenshot(); + if (thumbnailBitmap == null) { + thumbnail.setImageResource(R.drawable.browser_thumbnail); + } else { + thumbnail.setImageBitmap(thumbnailBitmap); + } Bitmap faviconBitmap = tab.getFavicon(); if (tab.isPrivateBrowsingEnabled()) { favicon.setImageResource(R.drawable.ic_incognito_holo_dark); - favicon.setBackgroundDrawable(null); } else { if (faviconBitmap == null) { favicon.setImageResource(R.drawable.app_web_browser_sm); } else { favicon.setImageBitmap(faviconBitmap); } - favicon.setBackgroundResource(R.drawable.bookmark_list_favicon_bg); } View close = view.findViewById(R.id.close); close.setTag(position); diff --git a/src/com/android/browser/PhoneUi.java b/src/com/android/browser/PhoneUi.java index dd68e85..9c3c912 100644 --- a/src/com/android/browser/PhoneUi.java +++ b/src/com/android/browser/PhoneUi.java @@ -18,10 +18,12 @@ package com.android.browser; import android.app.Activity; import android.content.Context; +import android.graphics.Bitmap; import android.graphics.PixelFormat; import android.os.Handler; import android.util.Log; import android.view.ActionMode; +import android.view.Display; import android.view.Gravity; import android.view.KeyEvent; import android.view.Menu; @@ -117,6 +119,7 @@ public class PhoneUi extends BaseUi { @Override public void setActiveTab(Tab tab) { + captureTab(mActiveTab); super.setActiveTab(tab); WebView view = tab.getWebView(); // TabControl.setCurrentTab has been called before this, @@ -134,6 +137,18 @@ public class PhoneUi extends BaseUi { tab.getTopWindow().requestFocus(); } + public void captureTab(final Tab tab) { + if (tab == null) return; + if (tab.getWebView() == null) return; + + Display display = mActivity.getWindowManager().getDefaultDisplay(); + float height = mActivity.getResources() + .getDimension(R.dimen.tab_view_thumbnail_height); + Bitmap sshot = Controller.createScreenshot(tab, + display.getWidth(), (int) height); + tab.setScreenshot(sshot); + } + @Override protected void showTitleBar() { if (canShowTitleBar()) { @@ -159,6 +174,7 @@ public class PhoneUi extends BaseUi { @Override public void showActiveTabsPage() { + captureTab(mActiveTab); mActiveTabsPage = new ActiveTabsPage(mActivity, mUiController); mTitleBar.setVisibility(View.GONE); hideTitleBar(); |