Revert "Handle group insert, view, and edit intents (1/2)"
This reverts commit 01c2f7f2e324dbf7ce70229ecb29f9c33542be0e.
Change-Id: I161c7a2277979f281d7579894b8f64e918082e7f
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 8af3e71..842d1b7 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -138,12 +138,6 @@
<data android:mimeType="vnd.android.cursor.dir/contact" />
</intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.INSERT" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="vnd.android.cursor.dir/group" />
- </intent-filter>
-
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable"
/>
@@ -273,20 +267,7 @@
<!-- Displays the members of a group in a list -->
<activity android:name=".activities.GroupMembersActivity"
- android:theme="@style/PeopleActivityTheme">
-
- <intent-filter>
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="vnd.android.cursor.item/group" />
- </intent-filter>
-
- <intent-filter>
- <action android:name="android.intent.action.EDIT" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="vnd.android.cursor.item/group" />
- </intent-filter>
- </activity>
+ android:theme="@style/PeopleActivityTheme"/>
<activity
android:name=".quickcontact.QuickContactActivity"
diff --git a/src/com/android/contacts/ContactsDrawerActivity.java b/src/com/android/contacts/ContactsDrawerActivity.java
index a12d0e1..b62d5e6 100644
--- a/src/com/android/contacts/ContactsDrawerActivity.java
+++ b/src/com/android/contacts/ContactsDrawerActivity.java
@@ -426,7 +426,7 @@
}
}
- protected void onCreateGroupMenuItemClicked() {
+ private void onCreateGroupMenuItemClicked() {
// Select the account to create the group
final Bundle extras = getIntent().getExtras();
final Account account = extras == null ? null :
diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java
index 756aeb4..8429d2a 100644
--- a/src/com/android/contacts/activities/PeopleActivity.java
+++ b/src/com/android/contacts/activities/PeopleActivity.java
@@ -281,18 +281,12 @@
return false;
}
- switch (mRequest.getActionCode()) {
- case ContactsRequest.ACTION_VIEW_CONTACT: {
- final Intent intent = ImplicitIntentsUtil.composeQuickContactIntent(
- mRequest.getContactUri(), QuickContactActivity.MODE_FULLY_EXPANDED);
- intent.putExtra(QuickContactActivity.EXTRA_PREVIOUS_SCREEN_TYPE, ScreenType.UNKNOWN);
- ImplicitIntentsUtil.startActivityInApp(this, intent);
- return false;
- }
- case ContactsRequest.ACTION_INSERT_GROUP: {
- onCreateGroupMenuItemClicked();
- return true;
- }
+ if (mRequest.getActionCode() == ContactsRequest.ACTION_VIEW_CONTACT) {
+ final Intent intent = ImplicitIntentsUtil.composeQuickContactIntent(
+ mRequest.getContactUri(), QuickContactActivity.MODE_FULLY_EXPANDED);
+ intent.putExtra(QuickContactActivity.EXTRA_PREVIOUS_SCREEN_TYPE, ScreenType.UNKNOWN);
+ ImplicitIntentsUtil.startActivityInApp(this, intent);
+ return false;
}
return true;
}
diff --git a/src/com/android/contacts/group/GroupUtil.java b/src/com/android/contacts/group/GroupUtil.java
index 41dfa8c..beba2ea 100644
--- a/src/com/android/contacts/group/GroupUtil.java
+++ b/src/com/android/contacts/group/GroupUtil.java
@@ -49,6 +49,9 @@
@NeededForTesting
public final class GroupUtil {
+ private static final String LEGACY_CONTACTS_AUTHORITY = "contacts";
+ private static final String LEGACY_CONTACTS_URI = "content://contacts/groups";
+
// System IDs of FFC groups in Google accounts
private static final Set<String> FFC_GROUPS =
new HashSet(Arrays.asList("Friends", "Family", "Coworkers"));
@@ -140,6 +143,21 @@
}
/**
+ * Converts the given group Uri to the legacy format if the legacy authority was specified
+ * in the given Uri.
+ */
+ // TODO(wjang):
+ public static Uri maybeConvertToLegacyUri(Uri groupUri) {
+ final String requestAuthority = groupUri.getAuthority();
+ if (!LEGACY_CONTACTS_AUTHORITY.equals(requestAuthority)) {
+ return groupUri;
+ }
+ final long groupId = ContentUris.parseId(groupUri);
+ final Uri legacyContentUri = Uri.parse(LEGACY_CONTACTS_URI);
+ return ContentUris.withAppendedId(legacyContentUri, groupId);
+ }
+
+ /**
* Returns true if it's an empty and read-only group of a Google account and the system ID of
* the group is one of "Friends", "Family" and "Coworkers".
*/
diff --git a/src/com/android/contacts/list/ContactsIntentResolver.java b/src/com/android/contacts/list/ContactsIntentResolver.java
index 800ed11..39eaeba 100644
--- a/src/com/android/contacts/list/ContactsIntentResolver.java
+++ b/src/com/android/contacts/list/ContactsIntentResolver.java
@@ -16,6 +16,7 @@
package com.android.contacts.list;
+import android.accounts.Account;
import android.app.Activity;
import android.app.SearchManager;
import android.content.Intent;
@@ -130,9 +131,6 @@
}
} else if (Intent.ACTION_INSERT_OR_EDIT.equals(action)) {
request.setActionCode(ContactsRequest.ACTION_INSERT_OR_EDIT_CONTACT);
- } else if (Intent.ACTION_INSERT.equals(action) &&
- Groups.CONTENT_TYPE.equals(intent.getType())) {
- request.setActionCode(ContactsRequest.ACTION_INSERT_GROUP);
} else if (Intent.ACTION_SEARCH.equals(action)) {
String query = intent.getStringExtra(SearchManager.QUERY);
// If the {@link SearchManager.QUERY} is empty, then check if a phone number
diff --git a/src/com/android/contacts/list/ContactsRequest.java b/src/com/android/contacts/list/ContactsRequest.java
index e9b3a86..615fac6 100644
--- a/src/com/android/contacts/list/ContactsRequest.java
+++ b/src/com/android/contacts/list/ContactsRequest.java
@@ -42,9 +42,6 @@
/** Show potential new members of a specific group */
public static final int ACTION_PICK_GROUP_MEMBERS = 21;
- /** Create a new group */
- public static final int ACTION_INSERT_GROUP = 22;
-
/** Show all starred contacts */
public static final int ACTION_STARRED = 30;
diff --git a/tests/res/values/donottranslate_strings.xml b/tests/res/values/donottranslate_strings.xml
index 3c3e5cc..bd30d6e 100644
--- a/tests/res/values/donottranslate_strings.xml
+++ b/tests/res/values/donottranslate_strings.xml
@@ -39,14 +39,13 @@
<item>ACTION_INSERT_OR_EDIT</item>
<item>ACTION_INSERT_OR_EDIT_PHONE_NUMBER</item>
<item>ACTION_INSERT_OR_EDIT_EMAIL_ADDRESS</item>
- <item>ACTION_INSERT_GROUP</item>
<item>ACTION_SEARCH (call button)</item>
<item>ACTION_SEARCH: contact</item>
<item>ACTION_SEARCH: email</item>
<item>ACTION_SEARCH: phone</item>
<item>SEARCH_SUGGESTION_CLICKED: contact</item>
- <!-- Edit -->
+ <!-- Edit Contact -->
<item>EDIT (content uri with only id)</item>
<item>EDIT (lookup uri without id)</item>
<item>EDIT (lookup uri)</item>
@@ -58,15 +57,13 @@
<item>EDIT (create new contact for account with data)</item>
<item>EDIT (create new raw contact)</item>
<item>EDIT (create new legacy)</item>
- <item>EDIT (group)</item>
- <!-- View -->
+ <!-- View Contact -->
<item>VIEW (content uri with only id)</item>
<item>VIEW (lookup uri without id)</item>
<item>VIEW (lookup uri)</item>
<item>VIEW (called for raw contact)</item>
<item>VIEW (legacy style uri)</item>
- <item>VIEW (group)</item>
<!-- Various ways to start Contacts -->
<item>QuickContactTestsActivity</item>
diff --git a/tests/src/com/android/contacts/tests/allintents/AllIntentsActivity.java b/tests/src/com/android/contacts/tests/allintents/AllIntentsActivity.java
index 926f75e..f0b285b 100644
--- a/tests/src/com/android/contacts/tests/allintents/AllIntentsActivity.java
+++ b/tests/src/com/android/contacts/tests/allintents/AllIntentsActivity.java
@@ -35,7 +35,6 @@
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Data;
-import android.provider.ContactsContract.Groups;
import android.provider.ContactsContract.Intents;
import android.provider.ContactsContract.Intents.Insert;
import android.provider.ContactsContract.RawContacts;
@@ -44,7 +43,6 @@
import android.widget.ListView;
import android.widget.Toast;
-import com.android.contacts.GroupListLoader;
import com.android.contacts.tests.R;
import com.android.contacts.tests.quickcontact.QuickContactTestsActivity;
@@ -87,7 +85,6 @@
ACTION_INSERT_OR_EDIT,
ACTION_INSERT_OR_EDIT_PHONE_NUMBER,
ACTION_INSERT_OR_EDIT_EMAIL_ADDRESS,
- ACTION_INSERT_GROUP,
ACTION_SEARCH_CALL,
ACTION_SEARCH_CONTACT,
ACTION_SEARCH_EMAIL,
@@ -104,13 +101,11 @@
EDIT_NEW_CONTACT_FOR_ACCOUNT_WITH_DATA,
EDIT_NEW_RAW_CONTACT,
EDIT_NEW_LEGACY,
- EDIT_GROUP,
VIEW_CONTACT,
VIEW_CONTACT_LOOKUP,
VIEW_CONTACT_LOOKUP_ID,
VIEW_RAW_CONTACT,
VIEW_LEGACY,
- VIEW_GROUP,
QUICK_CONTACT_TESTS_ACTIVITY;
public static ContactsIntent get(int ordinal) {
@@ -243,12 +238,6 @@
startActivity(intent);
break;
}
- case ACTION_INSERT_GROUP: {
- final Intent intent = new Intent(Intent.ACTION_INSERT);
- intent.setType(Groups.CONTENT_TYPE);
- startActivity(intent);
- break;
- }
case ACTION_SEARCH_CALL: {
Intent intent = new Intent(Intent.ACTION_SEARCH);
intent.putExtra(SearchManager.ACTION_MSG, "call");
@@ -369,13 +358,6 @@
startActivity(new Intent(Intent.ACTION_INSERT, legacyContentUri));
break;
}
- case EDIT_GROUP: {
- final Intent intent = findArbitraryGroupIntent(Intent.ACTION_EDIT);
- if (intent != null) {
- startActivity(intent);
- }
- break;
- }
case VIEW_CONTACT: {
final long contactId = findArbitraryContactWithPhoneNumber();
if (contactId != -1) {
@@ -438,13 +420,6 @@
}
break;
}
- case VIEW_GROUP: {
- final Intent intent = findArbitraryGroupIntent(Intent.ACTION_VIEW);
- if (intent != null) {
- startActivity(intent);
- }
- break;
- }
case QUICK_CONTACT_TESTS_ACTIVITY: {
startActivity(new Intent(this, QuickContactTestsActivity.class));
break;
@@ -521,34 +496,6 @@
return -1;
}
- private Intent findArbitraryGroupIntent(String action) {
- final long groupId = findArbitraryGroup();
- if (groupId == -1) return null;
- final Intent intent = new Intent(action) ;
- intent.setData(ContentUris.withAppendedId(Groups.CONTENT_URI, groupId));
- // TODO: ContactsProvider2#getType does handle the group mimetype
- intent.setClassName("com.google.android.contacts",
- "com.android.contacts.activities.GroupMembersActivity");
- return intent;
- }
-
- private long findArbitraryGroup() {
- final Cursor cursor = getContentResolver().query(Groups.CONTENT_URI,
- new String[] { Groups._ID },
- GroupListLoader.DEFAULT_SELECTION,
- null,
- "RANDOM() LIMIT 1");
- try {
- if (cursor.moveToFirst()) {
- return cursor.getLong(0);
- }
- } finally {
- cursor.close();
- }
- Toast.makeText(this, "Failed to find any group. Aborting.", Toast.LENGTH_SHORT).show();
- return -1;
- }
-
@Override
public void onAccountChosen(Account account, String dataSet, int tag) {
switch (ContactsIntent.get(tag)) {