summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSantos Cordon <santoscordon@google.com>2013-08-08 03:55:00 -0700
committerSantos Cordon <santoscordon@google.com>2013-08-08 23:52:56 +0000
commit1b3e3f1056317fca5be4e7535d722da8876b2cbf (patch)
tree1db2cef550db24572e391d1f094e7ff1b84fe500
parentf78a80ef8d521e12d59dfe10997477b5ae874281 (diff)
Add support for more call state labels.
Add remaining call-state UI for the callstate label. Include some bluetooth logic to show an icon for incoming calls. Change-Id: Iecd9b06fb58baf38f665e70e34014c8026d80f68 (cherry picked from commit 946291cb1bb0ec3b4b7f2939fd93dff15627403d)
-rw-r--r--InCallUI/res/drawable-hdpi/ic_incoming_call_bluetooth.pngbin0 -> 2560 bytes
-rw-r--r--InCallUI/res/drawable-mdpi/ic_incoming_call_bluetooth.pngbin0 -> 1245 bytes
-rw-r--r--InCallUI/res/drawable-xhdpi/ic_incoming_call_bluetooth.pngbin0 -> 5919 bytes
-rw-r--r--InCallUI/src/com/android/incallui/CallCardFragment.java81
-rw-r--r--InCallUI/src/com/android/incallui/CallCardPresenter.java44
5 files changed, 114 insertions, 11 deletions
diff --git a/InCallUI/res/drawable-hdpi/ic_incoming_call_bluetooth.png b/InCallUI/res/drawable-hdpi/ic_incoming_call_bluetooth.png
new file mode 100644
index 000000000..050c3e765
--- /dev/null
+++ b/InCallUI/res/drawable-hdpi/ic_incoming_call_bluetooth.png
Binary files differ
diff --git a/InCallUI/res/drawable-mdpi/ic_incoming_call_bluetooth.png b/InCallUI/res/drawable-mdpi/ic_incoming_call_bluetooth.png
new file mode 100644
index 000000000..4b317c110
--- /dev/null
+++ b/InCallUI/res/drawable-mdpi/ic_incoming_call_bluetooth.png
Binary files differ
diff --git a/InCallUI/res/drawable-xhdpi/ic_incoming_call_bluetooth.png b/InCallUI/res/drawable-xhdpi/ic_incoming_call_bluetooth.png
new file mode 100644
index 000000000..662e7bb60
--- /dev/null
+++ b/InCallUI/res/drawable-xhdpi/ic_incoming_call_bluetooth.png
Binary files differ
diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java
index 19c32f4fd..0fd8e357d 100644
--- a/InCallUI/src/com/android/incallui/CallCardFragment.java
+++ b/InCallUI/src/com/android/incallui/CallCardFragment.java
@@ -17,6 +17,7 @@
package com.android.incallui;
import android.app.Activity;
+import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
@@ -46,14 +47,19 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter>
private ViewStub mSecondaryCallInfo;
private TextView mSecondaryCallName;
+ // Cached DisplayMetrics density.
+ private float mDensity;
+
@Override
CallCardPresenter createPresenter() {
- return new CallCardPresenter();
+ return new CallCardPresenter(AudioModeProvider.getInstance());
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
+ mDensity = getResources().getDisplayMetrics().density;
+
return inflater.inflate(R.layout.call_card, container, false);
}
@@ -144,19 +150,23 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter>
}
@Override
- public void setCallState(int state, Call.DisconnectCause cause) {
+ public void setCallState(int state, Call.DisconnectCause cause, boolean bluetoothOn) {
String callStateLabel = null;
// States other than disconnected not yet supported
- if (state == Call.State.DISCONNECTED) {
- callStateLabel = getCallFailedString(cause);
- }
+ callStateLabel = getCallStateLabelFromState(state, cause);
- Logger.d(this, "setCallState ", callStateLabel);
+ Logger.v(this, "setCallState ", callStateLabel);
+ Logger.v(this, "DisconnectCause ", cause);
+ Logger.v(this, "bluetooth on ", bluetoothOn);
if (!TextUtils.isEmpty(callStateLabel)) {
mCallStateLabel.setVisibility(View.VISIBLE);
mCallStateLabel.setText(callStateLabel);
+
+ if (Call.State.INCOMING == state) {
+ setBluetoothOn(bluetoothOn);
+ }
} else {
mCallStateLabel.setVisibility(View.GONE);
// Gravity is aligned left when receiving an incoming call in landscape.
@@ -170,6 +180,65 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter>
}
}
+ private void setBluetoothOn(boolean onOff) {
+ // Also, display a special icon (alongside the "Incoming call"
+ // label) if there's an incoming call and audio will be routed
+ // to bluetooth when you answer it.
+ final int bluetoothIconId = R.drawable.ic_incoming_call_bluetooth;
+
+ if (onOff) {
+ mCallStateLabel.setCompoundDrawablesWithIntrinsicBounds(bluetoothIconId, 0, 0, 0);
+ mCallStateLabel.setCompoundDrawablePadding((int) (mDensity * 5));
+ } else {
+ // Clear out any icons
+ mCallStateLabel.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
+ }
+ }
+
+ /**
+ * Gets the call state label based on the state of the call and
+ * cause of disconnect
+ */
+ private String getCallStateLabelFromState(int state, Call.DisconnectCause cause) {
+ final Context context = getView().getContext();
+ String callStateLabel = null; // Label to display as part of the call banner
+
+ if (Call.State.IDLE == state) {
+ // "Call state" is meaningless in this state.
+
+ } else if (Call.State.ACTIVE == state) {
+ // We normally don't show a "call state label" at all in
+ // this state (but see below for some special cases).
+
+ } else if (Call.State.ONHOLD == state) {
+ callStateLabel = context.getString(R.string.card_title_on_hold);
+
+ } else if (Call.State.DIALING == state) {
+ callStateLabel = context.getString(R.string.card_title_dialing);
+
+ } else if (Call.State.INCOMING == state || Call.State.CALL_WAITING == state) {
+ callStateLabel = context.getString(R.string.card_title_incoming_call);
+
+ // TODO(klp): Add a disconnecting state
+ //} else if (Call.State.DISCONNECTING) {
+ // While in the DISCONNECTING state we display a "Hanging up"
+ // message in order to make the UI feel more responsive. (In
+ // GSM it's normal to see a delay of a couple of seconds while
+ // negotiating the disconnect with the network, so the "Hanging
+ // up" state at least lets the user know that we're doing
+ // something. This state is currently not used with CDMA.)
+ //callStateLabel = context.getString(R.string.card_title_hanging_up);
+
+ } else if (Call.State.DISCONNECTED == state) {
+ callStateLabel = getCallFailedString(cause);
+
+ } else {
+ Logger.wtf(this, "updateCallStateWidgets: unexpected call state: " + state);
+ }
+
+ return callStateLabel;
+ }
+
/**
* Maps the disconnect cause to a resource string.
*/
diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java
index f709abed9..e53151188 100644
--- a/InCallUI/src/com/android/incallui/CallCardPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java
@@ -24,9 +24,11 @@ import android.net.Uri;
import android.provider.ContactsContract.Contacts;
import android.text.TextUtils;
+import com.android.incallui.AudioModeProvider.AudioModeListener;
import com.android.incallui.InCallPresenter.InCallState;
import com.android.incallui.InCallPresenter.InCallStateListener;
+import com.android.services.telephony.common.AudioMode;
import com.android.services.telephony.common.Call;
/**
@@ -35,11 +37,13 @@ import com.android.services.telephony.common.Call;
*/
public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> implements
InCallStateListener, CallerInfoAsyncQuery.OnQueryCompleteListener,
- ContactsAsyncHelper.OnImageLoadCompleteListener {
+ ContactsAsyncHelper.OnImageLoadCompleteListener, AudioModeListener {
private static final int TOKEN_UPDATE_PHOTO_FOR_CALL_STATE = 0;
private Context mContext;
+ private AudioModeProvider mAudioModeProvider;
+ private Call mPrimary;
/**
* Uri being used to load contact photo for mPhoto. Will be null when nothing is being loaded,
@@ -50,13 +54,24 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> i
// Track the state for the photo.
private ContactsAsyncHelper.ImageTracker mPhotoTracker;
- public CallCardPresenter() {
+ public CallCardPresenter(AudioModeProvider audioModeProvider) {
mPhotoTracker = new ContactsAsyncHelper.ImageTracker();
+ mAudioModeProvider = audioModeProvider;
}
@Override
public void onUiReady(CallCardUi ui) {
super.onUiReady(ui);
+
+ mAudioModeProvider.addListener(this);
+ }
+
+ @Override
+ public void onUiUnready(CallCardUi ui) {
+ super.onUiUnready(ui);
+
+ mAudioModeProvider.removeListener(this);
+ mPrimary = null;
}
public void setContext(Context context) {
@@ -66,6 +81,9 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> i
@Override
public void onStateChange(InCallState state, CallList callList) {
final CallCardUi ui = getUi();
+ if (ui == null) {
+ return;
+ }
Call primary = null;
Call secondary = null;
@@ -95,10 +113,11 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> i
true);
ui.setNumber(primary.getNumber());
- ui.setCallState(primary.getState(), primary.getDisconnectCause());
+ ui.setCallState(primary.getState(), primary.getDisconnectCause(),
+ (mAudioModeProvider.getAudioMode() == AudioMode.BLUETOOTH));
} else {
ui.setNumber("");
- ui.setCallState(Call.State.INVALID, Call.DisconnectCause.UNKNOWN);
+ ui.setCallState(Call.State.INVALID, Call.DisconnectCause.UNKNOWN, false);
}
// Set secondary call data
@@ -107,6 +126,21 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> i
} else {
ui.setSecondaryCallInfo(false, null);
}
+
+ mPrimary = primary;
+ }
+
+ @Override
+ public void onAudioMode(int mode) {
+ if (mPrimary != null && getUi() != null) {
+ final boolean bluetoothOn = (AudioMode.BLUETOOTH == mode);
+
+ getUi().setCallState(mPrimary.getState(), mPrimary.getDisconnectCause(), bluetoothOn);
+ }
+ }
+
+ @Override
+ public void onSupportedAudioMode(int mask) {
}
/**
@@ -155,7 +189,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> i
void setImage(Drawable drawable);
void setImage(Bitmap bitmap);
void setSecondaryCallInfo(boolean show, String number);
- void setCallState(int state, Call.DisconnectCause cause);
+ void setCallState(int state, Call.DisconnectCause cause, boolean bluetoothOn);
}
@Override