Conference OK

This commit is contained in:
Sylvain Berfini 2012-09-19 16:43:16 +02:00
parent a72411f3c8
commit 5c20b51d19
40 changed files with 127 additions and 26 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

View file

@ -2,6 +2,8 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/dialer_alt_over" />
<item android:state_enabled="false"
android:drawable="@drawable/dialer_alt_disabled" />
<item
android:drawable="@drawable/dialer_alt_default" />
</selector>

View file

@ -2,6 +2,8 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/pause_off_over" />
<item android:state_enabled="false"
android:drawable="@drawable/pause_off_disabled" />
<item
android:drawable="@drawable/pause_off_default" />
</selector>

View file

@ -24,6 +24,7 @@
android:textSize="22dp" />
<ImageView
android:contentDescription="@string/content_description_pause"
android:id="@+id/callStatus"
android:layout_width="30dp"
android:layout_height="30dp"

View file

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:linphone="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="75dp"
android:orientation="horizontal"
android:gravity="center_vertical"
android:background="@drawable/cell_call_first">
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical|left"
android:paddingLeft="20dp"
android:paddingRight="10dp"
android:textStyle="bold"
android:textColor="@color/text_header"
android:text="@string/conference"
android:textSize="26dp" />
<ImageView
android:contentDescription="@string/content_description_pause"
android:id="@+id/conferenceStatus"
android:layout_width="30dp"
android:layout_height="30dp"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:src="@drawable/pause_default" />
<Chronometer
android:visibility="invisible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="20dp"
android:gravity="center_vertical|right"
android:textColor="@android:color/white"
android:textSize="22dp" />
</LinearLayout>

View file

@ -200,6 +200,7 @@
<string name="status_error">Enregistrement échoué</string>
<string name="addressHint">Numéro ou adresse</string>
<string name="conference">Conférence</string>
<!-- Used by Android to help blind people by describing them images -->
<string name="content_description_add_contact"></string>

View file

@ -5,6 +5,7 @@
<color name="text_selected">#ffcf4c29</color>
<color name="text_over">#ffb9c4cb</color>
<color name="text_default">#ff5b656f</color>
<color name="text_header">#ff7e8e9e</color>
<color name="numpad_background_bottom">#ffe4edf2</color>
<color name="numpad_background_dialer">#ffd8d8d8</color>

View file

@ -250,6 +250,7 @@
<string name="status_error">Registration failed</string>
<string name="addressHint">Number or address</string>
<string name="conference">Conference</string>
<!-- Used by Android to help blind people by describing them images -->
<string name="content_description_add_contact">Add to contacts button</string>

View file

