Merge "Remove CallLogActivity."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 520e14c..2877820 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -56,19 +56,6 @@
android:hardwareAccelerated="true"
>
- <!-- A list of recent calls -->
- <activity android:name=".activities.CallLogActivity"
- android:label="@string/recentCallsIconLabel"
- android:theme="@style/DialtactsTheme"
- android:uiOptions="splitActionBarWhenNarrow"
- >
- <intent-filter>
- <action android:name="com.android.phone.action.RECENT_CALLS" />
- <category android:name="android.intent.category.DEFAULT" />
- <category android:name="android.intent.category.TAB" />
- </intent-filter>
- </activity>
-
<!-- Intercept Dialer Intents for devices without a phone.
This activity should have the same intent filters as the DialtactsActivity,
so that its capturing the same events. Omit android.intent.category.LAUNCHER, because we
@@ -182,6 +169,11 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.TAB" />
</intent-filter>
+ <intent-filter android:label="@string/recentCallsIconLabel">
+ <action android:name="com.android.phone.action.RECENT_CALLS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.TAB" />
+ </intent-filter>
</activity>
<!-- The main Contacts activity with the contact list, favorites, and groups. -->
@@ -330,6 +322,18 @@
android:exported="true"
/>
+ <!-- Backwards compatibility: "Call log" from Gingerbread and earlier -->
+ <activity-alias android:name="RecentCallsListActivity"
+ android:targetActivity=".activities.DialtactsActivity"
+ android:exported="true"
+ />
+
+ <!-- Backwards compatibility: "Call log" from ICS -->
+ <activity-alias android:name=".activities.CallLogActivity"
+ android:targetActivity=".activities.DialtactsActivity"
+ android:exported="true"
+ />
+
<!-- An activity for joining contacts -->
<activity android:name=".activities.JoinContactActivity"
android:theme="@style/JoinContactActivityTheme"
diff --git a/res/layout/call_log_activity.xml b/res/layout/fragment_test.xml
similarity index 85%
rename from res/layout/call_log_activity.xml
rename to res/layout/fragment_test.xml
index b391795..af281eb 100644
--- a/res/layout/call_log_activity.xml
+++ b/res/layout/fragment_test.xml
@@ -18,8 +18,9 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
>
- <fragment class="com.android.contacts.calllog.CallLogFragment"
- android:id="@+id/call_log_fragment"
+ <!-- Placeholder to load the fragment under test. -->
+ <fragment android:id="@+id/fragment"
+ android:name="com.android.contacts.test.EmptyFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
diff --git a/src/com/android/contacts/activities/CallLogActivity.java b/src/com/android/contacts/activities/CallLogActivity.java
deleted file mode 100644
index dd81dab..0000000
--- a/src/com/android/contacts/activities/CallLogActivity.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2007 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 com.android.contacts.R;
-import com.android.contacts.calllog.CallLogFragment;
-import com.android.internal.telephony.ITelephony;
-import com.google.common.annotations.VisibleForTesting;
-
-import android.app.Activity;
-import android.content.ActivityNotFoundException;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.RemoteException;
-import android.os.ServiceManager;
-import android.os.SystemClock;
-import android.view.KeyEvent;
-import android.view.ViewConfiguration;
-
-/**
- * Displays a list of call log entries.
- */
-public class CallLogActivity extends Activity {
- private static final String TAG = "CallLogActivity";
-
- private CallLogFragment mFragment;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
-
- setContentView(R.layout.call_log_activity);
-
- // Typing here goes to the dialer
- setDefaultKeyMode(DEFAULT_KEYS_DIALER);
-
- mFragment = (CallLogFragment) getFragmentManager().findFragmentById(
- R.id.call_log_fragment);
- }
-
- @VisibleForTesting
- /*package*/ CallLogFragment getFragment() {
- return mFragment;
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- switch (keyCode) {
- case KeyEvent.KEYCODE_CALL: {
- long callPressDiff = SystemClock.uptimeMillis() - event.getDownTime();
- if (callPressDiff >= ViewConfiguration.getLongPressTimeout()) {
- // Launch voice dialer
- Intent intent = new Intent(Intent.ACTION_VOICE_COMMAND);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- try {
- startActivity(intent);
- } catch (ActivityNotFoundException e) {
- }
- return true;
- }
- }
- }
- return super.onKeyDown(keyCode, event);
- }
-
- @Override
- public boolean onKeyUp(int keyCode, KeyEvent event) {
- switch (keyCode) {
- case KeyEvent.KEYCODE_CALL:
- try {
- ITelephony phone = ITelephony.Stub.asInterface(
- ServiceManager.checkService("phone"));
- if (phone != null && !phone.isIdle()) {
- // Let the super class handle it
- break;
- }
- } catch (RemoteException re) {
- // Fall through and try to call the contact
- }
-
- mFragment.callSelectedEntry();
- return true;
- }
- return super.onKeyUp(keyCode, event);
- }
-}
diff --git a/src/com/android/contacts/calllog/CallLogAdapter.java b/src/com/android/contacts/calllog/CallLogAdapter.java
index ea3e03e..b38430b 100644
--- a/src/com/android/contacts/calllog/CallLogAdapter.java
+++ b/src/com/android/contacts/calllog/CallLogAdapter.java
@@ -47,7 +47,7 @@
/**
* Adapter class to fill in data for the Call Log.
*/
-public class CallLogAdapter extends GroupingListAdapter
+/*package*/ class CallLogAdapter extends GroupingListAdapter
implements Runnable, ViewTreeObserver.OnPreDrawListener, CallLogGroupBuilder.GroupCreator {
/** Interface used to initiate a refresh of the content. */
public interface CallFetcher {
@@ -193,7 +193,7 @@
}
};
- public CallLogAdapter(Context context, CallFetcher callFetcher,
+ CallLogAdapter(Context context, CallFetcher callFetcher,
ContactInfoHelper contactInfoHelper) {
super(context);
@@ -240,11 +240,7 @@
}
}
- public ContactInfo getContactInfo(String number) {
- return mContactInfoCache.getPossiblyExpired(number);
- }
-
- public void startRequestProcessing() {
+ private void startRequestProcessing() {
if (mRequestProcessingDisabled) {
return;
}
@@ -368,9 +364,8 @@
mCallLogGroupBuilder.addGroups(cursor);
}
- @VisibleForTesting
@Override
- public View newStandAloneView(Context context, ViewGroup parent) {
+ protected View newStandAloneView(Context context, ViewGroup parent) {
LayoutInflater inflater =
(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.call_log_list_item, parent, false);
@@ -378,15 +373,13 @@
return view;
}
- @VisibleForTesting
@Override
- public void bindStandAloneView(View view, Context context, Cursor cursor) {
+ protected void bindStandAloneView(View view, Context context, Cursor cursor) {
bindView(view, cursor, 1);
}
- @VisibleForTesting
@Override
- public View newChildView(Context context, ViewGroup parent) {
+ protected View newChildView(Context context, ViewGroup parent) {
LayoutInflater inflater =
(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.call_log_list_item, parent, false);
@@ -394,15 +387,13 @@
return view;
}
- @VisibleForTesting
@Override
- public void bindChildView(View view, Context context, Cursor cursor) {
+ protected void bindChildView(View view, Context context, Cursor cursor) {
bindView(view, cursor, 1);
}
- @VisibleForTesting
@Override
- public View newGroupView(Context context, ViewGroup parent) {
+ protected View newGroupView(Context context, ViewGroup parent) {
LayoutInflater inflater =
(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.call_log_list_item, parent, false);
@@ -410,9 +401,8 @@
return view;
}
- @VisibleForTesting
@Override
- public void bindGroupView(View view, Context context, Cursor cursor, int groupSize,
+ protected void bindGroupView(View view, Context context, Cursor cursor, int groupSize,
boolean expanded) {
bindView(view, cursor, groupSize);
}
@@ -678,11 +668,13 @@
* This method should be called in tests to disable such processing of requests when not
* needed.
*/
- public void disableRequestProcessingForTest() {
+ @VisibleForTesting
+ void disableRequestProcessingForTest() {
mRequestProcessingDisabled = true;
}
- public void injectContactInfoForTest(String number, ContactInfo contactInfo) {
+ @VisibleForTesting
+ void injectContactInfoForTest(String number, ContactInfo contactInfo) {
mContactInfoCache.put(number, contactInfo);
}
diff --git a/src/com/android/contacts/calllog/CallLogFragment.java b/src/com/android/contacts/calllog/CallLogFragment.java
index 7c889c8..96136a2 100644
--- a/src/com/android/contacts/calllog/CallLogFragment.java
+++ b/src/com/android/contacts/calllog/CallLogFragment.java
@@ -20,12 +20,12 @@
import com.android.contacts.ContactsUtils;
import com.android.contacts.R;
import com.android.contacts.activities.DialtactsActivity.ViewPagerVisibilityListener;
-import com.android.contacts.test.NeededForTesting;
import com.android.contacts.voicemail.VoicemailStatusHelper;
import com.android.contacts.voicemail.VoicemailStatusHelper.StatusMessage;
import com.android.contacts.voicemail.VoicemailStatusHelperImpl;
import com.android.internal.telephony.CallerInfo;
import com.android.internal.telephony.ITelephony;
+import com.google.common.annotations.VisibleForTesting;
import android.app.Activity;
import android.app.KeyguardManager;
@@ -275,6 +275,7 @@
return false;
}
}
+
public void callSelectedEntry() {
int position = getListView().getSelectedItemPosition();
if (position < 0) {
@@ -317,8 +318,8 @@
}
}
- @NeededForTesting
- public CallLogAdapter getAdapter() {
+ @VisibleForTesting
+ CallLogAdapter getAdapter() {
return mAdapter;
}
diff --git a/src/com/android/contacts/test/EmptyFragment.java b/src/com/android/contacts/test/EmptyFragment.java
new file mode 100644
index 0000000..e35b7f1
--- /dev/null
+++ b/src/com/android/contacts/test/EmptyFragment.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2011 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.test;
+
+import android.app.Fragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.FrameLayout;
+
+/**
+ * Empty fragment used for testing.
+ */
+public class EmptyFragment extends Fragment {
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Must return a ViewGroup, FrameLayout will do.
+ return new FrameLayout(getActivity());
+ }
+}
diff --git a/src/com/android/contacts/test/FragmentTestActivity.java b/src/com/android/contacts/test/FragmentTestActivity.java
index 34b1556..161ed74 100644
--- a/src/com/android/contacts/test/FragmentTestActivity.java
+++ b/src/com/android/contacts/test/FragmentTestActivity.java
@@ -30,6 +30,6 @@
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.empty);
+ setContentView(R.layout.fragment_test);
}
}
diff --git a/tests/src/com/android/contacts/activities/CallLogActivityTests.java b/tests/src/com/android/contacts/calllog/CallLogFragmentTest.java
similarity index 94%
rename from tests/src/com/android/contacts/activities/CallLogActivityTests.java
rename to tests/src/com/android/contacts/calllog/CallLogFragmentTest.java
index b670f05..09fe463 100644
--- a/tests/src/com/android/contacts/activities/CallLogActivityTests.java
+++ b/tests/src/com/android/contacts/calllog/CallLogFragmentTest.java
@@ -14,19 +14,15 @@
* limitations under the License.
*/
-package com.android.contacts.activities;
+package com.android.contacts.calllog;
import com.android.contacts.CallDetailActivity;
import com.android.contacts.R;
-import com.android.contacts.calllog.CallLogAdapter;
-import com.android.contacts.calllog.CallLogFragment;
-import com.android.contacts.calllog.CallLogListItemViews;
-import com.android.contacts.calllog.CallLogQuery;
-import com.android.contacts.calllog.CallLogQueryTestUtils;
-import com.android.contacts.calllog.ContactInfo;
-import com.android.contacts.calllog.IntentProvider;
+import com.android.contacts.test.FragmentTestActivity;
import com.android.internal.telephony.CallerInfo;
+import android.app.FragmentManager;
+import android.app.FragmentTransaction;
import android.content.ComponentName;
import android.content.ContentUris;
import android.content.Intent;
@@ -62,8 +58,7 @@
* -w com.android.contacts.tests/android.test.InstrumentationTestRunner
*/
@LargeTest
-public class CallLogActivityTests
- extends ActivityInstrumentationTestCase2<CallLogActivity> {
+public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<FragmentTestActivity> {
private static final int RAND_DURATION = -1;
private static final long NOW = -1L;
@@ -76,13 +71,14 @@
/** The formatted version of {@link #TEST_NUMBER}. */
private static final String TEST_FORMATTED_NUMBER = "1 212-555-1000";
- // We get the call list activity and assign is a frame to build
- // its list. mAdapter is an inner class of
- // CallLogActivity to build the rows (view) in the call
- // list. We reuse it with our own in-mem DB.
- private CallLogActivity mActivity;
+ /** The activity in which we are hosting the fragment. */
+ private FragmentTestActivity mActivity;
private CallLogFragment mFragment;
private FrameLayout mParentView;
+ /**
+ * The adapter used by the fragment to build the rows in the call log. We use it with our own in
+ * memory database.
+ */
private CallLogAdapter mAdapter;
private String mVoicemail;
@@ -103,8 +99,8 @@
// reverse order compare to the DB.
private View[] mList;
- public CallLogActivityTests() {
- super("com.android.contacts", CallLogActivity.class);
+ public CallLogFragmentTest() {
+ super("com.android.contacts", FragmentTestActivity.class);
mIndex = 1;
mRnd = new Random();
}
@@ -112,7 +108,18 @@
@Override
public void setUp() {
mActivity = getActivity();
- mFragment = mActivity.getFragment();
+ // Needed by the CallLogFragment.
+ mActivity.setTheme(R.style.DialtactsTheme);
+
+ // Create the fragment and load it into the activity.
+ mFragment = new CallLogFragment();
+ FragmentManager fragmentManager = mActivity.getFragmentManager();
+ FragmentTransaction transaction = fragmentManager.beginTransaction();
+ transaction.add(R.id.fragment, mFragment);
+ transaction.commit();
+ // Wait for the fragment to be loaded.
+ getInstrumentation().waitForIdleSync();
+
mVoicemail = TelephonyManager.getDefault().getVoiceMailNumber();
mAdapter = mFragment.getAdapter();
// Do not process requests for details during tests. This would start a background thread,