Browse Source

Add accessors to get Chrome dev and beta bookmarks, also fix potential bugs

master
Anthony Restaino 9 years ago
parent
commit
7f4cab1e2e
  1. 37
      app/src/main/java/acr/browser/lightning/database/BookmarkLocalSync.java

37
app/src/main/java/acr/browser/lightning/database/BookmarkLocalSync.java

@ -56,10 +56,12 @@ public class BookmarkLocalSync {
if (title == null || title.isEmpty()) { if (title == null || title.isEmpty()) {
title = Utils.getDomainName(url); title = Utils.getDomainName(url);
} }
if (title != null) {
list.add(new HistoryItem(url, title)); list.add(new HistoryItem(url, title));
} }
} }
} }
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -91,10 +93,12 @@ public class BookmarkLocalSync {
if (title == null || title.isEmpty()) { if (title == null || title.isEmpty()) {
title = Utils.getDomainName(url); title = Utils.getDomainName(url);
} }
if (title != null) {
list.add(new HistoryItem(url, title)); list.add(new HistoryItem(url, title));
} }
} }
} }
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -113,7 +117,38 @@ public class BookmarkLocalSync {
public boolean isChromeSupported() { public boolean isChromeSupported() {
Cursor cursor = getChromeCursor(); Cursor cursor = getChromeCursor();
Utils.close(cursor); Utils.close(cursor);
return cursor != null; Cursor dev = getChromeDevCursor();
Utils.close(dev);
Cursor beta = getChromeBetaCursor();
return cursor != null || dev != null || beta != null;
}
@Nullable
@WorkerThread
private Cursor getChromeBetaCursor() {
Cursor cursor;
Uri uri = Uri.parse(CHROME_BETA_BOOKMARKS_CONTENT);
try {
cursor = mContext.getContentResolver().query(uri,
new String[]{COLUMN_URL, COLUMN_TITLE, COLUMN_BOOKMARK}, null, null, null);
} catch (IllegalArgumentException e) {
return null;
}
return cursor;
}
@Nullable
@WorkerThread
private Cursor getChromeDevCursor() {
Cursor cursor;
Uri uri = Uri.parse(CHROME_DEV_BOOKMARKS_CONTENT);
try {
cursor = mContext.getContentResolver().query(uri,
new String[]{COLUMN_URL, COLUMN_TITLE, COLUMN_BOOKMARK}, null, null, null);
} catch (IllegalArgumentException e) {
return null;
}
return cursor;
} }
@Nullable @Nullable

Loading…
Cancel
Save