Merge "Remove deprecated API use"
diff --git a/src/com/android/dialer/SpecialCharSequenceMgr.java b/src/com/android/dialer/SpecialCharSequenceMgr.java
index 46c6de6..1e68612 100644
--- a/src/com/android/dialer/SpecialCharSequenceMgr.java
+++ b/src/com/android/dialer/SpecialCharSequenceMgr.java
@@ -18,6 +18,7 @@
 
 import android.app.Activity;
 import android.app.AlertDialog;
+import android.app.DialogFragment;
 import android.app.KeyguardManager;
 import android.app.ProgressDialog;
 import android.content.ActivityNotFoundException;
@@ -64,6 +65,8 @@
 public class SpecialCharSequenceMgr {
     private static final String TAG = "SpecialCharSequenceMgr";
 
+    private static final String TAG_SELECT_ACCT_FRAGMENT = "tag_select_acct_fragment";
+
     private static final String SECRET_CODE_ACTION = "android.provider.Telephony.SECRET_CODE";
     private static final String MMI_IMEI_DISPLAY = "*#06#";
     private static final String MMI_REGULATORY_INFO_DISPLAY = "*#07#";
@@ -229,9 +232,12 @@
                         public void onDialogDismissed() {}
                     };
 
-                    SelectPhoneAccountDialogFragment.showAccountDialog(
-                            ((Activity) context).getFragmentManager(), subscriptionAccountHandles,
-                            listener);
+                    // NOTE: If you want to support rotation of this dialog need
+                    // to refactor the listener and set it in DialpadFragment.onCreate()
+                    DialogFragment dialogFragment = SelectPhoneAccountDialogFragment.newInstance(
+                            subscriptionAccountHandles, listener);
+                    dialogFragment.show(((Activity) context).getFragmentManager(),
+                            TAG_SELECT_ACCT_FRAGMENT);
                 } else {
                     return false;
                 }
@@ -290,9 +296,12 @@
                     public void onDialogDismissed() {}
                 };
 
-                SelectPhoneAccountDialogFragment.showAccountDialog(
-                        ((Activity) context).getFragmentManager(), subscriptionAccountHandles,
-                        listener);
+                // NOTE: If you want to support rotation of this dialog need
+                // to refactor the listener and set it in DialpadFragment.onCreate()
+                DialogFragment dialogFragment = SelectPhoneAccountDialogFragment.newInstance(
+                        subscriptionAccountHandles, listener);
+                dialogFragment.show(((Activity) context).getFragmentManager(),
+                        TAG_SELECT_ACCT_FRAGMENT);
             }
             return true;
         }
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java
index 7c64c5b..3e8efa0 100644
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -153,7 +153,7 @@
         @Override
         public void onClick(View v) {
             final View callLogItem = (View) v.getParent().getParent();
-            handleRowExpanded(callLogItem, true /* animate */, false /* forceExpand */);
+            handleRowExpanded(callLogItem, false /* forceExpand */);
         }
     };
 
@@ -170,8 +170,7 @@
         public boolean onRequestSendAccessibilityEvent(ViewGroup host, View child,
                 AccessibilityEvent event) {
             if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED) {
-                handleRowExpanded(host, false /* animate */,
-                        true /* forceExpand */);
+                handleRowExpanded(host, true /* forceExpand */);
             }
             return super.onRequestSendAccessibilityEvent(host, child, event);
         }
@@ -316,7 +315,7 @@
      * @param c the cursor pointing to the entry in the call log
      * @param count the number of entries in the current item, greater than 1 if it is a group
      */
