Multicall OK + Fix LC iterate issue

This commit is contained in:
Sylvain Berfini 2012-09-19 11:45:08 +02:00
parent 9ee3a64dad
commit be5414481a
27 changed files with 149 additions and 41 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 596 B

After

Width:  |  Height:  |  Size: 570 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/conference_over" />
<item
android:drawable="@drawable/conference_default" />
</selector>

View file

@ -173,6 +173,16 @@
android:scaleType="fitXY" android:scaleType="fitXY"
android:src="@drawable/pause_off" /> android:src="@drawable/pause_off" />
<ImageView
android:id="@+id/conference"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:contentDescription="@string/content_description_conference"
android:scaleType="fitXY"
android:src="@drawable/conference" />
<ImageView <ImageView
android:id="@+id/video" android:id="@+id/video"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -10,6 +10,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:gravity="bottom"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView
@ -17,8 +18,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0.2" android:layout_weight="0.2"
android:adjustViewBounds="true" android:scaleType="fitEnd"
android:scaleType="fitXY"
android:src="@drawable/mark" android:src="@drawable/mark"
android:visibility="invisible" /> android:visibility="invisible" />
@ -27,8 +27,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0.2" android:layout_weight="0.2"
android:adjustViewBounds="true" android:scaleType="fitEnd"
android:scaleType="fitXY"
android:src="@drawable/mark" android:src="@drawable/mark"
android:visibility="invisible" /> android:visibility="invisible" />
@ -37,18 +36,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0.24" android:layout_weight="0.24"
android:adjustViewBounds="true"
android:scaleType="fitEnd" android:scaleType="fitEnd"
android:src="@drawable/dialer"
android:visibility="invisible" />
<ImageView
android:contentDescription="@string/content_description_mark"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/mark" android:src="@drawable/mark"
android:visibility="invisible" /> android:visibility="invisible" />
@ -57,8 +45,16 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0.2" android:layout_weight="0.2"
android:adjustViewBounds="true" android:scaleType="fitEnd"
android:scaleType="fitXY" android:src="@drawable/mark"
android:visibility="invisible" />
<ImageView
android:contentDescription="@string/content_description_mark"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:scaleType="fitEnd"
android:src="@drawable/mark" android:src="@drawable/mark"
android:visibility="invisible" /> android:visibility="invisible" />
@ -75,7 +71,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingTop="20dp"> android:paddingTop="40dp">
<LinearLayout <LinearLayout
android:id="@+id/fragmentContainer" android:id="@+id/fragmentContainer"
@ -98,6 +94,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:layout="@layout/status" /> tools:layout="@layout/status" />
</FrameLayout> </FrameLayout>
<LinearLayout <LinearLayout

View file

@ -50,6 +50,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
linphone:picture="@drawable/unknown_small" linphone:picture="@drawable/unknown_small"
android:layout_gravity="center" android:layout_gravity="center"
android:paddingBottom="10sp" /> android:paddingBottom="10dp" />
</LinearLayout> </LinearLayout>

View file

@ -180,6 +180,16 @@
android:scaleType="fitXY" android:scaleType="fitXY"
android:src="@drawable/pause_off" /> android:src="@drawable/pause_off" />
<ImageView
android:id="@+id/conference"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:contentDescription="@string/content_description_conference"
android:scaleType="fitXY"
android:src="@drawable/conference" />
<ImageView <ImageView
android:id="@+id/hangUp" android:id="@+id/hangUp"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -289,6 +289,7 @@
<string name="content_description_back"></string> <string name="content_description_back"></string>
<string name="content_description_setup_ok"></string> <string name="content_description_setup_ok"></string>
<string name="content_description_message_status"></string> <string name="content_description_message_status"></string>
<string name="content_description_conference"></string>
<string name="content_description_mark"></string> <string name="content_description_mark"></string>
<string name="setup_title">Account Setup Assistant</string> <string name="setup_title">Account Setup Assistant</string>

View file

