본문 바로가기
프로그래밍 놀이터/안드로이드, Java

연락처 계정 생성시 OEM 에서 연락처에서 추가/편집 가능한 Field 정의

by 돼지왕 왕돼지 2019. 1. 17.
반응형

연락처 계정 생성시 OEM 에서 연락처에서 추가/편집 가능한 Field 정의


android.provider.CONTACTS_STRUCTURE, aosp, contactsaccounttype, datakind, editschema, manifest, meta-data, SyncAdapterService, xml, 연락처 계정 생성시 OEM 에서 Control 가능한 Field 정의


-

먼저 Manifest 에 아래와 같이 SyncAdapterService 를 정의하면서

meta-data 에 android.provider.CONTACTS_STRUCTURE 에 xml 을 정의해서 넣어준다.

이 xml 을 OEM 등의 연락처 앱이 참조해서 필드 표시를 해준다


<service android:name=".service.MySyncAdapterService">
    <intent-filter>
        <action android:name="android.content.SyncAdapter"/>
    </intent-filter>

    <meta-data
        android:name="android.content.SyncAdapter"
        android:resource="@xml/syncadapter"/>
    <meta-data
        android:name="android.provider.CONTACTS_STRUCTURE"
        android:resource="@xml/contacts"/>
</service>



-

xml format 은 developer 문서에 공식적으로는 찾을 수 없었고, AOSP 안의 test 앱에서 그 scheme 을 찾을 수 있었다. ( http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.0.3_r1/packages/apps/Contacts/tests/res/xml/test_basic_contacts.xml )


해당 코드를 복붙해놓은 것인데 참조해서 정의하면 되겠다.

