From 3d3d25f2bee7cf9cdb91ef35d3028a6a62317e08 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Thu, 22 Aug 2013 18:03:39 -0700 Subject: Show gateway UI when dialing via a gateway Gateway information is not available in the Call object. Inside CallCardPresenter, we use this to show the user dialing information when dialing out through a gateway. This includes a "Calling via..." notice above the call state label and the gateway number. bug: 10393622 Change-Id: Iff1247cd592b0730bb7cfc6d16bd8f60b47f3737 --- .../com/android/incallui/CallCardPresenter.java | 52 +++++++++++++++++++--- 1 file changed, 47 insertions(+), 5 deletions(-) (limited to 'InCallUI/src/com/android/incallui/CallCardPresenter.java') diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index 5ab2529ff..f233d78ea 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -16,6 +16,9 @@ package com.android.incallui; +import android.content.Context; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -54,9 +57,9 @@ public class CallCardPresenter extends Presenter private ContactCacheEntry mPrimaryContactInfo; private ContactCacheEntry mSecondaryContactInfo; private CallTimer mCallTimer; + private Context mContext; public CallCardPresenter() { - // create the call timer mCallTimer = new CallTimer(new Runnable() { @Override @@ -66,7 +69,8 @@ public class CallCardPresenter extends Presenter }); } - public void init(PhoneNumberService phoneNumberService) { + public void init(Context context, PhoneNumberService phoneNumberService) { + mContext = context; mPhoneNumberService = phoneNumberService; } @@ -266,11 +270,14 @@ public class CallCardPresenter extends Presenter final String name = getNameForCall(mPrimaryContactInfo); final String number = getNumberForCall(mPrimaryContactInfo); final boolean nameIsNumber = name != null && name.equals(mPrimaryContactInfo.number); + final String gatewayLabel = getGatewayLabel(); + final String gatewayNumber = getGatewayNumber(); ui.setPrimary(number, name, nameIsNumber, mPrimaryContactInfo.label, - mPrimaryContactInfo.photo, mPrimary.isConferenceCall()); + mPrimaryContactInfo.photo, mPrimary.isConferenceCall(), gatewayLabel, + gatewayNumber); } else { // reset to nothing (like at end of call) - ui.setPrimary(null, null, false, null, null, false); + ui.setPrimary(null, null, false, null, null, false, null, null); } } @@ -300,6 +307,41 @@ public class CallCardPresenter extends Presenter } } + /** + * Returns the gateway number for any existing outgoing call. + */ + private String getGatewayNumber() { + if (hasOutgoingGatewayCall()) { + return mPrimary.getGatewayNumber(); + } + + return null; + } + + /** + * Returns the label for the gateway app for any existing outgoing call. + */ + private String getGatewayLabel() { + if (hasOutgoingGatewayCall() && getUi() != null) { + final PackageManager pm = mContext.getPackageManager(); + try { + final ApplicationInfo info = pm.getApplicationInfo(mPrimary.getGatewayPackage(), 0); + return mContext.getString(R.string.calling_via_template, + pm.getApplicationLabel(info).toString()); + } catch (PackageManager.NameNotFoundException e) { + } + } + return null; + } + + private boolean hasOutgoingGatewayCall() { + // We only display the gateway information while DIALING so return false for any othe + // call state. + return (mPrimary.getState() == Call.State.DIALING && + !TextUtils.isEmpty(mPrimary.getGatewayNumber()) && + !TextUtils.isEmpty(mPrimary.getGatewayPackage())); + } + private void fetchImage(final String url) { if (url != null) { new AsyncTask() { @@ -374,7 +416,7 @@ public class CallCardPresenter extends Presenter public interface CallCardUi extends Ui { void setVisible(boolean on); void setPrimary(String number, String name, boolean nameIsNumber, String label, - Drawable photo, boolean isConference); + Drawable photo, boolean isConference, String gatewayLabel, String gatewayNumber); void setSecondary(boolean show, String name, String label, Drawable photo); void setCallState(int state, Call.DisconnectCause cause, boolean bluetoothOn); void setPrimaryCallElapsedTime(boolean show, String duration); -- cgit v1.2.3