diff options
| author | Leon Scroggins <scroggo@google.com> | 2011-01-13 17:56:15 -0500 |
|---|---|---|
| committer | Leon Scroggins <scroggo@google.com> | 2011-01-13 18:30:03 -0500 |
| commit | 75630678154c89662b7f8e5fb19d0b77a2d7abb8 (patch) | |
| tree | 8371174e699e0e70931a482d74b2939c32b2f994 /src/com/android/browser/BookmarkUtils.java | |
| parent | 58fddd3154418fbdf7560db5662fcf6d248061e3 (diff) | |
| download | packages_apps_Browser-75630678154c89662b7f8e5fb19d0b77a2d7abb8.tar.gz packages_apps_Browser-75630678154c89662b7f8e5fb19d0b77a2d7abb8.tar.bz2 packages_apps_Browser-75630678154c89662b7f8e5fb19d0b77a2d7abb8.zip | |
Show a remove button for existing bookmarks.
Bug:3222677
Change-Id: Id11585bc68f239a02aa477898f6c00792ad44093
Diffstat (limited to 'src/com/android/browser/BookmarkUtils.java')
| -rw-r--r-- | src/com/android/browser/BookmarkUtils.java | 42 |
1 files changed, 42 insertions, 0 deletions
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(); + } } |
