1ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkey/* 2ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkey * Copyright (C) 2009 The Android Open Source Project 3ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkey * 4ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkey * Licensed under the Apache License, Version 2.0 (the "License"); 5ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkey * you may not use this file except in compliance with the License. 6ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkey * You may obtain a copy of the License at 7ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkey * 8ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkey * http://www.apache.org/licenses/LICENSE-2.0 9ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkey * 10ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkey * Unless required by applicable law or agreed to in writing, software 11ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkey * distributed under the License is distributed on an "AS IS" BASIS, 12ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkey * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkey * See the License for the specific language governing permissions and 14ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkey * limitations under the License. 15ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkey */ 16ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkey 17851222a96b5d68602fb361ea3527101e893f67e3Maurice Chupackage com.android.contacts.model.account; 18ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkey 19ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkeyimport android.content.Context; 2086ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onukiimport android.util.Log; 21ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkey 22e0b2f1e2d01d1ac52ba207dc7ce76971d853298eChiao Chengimport com.android.contacts.R; 23851222a96b5d68602fb361ea3527101e893f67e3Maurice Chuimport com.android.contacts.model.dataitem.DataKind; 24e0b2f1e2d01d1ac52ba207dc7ce76971d853298eChiao Chengimport com.android.contacts.test.NeededForTesting; 25e0b2f1e2d01d1ac52ba207dc7ce76971d853298eChiao Cheng 261dc28bef7d5353310359c3711b6cdac390d8a2e0Dmitri Plotnikovpublic class FallbackAccountType extends BaseAccountType { 2786ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki private static final String TAG = "FallbackAccountType"; 28ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkey 2986ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki private FallbackAccountType(Context context, String resPackageName) { 30ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkey this.accountType = null; 312b3f3c54d3beb017b2f59f19e9ce0ecc3e039dbcDave Santoro this.dataSet = null; 322cb71bd0d6096f48d9d8c6d66a753b164468abb2Isaac Katzenelson this.titleRes = R.string.account_phone; 33174eb0ac54a0b483fee05013a2eb5e538d4b6d0bDaniel Lehmann this.iconRes = R.mipmap.ic_launcher_contacts; 342e6148fe7d8a3e724d8a8f10780d7e5571780279Jeff Sharkey 3582a4f4408b74e193b43a12dc8e16c946a93bae4aMakoto Onuki // Note those are only set for unit tests. 3682a4f4408b74e193b43a12dc8e16c946a93bae4aMakoto Onuki this.resourcePackageName = resPackageName; 3782a4f4408b74e193b43a12dc8e16c946a93bae4aMakoto Onuki this.syncAdapterPackageName = resPackageName; 381dc28bef7d5353310359c3711b6cdac390d8a2e0Dmitri Plotnikov 3986ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki try { 4086ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki addDataKindStructuredName(context); 4186ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki addDataKindDisplayName(context); 4286ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki addDataKindPhoneticName(context); 4386ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki addDataKindNickname(context); 4486ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki addDataKindPhone(context); 4586ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki addDataKindEmail(context); 4686ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki addDataKindStructuredPostal(context); 4786ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki addDataKindIm(context); 4886ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki addDataKindOrganization(context); 4986ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki addDataKindPhoto(context); 5086ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki addDataKindNote(context); 5186ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki addDataKindWebsite(context); 5286ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki addDataKindSipAddress(context); 5386ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki 5486ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki mIsInitialized = true; 5586ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki } catch (DefinitionException e) { 5686ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki Log.e(TAG, "Problem building account type", e); 5786ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki } 5886ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki } 5986ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki 6086ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki public FallbackAccountType(Context context) { 6186ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki this(context, null); 6286ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki } 6386ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki 6486ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki /** 6586ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki * Used to compare with an {@link ExternalAccountType} built from a test contacts.xml. 6686ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki * In order to build {@link DataKind}s with the same resource package name, 6786ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki * {@code resPackageName} is injectable. 6886ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki */ 69a0290a4baab4297303cab3664c7abfd548f2e301Makoto Onuki @NeededForTesting 7082a4f4408b74e193b43a12dc8e16c946a93bae4aMakoto Onuki static AccountType createWithPackageNameForTest(Context context, String resPackageName) { 7186ccb6ce2ff6078b06add93aab489951ef83bc72Makoto Onuki return new FallbackAccountType(context, resPackageName); 72ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkey } 735297c6af41f3fd2f08cff5b84105af4efd1ab79fJeff Hamilton 745297c6af41f3fd2f08cff5b84105af4efd1ab79fJeff Hamilton @Override 7596e87fd6e808e9d853263ffeb5104f3253a18639Daniel Lehmann public boolean areContactsWritable() { 7696e87fd6e808e9d853263ffeb5104f3253a18639Daniel Lehmann return true; 7796e87fd6e808e9d853263ffeb5104f3253a18639Daniel Lehmann } 78ab066931efd4b6408b5f57026b421eb4a7934a39Jeff Sharkey} 79