Home | History | Annotate | Download | only in model
      1 /*
      2  * Copyright (C) 2011 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 import com.android.contacts.model.AccountType.EditField;
     21 import com.android.contacts.model.AccountType.EditType;
     22 import com.android.contacts.model.AccountType.StringInflater;
     23 
     24 import android.content.ContentValues;
     25 import android.provider.ContactsContract.Data;
     26 
     27 import java.text.SimpleDateFormat;
     28 import java.util.List;
     29 
     30 /**
     31  * Description of a specific data type, usually marked by a unique
     32  * {@link Data#MIMETYPE}. Includes details about how to view and edit
     33  * {@link Data} rows of this kind, including the possible {@link EditType}
     34  * labels and editable {@link EditField}.
     35  */
     36 public class DataKind {
     37 
     38     public static final String PSEUDO_MIME_TYPE_DISPLAY_NAME = "#displayName";
     39     public static final String PSEUDO_MIME_TYPE_PHONETIC_NAME = "#phoneticName";
     40     public static final String PSEUDO_COLUMN_PHONETIC_NAME = "#phoneticName";
     41 
     42     public String resPackageName;
     43     public String mimeType;
     44     public int titleRes;
     45     public int iconAltRes;
     46     public int iconAltDescriptionRes;
     47     public int weight;
     48     public boolean editable;
     49 
     50     public StringInflater actionHeader;
     51     public StringInflater actionAltHeader;
     52     public StringInflater actionBody;
     53 
     54     public boolean actionBodySocial = false;
     55 
     56     public String typeColumn;
     57 
     58     /**
     59      * Maximum number of values allowed in the list. -1 represents infinity.
     60      */
     61     public int typeOverallMax;
     62 
     63     public List<EditType> typeList;
     64     public List<EditField> fieldList;
     65 
     66     public ContentValues defaultValues;
     67 
     68     /** Layout resource id for an editor view to edit this {@link DataKind}. */
     69     public final int editorLayoutResourceId;
     70 
     71     /**
     72      * If this is a date field, this specifies the format of the date when saving. The
     73      * date includes year, month and day. If this is not a date field or the date field is not
     74      * editable, this value should be ignored.
     75      */
     76     public SimpleDateFormat dateFormatWithoutYear;
     77 
     78     /**
     79      * If this is a date field, this specifies the format of the date when saving. The
     80      * date includes month and day. If this is not a date field, the field is not editable or
     81      * dates without year are not supported, this value should be ignored.
     82      */
     83     public SimpleDateFormat dateFormatWithYear;
     84 
     85     public DataKind() {
     86         editorLayoutResourceId = R.layout.text_fields_editor_view;
     87     }
     88 
     89     public DataKind(String mimeType, int titleRes, int weight, boolean editable,
     90             int editorLayoutResourceId) {
     91         this.mimeType = mimeType;
     92         this.titleRes = titleRes;
     93         this.weight = weight;
     94         this.editable = editable;
     95         this.typeOverallMax = -1;
     96         this.editorLayoutResourceId = editorLayoutResourceId;
     97     }
     98 }