Merge "Show "Calling via google voice" only in the DIALING state." into klp-dev
diff --git a/InCallUI/res/layout/primary_call_info.xml b/InCallUI/res/layout/primary_call_info.xml
index 681519b..fd8b83a 100644
--- a/InCallUI/res/layout/primary_call_info.xml
+++ b/InCallUI/res/layout/primary_call_info.xml
@@ -167,7 +167,7 @@
                       android:textAppearance="?android:attr/textAppearanceSmall"
                       android:textColor="@color/incall_call_banner_text_color"
                       android:textAllCaps="true"
-                      android:background="@color/incall_secondary_info_background"
+                      android:background="@android:color/transparent"
                       android:singleLine="true"
                       android:ellipsize="end"/>
         </LinearLayout>
diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java
index 9c772cb..d96e411 100644
--- a/InCallUI/src/com/android/incallui/CallCardFragment.java
+++ b/InCallUI/src/com/android/incallui/CallCardFragment.java
@@ -167,20 +167,9 @@
     }
 
     @Override
-    public void setPrimaryGateway(String gatewayLabel, String gatewayNumber) {
-        if (!TextUtils.isEmpty(gatewayLabel) && !TextUtils.isEmpty(gatewayNumber)) {
-            mProviderLabel.setText(gatewayLabel);
-            mProviderNumber.setText(gatewayNumber);
-            mProviderInfo.setVisibility(View.VISIBLE);
-        } else {
-            mProviderInfo.setVisibility(View.GONE);
-        }
-    }
-
-    @Override
     public void setPrimary(String number, String name, boolean nameIsNumber, String label,
-            Drawable photo, boolean isConference, String gatewayLabel, String gatewayNumber) {
-        Log.d(this, "Setting primary call [" + gatewayLabel + "][" + gatewayNumber + "]");
+            Drawable photo, boolean isConference) {
+        Log.d(this, "Setting primary call");
 
         if (isConference) {
             name = getView().getResources().getString(R.string.card_title_conf_call);
@@ -190,9 +179,6 @@
 
         setPrimaryPhoneNumber(number);
 
-        // Set any gateway information
-        setPrimaryGateway(gatewayLabel, gatewayNumber);
-
         // set the name field.
         setPrimaryName(name, nameIsNumber);
 
@@ -236,7 +222,8 @@
     }
 
     @Override
-    public void setCallState(int state, Call.DisconnectCause cause, boolean bluetoothOn) {
+    public void setCallState(int state, Call.DisconnectCause cause, boolean bluetoothOn,
+            String gatewayLabel, String gatewayNumber) {
         String callStateLabel = null;
 
         // States other than disconnected not yet supported
@@ -245,25 +232,23 @@
         Log.v(this, "setCallState ", callStateLabel);
         Log.v(this, "DisconnectCause ", cause);
         Log.v(this, "bluetooth on ", bluetoothOn);
+        Log.v(this, "gateway " + gatewayLabel + gatewayNumber);
 
+        // There are cases where we totally skip the animation, in which case remove the transition
+        // animation here and restore it afterwards.
+        final boolean skipAnimation = (state == Call.State.DIALING
+                || state == Call.State.DISCONNECTED);
+        LayoutTransition transition = null;
+        if (skipAnimation) {
+            transition = mSupplementaryInfoContainer.getLayoutTransition();
+            mSupplementaryInfoContainer.setLayoutTransition(null);
+        }
+
+        // Update the call state label.
         if (!TextUtils.isEmpty(callStateLabel)) {
-            // There are cases where we totally skip the animation
-            final boolean skipAnimation = (state == Call.State.DIALING
-                    || state == Call.State.DISCONNECTED);
-
-            LayoutTransition transition = null;
-            if (skipAnimation) {
-                transition = mSupplementaryInfoContainer.getLayoutTransition();
-                mSupplementaryInfoContainer.setLayoutTransition(null);
-            }
-
             mCallStateLabel.setVisibility(View.VISIBLE);
             mCallStateLabel.setText(callStateLabel);
 
-            if (skipAnimation) {
-                mSupplementaryInfoContainer.setLayoutTransition(transition);
-            }
-
             if (Call.State.INCOMING == state) {
                 setBluetoothOn(bluetoothOn);
             }
@@ -278,6 +263,20 @@
                 mCallStateLabel.setGravity(Gravity.END);
             }
         }
+
+        // Provider info: (e.g. "Calling via <gatewayLabel>")
+        if (!TextUtils.isEmpty(gatewayLabel) && !TextUtils.isEmpty(gatewayNumber)) {
+            mProviderLabel.setText(gatewayLabel);
+            mProviderNumber.setText(gatewayNumber);
+            mProviderInfo.setVisibility(View.VISIBLE);
+        } else {
+            mProviderInfo.setVisibility(View.GONE);
+        }
+
+        // Restore the animation.
+        if (skipAnimation) {
+            mSupplementaryInfoContainer.setLayoutTransition(transition);
+        }
     }
 
     @Override
diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java
index 6c8056b..f56d4e1 100644
--- a/InCallUI/src/com/android/incallui/CallCardPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java
@@ -188,9 +188,10 @@
         if (mPrimary != null) {
             final boolean bluetoothOn =
                     (AudioModeProvider.getInstance().getAudioMode() == AudioMode.BLUETOOTH);
-            ui.setCallState(mPrimary.getState(), mPrimary.getDisconnectCause(), bluetoothOn);
+            ui.setCallState(mPrimary.getState(), mPrimary.getDisconnectCause(), bluetoothOn,
+                    getGatewayLabel(), getGatewayNumber());
         } else {
-            ui.setCallState(Call.State.IDLE, Call.DisconnectCause.UNKNOWN, false);
+            ui.setCallState(Call.State.IDLE, Call.DisconnectCause.UNKNOWN, false, null, null);
         }
     }
 
@@ -199,7 +200,8 @@
         if (mPrimary != null && getUi() != null) {
             final boolean bluetoothOn = (AudioMode.BLUETOOTH == mode);
 
-            getUi().setCallState(mPrimary.getState(), mPrimary.getDisconnectCause(), bluetoothOn);
+            getUi().setCallState(mPrimary.getState(), mPrimary.getDisconnectCause(), bluetoothOn,
+                    getGatewayLabel(), getGatewayNumber());
         }
     }
 
@@ -350,15 +352,12 @@
             final String name = getNameForCall(entry);
             final String number = getNumberForCall(entry);
             final boolean nameIsNumber = name != null && name.equals(entry.number);
-            final String gatewayLabel = getGatewayLabel();
-            final String gatewayNumber = getGatewayNumber();
 
             ui.setPrimary(number, name, nameIsNumber, entry.label,
-                    entry.photo, isConference, gatewayLabel,
-                    gatewayNumber);
+                    entry.photo, isConference);
         } else {
             // reset to nothing (like at end of call)
-            ui.setPrimary(null, null, false, null, null, false, null, null);
+            ui.setPrimary(null, null, false, null, null, false);
         }
 
     }
@@ -506,16 +505,16 @@
     public interface CallCardUi extends Ui {
         void setVisible(boolean on);
         void setPrimary(String number, String name, boolean nameIsNumber, String label,
-                Drawable photo, boolean isConference, String gatewayLabel, String gatewayNumber);
+                Drawable photo, boolean isConference);
         void setSecondary(boolean show, String name, boolean nameIsNumber, String label,
                 Drawable photo, boolean isConference);
         void setSecondaryImage(Bitmap bitmap);
-        void setCallState(int state, Call.DisconnectCause cause, boolean bluetoothOn);
+        void setCallState(int state, Call.DisconnectCause cause, boolean bluetoothOn,
+                String gatewayLabel, String gatewayNumber);
         void setPrimaryCallElapsedTime(boolean show, String duration);
         void setPrimaryName(String name, boolean nameIsNumber);
         void setPrimaryImage(Bitmap bitmap);
         void setPrimaryPhoneNumber(String phoneNumber);
         void setPrimaryLabel(String label);
-        void setPrimaryGateway(String label, String number);
     }
 }