summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Kolb <kolby@google.com>2010-09-19 14:40:21 -0700
committerMichael Kolb <kolby@google.com>2010-09-21 14:19:27 -0700
commit3a5be0cff4dc8ae8e46807ce40f35abd533e39a9 (patch)
tree082fb5508b125ca7063d55620d4f898e15e33a7c /src
parentfd638951d6aa4a4cee6872bd65cb5b2355cd2968 (diff)
downloadpackages_apps_Browser-3a5be0cff4dc8ae8e46807ce40f35abd533e39a9.zip
packages_apps_Browser-3a5be0cff4dc8ae8e46807ce40f35abd533e39a9.tar.gz
packages_apps_Browser-3a5be0cff4dc8ae8e46807ce40f35abd533e39a9.tar.bz2
change widget to use new PendingIntent API
set template on StackView setFillInIntent for individual items Change-Id: Ibbf457cf5ab1131bcfe1b38d77373f4e7c19cb6b
Diffstat (limited to 'src')
-rw-r--r--src/com/android/browser/widget/BookmarkStackWidgetService.java26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/com/android/browser/widget/BookmarkStackWidgetService.java b/src/com/android/browser/widget/BookmarkStackWidgetService.java
index f58cec1..83b07df 100644
--- a/src/com/android/browser/widget/BookmarkStackWidgetService.java
+++ b/src/com/android/browser/widget/BookmarkStackWidgetService.java
@@ -42,15 +42,12 @@ public class BookmarkStackWidgetService extends RemoteViewsService {
private static final String LOGTAG = "browserwidget";
- /** Force the bookmarks to be re-renderer. */
+ /** Force the bookmarks to be re-rendered. */
public static final String UPDATE = "com.android.browser.widget.UPDATE";
/** the adapter intent action */
public static final String ADAPTER = "com.android.browser.widget.ADAPTER";
- private static final String EXTRA_ID = "_id";
- private static final String EXTRA_URL = "_url";
-
private static final String[] PROJECTION = new String[] {
BrowserContract.Bookmarks._ID,
BrowserContract.Bookmarks.TITLE,
@@ -91,6 +88,11 @@ public class BookmarkStackWidgetService extends RemoteViewsService {
private void updateWidget() {
RemoteViews views = new RemoteViews(getPackageName(),
R.layout.bookmarkstackwidget);
+ Intent vi = new Intent(Intent.ACTION_VIEW);
+ vi.addCategory(Intent.CATEGORY_BROWSABLE);
+ views.setPendingIntentTemplate(R.id.stackwidget_stack,
+ PendingIntent.getActivity(BookmarkStackWidgetService.this, 0, vi,
+ PendingIntent.FLAG_CANCEL_CURRENT));
Intent adapter = new Intent(BookmarkStackWidgetService.ADAPTER, null,
this, BookmarkStackWidgetService.class);
views.setRemoteAdapter(R.id.stackwidget_stack, adapter);
@@ -106,6 +108,8 @@ public class BookmarkStackWidgetService extends RemoteViewsService {
RemoteViewsService.RemoteViewsFactory mViewFactory = new RemoteViewsFactory () {
+ Intent mFillIntent;
+
@Override
public int getCount() {
return mBookmarks.size();
@@ -126,9 +130,8 @@ public class BookmarkStackWidgetService extends RemoteViewsService {
RenderResult res = mBookmarks.get(position);
RemoteViews views = new RemoteViews(getPackageName(),
R.layout.bookmarkstackwidget_item);
- views.setOnClickPendingIntent(R.id.stack_item,
- getOpenUrlPendingIntent(res.mUrl));
-
+ mFillIntent.setData(Uri.parse(res.mUrl));
+ views.setOnClickFillInIntent(R.id.stack_item, mFillIntent);
// Set the title of the bookmark. Use the url as a backup.
String displayTitle = res.mTitle;
if (TextUtils.isEmpty(displayTitle)) {
@@ -154,6 +157,7 @@ public class BookmarkStackWidgetService extends RemoteViewsService {
@Override
public void onCreate() {
+ mFillIntent = new Intent();
update();
}
@@ -195,13 +199,6 @@ public class BookmarkStackWidgetService extends RemoteViewsService {
}
};
- private PendingIntent getOpenUrlPendingIntent(String url) {
- Intent vi = new Intent(Intent.ACTION_VIEW);
- vi.setData(Uri.parse(url));
- return PendingIntent.getActivity(this, 0, vi, PendingIntent.FLAG_CANCEL_CURRENT);
- }
-
-
// Class containing the rendering information for a specific bookmark.
private static class RenderResult {
final int mId;
@@ -217,5 +214,4 @@ public class BookmarkStackWidgetService extends RemoteViewsService {
}
-
}