Dmitri Plotnikov | 501b7ea | 2010-04-07 17:20:49 -0700 | [diff] [blame] | 1 | /* |
Dmitri Plotnikov | e4d32d9 | 2010-05-10 19:06:22 -0700 | [diff] [blame^] | 2 | * Copyright (C) 2009 The Android Open Source Project |
Dmitri Plotnikov | 501b7ea | 2010-04-07 17:20:49 -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 | |
| 17 | package com.android.contacts; |
| 18 | |
Dmitri Plotnikov | 6e2009d | 2010-04-22 16:03:53 -0700 | [diff] [blame] | 19 | |
Dmitri Plotnikov | 59fb48e | 2010-04-26 17:09:19 -0700 | [diff] [blame] | 20 | import com.android.contacts.list.JoinContactListFragment; |
Dmitri Plotnikov | e4d32d9 | 2010-05-10 19:06:22 -0700 | [diff] [blame^] | 21 | import com.android.contacts.list.OnContactPickerActionListener; |
Dmitri Plotnikov | 807a0fe | 2010-04-20 12:03:10 -0700 | [diff] [blame] | 22 | |
Dmitri Plotnikov | e4d32d9 | 2010-05-10 19:06:22 -0700 | [diff] [blame^] | 23 | import android.app.Activity; |
| 24 | import android.app.FragmentTransaction; |
Dmitri Plotnikov | 501b7ea | 2010-04-07 17:20:49 -0700 | [diff] [blame] | 25 | import android.content.Intent; |
Dmitri Plotnikov | 501b7ea | 2010-04-07 17:20:49 -0700 | [diff] [blame] | 26 | import android.net.Uri; |
Dmitri Plotnikov | e4d32d9 | 2010-05-10 19:06:22 -0700 | [diff] [blame^] | 27 | import android.os.Bundle; |
Dmitri Plotnikov | 501b7ea | 2010-04-07 17:20:49 -0700 | [diff] [blame] | 28 | import android.provider.ContactsContract; |
Dmitri Plotnikov | 501b7ea | 2010-04-07 17:20:49 -0700 | [diff] [blame] | 29 | import android.util.Log; |
Dmitri Plotnikov | 501b7ea | 2010-04-07 17:20:49 -0700 | [diff] [blame] | 30 | |
| 31 | /** |
| 32 | * An activity that shows a list of contacts that can be joined with the target contact. |
| 33 | */ |
Dmitri Plotnikov | e4d32d9 | 2010-05-10 19:06:22 -0700 | [diff] [blame^] | 34 | public class JoinContactActivity extends Activity { |
Dmitri Plotnikov | 501b7ea | 2010-04-07 17:20:49 -0700 | [diff] [blame] | 35 | |
| 36 | private static final String TAG = "JoinContactActivity"; |
| 37 | |
| 38 | /** |
| 39 | * The action for the join contact activity. |
| 40 | * <p> |
| 41 | * Input: extra field {@link #EXTRA_TARGET_CONTACT_ID} is the aggregate ID. |
| 42 | * TODO: move to {@link ContactsContract}. |
| 43 | */ |
| 44 | public static final String JOIN_CONTACT = "com.android.contacts.action.JOIN_CONTACT"; |
| 45 | |
| 46 | /** |
| 47 | * Used with {@link #JOIN_CONTACT} to give it the target for aggregation. |
| 48 | * <p> |
| 49 | * Type: LONG |
| 50 | */ |
| 51 | public static final String EXTRA_TARGET_CONTACT_ID = "com.android.contacts.action.CONTACT_ID"; |
| 52 | |
Dmitri Plotnikov | 501b7ea | 2010-04-07 17:20:49 -0700 | [diff] [blame] | 53 | private long mTargetContactId; |
| 54 | |
Dmitri Plotnikov | 501b7ea | 2010-04-07 17:20:49 -0700 | [diff] [blame] | 55 | @Override |
Dmitri Plotnikov | e4d32d9 | 2010-05-10 19:06:22 -0700 | [diff] [blame^] | 56 | protected void onCreate(Bundle savedInstanceState) { |
| 57 | super.onCreate(savedInstanceState); |
| 58 | |
| 59 | Intent intent = getIntent(); |
Dmitri Plotnikov | 501b7ea | 2010-04-07 17:20:49 -0700 | [diff] [blame] | 60 | mTargetContactId = intent.getLongExtra(EXTRA_TARGET_CONTACT_ID, -1); |
| 61 | if (mTargetContactId == -1) { |
| 62 | Log.e(TAG, "Intent " + intent.getAction() + " is missing required extra: " |
| 63 | + EXTRA_TARGET_CONTACT_ID); |
| 64 | setResult(RESULT_CANCELED); |
| 65 | finish(); |
Dmitri Plotnikov | e4d32d9 | 2010-05-10 19:06:22 -0700 | [diff] [blame^] | 66 | return; |
Dmitri Plotnikov | 501b7ea | 2010-04-07 17:20:49 -0700 | [diff] [blame] | 67 | } |
Dmitri Plotnikov | 59fb48e | 2010-04-26 17:09:19 -0700 | [diff] [blame] | 68 | |
Dmitri Plotnikov | e4d32d9 | 2010-05-10 19:06:22 -0700 | [diff] [blame^] | 69 | JoinContactListFragment fragment = new JoinContactListFragment(); |
| 70 | fragment.setTargetContactId(mTargetContactId); |
| 71 | fragment.setOnContactPickerActionListener(new OnContactPickerActionListener() { |
| 72 | public void onPickContactAction(Uri contactUri) { |
| 73 | Intent intent = new Intent(null, contactUri); |
| 74 | setResult(RESULT_OK, intent); |
| 75 | finish(); |
Dmitri Plotnikov | 501b7ea | 2010-04-07 17:20:49 -0700 | [diff] [blame] | 76 | } |
| 77 | |
Dmitri Plotnikov | e4d32d9 | 2010-05-10 19:06:22 -0700 | [diff] [blame^] | 78 | public void onSearchAllContactsAction(String string) { |
Dmitri Plotnikov | 501b7ea | 2010-04-07 17:20:49 -0700 | [diff] [blame] | 79 | } |
| 80 | |
Dmitri Plotnikov | e4d32d9 | 2010-05-10 19:06:22 -0700 | [diff] [blame^] | 81 | public void onShortcutIntentCreated(Intent intent) { |
| 82 | } |
Dmitri Plotnikov | 501b7ea | 2010-04-07 17:20:49 -0700 | [diff] [blame] | 83 | |
Dmitri Plotnikov | e4d32d9 | 2010-05-10 19:06:22 -0700 | [diff] [blame^] | 84 | public void onCreateNewContactAction() { |
| 85 | } |
| 86 | }); |
| 87 | |
| 88 | FragmentTransaction transaction = openFragmentTransaction(); |
| 89 | transaction.add(fragment, android.R.id.content); |
| 90 | transaction.commit(); |
Dmitri Plotnikov | 501b7ea | 2010-04-07 17:20:49 -0700 | [diff] [blame] | 91 | } |
Dmitri Plotnikov | 501b7ea | 2010-04-07 17:20:49 -0700 | [diff] [blame] | 92 | } |