Remove DialpadActivity

It is never used anymore. We're using Dial*tacts*Activity for Phone.

Intent with "com.android.phone.action.TOUCH_DIALER" has been used
inside the Activity and has never supported it for external use.
We'll keep the Intent for now, but we won't support correct behavior
for it. Using android.intent.action.DIAL should do what 3rd party
app will want.

TESTED:
- app works as usual with DIAL intent
- all unit tests run correctly
- intent with TOUCH_DIALER introduces Dialpad screen in
  DialtactsActivity

Bug: 5160191
Change-Id: I77d38fb3f7b51782fab3fee7b9e732f55ecf4654
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 95edf0f..aeec2b2 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -53,17 +53,6 @@
         android:hardwareAccelerated="true"
     >
 
-        <!-- A virtual 12 key dialer -->
-        <activity android:name=".activities.DialpadActivity"
-            android:launchMode="singleTop"
-        >
-            <intent-filter>
-                <action android:name="com.android.phone.action.TOUCH_DIALER" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="android.intent.category.TAB" />
-            </intent-filter>
-        </activity>
-
         <!-- A list of recent calls -->
         <activity android:name=".activities.CallLogActivity"
             android:label="@string/recentCallsIconLabel"
@@ -181,6 +170,13 @@
                 <category android:name="android.intent.category.DEFAULT" />
                 <category android:name="android.intent.category.BROWSABLE" />
             </intent-filter>
+            <!-- This was never intended to be public, but is here for backward
+                 compatibility.  Use Intent.ACTION_DIAL instead. -->
+            <intent-filter>
+                <action android:name="com.android.phone.action.TOUCH_DIALER" />
+                <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. -->
diff --git a/src/com/android/contacts/activities/DialpadActivity.java b/src/com/android/contacts/activities/DialpadActivity.java
deleted file mode 100644
index 1221068..0000000
--- a/src/com/android/contacts/activities/DialpadActivity.java
+++ /dev/null
@@ -1,137 +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.ContactsSearchManager;
-import com.android.contacts.R;
-import com.android.contacts.dialpad.DialpadFragment;
-
-import android.app.Activity;
-import android.content.ActivityNotFoundException;
-import android.content.Context;
-import android.content.Intent;
-import android.content.res.Configuration;
-import android.content.res.Resources;
-import android.os.Bundle;
-import android.os.SystemClock;
-import android.util.Log;
-import android.view.KeyEvent;
-import android.view.ViewConfiguration;
-import android.view.Window;
-import android.view.inputmethod.InputMethodManager;
-
-/**
- * Activity that displays a twelve-key phone dialpad.
- * This is just a simple container around DialpadFragment.
- * @see DialpadFragment
- */
-public class DialpadActivity extends Activity {
-    private static final String TAG = "DialpadActivity";
-
-    private DialpadFragment mFragment;
-
-    @Override
-    protected void onCreate(Bundle icicle) {
-        super.onCreate(icicle);
-
-        setContentView(R.layout.dialpad_activity);
-
-        Resources r = getResources();
-        // Do not show title in the case the device is in carmode.
-        if ((r.getConfiguration().uiMode & Configuration.UI_MODE_TYPE_MASK) ==
-                Configuration.UI_MODE_TYPE_CAR) {
-            requestWindowFeature(Window.FEATURE_NO_TITLE);
-        }
-
-        mFragment = (DialpadFragment) getFragmentManager().findFragmentById(
-                R.id.dialpad_fragment);
-    }
-
-    @Override
-    protected void onNewIntent(Intent newIntent) {
-        setIntent(newIntent);
-        mFragment.configureScreenFromIntent(newIntent);
-    }
-
-    public DialpadFragment getFragment() {
-        return mFragment;
-    }
-
-    @Override
-    public void onWindowFocusChanged(boolean hasFocus) {
-        if (hasFocus) {
-            // Hide soft keyboard, if visible (it's fugly over button dialer).
-            // The only known case where this will be true is when launching the dialer with
-            // ACTION_DIAL via a soft keyboard.  we dismiss it here because we don't
-            // have a window token yet in onCreate / onNewIntent
-            InputMethodManager inputMethodManager = (InputMethodManager)
-                    getSystemService(Context.INPUT_METHOD_SERVICE);
-            inputMethodManager.hideSoftInputFromWindow(
-                    mFragment.getDigitsWidget().getWindowToken(), 0);
-        }
-    }
-
-    @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) {
-                        Log.w(TAG, "Failed to launch voice dialer: " + e);
-                    }
-                }
-                return true;
-            }
-            case KeyEvent.KEYCODE_1: {
-                long timeDiff = SystemClock.uptimeMillis() - event.getDownTime();
-                if (timeDiff >= ViewConfiguration.getLongPressTimeout()) {
-                    // Long press detected, call voice mail
-                    mFragment.callVoicemail();
-                }
-                return true;
-            }
-        }
-        return super.onKeyDown(keyCode, event);
-    }
-
-    @Override
-    public boolean onKeyUp(int keyCode, KeyEvent event) {
-        switch (keyCode) {
-            case KeyEvent.KEYCODE_CALL: {
-                mFragment.dialButtonPressed();
-                return true;
-            }
-        }
-        return super.onKeyUp(keyCode, event);
-    }
-
-    @Override
-    public void startSearch(String initialQuery, boolean selectInitialQuery, Bundle appSearchData,
-            boolean globalSearch) {
-        if (globalSearch) {
-            super.startSearch(initialQuery, selectInitialQuery, appSearchData, globalSearch);
-        } else {
-            ContactsSearchManager.startSearch(this, initialQuery);
-        }
-    }
-}
diff --git a/src/com/android/contacts/activities/DialtactsActivity.java b/src/com/android/contacts/activities/DialtactsActivity.java
index 6200a69..71140bf 100644
--- a/src/com/android/contacts/activities/DialtactsActivity.java
+++ b/src/com/android/contacts/activities/DialtactsActivity.java
@@ -78,6 +78,11 @@
     private static final String CALL_SETTINGS_CLASS_NAME =
             "com.android.phone.CallFeaturesSetting";
 
+    /**
+     * Just for backward compatibility. Should behave as same as {@link Intent#ACTION_DIAL}.
+     */
+    private static final String ACTION_TOUCH_DIALER = "com.android.phone.action.TOUCH_DIALER";
+
     /** Used both by {@link ActionBar} and {@link ViewPagerAdapter} */
     private static final int TAB_INDEX_DIALER = 0;
     private static final int TAB_INDEX_CALL_LOG = 1;
@@ -558,7 +563,7 @@
     /** Returns true if the given intent contains a phone number to populate the dialer with */
     private boolean isDialIntent(Intent intent) {
         final String action = intent.getAction();
-        if (Intent.ACTION_DIAL.equals(action)) {
+        if (Intent.ACTION_DIAL.equals(action) || ACTION_TOUCH_DIALER.equals(action)) {
             return true;
         }
         if (Intent.ACTION_VIEW.equals(action)) {