Always return a valid Uri for account inbox
Also don't return virtual folders unless real folders exist b/14319452 Change-Id: Id5f62f5ccc4d5488ae467df741b0598a158ceb81
This commit is contained in:
parent
a41c1bd1b1
commit
0d7c709125
@ -265,6 +265,7 @@ public class EmailProvider extends ContentProvider {
|
|||||||
private static final int UI_DEFAULT_RECENT_FOLDERS = UI_BASE + 16;
|
private static final int UI_DEFAULT_RECENT_FOLDERS = UI_BASE + 16;
|
||||||
private static final int UI_FULL_FOLDERS = UI_BASE + 17;
|
private static final int UI_FULL_FOLDERS = UI_BASE + 17;
|
||||||
private static final int UI_ALL_FOLDERS = UI_BASE + 18;
|
private static final int UI_ALL_FOLDERS = UI_BASE + 18;
|
||||||
|
private static final int UI_INBOX = UI_BASE + 19;
|
||||||
|
|
||||||
private static final int BODY_BASE = 0xA000;
|
private static final int BODY_BASE = 0xA000;
|
||||||
private static final int BODY = BODY_BASE;
|
private static final int BODY = BODY_BASE;
|
||||||
@ -1129,6 +1130,7 @@ public class EmailProvider extends ContentProvider {
|
|||||||
// We listen to everything trailing uifolder/ since there might be an appVersion
|
// We listen to everything trailing uifolder/ since there might be an appVersion
|
||||||
// as in Utils.appendVersionQueryParameter().
|
// as in Utils.appendVersionQueryParameter().
|
||||||
sURIMatcher.addURI(EmailContent.AUTHORITY, "uifolder/*", UI_FOLDER);
|
sURIMatcher.addURI(EmailContent.AUTHORITY, "uifolder/*", UI_FOLDER);
|
||||||
|
sURIMatcher.addURI(EmailContent.AUTHORITY, "uiinbox/#", UI_INBOX);
|
||||||
sURIMatcher.addURI(EmailContent.AUTHORITY, "uiaccount/#", UI_ACCOUNT);
|
sURIMatcher.addURI(EmailContent.AUTHORITY, "uiaccount/#", UI_ACCOUNT);
|
||||||
sURIMatcher.addURI(EmailContent.AUTHORITY, "uiaccts", UI_ACCTS);
|
sURIMatcher.addURI(EmailContent.AUTHORITY, "uiaccts", UI_ACCTS);
|
||||||
sURIMatcher.addURI(EmailContent.AUTHORITY, "uiattachments/#", UI_ATTACHMENTS);
|
sURIMatcher.addURI(EmailContent.AUTHORITY, "uiattachments/#", UI_ATTACHMENTS);
|
||||||
@ -1231,6 +1233,7 @@ public class EmailProvider extends ContentProvider {
|
|||||||
case UI_MESSAGES:
|
case UI_MESSAGES:
|
||||||
case UI_MESSAGE:
|
case UI_MESSAGE:
|
||||||
case UI_FOLDER:
|
case UI_FOLDER:
|
||||||
|
case UI_INBOX:
|
||||||
case UI_ACCOUNT:
|
case UI_ACCOUNT:
|
||||||
case UI_ATTACHMENT:
|
case UI_ATTACHMENT:
|
||||||
case UI_ATTACHMENTS:
|
case UI_ATTACHMENTS:
|
||||||
@ -3226,6 +3229,9 @@ public class EmailProvider extends ContentProvider {
|
|||||||
inboxMailboxId != Mailbox.NO_MAILBOX) {
|
inboxMailboxId != Mailbox.NO_MAILBOX) {
|
||||||
values.put(UIProvider.AccountColumns.SettingsColumns.DEFAULT_INBOX,
|
values.put(UIProvider.AccountColumns.SettingsColumns.DEFAULT_INBOX,
|
||||||
uiUriString("uifolder", inboxMailboxId));
|
uiUriString("uifolder", inboxMailboxId));
|
||||||
|
} else {
|
||||||
|
values.put(UIProvider.AccountColumns.SettingsColumns.DEFAULT_INBOX,
|
||||||
|
uiUriString("uiinbox", accountId));
|
||||||
}
|
}
|
||||||
if (projectionColumns.contains(
|
if (projectionColumns.contains(
|
||||||
UIProvider.AccountColumns.SettingsColumns.DEFAULT_INBOX_NAME) &&
|
UIProvider.AccountColumns.SettingsColumns.DEFAULT_INBOX_NAME) &&
|
||||||
@ -3764,8 +3770,12 @@ public class EmailProvider extends ContentProvider {
|
|||||||
new String[] {id});
|
new String[] {id});
|
||||||
c = getFolderListCursor(c, Long.valueOf(id), uiProjection);
|
c = getFolderListCursor(c, Long.valueOf(id), uiProjection);
|
||||||
c.setNotificationUri(context.getContentResolver(), notifyUri);
|
c.setNotificationUri(context.getContentResolver(), notifyUri);
|
||||||
Cursor[] cursors = new Cursor[] {vc, c};
|
if (c.getCount() > 0) {
|
||||||
return new MergeCursor(cursors);
|
Cursor[] cursors = new Cursor[]{vc, c};
|
||||||
|
return new MergeCursor(cursors);
|
||||||
|
} else {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4405,7 +4415,11 @@ public class EmailProvider extends ContentProvider {
|
|||||||
new String[] {id});
|
new String[] {id});
|
||||||
rawc.setNotificationUri(context.getContentResolver(), notifyUri);
|
rawc.setNotificationUri(context.getContentResolver(), notifyUri);
|
||||||
vc.setNotificationUri(context.getContentResolver(), notifyUri);
|
vc.setNotificationUri(context.getContentResolver(), notifyUri);
|
||||||
c = new MergeCursor(new Cursor[] {rawc, vc});
|
if (rawc.getCount() > 0) {
|
||||||
|
c = new MergeCursor(new Cursor[]{rawc, vc});
|
||||||
|
} else {
|
||||||
|
c = rawc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case UI_FULL_FOLDERS: {
|
case UI_FULL_FOLDERS: {
|
||||||
@ -4476,12 +4490,26 @@ public class EmailProvider extends ContentProvider {
|
|||||||
notifyUri = UIPROVIDER_ATTACHMENT_NOTIFIER.buildUpon().appendPath(id).build();
|
notifyUri = UIPROVIDER_ATTACHMENT_NOTIFIER.buildUpon().appendPath(id).build();
|
||||||
break;
|
break;
|
||||||
case UI_FOLDER:
|
case UI_FOLDER:
|
||||||
mailboxId = Long.parseLong(id);
|
case UI_INBOX:
|
||||||
|
if (match == UI_INBOX) {
|
||||||
|
mailboxId = Mailbox.findMailboxOfType(context, Long.parseLong(id),
|
||||||
|
Mailbox.TYPE_INBOX);
|
||||||
|
if (mailboxId == Mailbox.NO_MAILBOX) {
|
||||||
|
LogUtils.d(LogUtils.TAG, "No inbox found for account %s", id);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
LogUtils.d(LogUtils.TAG, "Found inbox id %d", mailboxId);
|
||||||
|
} else {
|
||||||
|
mailboxId = Long.parseLong(id);
|
||||||
|
}
|
||||||
|
final String mailboxIdString = Long.toString(mailboxId);
|
||||||
if (isVirtualMailbox(mailboxId)) {
|
if (isVirtualMailbox(mailboxId)) {
|
||||||
c = getVirtualMailboxCursor(mailboxId, uiProjection);
|
c = getVirtualMailboxCursor(mailboxId, uiProjection);
|
||||||
notifyUri = UIPROVIDER_FOLDER_NOTIFIER.buildUpon().appendPath(id).build();
|
notifyUri = UIPROVIDER_FOLDER_NOTIFIER.buildUpon().appendPath(mailboxIdString)
|
||||||
|
.build();
|
||||||
} else {
|
} else {
|
||||||
c = db.rawQuery(genQueryMailbox(uiProjection, id), new String[]{id});
|
c = db.rawQuery(genQueryMailbox(uiProjection, mailboxIdString),
|
||||||
|
new String[]{mailboxIdString});
|
||||||
final List<String> projectionList = Arrays.asList(uiProjection);
|
final List<String> projectionList = Arrays.asList(uiProjection);
|
||||||
final int nameColumn = projectionList.indexOf(UIProvider.FolderColumns.NAME);
|
final int nameColumn = projectionList.indexOf(UIProvider.FolderColumns.NAME);
|
||||||
final int typeColumn = projectionList.indexOf(UIProvider.FolderColumns.TYPE);
|
final int typeColumn = projectionList.indexOf(UIProvider.FolderColumns.TYPE);
|
||||||
@ -4490,7 +4518,8 @@ public class EmailProvider extends ContentProvider {
|
|||||||
new MatrixCursorWithCachedColumns(uiProjection),
|
new MatrixCursorWithCachedColumns(uiProjection),
|
||||||
uiProjection.length, c, nameColumn, typeColumn);
|
uiProjection.length, c, nameColumn, typeColumn);
|
||||||
}
|
}
|
||||||
notifyUri = UIPROVIDER_FOLDER_NOTIFIER.buildUpon().appendPath(id).build();
|
notifyUri = UIPROVIDER_FOLDER_NOTIFIER.buildUpon().appendPath(mailboxIdString)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case UI_ACCOUNT:
|
case UI_ACCOUNT:
|
||||||
|
Loading…
Reference in New Issue
Block a user