diff options
author | Santos Cordon <santoscordon@google.com> | 2013-08-23 19:14:59 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-08-23 19:15:00 +0000 |
commit | 46c1840b5964f84cc2d632d9c6a41b0eca08f356 (patch) | |
tree | 0385d6ca8eeb7bd6a5542650cdab6a9a7bebdb29 /InCallUI/src/com/android/incallui/CallCardPresenter.java | |
parent | f511fc5d660562c44bf3cf50404db8c79941baca (diff) | |
parent | 3d3d25f2bee7cf9cdb91ef35d3028a6a62317e08 (diff) |
Merge "Show gateway UI when dialing via a gateway" into klp-dev
Diffstat (limited to 'InCallUI/src/com/android/incallui/CallCardPresenter.java')
-rw-r--r-- | InCallUI/src/com/android/incallui/CallCardPresenter.java | 52 |
1 files changed, 47 insertions, 5 deletions
diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index 1239695c3..cc2e3bf54 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.os.AsyncTask; @@ -50,9 +53,9 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> private ContactCacheEntry mPrimaryContactInfo; private ContactCacheEntry mSecondaryContactInfo; private CallTimer mCallTimer; + private Context mContext; public CallCardPresenter() { - // create the call timer mCallTimer = new CallTimer(new Runnable() { @Override @@ -62,7 +65,8 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> }); } - public void init(PhoneNumberService phoneNumberService) { + public void init(Context context, PhoneNumberService phoneNumberService) { + mContext = context; mPhoneNumberService = phoneNumberService; } @@ -262,11 +266,14 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> 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); } } @@ -296,6 +303,41 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> } } + /** + * 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<Void, Void, Bitmap>() { @@ -364,7 +406,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> 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); |