Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 421307c1 authored by Stephen Bird's avatar Stephen Bird
Browse files

Bookmarks: check to see if a bookmark exists before adding it

Previously, this would result in multiple bookmarks
of the same location

Ticket: QRDL-989
Change-Id: I0f19045bc7a6d5fa98c9ef4ee1a8ccda9c501eb1
(cherry picked from commit 85032a69)
parent 18ab0647
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -378,6 +378,8 @@
    <string name="bookmarks_button_remove_bookmark_cd">Remove the bookmark.</string>
    <!-- Bookmarks - Bookmarks - Actions - Bookmark successfully added -->
    <string name="bookmarks_msgs_add_success">The bookmark was added successfully.</string>
    <!-- Bookmarks - Bookmarks - Actions - Bookmark already exists -->
    <string name="bookmarks_msgs_add_exists">The bookmark was already exists.</string>

    <!-- Initial directory dialog title -->
    <string name="initial_directory_dialog_title">Initial folder</string>
+1 −1
Original line number Diff line number Diff line
@@ -400,7 +400,7 @@ public class ActionsDialog implements OnItemClickListener, OnItemLongClickListen
            case R.id.mnu_actions_add_to_bookmarks_current_folder:
                Bookmark bookmark = BookmarksActionPolicy.addToBookmarks(
                        this.mContext, this.mFso);
                if (mBackRef != null) {
                if (mBackRef != null && bookmark != null) {
                    // tell NavigationActivity's drawer to add the bookmark
                    mBackRef.addBookmark(bookmark);
                }
+9 −0
Original line number Diff line number Diff line
@@ -40,6 +40,15 @@ public final class BookmarksActionPolicy extends ActionsPolicy {
     */
    public static Bookmark addToBookmarks(final Context ctx, final FileSystemObject fso) {
        try {
            // Check if the bookmark exists already
            if (Bookmarks.getBookmark(ctx.getContentResolver(), fso.getFullPath()) != null) {
                DialogHelper.showToast(
                        ctx,
                        R.string.bookmarks_msgs_add_exists,
                        Toast.LENGTH_SHORT);
                return null;
            }

            // Create the bookmark
            Bookmark bookmark =
                    new Bookmark(BOOKMARK_TYPE.USER_DEFINED, fso.getName(), fso.getFullPath());