@ -21,6 +21,7 @@ import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCall; import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCall.State; import org.linphone.core.LinphoneCall.State;
import org.linphone.core.LinphoneCoreFactory; import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.Log;
import org.linphone.ui.AvatarWithShadow; import org.linphone.ui.AvatarWithShadow;
import android.app.Activity; import android.app.Activity;
@ -31,6 +32,7 @@ import android.os.SystemClock;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Chronometer; import android.widget.Chronometer;
import android.widget.ImageView; import android.widget.ImageView;
@ -41,16 +43,20 @@ import android.widget.TextView;
/** /**
* @author Sylvain Berfini * @author Sylvain Berfini
*/ */
public class AudioCallFragment extends Fragment { public class AudioCallFragment extends Fragment implements OnClickListener {
private static final int rowHeight = 75; // Value set in active_call.xml private static final int rowHeight = 75; // Value set in active_call.xml
// private static final int rowImageHeight = 100; // Value set in active_call.xml private static final int rowImageHeight = 75; // Value set in avatar.xml
private static final int botMarginIfImage = 25;
private static final int rowThickRatio = 85; // Ratio dependent from the image private static final int rowThickRatio = 85; // Ratio dependent from the image
private static final int topMargin = (int) ((rowHeight * rowThickRatio) / 100); private static final int topMargin = (int) ((rowHeight * rowThickRatio) / 100);
// private static final int topMarginWithImage = topMargin + rowImageHeight; private static final int topMarginWithImage = topMargin + rowImageHeight + botMarginIfImage;
private RelativeLayout callsList; private RelativeLayout callsList;
private LayoutInflater inflater; private LayoutInflater inflater;
private ViewGroup container; private ViewGroup container;
private boolean previousCallIsActive = false;
private InCallActivity incallActvityInstance;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
@ -75,6 +81,7 @@ public class AudioCallFragment extends Fragment {
displayOrHideContactPicture(callView, pictureUri, hide); displayOrHideContactPicture(callView, pictureUri, hide);
setRowBackgroundAndPadding(callView, resources, index); setRowBackgroundAndPadding(callView, resources, index);
registerCallDurationTimer(callView, call); registerCallDurationTimer(callView, call);
previousCallIsActive = !hide;
} }
private void setContactName(LinearLayout callView, LinphoneAddress lAddress, String sipUri, Resources resources) { private void setContactName(LinearLayout callView, LinphoneAddress lAddress, String sipUri, Resources resources) {
@ -93,6 +100,9 @@ public class AudioCallFragment extends Fragment {
private boolean displayCallStatusIconAndReturnCallPaused(LinearLayout callView, LinphoneCall call) { private boolean displayCallStatusIconAndReturnCallPaused(LinearLayout callView, LinphoneCall call) {
boolean isCallPaused; boolean isCallPaused;
ImageView callState = (ImageView) callView.findViewById(R.id.callStatus); ImageView callState = (ImageView) callView.findViewById(R.id.callStatus);
callState.setTag(call);
callState.setOnClickListener(this);
if (call.getState() == State.Paused || call.getState() == State.PausedByRemote || call.getState() == State.Pausing) { if (call.getState() == State.Paused || call.getState() == State.PausedByRemote || call.getState() == State.Pausing) {
callState.setImageResource(R.drawable.pause_default); callState.setImageResource(R.drawable.pause_default);
isCallPaused = true; isCallPaused = true;
@ -103,6 +113,7 @@ public class AudioCallFragment extends Fragment {
callState.setImageResource(R.drawable.play_default); callState.setImageResource(R.drawable.play_default);
isCallPaused = false; isCallPaused = false;
} }
return isCallPaused; return isCallPaused;
} }
@ -121,7 +132,11 @@ public class AudioCallFragment extends Fragment {
callView.findViewById(R.id.row).setBackgroundResource(R.drawable.sel_call_first); callView.findViewById(R.id.row).setBackgroundResource(R.drawable.sel_call_first);
} else { } else {
callView.findViewById(R.id.row).setBackgroundResource(R.drawable.sel_call); callView.findViewById(R.id.row).setBackgroundResource(R.drawable.sel_call);
callView.setPadding(0, LinphoneUtils.pixelsToDpi(resources, topMargin * index), 0, 0); if (previousCallIsActive) {
callView.setPadding(0, LinphoneUtils.pixelsToDpi(resources, topMarginWithImage * index), 0, 0);
} else {
callView.setPadding(0, LinphoneUtils.pixelsToDpi(resources, topMargin * index), 0, 0);
}
} }
} }
@ -140,12 +155,27 @@ public class AudioCallFragment extends Fragment {
timer.start(); timer.start();
} }
@Override
public void onClick(View v) {
int id = v.getId();
switch (id) {
case R.id.callStatus:
LinphoneCall call = (LinphoneCall) v.getTag();
if (incallActvityInstance != null) {
Log.e("InCallActivity instanciated");
incallActvityInstance.pauseOrResumeCall(call);
}
break;
}
}
@Override @Override
public void onAttach(Activity activity) { public void onAttach(Activity activity) {
super.onAttach(activity); super.onAttach(activity);
incallActvityInstance = (InCallActivity) activity;
if (InCallActivity.isInstanciated()) { if (incallActvityInstance != null) {
InCallActivity.instance().bindAudioFragment(this); incallActvityInstance.bindAudioFragment(this);
} }
} }

View file

@ -26,6 +26,7 @@ import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCall.State; import org.linphone.core.LinphoneCall.State;
import org.linphone.core.LinphoneCallParams; import org.linphone.core.LinphoneCallParams;
import org.linphone.core.LinphoneCore; import org.linphone.core.LinphoneCore;
import org.linphone.core.Log;
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration; import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
import org.linphone.ui.Numpad; import org.linphone.ui.Numpad;
@ -63,7 +64,7 @@ public class InCallActivity extends FragmentActivity implements
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
private Handler mControlsHandler = new Handler(); private Handler mControlsHandler = new Handler();
private Runnable mControls; private Runnable mControls;
private ImageView video, micro, speaker, addCall, pause, hangUp, dialer, switchCamera, options, transfer; private ImageView video, micro, speaker, addCall, pause, hangUp, dialer, switchCamera, options, transfer, conference;
private StatusFragment status; private StatusFragment status;
private AudioCallFragment audioCallFragment; private AudioCallFragment audioCallFragment;
private VideoCallFragment videoCallFragment; private VideoCallFragment videoCallFragment;
@ -153,6 +154,8 @@ public class InCallActivity extends FragmentActivity implements
pause.setEnabled(false); pause.setEnabled(false);
hangUp = (ImageView) findViewById(R.id.hangUp); hangUp = (ImageView) findViewById(R.id.hangUp);
hangUp.setOnClickListener(this); hangUp.setOnClickListener(this);
conference = (ImageView) findViewById(R.id.conference);
conference.setOnClickListener(this);
dialer = (ImageView) findViewById(R.id.dialer); dialer = (ImageView) findViewById(R.id.dialer);
dialer.setOnClickListener(this); dialer.setOnClickListener(this);
dialer.setEnabled(false); dialer.setEnabled(false);
@ -177,19 +180,10 @@ public class InCallActivity extends FragmentActivity implements
} }
} }
private void enableAndRefreshInCallActions() { private void refreshInCallActions() {
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
options.setEnabled(true);
video.setEnabled(true);
micro.setEnabled(true);
speaker.setEnabled(true);
addCall.setEnabled(true);
transfer.setEnabled(true);
pause.setEnabled(true);
dialer.setEnabled(true);
if (!isVideoActivatedInSettings()) { if (!isVideoActivatedInSettings()) {
video.setEnabled(false); video.setEnabled(false);
} else { } else {
@ -211,6 +205,40 @@ public class InCallActivity extends FragmentActivity implements
} else { } else {
micro.setImageResource(R.drawable.micro_on); micro.setImageResource(R.drawable.micro_on);
} }
if (LinphoneManager.getLc().getCallsNb() > 1) {
conference.setVisibility(View.VISIBLE);
pause.setVisibility(View.GONE);
} else {
conference.setVisibility(View.GONE);
pause.setVisibility(View.VISIBLE);
List<LinphoneCall> pausedCalls = LinphoneUtils.getCallsInState(LinphoneManager.getLc(), Arrays.asList(State.Paused));
if (pausedCalls.size() == 1) {
pause.setImageResource(R.drawable.pause_on);
} else {
pause.setImageResource(R.drawable.pause_off);
}
}
}
});
}
private void enableAndRefreshInCallActions() {
mHandler.post(new Runnable() {
@Override
public void run() {
options.setEnabled(true);
video.setEnabled(true);
micro.setEnabled(true);
speaker.setEnabled(true);
addCall.setEnabled(true);
transfer.setEnabled(true);
pause.setEnabled(true);
dialer.setEnabled(true);
conference.setEnabled(true);
refreshInCallActions();
} }
}); });
} }
@ -247,7 +275,7 @@ public class InCallActivity extends FragmentActivity implements
goBackToDialer(); goBackToDialer();
} }
else if (id == R.id.pause) { else if (id == R.id.pause) {
pause(); pauseOrResumeCall();
} }
else if (id == R.id.hangUp) { else if (id == R.id.hangUp) {
hangUp(); hangUp();
@ -255,6 +283,9 @@ public class InCallActivity extends FragmentActivity implements
else if (id == R.id.dialer) { else if (id == R.id.dialer) {
hideOrDisplayNumpad(); hideOrDisplayNumpad();
} }
else if (id == R.id.conference) {
enterConference();
}
else if (id == R.id.switchCamera) { else if (id == R.id.switchCamera) {
if (videoCallFragment != null) { if (videoCallFragment != null) {
videoCallFragment.switchCamera(); videoCallFragment.switchCamera();
@ -351,18 +382,29 @@ public class InCallActivity extends FragmentActivity implements
LinphoneManager.getLc().enableSpeaker(isSpeakerEnabled); LinphoneManager.getLc().enableSpeaker(isSpeakerEnabled);
} }
private void pause() { private void pauseOrResumeCall() {
LinphoneCore lc = LinphoneManager.getLc(); LinphoneCore lc = LinphoneManager.getLc();
LinphoneCall call = lc.getCurrentCall(); LinphoneCall call = lc.getCurrentCall();
pauseOrResumeCall(call);
}
public void pauseOrResumeCall(LinphoneCall call) {
Log.e("Call = " + call);
LinphoneCore lc = LinphoneManager.getLc();
if (call != null && LinphoneUtils.isCallRunning(call)) { if (call != null && LinphoneUtils.isCallRunning(call)) {
Log.e("Pausing call " + call);
lc.pauseCall(call); lc.pauseCall(call);
pause.setImageResource(R.drawable.pause_on); pause.setImageResource(R.drawable.pause_on);
} else { } else {
List<LinphoneCall> pausedCalls = LinphoneUtils.getCallsInState(lc, Arrays.asList(State.Paused)); List<LinphoneCall> pausedCalls = LinphoneUtils.getCallsInState(lc, Arrays.asList(State.Paused));
if (pausedCalls.size() == 1) { if (pausedCalls.size() == 1) {
LinphoneCall callToResume = pausedCalls.get(0); LinphoneCall callToResume = pausedCalls.get(0);
lc.resumeCall(callToResume); Log.e("CallToResume " + callToResume);
pause.setImageResource(R.drawable.pause_off); if ((call != null && callToResume.equals(call)) || call == null) {
Log.e("Resuming call " + callToResume);
lc.resumeCall(callToResume);
pause.setImageResource(R.drawable.pause_off);
}
} }
} }
} }
@ -380,6 +422,10 @@ public class InCallActivity extends FragmentActivity implements
} }
} }
private void enterConference() {
//TODO
}
public void displayVideoCallControlsIfHidden() { public void displayVideoCallControlsIfHidden() {
if (mControlsLayout != null) { if (mControlsLayout != null) {
if (mControlsLayout.getVisibility() != View.VISIBLE) { if (mControlsLayout.getVisibility() != View.VISIBLE) {
@ -661,6 +707,7 @@ public class InCallActivity extends FragmentActivity implements
}); });
} }
} }
refreshInCallActions();
if (audioCallFragment != null) { if (audioCallFragment != null) {
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
@ -688,6 +735,7 @@ public class InCallActivity extends FragmentActivity implements
@Override @Override
protected void onResume() { protected void onResume() {
instance = this;
LinphoneManager.addListener(this); LinphoneManager.addListener(this);
LinphoneManager.startProximitySensorForActivity(this); LinphoneManager.startProximitySensorForActivity(this);

View file

@ -795,7 +795,11 @@ public final class LinphoneManager implements LinphoneCoreListener {
mTimer.cancel(); mTimer.cancel();
mLc.destroy(); mLc.destroy();
mServiceContext.unregisterReceiver(instance.mKeepAliveReceiver); mServiceContext.unregisterReceiver(instance.mKeepAliveReceiver);
} finally { }
catch (RuntimeException e) {
e.printStackTrace();
}
finally {
mLc = null; mLc = null;
instance = null; instance = null;
} }