From 8a80413884d1afbd7e021d581546c2245f068619 Mon Sep 17 00:00:00 2001 From: Nancy Chen Date: Tue, 22 Jul 2014 16:55:11 -0700 Subject: Hide multiple-account information if there is only a single account The InCallUI call state label will show "...via [account]" if multiple accounts exist, this change will hide this if there is only a single account. Bug: 16483795 Change-Id: I11caea8df82058e9eb427a972ecb877ef7a73f1f --- .../com/android/incallui/CallCardPresenter.java | 74 +++++++++------------- 1 file changed, 30 insertions(+), 44 deletions(-) (limited to 'InCallUI/src/com/android') diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index 3d7371088..a1d6d65b6 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -72,7 +72,6 @@ public class CallCardPresenter extends Presenter }); } - public void init(Context context, Call call) { mContext = Preconditions.checkNotNull(context); @@ -196,7 +195,7 @@ public class CallCardPresenter extends Presenter callState = mPrimary.getState(); getUi().setCallState(callState, mPrimary.getDisconnectCause(), getConnectionLabel(), - getConnectionIcon(), getGatewayNumber()); + getCallProviderIcon(mPrimary), getGatewayNumber()); String currentNumber = getNumberFromHandle(mPrimary.getHandle()); if (PhoneNumberUtils.isEmergencyNumber(currentNumber)) { @@ -465,7 +464,7 @@ public class CallCardPresenter extends Presenter final boolean nameIsNumber = nameForCall != null && nameForCall.equals( mSecondaryContactInfo.number); ui.setSecondary(true /* show */, nameForCall, nameIsNumber, mSecondaryContactInfo.label, - getSecondaryCallProviderLabel(), getSecondaryCallProviderIcon(), + getCallProviderLabel(mSecondary), getCallProviderIcon(mSecondary), isConference, isGenericConf); } else { // reset to nothing so that it starts off blank next time we use it. @@ -473,6 +472,18 @@ public class CallCardPresenter extends Presenter } } + + /** + * Gets the phone account to display for a call. + */ + private PhoneAccount getAccountForCall(Call call) { + PhoneAccountHandle accountHandle = call.getAccountHandle(); + if (accountHandle == null) { + return null; + } + return getTelecommManager().getPhoneAccount(accountHandle); + } + /** * Returns the gateway number for any existing outgoing call. */ @@ -486,13 +497,21 @@ public class CallCardPresenter extends Presenter /** * Return the Drawable object of the icon to display to the left of the connection label. */ - private Drawable getConnectionIcon() { - PhoneAccountHandle accountHandle = mPrimary.getAccountHandle(); - if (accountHandle != null) { - PhoneAccount account = getTelecommManager().getPhoneAccount(accountHandle); - if (account != null) { - return account.getIcon(mContext); - } + private Drawable getCallProviderIcon(Call call) { + PhoneAccount account = getAccountForCall(call); + if (account != null && getTelecommManager().hasMultipleEnabledAccounts()) { + return account.getIcon(mContext); + } + return null; + } + + /** + * Return the string label to represent the call provider + */ + private String getCallProviderLabel(Call call) { + PhoneAccount account = getAccountForCall(call); + if (account != null && getTelecommManager().hasMultipleEnabledAccounts()) { + return account.getLabel().toString(); } return null; } @@ -514,36 +533,7 @@ public class CallCardPresenter extends Presenter return null; } } - PhoneAccountHandle accountHandle = mPrimary.getAccountHandle(); - if (accountHandle != null) { - PhoneAccount account = getTelecommManager().getPhoneAccount(accountHandle); - if (account != null) { - return getAccountLabel(account); - } - } - return null; - } - - private String getSecondaryCallProviderLabel() { - PhoneAccountHandle accountHandle = mSecondary.getAccountHandle(); - if (accountHandle != null) { - PhoneAccount account = getTelecommManager().getPhoneAccount(accountHandle); - if (account != null) { - return getAccountLabel(account); - } - } - return null; - } - - private Drawable getSecondaryCallProviderIcon() { - PhoneAccountHandle accountHandle = mSecondary.getAccountHandle(); - if (accountHandle != null) { - PhoneAccount account = getTelecommManager().getPhoneAccount(accountHandle); - if (account != null) { - return account.getIcon(mContext); - } - } - return null; + return getCallProviderLabel(mPrimary); } private boolean hasOutgoingGatewayCall() { @@ -604,10 +594,6 @@ public class CallCardPresenter extends Presenter return handle == null ? "" : handle.getSchemeSpecificPart(); } - private String getAccountLabel(PhoneAccount account) { - return account.getLabel() == null ? null : account.getLabel().toString(); - } - public interface CallCardUi extends Ui { void setVisible(boolean on); void setPrimary(String number, String name, boolean nameIsNumber, String label, -- cgit v1.2.3