Fix build break; support folder query
Change-Id: Ic2a62e2d00e0fe46a1a488d665818c47243c9d8d
This commit is contained in:
parent
9227dbbf0f
commit
7db23e6acb
@ -201,6 +201,7 @@ public class EmailProvider extends ContentProvider {
|
||||
private static final int UI_SENDDRAFT = UI_BASE + 8;
|
||||
private static final int UI_FOLDER_REFRESH = UI_BASE + 9;
|
||||
private static final int UI_FOLDER_STATUS = UI_BASE + 10;
|
||||
private static final int UI_FOLDER = UI_BASE + 11;
|
||||
|
||||
// MUST ALWAYS EQUAL THE LAST OF THE PREVIOUS BASE CONSTANTS
|
||||
private static final int LAST_EMAIL_PROVIDER_DB_BASE = UI_BASE;
|
||||
@ -404,6 +405,7 @@ public class EmailProvider extends ContentProvider {
|
||||
matcher.addURI(EmailContent.AUTHORITY, "uisenddraft/#", UI_SENDDRAFT);
|
||||
matcher.addURI(EmailContent.AUTHORITY, "uirefresh/#", UI_FOLDER_REFRESH);
|
||||
matcher.addURI(EmailContent.AUTHORITY, "uistatus/#", UI_FOLDER_STATUS);
|
||||
matcher.addURI(EmailContent.AUTHORITY, "uifolder/#", UI_FOLDER);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -901,6 +903,9 @@ public class EmailProvider extends ContentProvider {
|
||||
private static final Uri UIPROVIDER_MESSAGE_NOTIFIER =
|
||||
Uri.parse("content://" + UIProvider.AUTHORITY + "/uimessages");
|
||||
|
||||
private static final Uri UIPROVIDER_MAILBOX_NOTIFIER =
|
||||
Uri.parse("content://" + UIProvider.AUTHORITY + "/uifolder");
|
||||
|
||||
@Override
|
||||
public Uri insert(Uri uri, ContentValues values) {
|
||||
int match = findMatch(uri, "insert");
|
||||
@ -1121,6 +1126,7 @@ public class EmailProvider extends ContentProvider {
|
||||
case UI_FOLDERS:
|
||||
case UI_MESSAGES:
|
||||
case UI_MESSAGE:
|
||||
case UI_FOLDER:
|
||||
// For now, we don't allow selection criteria within these queries
|
||||
if (selection != null || selectionArgs != null) {
|
||||
throw new IllegalArgumentException("UI queries can't have selection/args");
|
||||
@ -1871,7 +1877,6 @@ outer:
|
||||
.add(UIProvider.FolderColumns.UNREAD_COUNT, MailboxColumns.UNREAD_COUNT)
|
||||
.add(UIProvider.FolderColumns.TOTAL_COUNT, MailboxColumns.MESSAGE_COUNT)
|
||||
.add(UIProvider.FolderColumns.REFRESH_URI, uriWithId("uirefresh"))
|
||||
.add(UIProvider.FolderColumns.STATUS_URI, uriWithId("uistatus"))
|
||||
.build();
|
||||
|
||||
/**
|
||||
@ -1983,6 +1988,18 @@ outer:
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a "single mailbox" SQLite query, given a projection from UnifiedEmail
|
||||
*
|
||||
* @param uiProjection as passed from UnifiedEmail
|
||||
* @return the SQLite query to be executed on the EmailProvider database
|
||||
*/
|
||||
private String genQueryMailbox(String[] uiProjection) {
|
||||
StringBuilder sb = genSelect(sFolderListMap, uiProjection);
|
||||
sb.append(" FROM " + Mailbox.TABLE_NAME + " WHERE " + MailboxColumns.ID + "=?");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the "subfolder list" SQLite query, given a projection from UnifiedEmail
|
||||
*
|
||||
@ -2026,6 +2043,7 @@ outer:
|
||||
*/
|
||||
private Cursor uiQuery(int match, Uri uri, String[] uiProjection) {
|
||||
Context context = getContext();
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
SQLiteDatabase db = getDatabase(context);
|
||||
// Should we ever return null, or throw an exception??
|
||||
Cursor c = null;
|
||||
@ -2049,11 +2067,17 @@ outer:
|
||||
case UI_MESSAGE:
|
||||
c = db.rawQuery(genQueryViewMessage(uiProjection), new String[] {id});
|
||||
break;
|
||||
case UI_FOLDER:
|
||||
c = db.rawQuery(genQueryMailbox(uiProjection), new String[] {id});
|
||||
// We'll notify on changes to the particular mailbox via the EmailProvider Uri
|
||||
c.setNotificationUri(resolver,
|
||||
ContentUris.withAppendedId(Mailbox.CONTENT_URI, Long.parseLong(id)));
|
||||
return c;
|
||||
}
|
||||
if (c != null) {
|
||||
// Notify UIProvider on changes
|
||||
// Make this more specific to actual query later on...
|
||||
c.setNotificationUri(context.getContentResolver(), UIPROVIDER_MESSAGE_NOTIFIER);
|
||||
c.setNotificationUri(resolver, UIPROVIDER_MESSAGE_NOTIFIER);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user