diff options
author | John Reck <jreck@google.com> | 2011-01-11 15:36:01 -0800 |
---|---|---|
committer | John Reck <jreck@google.com> | 2011-01-12 16:35:11 -0800 |
commit | 1537b774a62042a8b86100e1e6b0988bed70c385 (patch) | |
tree | b1ec5561d8fa4f679699fff9b80bba2731e35285 | |
parent | dcc1cd118d4db2b47ecd93c00608441375ced6b5 (diff) | |
download | android_packages_apps_Gello-1537b774a62042a8b86100e1e6b0988bed70c385.tar.gz android_packages_apps_Gello-1537b774a62042a8b86100e1e6b0988bed70c385.tar.bz2 android_packages_apps_Gello-1537b774a62042a8b86100e1e6b0988bed70c385.zip |
Replace old list widget with new thumbnail widget
Bug: 3336562
Change-Id: Ic612b5309f185658f4515bbc90cc44d8b9ccf1e0
31 files changed, 212 insertions, 212 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 9ceaf82b..1dc53f6e 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -189,9 +189,9 @@ android:configChanges="orientation|keyboardHidden" android:windowSoftInputMode="stateHidden"> </activity> - <!-- Bookmark list homescreen widget --> + <!-- Bookmark thumbnail homescreen widget --> <receiver - android:name=".widget.BookmarkListWidgetProvider" + android:name=".widget.BookmarkThumbnailWidgetProvider" android:label="@string/bookmarks"> <intent-filter> <action @@ -201,10 +201,10 @@ </intent-filter> <meta-data android:name="android.appwidget.provider" - android:resource="@xml/bookmarklistwidget_info" /> + android:resource="@xml/bookmarkthumbnailwidget_info" /> </receiver> <service - android:name=".widget.BookmarkListWidgetService" + android:name=".widget.BookmarkThumbnailWidgetService" android:exported="true" /> <!-- Makes .BrowserActivity the search target for any activity in Browser --> diff --git a/res/drawable-hdpi/bookmarks_widget_thumb_selector_pressed.9.png b/res/drawable-hdpi/bookmarks_widget_thumb_selector_pressed.9.png Binary files differnew file mode 100644 index 00000000..a329b193 --- /dev/null +++ b/res/drawable-hdpi/bookmarks_widget_thumb_selector_pressed.9.png diff --git a/res/drawable-hdpi/border_thumb_bookmarks_widget_holo.9.png b/res/drawable-hdpi/border_thumb_bookmarks_widget_holo.9.png Binary files differnew file mode 100644 index 00000000..ab0ece8d --- /dev/null +++ b/res/drawable-hdpi/border_thumb_bookmarks_widget_holo.9.png diff --git a/res/drawable-hdpi/gradient_overlay_bg_bookmark_widget_holo.png b/res/drawable-hdpi/gradient_overlay_bg_bookmark_widget_holo.png Binary files differdeleted file mode 100644 index c530cc55..00000000 --- a/res/drawable-hdpi/gradient_overlay_bg_bookmark_widget_holo.png +++ /dev/null diff --git a/res/drawable-hdpi/ic_bookmark_widget_bookmark_holo_dark.png b/res/drawable-hdpi/ic_bookmark_widget_bookmark_holo_dark.png Binary files differnew file mode 100644 index 00000000..d7c9bd93 --- /dev/null +++ b/res/drawable-hdpi/ic_bookmark_widget_bookmark_holo_dark.png diff --git a/res/drawable-hdpi/overlay_url_bookmark_widget_holo.9.png b/res/drawable-hdpi/overlay_url_bookmark_widget_holo.9.png Binary files differnew file mode 100644 index 00000000..570d238c --- /dev/null +++ b/res/drawable-hdpi/overlay_url_bookmark_widget_holo.9.png diff --git a/res/drawable-hdpi/thumb_bookmark_widget_folder_back_holo.png b/res/drawable-hdpi/thumb_bookmark_widget_folder_back_holo.png Binary files differnew file mode 100644 index 00000000..9ca04c17 --- /dev/null +++ b/res/drawable-hdpi/thumb_bookmark_widget_folder_back_holo.png diff --git a/res/drawable-hdpi/thumb_bookmark_widget_folder_holo.png b/res/drawable-hdpi/thumb_bookmark_widget_folder_holo.png Binary files differnew file mode 100644 index 00000000..e221fd2a --- /dev/null +++ b/res/drawable-hdpi/thumb_bookmark_widget_folder_holo.png diff --git a/res/drawable-mdpi/app_web_browser_sm.png b/res/drawable-mdpi/app_web_browser_sm.png Binary files differindex dbb460ad..21245c2b 100644 --- a/res/drawable-mdpi/app_web_browser_sm.png +++ b/res/drawable-mdpi/app_web_browser_sm.png diff --git a/res/drawable-mdpi/bg_bookmark_widget_holo.9.png b/res/drawable-mdpi/bg_bookmark_widget_holo.9.png Binary files differindex ac56bbe7..d95f8d39 100644 --- a/res/drawable-mdpi/bg_bookmark_widget_holo.9.png +++ b/res/drawable-mdpi/bg_bookmark_widget_holo.9.png diff --git a/res/drawable-mdpi/bookmarks_widget_thumb_selector_pressed.9.png b/res/drawable-mdpi/bookmarks_widget_thumb_selector_pressed.9.png Binary files differnew file mode 100644 index 00000000..6ec15764 --- /dev/null +++ b/res/drawable-mdpi/bookmarks_widget_thumb_selector_pressed.9.png diff --git a/res/drawable-mdpi/header_row_press_bookmark_widget_holo.9.png b/res/drawable-mdpi/border_thumb_bookmarks_widget_holo.9.png Binary files differindex 2e8874ec..486e5e87 100644 --- a/res/drawable-mdpi/header_row_press_bookmark_widget_holo.9.png +++ b/res/drawable-mdpi/border_thumb_bookmarks_widget_holo.9.png diff --git a/res/drawable-mdpi/gradient_overlay_bg_bookmark_widget_holo.png b/res/drawable-mdpi/gradient_overlay_bg_bookmark_widget_holo.png Binary files differdeleted file mode 100644 index 16733384..00000000 --- a/res/drawable-mdpi/gradient_overlay_bg_bookmark_widget_holo.png +++ /dev/null diff --git a/res/drawable-mdpi/header_bg_bookmark_widget_holo.png b/res/drawable-mdpi/header_bg_bookmark_widget_holo.png Binary files differdeleted file mode 100644 index 9c3f7a61..00000000 --- a/res/drawable-mdpi/header_bg_bookmark_widget_holo.png +++ /dev/null diff --git a/res/drawable-mdpi/header_row_focused_bookmark_widget_holo.9.png b/res/drawable-mdpi/ic_bookmark_widget_bookmark_holo_dark.png Binary files differindex b745159d..70477aac 100644 --- a/res/drawable-mdpi/header_row_focused_bookmark_widget_holo.9.png +++ b/res/drawable-mdpi/ic_bookmark_widget_bookmark_holo_dark.png diff --git a/res/drawable-mdpi/overlay_url_bookmark_widget_holo.9.png b/res/drawable-mdpi/overlay_url_bookmark_widget_holo.9.png Binary files differnew file mode 100644 index 00000000..a72900d3 --- /dev/null +++ b/res/drawable-mdpi/overlay_url_bookmark_widget_holo.9.png diff --git a/res/drawable-mdpi/stripes_overlay_bg_bookmark_widget_holo.png b/res/drawable-mdpi/stripes_overlay_bg_bookmark_widget_holo.png Binary files differindex 8c9614bd..6b387a09 100644 --- a/res/drawable-mdpi/stripes_overlay_bg_bookmark_widget_holo.png +++ b/res/drawable-mdpi/stripes_overlay_bg_bookmark_widget_holo.png diff --git a/res/drawable-mdpi/thumb_bookmark_widget_folder_back_holo.png b/res/drawable-mdpi/thumb_bookmark_widget_folder_back_holo.png Binary files differnew file mode 100644 index 00000000..e75e53f7 --- /dev/null +++ b/res/drawable-mdpi/thumb_bookmark_widget_folder_back_holo.png diff --git a/res/drawable-mdpi/thumb_bookmark_widget_folder_holo.png b/res/drawable-mdpi/thumb_bookmark_widget_folder_holo.png Binary files differnew file mode 100644 index 00000000..58ad3a0c --- /dev/null +++ b/res/drawable-mdpi/thumb_bookmark_widget_folder_holo.png diff --git a/res/drawable/bookmark_widget_thumb_selector.xml b/res/drawable/bookmark_widget_thumb_selector.xml new file mode 100644 index 00000000..d9b81713 --- /dev/null +++ b/res/drawable/bookmark_widget_thumb_selector.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_pressed="true" android:drawable="@drawable/bookmarks_widget_thumb_selector_pressed" /> + <item android:drawable="@android:color/transparent" /> +</selector> + diff --git a/res/drawable/browser_widget_preview.png b/res/drawable/browser_widget_preview.png Binary files differindex a3f48dd6..49239781 100755..100644 --- a/res/drawable/browser_widget_preview.png +++ b/res/drawable/browser_widget_preview.png diff --git a/res/drawable/widget_background.xml b/res/drawable/widget_background.xml index de6c3f25..15f8a59e 100644 --- a/res/drawable/widget_background.xml +++ b/res/drawable/widget_background.xml @@ -16,14 +16,16 @@ <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> - <item> - <bitmap - android:src="@drawable/gradient_overlay_bg_bookmark_widget_holo" - android:gravity="top|fill_horizontal" /> + <item + android:drawable="@drawable/bg_bookmark_widget_holo"> </item> <item> <bitmap android:src="@drawable/stripes_overlay_bg_bookmark_widget_holo" - android:gravity="top|fill_horizontal" /> + android:gravity="top|left|clip_vertical|clip_horizontal" + android:left="3dip" + android:right="3dip" + android:top="3dip" + android:bottom="3dip" /> </item> </layer-list> diff --git a/res/layout/bookmarklistwidget.xml b/res/layout/bookmarklistwidget.xml deleted file mode 100644 index f3857f82..00000000 --- a/res/layout/bookmarklistwidget.xml +++ /dev/null @@ -1,99 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2010 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<FrameLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:paddingTop="4dip" - android:paddingBottom="20dip" - android:paddingLeft="12dip" - android:paddingRight="12dip"> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" - android:background="@drawable/bg_bookmark_widget_holo" - android:paddingLeft="0dip" - android:paddingRight="0dip" - android:paddingBottom="0dip"> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="42dip" - android:orientation="horizontal" - android:background="@drawable/header_bg_bookmark_widget_holo" - android:layout_marginLeft="5dip" - android:layout_marginRight="5dip"> - <LinearLayout - android:id="@+id/header_browser" - android:layout_width="0dip" - android:layout_height="match_parent" - android:layout_weight="1" - android:orientation="horizontal" - android:paddingLeft="16dip" - android:focusable="true" - android:clickable="true" - android:background="@drawable/widget_header_selector"> - <ImageView - android:id="@+id/logo" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="center_vertical" - android:src="@drawable/ic_browser_bookmark_widget_holo" /> - <TextView - android:layout_width="0dip" - android:layout_height="wrap_content" - android:layout_weight="1" - android:layout_gravity="center_vertical" - android:text="@string/application_name" - android:textAppearance="?android:attr/textAppearanceMedium" - android:textStyle="bold" - android:paddingLeft="8dip" /> - </LinearLayout> - <ImageView - android:id="@+id/header_bookmarks" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:src="@drawable/btn_ic_bookmark_bookmark_widget_holo_dark" - android:scaleType="centerInside" - android:focusable="true" - android:clickable="true" - android:background="@drawable/widget_header_selector" - android:paddingLeft="8dip" - android:paddingRight="8dip" /> - </LinearLayout> - <ImageView android:background="@drawable/list_div_top_btm_bookmark_widget_holo" - android:layout_height="wrap_content" - android:layout_width="match_parent" - android:layout_marginLeft="2dip" - android:layout_marginRight="2dip" /> - <ListView - android:id="@+id/bookmarks_list" - android:layout_width="match_parent" - android:layout_height="0dip" - android:layout_weight="1" - android:background="@drawable/widget_background" - android:cacheColorHint="@android:color/transparent" - android:divider="@drawable/list_div_bookmark_widget_holo" - android:layout_marginLeft="5dip" - android:layout_marginRight="5dip" /> - <ImageView android:background="@drawable/list_div_top_btm_bookmark_widget_holo" - android:layout_height="wrap_content" - android:layout_width="match_parent" - android:layout_marginLeft="2dip" - android:layout_marginRight="2dip" - android:layout_marginBottom="2dip" /> - </LinearLayout> -</FrameLayout> diff --git a/res/layout/bookmarklistwidget_item.xml b/res/layout/bookmarklistwidget_item.xml deleted file mode 100644 index 2f640542..00000000 --- a/res/layout/bookmarklistwidget_item.xml +++ /dev/null @@ -1,43 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2010 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/list_item" - android:layout_width="match_parent" - android:layout_height="48dp" - android:orientation="horizontal" - android:background="@drawable/row_activated_bookmark_widget_holo"> - <ImageView - android:id="@+id/thumb" - android:src="@drawable/browser_thumbnail" - android:layout_height="@dimen/bookmark_widget_thumb_size" - android:layout_width="@dimen/bookmark_widget_thumb_size" - android:layout_gravity="center_vertical" - android:layout_marginLeft="16dp" - android:scaleType="centerInside"/> - <TextView - android:id="@+id/label" - android:layout_width="0dip" - android:layout_height="wrap_content" - android:layout_gravity="center_vertical" - android:layout_weight="1" - android:textAppearance="?android:attr/textAppearanceSmall" - android:paddingLeft="8dip" - android:maxLines="1" - android:scrollHorizontally="true" - android:ellipsize="marquee"/> -</LinearLayout> diff --git a/res/layout/bookmarkthumbnailwidget.xml b/res/layout/bookmarkthumbnailwidget.xml new file mode 100644 index 00000000..581db5ce --- /dev/null +++ b/res/layout/bookmarkthumbnailwidget.xml @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2010 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<FrameLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:paddingTop="4dip" + android:paddingBottom="22dip" + android:paddingLeft="13dip" + android:paddingRight="13dip"> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:padding="0dip" + android:background="@drawable/widget_background"> + <ImageView android:background="@drawable/list_div_top_btm_bookmark_widget_holo" + android:layout_height="wrap_content" + android:layout_width="match_parent" + android:layout_marginTop="2dip" + android:layout_marginLeft="1dip" + android:layout_marginRight="1dip" /> + <GridView + android:id="@+id/bookmarks_list" + android:layout_width="match_parent" + android:layout_height="0dip" + android:layout_weight="1" + android:layout_marginLeft="5dip" + android:layout_marginRight="5dip" + android:numColumns="2" + android:padding="1dip" + android:stretchMode="columnWidth" + android:horizontalSpacing="@dimen/widgetHorizontalSpacing" + android:verticalSpacing="@dimen/widgetVerticalSpacing" + android:drawSelectorOnTop="true" + android:listSelector="@drawable/bookmark_widget_thumb_selector" /> + <ImageView android:background="@drawable/list_div_top_btm_bookmark_widget_holo" + android:layout_height="wrap_content" + android:layout_width="match_parent" + android:layout_marginBottom="3dip" + android:layout_marginLeft="1dip" + android:layout_marginRight="1dip" /> + </LinearLayout> +</FrameLayout> diff --git a/res/layout/bookmarkthumbnailwidget_item.xml b/res/layout/bookmarkthumbnailwidget_item.xml new file mode 100644 index 00000000..b67b3866 --- /dev/null +++ b/res/layout/bookmarkthumbnailwidget_item.xml @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2010 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<RelativeLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/list_item" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + <ImageView + android:id="@+id/thumb" + android:src="@drawable/browser_thumbnail" + android:layout_width="match_parent" + android:layout_height="@dimen/widgetThumbnailHeight" + android:scaleType="centerCrop" + android:cropToPadding="true" + android:background="@drawable/border_thumb_bookmarks_widget_holo" /> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignBottom="@id/thumb" + android:background="@drawable/overlay_url_bookmark_widget_holo" + android:layout_marginLeft="2dip" + android:layout_marginRight="2dip" + android:layout_marginBottom="2dip"> + <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="centerInside" /> + <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="14sp" + android:typeface="sans" + android:textStyle="bold" + android:textColor="@android:color/white" /> + </LinearLayout> +</RelativeLayout> diff --git a/res/values-xlarge-port/dimensions.xml b/res/values-xlarge-port/dimensions.xml new file mode 100644 index 00000000..46e7272d --- /dev/null +++ b/res/values-xlarge-port/dimensions.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2010 The Android Open Source Project Licensed under the + Apache License, Version 2.0 (the "License"); you may not use this file + except in compliance with the License. You may obtain a copy of the + License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by + applicable law or agreed to in writing, software distributed under the + License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + CONDITIONS OF ANY KIND, either express or implied. See the License for + the specific language governing permissions and limitations under the + License. +--> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <dimen name="widgetThumbnailHeight">72dip</dimen> + <dimen name="widgetHorizontalSpacing">0dip</dimen> + <dimen name="widgetVerticalSpacing">4dip</dimen> +</resources> diff --git a/res/values-xlarge/dimensions.xml b/res/values-xlarge/dimensions.xml index 9f5a602f..43e1035b 100644 --- a/res/values-xlarge/dimensions.xml +++ b/res/values-xlarge/dimensions.xml @@ -13,6 +13,9 @@ <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <dimen name="bookmarkThumbnailWidth">180dip</dimen> <dimen name="bookmarkThumbnailHeight">120dip</dimen> + <dimen name="widgetThumbnailHeight">90dip</dimen> + <dimen name="widgetHorizontalSpacing">8dip</dimen> + <dimen name="widgetVerticalSpacing">8dip</dimen> <dimen name="favicon_padded_size">24dip</dimen> <!-- For the most visited page --> <dimen name="mv_max_width">1010dp</dimen> diff --git a/res/xml/bookmarklistwidget_info.xml b/res/xml/bookmarkthumbnailwidget_info.xml index c39ce8f7..6797f85a 100644 --- a/res/xml/bookmarklistwidget_info.xml +++ b/res/xml/bookmarkthumbnailwidget_info.xml @@ -21,5 +21,5 @@ android:minHeight="219dip" android:updatePeriodMillis="0" android:previewImage="@drawable/browser_widget_preview" - android:initialLayout="@layout/bookmarklistwidget"> + android:initialLayout="@layout/bookmarkthumbnailwidget"> </appwidget-provider> diff --git a/src/com/android/browser/widget/BookmarkListWidgetProvider.java b/src/com/android/browser/widget/BookmarkThumbnailWidgetProvider.java index 99daaa1c..14e1c890 100644 --- a/src/com/android/browser/widget/BookmarkListWidgetProvider.java +++ b/src/com/android/browser/widget/BookmarkThumbnailWidgetProvider.java @@ -16,7 +16,6 @@ package com.android.browser.widget; -import com.android.browser.BrowserActivity; import com.android.browser.R; import android.app.PendingIntent; @@ -31,7 +30,7 @@ import android.widget.RemoteViews; /** * Widget that shows a preview of the user's bookmarks. */ -public class BookmarkListWidgetProvider extends AppWidgetProvider { +public class BookmarkThumbnailWidgetProvider extends AppWidgetProvider { static final String ACTION_BOOKMARK_APPWIDGET_UPDATE = "com.android.browser.BOOKMARK_APPWIDGET_UPDATE"; @@ -60,46 +59,37 @@ public class BookmarkListWidgetProvider extends AppWidgetProvider { @Override public void onEnabled(Context context) { // Start the backing service - context.startService(new Intent(context, BookmarkListWidgetService.class)); + context.startService(new Intent(context, BookmarkThumbnailWidgetService.class)); } @Override public void onDisabled(Context context) { // Stop the backing service - context.stopService(new Intent(context, BookmarkListWidgetService.class)); + context.stopService(new Intent(context, BookmarkThumbnailWidgetService.class)); } @Override public void onDeleted(Context context, int[] appWidgetIds) { super.onDeleted(context, appWidgetIds); - context.startService(new Intent(BookmarkListWidgetService.ACTION_REMOVE_FACTORIES, - null, context, BookmarkListWidgetService.class) + context.startService(new Intent(BookmarkThumbnailWidgetService.ACTION_REMOVE_FACTORIES, + null, context, BookmarkThumbnailWidgetService.class) .putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds)); } private void performUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { - Intent launchBrowser = new Intent(BrowserActivity.ACTION_SHOW_BROWSER, - null, context, BrowserActivity.class); - Intent launchBookmarks = new Intent(BrowserActivity.ACTION_SHOW_BOOKMARKS, - null, context, BrowserActivity.class); - // Update the widgets for (int appWidgetId : appWidgetIds) { - Intent updateIntent = new Intent(context, BookmarkListWidgetService.class); + Intent updateIntent = new Intent(context, BookmarkThumbnailWidgetService.class); updateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); updateIntent.setData(Uri.parse(updateIntent.toUri(Intent.URI_INTENT_SCHEME))); RemoteViews views = new RemoteViews(context.getPackageName(), - R.layout.bookmarklistwidget); + R.layout.bookmarkthumbnailwidget); views.setRemoteAdapter(R.id.bookmarks_list, updateIntent); appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.bookmarks_list); - Intent ic = new Intent(context, BookmarkListWidgetService.class); + Intent ic = new Intent(context, BookmarkThumbnailWidgetService.class); views.setPendingIntentTemplate(R.id.bookmarks_list, PendingIntent.getService(context, 0, ic, PendingIntent.FLAG_UPDATE_CURRENT)); - views.setOnClickPendingIntent(R.id.header_browser, PendingIntent - .getActivity(context, 0, launchBrowser, PendingIntent.FLAG_CANCEL_CURRENT)); - views.setOnClickPendingIntent(R.id.header_bookmarks, PendingIntent - .getActivity(context, 0, launchBookmarks, PendingIntent.FLAG_CANCEL_CURRENT)); appWidgetManager.updateAppWidget(appWidgetId, views); } } @@ -109,6 +99,6 @@ public class BookmarkListWidgetProvider extends AppWidgetProvider { * {@link AppWidgetProvider} */ static ComponentName getComponentName(Context context) { - return new ComponentName(context, BookmarkListWidgetProvider.class); + return new ComponentName(context, BookmarkThumbnailWidgetProvider.class); } } diff --git a/src/com/android/browser/widget/BookmarkListWidgetService.java b/src/com/android/browser/widget/BookmarkThumbnailWidgetService.java index 4d72d415..fcd21033 100644 --- a/src/com/android/browser/widget/BookmarkListWidgetService.java +++ b/src/com/android/browser/widget/BookmarkThumbnailWidgetService.java @@ -16,7 +16,6 @@ package com.android.browser.widget; -import com.android.browser.BookmarkUtils; import com.android.browser.BrowserBookmarksPage; import com.android.browser.R; @@ -49,9 +48,9 @@ import java.util.List; import java.util.Map; import java.util.Stack; -public class BookmarkListWidgetService extends RemoteViewsService { +public class BookmarkThumbnailWidgetService extends RemoteViewsService { - static final String TAG = "BookmarkListWidgetService"; + static final String TAG = "BookmarkThumbnailWidgetService"; static final boolean USE_FOLDERS = true; static final String ACTION_REMOVE_FACTORIES @@ -66,13 +65,15 @@ public class BookmarkListWidgetService extends RemoteViewsService { BrowserContract.Bookmarks.FAVICON, BrowserContract.Bookmarks.IS_FOLDER, BrowserContract.Bookmarks.TOUCH_ICON, - BrowserContract.Bookmarks.POSITION /* needed for order by */}; + BrowserContract.Bookmarks.POSITION, /* needed for order by */ + BrowserContract.Bookmarks.THUMBNAIL}; private static final int BOOKMARK_INDEX_ID = 0; private static final int BOOKMARK_INDEX_TITLE = 1; private static final int BOOKMARK_INDEX_URL = 2; private static final int BOOKMARK_INDEX_FAVICON = 3; private static final int BOOKMARK_INDEX_IS_FOLDER = 4; private static final int BOOKMARK_INDEX_TOUCH_ICON = 5; + private static final int BOOKMARK_INDEX_THUMBNAIL = 7; private Map<Integer, BookmarkFactory> mFactories; private Handler mUiHandler; @@ -223,12 +224,12 @@ public class BookmarkListWidgetService extends RemoteViewsService { Breadcrumb folder = mBreadcrumbs.empty() ? null : mBreadcrumbs.peek(); RemoteViews views = new RemoteViews( - mContext.getPackageName(), R.layout.bookmarklistwidget_item); + mContext.getPackageName(), R.layout.bookmarkthumbnailwidget_item); Intent fillin; if (res.mIsFolder) { long nfi = res.mId; fillin = new Intent(ACTION_CHANGE_FOLDER, null, - mContext, BookmarkListWidgetService.class) + mContext, BookmarkThumbnailWidgetService.class) .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mWidgetId) .putExtra(Bookmarks._ID, nfi); } else { @@ -244,21 +245,26 @@ public class BookmarkListWidgetService extends RemoteViewsService { displayTitle = res.mUrl; } views.setTextViewText(R.id.label, displayTitle); - views.setDrawableParameters(R.id.list_item, true, 0, -1, null, -1); if (res.mIsFolder) { if (folder != null && res.mId == folder.mId) { - views.setImageViewResource(R.id.thumb, R.drawable.btn_ic_back_bookmark_widget_holo_dark); - views.setDrawableParameters(R.id.list_item, true, 255, -1, null, -1); + views.setImageViewResource(R.id.thumb, R.drawable.thumb_bookmark_widget_folder_back_holo); } else { - views.setImageViewResource(R.id.thumb, R.drawable.ic_folder_bookmark_widget_holo_dark); + views.setImageViewResource(R.id.thumb, R.drawable.thumb_bookmark_widget_folder_holo); } + views.setImageViewResource(R.id.favicon, R.drawable.ic_bookmark_widget_bookmark_holo_dark); } else { - if (res.mBitmap != null) { - views.setImageViewBitmap(R.id.thumb, res.mBitmap); + if (res.mThumbnail != null) { + views.setImageViewBitmap(R.id.thumb, res.mThumbnail); } else { views.setImageViewResource(R.id.thumb, R.drawable.browser_thumbnail); } + if (res.mIcon != null) { + views.setImageViewBitmap(R.id.favicon, res.mIcon); + } else { + views.setImageViewResource(R.id.favicon, + R.drawable.app_web_browser_sm); + } } return views; } @@ -364,35 +370,19 @@ public class BookmarkListWidgetService extends RemoteViewsService { // RemoteViews require a valid bitmap config Options options = new Options(); options.inPreferredConfig = Config.ARGB_8888; - Bitmap favIcon = null; - Bitmap touchIcon = null; - byte[] blob = c.getBlob(BOOKMARK_INDEX_TOUCH_ICON); + Bitmap thumbnail = null, favicon = null; + byte[] blob = c.getBlob(BOOKMARK_INDEX_THUMBNAIL); if (blob != null && blob.length > 0) { - touchIcon = BitmapFactory.decodeByteArray( + thumbnail = BitmapFactory.decodeByteArray( blob, 0, blob.length, options); - } else { - blob = c.getBlob(BOOKMARK_INDEX_FAVICON); - if (blob != null && blob.length > 0) { - favIcon = BitmapFactory.decodeByteArray( - blob, 0, blob.length, options); - } - } - - if (favIcon == null) { - favIcon = BitmapFactory.decodeResource( - mContext.getResources(), - R.drawable.app_web_browser_sm); } - if (touchIcon != null || favIcon != null) { - res.mBitmap = BookmarkUtils.createListWidgetIcon( - mContext, touchIcon, favIcon); - } - if (touchIcon != null) { - touchIcon.recycle(); - } - if (favIcon != null) { - favIcon.recycle(); + blob = c.getBlob(BOOKMARK_INDEX_FAVICON); + if (blob != null && blob.length > 0) { + favicon = BitmapFactory.decodeByteArray( + blob, 0, blob.length, options); } + res.mThumbnail = thumbnail; + res.mIcon = favicon; } bookmarks.add(res); } @@ -412,9 +402,9 @@ public class BookmarkListWidgetService extends RemoteViewsService { // Do a bit of house cleaning for the system if (mBookmarks != null) { for (RenderResult res : mBookmarks) { - if (res.mBitmap != null) { - res.mBitmap.recycle(); - res.mBitmap = null; + if (res.mThumbnail != null) { + res.mThumbnail.recycle(); + res.mThumbnail = null; } } } @@ -440,7 +430,8 @@ public class BookmarkListWidgetService extends RemoteViewsService { private static class RenderResult { final String mTitle; final String mUrl; - Bitmap mBitmap; + Bitmap mThumbnail; + Bitmap mIcon; boolean mIsFolder; long mId; |