blob: 501739d47f2749049d192890e05cd4944bcbff9a [file] [log] [blame]
Dmitri Plotnikov501b7ea2010-04-07 17:20:49 -07001/*
Dmitri Plotnikove4d32d92010-05-10 19:06:22 -07002 * Copyright (C) 2009 The Android Open Source Project
Dmitri Plotnikov501b7ea2010-04-07 17:20:49 -07003 *
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
17package com.android.contacts;
18
Dmitri Plotnikov6e2009d2010-04-22 16:03:53 -070019
Dmitri Plotnikov59fb48e2010-04-26 17:09:19 -070020import com.android.contacts.list.JoinContactListFragment;
Dmitri Plotnikove4d32d92010-05-10 19:06:22 -070021import com.android.contacts.list.OnContactPickerActionListener;
Dmitri Plotnikov807a0fe2010-04-20 12:03:10 -070022
Dmitri Plotnikove4d32d92010-05-10 19:06:22 -070023import android.app.Activity;
24import android.app.FragmentTransaction;
Dmitri Plotnikov501b7ea2010-04-07 17:20:49 -070025import android.content.Intent;
Dmitri Plotnikov501b7ea2010-04-07 17:20:49 -070026import android.net.Uri;
Dmitri Plotnikove4d32d92010-05-10 19:06:22 -070027import android.os.Bundle;
Dmitri Plotnikov501b7ea2010-04-07 17:20:49 -070028import android.provider.ContactsContract;
Dmitri Plotnikov501b7ea2010-04-07 17:20:49 -070029import android.util.Log;
Dmitri Plotnikov501b7ea2010-04-07 17:20:49 -070030
31/**
32 * An activity that shows a list of contacts that can be joined with the target contact.
33 */
Dmitri Plotnikove4d32d92010-05-10 19:06:22 -070034public class JoinContactActivity extends Activity {
Dmitri Plotnikov501b7ea2010-04-07 17:20:49 -070035
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 Plotnikov501b7ea2010-04-07 17:20:49 -070053 private long mTargetContactId;
54
Dmitri Plotnikov501b7ea2010-04-07 17:20:49 -070055 @Override
Dmitri Plotnikove4d32d92010-05-10 19:06:22 -070056 protected void onCreate(Bundle savedInstanceState) {
57 super.onCreate(savedInstanceState);
58
59 Intent intent = getIntent();
Dmitri Plotnikov501b7ea2010-04-07 17:20:49 -070060 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 Plotnikove4d32d92010-05-10 19:06:22 -070066 return;
Dmitri Plotnikov501b7ea2010-04-07 17:20:49 -070067 }
Dmitri Plotnikov59fb48e2010-04-26 17:09:19 -070068
Dmitri Plotnikove4d32d92010-05-10 19:06:22 -070069 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 Plotnikov501b7ea2010-04-07 17:20:49 -070076 }
77
Dmitri Plotnikove4d32d92010-05-10 19:06:22 -070078 public void onSearchAllContactsAction(String string) {
Dmitri Plotnikov501b7ea2010-04-07 17:20:49 -070079 }
80
Dmitri Plotnikove4d32d92010-05-10 19:06:22 -070081 public void onShortcutIntentCreated(Intent intent) {
82 }
Dmitri Plotnikov501b7ea2010-04-07 17:20:49 -070083
Dmitri Plotnikove4d32d92010-05-10 19:06:22 -070084 public void onCreateNewContactAction() {
85 }
86 });
87
88 FragmentTransaction transaction = openFragmentTransaction();
89 transaction.add(fragment, android.R.id.content);
90 transaction.commit();
Dmitri Plotnikov501b7ea2010-04-07 17:20:49 -070091 }
Dmitri Plotnikov501b7ea2010-04-07 17:20:49 -070092}