Home | History | Annotate | Download | only in model
      1 /*
      2  * Copyright (C) 2009 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.contacts.model;
     18 
     19 import com.android.contacts.R;
     20 
     21 import android.content.Context;
     22 import android.util.Log;
     23 
     24 public class FallbackAccountType extends BaseAccountType {
     25     private static final String TAG = "FallbackAccountType";
     26 
     27     private FallbackAccountType(Context context, String resPackageName) {
     28         this.accountType = null;
     29         this.dataSet = null;
     30         this.titleRes = R.string.account_phone;
     31         this.iconRes = R.mipmap.ic_launcher_contacts;
     32 
     33         this.resPackageName = resPackageName;
     34         this.summaryResPackageName = resPackageName;
     35 
     36         try {
     37             addDataKindStructuredName(context);
     38             addDataKindDisplayName(context);
     39             addDataKindPhoneticName(context);
     40             addDataKindNickname(context);
     41             addDataKindPhone(context);
     42             addDataKindEmail(context);
     43             addDataKindStructuredPostal(context);
     44             addDataKindIm(context);
     45             addDataKindOrganization(context);
     46             addDataKindPhoto(context);
     47             addDataKindNote(context);
     48             addDataKindWebsite(context);
     49             addDataKindSipAddress(context);
     50 
     51             mIsInitialized = true;
     52         } catch (DefinitionException e) {
     53             Log.e(TAG, "Problem building account type", e);
     54         }
     55     }
     56 
     57     public FallbackAccountType(Context context) {
     58         this(context, null);
     59     }
     60 
     61     /**
     62      * Used to compare with an {@link ExternalAccountType} built from a test contacts.xml.
     63      * In order to build {@link DataKind}s with the same resource package name,
     64      * {@code resPackageName} is injectable.
     65      */
     66     static AccountType createForTest(Context context, String resPackageName) {
     67         return new FallbackAccountType(context, resPackageName);
     68     }
     69 
     70     @Override
     71     public boolean areContactsWritable() {
     72         return true;
     73     }
     74 }
     75