Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 1 | /* |
Daniel Lehmann | ef3f8f0 | 2010-07-26 18:55:25 -0700 | [diff] [blame] | 2 | * Copyright (C) 2010 The Android Open Source Project |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 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 | |
Dmitri Plotnikov | 18ffaa2 | 2010-12-03 14:28:00 -0800 | [diff] [blame^] | 17 | package com.android.contacts.detail; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 18 | |
| 19 | import com.android.contacts.Collapser; |
Dmitri Plotnikov | caf0bc7 | 2010-09-03 15:16:21 -0700 | [diff] [blame] | 20 | import com.android.contacts.Collapser.Collapsible; |
Dmitri Plotnikov | 18ffaa2 | 2010-12-03 14:28:00 -0800 | [diff] [blame^] | 21 | import com.android.contacts.ContactLoader; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 22 | import com.android.contacts.ContactOptionsActivity; |
| 23 | import com.android.contacts.ContactPresenceIconUtil; |
| 24 | import com.android.contacts.ContactsUtils; |
Daniel Lehmann | 8fd7bb6 | 2010-08-13 20:50:31 -0700 | [diff] [blame] | 25 | import com.android.contacts.ContactsUtils.ImActions; |
Dmitri Plotnikov | 18ffaa2 | 2010-12-03 14:28:00 -0800 | [diff] [blame^] | 26 | import com.android.contacts.GroupMetaData; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 27 | import com.android.contacts.R; |
| 28 | import com.android.contacts.TypePrecedence; |
Dmitri Plotnikov | 18ffaa2 | 2010-12-03 14:28:00 -0800 | [diff] [blame^] | 29 | import com.android.contacts.editor.SelectAccountDialogFragment; |
Dmitri Plotnikov | 4597c92 | 2010-11-15 13:03:06 -0800 | [diff] [blame] | 30 | import com.android.contacts.model.AccountType; |
| 31 | import com.android.contacts.model.AccountType.DataKind; |
| 32 | import com.android.contacts.model.AccountType.EditType; |
Dmitri Plotnikov | 18ffaa2 | 2010-12-03 14:28:00 -0800 | [diff] [blame^] | 33 | import com.android.contacts.model.AccountTypes; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 34 | import com.android.contacts.util.Constants; |
| 35 | import com.android.contacts.util.DataStatus; |
Dmitri Plotnikov | 45b4402 | 2010-10-15 18:12:09 -0700 | [diff] [blame] | 36 | import com.android.contacts.util.DateUtils; |
Daniel Lehmann | f77b8e9 | 2010-07-16 18:58:36 -0700 | [diff] [blame] | 37 | import com.android.contacts.util.PhoneCapabilityTester; |
Dmitri Plotnikov | 85609ed | 2010-11-11 15:59:01 -0800 | [diff] [blame] | 38 | import com.android.contacts.widget.TransitionAnimationView; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 39 | import com.android.internal.telephony.ITelephony; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 40 | |
Dmitri Plotnikov | caf0bc7 | 2010-09-03 15:16:21 -0700 | [diff] [blame] | 41 | import android.accounts.Account; |
Daniel Lehmann | 25a0282 | 2010-05-11 15:52:43 -0700 | [diff] [blame] | 42 | import android.app.Activity; |
Daniel Lehmann | 222744e | 2010-07-12 16:28:06 -0700 | [diff] [blame] | 43 | import android.app.Fragment; |
| 44 | import android.app.LoaderManager; |
| 45 | import android.app.LoaderManager.LoaderCallbacks; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 46 | import android.content.ActivityNotFoundException; |
| 47 | import android.content.ContentUris; |
| 48 | import android.content.ContentValues; |
| 49 | import android.content.Context; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 50 | import android.content.Entity; |
Dmitri Plotnikov | caf0bc7 | 2010-09-03 15:16:21 -0700 | [diff] [blame] | 51 | import android.content.Entity.NamedContentValues; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 52 | import android.content.Intent; |
Jeff Hamilton | 3c46291 | 2010-05-15 02:20:01 -0500 | [diff] [blame] | 53 | import android.content.Loader; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 54 | import android.content.res.Resources; |
| 55 | import android.graphics.drawable.Drawable; |
| 56 | import android.net.ParseException; |
| 57 | import android.net.Uri; |
| 58 | import android.net.WebAddress; |
| 59 | import android.os.Bundle; |
| 60 | import android.os.RemoteException; |
| 61 | import android.os.ServiceManager; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 62 | import android.provider.ContactsContract.CommonDataKinds.Email; |
Dmitri Plotnikov | 45b4402 | 2010-10-15 18:12:09 -0700 | [diff] [blame] | 63 | import android.provider.ContactsContract.CommonDataKinds.Event; |
Dmitri Plotnikov | 2deaee1 | 2010-09-15 15:42:08 -0700 | [diff] [blame] | 64 | import android.provider.ContactsContract.CommonDataKinds.GroupMembership; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 65 | import android.provider.ContactsContract.CommonDataKinds.Im; |
| 66 | import android.provider.ContactsContract.CommonDataKinds.Nickname; |
| 67 | import android.provider.ContactsContract.CommonDataKinds.Note; |
| 68 | import android.provider.ContactsContract.CommonDataKinds.Organization; |
| 69 | import android.provider.ContactsContract.CommonDataKinds.Phone; |
Daniel Lehmann | 0540f8b | 2010-10-28 16:55:00 -0700 | [diff] [blame] | 70 | import android.provider.ContactsContract.CommonDataKinds.Relation; |
David Brown | 4423ca5 | 2010-08-30 18:56:37 -0700 | [diff] [blame] | 71 | import android.provider.ContactsContract.CommonDataKinds.SipAddress; |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 72 | import android.provider.ContactsContract.CommonDataKinds.StructuredName; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 73 | import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; |
| 74 | import android.provider.ContactsContract.CommonDataKinds.Website; |
Dmitri Plotnikov | caf0bc7 | 2010-09-03 15:16:21 -0700 | [diff] [blame] | 75 | import android.provider.ContactsContract.Contacts; |
| 76 | import android.provider.ContactsContract.Data; |
| 77 | import android.provider.ContactsContract.Directory; |
| 78 | import android.provider.ContactsContract.DisplayNameSources; |
Bai Tao | 09eb04f | 2010-09-01 15:34:16 +0800 | [diff] [blame] | 79 | import android.provider.ContactsContract.PhoneLookup; |
Dmitri Plotnikov | caf0bc7 | 2010-09-03 15:16:21 -0700 | [diff] [blame] | 80 | import android.provider.ContactsContract.RawContacts; |
| 81 | import android.provider.ContactsContract.StatusUpdates; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 82 | import android.telephony.PhoneNumberUtils; |
| 83 | import android.text.TextUtils; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 84 | import android.util.Log; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 85 | import android.view.KeyEvent; |
| 86 | import android.view.LayoutInflater; |
| 87 | import android.view.Menu; |
| 88 | import android.view.MenuInflater; |
| 89 | import android.view.MenuItem; |
| 90 | import android.view.View; |
Daniel Lehmann | c2687c3 | 2010-04-19 18:20:44 -0700 | [diff] [blame] | 91 | import android.view.View.OnClickListener; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 92 | import android.view.View.OnCreateContextMenuListener; |
Dmitri Plotnikov | caf0bc7 | 2010-09-03 15:16:21 -0700 | [diff] [blame] | 93 | import android.view.ViewGroup; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 94 | import android.widget.AdapterView; |
Dmitri Plotnikov | caf0bc7 | 2010-09-03 15:16:21 -0700 | [diff] [blame] | 95 | import android.widget.AdapterView.OnItemClickListener; |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 96 | import android.widget.BaseAdapter; |
Daniel Lehmann | 18db43d | 2010-09-30 18:16:59 -0700 | [diff] [blame] | 97 | import android.widget.Button; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 98 | import android.widget.ImageView; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 99 | import android.widget.ListView; |
| 100 | import android.widget.TextView; |
| 101 | import android.widget.Toast; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 102 | |
| 103 | import java.util.ArrayList; |
Dmitri Plotnikov | 2deaee1 | 2010-09-15 15:42:08 -0700 | [diff] [blame] | 104 | import java.util.Collections; |
| 105 | import java.util.List; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 106 | |
Dmitri Plotnikov | caf0bc7 | 2010-09-03 15:16:21 -0700 | [diff] [blame] | 107 | public class ContactDetailFragment extends Fragment implements OnCreateContextMenuListener, |
| 108 | OnItemClickListener, SelectAccountDialogFragment.Listener { |
Dmitri Plotnikov | 4eeac74 | 2010-11-03 16:25:06 -0700 | [diff] [blame] | 109 | |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 110 | private static final String TAG = "ContactDetailFragment"; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 111 | |
Daniel Lehmann | 18f104f | 2010-05-07 15:41:11 -0700 | [diff] [blame] | 112 | private static final int LOADER_DETAILS = 1; |
| 113 | |
Dmitri Plotnikov | 174fdc2 | 2010-10-29 13:55:01 -0700 | [diff] [blame] | 114 | private static final String KEY_CONTACT_URI = "contactUri"; |
Dmitri Plotnikov | 4eeac74 | 2010-11-03 16:25:06 -0700 | [diff] [blame] | 115 | private static final String LOADER_ARG_CONTACT_URI = "contactUri"; |
Dmitri Plotnikov | 174fdc2 | 2010-10-29 13:55:01 -0700 | [diff] [blame] | 116 | |
Daniel Lehmann | 25a0282 | 2010-05-11 15:52:43 -0700 | [diff] [blame] | 117 | private Context mContext; |
Dmitri Plotnikov | 3ad2f35 | 2010-10-28 22:37:51 -0700 | [diff] [blame] | 118 | private View mView; |
Daniel Lehmann | 25a0282 | 2010-05-11 15:52:43 -0700 | [diff] [blame] | 119 | private Uri mLookupUri; |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 120 | private Listener mListener; |
Daniel Lehmann | c2687c3 | 2010-04-19 18:20:44 -0700 | [diff] [blame] | 121 | |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 122 | private ContactLoader.Result mContactData; |
| 123 | private ContactDetailHeaderView mHeaderView; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 124 | private ListView mListView; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 125 | private ViewAdapter mAdapter; |
| 126 | private Uri mPrimaryPhoneUri = null; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 127 | |
Daniel Lehmann | 18db43d | 2010-09-30 18:16:59 -0700 | [diff] [blame] | 128 | private Button mCopyGalToLocalButton; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 129 | private boolean mAllRestricted; |
Daniel Lehmann | 18f104f | 2010-05-07 15:41:11 -0700 | [diff] [blame] | 130 | private final ArrayList<Long> mWritableRawContactIds = new ArrayList<Long>(); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 131 | private int mNumPhoneNumbers = 0; |
Bai Tao | 09eb04f | 2010-09-01 15:34:16 +0800 | [diff] [blame] | 132 | private String mDefaultCountryIso; |
Dmitri Plotnikov | 85609ed | 2010-11-11 15:59:01 -0800 | [diff] [blame] | 133 | private boolean mContactDataDisplayed; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 134 | |
| 135 | /** |
Daniel Lehmann | f77b8e9 | 2010-07-16 18:58:36 -0700 | [diff] [blame] | 136 | * Device capability: Set during buildEntries and used in the long-press context menu |
| 137 | */ |
| 138 | private boolean mHasPhone; |
| 139 | |
| 140 | /** |
| 141 | * Device capability: Set during buildEntries and used in the long-press context menu |
| 142 | */ |
| 143 | private boolean mHasSms; |
| 144 | |
| 145 | /** |
Daniel Lehmann | 7781ea1 | 2010-10-21 21:56:43 -0700 | [diff] [blame] | 146 | * Device capability: Set during buildEntries and used in the long-press context menu |
| 147 | */ |
| 148 | private boolean mHasSip; |
| 149 | |
| 150 | /** |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 151 | * The view shown if the detail list is empty. |
| 152 | * We set this to the list view when first bind the adapter, so that it won't be shown while |
| 153 | * we're loading data. |
| 154 | */ |
| 155 | private View mEmptyView; |
| 156 | |
| 157 | /** |
| 158 | * A list of distinct contact IDs included in the current contact. |
| 159 | */ |
| 160 | private ArrayList<Long> mRawContactIds = new ArrayList<Long>(); |
| 161 | private ArrayList<ViewEntry> mPhoneEntries = new ArrayList<ViewEntry>(); |
| 162 | private ArrayList<ViewEntry> mSmsEntries = new ArrayList<ViewEntry>(); |
| 163 | private ArrayList<ViewEntry> mEmailEntries = new ArrayList<ViewEntry>(); |
| 164 | private ArrayList<ViewEntry> mPostalEntries = new ArrayList<ViewEntry>(); |
| 165 | private ArrayList<ViewEntry> mImEntries = new ArrayList<ViewEntry>(); |
| 166 | private ArrayList<ViewEntry> mNicknameEntries = new ArrayList<ViewEntry>(); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 167 | private ArrayList<ViewEntry> mGroupEntries = new ArrayList<ViewEntry>(); |
Daniel Lehmann | 0540f8b | 2010-10-28 16:55:00 -0700 | [diff] [blame] | 168 | private ArrayList<ViewEntry> mRelationEntries = new ArrayList<ViewEntry>(); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 169 | private ArrayList<ViewEntry> mOtherEntries = new ArrayList<ViewEntry>(); |
| 170 | private ArrayList<ArrayList<ViewEntry>> mSections = new ArrayList<ArrayList<ViewEntry>>(); |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 171 | private LayoutInflater mInflater; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 172 | |
Dmitri Plotnikov | 85609ed | 2010-11-11 15:59:01 -0800 | [diff] [blame] | 173 | private boolean mTransitionAnimationRequested; |
| 174 | |
Daniel Lehmann | 25a0282 | 2010-05-11 15:52:43 -0700 | [diff] [blame] | 175 | public ContactDetailFragment() { |
| 176 | // Explicit constructor for inflation |
Daniel Lehmann | c2687c3 | 2010-04-19 18:20:44 -0700 | [diff] [blame] | 177 | |
| 178 | // Build the list of sections. The order they're added to mSections dictates the |
| 179 | // order they are displayed in the list. |
| 180 | mSections.add(mPhoneEntries); |
| 181 | mSections.add(mSmsEntries); |
| 182 | mSections.add(mEmailEntries); |
| 183 | mSections.add(mImEntries); |
| 184 | mSections.add(mPostalEntries); |
| 185 | mSections.add(mNicknameEntries); |
Daniel Lehmann | c2687c3 | 2010-04-19 18:20:44 -0700 | [diff] [blame] | 186 | mSections.add(mOtherEntries); |
Daniel Lehmann | 0540f8b | 2010-10-28 16:55:00 -0700 | [diff] [blame] | 187 | mSections.add(mRelationEntries); |
Dmitri Plotnikov | e843f91 | 2010-09-16 15:21:48 -0700 | [diff] [blame] | 188 | mSections.add(mGroupEntries); |
Daniel Lehmann | 25a0282 | 2010-05-11 15:52:43 -0700 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | @Override |
Dmitri Plotnikov | 174fdc2 | 2010-10-29 13:55:01 -0700 | [diff] [blame] | 192 | public void onCreate(Bundle savedInstanceState) { |
| 193 | super.onCreate(savedInstanceState); |
| 194 | if (savedInstanceState != null) { |
| 195 | mLookupUri = savedInstanceState.getParcelable(KEY_CONTACT_URI); |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | @Override |
| 200 | public void onSaveInstanceState(Bundle outState) { |
| 201 | super.onSaveInstanceState(outState); |
| 202 | outState.putParcelable(KEY_CONTACT_URI, mLookupUri); |
| 203 | } |
| 204 | |
| 205 | @Override |
Daniel Lehmann | 25a0282 | 2010-05-11 15:52:43 -0700 | [diff] [blame] | 206 | public void onAttach(Activity activity) { |
| 207 | super.onAttach(activity); |
| 208 | mContext = activity; |
Bai Tao | 09eb04f | 2010-09-01 15:34:16 +0800 | [diff] [blame] | 209 | mDefaultCountryIso = ContactsUtils.getCurrentCountryIso(mContext); |
Daniel Lehmann | 25a0282 | 2010-05-11 15:52:43 -0700 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | @Override |
Dianne Hackborn | 84df2b6 | 2010-05-12 19:04:42 -0700 | [diff] [blame] | 213 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) { |
Dmitri Plotnikov | 3ad2f35 | 2010-10-28 22:37:51 -0700 | [diff] [blame] | 214 | mView = inflater.inflate(R.layout.contact_detail_fragment, container, false); |
Daniel Lehmann | 25a0282 | 2010-05-11 15:52:43 -0700 | [diff] [blame] | 215 | |
Dianne Hackborn | eb4d1bf | 2010-06-08 23:12:51 -0700 | [diff] [blame] | 216 | setHasOptionsMenu(true); |
Daniel Lehmann | b2257cf | 2010-06-15 13:36:07 -0700 | [diff] [blame] | 217 | |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 218 | mInflater = inflater; |
| 219 | |
Dmitri Plotnikov | 3ad2f35 | 2010-10-28 22:37:51 -0700 | [diff] [blame] | 220 | mHeaderView = (ContactDetailHeaderView) mView.findViewById(R.id.contact_header_widget); |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 221 | mHeaderView.setListener(mHeaderViewListener); |
Daniel Lehmann | 25a0282 | 2010-05-11 15:52:43 -0700 | [diff] [blame] | 222 | |
Dmitri Plotnikov | 3ad2f35 | 2010-10-28 22:37:51 -0700 | [diff] [blame] | 223 | mListView = (ListView) mView.findViewById(android.R.id.list); |
Daniel Lehmann | 25a0282 | 2010-05-11 15:52:43 -0700 | [diff] [blame] | 224 | mListView.setOnCreateContextMenuListener(this); |
| 225 | mListView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY); |
| 226 | mListView.setOnItemClickListener(this); |
| 227 | // Don't set it to mListView yet. We do so later when we bind the adapter. |
Dmitri Plotnikov | 3ad2f35 | 2010-10-28 22:37:51 -0700 | [diff] [blame] | 228 | mEmptyView = mView.findViewById(android.R.id.empty); |
Daniel Lehmann | 25a0282 | 2010-05-11 15:52:43 -0700 | [diff] [blame] | 229 | |
Dmitri Plotnikov | 3ad2f35 | 2010-10-28 22:37:51 -0700 | [diff] [blame] | 230 | mCopyGalToLocalButton = (Button) mView.findViewById(R.id.copyLocal); |
Daniel Lehmann | 18db43d | 2010-09-30 18:16:59 -0700 | [diff] [blame] | 231 | mCopyGalToLocalButton.setOnClickListener(new OnClickListener() { |
| 232 | @Override |
| 233 | public void onClick(View v) { |
| 234 | makePersonalCopy(); |
| 235 | } |
| 236 | }); |
| 237 | |
Dmitri Plotnikov | d959104 | 2010-11-23 09:25:03 -0800 | [diff] [blame] | 238 | mView.setVisibility(View.INVISIBLE); |
Dmitri Plotnikov | 3ad2f35 | 2010-10-28 22:37:51 -0700 | [diff] [blame] | 239 | return mView; |
Daniel Lehmann | 25a0282 | 2010-05-11 15:52:43 -0700 | [diff] [blame] | 240 | } |
| 241 | |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 242 | public void setListener(Listener value) { |
| 243 | mListener = value; |
Daniel Lehmann | 25a0282 | 2010-05-11 15:52:43 -0700 | [diff] [blame] | 244 | } |
| 245 | |
Dmitri Plotnikov | 9cd1708 | 2010-07-09 14:10:04 -0700 | [diff] [blame] | 246 | public Uri getUri() { |
| 247 | return mLookupUri; |
| 248 | } |
| 249 | |
Daniel Lehmann | 222744e | 2010-07-12 16:28:06 -0700 | [diff] [blame] | 250 | @Override |
| 251 | public void onActivityCreated(Bundle savedInstanceState) { |
| 252 | super.onActivityCreated(savedInstanceState); |
| 253 | |
Dmitri Plotnikov | 4eeac74 | 2010-11-03 16:25:06 -0700 | [diff] [blame] | 254 | if (mLookupUri != null) { |
| 255 | Bundle args = new Bundle(); |
| 256 | args.putParcelable(LOADER_ARG_CONTACT_URI, mLookupUri); |
| 257 | getLoaderManager().initLoader(LOADER_DETAILS, args, mDetailLoaderListener); |
| 258 | } |
Daniel Lehmann | 222744e | 2010-07-12 16:28:06 -0700 | [diff] [blame] | 259 | } |
| 260 | |
Daniel Lehmann | 25a0282 | 2010-05-11 15:52:43 -0700 | [diff] [blame] | 261 | public void loadUri(Uri lookupUri) { |
Dmitri Plotnikov | f42f53d | 2010-11-03 16:47:53 -0700 | [diff] [blame] | 262 | if ((lookupUri != null && lookupUri.equals(mLookupUri)) |
| 263 | || (lookupUri == null && mLookupUri == null)) { |
Dmitri Plotnikov | 4eeac74 | 2010-11-03 16:25:06 -0700 | [diff] [blame] | 264 | return; |
| 265 | } |
| 266 | |
Daniel Lehmann | 18f104f | 2010-05-07 15:41:11 -0700 | [diff] [blame] | 267 | mLookupUri = lookupUri; |
Dmitri Plotnikov | 85609ed | 2010-11-11 15:59:01 -0800 | [diff] [blame] | 268 | mTransitionAnimationRequested = mContactDataDisplayed; |
| 269 | mContactDataDisplayed = true; |
Dmitri Plotnikov | 3ad2f35 | 2010-10-28 22:37:51 -0700 | [diff] [blame] | 270 | if (mLookupUri == null) { |
Dmitri Plotnikov | 5a30d9a | 2010-11-23 14:59:50 -0800 | [diff] [blame] | 271 | getLoaderManager().stopLoader(LOADER_DETAILS); |
Dmitri Plotnikov | 3ad2f35 | 2010-10-28 22:37:51 -0700 | [diff] [blame] | 272 | mContactData = null; |
| 273 | bindData(); |
| 274 | } else if (getActivity() != null) { |
Dmitri Plotnikov | 4eeac74 | 2010-11-03 16:25:06 -0700 | [diff] [blame] | 275 | Bundle args = new Bundle(); |
| 276 | args.putParcelable(LOADER_ARG_CONTACT_URI, mLookupUri); |
| 277 | getLoaderManager().restartLoader(LOADER_DETAILS, args, mDetailLoaderListener); |
Daniel Lehmann | 18f104f | 2010-05-07 15:41:11 -0700 | [diff] [blame] | 278 | } |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | private void bindData() { |
Dmitri Plotnikov | 3ad2f35 | 2010-10-28 22:37:51 -0700 | [diff] [blame] | 282 | if (mView == null) { |
| 283 | return; |
| 284 | } |
| 285 | |
Dmitri Plotnikov | 7bf064e | 2010-11-05 18:08:03 -0700 | [diff] [blame] | 286 | if (isAdded()) { |
| 287 | getActivity().invalidateOptionsMenu(); |
| 288 | } |
| 289 | |
Dmitri Plotnikov | 85609ed | 2010-11-11 15:59:01 -0800 | [diff] [blame] | 290 | if (mTransitionAnimationRequested) { |
| 291 | TransitionAnimationView.startAnimation(mView, mContactData == null); |
| 292 | mTransitionAnimationRequested = false; |
| 293 | } |
| 294 | |
Dmitri Plotnikov | 3ad2f35 | 2010-10-28 22:37:51 -0700 | [diff] [blame] | 295 | if (mContactData == null) { |
| 296 | mView.setVisibility(View.INVISIBLE); |
| 297 | return; |
| 298 | } |
| 299 | |
Daniel Lehmann | d3e0cdb | 2010-04-19 13:45:53 -0700 | [diff] [blame] | 300 | // Set the header |
Daniel Lehmann | b2257cf | 2010-06-15 13:36:07 -0700 | [diff] [blame] | 301 | mHeaderView.loadData(mContactData); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 302 | |
| 303 | // Build up the contact entries |
| 304 | buildEntries(); |
| 305 | |
| 306 | // Collapse similar data items in select sections. |
| 307 | Collapser.collapseList(mPhoneEntries); |
| 308 | Collapser.collapseList(mSmsEntries); |
| 309 | Collapser.collapseList(mEmailEntries); |
| 310 | Collapser.collapseList(mPostalEntries); |
| 311 | Collapser.collapseList(mImEntries); |
| 312 | |
| 313 | if (mAdapter == null) { |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 314 | mAdapter = new ViewAdapter(); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 315 | mListView.setAdapter(mAdapter); |
| 316 | } else { |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 317 | mAdapter.notifyDataSetChanged(); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 318 | } |
| 319 | mListView.setEmptyView(mEmptyView); |
Dmitri Plotnikov | 02cd491 | 2010-09-01 20:42:17 -0700 | [diff] [blame] | 320 | |
Daniel Lehmann | 18db43d | 2010-09-30 18:16:59 -0700 | [diff] [blame] | 321 | // Configure copy gal button |
| 322 | if (mContactData.isDirectoryEntry()) { |
| 323 | final int exportSupport = mContactData.getDirectoryExportSupport(); |
| 324 | if (exportSupport == Directory.EXPORT_SUPPORT_ANY_ACCOUNT |
| 325 | || exportSupport == Directory.EXPORT_SUPPORT_SAME_ACCOUNT_ONLY) { |
| 326 | mCopyGalToLocalButton.setVisibility(View.VISIBLE); |
| 327 | } else { |
| 328 | mCopyGalToLocalButton.setVisibility(View.GONE); |
| 329 | } |
| 330 | } else { |
| 331 | mCopyGalToLocalButton.setVisibility(View.GONE); |
| 332 | } |
| 333 | |
Dmitri Plotnikov | 3ad2f35 | 2010-10-28 22:37:51 -0700 | [diff] [blame] | 334 | mView.setVisibility(View.VISIBLE); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | /** |
| 338 | * Build up the entries to display on the screen. |
| 339 | */ |
| 340 | private final void buildEntries() { |
Daniel Lehmann | 7779f49 | 2010-08-24 15:26:36 -0700 | [diff] [blame] | 341 | mHasPhone = PhoneCapabilityTester.isPhone(mContext); |
Daniel Lehmann | f77b8e9 | 2010-07-16 18:58:36 -0700 | [diff] [blame] | 342 | mHasSms = PhoneCapabilityTester.isSmsIntentRegistered(mContext); |
Daniel Lehmann | 7781ea1 | 2010-10-21 21:56:43 -0700 | [diff] [blame] | 343 | mHasSip = PhoneCapabilityTester.isSipPhone(mContext); |
Daniel Lehmann | f77b8e9 | 2010-07-16 18:58:36 -0700 | [diff] [blame] | 344 | |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 345 | // Clear out the old entries |
| 346 | final int numSections = mSections.size(); |
| 347 | for (int i = 0; i < numSections; i++) { |
| 348 | mSections.get(i).clear(); |
| 349 | } |
| 350 | |
| 351 | mRawContactIds.clear(); |
| 352 | |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 353 | mAllRestricted = true; |
| 354 | mPrimaryPhoneUri = null; |
| 355 | mNumPhoneNumbers = 0; |
| 356 | |
| 357 | mWritableRawContactIds.clear(); |
| 358 | |
Daniel Lehmann | 35769b8 | 2010-10-18 16:33:29 -0700 | [diff] [blame] | 359 | final AccountTypes sources = AccountTypes.getInstance(mContext); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 360 | |
| 361 | // Build up method entries |
| 362 | if (mContactData == null) { |
| 363 | return; |
| 364 | } |
| 365 | |
Dmitri Plotnikov | 2deaee1 | 2010-09-15 15:42:08 -0700 | [diff] [blame] | 366 | ArrayList<String> groups = new ArrayList<String>(); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 367 | for (Entity entity: mContactData.getEntities()) { |
| 368 | final ContentValues entValues = entity.getEntityValues(); |
| 369 | final String accountType = entValues.getAsString(RawContacts.ACCOUNT_TYPE); |
| 370 | final long rawContactId = entValues.getAsLong(RawContacts._ID); |
| 371 | |
| 372 | // Mark when this contact has any unrestricted components |
Dmitri Plotnikov | 7ccdc1f | 2010-08-02 18:18:01 -0700 | [diff] [blame] | 373 | Integer restricted = entValues.getAsInteger(RawContacts.IS_RESTRICTED); |
| 374 | final boolean isRestricted = restricted != null && restricted != 0; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 375 | if (!isRestricted) mAllRestricted = false; |
| 376 | |
| 377 | if (!mRawContactIds.contains(rawContactId)) { |
| 378 | mRawContactIds.add(rawContactId); |
| 379 | } |
Dmitri Plotnikov | 4597c92 | 2010-11-15 13:03:06 -0800 | [diff] [blame] | 380 | AccountType contactsSource = sources.getInflatedSource(accountType, |
| 381 | AccountType.LEVEL_SUMMARY); |
Daniel Lehmann | 69e7fec | 2010-07-20 14:14:56 -0700 | [diff] [blame] | 382 | if (contactsSource == null || !contactsSource.readOnly) { |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 383 | mWritableRawContactIds.add(rawContactId); |
| 384 | } |
| 385 | |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 386 | for (NamedContentValues subValue : entity.getSubValues()) { |
| 387 | final ContentValues entryValues = subValue.values; |
| 388 | entryValues.put(Data.RAW_CONTACT_ID, rawContactId); |
| 389 | |
| 390 | final long dataId = entryValues.getAsLong(Data._ID); |
| 391 | final String mimeType = entryValues.getAsString(Data.MIMETYPE); |
| 392 | if (mimeType == null) continue; |
| 393 | |
Dmitri Plotnikov | 2deaee1 | 2010-09-15 15:42:08 -0700 | [diff] [blame] | 394 | if (GroupMembership.CONTENT_ITEM_TYPE.equals(mimeType)) { |
| 395 | Long groupId = entryValues.getAsLong(GroupMembership.GROUP_ROW_ID); |
Dmitri Plotnikov | 2deaee1 | 2010-09-15 15:42:08 -0700 | [diff] [blame] | 396 | if (groupId != null) { |
| 397 | handleGroupMembership(groups, mContactData.getGroupMetaData(), groupId); |
| 398 | } |
| 399 | continue; |
| 400 | } |
| 401 | |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 402 | final DataKind kind = sources.getKindOrFallback(accountType, mimeType, mContext, |
Dmitri Plotnikov | 4597c92 | 2010-11-15 13:03:06 -0800 | [diff] [blame] | 403 | AccountType.LEVEL_CONSTRAINTS); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 404 | if (kind == null) continue; |
| 405 | |
Daniel Lehmann | 1624964 | 2010-09-10 19:56:51 -0700 | [diff] [blame] | 406 | final ViewEntry entry = ViewEntry.fromValues(mContext, mimeType, kind, dataId, |
| 407 | entryValues); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 408 | |
| 409 | final boolean hasData = !TextUtils.isEmpty(entry.data); |
Dmitri Plotnikov | 7ccdc1f | 2010-08-02 18:18:01 -0700 | [diff] [blame] | 410 | Integer superPrimary = entryValues.getAsInteger(Data.IS_SUPER_PRIMARY); |
| 411 | final boolean isSuperPrimary = superPrimary != null && superPrimary != 0; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 412 | |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 413 | if (StructuredName.CONTENT_ITEM_TYPE.equals(mimeType)) { |
| 414 | // Always ignore the name. It is shown in the header if set |
| 415 | } else if (Phone.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) { |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 416 | // Build phone entries |
| 417 | mNumPhoneNumbers++; |
Bai Tao | 09eb04f | 2010-09-01 15:34:16 +0800 | [diff] [blame] | 418 | String phoneNumberE164 = |
| 419 | entryValues.getAsString(PhoneLookup.NORMALIZED_NUMBER); |
| 420 | entry.data = PhoneNumberUtils.formatNumber( |
| 421 | entry.data, phoneNumberE164, mDefaultCountryIso); |
Daniel Lehmann | f77b8e9 | 2010-07-16 18:58:36 -0700 | [diff] [blame] | 422 | final Intent phoneIntent = mHasPhone ? new Intent(Intent.ACTION_CALL_PRIVILEGED, |
| 423 | Uri.fromParts(Constants.SCHEME_TEL, entry.data, null)) : null; |
| 424 | final Intent smsIntent = mHasSms ? new Intent(Intent.ACTION_SENDTO, |
| 425 | Uri.fromParts(Constants.SCHEME_SMSTO, entry.data, null)) : null; |
| 426 | |
| 427 | // Configure Icons and Intents. Notice actionIcon is already set to the phone |
| 428 | if (mHasPhone && mHasSms) { |
| 429 | entry.intent = phoneIntent; |
| 430 | entry.secondaryIntent = smsIntent; |
| 431 | entry.secondaryActionIcon = kind.iconAltRes; |
| 432 | } else if (mHasPhone) { |
| 433 | entry.intent = phoneIntent; |
| 434 | } else if (mHasSms) { |
| 435 | entry.intent = smsIntent; |
| 436 | entry.actionIcon = kind.iconAltRes; |
| 437 | } else { |
| 438 | entry.intent = null; |
| 439 | entry.actionIcon = -1; |
| 440 | } |
| 441 | |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 442 | |
| 443 | // Remember super-primary phone |
| 444 | if (isSuperPrimary) mPrimaryPhoneUri = entry.uri; |
| 445 | |
| 446 | entry.isPrimary = isSuperPrimary; |
| 447 | mPhoneEntries.add(entry); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 448 | } else if (Email.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) { |
| 449 | // Build email entries |
| 450 | entry.intent = new Intent(Intent.ACTION_SENDTO, |
| 451 | Uri.fromParts(Constants.SCHEME_MAILTO, entry.data, null)); |
| 452 | entry.isPrimary = isSuperPrimary; |
| 453 | mEmailEntries.add(entry); |
| 454 | |
| 455 | // When Email rows have status, create additional Im row |
| 456 | final DataStatus status = mContactData.getStatuses().get(entry.id); |
| 457 | if (status != null) { |
| 458 | final String imMime = Im.CONTENT_ITEM_TYPE; |
| 459 | final DataKind imKind = sources.getKindOrFallback(accountType, |
Dmitri Plotnikov | 4597c92 | 2010-11-15 13:03:06 -0800 | [diff] [blame] | 460 | imMime, mContext, AccountType.LEVEL_MIMETYPES); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 461 | final ViewEntry imEntry = ViewEntry.fromValues(mContext, |
Daniel Lehmann | 1624964 | 2010-09-10 19:56:51 -0700 | [diff] [blame] | 462 | imMime, imKind, dataId, entryValues); |
Daniel Lehmann | 8fd7bb6 | 2010-08-13 20:50:31 -0700 | [diff] [blame] | 463 | final ImActions imActions = ContactsUtils.buildImActions(entryValues); |
| 464 | if (imActions != null) { |
| 465 | imEntry.actionIcon = imActions.getPrimaryActionIcon(); |
| 466 | imEntry.secondaryActionIcon = imActions.getSecondaryActionIcon(); |
| 467 | imEntry.intent = imActions.getPrimaryIntent(); |
| 468 | imEntry.secondaryIntent = imActions.getSecondaryIntent(); |
| 469 | } |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 470 | imEntry.applyStatus(status, false); |
| 471 | mImEntries.add(imEntry); |
| 472 | } |
| 473 | } else if (StructuredPostal.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) { |
| 474 | // Build postal entries |
| 475 | entry.maxLines = 4; |
| 476 | entry.intent = new Intent(Intent.ACTION_VIEW, entry.uri); |
| 477 | mPostalEntries.add(entry); |
| 478 | } else if (Im.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) { |
| 479 | // Build IM entries |
Daniel Lehmann | 8fd7bb6 | 2010-08-13 20:50:31 -0700 | [diff] [blame] | 480 | final ImActions imActions = ContactsUtils.buildImActions(entryValues); |
| 481 | if (imActions != null) { |
| 482 | entry.actionIcon = imActions.getPrimaryActionIcon(); |
| 483 | entry.secondaryActionIcon = imActions.getSecondaryActionIcon(); |
| 484 | entry.intent = imActions.getPrimaryIntent(); |
| 485 | entry.secondaryIntent = imActions.getSecondaryIntent(); |
| 486 | } |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 487 | |
| 488 | // Apply presence and status details when available |
| 489 | final DataStatus status = mContactData.getStatuses().get(entry.id); |
| 490 | if (status != null) { |
| 491 | entry.applyStatus(status, false); |
| 492 | } |
| 493 | mImEntries.add(entry); |
Daniel Lehmann | 1ad4d1b | 2010-10-18 19:20:41 -0700 | [diff] [blame] | 494 | } else if (Organization.CONTENT_ITEM_TYPE.equals(mimeType)) { |
| 495 | // Organizations are not shown. The first one is shown in the header |
| 496 | // and subsequent ones are not supported anymore |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 497 | } else if (Nickname.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) { |
| 498 | // Build nickname entries |
| 499 | final boolean isNameRawContact = |
| 500 | (mContactData.getNameRawContactId() == rawContactId); |
| 501 | |
| 502 | final boolean duplicatesTitle = |
| 503 | isNameRawContact |
| 504 | && mContactData.getDisplayNameSource() == DisplayNameSources.NICKNAME; |
| 505 | |
| 506 | if (!duplicatesTitle) { |
| 507 | entry.uri = null; |
| 508 | mNicknameEntries.add(entry); |
| 509 | } |
| 510 | } else if (Note.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) { |
| 511 | // Build note entries |
| 512 | entry.uri = null; |
| 513 | entry.maxLines = 100; |
| 514 | mOtherEntries.add(entry); |
| 515 | } else if (Website.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) { |
David Brown | 4423ca5 | 2010-08-30 18:56:37 -0700 | [diff] [blame] | 516 | // Build Website entries |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 517 | entry.uri = null; |
| 518 | entry.maxLines = 10; |
| 519 | try { |
| 520 | WebAddress webAddress = new WebAddress(entry.data); |
| 521 | entry.intent = new Intent(Intent.ACTION_VIEW, |
| 522 | Uri.parse(webAddress.toString())); |
| 523 | } catch (ParseException e) { |
| 524 | Log.e(TAG, "Couldn't parse website: " + entry.data); |
| 525 | } |
| 526 | mOtherEntries.add(entry); |
David Brown | 4423ca5 | 2010-08-30 18:56:37 -0700 | [diff] [blame] | 527 | } else if (SipAddress.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) { |
| 528 | // Build SipAddress entries |
| 529 | entry.uri = null; |
| 530 | entry.maxLines = 1; |
Daniel Lehmann | 7781ea1 | 2010-10-21 21:56:43 -0700 | [diff] [blame] | 531 | if (mHasSip) { |
| 532 | entry.intent = new Intent(Intent.ACTION_CALL_PRIVILEGED, |
| 533 | Uri.fromParts(Constants.SCHEME_SIP, entry.data, null)); |
| 534 | } else { |
| 535 | entry.intent = null; |
| 536 | entry.actionIcon = -1; |
| 537 | } |
David Brown | 4423ca5 | 2010-08-30 18:56:37 -0700 | [diff] [blame] | 538 | mOtherEntries.add(entry); |
| 539 | // TODO: Consider moving the SipAddress into its own |
| 540 | // section (rather than lumping it in with mOtherEntries) |
| 541 | // so that we can reposition it right under the phone number. |
Daniel Lehmann | 35769b8 | 2010-10-18 16:33:29 -0700 | [diff] [blame] | 542 | // (Then, we'd also update FallbackAccountType.java to set |
David Brown | 4423ca5 | 2010-08-30 18:56:37 -0700 | [diff] [blame] | 543 | // secondary=false for this field, and tweak the weight |
| 544 | // of its DataKind.) |
Dmitri Plotnikov | 45b4402 | 2010-10-15 18:12:09 -0700 | [diff] [blame] | 545 | } else if (Event.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) { |
| 546 | entry.data = DateUtils.formatDate(mContext, entry.data); |
| 547 | entry.uri = null; |
| 548 | mOtherEntries.add(entry); |
Daniel Lehmann | 0540f8b | 2010-10-28 16:55:00 -0700 | [diff] [blame] | 549 | } else if (Relation.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) { |
| 550 | mRelationEntries.add(entry); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 551 | } else { |
| 552 | // Handle showing custom rows |
| 553 | entry.intent = new Intent(Intent.ACTION_VIEW, entry.uri); |
| 554 | |
| 555 | // Use social summary when requested by external source |
| 556 | final DataStatus status = mContactData.getStatuses().get(entry.id); |
| 557 | final boolean hasSocial = kind.actionBodySocial && status != null; |
| 558 | if (hasSocial) { |
| 559 | entry.applyStatus(status, true); |
| 560 | } |
| 561 | |
| 562 | if (hasSocial || hasData) { |
| 563 | mOtherEntries.add(entry); |
| 564 | } |
| 565 | } |
| 566 | } |
| 567 | } |
Dmitri Plotnikov | 2deaee1 | 2010-09-15 15:42:08 -0700 | [diff] [blame] | 568 | |
| 569 | if (!groups.isEmpty()) { |
| 570 | ViewEntry entry = new ViewEntry(); |
| 571 | Collections.sort(groups); |
| 572 | StringBuilder sb = new StringBuilder(); |
| 573 | int size = groups.size(); |
| 574 | for (int i = 0; i < size; i++) { |
| 575 | if (i != 0) { |
| 576 | sb.append(", "); |
| 577 | } |
| 578 | sb.append(groups.get(i)); |
| 579 | } |
| 580 | entry.mimetype = GroupMembership.MIMETYPE; |
Daniel Lehmann | cfb525b | 2010-11-02 19:24:54 -0700 | [diff] [blame] | 581 | entry.kind = mContext.getString(R.string.groupsLabel).toUpperCase(); |
Dmitri Plotnikov | 2deaee1 | 2010-09-15 15:42:08 -0700 | [diff] [blame] | 582 | entry.data = sb.toString(); |
| 583 | mGroupEntries.add(entry); |
| 584 | } |
| 585 | } |
| 586 | |
| 587 | /** |
| 588 | * Maps group ID to the corresponding group name, collapses all synonymous groups. |
| 589 | * Ignores default groups (e.g. My Contacts) and favorites groups. |
| 590 | */ |
| 591 | private void handleGroupMembership( |
Dmitri Plotnikov | e843f91 | 2010-09-16 15:21:48 -0700 | [diff] [blame] | 592 | ArrayList<String> groups, List<GroupMetaData> groupMetaData, long groupId) { |
Dmitri Plotnikov | 2deaee1 | 2010-09-15 15:42:08 -0700 | [diff] [blame] | 593 | if (groupMetaData == null) { |
| 594 | return; |
| 595 | } |
| 596 | |
Dmitri Plotnikov | e843f91 | 2010-09-16 15:21:48 -0700 | [diff] [blame] | 597 | for (GroupMetaData group : groupMetaData) { |
Dmitri Plotnikov | 2deaee1 | 2010-09-15 15:42:08 -0700 | [diff] [blame] | 598 | if (group.getGroupId() == groupId) { |
| 599 | if (!group.isDefaultGroup() && !group.isFavorites()) { |
| 600 | String title = group.getTitle(); |
| 601 | if (!groups.contains(title)) { |
| 602 | groups.add(title); |
| 603 | } |
| 604 | } |
| 605 | break; |
| 606 | } |
| 607 | } |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 608 | } |
| 609 | |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 610 | private static String buildDataString(DataKind kind, ContentValues values, |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 611 | Context context) { |
| 612 | if (kind.actionBody == null) { |
| 613 | return null; |
| 614 | } |
| 615 | CharSequence actionBody = kind.actionBody.inflateUsing(context, values); |
| 616 | return actionBody == null ? null : actionBody.toString(); |
| 617 | } |
| 618 | |
| 619 | /** |
| 620 | * A basic structure with the data for a contact entry in the list. |
| 621 | */ |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 622 | private static class ViewEntry implements Collapsible<ViewEntry> { |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 623 | public int type = -1; |
Daniel Lehmann | 0f428ae | 2010-09-12 18:48:40 -0700 | [diff] [blame] | 624 | public String kind; |
| 625 | public String typeString; |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 626 | public String data; |
| 627 | public Uri uri; |
| 628 | public long id = 0; |
| 629 | public int maxLines = 1; |
| 630 | public String mimetype; |
| 631 | |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 632 | public Context context = null; |
| 633 | public String resPackageName = null; |
| 634 | public int actionIcon = -1; |
| 635 | public boolean isPrimary = false; |
| 636 | public int secondaryActionIcon = -1; |
| 637 | public Intent intent; |
| 638 | public Intent secondaryIntent = null; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 639 | public ArrayList<Long> ids = new ArrayList<Long>(); |
| 640 | public int collapseCount = 0; |
| 641 | |
| 642 | public int presence = -1; |
| 643 | |
| 644 | public CharSequence footerLine = null; |
| 645 | |
| 646 | private ViewEntry() { |
| 647 | } |
| 648 | |
| 649 | /** |
| 650 | * Build new {@link ViewEntry} and populate from the given values. |
| 651 | */ |
| 652 | public static ViewEntry fromValues(Context context, String mimeType, DataKind kind, |
Daniel Lehmann | 1624964 | 2010-09-10 19:56:51 -0700 | [diff] [blame] | 653 | long dataId, ContentValues values) { |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 654 | final ViewEntry entry = new ViewEntry(); |
| 655 | entry.context = context; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 656 | entry.id = dataId; |
| 657 | entry.uri = ContentUris.withAppendedId(Data.CONTENT_URI, entry.id); |
| 658 | entry.mimetype = mimeType; |
Dmitri Plotnikov | 5b20147 | 2010-10-13 10:21:08 -0700 | [diff] [blame] | 659 | entry.kind = (kind.titleRes == -1 || kind.titleRes == 0) ? "" |
Daniel Lehmann | a472325 | 2010-10-13 11:17:45 -0700 | [diff] [blame] | 660 | : context.getString(kind.titleRes).toUpperCase(); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 661 | entry.data = buildDataString(kind, values, context); |
| 662 | |
| 663 | if (kind.typeColumn != null && values.containsKey(kind.typeColumn)) { |
| 664 | entry.type = values.getAsInteger(kind.typeColumn); |
Daniel Lehmann | 0f428ae | 2010-09-12 18:48:40 -0700 | [diff] [blame] | 665 | |
| 666 | // get type string |
| 667 | entry.typeString = ""; |
| 668 | for (EditType type : kind.typeList) { |
| 669 | if (type.rawValue == entry.type) { |
Dmitri Plotnikov | 28ac584 | 2010-11-15 14:20:13 -0800 | [diff] [blame] | 670 | if (!type.unspecifiedType) { |
| 671 | if (type.customColumn == null) { |
| 672 | // Non-custom type. Get its description from the resource |
| 673 | entry.typeString = context.getString(type.labelRes); |
| 674 | } else { |
| 675 | // Custom type. Read it from the database |
| 676 | entry.typeString = values.getAsString(type.customColumn); |
| 677 | } |
Daniel Lehmann | 0f428ae | 2010-09-12 18:48:40 -0700 | [diff] [blame] | 678 | } |
| 679 | break; |
| 680 | } |
| 681 | } |
| 682 | } else { |
| 683 | entry.typeString = ""; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 684 | } |
Daniel Lehmann | 0f428ae | 2010-09-12 18:48:40 -0700 | [diff] [blame] | 685 | |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 686 | if (kind.iconRes > 0) { |
| 687 | entry.resPackageName = kind.resPackageName; |
| 688 | entry.actionIcon = kind.iconRes; |
| 689 | } |
| 690 | |
| 691 | return entry; |
| 692 | } |
| 693 | |
| 694 | /** |
| 695 | * Apply given {@link DataStatus} values over this {@link ViewEntry} |
| 696 | * |
| 697 | * @param fillData When true, the given status replaces {@link #data} |
| 698 | * and {@link #footerLine}. Otherwise only {@link #presence} |
| 699 | * is updated. |
| 700 | */ |
| 701 | public ViewEntry applyStatus(DataStatus status, boolean fillData) { |
| 702 | presence = status.getPresence(); |
| 703 | if (fillData && status.isValid()) { |
| 704 | this.data = status.getStatus().toString(); |
| 705 | this.footerLine = status.getTimestampLabel(context); |
| 706 | } |
| 707 | |
| 708 | return this; |
| 709 | } |
| 710 | |
Daniel Lehmann | 1624964 | 2010-09-10 19:56:51 -0700 | [diff] [blame] | 711 | @Override |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 712 | public boolean collapseWith(ViewEntry entry) { |
| 713 | // assert equal collapse keys |
| 714 | if (!shouldCollapseWith(entry)) { |
| 715 | return false; |
| 716 | } |
| 717 | |
| 718 | // Choose the label associated with the highest type precedence. |
| 719 | if (TypePrecedence.getTypePrecedence(mimetype, type) |
| 720 | > TypePrecedence.getTypePrecedence(entry.mimetype, entry.type)) { |
| 721 | type = entry.type; |
Daniel Lehmann | 0f428ae | 2010-09-12 18:48:40 -0700 | [diff] [blame] | 722 | kind = entry.kind; |
| 723 | typeString = entry.typeString; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 724 | } |
| 725 | |
| 726 | // Choose the max of the maxLines and maxLabelLines values. |
| 727 | maxLines = Math.max(maxLines, entry.maxLines); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 728 | |
| 729 | // Choose the presence with the highest precedence. |
| 730 | if (StatusUpdates.getPresencePrecedence(presence) |
| 731 | < StatusUpdates.getPresencePrecedence(entry.presence)) { |
| 732 | presence = entry.presence; |
| 733 | } |
| 734 | |
| 735 | // If any of the collapsed entries are primary make the whole thing primary. |
| 736 | isPrimary = entry.isPrimary ? true : isPrimary; |
| 737 | |
| 738 | // uri, and contactdId, shouldn't make a difference. Just keep the original. |
| 739 | |
| 740 | // Keep track of all the ids that have been collapsed with this one. |
| 741 | ids.add(entry.id); |
| 742 | collapseCount++; |
| 743 | return true; |
| 744 | } |
| 745 | |
Daniel Lehmann | 1624964 | 2010-09-10 19:56:51 -0700 | [diff] [blame] | 746 | @Override |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 747 | public boolean shouldCollapseWith(ViewEntry entry) { |
| 748 | if (entry == null) { |
| 749 | return false; |
| 750 | } |
| 751 | |
| 752 | if (!ContactsUtils.shouldCollapse(context, mimetype, data, entry.mimetype, |
| 753 | entry.data)) { |
| 754 | return false; |
| 755 | } |
| 756 | |
| 757 | if (!TextUtils.equals(mimetype, entry.mimetype) |
| 758 | || !ContactsUtils.areIntentActionEqual(intent, entry.intent) |
| 759 | || !ContactsUtils.areIntentActionEqual(secondaryIntent, entry.secondaryIntent) |
| 760 | || actionIcon != entry.actionIcon) { |
| 761 | return false; |
| 762 | } |
| 763 | |
| 764 | return true; |
| 765 | } |
| 766 | } |
| 767 | |
| 768 | /** Cache of the children views of a row */ |
| 769 | private static class ViewCache { |
Daniel Lehmann | 5ad20a6 | 2010-11-08 16:24:50 -0800 | [diff] [blame] | 770 | public View kindDivider; |
| 771 | public View inKindDivider; |
| 772 | public View lineBelowLast; |
Daniel Lehmann | 0f428ae | 2010-09-12 18:48:40 -0700 | [diff] [blame] | 773 | public TextView kind; |
| 774 | public TextView type; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 775 | public TextView data; |
| 776 | public TextView footer; |
| 777 | public ImageView actionIcon; |
| 778 | public ImageView presenceIcon; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 779 | public ImageView secondaryActionButton; |
| 780 | public View secondaryActionDivider; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 781 | } |
| 782 | |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 783 | private final class ViewAdapter extends BaseAdapter { |
Daniel Lehmann | 1624964 | 2010-09-10 19:56:51 -0700 | [diff] [blame] | 784 | @Override |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 785 | public View getView(int position, View convertView, ViewGroup parent) { |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 786 | final ViewEntry entry = getEntry(position); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 787 | final View v; |
Daniel Lehmann | c3a0008 | 2010-04-13 13:53:54 -0700 | [diff] [blame] | 788 | final ViewCache viewCache; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 789 | |
| 790 | // Check to see if we can reuse convertView |
| 791 | if (convertView != null) { |
| 792 | v = convertView; |
Daniel Lehmann | c3a0008 | 2010-04-13 13:53:54 -0700 | [diff] [blame] | 793 | viewCache = (ViewCache) v.getTag(); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 794 | } else { |
| 795 | // Create a new view if needed |
Daniel Lehmann | 0f428ae | 2010-09-12 18:48:40 -0700 | [diff] [blame] | 796 | v = mInflater.inflate(R.layout.contact_detail_list_item, parent, false); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 797 | |
| 798 | // Cache the children |
Daniel Lehmann | c3a0008 | 2010-04-13 13:53:54 -0700 | [diff] [blame] | 799 | viewCache = new ViewCache(); |
Daniel Lehmann | 0f428ae | 2010-09-12 18:48:40 -0700 | [diff] [blame] | 800 | viewCache.kind = (TextView) v.findViewById(R.id.kind); |
Daniel Lehmann | 5ad20a6 | 2010-11-08 16:24:50 -0800 | [diff] [blame] | 801 | viewCache.kindDivider = v.findViewById(R.id.kind_divider); |
| 802 | viewCache.lineBelowLast = v.findViewById(R.id.line_below_last); |
| 803 | viewCache.inKindDivider = v.findViewById(R.id.in_kind_divider); |
Daniel Lehmann | 0f428ae | 2010-09-12 18:48:40 -0700 | [diff] [blame] | 804 | viewCache.type = (TextView) v.findViewById(R.id.type); |
| 805 | viewCache.data = (TextView) v.findViewById(R.id.data); |
Daniel Lehmann | c3a0008 | 2010-04-13 13:53:54 -0700 | [diff] [blame] | 806 | viewCache.footer = (TextView) v.findViewById(R.id.footer); |
| 807 | viewCache.actionIcon = (ImageView) v.findViewById(R.id.action_icon); |
Daniel Lehmann | c3a0008 | 2010-04-13 13:53:54 -0700 | [diff] [blame] | 808 | viewCache.presenceIcon = (ImageView) v.findViewById(R.id.presence_icon); |
| 809 | viewCache.secondaryActionButton = (ImageView) v.findViewById( |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 810 | R.id.secondary_action_button); |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 811 | viewCache.secondaryActionButton.setOnClickListener(mSecondaryActionClickListener); |
Daniel Lehmann | c3a0008 | 2010-04-13 13:53:54 -0700 | [diff] [blame] | 812 | viewCache.secondaryActionDivider = v.findViewById(R.id.divider); |
| 813 | v.setTag(viewCache); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 814 | } |
| 815 | |
Daniel Lehmann | 0f428ae | 2010-09-12 18:48:40 -0700 | [diff] [blame] | 816 | final ViewEntry previousEntry = position == 0 ? null : getEntry(position - 1); |
| 817 | final boolean isFirstOfItsKind = |
| 818 | previousEntry == null ? true : !previousEntry.kind.equals(entry.kind); |
Daniel Lehmann | 5ad20a6 | 2010-11-08 16:24:50 -0800 | [diff] [blame] | 819 | final boolean isLast = position == getCount() - 1; |
Daniel Lehmann | 0f428ae | 2010-09-12 18:48:40 -0700 | [diff] [blame] | 820 | |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 821 | // Bind the data to the view |
Daniel Lehmann | 5ad20a6 | 2010-11-08 16:24:50 -0800 | [diff] [blame] | 822 | bindView(v, entry, isFirstOfItsKind, isLast); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 823 | return v; |
| 824 | } |
| 825 | |
Daniel Lehmann | 5ad20a6 | 2010-11-08 16:24:50 -0800 | [diff] [blame] | 826 | protected void bindView(View view, ViewEntry entry, boolean isFirstOfItsKind, |
| 827 | boolean isLast) { |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 828 | final Resources resources = mContext.getResources(); |
| 829 | ViewCache views = (ViewCache) view.getTag(); |
| 830 | |
Daniel Lehmann | 5ad20a6 | 2010-11-08 16:24:50 -0800 | [diff] [blame] | 831 | views.kind.setText(isFirstOfItsKind ? entry.kind : ""); |
| 832 | views.kindDivider.setVisibility(isFirstOfItsKind ? View.VISIBLE : View.GONE); |
| 833 | views.inKindDivider.setVisibility(isFirstOfItsKind ? View.GONE : View.VISIBLE); |
| 834 | if (views.lineBelowLast != null) { |
| 835 | views.lineBelowLast.setVisibility(isLast ? View.VISIBLE : View.GONE); |
Daniel Lehmann | cfb525b | 2010-11-02 19:24:54 -0700 | [diff] [blame] | 836 | } |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 837 | |
Daniel Lehmann | 5ad20a6 | 2010-11-08 16:24:50 -0800 | [diff] [blame] | 838 | views.type.setText(entry.typeString); |
| 839 | views.type.setVisibility( |
| 840 | TextUtils.isEmpty(entry.typeString) ? View.GONE : View.VISIBLE); |
| 841 | |
Daniel Lehmann | 0f428ae | 2010-09-12 18:48:40 -0700 | [diff] [blame] | 842 | // Set the content |
| 843 | final TextView content = views.data; |
| 844 | if (content != null) { |
Bai Tao | bff5549 | 2010-09-26 13:27:36 +0800 | [diff] [blame] | 845 | content.setText(entry.data); |
Daniel Lehmann | 0f428ae | 2010-09-12 18:48:40 -0700 | [diff] [blame] | 846 | setMaxLines(content, entry.maxLines); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 847 | } |
| 848 | |
| 849 | // Set the footer |
| 850 | if (!TextUtils.isEmpty(entry.footerLine)) { |
| 851 | views.footer.setText(entry.footerLine); |
| 852 | views.footer.setVisibility(View.VISIBLE); |
| 853 | } else { |
| 854 | views.footer.setVisibility(View.GONE); |
| 855 | } |
| 856 | |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 857 | // Set the action icon |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 858 | final ImageView action = views.actionIcon; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 859 | if (entry.actionIcon != -1) { |
| 860 | Drawable actionIcon; |
| 861 | if (entry.resPackageName != null) { |
| 862 | // Load external resources through PackageManager |
| 863 | actionIcon = mContext.getPackageManager().getDrawable(entry.resPackageName, |
| 864 | entry.actionIcon, null); |
| 865 | } else { |
| 866 | actionIcon = resources.getDrawable(entry.actionIcon); |
| 867 | } |
| 868 | action.setImageDrawable(actionIcon); |
| 869 | action.setVisibility(View.VISIBLE); |
| 870 | } else { |
| 871 | // Things should still line up as if there was an icon, so make it invisible |
| 872 | action.setVisibility(View.INVISIBLE); |
| 873 | } |
| 874 | |
| 875 | // Set the presence icon |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 876 | final Drawable presenceIcon = ContactPresenceIconUtil.getPresenceIcon( |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 877 | mContext, entry.presence); |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 878 | final ImageView presenceIconView = views.presenceIcon; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 879 | if (presenceIcon != null) { |
| 880 | presenceIconView.setImageDrawable(presenceIcon); |
| 881 | presenceIconView.setVisibility(View.VISIBLE); |
| 882 | } else { |
| 883 | presenceIconView.setVisibility(View.GONE); |
| 884 | } |
| 885 | |
| 886 | // Set the secondary action button |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 887 | final ImageView secondaryActionView = views.secondaryActionButton; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 888 | Drawable secondaryActionIcon = null; |
| 889 | if (entry.secondaryActionIcon != -1) { |
| 890 | secondaryActionIcon = resources.getDrawable(entry.secondaryActionIcon); |
| 891 | } |
| 892 | if (entry.secondaryIntent != null && secondaryActionIcon != null) { |
| 893 | secondaryActionView.setImageDrawable(secondaryActionIcon); |
Daniel Lehmann | c3a0008 | 2010-04-13 13:53:54 -0700 | [diff] [blame] | 894 | secondaryActionView.setTag(entry); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 895 | secondaryActionView.setVisibility(View.VISIBLE); |
| 896 | views.secondaryActionDivider.setVisibility(View.VISIBLE); |
| 897 | } else { |
| 898 | secondaryActionView.setVisibility(View.GONE); |
| 899 | views.secondaryActionDivider.setVisibility(View.GONE); |
| 900 | } |
| 901 | } |
| 902 | |
| 903 | private void setMaxLines(TextView textView, int maxLines) { |
| 904 | if (maxLines == 1) { |
| 905 | textView.setSingleLine(true); |
| 906 | textView.setEllipsize(TextUtils.TruncateAt.END); |
| 907 | } else { |
| 908 | textView.setSingleLine(false); |
| 909 | textView.setMaxLines(maxLines); |
| 910 | textView.setEllipsize(null); |
| 911 | } |
| 912 | } |
| 913 | |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 914 | private OnClickListener mSecondaryActionClickListener = new OnClickListener() { |
Daniel Lehmann | 1624964 | 2010-09-10 19:56:51 -0700 | [diff] [blame] | 915 | @Override |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 916 | public void onClick(View v) { |
| 917 | if (mListener == null) return; |
| 918 | if (v == null) return; |
| 919 | final ViewEntry entry = (ViewEntry) v.getTag(); |
| 920 | if (entry == null) return; |
| 921 | final Intent intent = entry.secondaryIntent; |
| 922 | if (intent == null) return; |
| 923 | mListener.onItemClicked(intent); |
| 924 | } |
| 925 | }; |
| 926 | |
Daniel Lehmann | 1624964 | 2010-09-10 19:56:51 -0700 | [diff] [blame] | 927 | @Override |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 928 | public int getCount() { |
| 929 | int count = 0; |
| 930 | final int numSections = mSections.size(); |
| 931 | for (int i = 0; i < numSections; i++) { |
| 932 | final ArrayList<ViewEntry> section = mSections.get(i); |
| 933 | count += section.size(); |
| 934 | } |
| 935 | return count; |
| 936 | } |
| 937 | |
Daniel Lehmann | 1624964 | 2010-09-10 19:56:51 -0700 | [diff] [blame] | 938 | @Override |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 939 | public Object getItem(int position) { |
| 940 | return getEntry(position); |
| 941 | } |
| 942 | |
Daniel Lehmann | 1624964 | 2010-09-10 19:56:51 -0700 | [diff] [blame] | 943 | @Override |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 944 | public long getItemId(int position) { |
| 945 | final ViewEntry entry = getEntry(position); |
| 946 | if (entry != null) { |
| 947 | return entry.id; |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 948 | } |
Daniel Lehmann | 1624964 | 2010-09-10 19:56:51 -0700 | [diff] [blame] | 949 | return -1; |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 950 | } |
| 951 | |
| 952 | private ViewEntry getEntry(int position) { |
| 953 | final int numSections = mSections.size(); |
| 954 | for (int i = 0; i < numSections; i++) { |
| 955 | final ArrayList<ViewEntry> section = mSections.get(i); |
| 956 | final int sectionSize = section.size(); |
| 957 | if (position < sectionSize) { |
| 958 | return section.get(position); |
| 959 | } |
| 960 | position -= sectionSize; |
| 961 | } |
| 962 | return null; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 963 | } |
| 964 | } |
| 965 | |
Daniel Lehmann | 3648d2e | 2010-06-30 19:58:31 +0200 | [diff] [blame] | 966 | @Override |
Dianne Hackborn | eb4d1bf | 2010-06-08 23:12:51 -0700 | [diff] [blame] | 967 | public void onCreateOptionsMenu(Menu menu, final MenuInflater inflater) { |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 968 | inflater.inflate(R.menu.view, menu); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 969 | } |
| 970 | |
Daniel Lehmann | 3648d2e | 2010-06-30 19:58:31 +0200 | [diff] [blame] | 971 | @Override |
Daniel Lehmann | f77b8e9 | 2010-07-16 18:58:36 -0700 | [diff] [blame] | 972 | public void onPrepareOptionsMenu(Menu menu) { |
Dmitri Plotnikov | 7bf064e | 2010-11-05 18:08:03 -0700 | [diff] [blame] | 973 | boolean isEmpty = mContactData == null; |
| 974 | boolean isDirectoryEntry = !isEmpty && mContactData.isDirectoryEntry(); |
Dmitri Plotnikov | 02cd491 | 2010-09-01 20:42:17 -0700 | [diff] [blame] | 975 | |
Daniel Lehmann | f77b8e9 | 2010-07-16 18:58:36 -0700 | [diff] [blame] | 976 | // Options only shows telephony-related settings (ringtone, send to voicemail). |
| 977 | // ==> Hide if we don't have a telephone |
| 978 | final MenuItem optionsMenu = menu.findItem(R.id.menu_options); |
Daniel Lehmann | 7779f49 | 2010-08-24 15:26:36 -0700 | [diff] [blame] | 979 | final boolean deviceHasPhone = PhoneCapabilityTester.isPhone(mContext); |
Dmitri Plotnikov | 7bf064e | 2010-11-05 18:08:03 -0700 | [diff] [blame] | 980 | optionsMenu.setVisible(!isEmpty && !isDirectoryEntry && deviceHasPhone); |
Dmitri Plotnikov | 02cd491 | 2010-09-01 20:42:17 -0700 | [diff] [blame] | 981 | |
| 982 | final MenuItem editMenu = menu.findItem(R.id.menu_edit); |
Dmitri Plotnikov | 7bf064e | 2010-11-05 18:08:03 -0700 | [diff] [blame] | 983 | editMenu.setVisible(!isEmpty && !isDirectoryEntry); |
Dmitri Plotnikov | 02cd491 | 2010-09-01 20:42:17 -0700 | [diff] [blame] | 984 | |
| 985 | final MenuItem deleteMenu = menu.findItem(R.id.menu_delete); |
Dmitri Plotnikov | 7bf064e | 2010-11-05 18:08:03 -0700 | [diff] [blame] | 986 | deleteMenu.setVisible(!isEmpty && !isDirectoryEntry); |
Dmitri Plotnikov | 02cd491 | 2010-09-01 20:42:17 -0700 | [diff] [blame] | 987 | |
| 988 | final MenuItem shareMenu = menu.findItem(R.id.menu_share); |
Dmitri Plotnikov | 7bf064e | 2010-11-05 18:08:03 -0700 | [diff] [blame] | 989 | shareMenu.setVisible(!isEmpty && !isDirectoryEntry && !mAllRestricted); |
Daniel Lehmann | f77b8e9 | 2010-07-16 18:58:36 -0700 | [diff] [blame] | 990 | } |
| 991 | |
| 992 | @Override |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 993 | public boolean onOptionsItemSelected(MenuItem item) { |
| 994 | switch (item.getItemId()) { |
| 995 | case R.id.menu_edit: { |
Daniel Lehmann | 99eefbe | 2010-08-24 16:45:03 -0700 | [diff] [blame] | 996 | if (mListener != null) mListener.onEditRequested(mLookupUri); |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 997 | break; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 998 | } |
| 999 | case R.id.menu_delete: { |
Daniel Lehmann | 69e7fec | 2010-07-20 14:14:56 -0700 | [diff] [blame] | 1000 | if (mListener != null) mListener.onDeleteRequested(mLookupUri); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 1001 | return true; |
| 1002 | } |
| 1003 | case R.id.menu_options: { |
Daniel Lehmann | 9fe582e | 2010-10-08 21:15:18 -0700 | [diff] [blame] | 1004 | if (mContactData == null) return false; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 1005 | final Intent intent = new Intent(mContext, ContactOptionsActivity.class); |
| 1006 | intent.setData(mContactData.getLookupUri()); |
| 1007 | mContext.startActivity(intent); |
| 1008 | return true; |
| 1009 | } |
| 1010 | case R.id.menu_share: { |
| 1011 | if (mAllRestricted) return false; |
Daniel Lehmann | 9fe582e | 2010-10-08 21:15:18 -0700 | [diff] [blame] | 1012 | if (mContactData == null) return false; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 1013 | |
| 1014 | final String lookupKey = mContactData.getLookupKey(); |
| 1015 | final Uri shareUri = Uri.withAppendedPath(Contacts.CONTENT_VCARD_URI, lookupKey); |
| 1016 | |
| 1017 | final Intent intent = new Intent(Intent.ACTION_SEND); |
| 1018 | intent.setType(Contacts.CONTENT_VCARD_TYPE); |
| 1019 | intent.putExtra(Intent.EXTRA_STREAM, shareUri); |
| 1020 | |
| 1021 | // Launch chooser to share contact via |
| 1022 | final CharSequence chooseTitle = mContext.getText(R.string.share_via); |
| 1023 | final Intent chooseIntent = Intent.createChooser(intent, chooseTitle); |
| 1024 | |
| 1025 | try { |
| 1026 | mContext.startActivity(chooseIntent); |
| 1027 | } catch (ActivityNotFoundException ex) { |
| 1028 | Toast.makeText(mContext, R.string.share_error, Toast.LENGTH_SHORT).show(); |
| 1029 | } |
| 1030 | return true; |
| 1031 | } |
| 1032 | } |
| 1033 | return false; |
| 1034 | } |
| 1035 | |
Dmitri Plotnikov | caf0bc7 | 2010-09-03 15:16:21 -0700 | [diff] [blame] | 1036 | private void makePersonalCopy() { |
| 1037 | if (mListener == null) { |
| 1038 | return; |
| 1039 | } |
| 1040 | |
| 1041 | int exportSupport = mContactData.getDirectoryExportSupport(); |
| 1042 | switch (exportSupport) { |
| 1043 | case Directory.EXPORT_SUPPORT_SAME_ACCOUNT_ONLY: { |
| 1044 | createCopy(new Account(mContactData.getDirectoryAccountName(), |
| 1045 | mContactData.getDirectoryAccountType())); |
| 1046 | break; |
| 1047 | } |
| 1048 | case Directory.EXPORT_SUPPORT_ANY_ACCOUNT: { |
Daniel Lehmann | 35769b8 | 2010-10-18 16:33:29 -0700 | [diff] [blame] | 1049 | final ArrayList<Account> accounts = AccountTypes.getInstance(mContext).getAccounts(true); |
Dmitri Plotnikov | caf0bc7 | 2010-09-03 15:16:21 -0700 | [diff] [blame] | 1050 | if (accounts.isEmpty()) { |
| 1051 | createCopy(null); |
| 1052 | return; // Don't show a dialog. |
| 1053 | } |
| 1054 | |
| 1055 | // In the common case of a single writable account, auto-select |
| 1056 | // it without showing a dialog. |
| 1057 | if (accounts.size() == 1) { |
| 1058 | createCopy(accounts.get(0)); |
| 1059 | return; // Don't show a dialog. |
| 1060 | } |
| 1061 | |
Dmitri Plotnikov | 40bb481 | 2010-11-23 15:21:33 -0800 | [diff] [blame] | 1062 | final SelectAccountDialogFragment dialog = new SelectAccountDialogFragment(); |
Daniel Lehmann | 4a62be4 | 2010-09-07 18:22:59 -0700 | [diff] [blame] | 1063 | dialog.setTargetFragment(this, 0); |
Dmitri Plotnikov | caf0bc7 | 2010-09-03 15:16:21 -0700 | [diff] [blame] | 1064 | dialog.show(getFragmentManager(), SelectAccountDialogFragment.TAG); |
| 1065 | break; |
| 1066 | } |
| 1067 | } |
| 1068 | } |
| 1069 | |
| 1070 | @Override |
| 1071 | public void onAccountSelectorCancelled() { |
| 1072 | } |
| 1073 | |
| 1074 | @Override |
Dmitri Plotnikov | 40bb481 | 2010-11-23 15:21:33 -0800 | [diff] [blame] | 1075 | public void onAccountChosen(Account account) { |
Dmitri Plotnikov | caf0bc7 | 2010-09-03 15:16:21 -0700 | [diff] [blame] | 1076 | createCopy(account); |
| 1077 | } |
| 1078 | |
| 1079 | private void createCopy(Account account) { |
| 1080 | if (mListener != null) { |
| 1081 | mListener.onCreateRawContactRequested(mContactData.getContentValues(), account); |
| 1082 | } |
| 1083 | } |
| 1084 | |
Dmitri Plotnikov | d364314 | 2010-07-09 13:49:07 -0700 | [diff] [blame] | 1085 | @Override |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 1086 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 1087 | if (mListener == null) return; |
| 1088 | final ViewEntry entry = mAdapter.getEntry(position); |
Daniel Lehmann | c3a0008 | 2010-04-13 13:53:54 -0700 | [diff] [blame] | 1089 | if (entry == null) return; |
Daniel Lehmann | 18f104f | 2010-05-07 15:41:11 -0700 | [diff] [blame] | 1090 | final Intent intent = entry.intent; |
| 1091 | if (intent == null) return; |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 1092 | mListener.onItemClicked(intent); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 1093 | } |
| 1094 | |
Daniel Lehmann | 1624964 | 2010-09-10 19:56:51 -0700 | [diff] [blame] | 1095 | public boolean handleKeyDown(int keyCode) { |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 1096 | switch (keyCode) { |
| 1097 | case KeyEvent.KEYCODE_CALL: { |
| 1098 | try { |
| 1099 | ITelephony phone = ITelephony.Stub.asInterface( |
| 1100 | ServiceManager.checkService("phone")); |
| 1101 | if (phone != null && !phone.isIdle()) { |
| 1102 | // Skip out and let the key be handled at a higher level |
| 1103 | break; |
| 1104 | } |
| 1105 | } catch (RemoteException re) { |
| 1106 | // Fall through and try to call the contact |
| 1107 | } |
| 1108 | |
| 1109 | int index = mListView.getSelectedItemPosition(); |
| 1110 | if (index != -1) { |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 1111 | final ViewEntry entry = mAdapter.getEntry(index); |
Daniel Lehmann | 0deb6d3 | 2010-08-05 11:37:36 -0700 | [diff] [blame] | 1112 | if (entry != null && entry.intent != null && |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 1113 | entry.intent.getAction() == Intent.ACTION_CALL_PRIVILEGED) { |
| 1114 | mContext.startActivity(entry.intent); |
| 1115 | return true; |
| 1116 | } |
| 1117 | } else if (mPrimaryPhoneUri != null) { |
| 1118 | // There isn't anything selected, call the default number |
| 1119 | final Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED, |
| 1120 | mPrimaryPhoneUri); |
| 1121 | mContext.startActivity(intent); |
| 1122 | return true; |
| 1123 | } |
| 1124 | return false; |
| 1125 | } |
| 1126 | |
| 1127 | case KeyEvent.KEYCODE_DEL: { |
Daniel Lehmann | 69e7fec | 2010-07-20 14:14:56 -0700 | [diff] [blame] | 1128 | if (mListener != null) mListener.onDeleteRequested(mLookupUri); |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 1129 | return true; |
| 1130 | } |
| 1131 | } |
| 1132 | |
Daniel Lehmann | c2687c3 | 2010-04-19 18:20:44 -0700 | [diff] [blame] | 1133 | return false; |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 1134 | } |
Daniel Lehmann | 18f104f | 2010-05-07 15:41:11 -0700 | [diff] [blame] | 1135 | |
Daniel Lehmann | 222744e | 2010-07-12 16:28:06 -0700 | [diff] [blame] | 1136 | /** |
| 1137 | * The listener for the detail loader |
| 1138 | */ |
| 1139 | private final LoaderManager.LoaderCallbacks<ContactLoader.Result> mDetailLoaderListener = |
| 1140 | new LoaderCallbacks<ContactLoader.Result>() { |
| 1141 | @Override |
| 1142 | public Loader<ContactLoader.Result> onCreateLoader(int id, Bundle args) { |
Dmitri Plotnikov | 4eeac74 | 2010-11-03 16:25:06 -0700 | [diff] [blame] | 1143 | Uri lookupUri = args.getParcelable(LOADER_ARG_CONTACT_URI); |
| 1144 | return new ContactLoader(mContext, lookupUri, true /* loadGroupMetaData */); |
Daniel Lehmann | 222744e | 2010-07-12 16:28:06 -0700 | [diff] [blame] | 1145 | } |
| 1146 | |
| 1147 | @Override |
| 1148 | public void onLoadFinished(Loader<ContactLoader.Result> loader, ContactLoader.Result data) { |
Dmitri Plotnikov | 5a30d9a | 2010-11-23 14:59:50 -0800 | [diff] [blame] | 1149 | if (data != ContactLoader.Result.NOT_FOUND && data != ContactLoader.Result.ERROR) { |
| 1150 | mContactData = data; |
| 1151 | } else { |
| 1152 | Log.i(TAG, "No contact found: " + ((ContactLoader)loader).getLookupUri()); |
| 1153 | mContactData = null; |
Daniel Lehmann | 222744e | 2010-07-12 16:28:06 -0700 | [diff] [blame] | 1154 | } |
Dmitri Plotnikov | 5a30d9a | 2010-11-23 14:59:50 -0800 | [diff] [blame] | 1155 | |
Daniel Lehmann | 222744e | 2010-07-12 16:28:06 -0700 | [diff] [blame] | 1156 | bindData(); |
Dmitri Plotnikov | 5a30d9a | 2010-11-23 14:59:50 -0800 | [diff] [blame] | 1157 | |
| 1158 | if (mContactData == null && mListener != null) { |
| 1159 | mListener.onContactNotFound(); |
| 1160 | } |
Daniel Lehmann | 222744e | 2010-07-12 16:28:06 -0700 | [diff] [blame] | 1161 | } |
| 1162 | }; |
| 1163 | |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 1164 | private ContactDetailHeaderView.Listener mHeaderViewListener = |
| 1165 | new ContactDetailHeaderView.Listener() { |
Daniel Lehmann | be82afa | 2010-07-14 15:31:56 -0700 | [diff] [blame] | 1166 | @Override |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 1167 | public void onDisplayNameClick(View view) { |
| 1168 | } |
| 1169 | |
Daniel Lehmann | be82afa | 2010-07-14 15:31:56 -0700 | [diff] [blame] | 1170 | @Override |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 1171 | public void onPhotoClick(View view) { |
| 1172 | } |
| 1173 | }; |
| 1174 | |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 1175 | public static interface Listener { |
Daniel Lehmann | 18f104f | 2010-05-07 15:41:11 -0700 | [diff] [blame] | 1176 | /** |
Daniel Lehmann | 69e7fec | 2010-07-20 14:14:56 -0700 | [diff] [blame] | 1177 | * Contact was not found, so somehow close this fragment. This is raised after a contact |
| 1178 | * is removed via Menu/Delete |
Daniel Lehmann | 18f104f | 2010-05-07 15:41:11 -0700 | [diff] [blame] | 1179 | */ |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 1180 | public void onContactNotFound(); |
Daniel Lehmann | 18f104f | 2010-05-07 15:41:11 -0700 | [diff] [blame] | 1181 | |
| 1182 | /** |
| 1183 | * User decided to go to Edit-Mode |
| 1184 | */ |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 1185 | public void onEditRequested(Uri lookupUri); |
Daniel Lehmann | 18f104f | 2010-05-07 15:41:11 -0700 | [diff] [blame] | 1186 | |
| 1187 | /** |
| 1188 | * User clicked a single item (e.g. mail) |
| 1189 | */ |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 1190 | public void onItemClicked(Intent intent); |
| 1191 | |
| 1192 | /** |
Daniel Lehmann | 69e7fec | 2010-07-20 14:14:56 -0700 | [diff] [blame] | 1193 | * User decided to delete the contact |
Daniel Lehmann | cdef2b6 | 2010-06-06 18:25:49 -0700 | [diff] [blame] | 1194 | */ |
Daniel Lehmann | 69e7fec | 2010-07-20 14:14:56 -0700 | [diff] [blame] | 1195 | public void onDeleteRequested(Uri lookupUri); |
Dmitri Plotnikov | caf0bc7 | 2010-09-03 15:16:21 -0700 | [diff] [blame] | 1196 | |
| 1197 | /** |
| 1198 | * User requested creation of a new contact with the specified values. |
| 1199 | * |
| 1200 | * @param values ContentValues containing data rows for the new contact. |
| 1201 | * @param account Account where the new contact should be created |
| 1202 | */ |
| 1203 | public void onCreateRawContactRequested(ArrayList<ContentValues> values, Account account); |
Daniel Lehmann | 18f104f | 2010-05-07 15:41:11 -0700 | [diff] [blame] | 1204 | } |
Daniel Lehmann | 4cd9441 | 2010-04-08 16:44:36 -0700 | [diff] [blame] | 1205 | } |