summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeon Scroggins <scroggo@google.com>2009-09-24 16:06:02 -0400
committerLeon Scroggins <scroggo@google.com>2009-09-25 12:02:32 -0400
commitf85516172840450a4d1270b658905dc1649ceaf2 (patch)
tree57cd9a39e277cfed92c2765658047c616a202487
parentaac7aa6fcfcb519755987ec126be066323f589c8 (diff)
downloadpackages_apps_browser-f85516172840450a4d1270b658905dc1649ceaf2.zip
packages_apps_browser-f85516172840450a4d1270b658905dc1649ceaf2.tar.gz
packages_apps_browser-f85516172840450a4d1270b658905dc1649ceaf2.tar.bz2
Fix layout issues on the bookmarks screen.
Limit the title of a bookmark to stop at the right edge of screenshot. Use the new default screenshots for bookmarks without screenshots. Resize the bookmark screenshot to match the size of the default icon. Fixes http://b/issue?id=2042025 and http://b/issue?id=2098770 Change-Id: I66a10671ea98007cfe5bf7502fb1e3619276ca22
-rw-r--r--res/drawable-hdpi/browser_thumbnail.pngbin0 -> 2836 bytes
-rw-r--r--res/drawable-mdpi/browser_thumbnail.pngbin0 -> 1865 bytes
-rw-r--r--res/layout/bookmark_thumbnail.xml7
-rw-r--r--src/com/android/browser/BrowserActivity.java42
-rw-r--r--src/com/android/browser/BrowserBookmarksAdapter.java4
-rw-r--r--src/com/android/browser/BrowserBookmarksPage.java9
6 files changed, 50 insertions, 12 deletions
diff --git a/res/drawable-hdpi/browser_thumbnail.png b/res/drawable-hdpi/browser_thumbnail.png
new file mode 100644
index 0000000..590a005
--- /dev/null
+++ b/res/drawable-hdpi/browser_thumbnail.png
Binary files differ
diff --git a/res/drawable-mdpi/browser_thumbnail.png b/res/drawable-mdpi/browser_thumbnail.png
new file mode 100644
index 0000000..2d54e07
--- /dev/null
+++ b/res/drawable-mdpi/browser_thumbnail.png
Binary files differ
diff --git a/res/layout/bookmark_thumbnail.xml b/res/layout/bookmark_thumbnail.xml
index d53350b..abbbb45 100644
--- a/res/layout/bookmark_thumbnail.xml
+++ b/res/layout/bookmark_thumbnail.xml
@@ -16,15 +16,17 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="0dip"
>
<ImageView android:id="@+id/thumb"
- android:src="@drawable/ic_launcher_shortcut_browser_bookmark"
+ android:src="@drawable/browser_thumbnail"
android:scaleType="center"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
+ android:layout_gravity="center"
/>
<!-- FIXME: Want to have a gradient over the thumb -->
@@ -67,10 +69,11 @@
android:paddingTop="0dip"
android:paddingBottom="0dip"
android:layout_marginTop="0dip"
- android:layout_marginBottom="16dip"
android:scrollHorizontally="true"
android:ellipsize="marquee"
android:layout_below="@+id/thumb"
+ android:layout_alignLeft="@+id/thumb"
+ android:layout_alignRight="@+id/thumb"
/>
</RelativeLayout>
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index 444e98d..b1a3abe 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -2376,21 +2376,51 @@ public class BrowserActivity extends Activity
}
/**
- * Constants for the size of the thumbnail created when taking a screenshot
+ * Values for the size of the thumbnail created when taking a screenshot.
+ * Lazily initialized. Instead of using these directly, use
+ * getDesiredThumbnailWidth() or getDesiredThumbnailHeight().
*/
- /* package */ static final int THUMBNAIL_WIDTH = 130;
- /* package */ static final int THUMBNAIL_HEIGHT = 104;
+ private static int THUMBNAIL_WIDTH = 0;
+ private static int THUMBNAIL_HEIGHT = 0;
+
+ /**
+ * Return the desired width for thumbnail screenshots, which are stored in
+ * the database, and used on the bookmarks screen.
+ * @param context Context for finding out the density of the screen.
+ * @return int desired width for thumbnail screenshot.
+ */
+ /* package */ static int getDesiredThumbnailWidth(Context context) {
+ if (THUMBNAIL_WIDTH == 0) {
+ float density = context.getResources().getDisplayMetrics().density;
+ THUMBNAIL_WIDTH = (int) (90 * density);
+ THUMBNAIL_HEIGHT = (int) (80 * density);
+ }
+ return THUMBNAIL_WIDTH;
+ }
+
+ /**
+ * Return the desired height for thumbnail screenshots, which are stored in
+ * the database, and used on the bookmarks screen.
+ * @param context Context for finding out the density of the screen.
+ * @return int desired height for thumbnail screenshot.
+ */
+ /* package */ static int getDesiredThumbnailHeight(Context context) {
+ // To ensure that they are both initialized.
+ getDesiredThumbnailWidth(context);
+ return THUMBNAIL_HEIGHT;
+ }
private Bitmap createScreenshot(WebView view) {
Picture thumbnail = view.capturePicture();
- Bitmap bm = Bitmap.createBitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT,
- Bitmap.Config.ARGB_4444);
+ Bitmap bm = Bitmap.createBitmap(getDesiredThumbnailWidth(this),
+ getDesiredThumbnailHeight(this), Bitmap.Config.ARGB_4444);
Canvas canvas = new Canvas(bm);
// May need to tweak these values to determine what is the
// best scale factor
int contentWidth = view.getContentWidth();
if (contentWidth > 0) {
- float scaleFactor = (float) THUMBNAIL_WIDTH / (float) contentWidth;
+ float scaleFactor = (float) getDesiredThumbnailWidth(this)
+ / (float) contentWidth;
canvas.scale(scaleFactor, scaleFactor);
}
thumbnail.draw(canvas);
diff --git a/src/com/android/browser/BrowserBookmarksAdapter.java b/src/com/android/browser/BrowserBookmarksAdapter.java
index bbecab9..8b0fb41 100644
--- a/src/com/android/browser/BrowserBookmarksAdapter.java
+++ b/src/com/android/browser/BrowserBookmarksAdapter.java
@@ -429,7 +429,7 @@ class BrowserBookmarksAdapter extends BaseAdapter {
thumb.setImageBitmap(mCurrentThumbnail);
} else {
thumb.setImageResource(
- R.drawable.ic_launcher_shortcut_browser_bookmark);
+ R.drawable.browser_thumbnail);
}
return convertView;
}
@@ -439,7 +439,7 @@ class BrowserBookmarksAdapter extends BaseAdapter {
Browser.HISTORY_PROJECTION_TITLE_INDEX));
Bitmap thumbnail = getBitmap(Browser.HISTORY_PROJECTION_THUMBNAIL_INDEX, position);
if (thumbnail == null) {
- thumb.setImageResource(R.drawable.ic_launcher_shortcut_browser_bookmark);
+ thumb.setImageResource(R.drawable.browser_thumbnail);
} else {
thumb.setImageBitmap(thumbnail);
}
diff --git a/src/com/android/browser/BrowserBookmarksPage.java b/src/com/android/browser/BrowserBookmarksPage.java
index 17a362b..8b67e4d 100644
--- a/src/com/android/browser/BrowserBookmarksPage.java
+++ b/src/com/android/browser/BrowserBookmarksPage.java
@@ -294,11 +294,16 @@ public class BrowserBookmarksPage extends Activity implements
mGridPage.setAdapter(mBookmarksAdapter);
mGridPage.setOnItemClickListener(mListener);
mGridPage.setNumColumns(GridView.AUTO_FIT);
- mGridPage.setColumnWidth(BrowserActivity.THUMBNAIL_WIDTH);
+ mGridPage.setColumnWidth(
+ BrowserActivity.getDesiredThumbnailWidth(this));
mGridPage.setFocusable(true);
mGridPage.setFocusableInTouchMode(true);
mGridPage.setSelector(android.R.drawable.gallery_thumb);
- mGridPage.setVerticalSpacing(10);
+ float density = getResources().getDisplayMetrics().density;
+ mGridPage.setVerticalSpacing((int) (14 * density));
+ mGridPage.setHorizontalSpacing((int) (8 * density));
+ mGridPage.setStretchMode(GridView.STRETCH_SPACING);
+ mGridPage.setDrawSelectorOnTop(true);
if (mMostVisited) {
mGridPage.setEmptyView(mEmptyView);
}