Create requireSetup attribute; use it for gImap

Change-Id: Id5f37861e4d6f2c2ed0fe98bd8b4d7eb73868c09
This commit is contained in:
Marc Blank 2012-09-08 13:08:50 -07:00
parent fdb1635868
commit 81b0f74efa
4 changed files with 15 additions and 4 deletions

View File

@ -84,6 +84,7 @@
email:syncChanges="true"
email:inferPrefix="imap"
email:offerLoadMore="true"
email:requiresSetup="true"
/>
<emailservice
email:protocol="eas"

View File

@ -66,5 +66,6 @@
</attr>
<attr name="inferPrefix" format="string"/>
<attr name="requiresAccountUpdate" format="boolean"/>
<attr name="requiresSetup" format="boolean"/>
</declare-styleable>
</resources>

View File

@ -2840,12 +2840,13 @@ outer:
}
if (projectionColumns.contains(
UIProvider.AccountColumns.SettingsColumns.SETUP_INTENT_URI)) {
// Use this if needed
// Set the setup intent if needed
// TODO We should clarify/document the trash/setup relationship
long trashId = Mailbox.findMailboxOfType(context, accountId, Mailbox.TYPE_TRASH);
if (trashId == Mailbox.NO_MAILBOX) {
// STOPSHIP Don't hard-code this for imap
String protocol = Account.getProtocol(context, Long.parseLong(id));
if (protocol.equals("gImap")) {
EmailServiceInfo info = EmailServiceUtils.getServiceInfoForAccount(context,
accountId);
if (info != null && info.requiresSetup) {
values.put(UIProvider.AccountColumns.SettingsColumns.SETUP_INTENT_URI,
getExternalUriString("setup", id));
}

View File

@ -177,6 +177,7 @@ public class EmailServiceUtils {
public String inferPrefix;
public boolean requiresAccountUpdate;
public boolean offerLoadMore;
public boolean requiresSetup;
public String toString() {
StringBuilder sb = new StringBuilder("Protocol: ");
@ -211,6 +212,11 @@ public class EmailServiceUtils {
}
}
public static EmailServiceInfo getServiceInfoForAccount(Context context, long accountId) {
String protocol = Account.getProtocol(context, accountId);
return getServiceInfo(context, protocol);
}
public static EmailServiceInfo getServiceInfo(Context context, String protocol) {
if (sServiceList.isEmpty()) {
findServices(context);
@ -529,6 +535,8 @@ public class EmailServiceUtils {
info.inferPrefix = ta.getString(R.styleable.EmailServiceInfo_inferPrefix);
info.offerLoadMore =
ta.getBoolean(R.styleable.EmailServiceInfo_offerLoadMore, false);
info.requiresSetup =
ta.getBoolean(R.styleable.EmailServiceInfo_requiresSetup, false);
// Must have either "class" (local) or "intent" (remote)
if (klass != null) {