From 75630678154c89662b7f8e5fb19d0b77a2d7abb8 Mon Sep 17 00:00:00 2001 From: Leon Scroggins Date: Thu, 13 Jan 2011 17:56:15 -0500 Subject: Show a remove button for existing bookmarks. Bug:3222677 Change-Id: Id11585bc68f239a02aa477898f6c00792ad44093 --- src/com/android/browser/BookmarkUtils.java | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/com/android/browser/BookmarkUtils.java') diff --git a/src/com/android/browser/BookmarkUtils.java b/src/com/android/browser/BookmarkUtils.java index b548607ff..27d3310dc 100644 --- a/src/com/android/browser/BookmarkUtils.java +++ b/src/com/android/browser/BookmarkUtils.java @@ -16,7 +16,10 @@ package com.android.browser; +import android.app.AlertDialog; +import android.content.ContentUris; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Bitmap; @@ -30,6 +33,7 @@ import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.graphics.RectF; import android.net.Uri; +import android.os.Message; import android.preference.PreferenceManager; import android.provider.Browser; import android.provider.BrowserContract; @@ -212,4 +216,42 @@ public class BookmarkUtils { BrowserContract.Bookmarks.PARAM_ACCOUNT_TYPE, accountType); return ub; } + + /** + * Show a confirmation dialog to remove a bookmark. + * @param id Id of the bookmark to remove + * @param title Title of the bookmark, to be displayed in the confirmation method. + * @param context Package Context for strings, dialog, ContentResolver + * @param msg Message to send if the bookmark is deleted. + */ + static void displayRemoveBookmarkDialog( final long id, final String title, + final Context context, final Message msg) { + + new AlertDialog.Builder(context) + .setTitle(R.string.delete_bookmark) + .setIcon(android.R.drawable.ic_dialog_alert) + .setMessage(context.getString(R.string.delete_bookmark_warning, + title)) + .setPositiveButton(R.string.ok, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int whichButton) { + if (msg != null) { + msg.sendToTarget(); + } + Runnable runnable = new Runnable(){ + @Override + public void run() { + Uri uri = ContentUris.withAppendedId( + BrowserContract.Bookmarks.CONTENT_URI, + id); + context.getContentResolver().delete(uri, null, null); + } + }; + new Thread(runnable).start(); + } + }) + .setNegativeButton(R.string.cancel, null) + .show(); + } } -- cgit v1.2.3