Implement empty design for bookmark widget
Bug: 3355018
Change-Id: Ie64ed52c64445771037c980be181978de4caf250
diff --git a/res/drawable-mdpi/thumbnail_bookmarks_widget_no_bookmark_holo.png b/res/drawable-mdpi/thumbnail_bookmarks_widget_no_bookmark_holo.png
new file mode 100644
index 0000000..6ac18e7
--- /dev/null
+++ b/res/drawable-mdpi/thumbnail_bookmarks_widget_no_bookmark_holo.png
Binary files differ
diff --git a/src/com/android/browser/widget/BookmarkThumbnailWidgetService.java b/src/com/android/browser/widget/BookmarkThumbnailWidgetService.java
index 1c7856f..631bf84 100644
--- a/src/com/android/browser/widget/BookmarkThumbnailWidgetService.java
+++ b/src/com/android/browser/widget/BookmarkThumbnailWidgetService.java
@@ -16,6 +16,7 @@
package com.android.browser.widget;
+import com.android.browser.BrowserActivity;
import com.android.browser.BrowserBookmarksPage;
import com.android.browser.R;
@@ -95,9 +96,15 @@
public int onStartCommand(Intent intent, int flags, int startId) {
String action = intent.getAction();
if (Intent.ACTION_VIEW.equals(action)) {
- Intent view = new Intent(intent);
- view.setComponent(null);
- startActivity(view);
+ if (intent.getData() == null) {
+ startActivity(new Intent(BrowserActivity.ACTION_SHOW_BROWSER, null,
+ this, BrowserActivity.class)
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
+ } else {
+ Intent view = new Intent(intent);
+ view.setComponent(null);
+ startActivity(view);
+ }
} else if (ACTION_REMOVE_FACTORIES.equals(action)) {
int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
if (ids != null) {
@@ -242,8 +249,10 @@
.putExtra(Bookmarks._ID, nfi);
} else {
fillin = new Intent(Intent.ACTION_VIEW)
- .setData(Uri.parse(res.mUrl))
.addCategory(Intent.CATEGORY_BROWSABLE);
+ if (!TextUtils.isEmpty(res.mUrl)) {
+ fillin.setData(Uri.parse(res.mUrl));
+ }
}
views.setOnClickFillInIntent(R.id.list_item, fillin);
// Set the title of the bookmark. Use the url as a backup.
@@ -396,6 +405,18 @@
}
bookmarks.add(res);
}
+ if (bookmarks.size() == 0) {
+ RenderResult res = new RenderResult(0, "", "");
+ Bitmap thumbnail = BitmapFactory.decodeResource(
+ mContext.getResources(),
+ R.drawable.thumbnail_bookmarks_widget_no_bookmark_holo);
+ Bitmap favicon = Bitmap.createBitmap(1, 1, Config.ALPHA_8);
+ res.mThumbnail = thumbnail;
+ res.mIcon = favicon;
+ for (int i = 0; i < 6; i++) {
+ bookmarks.add(res);
+ }
+ }
return bookmarks;
}
} catch (IllegalStateException e) {