Loading tests/AndroidManifest.xml +6 −33 Original line number Diff line number Diff line Loading @@ -23,8 +23,6 @@ <uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.WRITE_CONTACTS" /> <uses-permission android:name="android.permission.READ_CALL_LOG" /> <uses-permission android:name="android.permission.WRITE_CALL_LOG" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.USE_CREDENTIALS" /> Loading @@ -37,13 +35,13 @@ <uses-permission android:name="android.permission.READ_PROFILE" /> <uses-permission android:name="android.permission.READ_SOCIAL_STREAM" /> <application> <application android:label="@string/applicationLabel"> <uses-library android:name="android.test.runner" /> <meta-data android:name="com.android.contacts.iconset" android:resource="@xml/iconset" /> <activity android:name=".allintents.AllIntentsActivity" android:label="@string/contactsIntents" > <activity android:name=".allintents.AllIntentsActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> Loading @@ -51,34 +49,9 @@ </intent-filter> </activity> <activity android:name=".allintents.ResultActivity" android:label="@string/result" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".allintents.ResultActivity"/> <activity android:name=".widget.PinnedHeaderUseCaseActivity" android:label="@string/pinnedHeaderList" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".quickcontact.QuickContactTestsActivity" android:label="@string/quickContactTests" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".quickcontact.QuickContactTestsActivity"/> <!-- Test authenticators/sync adapters. Loading tests/res/values/donottranslate_strings.xml +2 −18 Original line number Diff line number Diff line Loading @@ -15,8 +15,7 @@ --> <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <string name="contactsIntents">Contacts Intents</string> <string name="result">Result returned by activity</string> <string name="applicationLabel">Contacts Test</string> <string-array name="allIntents"> <!-- List modes --> Loading Loading @@ -45,7 +44,6 @@ <item>ACTION_SEARCH: email</item> <item>ACTION_SEARCH: phone</item> <item>SEARCH_SUGGESTION_CLICKED: contact</item> <item>TODO: JOIN_CONTACT</item> <!-- Edit Contact --> <item>EDIT (content uri with only id)</item> Loading @@ -68,23 +66,9 @@ <item>VIEW (legacy style uri)</item> <!-- Various ways to start Contacts --> <item>DIAL</item> <item>DIAL phone (deprecated)</item> <item>DIAL person (deprecated)</item> <item>DIAL voicemail</item> <item>CALL BUTTON</item> <item>DIAL tel</item> <item>VIEW tel</item> <item>VIEW calls (call-log after a phone call)</item> <item>VIEW missed calls</item> <item>VIEW voicemails</item> <item>VIEW calls item</item> <item>CallDetailActivity (legacy)</item> <item>CallLogActivity (legacy)</item> <item>QuickContactTestsActivity</item> </string-array> <string name="pinnedHeaderList">Pinned Headers</string> <string name="quickContactTests">Quick Contact modes</string> <string name="pickContact">Pick contact</string> <string name="quickContactIntent">Start with Intent</string> <string name="fillCallLogTest">Fill call log test</string> Loading tests/src/com/android/contacts/tests/allintents/AllIntentsActivity.java +5 −134 Original line number Diff line number Diff line Loading @@ -26,8 +26,6 @@ import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.provider.CallLog; import android.provider.CallLog.Calls; import android.provider.Contacts.ContactMethods; import android.provider.Contacts.People; import android.provider.Contacts.Phones; Loading @@ -46,6 +44,7 @@ import android.widget.ListView; import android.widget.Toast; import com.android.contacts.tests.R; import com.android.contacts.tests.quickcontact.QuickContactTestsActivity; import java.util.ArrayList; Loading Loading @@ -91,7 +90,6 @@ public class AllIntentsActivity extends ListActivity ACTION_SEARCH_EMAIL, ACTION_SEARCH_PHONE, SEARCH_SUGGESTION_CLICKED_CONTACT, JOIN_CONTACT, EDIT_CONTACT, EDIT_CONTACT_LOOKUP, EDIT_CONTACT_LOOKUP_ID, Loading @@ -108,19 +106,7 @@ public class AllIntentsActivity extends ListActivity VIEW_CONTACT_LOOKUP_ID, VIEW_RAW_CONTACT, VIEW_LEGACY, DIAL, DIAL_phone, DIAL_person, DIAL_voicemail, CALL_BUTTON, DIAL_tel, VIEW_tel, VIEW_CALLLOG, VIEW_CALLLOG_MISSED, VIEW_CALLLOG_VOICEMAIL, VIEW_CALLLOG_ENTRY, LEGACY_CALL_DETAILS_ACTIVITY, LEGACY_CALL_LOG_ACTIVITY; QUICK_CONTACT_TESTS_ACTIVITY; public static ContactsIntent get(int ordinal) { return values()[ordinal]; Loading @@ -130,6 +116,7 @@ public class AllIntentsActivity extends ListActivity @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new ArrayAdapter<String>(this, R.layout.intent_list_item, getResources().getStringArray(R.array.allIntents))); mContactsPackageName = getResources().getString( Loading Loading @@ -287,10 +274,6 @@ public class AllIntentsActivity extends ListActivity } break; } case JOIN_CONTACT: { // TODO break; } case EDIT_CONTACT: { final long contactId = findArbitraryContactWithPhoneNumber(); final Uri uri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); Loading Loading @@ -409,93 +392,8 @@ public class AllIntentsActivity extends ListActivity startActivity(intent); break; } case DIAL: { startActivity(new Intent(Intent.ACTION_DIAL)); break; } case DIAL_phone: { // This is the legacy URI (there is no >2.0 way to call a phone data item) final long dataId = findArbitraryPhoneDataId(); if (dataId != -1) { final Uri legacyContentUri = Uri.parse("content://contacts/phones"); final Uri uri = ContentUris.withAppendedId(legacyContentUri, dataId); startActivity(new Intent(Intent.ACTION_DIAL, uri)); } break; } case DIAL_person: { // This is the legacy URI (there is no >2.0 way to call a person) final long contactId = findArbitraryContactWithPhoneNumber(); if (contactId != -1) { final Uri legacyContentUri = Uri.parse("content://contacts/people"); final long rawContactId = findArbitraryRawContactOfContact(contactId); final Uri uri = ContentUris.withAppendedId(legacyContentUri, rawContactId); startActivity(new Intent(Intent.ACTION_DIAL, uri)); } break; } case DIAL_voicemail: { startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("voicemail:"))); break; } case CALL_BUTTON: { startActivity(new Intent(Intent.ACTION_CALL_BUTTON)); break; } case DIAL_tel: { startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:555-123-4567"))); break; } case VIEW_tel: { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("tel:555-123-4567"))); break; } case VIEW_CALLLOG: { final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setType(CallLog.Calls.CONTENT_TYPE); startActivity(intent); break; } case VIEW_CALLLOG_MISSED: { final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setType(CallLog.Calls.CONTENT_TYPE); intent.putExtra(CallLog.Calls.EXTRA_CALL_TYPE_FILTER, CallLog.Calls.MISSED_TYPE); startActivity(intent); break; } case VIEW_CALLLOG_VOICEMAIL: { final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setType(CallLog.Calls.CONTENT_TYPE); intent.putExtra(CallLog.Calls.EXTRA_CALL_TYPE_FILTER, CallLog.Calls.VOICEMAIL_TYPE); startActivity(intent); break; } case VIEW_CALLLOG_ENTRY: { Uri uri = getCallLogUri(); if (uri == null) { Toast.makeText(this, "Call log is empty", Toast.LENGTH_LONG).show(); break; } final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(uri); startActivity(intent); break; } case LEGACY_CALL_DETAILS_ACTIVITY: { Uri uri = getCallLogUri(); if (uri == null) { Toast.makeText(this, "Call log is empty", Toast.LENGTH_LONG).show(); break; } final Intent intent = new Intent("android.intent.action.VIEW"); intent.setData(uri); bindIntentToClass(intent, "com.android.dialer.CallDetailActivity"); startActivity(intent); break; } case LEGACY_CALL_LOG_ACTIVITY: { startActivity(bindIntentToClass(new Intent(), "com.android.contacts.activities.CallLogActivity")); case QUICK_CONTACT_TESTS_ACTIVITY: { startActivity(new Intent(this, QuickContactTestsActivity.class)); break; } Loading @@ -505,17 +403,6 @@ public class AllIntentsActivity extends ListActivity } } /** Returns the URI of one of the items in the call log, or null if the call log is empty. */ private Uri getCallLogUri() { Cursor cursor = getContentResolver().query( Calls.CONTENT_URI, new String[]{ Calls._ID }, null, null, Calls.DEFAULT_SORT_ORDER); if (!cursor.moveToNext()) { return null; } return ContentUris.withAppendedId(Calls.CONTENT_URI, cursor.getLong(0)); } /** Creates an intent that is bound to a specific activity by name. */ private Intent bindIntentToClass(Intent intent, String activityClassName) { intent.setComponent(new ComponentName(mContactsPackageName, Loading Loading @@ -562,22 +449,6 @@ public class AllIntentsActivity extends ListActivity return -1; } private long findArbitraryPhoneDataId() { final Cursor cursor = getContentResolver().query(Data.CONTENT_URI, new String[] { Data._ID }, Data.MIMETYPE + "=" + Phone.MIMETYPE, null, "RANDOM() LIMIT 1"); try { if (cursor.moveToFirst()) { return cursor.getLong(0); } } finally { cursor.close(); } return -1; } private long findArbitraryRawContactOfContact(long contactId) { final Cursor cursor = getContentResolver().query(RawContacts.CONTENT_URI, new String[] { RawContacts._ID }, Loading Loading
tests/AndroidManifest.xml +6 −33 Original line number Diff line number Diff line Loading @@ -23,8 +23,6 @@ <uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.WRITE_CONTACTS" /> <uses-permission android:name="android.permission.READ_CALL_LOG" /> <uses-permission android:name="android.permission.WRITE_CALL_LOG" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.USE_CREDENTIALS" /> Loading @@ -37,13 +35,13 @@ <uses-permission android:name="android.permission.READ_PROFILE" /> <uses-permission android:name="android.permission.READ_SOCIAL_STREAM" /> <application> <application android:label="@string/applicationLabel"> <uses-library android:name="android.test.runner" /> <meta-data android:name="com.android.contacts.iconset" android:resource="@xml/iconset" /> <activity android:name=".allintents.AllIntentsActivity" android:label="@string/contactsIntents" > <activity android:name=".allintents.AllIntentsActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> Loading @@ -51,34 +49,9 @@ </intent-filter> </activity> <activity android:name=".allintents.ResultActivity" android:label="@string/result" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".allintents.ResultActivity"/> <activity android:name=".widget.PinnedHeaderUseCaseActivity" android:label="@string/pinnedHeaderList" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".quickcontact.QuickContactTestsActivity" android:label="@string/quickContactTests" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".quickcontact.QuickContactTestsActivity"/> <!-- Test authenticators/sync adapters. Loading
tests/res/values/donottranslate_strings.xml +2 −18 Original line number Diff line number Diff line Loading @@ -15,8 +15,7 @@ --> <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <string name="contactsIntents">Contacts Intents</string> <string name="result">Result returned by activity</string> <string name="applicationLabel">Contacts Test</string> <string-array name="allIntents"> <!-- List modes --> Loading Loading @@ -45,7 +44,6 @@ <item>ACTION_SEARCH: email</item> <item>ACTION_SEARCH: phone</item> <item>SEARCH_SUGGESTION_CLICKED: contact</item> <item>TODO: JOIN_CONTACT</item> <!-- Edit Contact --> <item>EDIT (content uri with only id)</item> Loading @@ -68,23 +66,9 @@ <item>VIEW (legacy style uri)</item> <!-- Various ways to start Contacts --> <item>DIAL</item> <item>DIAL phone (deprecated)</item> <item>DIAL person (deprecated)</item> <item>DIAL voicemail</item> <item>CALL BUTTON</item> <item>DIAL tel</item> <item>VIEW tel</item> <item>VIEW calls (call-log after a phone call)</item> <item>VIEW missed calls</item> <item>VIEW voicemails</item> <item>VIEW calls item</item> <item>CallDetailActivity (legacy)</item> <item>CallLogActivity (legacy)</item> <item>QuickContactTestsActivity</item> </string-array> <string name="pinnedHeaderList">Pinned Headers</string> <string name="quickContactTests">Quick Contact modes</string> <string name="pickContact">Pick contact</string> <string name="quickContactIntent">Start with Intent</string> <string name="fillCallLogTest">Fill call log test</string> Loading
tests/src/com/android/contacts/tests/allintents/AllIntentsActivity.java +5 −134 Original line number Diff line number Diff line Loading @@ -26,8 +26,6 @@ import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.provider.CallLog; import android.provider.CallLog.Calls; import android.provider.Contacts.ContactMethods; import android.provider.Contacts.People; import android.provider.Contacts.Phones; Loading @@ -46,6 +44,7 @@ import android.widget.ListView; import android.widget.Toast; import com.android.contacts.tests.R; import com.android.contacts.tests.quickcontact.QuickContactTestsActivity; import java.util.ArrayList; Loading Loading @@ -91,7 +90,6 @@ public class AllIntentsActivity extends ListActivity ACTION_SEARCH_EMAIL, ACTION_SEARCH_PHONE, SEARCH_SUGGESTION_CLICKED_CONTACT, JOIN_CONTACT, EDIT_CONTACT, EDIT_CONTACT_LOOKUP, EDIT_CONTACT_LOOKUP_ID, Loading @@ -108,19 +106,7 @@ public class AllIntentsActivity extends ListActivity VIEW_CONTACT_LOOKUP_ID, VIEW_RAW_CONTACT, VIEW_LEGACY, DIAL, DIAL_phone, DIAL_person, DIAL_voicemail, CALL_BUTTON, DIAL_tel, VIEW_tel, VIEW_CALLLOG, VIEW_CALLLOG_MISSED, VIEW_CALLLOG_VOICEMAIL, VIEW_CALLLOG_ENTRY, LEGACY_CALL_DETAILS_ACTIVITY, LEGACY_CALL_LOG_ACTIVITY; QUICK_CONTACT_TESTS_ACTIVITY; public static ContactsIntent get(int ordinal) { return values()[ordinal]; Loading @@ -130,6 +116,7 @@ public class AllIntentsActivity extends ListActivity @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new ArrayAdapter<String>(this, R.layout.intent_list_item, getResources().getStringArray(R.array.allIntents))); mContactsPackageName = getResources().getString( Loading Loading @@ -287,10 +274,6 @@ public class AllIntentsActivity extends ListActivity } break; } case JOIN_CONTACT: { // TODO break; } case EDIT_CONTACT: { final long contactId = findArbitraryContactWithPhoneNumber(); final Uri uri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); Loading Loading @@ -409,93 +392,8 @@ public class AllIntentsActivity extends ListActivity startActivity(intent); break; } case DIAL: { startActivity(new Intent(Intent.ACTION_DIAL)); break; } case DIAL_phone: { // This is the legacy URI (there is no >2.0 way to call a phone data item) final long dataId = findArbitraryPhoneDataId(); if (dataId != -1) { final Uri legacyContentUri = Uri.parse("content://contacts/phones"); final Uri uri = ContentUris.withAppendedId(legacyContentUri, dataId); startActivity(new Intent(Intent.ACTION_DIAL, uri)); } break; } case DIAL_person: { // This is the legacy URI (there is no >2.0 way to call a person) final long contactId = findArbitraryContactWithPhoneNumber(); if (contactId != -1) { final Uri legacyContentUri = Uri.parse("content://contacts/people"); final long rawContactId = findArbitraryRawContactOfContact(contactId); final Uri uri = ContentUris.withAppendedId(legacyContentUri, rawContactId); startActivity(new Intent(Intent.ACTION_DIAL, uri)); } break; } case DIAL_voicemail: { startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("voicemail:"))); break; } case CALL_BUTTON: { startActivity(new Intent(Intent.ACTION_CALL_BUTTON)); break; } case DIAL_tel: { startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:555-123-4567"))); break; } case VIEW_tel: { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("tel:555-123-4567"))); break; } case VIEW_CALLLOG: { final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setType(CallLog.Calls.CONTENT_TYPE); startActivity(intent); break; } case VIEW_CALLLOG_MISSED: { final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setType(CallLog.Calls.CONTENT_TYPE); intent.putExtra(CallLog.Calls.EXTRA_CALL_TYPE_FILTER, CallLog.Calls.MISSED_TYPE); startActivity(intent); break; } case VIEW_CALLLOG_VOICEMAIL: { final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setType(CallLog.Calls.CONTENT_TYPE); intent.putExtra(CallLog.Calls.EXTRA_CALL_TYPE_FILTER, CallLog.Calls.VOICEMAIL_TYPE); startActivity(intent); break; } case VIEW_CALLLOG_ENTRY: { Uri uri = getCallLogUri(); if (uri == null) { Toast.makeText(this, "Call log is empty", Toast.LENGTH_LONG).show(); break; } final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(uri); startActivity(intent); break; } case LEGACY_CALL_DETAILS_ACTIVITY: { Uri uri = getCallLogUri(); if (uri == null) { Toast.makeText(this, "Call log is empty", Toast.LENGTH_LONG).show(); break; } final Intent intent = new Intent("android.intent.action.VIEW"); intent.setData(uri); bindIntentToClass(intent, "com.android.dialer.CallDetailActivity"); startActivity(intent); break; } case LEGACY_CALL_LOG_ACTIVITY: { startActivity(bindIntentToClass(new Intent(), "com.android.contacts.activities.CallLogActivity")); case QUICK_CONTACT_TESTS_ACTIVITY: { startActivity(new Intent(this, QuickContactTestsActivity.class)); break; } Loading @@ -505,17 +403,6 @@ public class AllIntentsActivity extends ListActivity } } /** Returns the URI of one of the items in the call log, or null if the call log is empty. */ private Uri getCallLogUri() { Cursor cursor = getContentResolver().query( Calls.CONTENT_URI, new String[]{ Calls._ID }, null, null, Calls.DEFAULT_SORT_ORDER); if (!cursor.moveToNext()) { return null; } return ContentUris.withAppendedId(Calls.CONTENT_URI, cursor.getLong(0)); } /** Creates an intent that is bound to a specific activity by name. */ private Intent bindIntentToClass(Intent intent, String activityClassName) { intent.setComponent(new ComponentName(mContactsPackageName, Loading Loading @@ -562,22 +449,6 @@ public class AllIntentsActivity extends ListActivity return -1; } private long findArbitraryPhoneDataId() { final Cursor cursor = getContentResolver().query(Data.CONTENT_URI, new String[] { Data._ID }, Data.MIMETYPE + "=" + Phone.MIMETYPE, null, "RANDOM() LIMIT 1"); try { if (cursor.moveToFirst()) { return cursor.getLong(0); } } finally { cursor.close(); } return -1; } private long findArbitraryRawContactOfContact(long contactId) { final Cursor cursor = getContentResolver().query(RawContacts.CONTENT_URI, new String[] { RawContacts._ID }, Loading