diff options
author | Sailesh Nepal <sail@google.com> | 2014-04-07 22:33:09 -0700 |
---|---|---|
committer | Sailesh Nepal <sail@google.com> | 2014-04-07 22:34:12 -0700 |
commit | 46848bb9b89cc5417afae19aaab38fe331a7b474 (patch) | |
tree | c7c1f92fe123c112175577ffeb5187d98f1044c3 /InCallUI/src/com/android/incallui/CallCardFragment.java | |
parent | c6f4e50a4130fb8f7247f5eab6849829701ad484 (diff) |
InCallUI: Handoff UI tweaks
This CL disables the handoff button when handoff is pending.
It also cleans up the handoff UI code.
Bug: 13565185, 13799169
Change-Id: Ie2831ba29d628fb5a0538defe918e3151eb5b824
Diffstat (limited to 'InCallUI/src/com/android/incallui/CallCardFragment.java')
-rw-r--r-- | InCallUI/src/com/android/incallui/CallCardFragment.java | 98 |
1 files changed, 63 insertions, 35 deletions
diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index 984b73a15..090820c47 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -47,6 +47,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr private TextView mPhoneNumber; private TextView mNumberLabel; private TextView mPrimaryName; + private TextView mCallServiceLabel; private TextView mCallStateLabel; private TextView mCallTypeLabel; private ImageView mPhoto; @@ -107,6 +108,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mNumberLabel = (TextView) view.findViewById(R.id.label); mSecondaryCallInfo = (ViewStub) view.findViewById(R.id.secondary_call_info); mPhoto = (ImageView) view.findViewById(R.id.photo); + mCallServiceLabel = (TextView) view.findViewById(R.id.callServiceLabel); mCallStateLabel = (TextView) view.findViewById(R.id.callStateLabel); mCallTypeLabel = (TextView) view.findViewById(R.id.callTypeLabel); mElapsedTime = (TextView) view.findViewById(R.id.elapsedTime); @@ -131,12 +133,6 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr } @Override - public void setShowConnectionHandoff(boolean showConnectionHandoff) { - Log.v(this, "setShowConnectionHandoff: " + showConnectionHandoff); - mConnectionHandoffButton.setVisibility(showConnectionHandoff ? View.VISIBLE : View.GONE); - } - - @Override public void setPrimaryName(String name, boolean nameIsNumber) { if (TextUtils.isEmpty(name)) { mPrimaryName.setText(""); @@ -241,18 +237,29 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr } @Override - public void setCallState(int state, int cause, boolean bluetoothOn, - String gatewayLabel, String gatewayNumber, String wifiConnection) { - String callStateLabel = null; + public void setCallState(int state, int cause, boolean bluetoothOn, String gatewayLabel, + String gatewayNumber, boolean isWiFi, boolean isHandoffCapable, + boolean isHandoffPending) { + String callStateText = null; if (Call.State.isDialing(state) && !TextUtils.isEmpty(gatewayLabel)) { // Provider info: (e.g. "Calling via <gatewayLabel>") - callStateLabel = gatewayLabel; + callStateText = gatewayLabel; } else { - callStateLabel = getCallStateLabelFromState(state, cause); + callStateText = getCallStateLabelFromState(state, cause); + } + + // Only show call service related text if call state is not being displayed. + String callServiceText = null; + if (TextUtils.isEmpty(callStateText)) { + if (isHandoffPending) { + callServiceText = getResources().getString(R.string.handoff_status_pending); + } else if (isWiFi) { + callServiceText = getResources().getString(R.string.in_call_wifi_connected); + } } - Log.v(this, "setCallState " + callStateLabel); + Log.v(this, "setCallState " + callStateText); Log.v(this, "DisconnectCause " + DisconnectCause.toString(cause)); Log.v(this, "bluetooth on " + bluetoothOn); Log.v(this, "gateway " + gatewayLabel + gatewayNumber); @@ -267,31 +274,57 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mSupplementaryInfoContainer.setLayoutTransition(null); } - // Update the call state label. - if (!TextUtils.isEmpty(wifiConnection)) { - mCallStateLabel.setText(getResources().getString(R.string.in_call_wifi_connected, - wifiConnection)); - mCallStateLabel.setGravity(Gravity.START | Gravity.CENTER_VERTICAL); - mCallStateLabel.setBackgroundResource(R.color.wifi_connected_background); - mCallStateLabel.setCompoundDrawablesRelativeWithIntrinsicBounds( - R.drawable.ic_in_call_wifi, 0, 0, 0); - mCallStateLabel.setCompoundDrawablePadding(5); - mCallStateLabel.setAllCaps(false); - mCallStateLabel.setVisibility(View.VISIBLE); + updateCallServiceLabel(isWiFi, callServiceText); + updateCallStateLabel(state, bluetoothOn, callStateText); + + // Only show the handoff button if call state is not being displayed. + boolean showHandoffButton = isHandoffCapable && TextUtils.isEmpty(callStateText); + mConnectionHandoffButton.setVisibility(showHandoffButton ? View.VISIBLE : View.GONE); + mConnectionHandoffButton.setEnabled(!isHandoffPending); - } else if (!TextUtils.isEmpty(callStateLabel)) { - mCallStateLabel.setGravity(Gravity.END); - mCallStateLabel.setAllCaps(true); + // Background color. + if (isWiFi) { + mSupplementaryInfoContainer.setBackgroundResource(R.color.wifi_connected_background); + } else { + mSupplementaryInfoContainer.setBackgroundResource( + R.color.incall_secondary_info_background); + } + + // Restore the animation. + if (skipAnimation) { + mSupplementaryInfoContainer.setLayoutTransition(transition); + } + } + + private void updateCallServiceLabel(boolean isWiFi, String text) { + if (!TextUtils.isEmpty(text)) { + mCallServiceLabel.setText(text); + if (isWiFi) { + mCallServiceLabel.setCompoundDrawablesRelativeWithIntrinsicBounds( + R.drawable.ic_in_call_wifi, 0, 0, 0); + mCallServiceLabel.setCompoundDrawablePadding(5); + mCallServiceLabel.setCompoundDrawablePadding((int) (mDensity * 5)); + } else { + mCallServiceLabel.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); + } + mCallServiceLabel.setVisibility(View.VISIBLE); + } else { + mCallServiceLabel.setText(""); + mCallServiceLabel.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); + mCallServiceLabel.setVisibility(View.GONE); + } + } + + private void updateCallStateLabel(int state, boolean bluetoothOn, String text) { + if (!TextUtils.isEmpty(text)) { mCallStateLabel.setVisibility(View.VISIBLE); - mCallStateLabel.setText(callStateLabel); - mCallStateLabel.setCompoundDrawables(null, null, null, null); + mCallStateLabel.setText(text); + if (Call.State.INCOMING == state) { setBluetoothOn(bluetoothOn); } } else { mCallStateLabel.setVisibility(View.GONE); - mCallStateLabel.setCompoundDrawables(null, null, null, null); - // Gravity is aligned left when receiving an incoming call in landscape. // In that rare case, the gravity needs to be reset to the right. // Also, setText("") is used since there is a delay in making the view GONE, @@ -301,11 +334,6 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mCallStateLabel.setGravity(Gravity.END); } } - - // Restore the animation. - if (skipAnimation) { - mSupplementaryInfoContainer.setLayoutTransition(transition); - } } private void showInternetCallLabel(boolean show) { |