DataKind.java revision edb576aab33efff623691a89ace3c76cb2ff12d1
1package com.android.contacts.model;
2
3import com.android.contacts.R;
4import com.android.contacts.model.AccountType.EditField;
5import com.android.contacts.model.AccountType.EditType;
6import com.android.contacts.model.AccountType.StringInflater;
7
8import android.content.ContentValues;
9import android.provider.ContactsContract.Data;
10
11import java.text.SimpleDateFormat;
12import java.util.List;
13
14/**
15 * Description of a specific data type, usually marked by a unique
16 * {@link Data#MIMETYPE}. Includes details about how to view and edit
17 * {@link Data} rows of this kind, including the possible {@link EditType}
18 * labels and editable {@link EditField}.
19 */
20public class DataKind {
21
22    public static final String PSEUDO_MIME_TYPE_DISPLAY_NAME = "#displayName";
23    public static final String PSEUDO_MIME_TYPE_PHONETIC_NAME = "#phoneticName";
24    public static final String PSEUDO_COLUMN_PHONETIC_NAME = "#phoneticName";
25
26    public String resPackageName;
27    public String mimeType;
28    public int titleRes;
29    public int iconRes;
30    /** Icon used for secondary action when shown on top of a bright background */
31    public int iconAltRes;
32    /** Icon used for secondary action when shown on top of a dark background */
33    public int iconAltResDark;
34    public int weight;
35    public boolean editable;
36
37    /**
38     * If this is true (default), the user can add and remove values.
39     * If false, the editor will always show a single field (which might be empty).
40     */
41    public boolean isList;
42
43    public StringInflater actionHeader;
44    public StringInflater actionAltHeader;
45    public StringInflater actionBody;
46
47    public boolean actionBodySocial = false;
48
49    public String typeColumn;
50
51    /**
52     * Maximum number of values allowed in the list. -1 represents infinity.
53     * If {@link DataKind#isList} is false, this value is ignored.
54     */
55    public int typeOverallMax;
56
57    public List<EditType> typeList;
58    public List<EditField> fieldList;
59
60    public ContentValues defaultValues;
61
62    /** Layout resource id for an editor view to edit this {@link DataKind}. */
63    public final int editorLayoutResourceId;
64
65    /** Text appearance resource id for the value of a field in this {@link DataKind}. */
66    public final int textAppearanceResourceId;
67
68    /**
69     * If this is a date field, this specifies the format of the date when saving. The
70     * date includes year, month and day. If this is not a date field or the date field is not
71     * editable, this value should be ignored.
72     */
73    public SimpleDateFormat dateFormatWithoutYear;
74
75    /**
76     * If this is a date field, this specifies the format of the date when saving. The
77     * date includes month and day. If this is not a date field, the field is not editable or
78     * dates without year are not supported, this value should be ignored.
79     */
80    public SimpleDateFormat dateFormatWithYear;
81
82    public DataKind() {
83        editorLayoutResourceId = R.layout.text_fields_editor_view;
84        textAppearanceResourceId = android.R.style.TextAppearance_Medium;
85    }
86
87    public DataKind(String mimeType, int titleRes, int iconRes, int weight, boolean editable,
88            int editorLayoutResourceId, int textAppearanceResourceId) {
89        this.mimeType = mimeType;
90        this.titleRes = titleRes;
91        this.iconRes = iconRes;
92        this.weight = weight;
93        this.editable = editable;
94        this.isList = true;
95        this.typeOverallMax = -1;
96        this.editorLayoutResourceId = editorLayoutResourceId;
97        this.textAppearanceResourceId = textAppearanceResourceId;
98    }
99}