diff options
author | Patrick Scott <phanna@android.com> | 2009-09-23 08:08:17 -0400 |
---|---|---|
committer | Patrick Scott <phanna@android.com> | 2009-09-23 14:48:32 -0400 |
commit | 555c5808b3beb8d535480bbed6b7b4d17e21aa98 (patch) | |
tree | 8c9a205e43365db00f8455e2db7c3d535fbd2270 /src/com/android/browser/ActiveTabsPage.java | |
parent | 5e335a381a0cd66e94117b202c1f34f5cb29c9b8 (diff) | |
download | packages_apps_Browser-555c5808b3beb8d535480bbed6b7b4d17e21aa98.zip packages_apps_Browser-555c5808b3beb8d535480bbed6b7b4d17e21aa98.tar.gz packages_apps_Browser-555c5808b3beb8d535480bbed6b7b4d17e21aa98.tar.bz2 |
Use favicons in the tab page instead of a snapshot.
Remove the FakeWebView and all the picture stuff from the picker data. Use the
favicon in a layout similar to history and bookmarks. Add tab_view_add_tab.xml
to have a simpler layout for the "new tab" item in the list.
Diffstat (limited to 'src/com/android/browser/ActiveTabsPage.java')
-rw-r--r-- | src/com/android/browser/ActiveTabsPage.java | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/src/com/android/browser/ActiveTabsPage.java b/src/com/android/browser/ActiveTabsPage.java index e589d42..90c417a 100644 --- a/src/com/android/browser/ActiveTabsPage.java +++ b/src/com/android/browser/ActiveTabsPage.java @@ -17,6 +17,7 @@ package com.android.browser; import android.content.Context; +import android.graphics.Bitmap; import android.util.AttributeSet; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -102,36 +103,44 @@ public class ActiveTabsPage extends LinearLayout { public long getItemId(int position) { return position; } - public View getView(int position, View convertView, ViewGroup parent) { - if (convertView == null) { - convertView = mFactory.inflate(R.layout.tab_view, null); + public int getViewTypeCount() { + return 2; + } + public int getItemViewType(int position) { + if (mControl.getTabCount() < TabControl.MAX_TABS) { + position--; } - TextView title = (TextView) convertView.findViewById(R.id.title); - TextView url = (TextView) convertView.findViewById(R.id.url); - FakeWebView webView - = (FakeWebView) convertView.findViewById(R.id.screen_shot); - View close = convertView.findViewById(R.id.close); - View divider = convertView.findViewById(R.id.divider); - + // Do not recycle the "add new tab" item. + return position == -1 ? IGNORE_ITEM_VIEW_TYPE : 1; + } + public View getView(int position, View convertView, ViewGroup parent) { final int tabCount = mControl.getTabCount(); if (tabCount < TabControl.MAX_TABS) { position--; } - if (position == -1) { - title.setText(R.string.new_tab); - url.setVisibility(View.GONE); - webView.setImageResource(R.drawable.ic_add_tab); - close.setVisibility(View.GONE); - divider.setVisibility(View.GONE); - } else { + + if (convertView == null) { + convertView = mFactory.inflate(position == -1 ? + R.layout.tab_view_add_tab : R.layout.tab_view, null); + } + + if (position != -1) { + TextView title = + (TextView) convertView.findViewById(R.id.title); + TextView url = (TextView) convertView.findViewById(R.id.url); + ImageView favicon = + (ImageView) convertView.findViewById(R.id.favicon); + View close = convertView.findViewById(R.id.close); TabControl.Tab tab = mControl.getTab(position); mControl.populatePickerData(tab); title.setText(tab.getTitle()); url.setText(tab.getUrl()); - url.setVisibility(View.VISIBLE); - webView.setTab(tab); - divider.setVisibility(View.VISIBLE); - close.setVisibility(View.VISIBLE); + Bitmap icon = tab.getFavicon(); + if (icon != null) { + favicon.setImageBitmap(icon); + } else { + favicon.setImageResource(R.drawable.app_web_browser_sm); + } final int closePosition = position; close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { |