Add "call type" indication to CallCard.

For SIP calls, the in-call UI now displays "Internet call" in green text
just below the phone number.

Change-Id: Icdd23d9a3def78bac6bab82fa919336b38b18e4f
diff --git a/res/layout/call_card_person_info.xml b/res/layout/call_card_person_info.xml
index b5a6901..0810464 100644
--- a/res/layout/call_card_person_info.xml
+++ b/res/layout/call_card_person_info.xml
@@ -113,6 +113,20 @@
                   />
     </LinearLayout>
 
+    <!-- Call type indication: a special label and/or branding
+         for certain kinds of calls -->
+    <TextView android:id="@+id/callTypeLabel"
+              android:textAppearance="?android:attr/textAppearanceSmall"
+              android:textSize="16sp"
+              android:textColor="?android:attr/textColorSecondary"
+              android:maxLines="1"
+              android:ellipsize="end"
+              android:paddingLeft="10dip"
+              android:paddingRight="10dip"
+              android:layout_width="wrap_content"
+              android:layout_height="wrap_content"
+              />
+
     <!-- Social status -->
     <TextView android:id="@+id/socialStatus"
               android:textAppearance="?android:attr/textAppearanceSmall"
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 8c66f3a..a89e2bb 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -4,9 +4,9 @@
      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.
@@ -24,7 +24,8 @@
     <color name="incall_textEnded">#FF6072</color> <!-- red -->
     <color name="incall_textOnHold">#FF9524</color> <!-- orange -->
     <color name="incall_endButtonLabel">#FF6072</color> <!-- red -->
-    
+    <color name="incall_callTypeSip">#99CE3F</color> <!-- green -->
+
     <!-- DTMF Dialer -->
     <color name="dtmf_dialer_background">#333333</color> <!-- green -->
     <color name="dtmf_dialer_display_text">#FFFFFF</color> <!-- white -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ad73034..1a93c2b 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -935,6 +935,9 @@
     <!-- In-call screen: message displayed in an error dialog -->
     <string name="incall_error_supp_service_hangup">Unable to release call(s).</string>
 
+    <!-- In-call screen: "call type" indication for a SIP call [CHAR LIMIT=30]  -->
+    <string name="incall_call_type_label_sip">Internet call</string>
+
     <!-- Dialog title for the "radio enable" UI for emergency calls -->
     <string name="emergency_enable_radio_dialog_title">Emergency call</string>
     <!-- Status message for the "radio enable" UI for emergency calls -->
diff --git a/src/com/android/phone/CallCard.java b/src/com/android/phone/CallCard.java
index d85e531..657dfc5 100755
--- a/src/com/android/phone/CallCard.java
+++ b/src/com/android/phone/CallCard.java
@@ -81,6 +81,7 @@
     private int mTextColorConnectedBluetooth;
     private int mTextColorEnded;
     private int mTextColorOnHold;
+    private int mTextColorCallTypeSip;
 
     // The main block of info about the "primary" or "active" call,
     // including photo / name / phone number / etc.
@@ -89,6 +90,7 @@
     private TextView mName;
     private TextView mPhoneNumber;
     private TextView mLabel;
+    private TextView mCallTypeLabel;
     private TextView mSocialStatus;
 
     // Info about the "secondary" call, which is the "call on hold" when
@@ -175,6 +177,7 @@
                 getResources().getColor(R.color.incall_textConnectedBluetooth);
         mTextColorEnded = getResources().getColor(R.color.incall_textEnded);
         mTextColorOnHold = getResources().getColor(R.color.incall_textOnHold);
+        mTextColorCallTypeSip = getResources().getColor(R.color.incall_callTypeSip);
 
         // "Caller info" area, including photo / name / phone numbers / etc
         mPhoto = (ImageView) findViewById(R.id.photo);
@@ -183,6 +186,7 @@
         mName = (TextView) findViewById(R.id.name);
         mPhoneNumber = (TextView) findViewById(R.id.phoneNumber);
         mLabel = (TextView) findViewById(R.id.label);
+        mCallTypeLabel = (TextView) findViewById(R.id.callTypeLabel);
         mSocialStatus = (TextView) findViewById(R.id.socialStatus);
 
         // "Other call" info area
@@ -1121,18 +1125,9 @@
             mLabel.setVisibility(View.GONE);
         }
 
-        // "Social status": currently unused.
-        // Note socialStatus is *only* visible while an incoming
-        // call is ringing, never in any other call state.
-        if ((socialStatusText != null) && call.isRinging() && !call.isGeneric()) {
-            mSocialStatus.setVisibility(View.VISIBLE);
-            mSocialStatus.setText(socialStatusText);
-            mSocialStatus.setCompoundDrawablesWithIntrinsicBounds(
-                    socialStatusBadge, null, null, null);
-            mSocialStatus.setCompoundDrawablePadding((int) (mDensity * 6));
-        } else {
-            mSocialStatus.setVisibility(View.GONE);
-        }
+        // Other text fields:
+        updateCallTypeLabel(call);
+        updateSocialStatus(socialStatusText, socialStatusBadge, call);  // Currently unused
     }
 
     private String getPresentationString(int presentation) {
@@ -1191,8 +1186,9 @@
         mPhoneNumber.setVisibility(View.GONE);
         mLabel.setVisibility(View.GONE);
 
-        // socialStatus is never visible in this state.
-        mSocialStatus.setVisibility(View.GONE);
+        // Other text fields:
+        updateCallTypeLabel(call);
+        updateSocialStatus(null, null, null);  // socialStatus is never visible in this state
 
         // TODO: for a GSM conference call, since we do actually know who
         // you're talking to, consider also showing names / numbers /
@@ -1410,6 +1406,54 @@
     }
 
     /**
+     * Updates the "Call type" label, based on the current foreground call.
+     * This is a special label and/or branding we display for certain
+     * kinds of calls.
+     *
+     * (So far, this is used only for SIP calls, which get an
+     * "Internet call" label.  TODO: But eventually, the telephony
+     * layer might allow each pluggable "provider" to specify a string
+     * and/or icon to be displayed here.)
+     */
+    private void updateCallTypeLabel(Call call) {
+        int phoneType = (call != null) ? call.getPhone().getPhoneType() : Phone.PHONE_TYPE_NONE;
+        if (phoneType == Phone.PHONE_TYPE_SIP) {
+            mCallTypeLabel.setVisibility(View.VISIBLE);
+            mCallTypeLabel.setText(R.string.incall_call_type_label_sip);
+            mCallTypeLabel.setTextColor(mTextColorCallTypeSip);
+            // If desired, we could also display a "badge" next to the label, as follows:
+            //   mCallTypeLabel.setCompoundDrawablesWithIntrinsicBounds(
+            //           callTypeSpecificBadge, null, null, null);
+            //   mCallTypeLabel.setCompoundDrawablePadding((int) (mDensity * 6));
+        } else {
+            mCallTypeLabel.setVisibility(View.GONE);
+        }
+    }
+
+    /**
+     * Updates the "social status" label with the specified text and
+     * (optional) badge.
+     */
+    private void updateSocialStatus(String socialStatusText,
+                                    Drawable socialStatusBadge,
+                                    Call call) {
+        // The socialStatus field is *only* visible while an incoming call
+        // is ringing, never in any other call state.
+        if ((socialStatusText != null)
+                && (call != null)
+                && call.isRinging()
+                && !call.isGeneric()) {
+            mSocialStatus.setVisibility(View.VISIBLE);
+            mSocialStatus.setText(socialStatusText);
+            mSocialStatus.setCompoundDrawablesWithIntrinsicBounds(
+                    socialStatusBadge, null, null, null);
+            mSocialStatus.setCompoundDrawablePadding((int) (mDensity * 6));
+        } else {
+            mSocialStatus.setVisibility(View.GONE);
+        }
+    }
+
+    /**
      * Hides the top-level UI elements of the call card:  The "main
      * call card" element representing the current active or ringing call,
      * and also the info areas for "ongoing" or "on hold" calls in some