зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1243558 - Add UrlAnnotations.getScreenshots method. r=sebastian
MozReview-Commit-ID: GOjliERct95 --HG-- extra : rebase_source : f5a41d08d6d320a4f8ef8e39030faaf36ab3cb65
This commit is contained in:
Родитель
cb1f901dc0
Коммит
196ad44e57
|
@ -512,6 +512,17 @@ public class BrowserContract {
|
|||
public static final String VALUE = "value";
|
||||
public static final String SYNC_STATUS = "sync_status";
|
||||
|
||||
public enum Key {
|
||||
// We use a parameter, rather than name(), as defensive coding: we can't let the
|
||||
// enum name change because we've already stored values into the DB.
|
||||
SCREENSHOT ("screenshot");
|
||||
|
||||
private final String dbValue;
|
||||
|
||||
Key(final String dbValue) { this.dbValue = dbValue; }
|
||||
public String getDbValue() { return dbValue; }
|
||||
}
|
||||
|
||||
public enum SyncStatus {
|
||||
// We use a parameter, rather than ordinal(), as defensive coding: we can't let the
|
||||
// ordinal values change because we've already stored values into the DB.
|
||||
|
|
|
@ -6,8 +6,13 @@ package org.mozilla.gecko.db;
|
|||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import org.json.JSONObject;
|
||||
import org.mozilla.gecko.annotation.RobocopTarget;
|
||||
import org.mozilla.gecko.db.BrowserContract.UrlAnnotations.Key;
|
||||
|
||||
public class LocalUrlAnnotations implements UrlAnnotations {
|
||||
private Uri urlAnnotationsTableWithProfile;
|
||||
|
@ -28,4 +33,26 @@ public class LocalUrlAnnotations implements UrlAnnotations {
|
|||
values.put(BrowserContract.UrlAnnotations.DATE_MODIFIED, creationTime);
|
||||
cr.insert(urlAnnotationsTableWithProfile, values);
|
||||
}
|
||||
|
||||
private Cursor queryByKey(final ContentResolver cr, @NonNull final Key key, @Nullable final String[] projections,
|
||||
@Nullable final String sortOrder) {
|
||||
return cr.query(urlAnnotationsTableWithProfile,
|
||||
projections,
|
||||
BrowserContract.UrlAnnotations.KEY + " = ?", new String[] { key.getDbValue() },
|
||||
sortOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor getScreenshots(ContentResolver cr) {
|
||||
return queryByKey(cr,
|
||||
Key.SCREENSHOT,
|
||||
new String[] {
|
||||
BrowserContract.UrlAnnotations._ID,
|
||||
BrowserContract.UrlAnnotations.URL,
|
||||
BrowserContract.UrlAnnotations.KEY,
|
||||
BrowserContract.UrlAnnotations.VALUE,
|
||||
BrowserContract.UrlAnnotations.DATE_CREATED,
|
||||
},
|
||||
BrowserContract.UrlAnnotations.DATE_CREATED + " DESC");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,6 +153,9 @@ class StubTabsAccessor implements TabsAccessor {
|
|||
class StubUrlAnnotations implements UrlAnnotations {
|
||||
@Override
|
||||
public void insertAnnotation(ContentResolver cr, String url, String key, String value) {}
|
||||
|
||||
@Override
|
||||
public Cursor getScreenshots(ContentResolver cr) { return null; }
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -5,8 +5,10 @@
|
|||
package org.mozilla.gecko.db;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.database.Cursor;
|
||||
import org.mozilla.gecko.annotation.RobocopTarget;
|
||||
|
||||
public interface UrlAnnotations {
|
||||
@RobocopTarget void insertAnnotation(ContentResolver cr, String url, String key, String value);
|
||||
Cursor getScreenshots(ContentResolver cr);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче