Use ActionBar in call log details activity.

This replaces the temporary mock that I added earlier on.

It also gives the action bar home button the correct semantics: it now
always goes to the call log, no matter from which context it had been
opened.

Bug: 5071264
Change-Id: I0324bb91bbd003b46574ec4e422eaed66fa176b3
diff --git a/res/layout/call_detail.xml b/res/layout/call_detail.xml
index e6a685e..02dd098 100644
--- a/res/layout/call_detail.xml
+++ b/res/layout/call_detail.xml
@@ -20,29 +20,12 @@
     android:orientation="horizontal"
     android:gravity="top"
 >
-    <LinearLayout
-        android:id="@+id/action_bar"
-        android:layout_width="match_parent"
-        android:layout_height="@dimen/call_detail_action_bar_height"
-        android:layout_alignParentLeft="true"
-        android:layout_alignParentTop="true"
-        android:orientation="horizontal"
-        android:background="@drawable/call_log_action_bar_bg"
-    >
-        <ImageView
-            android:id="@+id/action_bar_home"
-            android:layout_width="wrap_content"
-            android:layout_height="match_parent"
-            android:src="@drawable/ic_call_log_home"
-        />
-    </LinearLayout>
-
     <FrameLayout
         android:id="@+id/voicemail_status"
-        android:layout_below="@id/action_bar"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_alignParentLeft="true"
+        android:layout_alignParentTop="true"
         android:visibility="gone"
     >
         <include layout="@layout/call_log_voicemail_status"/>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 46e6583..d26affc 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -53,8 +53,7 @@
         <item name="call_log_voicemail_status_text_color">#000000</item>
     </style>
 
-    <style name="CallDetailActivityTheme" parent="android:Theme.Holo">
-        <item name="android:windowNoTitle">true</item>
+    <style name="CallDetailActivityTheme" parent="android:Theme.Holo.SplitActionBarWhenNarrow">
         <item name="android:gravity">top</item>
         <item name="call_detail_transparent_background">#CC000000</item>
         <item name="call_detail_contact_background_overlay_alpha">0.25</item>
diff --git a/src/com/android/contacts/CallDetailActivity.java b/src/com/android/contacts/CallDetailActivity.java
index d732d66..813ebb1 100644
--- a/src/com/android/contacts/CallDetailActivity.java
+++ b/src/com/android/contacts/CallDetailActivity.java
@@ -24,6 +24,7 @@
 import com.android.contacts.voicemail.VoicemailStatusHelper.StatusMessage;
 import com.android.contacts.voicemail.VoicemailStatusHelperImpl;
 
+import android.app.ActionBar;
 import android.app.FragmentManager;
 import android.app.ListActivity;
 import android.content.ContentResolver;
@@ -81,7 +82,6 @@
     private CallTypeHelper mCallTypeHelper;
     private PhoneNumberHelper mPhoneNumberHelper;
     private PhoneCallDetailsHelper mPhoneCallDetailsHelper;
-    private View mHomeActionView;
     private ImageView mMainActionView;
     private ImageView mContactBackgroundView;
 
@@ -156,20 +156,12 @@
         mStatusMessageView = findViewById(R.id.voicemail_status);
         mStatusMessageText = (TextView) findViewById(R.id.voicemail_status_message);
         mStatusMessageAction = (TextView) findViewById(R.id.voicemail_status_action);
-        mHomeActionView = findViewById(R.id.action_bar_home);
         mMainActionView = (ImageView) findViewById(R.id.main_action);
         mContactBackgroundView = (ImageView) findViewById(R.id.contact_background);
         mDefaultCountryIso = ContactsUtils.getCurrentCountryIso(this);
         mContactPhotoManager = ContactPhotoManager.getInstance(this);
         getListView().setOnItemClickListener(this);
-        mHomeActionView.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                // We want this to start the call log if this activity was not started from the
-                // call log itself.
-                CallDetailActivity.this.finish();
-            }
-        });
+        configureActionBar();
     }
 
     @Override
@@ -654,8 +646,32 @@
                         new Intent(Intent.ACTION_DIAL, mPhoneNumberHelper.getCallUri(mNumber)));
                 return true;
 
+            case android.R.id.home: {
+                onHomeSelected();
+                return true;
+            }
+
             default:
                 throw new IllegalArgumentException();
         }
     }
+
+    private void configureActionBar() {
+        ActionBar actionBar = getActionBar();
+        if (actionBar != null) {
+            actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME,
+                    ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE
+                    | ActionBar.DISPLAY_SHOW_HOME);
+            actionBar.setIcon(R.drawable.ic_ab_dialer_holo_dark);
+        }
+    }
+
+    /** Invoked when the user presses the home button in the action bar. */
+    private void onHomeSelected() {
+        Intent intent = new Intent(Intent.ACTION_VIEW, Calls.CONTENT_URI);
+        // This will open the call log even if the detail view has been opened directly.
+        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+        startActivity(intent);
+        finish();
+    }
 }