Yorke Lee | 2644d94 | 2013-10-28 11:05:43 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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 | |
Gary Mai | 69c182a | 2016-12-05 13:07:03 -0800 | [diff] [blame] | 17 | package com.android.contacts.model.dataitem; |
Yorke Lee | 2644d94 | 2013-10-28 11:05:43 -0700 | [diff] [blame] | 18 | |
| 19 | import android.content.ContentValues; |
| 20 | import android.provider.ContactsContract; |
| 21 | import android.provider.ContactsContract.CommonDataKinds.StructuredName; |
| 22 | import android.provider.ContactsContract.Contacts.Data; |
| 23 | |
| 24 | /** |
| 25 | * Represents a structured name data item, wrapping the columns in |
| 26 | * {@link ContactsContract.CommonDataKinds.StructuredName}. |
| 27 | */ |
| 28 | public class StructuredNameDataItem extends DataItem { |
| 29 | |
| 30 | public StructuredNameDataItem() { |
| 31 | super(new ContentValues()); |
| 32 | getContentValues().put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE); |
| 33 | } |
| 34 | |
| 35 | /* package */ StructuredNameDataItem(ContentValues values) { |
| 36 | super(values); |
| 37 | } |
| 38 | |
| 39 | public String getDisplayName() { |
| 40 | return getContentValues().getAsString(StructuredName.DISPLAY_NAME); |
| 41 | } |
| 42 | |
| 43 | public void setDisplayName(String name) { |
| 44 | getContentValues().put(StructuredName.DISPLAY_NAME, name); |
| 45 | } |
| 46 | |
| 47 | public String getGivenName() { |
| 48 | return getContentValues().getAsString(StructuredName.GIVEN_NAME); |
| 49 | } |
| 50 | |
| 51 | public String getFamilyName() { |
| 52 | return getContentValues().getAsString(StructuredName.FAMILY_NAME); |
| 53 | } |
| 54 | |
| 55 | public String getPrefix() { |
| 56 | return getContentValues().getAsString(StructuredName.PREFIX); |
| 57 | } |
| 58 | |
| 59 | public String getMiddleName() { |
| 60 | return getContentValues().getAsString(StructuredName.MIDDLE_NAME); |
| 61 | } |
| 62 | |
| 63 | public String getSuffix() { |
| 64 | return getContentValues().getAsString(StructuredName.SUFFIX); |
| 65 | } |
| 66 | |
| 67 | public String getPhoneticGivenName() { |
| 68 | return getContentValues().getAsString(StructuredName.PHONETIC_GIVEN_NAME); |
| 69 | } |
| 70 | |
| 71 | public String getPhoneticMiddleName() { |
| 72 | return getContentValues().getAsString(StructuredName.PHONETIC_MIDDLE_NAME); |
| 73 | } |
| 74 | |
| 75 | public String getPhoneticFamilyName() { |
| 76 | return getContentValues().getAsString(StructuredName.PHONETIC_FAMILY_NAME); |
| 77 | } |
| 78 | |
| 79 | public String getFullNameStyle() { |
| 80 | return getContentValues().getAsString(StructuredName.FULL_NAME_STYLE); |
| 81 | } |
| 82 | |
Yorke Lee | 2644d94 | 2013-10-28 11:05:43 -0700 | [diff] [blame] | 83 | public void setPhoneticFamilyName(String name) { |
| 84 | getContentValues().put(StructuredName.PHONETIC_FAMILY_NAME, name); |
| 85 | } |
| 86 | |
| 87 | public void setPhoneticMiddleName(String name) { |
| 88 | getContentValues().put(StructuredName.PHONETIC_MIDDLE_NAME, name); |
| 89 | } |
| 90 | |
| 91 | public void setPhoneticGivenName(String name) { |
| 92 | getContentValues().put(StructuredName.PHONETIC_GIVEN_NAME, name); |
| 93 | } |
Walter Jang | 8010cd5 | 2015-02-27 17:17:15 -0800 | [diff] [blame] | 94 | |
| 95 | public boolean isSuperPrimary() { |
Walter Jang | f3a95a9 | 2015-03-02 12:44:56 -0800 | [diff] [blame] | 96 | final ContentValues contentValues = getContentValues(); |
| 97 | return contentValues == null || !contentValues.containsKey(StructuredName.IS_SUPER_PRIMARY) |
| 98 | ? false : contentValues.getAsBoolean(StructuredName.IS_SUPER_PRIMARY); |
Walter Jang | 8010cd5 | 2015-02-27 17:17:15 -0800 | [diff] [blame] | 99 | } |
Yorke Lee | 2644d94 | 2013-10-28 11:05:43 -0700 | [diff] [blame] | 100 | } |