Contact picker: add search icon & hide searchview
Hide/unhide the SearchView when you click a seach menu item.
This is the first and more important step for b/16190113.
In a later CL, I might remove the SearchView and replace it
with the custom actionbar view created by dialer & used
in PeopleActivity.
Also merged JoinContactActivity into ContactSelectionActivity.
Bug: 16190113
Change-Id: I04bf7d22dffbf7f104362b17c9064cb386a01abe
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 69d211e..1175fe7 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -176,6 +176,11 @@
<data android:mimeType="vnd.android.cursor.item/postal-address_v2" />
<data android:mimeType="vnd.android.cursor.item/postal-address" />
</intent-filter>
+
+ <intent-filter>
+ <action android:name="com.android.contacts.action.JOIN_CONTACT" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
</activity>
<!-- Backwards compatibility: somebody may have hard coded this activity name -->
@@ -195,17 +200,6 @@
android:exported="true"
/>
- <!-- An activity for joining contacts -->
- <activity android:name=".activities.JoinContactActivity"
- android:theme="@style/JoinContactActivityTheme"
- android:clearTaskOnLaunch="true"
- >
- <intent-filter>
- <action android:name="com.android.contacts.action.JOIN_CONTACT" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity>
-
<!-- Used to set options -->
<activity
android:name=".preference.ContactsPreferenceActivity"
diff --git a/res/layout-sw600dp/join_contact_picker.xml b/res/layout-sw600dp/join_contact_picker.xml
deleted file mode 100644
index 9de85db..0000000
--- a/res/layout-sw600dp/join_contact_picker.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<view xmlns:android="http://schemas.android.com/apk/res/android"
- class="com.android.contacts.widget.FullHeightLinearLayout"
- style="@style/ContactPickerLayout"
- android:orientation="vertical">
- <!-- See also comments in contact_picker.xml -->
- <view
- class="android.widget.SearchView"
- android:id="@+id/search_view"
- android:layout_width="match_parent"
- android:maxWidth="@dimen/contact_picker_search_view_max_width"
- android:layout_height="wrap_content"
- android:layout_marginLeft="0dip"
- android:layout_marginRight="@dimen/list_visible_scrollbar_padding"
- android:layout_marginStart="0dip"
- android:layout_marginEnd="@dimen/list_visible_scrollbar_padding"
- android:paddingRight="0dip"
- android:paddingEnd="0dip"
- android:iconifiedByDefault="false" />
-
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="0dip"
- android:layout_weight="1"
- android:id="@+id/list_container" />
-</view>
diff --git a/res/layout/join_contact_picker.xml b/res/layout/join_contact_picker.xml
deleted file mode 100644
index ee30525..0000000
--- a/res/layout/join_contact_picker.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<view xmlns:android="http://schemas.android.com/apk/res/android"
- class="com.android.contacts.widget.FullHeightLinearLayout"
- style="@style/ContactPickerLayout"
- android:orientation="vertical">
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="0dip"
- android:layout_weight="1"
- android:id="@+id/list_container" />
-</view>
diff --git a/res/menu/search_menu.xml b/res/menu/search_menu.xml
new file mode 100644
index 0000000..355442e
--- /dev/null
+++ b/res/menu/search_menu.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <item
+ android:id="@+id/menu_search"
+ android:icon="@drawable/ic_ab_search"
+ android:title="@string/menu_search"
+ android:showAsAction="always" />
+</menu>
diff --git a/res/values-sw600dp/styles.xml b/res/values-sw600dp/styles.xml
index aa28dbf..17b1f69 100644
--- a/res/values-sw600dp/styles.xml
+++ b/res/values-sw600dp/styles.xml
@@ -19,12 +19,6 @@
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
</style>
- <style name="JoinContactActivityTheme" parent="ContactPickerTheme" >
- <item name="android:layout_width">match_parent</item>
- <item name="android:layout_height">match_parent</item>
- <!-- In the contact picker screen we're using adjustResize but we don't want it here. -->
- <item name="android:windowSoftInputMode">adjustUnspecified</item>
- </style>
<style name="DetailActivityTheme" parent="@android:Theme.Dialog">
<item name="android:windowContentOverlay">@null</item>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 1eae4d0..af3c031 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -171,9 +171,6 @@
<item name="android:layout_height">match_parent</item>
</style>
- <style name="JoinContactActivityTheme" parent="ContactPickerTheme" >
- </style>
-
<style name="ContactsPreferencesTheme" parent="@style/PeopleTheme">
<item name="android:listViewStyle">@style/ListViewStyle</item>
</style>
diff --git a/src/com/android/contacts/activities/ContactSelectionActivity.java b/src/com/android/contacts/activities/ContactSelectionActivity.java
index c67a50e..c35f192 100644
--- a/src/com/android/contacts/activities/ContactSelectionActivity.java
+++ b/src/com/android/contacts/activities/ContactSelectionActivity.java
@@ -27,9 +27,12 @@
import android.os.Bundle;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Intents.Insert;
+import android.provider.ContactsContract.Intents.UI;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
@@ -48,6 +51,7 @@
import com.android.contacts.list.ContactsRequest;
import com.android.contacts.common.list.DirectoryListLoader;
import com.android.contacts.list.EmailAddressPickerFragment;
+import com.android.contacts.list.JoinContactListFragment;
import com.android.contacts.list.LegacyPhoneNumberPickerFragment;
import com.android.contacts.list.OnContactPickerActionListener;
import com.android.contacts.list.OnEmailAddressPickerActionListener;
@@ -71,15 +75,18 @@
private static final int SUBACTIVITY_ADD_TO_EXISTING_CONTACT = 0;
private static final String KEY_ACTION_CODE = "actionCode";
+ private static final String KEY_SEARCH_MODE = "searchMode";
private static final int DEFAULT_DIRECTORY_RESULT_LIMIT = 20;
private ContactsIntentResolver mIntentResolver;
protected ContactEntryListFragment<?> mListFragment;
private int mActionCode = -1;
+ private boolean mIsSearchMode;
private ContactsRequest mRequest;
private SearchView mSearchView;
+ private View mSearchViewContainer;
public ContactSelectionActivity() {
mIntentResolver = new ContactsIntentResolver(this);
@@ -99,6 +106,7 @@
if (savedState != null) {
mActionCode = savedState.getInt(KEY_ACTION_CODE);
+ mIsSearchMode = savedState.getBoolean(KEY_SEARCH_MODE);
}
// Extract relevant information from the intent
@@ -131,9 +139,9 @@
private void prepareSearchViewAndActionBar() {
final ActionBar actionBar = getActionBar();
- final View searchViewContainer = LayoutInflater.from(actionBar.getThemedContext())
+ mSearchViewContainer = LayoutInflater.from(actionBar.getThemedContext())
.inflate(R.layout.custom_action_bar, null);
- mSearchView = (SearchView) searchViewContainer.findViewById(R.id.search_view);
+ mSearchView = (SearchView) mSearchViewContainer.findViewById(R.id.search_view);
// Postal address pickers (and legacy pickers) don't support search, so just show
// "HomeAsUp" button and title.
@@ -148,25 +156,39 @@
return;
}
+ actionBar.setDisplayShowHomeEnabled(true);
+ actionBar.setDisplayHomeAsUpEnabled(true);
+
// In order to make the SearchView look like "shown via search menu", we need to
// manually setup its state. See also DialtactsActivity.java and ActionBarAdapter.java.
mSearchView.setIconifiedByDefault(true);
mSearchView.setQueryHint(getString(R.string.hint_findContacts));
mSearchView.setIconified(false);
+ mSearchView.setFocusable(true);
mSearchView.setOnQueryTextListener(this);
mSearchView.setOnCloseListener(this);
mSearchView.setOnQueryTextFocusChangeListener(this);
- actionBar.setCustomView(searchViewContainer,
+ actionBar.setCustomView(mSearchViewContainer,
new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
actionBar.setDisplayShowCustomEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowTitleEnabled(false);
- // Clear focus and suppress keyboard show-up.
- mSearchView.clearFocus();
+ configureSearchMode();
+ }
+
+ private void configureSearchMode() {
+ final ActionBar actionBar = getActionBar();
+ if (mIsSearchMode) {
+ actionBar.setDisplayShowTitleEnabled(false);
+ mSearchViewContainer.setVisibility(View.VISIBLE);
+ mSearchView.requestFocus();
+ } else {
+ actionBar.setDisplayShowTitleEnabled(true);
+ mSearchViewContainer.setVisibility(View.GONE);
+ mSearchView.setQuery(null, true);
+ }
+ invalidateOptionsMenu();
}
@Override
@@ -175,7 +197,11 @@
case android.R.id.home:
// Go back to previous screen, intending "cancel"
setResult(RESULT_CANCELED);
- finish();
+ onBackPressed();
+ return true;
+ case R.id.menu_search:
+ mIsSearchMode = !mIsSearchMode;
+ configureSearchMode();
return true;
}
return super.onOptionsItemSelected(item);
@@ -185,6 +211,7 @@
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt(KEY_ACTION_CODE, mActionCode);
+ outState.putBoolean(KEY_SEARCH_MODE, mIsSearchMode);
}
private void configureActivityTitle() {
@@ -239,6 +266,11 @@
setTitle(R.string.contactPickerActivityTitle);
break;
}
+
+ case ContactsRequest.ACTION_PICK_JOIN: {
+ setTitle(R.string.titleJoinContactDataWith);
+ break;
+ }
}
}
@@ -307,10 +339,18 @@
case ContactsRequest.ACTION_PICK_POSTAL: {
PostalAddressPickerFragment fragment = new PostalAddressPickerFragment();
+
mListFragment = fragment;
break;
}
+ case ContactsRequest.ACTION_PICK_JOIN: {
+ JoinContactListFragment joinFragment = new JoinContactListFragment();
+ joinFragment.setTargetContactId(getTargetContactId());
+ mListFragment = joinFragment;
+ break;
+ }
+
default:
throw new IllegalStateException("Invalid action code: " + mActionCode);
}
@@ -347,6 +387,9 @@
} else if (mListFragment instanceof EmailAddressPickerFragment) {
((EmailAddressPickerFragment) mListFragment).setOnEmailAddressPickerActionListener(
new EmailAddressPickerActionListener());
+ } else if (mListFragment instanceof JoinContactListFragment) {
+ ((JoinContactListFragment) mListFragment).setOnContactPickerActionListener(
+ new JoinContactActionListener());
} else {
throw new IllegalStateException("Unsupported list fragment type: " + mListFragment);
}
@@ -460,6 +503,27 @@
}
}
+ private final class JoinContactActionListener implements OnContactPickerActionListener {
+ @Override
+ public void onPickContactAction(Uri contactUri) {
+ Intent intent = new Intent(null, contactUri);
+ setResult(RESULT_OK, intent);
+ finish();
+ }
+
+ @Override
+ public void onShortcutIntentCreated(Intent intent) {
+ }
+
+ @Override
+ public void onCreateNewContactAction() {
+ }
+
+ @Override
+ public void onEditContactAction(Uri contactLookupUri) {
+ }
+ }
+
private final class PostalAddressPickerActionListener implements
OnPostalAddressPickerActionListener {
@Override
@@ -546,6 +610,19 @@
}
}
+ private long getTargetContactId() {
+ Intent intent = getIntent();
+ final long targetContactId = intent.getLongExtra(UI.TARGET_CONTACT_ID_EXTRA_KEY, -1);
+ if (targetContactId == -1) {
+ Log.e(TAG, "Intent " + intent.getAction() + " is missing required extra: "
+ + UI.TARGET_CONTACT_ID_EXTRA_KEY);
+ setResult(RESULT_CANCELED);
+ finish();
+ return -1;
+ }
+ return targetContactId;
+ }
+
private void startCreateNewContactActivity() {
Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
intent.putExtra(ContactEditorActivity.INTENT_KEY_FINISH_ACTIVITY_ON_SAVE_COMPLETED, true);
@@ -574,4 +651,26 @@
}
}
}
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ super.onCreateOptionsMenu(menu);
+
+ final MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.search_menu, menu);
+
+ final MenuItem searchItem = menu.findItem(R.id.menu_search);
+ searchItem.setVisible(!mIsSearchMode);
+ return true;
+ }
+
+ @Override
+ public void onBackPressed() {
+ if (mIsSearchMode) {
+ mIsSearchMode = false;
+ configureSearchMode();
+ } else {
+ super.onBackPressed();
+ }
+ }
}
diff --git a/src/com/android/contacts/activities/JoinContactActivity.java b/src/com/android/contacts/activities/JoinContactActivity.java
deleted file mode 100644
index c345a01..0000000
--- a/src/com/android/contacts/activities/JoinContactActivity.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.contacts.activities;
-
-
-import android.app.ActionBar;
-import android.app.ActionBar.LayoutParams;
-import android.app.Fragment;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.provider.ContactsContract;
-import android.text.TextUtils;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.View.OnFocusChangeListener;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.SearchView;
-import android.widget.SearchView.OnCloseListener;
-import android.widget.SearchView.OnQueryTextListener;
-
-import com.android.contacts.ContactsActivity;
-import com.android.contacts.R;
-import com.android.contacts.common.list.ContactEntryListFragment;
-import com.android.contacts.list.JoinContactListFragment;
-import com.android.contacts.list.OnContactPickerActionListener;
-
-/**
- * An activity that shows a list of contacts that can be joined with the target contact.
- */
-public class JoinContactActivity extends ContactsActivity
- implements OnQueryTextListener, OnCloseListener, OnFocusChangeListener {
-
- private static final String TAG = "JoinContactActivity";
-
- /**
- * The action for the join contact activity.
- * <p>
- * Input: extra field {@link #EXTRA_TARGET_CONTACT_ID} is the aggregate ID.
- * TODO: move to {@link ContactsContract}.
- */
- public static final String JOIN_CONTACT = "com.android.contacts.action.JOIN_CONTACT";
-
- /**
- * Used with {@link #JOIN_CONTACT} to give it the target for aggregation.
- * <p>
- * Type: LONG
- */
- public static final String EXTRA_TARGET_CONTACT_ID = "com.android.contacts.action.CONTACT_ID";
-
- private static final String KEY_TARGET_CONTACT_ID = "targetContactId";
-
- private long mTargetContactId;
-
- private JoinContactListFragment mListFragment;
- private SearchView mSearchView;
-
- @Override
- public void onAttachFragment(Fragment fragment) {
- if (fragment instanceof JoinContactListFragment) {
- mListFragment = (JoinContactListFragment) fragment;
- setupActionListener();
- }
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- Intent intent = getIntent();
- mTargetContactId = intent.getLongExtra(EXTRA_TARGET_CONTACT_ID, -1);
- if (mTargetContactId == -1) {
- Log.e(TAG, "Intent " + intent.getAction() + " is missing required extra: "
- + EXTRA_TARGET_CONTACT_ID);
- setResult(RESULT_CANCELED);
- finish();
- return;
- }
-
- setContentView(R.layout.join_contact_picker);
- setTitle(R.string.titleJoinContactDataWith);
-
- if (mListFragment == null) {
- mListFragment = new JoinContactListFragment();
-
- getFragmentManager().beginTransaction()
- .replace(R.id.list_container, mListFragment)
- .commitAllowingStateLoss();
- }
-
- prepareSearchViewAndActionBar();
- }
-
- private void setupActionListener() {
- mListFragment.setTargetContactId(mTargetContactId);
- mListFragment.setOnContactPickerActionListener(new OnContactPickerActionListener() {
- @Override
- public void onPickContactAction(Uri contactUri) {
- Intent intent = new Intent(null, contactUri);
- setResult(RESULT_OK, intent);
- finish();
- }
-
- @Override
- public void onShortcutIntentCreated(Intent intent) {
- }
-
- @Override
- public void onCreateNewContactAction() {
- }
-
- @Override
- public void onEditContactAction(Uri contactLookupUri) {
- }
- });
- }
-
- private void prepareSearchViewAndActionBar() {
- final ActionBar actionBar = getActionBar();
- if (actionBar != null) {
- final View searchViewOnLayout = findViewById(R.id.search_view);
- if (searchViewOnLayout != null) {
- searchViewOnLayout.setVisibility(View.GONE);
- }
-
- final View searchViewLayout = LayoutInflater.from(actionBar.getThemedContext())
- .inflate(R.layout.custom_action_bar, null);
- mSearchView = (SearchView) searchViewLayout.findViewById(R.id.search_view);
-
- // In order to make the SearchView look like "shown via search menu", we need to
- // manually setup its state. See also DialtactsActivity.java and ActionBarAdapter.java.
- mSearchView.setIconifiedByDefault(true);
- mSearchView.setQueryHint(getString(R.string.hint_findContacts));
- mSearchView.setIconified(false);
-
- mSearchView.setOnQueryTextListener(this);
- mSearchView.setOnCloseListener(this);
- mSearchView.setOnQueryTextFocusChangeListener(this);
-
- actionBar.setCustomView(searchViewLayout,
- new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
- actionBar.setDisplayShowCustomEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
- actionBar.setDisplayHomeAsUpEnabled(true);
- } else {
- mSearchView = (SearchView) findViewById(R.id.search_view);
- mSearchView.setQueryHint(getString(R.string.hint_findContacts));
- mSearchView.setOnQueryTextListener(this);
- mSearchView.setOnQueryTextFocusChangeListener(this);
- }
-
- // Clear focus and suppress keyboard show-up.
- mSearchView.clearFocus();
- }
-
- @Override
- public boolean onQueryTextChange(String newText) {
- mListFragment.setQueryString(newText, true);
- return false;
- }
-
- @Override
- public boolean onQueryTextSubmit(String query) {
- return false;
- }
-
- @Override
- public boolean onClose() {
- if (!TextUtils.isEmpty(mSearchView.getQuery())) {
- mSearchView.setQuery(null, true);
- }
- return true;
- }
-
- @Override
- public void onFocusChange(View view, boolean hasFocus) {
- switch (view.getId()) {
- case R.id.search_view: {
- if (hasFocus) {
- showInputMethod(mSearchView.findFocus());
- }
- }
- }
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- // Go back to previous screen, intending "cancel"
- setResult(RESULT_CANCELED);
- finish();
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- outState.putLong(KEY_TARGET_CONTACT_ID, mTargetContactId);
- }
-
- @Override
- protected void onRestoreInstanceState(Bundle savedInstanceState) {
- super.onRestoreInstanceState(savedInstanceState);
- mTargetContactId = savedInstanceState.getLong(KEY_TARGET_CONTACT_ID);
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode == ContactEntryListFragment.ACTIVITY_REQUEST_CODE_PICKER
- && resultCode == RESULT_OK) {
- mListFragment.onPickerResult(data);
- }
- }
-
- private void showInputMethod(View view) {
- final InputMethodManager imm = (InputMethodManager)
- getSystemService(Context.INPUT_METHOD_SERVICE);
- if (imm != null) {
- if (!imm.showSoftInput(view, 0)) {
- Log.w(TAG, "Failed to show soft input method.");
- }
- }
- }
-}
diff --git a/src/com/android/contacts/editor/ContactEditorFragment.java b/src/com/android/contacts/editor/ContactEditorFragment.java
index 1b950d2..b4ec7f9 100644
--- a/src/com/android/contacts/editor/ContactEditorFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorFragment.java
@@ -49,6 +49,7 @@
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Groups;
import android.provider.ContactsContract.Intents;
+import android.provider.ContactsContract.Intents.UI;
import android.provider.ContactsContract.QuickContact;
import android.provider.ContactsContract.RawContacts;
import android.text.TextUtils;
@@ -71,7 +72,6 @@
import com.android.contacts.R;
import com.android.contacts.activities.ContactEditorAccountsChangedActivity;
import com.android.contacts.activities.ContactEditorActivity;
-import com.android.contacts.activities.JoinContactActivity;
import com.android.contacts.common.model.AccountTypeManager;
import com.android.contacts.common.model.ValuesDelta;
import com.android.contacts.common.model.account.AccountType;
@@ -1377,8 +1377,8 @@
mContactIdForJoin = ContentUris.parseId(contactLookupUri);
mContactWritableForJoin = isContactWritable();
- final Intent intent = new Intent(JoinContactActivity.JOIN_CONTACT);
- intent.putExtra(JoinContactActivity.EXTRA_TARGET_CONTACT_ID, mContactIdForJoin);
+ final Intent intent = new Intent(UI.PICK_JOIN_CONTACT_ACTION);
+ intent.putExtra(UI.TARGET_CONTACT_ID_EXTRA_KEY, mContactIdForJoin);
startActivityForResult(intent, REQUEST_CODE_JOIN);
}
diff --git a/src/com/android/contacts/list/ContactsIntentResolver.java b/src/com/android/contacts/list/ContactsIntentResolver.java
index 838393e..b4416be 100644
--- a/src/com/android/contacts/list/ContactsIntentResolver.java
+++ b/src/com/android/contacts/list/ContactsIntentResolver.java
@@ -173,6 +173,8 @@
request.setContactUri(data);
intent.setAction(Intent.ACTION_DEFAULT);
intent.setData(null);
+ } else if (UI.PICK_JOIN_CONTACT_ACTION.equals(action)) {
+ request.setActionCode(ContactsRequest.ACTION_PICK_JOIN);
}
// Allow the title to be set to a custom String using an extra on the intent
String title = intent.getStringExtra(UI.TITLE_EXTRA_KEY);
diff --git a/src/com/android/contacts/list/ContactsRequest.java b/src/com/android/contacts/list/ContactsRequest.java
index 2a26ddf..7955fde 100644
--- a/src/com/android/contacts/list/ContactsRequest.java
+++ b/src/com/android/contacts/list/ContactsRequest.java
@@ -77,6 +77,9 @@
/** Show all contacts and activate the specified one */
public static final int ACTION_VIEW_CONTACT = 140;
+ /** Show contacts recommended for joining with a specified target contact */
+ public static final int ACTION_PICK_JOIN = 150;
+
private boolean mValid = true;
private int mActionCode = ACTION_DEFAULT;
private Intent mRedirectIntent;