<ContactsAccountType
    xmlns:android="http://schemas.android.com/apk/res/android"
    >
    <EditSchema>
        <!--
            Name:
            - maxOccurs must be 1
            - No types.

            - Currently all the supportsXxx attributes must be true, but here's the plan for the
              future:
              (There's some hardcoded assumptions in the contact editor, which is one reason
              for the above restriction)

                - "Family name" and "Given name" must be supported.
                    - All sync adapters must support structured name. "display name only" is not
                      supported.
                      -> Supporting this would require relatively large changes to
                         the contact editor.

                - Fields are decided from the attributes:
                    StructuredName.DISPLAY_NAME         if supportsDisplayName == true
                    StructuredName.PREFIX               if supportsPrefix == true
                    StructuredName.FAMILY_NAME          (always)
                    StructuredName.MIDDLE_NAME          if supportsPrefix == true
                    StructuredName.GIVEN_NAME           (always)
                    StructuredName.SUFFIX               if supportsSuffix == true
                    StructuredName.PHONETIC_FAMILY_NAME if supportsPhoneticFamilyName == true
                    StructuredName.PHONETIC_MIDDLE_NAME if supportsPhoneticMiddleName == true
                    StructuredName.PHONETIC_GIVEN_NAME  if supportsPhoneticGivenName == true

                - DataKind.PSEUDO_MIME_TYPE_DISPLAY_NAME  is always added.
                - DataKind.PSEUDO_MIME_TYPE_PHONETIC_NAME is added
                  if any of supportsPhoneticXxx == true
        -->
        <!-- Fallback/Google definition.  Supports all. -->
        <DataKind kind="name"
            maxOccurs="1"
            supportsDisplayName="true"
            supportsPrefix="true"
            supportsMiddleName="true"
            supportsSuffix="true"
            supportsPhoneticFamilyName="true"
            supportsPhoneticMiddleName="true"
            supportsPhoneticGivenName="true"
            >
        </DataKind>

        <!-- Exchange definition.  No display-name, no phonetic-middle.
        <DataKind kind="name"
            supportsDisplayName="false"
            supportsPrefix="true"
            supportsMiddleName="true"
            supportsSuffix="true"
            supportsPhoneticFamilyName="true"
            supportsPhoneticMiddleName="false"
            supportsPhoneticGivenName ="true"
            >
        </DataKind>
        -->

        <!--
            Photo:
            - maxOccurs must be 1
            - No types.
        -->
        <DataKind kind="photo" maxOccurs="1" />

        <!--
            Phone definition.
            - "is secondary?" is inferred from type.
        -->
        <!-- Fallback, Google definition.  -->
        <DataKind kind="phone" >
            <!-- Note: Google type doesn't have obsolete ones -->
            <Type type="mobile" />
            <Type type="home" />
            <Type type="work" />
            <Type type="fax_work" />
            <Type type="fax_home" />
            <Type type="pager" />
            <Type type="other" />
            <Type type="custom"/>
            <Type type="callback" />
            <Type type="car" />
            <Type type="company_main" />
            <Type type="isdn" />
            <Type type="main" />
            <Type type="other_fax" />
            <Type type="radio" />
            <Type type="telex" />
            <Type type="tty_tdd" />
            <Type type="work_mobile"/>
            <Type type="work_pager" />
            <Type type="assistant" />
            <Type type="mms" />
        </DataKind>

        <!-- Exchange definition.
        <DataKind kind="phone" >
            <Type type="home" maxOccurs="2" />
            <Type type="mobile" maxOccurs="1" />
            <Type type="work" maxOccurs="2" />
            <Type type="fax_work" maxOccurs="1" />
            <Type type="fax_home" maxOccurs="1" />
            <Type type="pager" maxOccurs="1" />
            <Type type="car" maxOccurs="1" />
            <Type type="company_main" maxOccurs="1" />
            <Type type="mms" maxOccurs="1" />
            <Type type="radio" maxOccurs="1" />
            <Type type="assistant" maxOccurs="1" />
        </DataKind>
        -->

        <!--
            Email
        -->
        <!-- Fallback/Google definition.  -->
        <DataKind kind="email" >
            <!-- Note: Google type doesn't have obsolete ones -->
            <Type type="home" />
            <Type type="work" />
            <Type type="other" />
            <Type type="mobile" />
            <Type type="custom" />
        </DataKind>

        <!--
            Exchange definition.
            - Same definition as "fallback" except for maxOccurs=3
        <DataKind kind="email" maxOccurs="3" >
            <Type type="home" />
            <Type type="work" />
            <Type type="other" />
            <Type type="mobile" />
            <Type type="custom" />
        </DataKind>
        -->

        <!--
            Nickname
            - maxOccurs must be 1
            - No types.
        -->
        <DataKind kind="nickname" maxOccurs="1" />

        <!--
            Im:
             - The TYPE column always stores Im.TYPE_OTHER (defaultValues is always set)
             - The user-selected type is stored in Im.PROTOCOL
        -->
        <!-- Fallback, Google definition.  -->
        <DataKind kind="im" >
            <Type type="aim" />
            <Type type="msn" />
            <Type type="yahoo" />
            <Type type="skype" />
            <Type type="qq" />
            <Type type="google_talk" />
            <Type type="icq" />
            <Type type="jabber" />
            <Type type="custom" />
        </DataKind>

        <!-- Exchange definition.
        <DataKind kind="im" maxOccurs="3" >
            <Type type="aim" />
            <Type type="msn" />
            <Type type="yahoo" />
            <Type type="skype" />
            <Type type="qq" />
            <Type type="google_talk" />
            <Type type="icq" />
            <Type type="jabber" />
            <Type type="custom" />
        </DataKind>
        -->

        <!--
            Postal address.
        -->
        <!-- Fallback/Google definition.  Not structured. -->
        <DataKind kind="postal" needsStructured="false" >
            <Type type="home" />
            <Type type="work" />
            <Type type="other" />
            <Type type="custom" />
        </DataKind>

        <!-- Exchange definition.  Structured.
        <DataKind kind="postal" needsStructured="true" >
            <Type type="work" />
            <Type type="home" />
            <Type type="other" />
        </DataKind>
        -->

        <!--
            Organization:
            - Fields are fixed: COMPANY, TITLE
            - maxOccurs must be 1
            - No types.
        -->
        <DataKind kind="organization" maxOccurs="1" />

        <!--
            Website:
            - No types.
        -->
        <DataKind kind="website" />

        <!--
            Below kinds have nothing configurable.
            - No types are supported.
            - maxOccurs must be 1
        -->
        <DataKind kind="sip_address" maxOccurs="1" />
        <DataKind kind="note" maxOccurs="1" />

        <!--
            Google/Exchange supports it, but fallback doesn't.
        <DataKind kind="group_membership" maxOccurs="1" />
        -->

        <!--
            Event
        -->
        <DataKind kind="event" dateWithTime="false">
            <Type type="birthday" maxOccurs="1" yearOptional="true" />
            <Type type="anniversary" />
            <Type type="other" />
            <Type type="custom" />
        </DataKind>

        <!--
            Exchange definition.  dateWithTime is needed only for Exchange.
        <DataKind kind="event" dateWithTime="true">
            <Type type="birthday" maxOccurs="1" />
        </DataKind>
        -->

        <!--
            Relationship
        -->
        <DataKind kind="relationship" >
            <Type type="assistant" />
            <Type type="brother" />
            <Type type="child" />
            <Type type="domestic_partner" />
            <Type type="father" />
            <Type type="friend" />
            <Type type="manager" />
            <Type type="mother" />
            <Type type="parent" />
            <Type type="partner" />
            <Type type="referred_by" />
            <Type type="relative" />
            <Type type="sister" />
            <Type type="spouse" />
            <Type type="custom" />
        </DataKind>
    </EditSchema>
</ContactsAccountType>



반응형

댓글