mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1050034 - Eliminate BrowserDB.URLColumns. r=lucasr
This commit is contained in:
parent
2f57a332f5
commit
39deb4f373
@ -10,7 +10,7 @@ import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.mozilla.gecko.db.BrowserContract.ExpirePriority;
|
||||
import org.mozilla.gecko.db.SuggestedSites;
|
||||
import org.mozilla.gecko.db.BrowserContract.History;
|
||||
import org.mozilla.gecko.distribution.Distribution;
|
||||
import org.mozilla.gecko.favicons.decoders.LoadFaviconResult;
|
||||
import org.mozilla.gecko.mozglue.RobocopTarget;
|
||||
@ -21,8 +21,8 @@ import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.ContentObserver;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
|
||||
/**
|
||||
* A utility wrapper for accessing a static {@link LocalBrowserDB},
|
||||
@ -32,20 +32,9 @@ import android.graphics.Color;
|
||||
* Be careful using this class: if you're not BrowserApp, you probably
|
||||
* want to manually instantiate and use LocalBrowserDB itself.
|
||||
*
|
||||
* Also manages some mapping column names and flags.
|
||||
* The column name mapping will be removed in Bug 1050034.
|
||||
* Also manages some flags.
|
||||
*/
|
||||
public class BrowserDB {
|
||||
public static interface URLColumns {
|
||||
public static String URL = "url";
|
||||
public static String TITLE = "title";
|
||||
public static String FAVICON = "favicon";
|
||||
public static String THUMBNAIL = "thumbnail";
|
||||
public static String DATE_LAST_VISITED = "date-last-visited";
|
||||
public static String VISITS = "visits";
|
||||
public static String KEYWORD = "keyword";
|
||||
}
|
||||
|
||||
public static enum FilterFlags {
|
||||
EXCLUDE_PINNED_SITES
|
||||
}
|
||||
@ -87,7 +76,7 @@ public class BrowserDB {
|
||||
private static void appendUrlsFromCursor(List<String> urls, Cursor c) {
|
||||
c.moveToPosition(-1);
|
||||
while (c.moveToNext()) {
|
||||
String url = c.getString(c.getColumnIndex(URLColumns.URL));
|
||||
String url = c.getString(c.getColumnIndex(History.URL));
|
||||
|
||||
// Do a simpler check before decoding to avoid parsing
|
||||
// all URLs unnecessarily.
|
||||
|
@ -26,13 +26,11 @@ import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.db.BrowserContract.Bookmarks;
|
||||
import org.mozilla.gecko.db.BrowserContract.Combined;
|
||||
import org.mozilla.gecko.db.BrowserContract.ExpirePriority;
|
||||
import org.mozilla.gecko.db.BrowserContract.FaviconColumns;
|
||||
import org.mozilla.gecko.db.BrowserContract.Favicons;
|
||||
import org.mozilla.gecko.db.BrowserContract.History;
|
||||
import org.mozilla.gecko.db.BrowserContract.ReadingListItems;
|
||||
import org.mozilla.gecko.db.BrowserContract.SyncColumns;
|
||||
import org.mozilla.gecko.db.BrowserContract.Thumbnails;
|
||||
import org.mozilla.gecko.db.BrowserContract.URLColumns;
|
||||
import org.mozilla.gecko.db.BrowserDB.FilterFlags;
|
||||
import org.mozilla.gecko.distribution.Distribution;
|
||||
import org.mozilla.gecko.favicons.decoders.FaviconDecoder;
|
||||
@ -524,13 +522,11 @@ public class LocalBrowserDB {
|
||||
// We also give bookmarks an extra bonus boost by adding 100 points to their frecency score.
|
||||
final String sortOrder = BrowserContract.getFrecencySortOrder(true, false);
|
||||
|
||||
Cursor c = cr.query(combinedUriWithLimit(limit),
|
||||
projection,
|
||||
selection,
|
||||
selectionArgs,
|
||||
sortOrder);
|
||||
|
||||
return new LocalDBCursor(c);
|
||||
return cr.query(combinedUriWithLimit(limit),
|
||||
projection,
|
||||
selection,
|
||||
selectionArgs,
|
||||
sortOrder);
|
||||
}
|
||||
|
||||
public int getCount(ContentResolver cr, String database) {
|
||||
@ -677,29 +673,25 @@ public class LocalBrowserDB {
|
||||
|
||||
@RobocopTarget
|
||||
public Cursor getAllVisitedHistory(ContentResolver cr) {
|
||||
Cursor c = cr.query(mHistoryUriWithProfile,
|
||||
new String[] { History.URL },
|
||||
History.VISITS + " > 0",
|
||||
null,
|
||||
null);
|
||||
|
||||
return new LocalDBCursor(c);
|
||||
return cr.query(mHistoryUriWithProfile,
|
||||
new String[] { History.URL },
|
||||
History.VISITS + " > 0",
|
||||
null,
|
||||
null);
|
||||
}
|
||||
|
||||
public Cursor getRecentHistory(ContentResolver cr, int limit) {
|
||||
Cursor c = cr.query(combinedUriWithLimit(limit),
|
||||
new String[] { Combined._ID,
|
||||
Combined.BOOKMARK_ID,
|
||||
Combined.HISTORY_ID,
|
||||
Combined.URL,
|
||||
Combined.TITLE,
|
||||
Combined.DATE_LAST_VISITED,
|
||||
Combined.VISITS },
|
||||
History.DATE_LAST_VISITED + " > 0",
|
||||
null,
|
||||
History.DATE_LAST_VISITED + " DESC");
|
||||
|
||||
return new LocalDBCursor(c);
|
||||
return cr.query(combinedUriWithLimit(limit),
|
||||
new String[] { Combined._ID,
|
||||
Combined.BOOKMARK_ID,
|
||||
Combined.HISTORY_ID,
|
||||
Combined.URL,
|
||||
Combined.TITLE,
|
||||
Combined.DATE_LAST_VISITED,
|
||||
Combined.VISITS },
|
||||
History.DATE_LAST_VISITED + " > 0",
|
||||
null,
|
||||
History.DATE_LAST_VISITED + " DESC");
|
||||
}
|
||||
|
||||
public void expireHistory(ContentResolver cr, ExpirePriority priority) {
|
||||
@ -727,8 +719,7 @@ public class LocalBrowserDB {
|
||||
|
||||
@RobocopTarget
|
||||
public Cursor getBookmarksInFolder(ContentResolver cr, long folderId) {
|
||||
Cursor c = null;
|
||||
boolean addDesktopFolder = false;
|
||||
final boolean addDesktopFolder;
|
||||
|
||||
// We always want to show mobile bookmarks in the root view.
|
||||
if (folderId == Bookmarks.FIXED_ROOT_ID) {
|
||||
@ -737,8 +728,11 @@ public class LocalBrowserDB {
|
||||
// We'll add a fake "Desktop Bookmarks" folder to the root view if desktop
|
||||
// bookmarks exist, so that the user can still access non-mobile bookmarks.
|
||||
addDesktopFolder = desktopBookmarksExist(cr);
|
||||
} else {
|
||||
addDesktopFolder = false;
|
||||
}
|
||||
|
||||
final Cursor c;
|
||||
if (folderId == Bookmarks.FAKE_DESKTOP_FOLDER_ID) {
|
||||
// Since the "Desktop Bookmarks" folder doesn't actually exist, we
|
||||
// just fake it by querying specifically certain known desktop folders.
|
||||
@ -767,10 +761,10 @@ public class LocalBrowserDB {
|
||||
|
||||
if (addDesktopFolder) {
|
||||
// Wrap cursor to add fake desktop bookmarks and reading list folders
|
||||
c = new SpecialFoldersCursorWrapper(c, addDesktopFolder);
|
||||
return new SpecialFoldersCursorWrapper(c, addDesktopFolder);
|
||||
}
|
||||
|
||||
return new LocalDBCursor(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
public Cursor getReadingList(ContentResolver cr) {
|
||||
@ -1482,37 +1476,6 @@ public class LocalBrowserDB {
|
||||
}
|
||||
}
|
||||
|
||||
private static class LocalDBCursor extends CursorWrapper {
|
||||
public LocalDBCursor(Cursor c) {
|
||||
super(c);
|
||||
}
|
||||
|
||||
private String translateColumnName(String columnName) {
|
||||
if (columnName.equals(BrowserDB.URLColumns.URL)) {
|
||||
columnName = URLColumns.URL;
|
||||
} else if (columnName.equals(BrowserDB.URLColumns.TITLE)) {
|
||||
columnName = URLColumns.TITLE;
|
||||
} else if (columnName.equals(BrowserDB.URLColumns.FAVICON)) {
|
||||
columnName = FaviconColumns.FAVICON;
|
||||
} else if (columnName.equals(BrowserDB.URLColumns.DATE_LAST_VISITED)) {
|
||||
columnName = History.DATE_LAST_VISITED;
|
||||
} else if (columnName.equals(BrowserDB.URLColumns.VISITS)) {
|
||||
columnName = History.VISITS;
|
||||
}
|
||||
|
||||
return columnName;
|
||||
}
|
||||
|
||||
public int getColumnIndex(String columnName) {
|
||||
return super.getColumnIndex(translateColumnName(columnName));
|
||||
}
|
||||
|
||||
public int getColumnIndexOrThrow(String columnName) {
|
||||
return super.getColumnIndexOrThrow(translateColumnName(columnName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void pinSite(ContentResolver cr, String url, String title, int position) {
|
||||
ContentValues values = new ContentValues();
|
||||
final long now = System.currentTimeMillis();
|
||||
|
@ -1,5 +1,11 @@
|
||||
package org.mozilla.gecko.db;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.mozilla.gecko.db.BrowserContract.Bookmarks;
|
||||
import org.mozilla.gecko.db.BrowserContract.TopSites;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.database.CharArrayBuffer;
|
||||
import android.database.ContentObserver;
|
||||
@ -10,15 +16,6 @@ import android.os.Bundle;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.mozilla.gecko.db.BrowserContract.Bookmarks;
|
||||
import org.mozilla.gecko.db.BrowserContract.TopSites;
|
||||
import org.mozilla.gecko.db.BrowserDB.URLColumns;
|
||||
|
||||
/**
|
||||
* {@TopSitesCursorWrapper} is a cursor wrapper that merges
|
||||
* the top and pinned sites cursors into one. It ensures the
|
||||
|
@ -11,7 +11,6 @@ import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.Telemetry;
|
||||
import org.mozilla.gecko.TelemetryContract;
|
||||
import org.mozilla.gecko.db.BrowserContract.Bookmarks;
|
||||
import org.mozilla.gecko.db.BrowserDB.URLColumns;
|
||||
import org.mozilla.gecko.home.HomePager.OnUrlOpenListener;
|
||||
|
||||
import android.content.Context;
|
||||
@ -91,7 +90,7 @@ public class BookmarksListView extends HomeListView
|
||||
adapter.moveToChildFolder(folderId, folderTitle);
|
||||
} else {
|
||||
// Otherwise, just open the URL
|
||||
final String url = cursor.getString(cursor.getColumnIndexOrThrow(URLColumns.URL));
|
||||
final String url = cursor.getString(cursor.getColumnIndexOrThrow(Bookmarks.URL));
|
||||
|
||||
Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.LIST_ITEM);
|
||||
|
||||
|
@ -5,6 +5,15 @@
|
||||
|
||||
package org.mozilla.gecko.home;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.mozilla.gecko.EventDispatcher;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
import org.mozilla.gecko.GeckoEvent;
|
||||
@ -14,9 +23,9 @@ import org.mozilla.gecko.Tab;
|
||||
import org.mozilla.gecko.Tabs;
|
||||
import org.mozilla.gecko.Telemetry;
|
||||
import org.mozilla.gecko.TelemetryContract;
|
||||
import org.mozilla.gecko.db.BrowserDB.URLColumns;
|
||||
import org.mozilla.gecko.db.BrowserContract.History;
|
||||
import org.mozilla.gecko.db.BrowserContract.URLColumns;
|
||||
import org.mozilla.gecko.home.HomePager.OnUrlOpenListener;
|
||||
import org.mozilla.gecko.home.SearchEngine;
|
||||
import org.mozilla.gecko.home.SearchLoader.SearchCursorLoader;
|
||||
import org.mozilla.gecko.mozglue.RobocopTarget;
|
||||
import org.mozilla.gecko.toolbar.AutocompleteHandler;
|
||||
@ -24,10 +33,6 @@ import org.mozilla.gecko.util.GeckoEventListener;
|
||||
import org.mozilla.gecko.util.StringUtils;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
@ -55,12 +60,6 @@ import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Fragment that displays frecency search results in a ListView.
|
||||
*/
|
||||
@ -444,7 +443,7 @@ public class BrowserSearch extends HomeFragment
|
||||
}
|
||||
|
||||
final int searchLength = searchTerm.length();
|
||||
final int urlIndex = c.getColumnIndexOrThrow(URLColumns.URL);
|
||||
final int urlIndex = c.getColumnIndexOrThrow(History.URL);
|
||||
int searchCount = 0;
|
||||
|
||||
do {
|
||||
|
@ -12,8 +12,8 @@ import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.Telemetry;
|
||||
import org.mozilla.gecko.TelemetryContract;
|
||||
import org.mozilla.gecko.db.BrowserContract.Combined;
|
||||
import org.mozilla.gecko.db.BrowserContract.History;
|
||||
import org.mozilla.gecko.db.BrowserDB;
|
||||
import org.mozilla.gecko.db.BrowserDB.URLColumns;
|
||||
import org.mozilla.gecko.home.HomePager.OnUrlOpenListener;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
|
||||
@ -96,7 +96,7 @@ public class HistoryPanel extends HomeFragment {
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
position -= mAdapter.getMostRecentSectionsCountBefore(position);
|
||||
final Cursor c = mAdapter.getCursor(position);
|
||||
final String url = c.getString(c.getColumnIndexOrThrow(URLColumns.URL));
|
||||
final String url = c.getString(c.getColumnIndexOrThrow(History.URL));
|
||||
|
||||
Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.LIST_ITEM);
|
||||
|
||||
@ -385,7 +385,7 @@ public class HistoryPanel extends HomeFragment {
|
||||
|
||||
do {
|
||||
final int position = c.getPosition();
|
||||
final long time = c.getLong(c.getColumnIndexOrThrow(URLColumns.DATE_LAST_VISITED));
|
||||
final long time = c.getLong(c.getColumnIndexOrThrow(History.DATE_LAST_VISITED));
|
||||
final MostRecentSection itemSection = HistoryAdapter.getMostRecentSectionForTime(today, time);
|
||||
|
||||
if (section != itemSection) {
|
||||
|
@ -8,8 +8,9 @@ package org.mozilla.gecko.home;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.db.BrowserContract.History;
|
||||
import org.mozilla.gecko.db.BrowserContract.URLColumns;
|
||||
import org.mozilla.gecko.db.BrowserDB.FilterFlags;
|
||||
import org.mozilla.gecko.db.BrowserDB.URLColumns;
|
||||
import org.mozilla.gecko.util.StringUtils;
|
||||
|
||||
import android.content.Context;
|
||||
|
@ -12,8 +12,8 @@ import org.mozilla.gecko.ReaderModeUtils;
|
||||
import org.mozilla.gecko.Telemetry;
|
||||
import org.mozilla.gecko.TelemetryContract;
|
||||
import org.mozilla.gecko.db.BrowserContract.ReadingListItems;
|
||||
import org.mozilla.gecko.db.BrowserContract.URLColumns;
|
||||
import org.mozilla.gecko.db.BrowserDB;
|
||||
import org.mozilla.gecko.db.BrowserDB.URLColumns;
|
||||
import org.mozilla.gecko.home.HomePager.OnUrlOpenListener;
|
||||
|
||||
import android.app.Activity;
|
||||
|
@ -11,10 +11,9 @@ import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.Tab;
|
||||
import org.mozilla.gecko.Tabs;
|
||||
import org.mozilla.gecko.db.BrowserContract.Combined;
|
||||
import org.mozilla.gecko.db.BrowserDB.URLColumns;
|
||||
import org.mozilla.gecko.db.BrowserContract.URLColumns;
|
||||
import org.mozilla.gecko.favicons.Favicons;
|
||||
import org.mozilla.gecko.favicons.OnFaviconLoadedListener;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
import org.mozilla.gecko.widget.FaviconView;
|
||||
|
||||
import android.content.Context;
|
||||
|
Loading…
Reference in New Issue
Block a user