Add a utility function to map mailbox type to authority.

Change-Id: I21731a5d9ba45850577fdda4d6bef8835d6d3249
This commit is contained in:
Yu Ping Hu 2013-08-09 17:30:32 -07:00
parent e13af80f6f
commit 2bafe9d904

View File

@ -25,6 +25,8 @@ import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.provider.CalendarContract;
import android.provider.ContactsContract;
import android.util.SparseBooleanArray; import android.util.SparseBooleanArray;
import com.android.emailcommon.Logging; import com.android.emailcommon.Logging;
@ -801,4 +803,20 @@ public class Mailbox extends EmailContent implements MailboxColumns, Parcelable
ACCOUNT_KEY_PROJECTION, null, null, null, ACCOUNT_KEY_PROJECTION, null, null, null,
ACCOUNT_KEY_PROJECTION_ACCOUNT_KEY_COLUMN, Account.NO_ACCOUNT); ACCOUNT_KEY_PROJECTION_ACCOUNT_KEY_COLUMN, Account.NO_ACCOUNT);
} }
/**
* Gets the correct authority for a mailbox.
* @param mailboxType The type of the mailbox we're interested in.
* @return The authority for the mailbox we're interested in.
*/
public static String getAuthority(final int mailboxType) {
switch (mailboxType) {
case Mailbox.TYPE_CALENDAR:
return CalendarContract.AUTHORITY;
case Mailbox.TYPE_CONTACTS:
return ContactsContract.AUTHORITY;
default:
return EmailContent.AUTHORITY;
}
}
} }