Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dcf751d7 authored by Makoto Onuki's avatar Makoto Onuki
Browse files

EditSchema parser for ExternalAccountType

This also includes:
- Removed getHeaderColor/getSideBarColor from AccountType

- Implemented a test authenticator/sync adapter in the test apk.
This defines a test account type "com.android.contacts.tests.authtest.basic".
We could potentially add more account types to the test apk to test different
edit schema variations, but at this point this is impossible, as
ExternalAccountType doesn't have a way to tell which contacts.xml belongs
to which account type.  The current contacts.xml defined here builds
the fallback account type equivalent.

The sync adapter is pretty rudimentary; it doesn't clear the isDirty flag
on modified raw contacts or delete raw contacts with isDeleted set.  At
this point this doesn't seem to be necessary to test EditSchema.

Note:
For now it's still not meant to be public API.  Right now it's only manually
tested with the edit schema defition in the test apk described above.

Bug 5381810

Change-Id: Ifefdb969b4e08775125924b1366d24effc4db2f2
parent 20ffc86b
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.provider.ContactsContract.CommonDataKinds.StructuredPostal;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.RawContacts;
import android.util.Log;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;

@@ -82,6 +83,14 @@ public abstract class AccountType {
     */
    private HashMap<String, DataKind> mMimeKinds = Maps.newHashMap();

    /**
     * Whether this account type was able to be fully initialized.  This may be false if
     * (for example) the package name associated with the account type could not be found.
     */
    public boolean isInitialized() {
        return true;
    }

    public boolean isExtension() {
        return false;
    }
@@ -234,10 +243,6 @@ public abstract class AccountType {
     */
    abstract public boolean isGroupMembershipEditable();

    abstract public int getHeaderColor(Context context);

    abstract public int getSideBarColor(Context context);

    /**
     * {@link Comparator} to sort by {@link DataKind#weight}.
     */
@@ -270,6 +275,11 @@ public abstract class AccountType {
     * Add given {@link DataKind} to list of those provided by this source.
     */
    public DataKind addKind(DataKind kind) {
        if (mMimeKinds.get(kind.mimeType) != null) {
            // TODO Make it exception.
            Log.w(TAG, "mime type '" + kind.mimeType + "' is already registered");
        }

        kind.resPackageName = this.resPackageName;
        this.mKinds.add(kind);
        this.mMimeKinds.put(kind.mimeType, kind);
@@ -351,7 +361,7 @@ public abstract class AccountType {
     * {@link Phone#NUMBER}. Includes flags to apply to an {@link EditText}, and
     * the column where this field is stored.
     */
    public static class EditField {
    public static final class EditField {
        public String column;
        public int titleRes;
        public int inputType;
+1 −1
Original line number Diff line number Diff line
@@ -388,7 +388,7 @@ class AccountTypeManagerImpl extends AccountTypeManager
                    Log.d(TAG, "Registering external account type=" + type
                            + ", packageName=" + auth.packageName);
                    accountType = new ExternalAccountType(mContext, auth.packageName, false);
                    if (!((ExternalAccountType) accountType).isInitialized()) {
                    if (!accountType.isInitialized()) {
                        // Skip external account types that couldn't be initialized.
                        continue;
                    }
+910 −24

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ import java.util.List;
 * {@link Data} rows of this kind, including the possible {@link EditType}
 * labels and editable {@link EditField}.
 */
public class DataKind {
public final class DataKind {

    public static final String PSEUDO_MIME_TYPE_DISPLAY_NAME = "#displayName";
    public static final String PSEUDO_MIME_TYPE_PHONETIC_NAME = "#phoneticName";
+0 −10
Original line number Diff line number Diff line
@@ -322,16 +322,6 @@ public class ExchangeAccountType extends BaseAccountType {
        return kind;
    }

    @Override
    public int getHeaderColor(Context context) {
        return 0xffd5ba96;
    }

    @Override
    public int getSideBarColor(Context context) {
        return 0xffb58e59;
    }

    @Override
    public boolean isGroupMembershipEditable() {
        return true;
Loading