@ -21,7 +21,6 @@ import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCall.State;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.Log;
import org.linphone.ui.AvatarWithShadow;
import android.app.Activity;
@ -49,12 +48,14 @@ public class AudioCallFragment extends Fragment implements OnClickListener {
private static final int botMarginIfImage = 25;
private static final int rowThickRatio = 85; // Ratio dependent from the image
private static final int topMargin = (int) ((rowHeight * rowThickRatio) / 100);
private static final int conferenceMargin = 20;
private static final int topMarginWithImage = topMargin + rowImageHeight + botMarginIfImage;
private RelativeLayout callsList;
private LayoutInflater inflater;
private ViewGroup container;
private boolean previousCallIsActive = false;
private boolean isConferenceRunning = false;
private InCallActivity incallActvityInstance;
@ -71,6 +72,20 @@ public class AudioCallFragment extends Fragment implements OnClickListener {
return view;
}
private void displayConferenceHeader() {
LinearLayout conferenceHeader = (LinearLayout) inflater.inflate(R.layout.conference_header, container, false);
ImageView conferenceState = (ImageView) conferenceHeader.findViewById(R.id.conferenceStatus);
conferenceState.setOnClickListener(this);
if (LinphoneManager.getLc().isInConference()) {
conferenceState.setImageResource(R.drawable.play_default);
} else {
conferenceState.setImageResource(R.drawable.pause_default);
}
callsList.addView(conferenceHeader);
}
private void displayCall(Resources resources, LinearLayout callView, LinphoneCall call, int index) {
String sipUri = call.getRemoteAddress().asStringUriOnly();
LinphoneAddress lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
@ -79,9 +94,11 @@ public class AudioCallFragment extends Fragment implements OnClickListener {
setContactName(callView, lAddress, sipUri, resources);
boolean hide = displayCallStatusIconAndReturnCallPaused(callView, call);
displayOrHideContactPicture(callView, pictureUri, hide);
setRowBackgroundAndPadding(callView, resources, index, !hide);
setRowBackgroundAndPadding(callView, resources, index, call, !hide);
registerCallDurationTimer(callView, call);
previousCallIsActive = !hide;
callsList.addView(callView);
}
private void setContactName(LinearLayout callView, LinphoneAddress lAddress, String sipUri, Resources resources) {
@ -98,7 +115,7 @@ public class AudioCallFragment extends Fragment implements OnClickListener {
}
private boolean displayCallStatusIconAndReturnCallPaused(LinearLayout callView, LinphoneCall call) {
boolean isCallPaused;
boolean isCallPaused, isInConference;
ImageView callState = (ImageView) callView.findViewById(R.id.callStatus);
callState.setTag(call);
callState.setOnClickListener(this);
@ -106,15 +123,23 @@ public class AudioCallFragment extends Fragment implements OnClickListener {
if (call.getState() == State.Paused || call.getState() == State.PausedByRemote || call.getState() == State.Pausing) {
callState.setImageResource(R.drawable.pause_default);
isCallPaused = true;
isInConference = false;
} else if (call.getState() == State.OutgoingInit || call.getState() == State.OutgoingProgress || call.getState() == State.OutgoingRinging) {
callState.setImageResource(R.drawable.call_state_ringing_default);
isCallPaused = false;
isInConference = false;
} else {
if (isConferenceRunning && call.isInConference()) {
callState.setImageResource(R.drawable.call_state_delete_default);
isInConference = true;
} else {
callState.setImageResource(R.drawable.play_default);
isInConference = false;
}
isCallPaused = false;
}
return isCallPaused;
return isCallPaused || isInConference;
}
private void displayOrHideContactPicture(LinearLayout callView, Uri pictureUri, boolean hide) {
@ -127,7 +152,7 @@ public class AudioCallFragment extends Fragment implements OnClickListener {
}
}
private void setRowBackgroundAndPadding(LinearLayout callView, Resources resources, int index, boolean active) {
private void setRowBackgroundAndPadding(LinearLayout callView, Resources resources, int index, LinphoneCall call, boolean active) {
int backgroundResource;
if (index == 0) {
// backgroundResource = active ? R.drawable.cell_call_first_highlight : R.drawable.cell_call_first;
@ -139,10 +164,16 @@ public class AudioCallFragment extends Fragment implements OnClickListener {
callView.findViewById(R.id.row).setBackgroundResource(backgroundResource);
if (index != 0) {
int marginIfConferenceAndCallNotInside = 0;
if (isConferenceRunning) {
if (!call.isInConference()) {
marginIfConferenceAndCallNotInside = conferenceMargin;
}
}
if (previousCallIsActive) {
callView.setPadding(0, LinphoneUtils.pixelsToDpi(resources, topMarginWithImage * index), 0, 0);
callView.setPadding(0, LinphoneUtils.pixelsToDpi(resources, (topMarginWithImage * index) + marginIfConferenceAndCallNotInside), 0, 0);
} else {
callView.setPadding(0, LinphoneUtils.pixelsToDpi(resources, topMargin * index), 0, 0);
callView.setPadding(0, LinphoneUtils.pixelsToDpi(resources, (topMargin * index) + marginIfConferenceAndCallNotInside), 0, 0);
}
}
}
@ -169,8 +200,12 @@ public class AudioCallFragment extends Fragment implements OnClickListener {
case R.id.callStatus:
LinphoneCall call = (LinphoneCall) v.getTag();
if (incallActvityInstance != null) {
Log.e("InCallActivity instanciated");
incallActvityInstance.pauseOrResumeCall(call);
incallActvityInstance.pauseOrResumeCall(call, true);
}
break;
case R.id.conferenceStatus:
if (incallActvityInstance != null) {
incallActvityInstance.pauseOrResumeConference();
}
break;
}
@ -191,8 +226,8 @@ public class AudioCallFragment extends Fragment implements OnClickListener {
super.onStart();
// Just to be sure we have incall controls
if (InCallActivity.isInstanciated()) {
InCallActivity.instance().setCallControlsVisibleAndRemoveCallbacks();
if (incallActvityInstance != null) {
incallActvityInstance.setCallControlsVisibleAndRemoveCallbacks();
}
}
@ -213,14 +248,18 @@ public class AudioCallFragment extends Fragment implements OnClickListener {
int index = 0;
if (LinphoneManager.getLc().getCallsNb() == 0) {
InCallActivity.instance().goBackToDialer();
incallActvityInstance.goBackToDialer();
return;
}
isConferenceRunning = LinphoneManager.getLc().getConferenceSize() > 1;
if (isConferenceRunning) {
displayConferenceHeader();
index++;
}
for (LinphoneCall call : LinphoneManager.getLc().getCalls()) {
LinearLayout callView = (LinearLayout) inflater.inflate(R.layout.active_call, container, false);
displayCall(resources, callView, call, index);
callsList.addView(callView);
index++;
}

View file

@ -26,7 +26,6 @@ import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCall.State;
import org.linphone.core.LinphoneCallParams;
import org.linphone.core.LinphoneCore;
import org.linphone.core.Log;
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
import org.linphone.ui.Numpad;
@ -385,23 +384,26 @@ public class InCallActivity extends FragmentActivity implements
private void pauseOrResumeCall() {
LinphoneCore lc = LinphoneManager.getLc();
LinphoneCall call = lc.getCurrentCall();
pauseOrResumeCall(call);
pauseOrResumeCall(call, false);
}
public void pauseOrResumeCall(LinphoneCall call) {
Log.e("Call = " + call);
public void pauseOrResumeCall(LinphoneCall call, boolean leaveConference) {
LinphoneCore lc = LinphoneManager.getLc();
if (call != null && LinphoneUtils.isCallRunning(call)) {
Log.e("Pausing call " + call);
if (call.isInConference()) {
lc.removeFromConference(call);
if (lc.getConferenceSize() <= 1) {
lc.leaveConference();
}
} else {
lc.pauseCall(call);
pause.setImageResource(R.drawable.pause_on);
}
} else {
List<LinphoneCall> pausedCalls = LinphoneUtils.getCallsInState(lc, Arrays.asList(State.Paused));
if (pausedCalls.size() == 1) {
LinphoneCall callToResume = pausedCalls.get(0);
Log.e("CallToResume " + callToResume);
if ((call != null && callToResume.equals(call)) || call == null) {
Log.e("Resuming call " + callToResume);
lc.resumeCall(callToResume);
pause.setImageResource(R.drawable.pause_off);
}
@ -423,7 +425,16 @@ public class InCallActivity extends FragmentActivity implements
}
private void enterConference() {
//TODO
LinphoneManager.getLc().addAllToConference();
}
public void pauseOrResumeConference() {
LinphoneCore lc = LinphoneManager.getLc();
if (lc.isInConference()) {
lc.leaveConference();
} else {
lc.enterConference();
}
}
public void displayVideoCallControlsIfHidden() {

View file

@ -277,9 +277,11 @@ public class StatusFragment extends Fragment {
super.onResume();
LinphoneCall call = LinphoneManager.getLc().getCurrentCall();
if (isInCall && call != null) {
if (isInCall && (call != null || LinphoneManager.getLc().getConferenceSize() > 1)) {
startCallQuality();
if (call != null) {
refreshStatusItems(call, call.getCurrentParamsCopy().getVideoEnabled());
}
// We are obviously connected
statusLed.setImageResource(R.drawable.led_connected);