Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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.editor; |
| 18 | |
| 19 | import com.android.contacts.R; |
| 20 | import com.android.contacts.common.model.AccountTypeManager; |
| 21 | import com.android.contacts.common.model.RawContactDelta; |
| 22 | import com.android.contacts.common.model.RawContactDeltaList; |
Walter Jang | e720fde | 2015-02-17 10:54:14 -0800 | [diff] [blame] | 23 | import com.android.contacts.common.model.RawContactModifier; |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 24 | import com.android.contacts.common.model.ValuesDelta; |
| 25 | import com.android.contacts.common.model.account.AccountType; |
| 26 | import com.android.contacts.common.model.account.AccountType.EditField; |
| 27 | import com.android.contacts.common.model.dataitem.DataKind; |
Walter Jang | f46abd8 | 2015-02-20 16:52:04 -0800 | [diff] [blame] | 28 | import com.android.contacts.common.util.MaterialColorMapUtils; |
Walter Jang | 3efae4a | 2015-02-18 11:12:00 -0800 | [diff] [blame] | 29 | import com.android.contacts.editor.CompactContactEditorFragment.PhotoHandler; |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 30 | |
| 31 | import android.content.Context; |
Walter Jang | 3efae4a | 2015-02-18 11:12:00 -0800 | [diff] [blame] | 32 | import android.graphics.Bitmap; |
Walter Jang | 41b3ea1 | 2015-03-09 17:30:06 -0700 | [diff] [blame] | 33 | import android.net.Uri; |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 34 | import android.provider.ContactsContract.CommonDataKinds.Email; |
| 35 | import android.provider.ContactsContract.CommonDataKinds.GroupMembership; |
Walter Jang | 3efae4a | 2015-02-18 11:12:00 -0800 | [diff] [blame] | 36 | import android.provider.ContactsContract.CommonDataKinds.Nickname; |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 37 | import android.provider.ContactsContract.CommonDataKinds.Phone; |
| 38 | import android.provider.ContactsContract.CommonDataKinds.Photo; |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 39 | import android.provider.ContactsContract.CommonDataKinds.StructuredName; |
| 40 | import android.text.TextUtils; |
| 41 | import android.util.AttributeSet; |
| 42 | import android.util.Log; |
| 43 | import android.view.LayoutInflater; |
Walter Jang | b1c8762 | 2015-02-13 17:51:38 -0800 | [diff] [blame] | 44 | import android.view.View; |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 45 | import android.view.ViewGroup; |
| 46 | import android.widget.LinearLayout; |
| 47 | |
| 48 | import java.util.ArrayList; |
| 49 | import java.util.List; |
| 50 | |
| 51 | /** |
| 52 | * View to display information from multiple {@link RawContactDelta}s grouped together |
| 53 | * (e.g. all the phone numbers from a {@link com.android.contacts.common.model.Contact} together. |
| 54 | */ |
Walter Jang | b6ca272 | 2015-02-20 11:10:25 -0800 | [diff] [blame] | 55 | public class CompactRawContactsEditorView extends LinearLayout implements View.OnClickListener { |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 56 | |
| 57 | private static final String TAG = "CompactEditorView"; |
| 58 | |
Walter Jang | b6ca272 | 2015-02-20 11:10:25 -0800 | [diff] [blame] | 59 | /** |
| 60 | * Callbacks for hosts of {@link CompactRawContactsEditorView}s. |
| 61 | */ |
| 62 | public interface Listener { |
| 63 | |
| 64 | /** |
| 65 | * Invoked when the compact editor should be expanded to show all fields. |
| 66 | */ |
| 67 | public void onExpandEditor(); |
Walter Jang | 151f3e6 | 2015-02-26 15:29:40 -0800 | [diff] [blame] | 68 | |
| 69 | /** |
| 70 | * Invoked when the structured name editor field has changed. |
| 71 | * |
| 72 | * @param rawContactId The raw contact ID from the underlying {@link RawContactDelta}. |
| 73 | * @param valuesDelta The values from the underlying {@link RawContactDelta}. |
| 74 | */ |
| 75 | public void onNameFieldChanged(long rawContactId, ValuesDelta valuesDelta); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Marks a name as super primary when it is changed. |
| 80 | * |
| 81 | * This is for the case when two or more raw contacts with names are joined where neither is |
| 82 | * marked as super primary. If the user hits back (which causes a save) after changing the |
| 83 | * name that was arbitrarily displayed, we want that to be the name that is used. |
| 84 | * |
| 85 | * Should only be set when a super primary name does not already exist since we only show |
| 86 | * one name field. |
| 87 | */ |
| 88 | static final class NameEditorListener implements Editor.EditorListener { |
| 89 | |
| 90 | private final ValuesDelta mValuesDelta; |
| 91 | private final long mRawContactId; |
| 92 | private final Listener mListener; |
| 93 | |
| 94 | public NameEditorListener(ValuesDelta valuesDelta, long rawContactId, |
| 95 | Listener listener) { |
| 96 | mValuesDelta = valuesDelta; |
| 97 | mRawContactId = rawContactId; |
| 98 | mListener = listener; |
| 99 | } |
| 100 | |
| 101 | @Override |
| 102 | public void onRequest(int request) { |
| 103 | if (request == Editor.EditorListener.FIELD_CHANGED) { |
| 104 | mValuesDelta.setSuperPrimary(true); |
| 105 | if (mListener != null) { |
| 106 | mListener.onNameFieldChanged(mRawContactId, mValuesDelta); |
| 107 | } |
| 108 | } else if (request == Editor.EditorListener.FIELD_TURNED_EMPTY) { |
| 109 | mValuesDelta.setSuperPrimary(false); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | @Override |
| 114 | public void onDeleteRequested(Editor editor) { |
| 115 | } |
Walter Jang | b6ca272 | 2015-02-20 11:10:25 -0800 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | private Listener mListener; |
| 119 | |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 120 | private AccountTypeManager mAccountTypeManager; |
| 121 | private LayoutInflater mLayoutInflater; |
Walter Jang | d35e5ef | 2015-02-24 09:18:16 -0800 | [diff] [blame] | 122 | |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 123 | private ViewIdGenerator mViewIdGenerator; |
Walter Jang | f46abd8 | 2015-02-20 16:52:04 -0800 | [diff] [blame] | 124 | private MaterialColorMapUtils.MaterialPalette mMaterialPalette; |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 125 | |
Walter Jang | a5e4bb2 | 2015-02-24 13:08:16 -0800 | [diff] [blame] | 126 | private CompactPhotoEditorView mPhoto; |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 127 | private ViewGroup mNames; |
Walter Jang | b1c8762 | 2015-02-13 17:51:38 -0800 | [diff] [blame] | 128 | private ViewGroup mPhoneticNames; |
| 129 | private ViewGroup mNicknames; |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 130 | private ViewGroup mPhoneNumbers; |
| 131 | private ViewGroup mEmails; |
| 132 | private ViewGroup mOther; |
Walter Jang | b6ca272 | 2015-02-20 11:10:25 -0800 | [diff] [blame] | 133 | private View mMoreFields; |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 134 | |
Walter Jang | 151f3e6 | 2015-02-26 15:29:40 -0800 | [diff] [blame] | 135 | // The ValuesDelta for the non super primary name that was displayed to the user. |
| 136 | private ValuesDelta mNameValuesDelta; |
| 137 | |
Walter Jang | 3efae4a | 2015-02-18 11:12:00 -0800 | [diff] [blame] | 138 | private long mPhotoRawContactId; |
| 139 | |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 140 | public CompactRawContactsEditorView(Context context) { |
| 141 | super(context); |
| 142 | } |
| 143 | |
| 144 | public CompactRawContactsEditorView(Context context, AttributeSet attrs) { |
| 145 | super(context, attrs); |
| 146 | } |
| 147 | |
Walter Jang | b6ca272 | 2015-02-20 11:10:25 -0800 | [diff] [blame] | 148 | /** |
| 149 | * Sets the receiver for {@link CompactRawContactsEditorView} callbacks. |
| 150 | */ |
| 151 | public void setListener(Listener listener) { |
| 152 | mListener = listener; |
| 153 | } |
| 154 | |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 155 | @Override |
| 156 | protected void onFinishInflate() { |
| 157 | super.onFinishInflate(); |
| 158 | |
| 159 | mAccountTypeManager = AccountTypeManager.getInstance(getContext()); |
| 160 | mLayoutInflater = (LayoutInflater) |
| 161 | getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
| 162 | |
Walter Jang | a5e4bb2 | 2015-02-24 13:08:16 -0800 | [diff] [blame] | 163 | mPhoto = (CompactPhotoEditorView) findViewById(R.id.photo_editor); |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 164 | mNames = (LinearLayout) findViewById(R.id.names); |
Walter Jang | b1c8762 | 2015-02-13 17:51:38 -0800 | [diff] [blame] | 165 | mPhoneticNames = (LinearLayout) findViewById(R.id.phonetic_names); |
| 166 | mNicknames = (LinearLayout) findViewById(R.id.nicknames); |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 167 | mPhoneNumbers = (LinearLayout) findViewById(R.id.phone_numbers); |
| 168 | mEmails = (LinearLayout) findViewById(R.id.emails); |
| 169 | mOther = (LinearLayout) findViewById(R.id.other); |
Walter Jang | b6ca272 | 2015-02-20 11:10:25 -0800 | [diff] [blame] | 170 | mMoreFields = findViewById(R.id.more_fields); |
| 171 | mMoreFields.setOnClickListener(this); |
| 172 | } |
| 173 | |
Walter Jang | b6ca272 | 2015-02-20 11:10:25 -0800 | [diff] [blame] | 174 | @Override |
| 175 | public void onClick(View view) { |
| 176 | if (view.getId() == R.id.more_fields && mListener != null ) { |
Walter Jang | 151f3e6 | 2015-02-26 15:29:40 -0800 | [diff] [blame] | 177 | // We mark the name that was displayed as super primary before expanding |
| 178 | // so that a save on the expanded editor (without a name change) does not |
| 179 | // cause the displayed name to change. |
| 180 | if (mNameValuesDelta != null) { |
| 181 | mNameValuesDelta.setSuperPrimary(true); |
| 182 | } |
| 183 | |
Walter Jang | b6ca272 | 2015-02-20 11:10:25 -0800 | [diff] [blame] | 184 | mListener.onExpandEditor(); |
| 185 | } |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | @Override |
| 189 | public void setEnabled(boolean enabled) { |
| 190 | super.setEnabled(enabled); |
| 191 | setEnabled(enabled, mNames); |
Walter Jang | b1c8762 | 2015-02-13 17:51:38 -0800 | [diff] [blame] | 192 | setEnabled(enabled, mPhoneticNames); |
| 193 | setEnabled(enabled, mNicknames); |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 194 | setEnabled(enabled, mPhoneNumbers); |
| 195 | setEnabled(enabled, mEmails); |
| 196 | setEnabled(enabled, mOther); |
| 197 | } |
| 198 | |
| 199 | private void setEnabled(boolean enabled, ViewGroup viewGroup) { |
| 200 | if (viewGroup != null) { |
| 201 | final int childCount = viewGroup.getChildCount(); |
| 202 | for (int i = 0; i < childCount; i++) { |
| 203 | viewGroup.getChildAt(i).setEnabled(enabled); |
| 204 | } |
| 205 | } |
| 206 | } |
| 207 | |
Walter Jang | 3efae4a | 2015-02-18 11:12:00 -0800 | [diff] [blame] | 208 | /** |
Walter Jang | a5e4bb2 | 2015-02-24 13:08:16 -0800 | [diff] [blame] | 209 | * Pass through to {@link CompactPhotoEditorView#setPhotoHandler}. |
Walter Jang | 3efae4a | 2015-02-18 11:12:00 -0800 | [diff] [blame] | 210 | */ |
| 211 | public void setPhotoHandler(PhotoHandler photoHandler) { |
Walter Jang | a5e4bb2 | 2015-02-24 13:08:16 -0800 | [diff] [blame] | 212 | mPhoto.setPhotoHandler(photoHandler); |
Walter Jang | 3efae4a | 2015-02-18 11:12:00 -0800 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | /** |
Walter Jang | a5e4bb2 | 2015-02-24 13:08:16 -0800 | [diff] [blame] | 216 | * Pass through to {@link CompactPhotoEditorView#setPhoto}. |
Walter Jang | 3efae4a | 2015-02-18 11:12:00 -0800 | [diff] [blame] | 217 | */ |
| 218 | public void setPhoto(Bitmap bitmap) { |
Walter Jang | a5e4bb2 | 2015-02-24 13:08:16 -0800 | [diff] [blame] | 219 | mPhoto.setPhoto(bitmap); |
Walter Jang | 3efae4a | 2015-02-18 11:12:00 -0800 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | /** |
Walter Jang | 41b3ea1 | 2015-03-09 17:30:06 -0700 | [diff] [blame] | 223 | * Pass through to {@link CompactPhotoEditorView#setFullSizedPhoto(Uri)}. |
| 224 | */ |
| 225 | public void setFullSizePhoto(Uri photoUri) { |
| 226 | mPhoto.setFullSizedPhoto(photoUri); |
| 227 | } |
| 228 | |
| 229 | /** |
Walter Jang | a5e4bb2 | 2015-02-24 13:08:16 -0800 | [diff] [blame] | 230 | * Pass through to {@link CompactPhotoEditorView#isWritablePhotoSet}. |
Walter Jang | 3efae4a | 2015-02-18 11:12:00 -0800 | [diff] [blame] | 231 | */ |
| 232 | public boolean isWritablePhotoSet() { |
Walter Jang | a5e4bb2 | 2015-02-24 13:08:16 -0800 | [diff] [blame] | 233 | return mPhoto.isWritablePhotoSet(); |
Walter Jang | 3efae4a | 2015-02-18 11:12:00 -0800 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | /** |
Walter Jang | 3efae4a | 2015-02-18 11:12:00 -0800 | [diff] [blame] | 237 | * Get the raw contact ID for the CompactHeaderView photo. |
| 238 | */ |
Walter Jang | 3efae4a | 2015-02-18 11:12:00 -0800 | [diff] [blame] | 239 | public long getPhotoRawContactId() { |
| 240 | return mPhotoRawContactId; |
| 241 | } |
| 242 | |
Walter Jang | d35e5ef | 2015-02-24 09:18:16 -0800 | [diff] [blame] | 243 | public StructuredNameEditorView getStructuredNameEditorView() { |
| 244 | // We only ever show one StructuredName |
| 245 | return mNames.getChildCount() == 0 |
| 246 | ? null : (StructuredNameEditorView) mNames.getChildAt(0); |
| 247 | } |
| 248 | |
Walter Jang | bf63a6d | 2015-05-05 09:14:35 -0700 | [diff] [blame] | 249 | public PhoneticNameEditorView getFirstPhoneticNameEditorView() { |
| 250 | // There should only ever be one phonetic name |
| 251 | return mPhoneticNames.getChildCount() == 0 |
| 252 | ? null : (PhoneticNameEditorView) mPhoneticNames.getChildAt(0); |
| 253 | } |
| 254 | |
Walter Jang | d35e5ef | 2015-02-24 09:18:16 -0800 | [diff] [blame] | 255 | public View getAggregationAnchorView() { |
| 256 | // Since there is only one structured name we can just return it as the anchor for |
| 257 | // the aggregation suggestions popup |
| 258 | if (mNames.getChildCount() == 0) { |
| 259 | return null; |
| 260 | } |
| 261 | return mNames.getChildAt(0).findViewById(R.id.anchor_view); |
| 262 | } |
| 263 | |
Walter Jang | f46abd8 | 2015-02-20 16:52:04 -0800 | [diff] [blame] | 264 | public void setState(RawContactDeltaList rawContactDeltas, |
| 265 | MaterialColorMapUtils.MaterialPalette materialPalette, |
Walter Jang | ac679af | 2015-06-01 12:17:06 -0700 | [diff] [blame^] | 266 | ViewIdGenerator viewIdGenerator, long photoId) { |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 267 | mNames.removeAllViews(); |
Walter Jang | b1c8762 | 2015-02-13 17:51:38 -0800 | [diff] [blame] | 268 | mPhoneticNames.removeAllViews(); |
| 269 | mNicknames.removeAllViews(); |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 270 | mPhoneNumbers.removeAllViews(); |
| 271 | mEmails.removeAllViews(); |
| 272 | mOther.removeAllViews(); |
| 273 | |
| 274 | if (rawContactDeltas == null || rawContactDeltas.isEmpty()) { |
| 275 | return; |
| 276 | } |
| 277 | |
| 278 | mViewIdGenerator = viewIdGenerator; |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 279 | setId(mViewIdGenerator.getId(rawContactDeltas.get(0), /* dataKind =*/ null, |
| 280 | /* valuesDelta =*/ null, ViewIdGenerator.NO_VIEW_INDEX)); |
Walter Jang | f46abd8 | 2015-02-20 16:52:04 -0800 | [diff] [blame] | 281 | mMaterialPalette = materialPalette; |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 282 | |
Walter Jang | bf63a6d | 2015-05-05 09:14:35 -0700 | [diff] [blame] | 283 | vlog("Setting compact editor state from " + rawContactDeltas); |
Walter Jang | ac679af | 2015-06-01 12:17:06 -0700 | [diff] [blame^] | 284 | addPhotoView(rawContactDeltas, viewIdGenerator, photoId); |
Walter Jang | 1044645 | 2015-02-20 13:51:16 -0800 | [diff] [blame] | 285 | addStructuredNameView(rawContactDeltas); |
Walter Jang | 3efae4a | 2015-02-18 11:12:00 -0800 | [diff] [blame] | 286 | addEditorViews(rawContactDeltas); |
Walter Jang | e720fde | 2015-02-17 10:54:14 -0800 | [diff] [blame] | 287 | removeExtraEmptyTextFields(mPhoneNumbers); |
| 288 | removeExtraEmptyTextFields(mEmails); |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 289 | } |
| 290 | |
Walter Jang | 151f3e6 | 2015-02-26 15:29:40 -0800 | [diff] [blame] | 291 | private void addPhotoView(RawContactDeltaList rawContactDeltas, |
Walter Jang | ac679af | 2015-06-01 12:17:06 -0700 | [diff] [blame^] | 292 | ViewIdGenerator viewIdGenerator, long photoId) { |
| 293 | // Look for a match for the photo ID that was passed in |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 294 | for (RawContactDelta rawContactDelta : rawContactDeltas) { |
Walter Jang | 3b21027 | 2015-03-04 11:34:11 -0800 | [diff] [blame] | 295 | if (!rawContactDelta.isVisible()) continue; |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 296 | final AccountType accountType = rawContactDelta.getAccountType(mAccountTypeManager); |
Walter Jang | e720fde | 2015-02-17 10:54:14 -0800 | [diff] [blame] | 297 | |
Walter Jang | 3efae4a | 2015-02-18 11:12:00 -0800 | [diff] [blame] | 298 | // Make sure we have a photo |
| 299 | RawContactModifier.ensureKindExists( |
| 300 | rawContactDelta, accountType, Photo.CONTENT_ITEM_TYPE); |
| 301 | |
Walter Jang | 3b21027 | 2015-03-04 11:34:11 -0800 | [diff] [blame] | 302 | // Look for a non-empty super primary photo |
Walter Jang | 3efae4a | 2015-02-18 11:12:00 -0800 | [diff] [blame] | 303 | final DataKind dataKind = accountType.getKindForMimetype(Photo.CONTENT_ITEM_TYPE); |
| 304 | if (dataKind != null) { |
Walter Jang | ac679af | 2015-06-01 12:17:06 -0700 | [diff] [blame^] | 305 | for (ValuesDelta valuesDelta |
| 306 | : rawContactDelta.getMimeEntries(Photo.CONTENT_ITEM_TYPE)) { |
| 307 | if (valuesDelta != null && valuesDelta.getId() != null |
| 308 | && valuesDelta.getId().equals(photoId)) { |
| 309 | mPhotoRawContactId = rawContactDelta.getRawContactId(); |
| 310 | mPhoto.setValues(dataKind, valuesDelta, rawContactDelta, |
| 311 | /* readOnly =*/ !dataKind.editable, mMaterialPalette, |
| 312 | viewIdGenerator); |
| 313 | return; |
| 314 | } |
| 315 | } |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | // Look for a non-empty super primary photo |
| 320 | for (RawContactDelta rawContactDelta : rawContactDeltas) { |
| 321 | if (!rawContactDelta.isVisible()) continue; |
| 322 | final AccountType accountType = rawContactDelta.getAccountType(mAccountTypeManager); |
| 323 | final DataKind dataKind = accountType.getKindForMimetype(Photo.CONTENT_ITEM_TYPE); |
| 324 | if (dataKind != null) { |
Walter Jang | 3b21027 | 2015-03-04 11:34:11 -0800 | [diff] [blame] | 325 | final ValuesDelta valuesDelta = getNonEmptySuperPrimaryValuesDeltas( |
| 326 | rawContactDelta, Photo.CONTENT_ITEM_TYPE, dataKind); |
| 327 | if (valuesDelta != null) { |
Walter Jang | 3efae4a | 2015-02-18 11:12:00 -0800 | [diff] [blame] | 328 | mPhotoRawContactId = rawContactDelta.getRawContactId(); |
Walter Jang | a5e4bb2 | 2015-02-24 13:08:16 -0800 | [diff] [blame] | 329 | mPhoto.setValues(dataKind, valuesDelta, rawContactDelta, |
Walter Jang | 3b21027 | 2015-03-04 11:34:11 -0800 | [diff] [blame] | 330 | /* readOnly =*/ !dataKind.editable, mMaterialPalette, |
| 331 | viewIdGenerator); |
Walter Jang | 3efae4a | 2015-02-18 11:12:00 -0800 | [diff] [blame] | 332 | return; |
| 333 | } |
| 334 | } |
| 335 | } |
Walter Jang | 3b21027 | 2015-03-04 11:34:11 -0800 | [diff] [blame] | 336 | // We didn't find a non-empty super primary photo, use the first non-empty one |
| 337 | for (RawContactDelta rawContactDelta : rawContactDeltas) { |
| 338 | if (!rawContactDelta.isVisible()) continue; |
| 339 | final AccountType accountType = rawContactDelta.getAccountType(mAccountTypeManager); |
| 340 | final DataKind dataKind = accountType.getKindForMimetype(Photo.CONTENT_ITEM_TYPE); |
| 341 | if (dataKind != null) { |
| 342 | final List<ValuesDelta> valuesDeltas = getNonEmptyValuesDeltas( |
| 343 | rawContactDelta, Photo.CONTENT_ITEM_TYPE, dataKind); |
| 344 | if (valuesDeltas != null && !valuesDeltas.isEmpty()) { |
| 345 | mPhotoRawContactId = rawContactDelta.getRawContactId(); |
| 346 | mPhoto.setValues(dataKind, valuesDeltas.get(0), rawContactDelta, |
| 347 | /* readOnly =*/ !dataKind.editable, mMaterialPalette, |
| 348 | viewIdGenerator); |
| 349 | return; |
| 350 | } |
| 351 | } |
| 352 | } |
| 353 | // No suitable non-empty photo |
| 354 | for (RawContactDelta rawContactDelta : rawContactDeltas) { |
| 355 | if (!rawContactDelta.isVisible()) continue; |
| 356 | final AccountType accountType = rawContactDelta.getAccountType(mAccountTypeManager); |
| 357 | final DataKind dataKind = accountType.getKindForMimetype(Photo.CONTENT_ITEM_TYPE); |
| 358 | if (dataKind != null) { |
| 359 | final ValuesDelta valuesDelta = rawContactDelta.getSuperPrimaryEntry( |
| 360 | dataKind.mimeType, /* forceSelection =*/ true); |
| 361 | if (valuesDelta != null) { |
| 362 | mPhotoRawContactId = rawContactDelta.getRawContactId(); |
| 363 | mPhoto.setValues(dataKind, valuesDelta, rawContactDelta, |
| 364 | /* readOnly =*/ !dataKind.editable, mMaterialPalette, |
| 365 | viewIdGenerator); |
| 366 | return; |
| 367 | } |
| 368 | } |
| 369 | } |
| 370 | // Should not happen since we ensure the kind exists but if we unexpectedly get here |
| 371 | // we must remove the photo section so that it does not take up the entire view |
| 372 | mPhoto.setVisibility(View.GONE); |
Walter Jang | 3efae4a | 2015-02-18 11:12:00 -0800 | [diff] [blame] | 373 | } |
| 374 | |
Walter Jang | 1044645 | 2015-02-20 13:51:16 -0800 | [diff] [blame] | 375 | private void addStructuredNameView(RawContactDeltaList rawContactDeltas) { |
| 376 | for (RawContactDelta rawContactDelta : rawContactDeltas) { |
Walter Jang | 151f3e6 | 2015-02-26 15:29:40 -0800 | [diff] [blame] | 377 | if (!rawContactDelta.isVisible()) continue; |
Walter Jang | 1044645 | 2015-02-20 13:51:16 -0800 | [diff] [blame] | 378 | final AccountType accountType = rawContactDelta.getAccountType(mAccountTypeManager); |
| 379 | |
| 380 | // Make sure we have a structured name |
| 381 | RawContactModifier.ensureKindExists( |
| 382 | rawContactDelta, accountType, StructuredName.CONTENT_ITEM_TYPE); |
| 383 | |
Walter Jang | 151f3e6 | 2015-02-26 15:29:40 -0800 | [diff] [blame] | 384 | // Note use of pseudo mime type to get the DataKind and StructuredName to get value |
Walter Jang | 1044645 | 2015-02-20 13:51:16 -0800 | [diff] [blame] | 385 | final DataKind dataKind = accountType.getKindForMimetype( |
Walter Jang | 151f3e6 | 2015-02-26 15:29:40 -0800 | [diff] [blame] | 386 | DataKind.PSEUDO_MIME_TYPE_DISPLAY_NAME); |
| 387 | if (dataKind == null || !dataKind.editable) continue; |
| 388 | |
| 389 | final ValuesDelta superPrimaryValuesDelta = getNonEmptySuperPrimaryValuesDeltas( |
| 390 | rawContactDelta, StructuredName.CONTENT_ITEM_TYPE, dataKind); |
| 391 | if (superPrimaryValuesDelta != null) { |
| 392 | // Our first preference is for a non-empty super primary name |
Walter Jang | a26490b | 2015-05-27 13:08:24 -0700 | [diff] [blame] | 393 | final NameEditorListener nameEditorListener = new NameEditorListener( |
| 394 | superPrimaryValuesDelta, rawContactDelta.getRawContactId(), mListener); |
Walter Jang | 151f3e6 | 2015-02-26 15:29:40 -0800 | [diff] [blame] | 395 | mNames.addView(inflateStructuredNameEditorView(mNames, accountType, |
Walter Jang | a26490b | 2015-05-27 13:08:24 -0700 | [diff] [blame] | 396 | superPrimaryValuesDelta, rawContactDelta, nameEditorListener)); |
Walter Jang | 151f3e6 | 2015-02-26 15:29:40 -0800 | [diff] [blame] | 397 | return; |
| 398 | } |
| 399 | } |
| 400 | // We didn't find a super primary name |
| 401 | for (RawContactDelta rawContactDelta : rawContactDeltas) { |
| 402 | if (!rawContactDelta.isVisible()) continue; |
| 403 | final AccountType accountType = rawContactDelta.getAccountType(mAccountTypeManager); |
| 404 | |
| 405 | final DataKind dataKind = accountType.getKindForMimetype( |
| 406 | DataKind.PSEUDO_MIME_TYPE_DISPLAY_NAME); |
| 407 | if (dataKind == null || !dataKind.editable) continue; |
| 408 | |
| 409 | final List<ValuesDelta> nonEmptyValuesDeltas = getNonEmptyValuesDeltas( |
| 410 | rawContactDelta, StructuredName.CONTENT_ITEM_TYPE, dataKind); |
| 411 | if (nonEmptyValuesDeltas != null && !nonEmptyValuesDeltas.isEmpty()) { |
| 412 | // Take the first non-empty name, also make it super primary before expanding to the |
| 413 | // full editor (see #onCLick) so that name does not change if the user saves from |
| 414 | // the fully expanded editor. |
| 415 | mNameValuesDelta = nonEmptyValuesDeltas.get(0); |
| 416 | final NameEditorListener nameEditorListener = new NameEditorListener( |
| 417 | mNameValuesDelta, rawContactDelta.getRawContactId(), mListener); |
| 418 | mNames.addView(inflateStructuredNameEditorView(mNames, accountType, |
| 419 | mNameValuesDelta, rawContactDelta, nameEditorListener)); |
| 420 | return; |
| 421 | } |
| 422 | } |
| 423 | for (RawContactDelta rawContactDelta : rawContactDeltas) { |
| 424 | if (!rawContactDelta.isVisible()) continue; |
| 425 | final AccountType accountType = rawContactDelta.getAccountType(mAccountTypeManager); |
| 426 | |
| 427 | final DataKind dataKind = accountType.getKindForMimetype( |
| 428 | DataKind.PSEUDO_MIME_TYPE_DISPLAY_NAME); |
| 429 | if (dataKind == null || !dataKind.editable) continue; |
| 430 | |
| 431 | // Fall back to the first entry |
| 432 | final ArrayList<ValuesDelta> valuesDeltas = rawContactDelta.getMimeEntries( |
Walter Jang | 1044645 | 2015-02-20 13:51:16 -0800 | [diff] [blame] | 433 | StructuredName.CONTENT_ITEM_TYPE); |
Walter Jang | 151f3e6 | 2015-02-26 15:29:40 -0800 | [diff] [blame] | 434 | if (valuesDeltas != null && !valuesDeltas.isEmpty()) { |
| 435 | mNameValuesDelta = valuesDeltas.get(0); |
| 436 | final NameEditorListener nameEditorListener = new NameEditorListener( |
| 437 | mNameValuesDelta, rawContactDelta.getRawContactId(), mListener); |
| 438 | mNames.addView(inflateStructuredNameEditorView(mNames, accountType, |
| 439 | mNameValuesDelta, rawContactDelta, nameEditorListener)); |
| 440 | return; |
Walter Jang | 1044645 | 2015-02-20 13:51:16 -0800 | [diff] [blame] | 441 | } |
| 442 | } |
| 443 | } |
| 444 | |
Walter Jang | 3efae4a | 2015-02-18 11:12:00 -0800 | [diff] [blame] | 445 | private void addEditorViews(RawContactDeltaList rawContactDeltas) { |
| 446 | for (RawContactDelta rawContactDelta : rawContactDeltas) { |
| 447 | if (!rawContactDelta.isVisible()) { |
| 448 | continue; |
| 449 | } |
| 450 | final AccountType accountType = rawContactDelta.getAccountType(mAccountTypeManager); |
| 451 | |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 452 | for (DataKind dataKind : accountType.getSortedDataKinds()) { |
| 453 | if (!dataKind.editable) { |
| 454 | continue; |
| 455 | } |
| 456 | final String mimeType = dataKind.mimeType; |
Walter Jang | bf63a6d | 2015-05-05 09:14:35 -0700 | [diff] [blame] | 457 | vlog(mimeType + " " + dataKind.fieldList.size() + " field(s)"); |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 458 | if (Photo.CONTENT_ITEM_TYPE.equals(mimeType) |
Walter Jang | 1044645 | 2015-02-20 13:51:16 -0800 | [diff] [blame] | 459 | || StructuredName.CONTENT_ITEM_TYPE.equals(mimeType) |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 460 | || GroupMembership.CONTENT_ITEM_TYPE.equals(mimeType)) { |
Walter Jang | 151f3e6 | 2015-02-26 15:29:40 -0800 | [diff] [blame] | 461 | // Photos and structured names are handled separately and |
| 462 | // group membership is not supported |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 463 | continue; |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 464 | } else if (DataKind.PSEUDO_MIME_TYPE_PHONETIC_NAME.equals(mimeType)) { |
Walter Jang | 151f3e6 | 2015-02-26 15:29:40 -0800 | [diff] [blame] | 465 | // Only add phonetic names if there is a non-empty one. Note the use of |
| 466 | // StructuredName mimeType below, even though we matched a pseudo mime type. |
Walter Jang | 3a37a1a | 2015-03-04 07:41:32 -0800 | [diff] [blame] | 467 | final ValuesDelta valuesDelta = rawContactDelta.getSuperPrimaryEntry( |
| 468 | StructuredName.CONTENT_ITEM_TYPE, /* forceSelection =*/ true); |
| 469 | if (hasNonEmptyValue(dataKind, valuesDelta)) { |
| 470 | mPhoneticNames.addView(inflatePhoneticNameEditorView( |
| 471 | mPhoneticNames, accountType, valuesDelta, rawContactDelta)); |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 472 | } |
| 473 | } else if (Nickname.CONTENT_ITEM_TYPE.equals(mimeType)) { |
Walter Jang | 151f3e6 | 2015-02-26 15:29:40 -0800 | [diff] [blame] | 474 | // Only add nicknames if there is a non-empty one |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 475 | if (hasNonEmptyValuesDelta(rawContactDelta, mimeType, dataKind)) { |
Walter Jang | 28c98b7 | 2015-06-01 15:56:37 -0700 | [diff] [blame] | 476 | mNicknames.addView(inflateKindSectionView(mNicknames, dataKind, |
| 477 | rawContactDelta, /* showOneEmptyEditor =*/ false)); |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 478 | } |
| 479 | } else if (Phone.CONTENT_ITEM_TYPE.equals(mimeType)) { |
Walter Jang | 28c98b7 | 2015-06-01 15:56:37 -0700 | [diff] [blame] | 480 | mPhoneNumbers.addView(inflateKindSectionView(mPhoneNumbers, dataKind, |
| 481 | rawContactDelta, /* showOneEmptyEditor =*/ true)); |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 482 | } else if (Email.CONTENT_ITEM_TYPE.equals(mimeType)) { |
Walter Jang | 28c98b7 | 2015-06-01 15:56:37 -0700 | [diff] [blame] | 483 | mEmails.addView(inflateKindSectionView(mEmails, dataKind, rawContactDelta, |
| 484 | /* showOneEmptyEditor =*/ true)); |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 485 | } else if (hasNonEmptyValuesDelta(rawContactDelta, mimeType, dataKind)) { |
Walter Jang | 28c98b7 | 2015-06-01 15:56:37 -0700 | [diff] [blame] | 486 | mOther.addView(inflateKindSectionView(mOther, dataKind, rawContactDelta, |
| 487 | /* showOneEmptyEditor =*/ false)); |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 488 | } |
| 489 | } |
| 490 | } |
| 491 | } |
| 492 | |
Walter Jang | e720fde | 2015-02-17 10:54:14 -0800 | [diff] [blame] | 493 | // TODO: avoid inflating extra views and deleting them |
| 494 | private void removeExtraEmptyTextFields(ViewGroup viewGroup) { |
| 495 | // If there is one (or less) editors, leave it whether it is empty or not |
| 496 | if (viewGroup.getChildCount() <= 1) { |
Walter Jang | b1c8762 | 2015-02-13 17:51:38 -0800 | [diff] [blame] | 497 | return; |
| 498 | } |
Walter Jang | e720fde | 2015-02-17 10:54:14 -0800 | [diff] [blame] | 499 | // Determine if there are any non-empty editors |
| 500 | boolean hasAtLeastOneNonEmptyEditorView = false; |
| 501 | for (int i = 0; i < viewGroup.getChildCount(); i++) { |
| 502 | if (!isEmptyEditorView(viewGroup.getChildAt(i))) { |
| 503 | hasAtLeastOneNonEmptyEditorView = true; |
Walter Jang | b1c8762 | 2015-02-13 17:51:38 -0800 | [diff] [blame] | 504 | break; |
| 505 | } |
| 506 | } |
Walter Jang | e720fde | 2015-02-17 10:54:14 -0800 | [diff] [blame] | 507 | if (hasAtLeastOneNonEmptyEditorView) { |
| 508 | // There is at least one non-empty editor, remove all the empty ones |
| 509 | for (int i = 0; i < viewGroup.getChildCount(); i++) { |
| 510 | if (isEmptyEditorView(viewGroup.getChildAt(i))) { |
| 511 | viewGroup.getChildAt(i).setVisibility(View.GONE); |
Walter Jang | b1c8762 | 2015-02-13 17:51:38 -0800 | [diff] [blame] | 512 | } |
| 513 | } |
| 514 | } else { |
Walter Jang | e720fde | 2015-02-17 10:54:14 -0800 | [diff] [blame] | 515 | // There is no non-empty editor, keep the first empty view and remove the rest |
| 516 | for (int i = 1; i < viewGroup.getChildCount(); i++) { |
| 517 | viewGroup.getChildAt(i).setVisibility(View.GONE); |
Walter Jang | b1c8762 | 2015-02-13 17:51:38 -0800 | [diff] [blame] | 518 | } |
| 519 | } |
| 520 | } |
| 521 | |
Walter Jang | e720fde | 2015-02-17 10:54:14 -0800 | [diff] [blame] | 522 | private static boolean isEmptyEditorView(View view) { |
| 523 | if (view instanceof TextFieldsEditorView) { |
| 524 | final TextFieldsEditorView textFieldsEditorView = (TextFieldsEditorView) view; |
| 525 | return textFieldsEditorView.isEmpty(); |
| 526 | } |
| 527 | if (view instanceof KindSectionView) { |
| 528 | final KindSectionView kindSectionView = (KindSectionView) view; |
| 529 | return kindSectionView.hasEmptyEditor(); |
| 530 | } |
| 531 | return false; |
| 532 | } |
| 533 | |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 534 | private static boolean hasNonEmptyValuesDelta(RawContactDelta rawContactDelta, |
| 535 | String mimeType, DataKind dataKind) { |
| 536 | return !getNonEmptyValuesDeltas(rawContactDelta, mimeType, dataKind).isEmpty(); |
| 537 | } |
| 538 | |
Walter Jang | 151f3e6 | 2015-02-26 15:29:40 -0800 | [diff] [blame] | 539 | private static ValuesDelta getNonEmptySuperPrimaryValuesDeltas(RawContactDelta rawContactDelta, |
| 540 | String mimeType, DataKind dataKind) { |
| 541 | for (ValuesDelta valuesDelta : getNonEmptyValuesDeltas( |
| 542 | rawContactDelta, mimeType, dataKind)) { |
| 543 | if (valuesDelta.isSuperPrimary()) { |
| 544 | return valuesDelta; |
| 545 | } |
| 546 | } |
| 547 | return null; |
| 548 | } |
| 549 | |
| 550 | static List<ValuesDelta> getNonEmptyValuesDeltas(RawContactDelta rawContactDelta, |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 551 | String mimeType, DataKind dataKind) { |
| 552 | final List<ValuesDelta> result = new ArrayList<>(); |
| 553 | if (rawContactDelta == null) { |
Walter Jang | bf63a6d | 2015-05-05 09:14:35 -0700 | [diff] [blame] | 554 | vlog("Null RawContactDelta"); |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 555 | return result; |
| 556 | } |
| 557 | if (!rawContactDelta.hasMimeEntries(mimeType)) { |
Walter Jang | bf63a6d | 2015-05-05 09:14:35 -0700 | [diff] [blame] | 558 | vlog("No ValueDeltas"); |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 559 | return result; |
| 560 | } |
| 561 | for (ValuesDelta valuesDelta : rawContactDelta.getMimeEntries(mimeType)) { |
Walter Jang | 3a37a1a | 2015-03-04 07:41:32 -0800 | [diff] [blame] | 562 | if (hasNonEmptyValue(dataKind, valuesDelta)) { |
| 563 | result.add(valuesDelta); |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 564 | } |
| 565 | } |
| 566 | return result; |
| 567 | } |
| 568 | |
Walter Jang | 3a37a1a | 2015-03-04 07:41:32 -0800 | [diff] [blame] | 569 | private static boolean hasNonEmptyValue(DataKind dataKind, ValuesDelta valuesDelta) { |
| 570 | if (valuesDelta == null) { |
Walter Jang | bf63a6d | 2015-05-05 09:14:35 -0700 | [diff] [blame] | 571 | vlog("Null valuesDelta"); |
Walter Jang | 3a37a1a | 2015-03-04 07:41:32 -0800 | [diff] [blame] | 572 | return false; |
| 573 | } |
| 574 | for (EditField editField : dataKind.fieldList) { |
| 575 | final String column = editField.column; |
| 576 | final String value = valuesDelta == null ? null : valuesDelta.getAsString(column); |
Walter Jang | bf63a6d | 2015-05-05 09:14:35 -0700 | [diff] [blame] | 577 | vlog("Field " + column + " empty=" + TextUtils.isEmpty(value) + " value=" + value); |
Walter Jang | 3a37a1a | 2015-03-04 07:41:32 -0800 | [diff] [blame] | 578 | if (!TextUtils.isEmpty(value)) { |
| 579 | return true; |
| 580 | } |
| 581 | } |
| 582 | return false; |
| 583 | } |
| 584 | |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 585 | private StructuredNameEditorView inflateStructuredNameEditorView(ViewGroup viewGroup, |
Walter Jang | 151f3e6 | 2015-02-26 15:29:40 -0800 | [diff] [blame] | 586 | AccountType accountType, ValuesDelta valuesDelta, RawContactDelta rawContactDelta, |
| 587 | NameEditorListener nameEditorListener) { |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 588 | final StructuredNameEditorView result = (StructuredNameEditorView) mLayoutInflater.inflate( |
| 589 | R.layout.structured_name_editor_view, viewGroup, /* attachToRoot =*/ false); |
Walter Jang | 151f3e6 | 2015-02-26 15:29:40 -0800 | [diff] [blame] | 590 | if (nameEditorListener != null) { |
| 591 | result.setEditorListener(nameEditorListener); |
| 592 | } |
Walter Jang | 3a37a1a | 2015-03-04 07:41:32 -0800 | [diff] [blame] | 593 | result.setDeletable(false); |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 594 | result.setValues( |
| 595 | accountType.getKindForMimetype(DataKind.PSEUDO_MIME_TYPE_DISPLAY_NAME), |
| 596 | valuesDelta, |
| 597 | rawContactDelta, |
| 598 | /* readOnly =*/ false, |
| 599 | mViewIdGenerator); |
| 600 | return result; |
| 601 | } |
| 602 | |
| 603 | private PhoneticNameEditorView inflatePhoneticNameEditorView(ViewGroup viewGroup, |
| 604 | AccountType accountType, ValuesDelta valuesDelta, RawContactDelta rawContactDelta) { |
| 605 | final PhoneticNameEditorView result = (PhoneticNameEditorView) mLayoutInflater.inflate( |
| 606 | R.layout.phonetic_name_editor_view, viewGroup, /* attachToRoot =*/ false); |
Walter Jang | 3a37a1a | 2015-03-04 07:41:32 -0800 | [diff] [blame] | 607 | result.setDeletable(false); |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 608 | result.setValues( |
| 609 | accountType.getKindForMimetype(DataKind.PSEUDO_MIME_TYPE_PHONETIC_NAME), |
| 610 | valuesDelta, |
| 611 | rawContactDelta, |
| 612 | /* readOnly =*/ false, |
| 613 | mViewIdGenerator); |
| 614 | return result; |
| 615 | } |
| 616 | |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 617 | private KindSectionView inflateKindSectionView(ViewGroup viewGroup, DataKind dataKind, |
Walter Jang | 28c98b7 | 2015-06-01 15:56:37 -0700 | [diff] [blame] | 618 | RawContactDelta rawContactDelta, boolean showOneEmptyEditor) { |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 619 | final KindSectionView result = (KindSectionView) mLayoutInflater.inflate( |
| 620 | R.layout.item_kind_section, viewGroup, /* attachToRoot =*/ false); |
| 621 | result.setState( |
| 622 | dataKind, |
| 623 | rawContactDelta, |
| 624 | /* readOnly =*/ false, |
Walter Jang | 28c98b7 | 2015-06-01 15:56:37 -0700 | [diff] [blame] | 625 | showOneEmptyEditor, |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 626 | mViewIdGenerator); |
| 627 | return result; |
| 628 | } |
| 629 | |
Walter Jang | bf63a6d | 2015-05-05 09:14:35 -0700 | [diff] [blame] | 630 | private static void vlog(String message) { |
| 631 | if (Log.isLoggable(TAG, Log.VERBOSE)) { |
| 632 | Log.v(TAG, message); |
Walter Jang | cab3dce | 2015-02-09 17:48:03 -0800 | [diff] [blame] | 633 | } |
| 634 | } |
| 635 | } |