summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Lee <anwlee@google.com>2014-10-15 19:59:19 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-10-15 19:59:19 +0000
commitaec501c9c29db2ef2f2ac885da1462a5916e32b7 (patch)
tree3c1bab5a5b74a80b503b1ad93eb7201c71b9186a
parenta005a7b017d4cb2afdb6c0c359b334c3e7dcb285 (diff)
parent21707a656d5097323627b5096276dfa509259150 (diff)
Merge "Update Conference Manager UI after capability changes." into lmp-mr1-dev
-rw-r--r--InCallUI/src/com/android/incallui/ConferenceManagerFragment.java67
-rw-r--r--InCallUI/src/com/android/incallui/ConferenceManagerPresenter.java76
2 files changed, 79 insertions, 64 deletions
diff --git a/InCallUI/src/com/android/incallui/ConferenceManagerFragment.java b/InCallUI/src/com/android/incallui/ConferenceManagerFragment.java
index e7785c151..c6ae19a1c 100644
--- a/InCallUI/src/com/android/incallui/ConferenceManagerFragment.java
+++ b/InCallUI/src/com/android/incallui/ConferenceManagerFragment.java
@@ -61,8 +61,8 @@ public class ConferenceManagerFragment
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- final View parent = inflater.inflate(R.layout.conference_manager_fragment, container,
- false);
+ final View parent =
+ inflater.inflate(R.layout.conference_manager_fragment, container, false);
// Create list of conference call widgets
mConferenceCallList = new ViewGroup[getPresenter().getMaxCallersInConference()];
@@ -70,6 +70,7 @@ public class ConferenceManagerFragment
R.id.caller3, R.id.caller4 };
for (int i = 0; i < getPresenter().getMaxCallersInConference(); i++) {
mConferenceCallList[i] = (ViewGroup) parent.findViewById(viewGroupIdList[i]);
+ initializeRow(mConferenceCallList[i], i);
}
mContactPhotoManager =
@@ -81,6 +82,27 @@ public class ConferenceManagerFragment
return parent;
}
+ /**
+ * Setup listeners for disconnecting and separating child calls.
+ */
+ private void initializeRow(View rowView, final int rowId) {
+ View endButton = rowView.findViewById(R.id.conferenceCallerDisconnect);
+ endButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ getPresenter().endConferenceConnection(rowId);
+ }
+ });
+
+ View separateButton = rowView.findViewById(R.id.conferenceCallerSeparate);
+ separateButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ getPresenter().separateConferenceConnection(rowId);
+ }
+ });
+ }
+
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
@@ -114,11 +136,7 @@ public class ConferenceManagerFragment
@Override
public void setRowVisible(int rowId, boolean on) {
- if (on) {
- mConferenceCallList[rowId].setVisibility(View.VISIBLE);
- } else {
- mConferenceCallList[rowId].setVisibility(View.GONE);
- }
+ mConferenceCallList[rowId].setVisibility(on ? View.VISIBLE : View.GONE);
}
/**
@@ -158,38 +176,15 @@ public class ConferenceManagerFragment
}
@Override
- public final void setupEndButtonForRow(final int rowId, boolean canDisconnect) {
+ public void updateEndButtonForRow(int rowId, boolean canDisconnect) {
View endButton = mConferenceCallList[rowId].findViewById(R.id.conferenceCallerDisconnect);
-
- // Comment
- if (canDisconnect) {
- endButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- getPresenter().endConferenceConnection(rowId);
- }
- });
- endButton.setVisibility(View.VISIBLE);
- } else {
- endButton.setVisibility(View.INVISIBLE);
- }
+ endButton.setVisibility(canDisconnect ? View.VISIBLE : View.GONE);
}
@Override
- public final void setupSeparateButtonForRow(final int rowId, boolean canSeparate) {
- final View separateButton =
+ public void updateSeparateButtonForRow(int rowId, boolean canSeparate) {
+ View separateButton =
mConferenceCallList[rowId].findViewById(R.id.conferenceCallerSeparate);
-
- if (canSeparate) {
- separateButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- getPresenter().separateConferenceConnection(rowId);
- }
- });
- separateButton.setVisibility(View.VISIBLE);
- } else {
- separateButton.setVisibility(View.INVISIBLE);
- }
+ separateButton.setVisibility(canSeparate ? View.VISIBLE : View.GONE);
}
-} \ No newline at end of file
+}
diff --git a/InCallUI/src/com/android/incallui/ConferenceManagerPresenter.java b/InCallUI/src/com/android/incallui/ConferenceManagerPresenter.java
index 269f37d9c..555048da1 100644
--- a/InCallUI/src/com/android/incallui/ConferenceManagerPresenter.java
+++ b/InCallUI/src/com/android/incallui/ConferenceManagerPresenter.java
@@ -22,6 +22,7 @@ import android.telecom.PhoneCapabilities;
import android.text.TextUtils;
import com.android.incallui.ContactInfoCache.ContactCacheEntry;
+import com.android.incallui.InCallPresenter.InCallDetailsListener;
import com.android.incallui.InCallPresenter.InCallState;
import com.android.incallui.InCallPresenter.InCallStateListener;
@@ -32,11 +33,11 @@ import com.google.common.base.Preconditions;
*/
public class ConferenceManagerPresenter
extends Presenter<ConferenceManagerPresenter.ConferenceManagerUi>
- implements InCallStateListener {
+ implements InCallStateListener, InCallDetailsListener {
private static final int MAX_CALLERS_IN_CONFERENCE = 5;
- private String[] mCallerIds;
+ private String[] mCallerIds = new String[0];
private Context mContext;
@Override
@@ -73,6 +74,26 @@ public class ConferenceManagerPresenter
}
}
+ @Override
+ public void onDetailsChanged(Call call, android.telecom.Call.Details details) {
+ boolean canDisconnect = PhoneCapabilities.can(
+ details.getCallCapabilities(), PhoneCapabilities.DISCONNECT_FROM_CONFERENCE);
+ boolean canSeparate = PhoneCapabilities.can(
+ details.getCallCapabilities(), PhoneCapabilities.SEPARATE_FROM_CONFERENCE);
+
+ if (call.can(PhoneCapabilities.DISCONNECT_FROM_CONFERENCE) == canDisconnect
+ && call.can(PhoneCapabilities.SEPARATE_FROM_CONFERENCE) == canSeparate) {
+ return;
+ }
+
+ for (int i = 0; i < mCallerIds.length; i++) {
+ if (mCallerIds[i] == call.getId()) {
+ getUi().updateSeparateButtonForRow(i, canSeparate);
+ getUi().updateEndButtonForRow(i, canDisconnect);
+ }
+ }
+ }
+
public void init(Context context, CallList callList) {
mContext = Preconditions.checkNotNull(context);
mContext = context;
@@ -82,35 +103,33 @@ public class ConferenceManagerPresenter
private void update(CallList callList) {
// callList is non null, but getActiveOrBackgroundCall() may return null
final Call currentCall = callList.getActiveOrBackgroundCall();
- if (currentCall != null) {
- // getChildCallIds() always returns a valid Set
- mCallerIds = currentCall.getChildCallIds().toArray(new String[0]);
- } else {
- mCallerIds = new String[0];
+ if (currentCall == null) {
+ return;
}
+
+ // getChildCallIds() always returns a valid Set
+ mCallerIds = currentCall.getChildCallIds().toArray(new String[0]);
Log.d(this, "Number of calls is " + String.valueOf(mCallerIds.length));
- // Users can split out a call from the conference call if there either the active call
- // or the holding call is empty. If both are filled at the moment, users can not split out
- // another call.
+ // Users can split out a call from the conference call if either the active call or the
+ // holding call is empty. If both are filled, users can not split out another call.
final boolean hasActiveCall = (callList.getActiveCall() != null);
final boolean hasHoldingCall = (callList.getBackgroundCall() != null);
boolean canSeparate = !(hasActiveCall && hasHoldingCall);
for (int i = 0; i < MAX_CALLERS_IN_CONFERENCE; i++) {
if (i < mCallerIds.length) {
- int callCapabilities =
- callList.getCallById(currentCall.getChildCallIds().get(i))
- .getTelecommCall().getDetails().getCallCapabilities();
- boolean thisRowCanSeparate = canSeparate &&
- ((callCapabilities & PhoneCapabilities.SEPARATE_FROM_CONFERENCE) != 0);
- boolean thisRowCanDisconnect =
- ((callCapabilities & PhoneCapabilities.DISCONNECT_FROM_CONFERENCE) != 0);
+ Call call = callList.getCallById(currentCall.getChildCallIds().get(i));
+ int callCapabilities = call.getTelecommCall().getDetails().getCallCapabilities();
+ boolean thisRowCanSeparate = canSeparate && PhoneCapabilities.can(
+ callCapabilities, PhoneCapabilities.SEPARATE_FROM_CONFERENCE);
+ boolean thisRowCanDisconnect = PhoneCapabilities.can(
+ callCapabilities, PhoneCapabilities.DISCONNECT_FROM_CONFERENCE);
// Fill in the row in the UI for this caller.
- final ContactCacheEntry contactCache = ContactInfoCache.getInstance(mContext).
- getInfo(mCallerIds[i]);
+ final ContactCacheEntry contactCache =
+ ContactInfoCache.getInstance(mContext).getInfo(mCallerIds[i]);
updateManageConferenceRow(
- i,
+ i /* row index */,
contactCache,
thisRowCanSeparate,
thisRowCanDisconnect);
@@ -133,10 +152,11 @@ public class ConferenceManagerPresenter
* on this row in the UI.
* @param canDisconnect if true, show a "Disconnect" button on this row in the UI.
*/
- public void updateManageConferenceRow(final int i,
- final ContactCacheEntry contactCacheEntry,
- boolean canSeparate,
- boolean canDisconnect) {
+ public void updateManageConferenceRow(
+ final int i,
+ final ContactCacheEntry contactCacheEntry,
+ boolean canSeparate,
+ boolean canDisconnect) {
if (contactCacheEntry != null) {
// Activate this row of the Manage conference panel:
@@ -150,8 +170,8 @@ public class ConferenceManagerPresenter
number = null;
}
- getUi().setupSeparateButtonForRow(i, canSeparate);
- getUi().setupEndButtonForRow(i, canDisconnect);
+ getUi().updateSeparateButtonForRow(i, canSeparate);
+ getUi().updateEndButtonForRow(i, canDisconnect);
getUi().displayCallerInfoForConferenceRow(i, name, number, contactCacheEntry.label,
contactCacheEntry.lookupKey, contactCacheEntry.displayPhotoUri);
} else {
@@ -182,7 +202,7 @@ public class ConferenceManagerPresenter
void setRowVisible(int rowId, boolean on);
void displayCallerInfoForConferenceRow(int rowId, String callerName, String callerNumber,
String callerNumberType, String lookupKey, Uri photoUri);
- void setupSeparateButtonForRow(int rowId, boolean canSeparate);
- void setupEndButtonForRow(int rowId, boolean canDisconnect);
+ void updateSeparateButtonForRow(int rowId, boolean canSeparate);
+ void updateEndButtonForRow(int rowId, boolean canDisconnect);
}
}