diff options
author | Nancy Chen <nancychen@google.com> | 2014-07-22 16:55:11 -0700 |
---|---|---|
committer | Nancy Chen <nancychen@google.com> | 2014-07-23 16:49:39 -0700 |
commit | 8a80413884d1afbd7e021d581546c2245f068619 (patch) | |
tree | c4cb510fa203f24c82d2f937948e5bb9b974b3c5 /InCallUI | |
parent | fbfad4618630b82331074197519aa93f25d8e312 (diff) |
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
Diffstat (limited to 'InCallUI')
-rw-r--r-- | InCallUI/src/com/android/incallui/CallCardPresenter.java | 74 |
1 files changed, 30 insertions, 44 deletions
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<CallCardPresenter.CallCardUi> }); } - public void init(Context context, Call call) { mContext = Preconditions.checkNotNull(context); @@ -196,7 +195,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> 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<CallCardPresenter.CallCardUi> 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<CallCardPresenter.CallCardUi> } } + + /** + * 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<CallCardPresenter.CallCardUi> /** * 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<CallCardPresenter.CallCardUi> 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<CallCardPresenter.CallCardUi> 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, |