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

Unverified Commit a9efaa60 authored by Michael W's avatar Michael W Committed by Michael Bestas
Browse files

Contacts: Device Contacts: Simplify phone type

* Current list has Car, Telex, ISDN, etc...
* Copy from GoogleAccountType, which reduces the list heavily to
  something sane

Change-Id: I0958ab8065e14c29716220afd86dcff3cd94e8f1
parent 32223abc
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.accounts.AuthenticatorDescription;
import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import androidx.core.content.ContextCompat;
import androidx.core.content.res.ResourcesCompat;

@@ -27,6 +28,8 @@ import com.android.contacts.R;
import com.android.contacts.model.dataitem.DataKind;
import com.android.contactsbind.FeedbackHelper;

import com.google.common.collect.Lists;

public class FallbackAccountType extends BaseAccountType {
    private static final String TAG = "FallbackAccountType";

@@ -107,4 +110,27 @@ public class FallbackAccountType extends BaseAccountType {
                new AccountDisplayInfo(account, account.name,
                        getDisplayLabel(context), getDisplayIcon(context), false), this);
    }

    @Override
    protected DataKind addDataKindPhone(Context context) throws DefinitionException {
        final DataKind kind = super.addDataKindPhone(context);

        kind.typeColumn = Phone.TYPE;
        kind.typeList = Lists.newArrayList();
        kind.typeList.add(buildPhoneType(Phone.TYPE_MOBILE));
        kind.typeList.add(buildPhoneType(Phone.TYPE_WORK));
        kind.typeList.add(buildPhoneType(Phone.TYPE_HOME));
        kind.typeList.add(buildPhoneType(Phone.TYPE_MAIN));
        kind.typeList.add(buildPhoneType(Phone.TYPE_FAX_WORK).setSecondary(true));
        kind.typeList.add(buildPhoneType(Phone.TYPE_FAX_HOME).setSecondary(true));
        kind.typeList.add(buildPhoneType(Phone.TYPE_PAGER).setSecondary(true));
        kind.typeList.add(buildPhoneType(Phone.TYPE_OTHER));
        kind.typeList.add(buildPhoneType(Phone.TYPE_CUSTOM).setSecondary(true)
                .setCustomColumn(Phone.LABEL));

        kind.fieldList = Lists.newArrayList();
        kind.fieldList.add(new EditField(Phone.NUMBER, R.string.phoneLabelsGroup, FLAGS_PHONE));

        return kind;
    }
}