Show contact details when contact is tapped.

Do this by changing the routing logic: For viewing contacts, we
do not use the FrontDoorActivity as a proxy anymore. Instead,
ContactDetailActivity will forward the Intent to the ContactBrowserActivity
on a tablet

Change-Id: I04a03404410f3108f583da4592f6ae9f0f4e5bd2
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 52562e0..ec0709f 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -185,16 +185,6 @@
                 <category android:name="android.intent.category.LAUNCHER" />
                 <category android:name="android.intent.category.BROWSABLE" />
             </intent-filter>
-
-            <intent-filter>
-                <action android:name="android.intent.action.VIEW" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <data android:mimeType="vnd.android.cursor.dir/person" />
-                <data android:mimeType="vnd.android.cursor.dir/contact" />
-                <data android:mimeType="vnd.android.cursor.item/person" />
-                <data android:mimeType="vnd.android.cursor.item/contact" />
-                <data android:mimeType="vnd.android.cursor.item/raw_contact" />
-            </intent-filter>
         </activity>
 
         <!-- The actual list of contacts -->
@@ -442,6 +432,11 @@
             <intent-filter android:label="@string/viewContactDesription">
                 <action android:name="android.intent.action.VIEW" />
                 <category android:name="android.intent.category.DEFAULT" />
+                <data android:mimeType="vnd.android.cursor.dir/person" />
+                <data android:mimeType="vnd.android.cursor.dir/contact" />
+                <data android:mimeType="vnd.android.cursor.item/person" />
+                <data android:mimeType="vnd.android.cursor.item/contact" />
+                <data android:mimeType="vnd.android.cursor.item/raw_contact" />
             </intent-filter>
         </activity>
 
diff --git a/res/values-xlarge/donottranslate_config.xml b/res/values-xlarge/donottranslate_config.xml
new file mode 100644
index 0000000..fcb7da9
--- /dev/null
+++ b/res/values-xlarge/donottranslate_config.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 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.
+*/
+-->
+
+<resources>
+    <bool name="config_use_two_panes">true</bool>
+</resources>
diff --git a/res/values/donottranslate_config.xml b/res/values/donottranslate_config.xml
index f5efa13..e310953 100644
--- a/res/values/donottranslate_config.xml
+++ b/res/values/donottranslate_config.xml
@@ -99,4 +99,8 @@
 
     <!-- If true, phonetic name is included in the contact editor by default -->
     <bool name="config_editor_include_phonetic_name">false</bool>
+
+    <!-- If true, Contacts uses two panes: List and Detail. If false, Details are
+         shown in their own screens. This flag must be in sync with the layout definitions. -->
+    <bool name="config_use_two_panes">false</bool>
 </resources>
diff --git a/src/com/android/contacts/activities/ContactDetailActivity.java b/src/com/android/contacts/activities/ContactDetailActivity.java
index 56e8353..0036256 100644
--- a/src/com/android/contacts/activities/ContactDetailActivity.java
+++ b/src/com/android/contacts/activities/ContactDetailActivity.java
@@ -22,6 +22,7 @@
 import com.android.contacts.R;
 import com.android.contacts.detail.ContactDetailFragment;
 import com.android.contacts.interactions.ContactDeletionInteraction;
+import com.android.contacts.util.PhoneCapabilityTester;
 
 import android.accounts.Account;
 import android.content.ActivityNotFoundException;
@@ -44,6 +45,23 @@
     public void onCreate(Bundle savedState) {
         super.onCreate(savedState);
 
+        if (PhoneCapabilityTester.isUsingTwoPanes(this)) {
+            // This activity must not be shown. We have to select the contact in the
+            // ContactBrowserActivity instead ==> Create a forward intent and finish
+            final Intent originalIntent = getIntent();
+            Intent intent = new Intent();
+            intent.setAction(originalIntent.getAction());
+            intent.setDataAndType(originalIntent.getData(), originalIntent.getType());
+            intent.setFlags(
+                    Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_FORWARD_RESULT
+                            | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
+
+            intent.setClass(this, ContactBrowserActivity.class);
+            startActivity(intent);
+            finish();
+            return;
+        }
+
         setContentView(R.layout.contact_detail_activity);
 
         mFragment = (ContactDetailFragment) getFragmentManager().findFragmentById(
diff --git a/src/com/android/contacts/activities/ContactsFrontDoor.java b/src/com/android/contacts/activities/ContactsFrontDoor.java
index 3677cce..1f8a491 100644
--- a/src/com/android/contacts/activities/ContactsFrontDoor.java
+++ b/src/com/android/contacts/activities/ContactsFrontDoor.java
@@ -39,12 +39,12 @@
                         | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
         intent.putExtra(EXTRA_FRONT_DOOR, true);
 
-        if (PhoneCapabilityTester.isPhone(this)) {
-            // Default to the normal dialtacts layout
-            intent.setClass(this, DialtactsActivity.class);
-        } else {
+        if (PhoneCapabilityTester.isUsingTwoPanes(this)) {
             // No tabs, just a contact list
             intent.setClass(this, ContactBrowserActivity.class);
+        } else {
+            // Default to the normal dialtacts layout
+            intent.setClass(this, DialtactsActivity.class);
         }
 
         startActivity(intent);
diff --git a/src/com/android/contacts/util/PhoneCapabilityTester.java b/src/com/android/contacts/util/PhoneCapabilityTester.java
index 23319aa..d3a8060 100644
--- a/src/com/android/contacts/util/PhoneCapabilityTester.java
+++ b/src/com/android/contacts/util/PhoneCapabilityTester.java
@@ -16,6 +16,8 @@
 
 package com.android.contacts.util;
 
+import com.android.contacts.R;
+
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
@@ -79,4 +81,12 @@
                 Uri.fromParts(Constants.SCHEME_SMSTO, "", null));
         return isIntentRegistered(context, intent);
     }
+
+    /**
+     * True if we are using two-pane layouts ("tablet mode"), false if we are using single views
+     * ("phone mode")
+     */
+    public static boolean isUsingTwoPanes(Context context) {
+        return context.getResources().getBoolean(R.bool.config_use_two_panes);
+    }
 }