mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-28 13:21:28 +00:00
Bug 1293710 - Display highlights in activity stream panel. r=ahunt
MozReview-Commit-ID: CnE0Ivq6OXz --HG-- extra : rebase_source : 5e3431f8a536fba08a4a40c679f83bd07ef97ceb
This commit is contained in:
parent
43d2a41065
commit
509e8627f2
@ -592,6 +592,8 @@ public class BrowserContract {
|
||||
|
||||
public static final class Highlights {
|
||||
public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "highlights");
|
||||
|
||||
public static final String DATE = "date";
|
||||
}
|
||||
|
||||
@RobocopTarget
|
||||
|
@ -19,6 +19,7 @@ import org.mozilla.gecko.db.BrowserContract.Bookmarks;
|
||||
import org.mozilla.gecko.db.BrowserContract.Combined;
|
||||
import org.mozilla.gecko.db.BrowserContract.FaviconColumns;
|
||||
import org.mozilla.gecko.db.BrowserContract.Favicons;
|
||||
import org.mozilla.gecko.db.BrowserContract.Highlights;
|
||||
import org.mozilla.gecko.db.BrowserContract.History;
|
||||
import org.mozilla.gecko.db.BrowserContract.Visits;
|
||||
import org.mozilla.gecko.db.BrowserContract.Schema;
|
||||
@ -1161,7 +1162,8 @@ public class BrowserProvider extends SharedBrowserDatabaseProvider {
|
||||
DBUtils.qualifyColumn(Bookmarks.TABLE_NAME, Bookmarks._ID) + " AS " + Combined.BOOKMARK_ID + ", " +
|
||||
"-1 AS " + Combined.HISTORY_ID + ", " +
|
||||
DBUtils.qualifyColumn(Bookmarks.TABLE_NAME, Bookmarks.URL) + ", " +
|
||||
DBUtils.qualifyColumn(Bookmarks.TABLE_NAME, Bookmarks.TITLE) + " " +
|
||||
DBUtils.qualifyColumn(Bookmarks.TABLE_NAME, Bookmarks.TITLE) + ", " +
|
||||
DBUtils.qualifyColumn(Bookmarks.TABLE_NAME, Bookmarks.DATE_CREATED) + " AS " + Highlights.DATE + " " +
|
||||
"FROM " + Bookmarks.TABLE_NAME + " " +
|
||||
"LEFT JOIN " + History.TABLE_NAME + " ON " +
|
||||
DBUtils.qualifyColumn(Bookmarks.TABLE_NAME, Bookmarks.URL) + " = " +
|
||||
@ -1181,7 +1183,8 @@ public class BrowserProvider extends SharedBrowserDatabaseProvider {
|
||||
History._ID + " AS " + Combined.HISTORY_ID + ", " +
|
||||
"-1 AS " + Combined.BOOKMARK_ID + ", " +
|
||||
History.URL + ", " +
|
||||
History.TITLE + " " +
|
||||
History.TITLE + ", " +
|
||||
History.DATE_LAST_VISITED + " AS " + Highlights.DATE + " " +
|
||||
"FROM " + History.TABLE_NAME + " " +
|
||||
"WHERE " + History.DATE_LAST_VISITED + " < " + last30Minutes + " " +
|
||||
"AND " + History.VISITS + " <= 3 " +
|
||||
|
@ -56,29 +56,14 @@ public class ActivityStream extends FrameLayout {
|
||||
adapter.swapTopSitesCursor(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a temporary cursor loader. We'll probably need a completely new query for AS,
|
||||
* at that time we can switch to the new CursorLoader, as opposed to using our outdated
|
||||
* SimpleCursorLoader.
|
||||
*/
|
||||
private static class HistoryLoader extends SimpleCursorLoader {
|
||||
public HistoryLoader(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Cursor loadCursor() {
|
||||
final Context context = getContext();
|
||||
return GeckoProfile.get(context).getDB()
|
||||
.getRecentHistory(context.getContentResolver(), 10);
|
||||
}
|
||||
}
|
||||
|
||||
private class CursorLoaderCallbacks implements LoaderManager.LoaderCallbacks<Cursor> {
|
||||
@Override
|
||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||
if (id == LOADER_ID_HIGHLIGHTS) {
|
||||
return new HistoryLoader(getContext());
|
||||
final Context context = getContext();
|
||||
return GeckoProfile.get(context)
|
||||
.getDB()
|
||||
.getHighlights(context, 10);
|
||||
} else if (id == LOADER_ID_TOPSITES) {
|
||||
return GeckoProfile.get(getContext()).getDB().getActivityStreamTopSites(getContext(),
|
||||
TopSitesPagerAdapter.TOTAL_ITEMS);
|
||||
|
@ -69,10 +69,10 @@ public abstract class StreamItem extends RecyclerView.ViewHolder {
|
||||
|
||||
@Override
|
||||
public void bind(Cursor cursor) {
|
||||
vLabel.setText(cursor.getString(cursor.getColumnIndexOrThrow(BrowserContract.History.TITLE)));
|
||||
final long time = cursor.getLong(cursor.getColumnIndexOrThrow(BrowserContract.Highlights.DATE));
|
||||
final String ago = DateUtils.getRelativeTimeSpanString(time, System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, 0).toString();
|
||||
|
||||
final long timeVisited = cursor.getLong(cursor.getColumnIndexOrThrow(BrowserContract.History.DATE_LAST_VISITED));
|
||||
final String ago = DateUtils.getRelativeTimeSpanString(timeVisited, System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, 0).toString();
|
||||
vLabel.setText(cursor.getString(cursor.getColumnIndexOrThrow(BrowserContract.History.TITLE)));
|
||||
vTimeSince.setText(ago);
|
||||
}
|
||||
}
|
||||
@ -95,8 +95,8 @@ public abstract class StreamItem extends RecyclerView.ViewHolder {
|
||||
public void bind(Cursor cursor) {
|
||||
vLabel.setText(cursor.getString(cursor.getColumnIndexOrThrow(BrowserContract.History.TITLE)));
|
||||
|
||||
final long timeVisited = cursor.getLong(cursor.getColumnIndexOrThrow(BrowserContract.History.DATE_LAST_VISITED));
|
||||
final String ago = DateUtils.getRelativeTimeSpanString(timeVisited, System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, 0).toString();
|
||||
final long time = cursor.getLong(cursor.getColumnIndexOrThrow(BrowserContract.Highlights.DATE));
|
||||
final String ago = DateUtils.getRelativeTimeSpanString(time, System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, 0).toString();
|
||||
vTimeSince.setText(ago);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user