mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 822979 - Bookmark popup notification improvements. r=margaret
This commit is contained in:
parent
760c09ab43
commit
b2acd2534d
@ -548,6 +548,8 @@ public class BrowserApp extends GeckoApp
|
||||
}
|
||||
|
||||
private void showBookmarkAddedToast() {
|
||||
// This flow is from the option menu which has check to see if a bookmark was already added.
|
||||
// So, it is safe here to show the toast that bookmark_added without any checks.
|
||||
getButtonToast().show(false,
|
||||
getResources().getString(R.string.bookmark_added),
|
||||
ButtonToast.LENGTH_SHORT,
|
||||
|
@ -559,11 +559,12 @@ public abstract class GeckoApp
|
||||
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
db.addBookmark(getContentResolver(), title, url);
|
||||
final boolean bookmarkAdded = db.addBookmark(getContentResolver(), title, url);
|
||||
final int resId = bookmarkAdded ? R.string.bookmark_added : R.string.bookmark_already_added;
|
||||
ThreadUtils.postToUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(context, R.string.bookmark_added, Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(context, resId, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ public interface BrowserDB {
|
||||
public abstract String getUrlForKeyword(ContentResolver cr, String keyword);
|
||||
|
||||
public abstract boolean isBookmark(ContentResolver cr, String uri);
|
||||
public abstract void addBookmark(ContentResolver cr, String title, String uri);
|
||||
public abstract boolean addBookmark(ContentResolver cr, String title, String uri);
|
||||
public abstract Cursor getBookmarkForUrl(ContentResolver cr, String url);
|
||||
public abstract void removeBookmarksWithURL(ContentResolver cr, String uri);
|
||||
public abstract void registerBookmarkObserver(ContentResolver cr, ContentObserver observer);
|
||||
|
@ -939,9 +939,34 @@ public class LocalBrowserDB implements BrowserDB {
|
||||
|
||||
@Override
|
||||
@RobocopTarget
|
||||
public void addBookmark(ContentResolver cr, String title, String uri) {
|
||||
public boolean addBookmark(ContentResolver cr, String title, String uri) {
|
||||
long folderId = getFolderIdFromGuid(cr, Bookmarks.MOBILE_FOLDER_GUID);
|
||||
if (isBookmarkForUrlInFolder(cr, uri, folderId)) {
|
||||
// Bookmark added already.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add a new bookmark.
|
||||
addBookmarkItem(cr, title, uri, folderId);
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isBookmarkForUrlInFolder(ContentResolver cr, String uri, long folderId) {
|
||||
final Cursor c = cr.query(bookmarksUriWithLimit(1),
|
||||
new String[] { Bookmarks._ID },
|
||||
Bookmarks.URL + " = ? AND " + Bookmarks.PARENT + " = ? AND " + Bookmarks.IS_DELETED + " == 0",
|
||||
new String[] { uri, String.valueOf(folderId) },
|
||||
Bookmarks.URL);
|
||||
|
||||
if (c == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
return c.getCount() > 0;
|
||||
} finally {
|
||||
c.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -250,7 +250,8 @@ public class StubBrowserDB implements BrowserDB {
|
||||
}
|
||||
|
||||
@RobocopTarget
|
||||
public void addBookmark(ContentResolver cr, String title, String uri) {
|
||||
public boolean addBookmark(ContentResolver cr, String title, String uri) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@RobocopTarget
|
||||
|
@ -44,6 +44,10 @@
|
||||
<!ENTITY bookmark "Bookmark">
|
||||
<!ENTITY bookmark_remove "Remove bookmark">
|
||||
<!ENTITY bookmark_added "Bookmark added">
|
||||
<!-- Localization note (bookmark_already_added) : This string is
|
||||
used as a label in a toast. It is the verb "to bookmark", not
|
||||
the noun "a bookmark". -->
|
||||
<!ENTITY bookmark_already_added "Already bookmarked">
|
||||
<!ENTITY bookmark_removed "Bookmark removed">
|
||||
<!ENTITY bookmark_updated "Bookmark updated">
|
||||
<!ENTITY bookmark_options "Options">
|
||||
|
@ -80,6 +80,7 @@
|
||||
<string name="bookmark">&bookmark;</string>
|
||||
<string name="bookmark_remove">&bookmark_remove;</string>
|
||||
<string name="bookmark_added">&bookmark_added;</string>
|
||||
<string name="bookmark_already_added">&bookmark_already_added;</string>
|
||||
<string name="bookmark_removed">&bookmark_removed;</string>
|
||||
<string name="bookmark_updated">&bookmark_updated;</string>
|
||||
<string name="bookmark_options">&bookmark_options;</string>
|
||||
|
@ -50,14 +50,12 @@ class DatabaseHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a bookmark, or updates the bookmark title if the url already exists.
|
||||
*
|
||||
* The LocalBrowserDB.addBookmark implementation handles updating existing bookmarks.
|
||||
* Adds a bookmark.
|
||||
*/
|
||||
protected void addOrUpdateMobileBookmark(String title, String url) {
|
||||
protected void addMobileBookmark(String title, String url) {
|
||||
final ContentResolver resolver = mActivity.getContentResolver();
|
||||
getProfileDB().addBookmark(resolver, title, url);
|
||||
mAsserter.ok(true, "Inserting/updating a new bookmark", "Inserting/updating the bookmark with the title = " + title + " and the url = " + url);
|
||||
mAsserter.ok(true, "Inserting a new bookmark", "Inserting the bookmark with the title = " + title + " and the url = " + url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,7 +31,7 @@ public class testBookmark extends AboutHomeTest {
|
||||
mAsserter.ok(mDatabaseHelper.isBookmark(url), "Checking that " + url + " is bookmarked by default", url + " is bookmarked");
|
||||
}
|
||||
|
||||
mDatabaseHelper.addOrUpdateMobileBookmark(mStringHelper.ROBOCOP_BLANK_PAGE_01_TITLE, BOOKMARK_URL);
|
||||
mDatabaseHelper.addMobileBookmark(mStringHelper.ROBOCOP_BLANK_PAGE_01_TITLE, BOOKMARK_URL);
|
||||
waitForBookmarked(true);
|
||||
|
||||
isBookmarkDisplayed(BOOKMARK_URL);
|
||||
|
@ -13,7 +13,7 @@ public class testBookmarkKeyword extends AboutHomeTest {
|
||||
final String keyword = "testkeyword";
|
||||
|
||||
// Add a bookmark, and update it to have a keyword.
|
||||
mDatabaseHelper.addOrUpdateMobileBookmark(mStringHelper.ROBOCOP_BLANK_PAGE_01_TITLE, url);
|
||||
mDatabaseHelper.addMobileBookmark(mStringHelper.ROBOCOP_BLANK_PAGE_01_TITLE, url);
|
||||
mDatabaseHelper.updateBookmark(url, mStringHelper.ROBOCOP_BLANK_PAGE_01_TITLE, keyword);
|
||||
|
||||
// Enter the keyword in the urlbar.
|
||||
|
@ -40,7 +40,7 @@ public class testBookmarklets extends AboutHomeTest {
|
||||
|
||||
// add the bookmarklet to the database. there's currently no way to
|
||||
// add this using the UI, so we go through the content provider.
|
||||
mDatabaseHelper.addOrUpdateMobileBookmark(title, js);
|
||||
mDatabaseHelper.addMobileBookmark(title, js);
|
||||
|
||||
// Open about:home in the Bookmarks page
|
||||
openAboutHomeTab(AboutHomeTabs.BOOKMARKS);
|
||||
|
@ -21,7 +21,7 @@ public class testBookmarksPanel extends AboutHomeTest {
|
||||
initializeProfile();
|
||||
|
||||
// Add a mobile bookmark.
|
||||
mDatabaseHelper.addOrUpdateMobileBookmark(mStringHelper.ROBOCOP_BLANK_PAGE_01_TITLE, BOOKMARK_URL);
|
||||
mDatabaseHelper.addMobileBookmark(mStringHelper.ROBOCOP_BLANK_PAGE_01_TITLE, BOOKMARK_URL);
|
||||
|
||||
openAboutHomeTab(AboutHomeTabs.BOOKMARKS);
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class testClearPrivateData extends PixelTest {
|
||||
|
||||
loadUrlAndWait(blank1);
|
||||
verifyUrlBarTitle(blank1);
|
||||
mDatabaseHelper.addOrUpdateMobileBookmark(mStringHelper.ROBOCOP_BLANK_PAGE_02_TITLE, blank2);
|
||||
mDatabaseHelper.addMobileBookmark(mStringHelper.ROBOCOP_BLANK_PAGE_02_TITLE, blank2);
|
||||
|
||||
// Checking that the history list is not empty
|
||||
verifyHistoryCount(1);
|
||||
|
@ -113,7 +113,7 @@ public class testImportFromAndroid extends AboutHomeTest {
|
||||
for (String url:androidBookmarks) {
|
||||
// Add every 3rd bookmark to Firefox Mobile
|
||||
if ((androidBookmarks.indexOf(url) % 3) == 0) {
|
||||
mDatabaseHelper.addOrUpdateMobileBookmark("Bookmark Number" + String.valueOf(androidBookmarks.indexOf(url)), url);
|
||||
mDatabaseHelper.addMobileBookmark("Bookmark Number" + String.valueOf(androidBookmarks.indexOf(url)), url);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user