-    private void bindView(View callLogItemView, Cursor c, int count) {
+    public void bindView(View callLogItemView, Cursor c, int count) {
         callLogItemView.setAccessibilityDelegate(mAccessibilityDelegate);
         final CallLogListItemViews views = (CallLogListItemViews) callLogItemView.getTag();
 
@@ -541,22 +540,6 @@
     }
 
     /**
-     * Bind a call log entry view for testing purposes.  Also inflates the action view stub so
-     * unit tests can access the buttons contained within.
-     *
-     * @param view The current call log row.
-     * @param context The current context.
-     * @param cursor The cursor to bind from.
-     */
-    @VisibleForTesting
-    void bindViewForTest(View view, Context context, Cursor cursor) {
-        bindStandAloneView(view, context, cursor);
-        CallLogListItemViews views = CallLogListItemViews.fromView(context, view);
-        views.inflateActionViewStub(mOnReportButtonClickListener, mActionListener,
-                mPhoneNumberUtilsWrapper, mCallLogViewsHelper);
-    }
-
-    /**
      * Sets whether processing of requests for contact details should be enabled.
      *
      * This method should be called in tests to disable such processing of requests when not
@@ -640,11 +623,10 @@
      * Manages the state changes for the UI interaction where a call log row is expanded.
      *
      * @param view The view that was tapped
-     * @param animate Whether or not to animate the expansion/collapse
      * @param forceExpand Whether or not to force the call log row into an expanded state regardless
      *        of its previous state
      */
-    private void handleRowExpanded(View view, boolean animate, boolean forceExpand) {
+    private void handleRowExpanded(View view, boolean forceExpand) {
         final CallLogListItemViews views = (CallLogListItemViews) view.getTag();
 
         if (forceExpand && isExpanded(views.rowId)) {
@@ -653,10 +635,17 @@
 
         // Hide or show the actions view.
         boolean expanded = toggleExpansion(views.rowId);
+        expandItem(views, expanded);
+    }
 
+    /**
+     * @param views The view holder for the item to expand or collapse.
+     * @param expand {@code true} to expand the item, {@code false} otherwise.
+     */
+    public void expandItem(CallLogListItemViews views, boolean expand) {
         // Trigger loading of the viewstub and visual expand or collapse.
         views.expandOrCollapseActions(
-                expanded,
+                expand,
                 mOnReportButtonClickListener,
                 mActionListener,
                 mPhoneNumberUtilsWrapper,
diff --git a/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java b/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java
index 0553422..b57489d 100644
--- a/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java
+++ b/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java
@@ -57,7 +57,7 @@
  *   runtest contacts
  * or
  *   adb shell am instrument \
- *     -w com.android.contacts.tests/android.test.InstrumentationTestRunner
+ *     -w com.android.dialer.tests/android.test.InstrumentationTestRunner
  */
 @LargeTest
 public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<FragmentTestActivity> {
@@ -177,7 +177,7 @@
         mCursor.moveToFirst();
         insertPrivate(NOW, 0);
         View view = mAdapter.newStandAloneView(getActivity(), mParentView);
-        mAdapter.bindViewForTest(view, getActivity(), mCursor);
+        bindViewForTest(view, mCursor);
     }
 
     @MediumTest
@@ -193,7 +193,7 @@
         mCursor.moveToFirst();
         insert(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0, Calls.INCOMING_TYPE);
         View view = mAdapter.newStandAloneView(getActivity(), mParentView);
-        mAdapter.bindViewForTest(view, getActivity(), mCursor);
+        bindViewForTest(view, mCursor);
 
         CallLogListItemViews views = (CallLogListItemViews) view.getTag();
         assertNameIs(views, TEST_NUMBER);
@@ -207,7 +207,7 @@
         values[CallLogQuery.CACHED_FORMATTED_NUMBER] = TEST_FORMATTED_NUMBER;
         insertValues(values);
         View view = mAdapter.newStandAloneView(getActivity(), mParentView);
-        mAdapter.bindViewForTest(view, getActivity(), mCursor);
+        bindViewForTest(view, mCursor);
 
         CallLogListItemViews views = (CallLogListItemViews) view.getTag();
         assertNameIs(views, TEST_FORMATTED_NUMBER);
@@ -221,7 +221,7 @@
         insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE,
                 "John Doe", Phone.TYPE_HOME, TEST_DEFAULT_CUSTOM_LABEL);
         View view = mAdapter.newStandAloneView(getActivity(), mParentView);
-        mAdapter.bindViewForTest(view, getActivity(), mCursor);
+        bindViewForTest(view, mCursor);
 
         CallLogListItemViews views = (CallLogListItemViews) view.getTag();
         assertNameIs(views, "John Doe");
@@ -234,7 +234,7 @@
         insertWithCachedValues("sip:johndoe@gmail.com", NOW, 0, Calls.INCOMING_TYPE,
                 "John Doe", Phone.TYPE_HOME, TEST_DEFAULT_CUSTOM_LABEL);
         View view = mAdapter.newStandAloneView(getActivity(), mParentView);
-        mAdapter.bindViewForTest(view, getActivity(), mCursor);
+        bindViewForTest(view, mCursor);
 
         CallLogListItemViews views = (CallLogListItemViews) view.getTag();
         assertNameIs(views, "John Doe");
@@ -249,7 +249,7 @@
         insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE,
                 "John Doe", Phone.TYPE_HOME, TEST_DEFAULT_CUSTOM_LABEL);
         View view = mAdapter.newStandAloneView(getActivity(), mParentView);
-        mAdapter.bindViewForTest(view, getActivity(), mCursor);
+        bindViewForTest(view, mCursor);
 
         CallLogListItemViews views = (CallLogListItemViews) view.getTag();
         assertNameIs(views, "John Doe");
@@ -264,7 +264,7 @@
         insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE,
                 "John Doe", Phone.TYPE_WORK, TEST_DEFAULT_CUSTOM_LABEL);
         View view = mAdapter.newStandAloneView(getActivity(), mParentView);
-        mAdapter.bindViewForTest(view, getActivity(), mCursor);
+        bindViewForTest(view, mCursor);
 
         CallLogListItemViews views = (CallLogListItemViews) view.getTag();
         assertNameIs(views, "John Doe");
@@ -278,7 +278,7 @@
         insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE,
                 "John Doe", Phone.TYPE_CUSTOM, numberLabel);
         View view = mAdapter.newStandAloneView(getActivity(), mParentView);
-        mAdapter.bindViewForTest(view, getActivity(), mCursor);
+        bindViewForTest(view, mCursor);
 
         CallLogListItemViews views = (CallLogListItemViews) view.getTag();
         assertNameIs(views, "John Doe");
@@ -291,7 +291,7 @@
         insertWithCachedValues(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE,
                 "John Doe", Phone.TYPE_HOME, "");
         View view = mAdapter.newStandAloneView(getActivity(), mParentView);
-        mAdapter.bindViewForTest(view, getActivity(), mCursor);
+        bindViewForTest(view, mCursor);
 
         CallLogListItemViews views = (CallLogListItemViews) view.getTag();
         assertTrue(views.quickContactView.isEnabled());
@@ -302,7 +302,7 @@
         mCursor.moveToFirst();
         insert(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0, Calls.INCOMING_TYPE);
         View view = mAdapter.newStandAloneView(getActivity(), mParentView);
-        mAdapter.bindViewForTest(view, getActivity(), mCursor);
+        bindViewForTest(view, mCursor);
 
         CallLogListItemViews views = (CallLogListItemViews) view.getTag();
         assertFalse(views.quickContactView.isEnabled());
@@ -313,7 +313,7 @@
         mCursor.moveToFirst();
         insert(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0, Calls.INCOMING_TYPE);
         View view = mAdapter.newStandAloneView(getActivity(), mParentView);
-        mAdapter.bindViewForTest(view, getActivity(), mCursor);
+        bindViewForTest(view, mCursor);
 
         CallLogListItemViews views = (CallLogListItemViews) view.getTag();
 
@@ -334,7 +334,7 @@
         mCursor.moveToFirst();
         insertVoicemail(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0);
         View view = mAdapter.newStandAloneView(getActivity(), mParentView);
-        mAdapter.bindViewForTest(view, getActivity(), mCursor);
+        bindViewForTest(view, mCursor);
 
         CallLogListItemViews views = (CallLogListItemViews) view.getTag();
         IntentProvider intentProvider = (IntentProvider) views.voicemailButtonView.getTag();
@@ -424,7 +424,7 @@
             if (null == mList[i]) {
                 mList[i] = mAdapter.newStandAloneView(mActivity, mParentView);
             }
-            mAdapter.bindViewForTest(mList[i], mActivity, mCursor);
+            bindViewForTest(mList[i], mCursor);
             mCursor.moveToPrevious();
             i++;
         }
@@ -442,6 +442,19 @@
     //
 
     /**
+     * Bind a call log entry view for testing purposes.  Also inflates the action view stub so
+     * unit tests can access the buttons contained within.
+     *
+     * @param view The current call log row.
+     * @param cursor The cursor to bind from.
+     */
+    private void bindViewForTest(View view, MatrixCursor cursor) {
+        mAdapter.bindView(view, cursor, /* count */ 1);
+        CallLogListItemViews views = (CallLogListItemViews) view.getTag();
+        mAdapter.expandItem(views, /* expand */ true);
+    }
+
+    /**
      * Insert a certain number of random numbers in the DB. Makes sure
      * there is at least one private and one unknown number in the DB.
      * @param num Of entries to be inserted.