Cleanup Bookmarks, History, and SavedPages screen
- Redesigned bookmark thumbnail view
- Custom ImageView to scale the thumbnail properly
- Fix column count in bookmark expandable view
- Disable GroupView if we have only one account in bookmark
Change-Id: I2fccae50b9e96c909744bd5c7d0af7b373136c54
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 2ede78a..87175fe 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -237,7 +237,8 @@
</intent-filter>
</activity>
- <activity android:name="ComboViewActivity">
+ <activity android:name="ComboViewActivity"
+ android:theme="@style/ComboViewTheme">
</activity>
<!-- Bookmark thumbnail homescreen widget -->
diff --git a/res/drawable-hdpi/img_bookmark_card_normal.9.png b/res/drawable-hdpi/img_bookmark_card_normal.9.png
new file mode 100644
index 0000000..78dc977
--- /dev/null
+++ b/res/drawable-hdpi/img_bookmark_card_normal.9.png
Binary files differ
diff --git a/res/drawable-hdpi/img_bookmark_card_pressed.9.png b/res/drawable-hdpi/img_bookmark_card_pressed.9.png
new file mode 100644
index 0000000..d195288
--- /dev/null
+++ b/res/drawable-hdpi/img_bookmark_card_pressed.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/img_bookmark_card_normal.9.png b/res/drawable-xhdpi/img_bookmark_card_normal.9.png
new file mode 100644
index 0000000..38f488e
--- /dev/null
+++ b/res/drawable-xhdpi/img_bookmark_card_normal.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/img_bookmark_card_pressed.9.png b/res/drawable-xhdpi/img_bookmark_card_pressed.9.png
new file mode 100644
index 0000000..9a30518
--- /dev/null
+++ b/res/drawable-xhdpi/img_bookmark_card_pressed.9.png
Binary files differ
diff --git a/res/drawable-xxhdpi/img_bookmark_card_normal.9.png b/res/drawable-xxhdpi/img_bookmark_card_normal.9.png
new file mode 100644
index 0000000..abb1ca2
--- /dev/null
+++ b/res/drawable-xxhdpi/img_bookmark_card_normal.9.png
Binary files differ
diff --git a/res/drawable-xxhdpi/img_bookmark_card_pressed.9.png b/res/drawable-xxhdpi/img_bookmark_card_pressed.9.png
new file mode 100644
index 0000000..d6fbad8
--- /dev/null
+++ b/res/drawable-xxhdpi/img_bookmark_card_pressed.9.png
Binary files differ
diff --git a/res/drawable/bookmark_thumb_selector.xml b/res/drawable/bookmark_thumb_selector.xml
index 5509aba..5c04410 100644
--- a/res/drawable/bookmark_thumb_selector.xml
+++ b/res/drawable/bookmark_thumb_selector.xml
@@ -15,8 +15,8 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/bookmarks_widget_thumb_selector_focused" />
- <item android:state_pressed="true" android:drawable="@drawable/bookmark_thumb_selector_transition" />
- <item android:drawable="@android:color/transparent" />
+ <item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/img_bookmark_card_pressed" />
+ <item android:state_pressed="true" android:drawable="@drawable/img_bookmark_card_pressed" />
+ <item android:drawable="@drawable/img_bookmark_card_normal" />
</selector>
diff --git a/res/drawable/shadow_bottom.xml b/res/drawable/shadow_bottom.xml
new file mode 100644
index 0000000..b32acd7
--- /dev/null
+++ b/res/drawable/shadow_bottom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+ <gradient
+ android:startColor="#20000000"
+ android:centerColor="#0A777777"
+ android:endColor="#00FFFFFF"
+ android:angle="270"/>
+</shape>
\ No newline at end of file
diff --git a/res/drawable/shadow_top.xml b/res/drawable/shadow_top.xml
new file mode 100644
index 0000000..fb801d4
--- /dev/null
+++ b/res/drawable/shadow_top.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+ <gradient
+ android:startColor="#20000000"
+ android:centerColor="#0A777777"
+ android:endColor="#00FFFFFF"
+ android:angle="90"/>
+</shape>
\ No newline at end of file
diff --git a/res/layout-sw600dp/history.xml b/res/layout-sw600dp/history.xml
index 594b85f..cdf5493 100644
--- a/res/layout-sw600dp/history.xml
+++ b/res/layout-sw600dp/history.xml
@@ -39,18 +39,32 @@
android:textAppearance="?android:attr/textAppearanceLarge"
android:visibility="gone" />
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/combo_shadow_height"
+ android:layout_gravity="bottom"
+ android:background="@drawable/shadow_top" />
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/combo_shadow_height"
+ android:layout_gravity="top"
+ android:background="@drawable/shadow_bottom" />
+
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
+ style="?android:attr/buttonBarStyle"
+ android:background="@color/primary"
android:layout_weight="10">
<Button
android:id="@+id/clear_history_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ style="?android:attr/buttonBarButtonStyle"
android:text="@string/clear_history" />
</LinearLayout>
</LinearLayout>
diff --git a/res/layout-sw600dp/snapshot_item.xml b/res/layout-sw600dp/snapshot_item.xml
index 2fc6ca8..0e28236 100644
--- a/res/layout-sw600dp/snapshot_item.xml
+++ b/res/layout-sw600dp/snapshot_item.xml
@@ -18,7 +18,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:padding="@dimen/combo_horizontalSpacing">
+ android:padding="@dimen/combo_snapshot_item_padding">
<ImageView
android:id="@+id/thumb"
android:src="@drawable/thumbnail_bookmarks_widget_no_bookmark_holo"
@@ -51,7 +51,7 @@
android:layout_below="@+id/thumb"
android:layout_alignLeft="@+id/thumb"
android:scaleType="fitXY"
- android:layout_marginTop="12dip" />
+ android:layout_marginTop="6dip" />
<TextView android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout/bookmark_thumbnail.xml b/res/layout/bookmark_thumbnail.xml
index c7f9651..04d75c2 100644
--- a/res/layout/bookmark_thumbnail.xml
+++ b/res/layout/bookmark_thumbnail.xml
@@ -18,47 +18,35 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:orientation="vertical"
- android:padding="@dimen/combo_horizontalSpacing"
+ android:paddingLeft="@dimen/combo_horizontalSpacing"
+ android:paddingRight="@dimen/combo_horizontalSpacing"
+ android:layout_margin="@dimen/combo_bookmark_thumbnail_margin"
android:background="@drawable/bookmark_thumb_selector"
+ android:orientation="vertical"
>
- <ImageView
- android:id="@+id/thumb"
- android:src="@drawable/browser_thumbnail"
- android:scaleType="centerCrop"
- android:layout_height="@dimen/bookmarkThumbnailHeight"
+ <com.android.browser.view.BookmarkThumbImageView
+ android:id="@+id/thumb_image"
android:layout_width="@dimen/bookmarkThumbnailWidth"
- android:layout_centerHorizontal="true"
- android:background="@drawable/border_thumb_bookmarks_widget_holo"
+ android:layout_height="@dimen/bookmarkThumbnailHeight"
+ android:paddingTop="2dip"
+ android:scaleType="centerCrop"
+ android:src="@drawable/browser_thumbnail"
/>
- <ImageView
- android:id="@+id/divider"
- android:src="?android:attr/dividerVertical"
- android:layout_width="wrap_content"
- android:layout_height="24dip"
- android:layout_below="@+id/thumb"
- android:layout_alignLeft="@+id/thumb"
- android:scaleType="fitXY"
- android:layout_marginTop="12dip"
- />
-
- <TextView android:id="@+id/label"
+ <TextView
+ android:id="@+id/label"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_toRightOf="@id/divider"
- android:layout_alignTop="@id/divider"
- android:layout_alignBottom="@id/divider"
- android:layout_alignRight="@+id/thumb"
- android:paddingLeft="8dip"
- android:paddingRight="2dip"
- android:gravity="center_vertical"
- android:singleLine="true"
+ android:layout_height="wrap_content"
android:ellipsize="marquee"
- android:typeface="sans"
- android:textSize="14sp"
- android:textColor="#AAAAAA"
+ android:paddingLeft="8dip"
+ android:paddingRight="4dip"
+ android:paddingTop="2dip"
+ android:paddingBottom="2dip"
+ android:singleLine="true"
+ android:textColor="@color/black"
+ android:textSize="16sp"
+ android:fontFamily="sans-serif-light"
/>
</com.android.browser.view.BookmarkContainer>
diff --git a/res/layout/bookmarks.xml b/res/layout/bookmarks.xml
index 02a5a97..2475af3 100644
--- a/res/layout/bookmarks.xml
+++ b/res/layout/bookmarks.xml
@@ -41,26 +41,44 @@
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/empty_bookmarks_folder"
android:visibility="gone" />
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/combo_shadow_height"
+ android:layout_gravity="bottom"
+ android:background="@drawable/shadow_top" />
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/combo_shadow_height"
+ android:layout_gravity="top"
+ android:background="@drawable/shadow_bottom" />
+
</FrameLayout>
+
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:orientation="horizontal"
android:layout_weight="10"
- android:layout_alignParentBottom="true" >
+ android:background="@color/primary"
+ style="?android:attr/buttonBarStyle" >
<Button
android:id="@+id/add_bookmark_button"
android:text="@string/add_new_bookmark"
- android:layout_width="match_parent"
+ android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
+ style="?android:attr/buttonBarButtonStyle"
/>
<Button
android:id="@+id/new_bmfolder_button"
android:text="@string/new_folder"
- android:layout_width="match_parent"
+ android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
+ style="?android:attr/buttonBarButtonStyle"
/>
</LinearLayout>
diff --git a/res/layout/history.xml b/res/layout/history.xml
index 53f70dc..705c32d 100644
--- a/res/layout/history.xml
+++ b/res/layout/history.xml
@@ -39,18 +39,34 @@
android:visibility="gone"
/>
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/combo_shadow_height"
+ android:layout_gravity="bottom"
+ android:background="@drawable/shadow_top" />
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/combo_shadow_height"
+ android:layout_gravity="top"
+ android:background="@drawable/shadow_bottom" />
+
</FrameLayout>
+
+
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="10"
- android:layout_alignParentBottom="true" >
+ android:background="@color/primary"
+ style="?android:attr/buttonBarStyle" >
<Button
android:id="@+id/clear_history_button"
android:text="@string/clear_history"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ style="?android:attr/buttonBarButtonStyle"
/>
</LinearLayout>
diff --git a/res/layout/snapshot_item.xml b/res/layout/snapshot_item.xml
index 7c7ba3b..94a9898 100644
--- a/res/layout/snapshot_item.xml
+++ b/res/layout/snapshot_item.xml
@@ -18,7 +18,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:padding="@dimen/combo_horizontalSpacing">
+ android:padding="@dimen/combo_snapshot_item_padding">
<ImageView
android:id="@+id/thumb"
android:src="@drawable/thumbnail_bookmarks_widget_no_bookmark_holo"
@@ -49,12 +49,12 @@
android:layout_below="@+id/thumb"
android:layout_alignLeft="@+id/thumb"
android:layout_alignRight="@+id/thumb"
- android:layout_marginTop="6dip"
+ android:layout_marginTop="5dip"
android:paddingLeft="8dip"
android:gravity="center_vertical"
- android:typeface="sans"
+ android:textColor="@color/black"
android:textSize="12sp"
- android:textColor="#AAAAAA"
+ android:fontFamily="sans-serif-light"
android:lines="2" />
<ImageView
android:id="@+id/divider"
diff --git a/res/layout/snapshots.xml b/res/layout/snapshots.xml
index a02fbb9..045a418 100644
--- a/res/layout/snapshots.xml
+++ b/res/layout/snapshots.xml
@@ -18,7 +18,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:paddingTop="@dimen/combo_paddingTop">
+ android:paddingTop="@dimen/combo_snapshot_paddingTop">
<com.android.browser.view.SnapshotGridView
android:id="@+id/grid"
@@ -37,4 +37,10 @@
android:text="@string/empty_snapshots_folder"
android:visibility="gone" />
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/combo_shadow_height"
+ android:layout_gravity="top"
+ android:background="@drawable/shadow_bottom" />
+
</FrameLayout>
diff --git a/res/values-sw600dp/dimensions.xml b/res/values-sw600dp/dimensions.xml
index 8edbf5b..8e6bf31 100644
--- a/res/values-sw600dp/dimensions.xml
+++ b/res/values-sw600dp/dimensions.xml
@@ -12,7 +12,7 @@
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<dimen name="bookmarkThumbnailWidth">180dip</dimen>
- <dimen name="bookmarkThumbnailHeight">120dip</dimen>
+ <dimen name="bookmarkThumbnailHeight">90dip</dimen>
<dimen name="widgetThumbnailHeight">104dip</dimen>
<dimen name="widgetColumnWidth">130dip</dimen>
<dimen name="favicon_padded_size">28dip</dimen>
@@ -23,7 +23,7 @@
<dimen name="mv_item_width_portrait">213px</dimen>
<dimen name="mv_border_width">3px</dimen>
<!-- For the combined Bookmarks History view -->
- <dimen name="combo_paddingTop">50dip</dimen>
+ <dimen name="combo_paddingTop">0dip</dimen>
<dimen name="combo_horizontalSpacing">8dip</dimen>
<dimen name="suggest_item_padding">8dp</dimen>
<dimen name="tab_thumbnail_width">240dip</dimen>
diff --git a/res/values-sw600dp/styles.xml b/res/values-sw600dp/styles.xml
index 44fe540..bcfb749 100644
--- a/res/values-sw600dp/styles.xml
+++ b/res/values-sw600dp/styles.xml
@@ -25,4 +25,7 @@
<item name="android:actionBarSize">56dip</item>
</style>
+ <style name="ComboViewTheme" parent="@style/BrowserBase">
+ </style>
+
</resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index a7b76a1..480ca7d 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -24,7 +24,7 @@
<!-- fundamental colors -->
<color name="primary">#ffffff</color>
<color name="navigation_bars">#101828</color>
- <color name="accent">#008aa1</color>
+ <color name="accent">#FF1AACA2</color>
<color name="browser_window_background">#ffffff</color>
<!-- derived colors -->
@@ -47,6 +47,8 @@
<color name="bookmarkWidgetFolderBackground">#A0383847</color>
<color name="bookmarkWidgetFaviconBackground">#23ffffff</color>
<color name="bookmarkListFaviconBackground">#23ffffff</color>
+ <color name="bookmarkLabelColor">#555555</color>
+ <color name="comboViewActionBarColor">#ffffff</color>
<color name="tabFaviconBackground">#FF555555</color>
<color name="tabFocusHighlight">#FF99CC00</color>
<color name="tabViewTitleBackground">#D0000000</color>
diff --git a/res/values/dimensions.xml b/res/values/dimensions.xml
index 6741b26..cf6b60a 100755
--- a/res/values/dimensions.xml
+++ b/res/values/dimensions.xml
@@ -19,8 +19,8 @@
<dimen name="tab_slice">15.5dp</dimen>
<dimen name="tab_focus_stroke">2dip</dimen>
<dimen name="max_tab_width">300dp</dimen>
- <dimen name="bookmarkThumbnailWidth">90dip</dimen>
- <dimen name="bookmarkThumbnailHeight">80dip</dimen>
+ <dimen name="bookmarkThumbnailWidth">130dip</dimen>
+ <dimen name="bookmarkThumbnailHeight">65dip</dimen>
<!--Add for Navigation Feature -->
<dimen name="mynav_item_width">80px</dimen>
<dimen name="mynav_item_width_portrait">80px</dimen>
@@ -49,7 +49,11 @@
<dimen name="widgetColumnWidth">80dip</dimen>
<!-- For the combined Bookmarks History view -->
<dimen name="combo_paddingTop">0dip</dimen>
+ <dimen name="combo_snapshot_paddingTop">0dip</dimen>
<dimen name="combo_horizontalSpacing">6dip</dimen>
+ <dimen name="combo_bookmark_thumbnail_margin">4dip</dimen>
+ <dimen name="combo_snapshot_item_padding">12dip</dimen>
+ <dimen name="combo_shadow_height">8dip</dimen>
<dimen name="tab_view_thumbnail_height">76dip</dimen>
<!-- Preference activity side margins -->
<dimen name="preference_screen_side_margin">0dp</dimen>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index db4ac91..ec0f34c 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -69,6 +69,16 @@
<style name="SettingsTheme" parent="@style/BrowserBase">
</style>
+ <style name="ComboViewActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar">
+ <item name="android:background">@color/comboViewActionBarColor</item>
+ </style>
+ <style name="ComboViewActionBarTabBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.TabBar">
+ <item name="android:background">@color/comboViewActionBarColor</item>
+ </style>
+ <style name="ComboViewTheme" parent="@style/BrowserBase">
+ <item name="android:actionBarStyle">@style/ComboViewActionBarStyle</item>
+ <item name="android:actionBarTabBarStyle">@style/ComboViewActionBarTabBarStyle</item>
+ </style>
<style name="NavButton">
<item name="android:background">?android:attr/selectableItemBackground</item>
diff --git a/src/com/android/browser/BrowserBookmarksAdapter.java b/src/com/android/browser/BrowserBookmarksAdapter.java
index 3b38f1e..2acc9c9 100644
--- a/src/com/android/browser/BrowserBookmarksAdapter.java
+++ b/src/com/android/browser/BrowserBookmarksAdapter.java
@@ -23,7 +23,6 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.TextView;
@@ -31,6 +30,7 @@
import com.android.browser.platformsupport.BrowserContract.Bookmarks;
import com.android.browser.util.ThreadedCursorAdapter;
import com.android.browser.view.BookmarkContainer;
+import com.android.browser.view.BookmarkThumbImageView;
public class BrowserBookmarksAdapter extends
ThreadedCursorAdapter<BrowserBookmarksAdapterItem> {
@@ -83,7 +83,7 @@
.getDimensionPixelSize(R.dimen.combo_horizontalSpacing);
view.setPadding(padding, view.getPaddingTop(),
padding, view.getPaddingBottom());
- ImageView thumb = (ImageView) view.findViewById(R.id.thumb);
+ BookmarkThumbImageView thumb = (BookmarkThumbImageView) view.findViewById(R.id.thumb_image);
TextView tv = (TextView) view.findViewById(R.id.label);
tv.setText(item.title);
@@ -93,13 +93,12 @@
thumb.setScaleType(ScaleType.FIT_END);
thumb.setBackground(null);
} else {
- thumb.setScaleType(ScaleType.CENTER_CROP);
if (item.thumbnail == null || !item.has_thumbnail) {
+ thumb.setScaleType(ScaleType.CENTER_CROP);
thumb.setImageResource(R.drawable.browser_thumbnail);
} else {
thumb.setImageDrawable(item.thumbnail);
}
- thumb.setBackgroundResource(R.drawable.border_thumb_bookmarks_widget_holo);
}
}
diff --git a/src/com/android/browser/view/BookmarkContainer.java b/src/com/android/browser/view/BookmarkContainer.java
index 5175589..54f281c 100644
--- a/src/com/android/browser/view/BookmarkContainer.java
+++ b/src/com/android/browser/view/BookmarkContainer.java
@@ -24,9 +24,9 @@
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewConfiguration;
-import android.widget.RelativeLayout;
+import android.widget.LinearLayout;
-public class BookmarkContainer extends RelativeLayout implements OnClickListener {
+public class BookmarkContainer extends LinearLayout implements OnClickListener {
private OnClickListener mClickListener;
private boolean mIgnoreRequestLayout = false;
diff --git a/src/com/android/browser/view/BookmarkExpandableView.java b/src/com/android/browser/view/BookmarkExpandableView.java
index aec00ff..db19c33 100644
--- a/src/com/android/browser/view/BookmarkExpandableView.java
+++ b/src/com/android/browser/view/BookmarkExpandableView.java
@@ -109,7 +109,8 @@
LayoutInflater infalter = LayoutInflater.from(mContext);
View v = infalter.inflate(layout, this, false);
v.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
- mColumnWidth = v.getMeasuredWidth();
+ int margin = getResources().getDimensionPixelSize(R.dimen.combo_bookmark_thumbnail_margin);
+ mColumnWidth = v.getMeasuredWidth() + (margin * 2);
}
public void clearAccounts() {
@@ -402,6 +403,16 @@
if (view == null) {
view = mInflater.inflate(R.layout.bookmark_group_view, parent, false);
view.setOnClickListener(mGroupOnClickListener);
+ if (getGroupCount() == 1 && isExpanded) {
+ // Hide the group view if we have only one group in this expandable list.
+ ViewGroup.LayoutParams lp = view.getLayoutParams();
+ lp.height = 0;
+ view.setLayoutParams(lp);
+ view.setVisibility(View.INVISIBLE);
+ if (parent instanceof ExpandableListView) {
+ ((ExpandableListView) parent).setGroupIndicator(null);
+ }
+ }
}
view.setTag(R.id.group_position, groupPosition);
FrameLayout crumbHolder = (FrameLayout) view.findViewById(R.id.crumb_holder);
diff --git a/src/com/android/browser/view/BookmarkThumbImageView.java b/src/com/android/browser/view/BookmarkThumbImageView.java
new file mode 100644
index 0000000..50b3544
--- /dev/null
+++ b/src/com/android/browser/view/BookmarkThumbImageView.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+package com.android.browser.view;
+
+import android.content.Context;
+import android.graphics.Matrix;
+import android.graphics.drawable.Drawable;
+import android.util.AttributeSet;
+import android.widget.ImageView;
+
+public class BookmarkThumbImageView extends ImageView {
+
+ public BookmarkThumbImageView(Context context) {
+ this(context, null);
+ }
+
+ public BookmarkThumbImageView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public BookmarkThumbImageView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ @Override
+ public void setImageDrawable(Drawable drawable) {
+ int drawableWidth = drawable.getIntrinsicWidth();
+ int drawableHeight = drawable.getIntrinsicHeight();
+ int containerWidth = getWidth() - getPaddingLeft() - getPaddingRight();
+ int containerHeight = getHeight() - getPaddingTop() - getPaddingBottom();
+
+ float scale;
+ Matrix m = new Matrix();
+ if ( (drawableWidth * containerHeight) > (containerWidth * drawableHeight)) {
+ scale = (float) containerHeight / (float) drawableHeight;
+ } else {
+ scale = (float) containerWidth / (float) drawableWidth;
+ float translateY = (containerHeight - drawableHeight * scale) / 2;
+ if (translateY < 0) {
+ translateY = 0;
+ }
+ m.postTranslate(0, translateY + 0.5f);
+ }
+ m.setScale(scale, scale);
+
+ this.setScaleType(ScaleType.MATRIX);
+ this.setImageMatrix(m);
+ super.setImageDrawable(drawable);
+ }
+}