Move some callbacks + auto start video on share.
This commit is contained in:
parent
6b52e92224
commit
23ddab7710
8 changed files with 88 additions and 53 deletions
|
@ -179,6 +179,11 @@ public class ConferenceActivity extends ListActivity implements
|
||||||
if (multipleCallsLimit > 0) {
|
if (multipleCallsLimit > 0) {
|
||||||
updateAddCallButton();
|
updateAddCallButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LinphoneCall currentCall = LinphoneManager.getLc().getCurrentCall();
|
||||||
|
if (currentCall != null) {
|
||||||
|
tryToStartVideoActivity(currentCall, currentCall.getState());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAddCallButton() {
|
private void updateAddCallButton() {
|
||||||
|
@ -193,9 +198,9 @@ public class ConferenceActivity extends ListActivity implements
|
||||||
|
|
||||||
protected void registerLinphoneListener(boolean register) {
|
protected void registerLinphoneListener(boolean register) {
|
||||||
if (register)
|
if (register)
|
||||||
LinphoneManager.getInstance().addListener(this);
|
LinphoneManager.addListener(this);
|
||||||
else
|
else
|
||||||
LinphoneManager.getInstance().removeListener(this);
|
LinphoneManager.removeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -670,10 +675,23 @@ public class ConferenceActivity extends ListActivity implements
|
||||||
controlLayout.setVisibility(hide ? GONE : VISIBLE);
|
controlLayout.setVisibility(hide ? GONE : VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void tryToStartVideoActivity(LinphoneCall call, State state) {
|
||||||
|
if (State.StreamsRunning == state && call.getCurrentParamsCopy().getVideoEnabled()) {
|
||||||
|
if (call.cameraEnabled() ) {
|
||||||
|
LinphoneActivity.instance().startVideoActivity();
|
||||||
|
} else {
|
||||||
|
Log.i("Not starting video call activity as the camera is disabled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void onCallStateChanged(final LinphoneCall call, final State state,
|
public void onCallStateChanged(final LinphoneCall call, final State state,
|
||||||
final String message) {
|
final String message) {
|
||||||
final String stateStr = call + " " + state.toString();
|
final String stateStr = call + " " + state.toString();
|
||||||
Log.d("ConferenceActivity received state ",stateStr);
|
Log.d("ConferenceActivity received state ",stateStr);
|
||||||
|
|
||||||
|
tryToStartVideoActivity(call, state);
|
||||||
|
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
CalleeListAdapter adapter = (CalleeListAdapter) getListAdapter();
|
CalleeListAdapter adapter = (CalleeListAdapter) getListAdapter();
|
||||||
|
|
|
@ -87,8 +87,6 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Lin
|
||||||
private static final String CURRENT_ADDRESS = "org.linphone.current-address";
|
private static final String CURRENT_ADDRESS = "org.linphone.current-address";
|
||||||
private static final String CURRENT_DISPLAYNAME = "org.linphone.current-displayname";
|
private static final String CURRENT_DISPLAYNAME = "org.linphone.current-displayname";
|
||||||
|
|
||||||
private static final int INCOMING_CALL_ACTIVITY = 10;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return null if not ready yet
|
* @return null if not ready yet
|
||||||
*/
|
*/
|
||||||
|
@ -159,13 +157,11 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Lin
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateWhenManagerReady() {
|
public void onCreateWhenManagerReady() {
|
||||||
LinphoneCore lc = LinphoneManager.getLc();
|
LinphoneCall pendingCall = LinphoneManager.getInstance().getPendingIncomingCall();
|
||||||
if (lc.isIncall()) {
|
if (pendingCall != null) {
|
||||||
if(lc.isInComingInvitePending()) {
|
LinphoneActivity.instance().startIncomingCallActivity(pendingCall);
|
||||||
callPending(lc.getCurrentCall());
|
} else if (LinphoneManager.getLc().isIncall()) {
|
||||||
} else {
|
enterIncallMode();
|
||||||
enterIncallMode(lc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,8 +222,9 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Lin
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void enterIncallMode(LinphoneCore lc) {
|
private void enterIncallMode() {
|
||||||
LinphoneAddress address = LinphoneManager.getLc().getRemoteAddress();
|
LinphoneCore lc = LinphoneManager.getLc();
|
||||||
|
LinphoneAddress address = lc.getRemoteAddress();
|
||||||
mDisplayNameView.setText(LinphoneManager.extractADisplayName(getResources(), address));
|
mDisplayNameView.setText(LinphoneManager.extractADisplayName(getResources(), address));
|
||||||
|
|
||||||
// setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
|
// setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
|
||||||
|
@ -280,8 +277,6 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Lin
|
||||||
|
|
||||||
|
|
||||||
private void exitCallMode() {
|
private void exitCallMode() {
|
||||||
finishActivity(INCOMING_CALL_ACTIVITY);
|
|
||||||
|
|
||||||
if (useIncallActivity) {
|
if (useIncallActivity) {
|
||||||
LinphoneActivity.instance().closeIncallActivity();
|
LinphoneActivity.instance().closeIncallActivity();
|
||||||
} else if(useConferenceActivity) {
|
} else if(useConferenceActivity) {
|
||||||
|
@ -306,14 +301,6 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Lin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void callPending(final LinphoneCall call) {
|
|
||||||
Intent intent = new Intent()
|
|
||||||
.setClass(this, IncomingCallActivity.class)
|
|
||||||
.putExtra("stringUri", call.getRemoteAddress().asStringUriOnly());
|
|
||||||
startActivityForResult(intent, INCOMING_CALL_ACTIVITY);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Dialog onCreateDialog(int id) {
|
protected Dialog onCreateDialog(int id) {
|
||||||
if (id == LinphoneManagerWaitHelper.DIALOG_ID) {
|
if (id == LinphoneManagerWaitHelper.DIALOG_ID) {
|
||||||
|
@ -379,29 +366,21 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Lin
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state==LinphoneCall.State.OutgoingInit){
|
if (state==State.OutgoingInit){
|
||||||
call.enableCamera(LinphoneManager.getInstance().shareMyCamera());
|
enterIncallMode();
|
||||||
enterIncallMode(lc);
|
}else if (state==State.Connected){
|
||||||
LinphoneActivity.instance().startOrientationSensor();
|
|
||||||
}else if (state==LinphoneCall.State.IncomingReceived){
|
|
||||||
callPending(call);
|
|
||||||
call.enableCamera(LinphoneManager.getInstance().shareMyCamera());
|
|
||||||
LinphoneActivity.instance().startOrientationSensor();
|
|
||||||
}else if (state==LinphoneCall.State.Connected){
|
|
||||||
if (call.getDirection() == CallDirection.Incoming) {
|
if (call.getDirection() == CallDirection.Incoming) {
|
||||||
enterIncallMode(lc);
|
enterIncallMode();
|
||||||
}
|
}
|
||||||
}else if (state==LinphoneCall.State.Error){
|
}else if (state==State.Error){
|
||||||
showToast(R.string.call_error, message);
|
showToast(R.string.call_error, message);
|
||||||
if (lc.getCallsNb() == 0){
|
if (lc.getCallsNb() == 0){
|
||||||
if (mWakeLock.isHeld()) mWakeLock.release();
|
if (mWakeLock.isHeld()) mWakeLock.release();
|
||||||
exitCallMode();
|
exitCallMode();
|
||||||
LinphoneActivity.instance().stopOrientationSensor();
|
|
||||||
}
|
}
|
||||||
}else if (state==LinphoneCall.State.CallEnd){
|
}else if (state==State.CallEnd){
|
||||||
if (lc.getCallsNb() == 0){
|
if (lc.getCallsNb() == 0){
|
||||||
exitCallMode();
|
exitCallMode();
|
||||||
LinphoneActivity.instance().stopOrientationSensor();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class IncomingCallActivity extends Activity implements LinphoneManagerRea
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResumeWhenManagerReady() {
|
public void onResumeWhenManagerReady() {
|
||||||
LinphoneManager.getInstance().addListener(this);
|
LinphoneManager.addListener(this);
|
||||||
findIncomingCall(getIntent());
|
findIncomingCall(getIntent());
|
||||||
if (mCall == null) {
|
if (mCall == null) {
|
||||||
finish();
|
finish();
|
||||||
|
@ -125,7 +125,7 @@ public class IncomingCallActivity extends Activity implements LinphoneManagerRea
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
LinphoneManager.getInstance().removeListener(this);
|
LinphoneManager.removeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -22,10 +22,13 @@ package org.linphone;
|
||||||
import static android.content.Intent.ACTION_MAIN;
|
import static android.content.Intent.ACTION_MAIN;
|
||||||
|
|
||||||
import org.linphone.LinphoneManager.EcCalibrationListener;
|
import org.linphone.LinphoneManager.EcCalibrationListener;
|
||||||
|
import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
|
import org.linphone.core.LinphoneCall;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCoreException;
|
import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.Log;
|
import org.linphone.core.Log;
|
||||||
|
import org.linphone.core.LinphoneCall.State;
|
||||||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||||
import org.linphone.mediastream.Version;
|
import org.linphone.mediastream.Version;
|
||||||
|
@ -50,13 +53,12 @@ import android.text.Html;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.TabWidget;
|
import android.widget.TabWidget;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import android.widget.TabHost.TabSpec;
|
import android.widget.TabHost.TabSpec;
|
||||||
|
|
||||||
public class LinphoneActivity extends TabActivity implements SensorEventListener, ContactPicked {
|
public class LinphoneActivity extends TabActivity implements SensorEventListener, ContactPicked, LinphoneOnCallStateChangedListener {
|
||||||
public static final String DIALER_TAB = "dialer";
|
public static final String DIALER_TAB = "dialer";
|
||||||
public static final String PREF_FIRST_LAUNCH = "pref_first_launch";
|
public static final String PREF_FIRST_LAUNCH = "pref_first_launch";
|
||||||
private static final int video_activity = 100;
|
private static final int video_activity = 100;
|
||||||
|
@ -69,12 +71,10 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
|
||||||
private static LinphoneActivity instance;
|
private static LinphoneActivity instance;
|
||||||
|
|
||||||
|
|
||||||
private FrameLayout mMainFrame;
|
|
||||||
private SensorManager mSensorManager;
|
private SensorManager mSensorManager;
|
||||||
private Sensor mAccelerometer;
|
private Sensor mAccelerometer;
|
||||||
private int previousRotation = -1;
|
private int previousRotation = -1;
|
||||||
|
|
||||||
private static final String SCREEN_IS_HIDDEN = "screen_is_hidden";
|
|
||||||
private Handler mHandler = new Handler();
|
private Handler mHandler = new Handler();
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,7 +110,6 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
|
||||||
startService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class));
|
startService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class));
|
||||||
|
|
||||||
|
|
||||||
mMainFrame = (FrameLayout) findViewById(R.id.main_frame);
|
|
||||||
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
|
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
|
||||||
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
||||||
|
@ -131,6 +130,7 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LinphoneManager.addListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -254,11 +254,11 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
if (isFinishing()) {
|
if (isFinishing()) {
|
||||||
//restore audio settings
|
//restore audio settings
|
||||||
boolean isUserRequest = false;
|
boolean isUserRequest = false;
|
||||||
LinphoneManager.getInstance().routeAudioToReceiver(isUserRequest);
|
LinphoneManager.getInstance().routeAudioToReceiver(isUserRequest);
|
||||||
|
LinphoneManager.removeListener(this);
|
||||||
LinphoneManager.stopProximitySensorForActivity(this);
|
LinphoneManager.stopProximitySensorForActivity(this);
|
||||||
instance = null;
|
instance = null;
|
||||||
}
|
}
|
||||||
|
@ -489,6 +489,13 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void startIncomingCallActivity(LinphoneCall pendingCall) {
|
||||||
|
Intent intent = new Intent()
|
||||||
|
.setClass(this, IncomingCallActivity.class)
|
||||||
|
.putExtra("stringUri", pendingCall.getRemoteAddress().asStringUriOnly());
|
||||||
|
startActivityForResult(intent, INCOMING_CALL_ACTIVITY);
|
||||||
|
}
|
||||||
|
|
||||||
public void finishVideoActivity() {
|
public void finishVideoActivity() {
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -496,6 +503,21 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCallStateChanged(LinphoneCall call, State state,
|
||||||
|
String message) {
|
||||||
|
if (state==State.IncomingReceived) {
|
||||||
|
startIncomingCallActivity(call);
|
||||||
|
}
|
||||||
|
if (state==State.OutgoingInit || state==State.IncomingReceived) {
|
||||||
|
startOrientationSensor();
|
||||||
|
} else if (state==State.Error || state==State.CallEnd){
|
||||||
|
stopOrientationSensor();
|
||||||
|
finishActivity(INCOMING_CALL_ACTIVITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ import java.util.TimerTask;
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnAudioChangedListener;
|
import org.linphone.LinphoneSimpleListener.LinphoneOnAudioChangedListener;
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneServiceListener;
|
import org.linphone.LinphoneSimpleListener.LinphoneServiceListener;
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnAudioChangedListener.AudioState;
|
import org.linphone.LinphoneSimpleListener.LinphoneOnAudioChangedListener.AudioState;
|
||||||
|
import org.linphone.core.CallDirection;
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
import org.linphone.core.LinphoneAuthInfo;
|
import org.linphone.core.LinphoneAuthInfo;
|
||||||
import org.linphone.core.LinphoneCall;
|
import org.linphone.core.LinphoneCall;
|
||||||
|
@ -133,13 +134,13 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
|
|
||||||
private WakeLock mIncallWakeLock;
|
private WakeLock mIncallWakeLock;
|
||||||
|
|
||||||
private List<LinphoneSimpleListener> simpleListeners = new ArrayList<LinphoneSimpleListener>();
|
private static List<LinphoneSimpleListener> simpleListeners = new ArrayList<LinphoneSimpleListener>();
|
||||||
public void addListener(LinphoneSimpleListener listener) {
|
public static void addListener(LinphoneSimpleListener listener) {
|
||||||
if (!simpleListeners.contains(listener)) {
|
if (!simpleListeners.contains(listener)) {
|
||||||
simpleListeners.add(listener);
|
simpleListeners.add(listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void removeListener(LinphoneSimpleListener listener) {
|
public static void removeListener(LinphoneSimpleListener listener) {
|
||||||
simpleListeners.remove(listener);
|
simpleListeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1139,6 +1140,10 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
|
|
||||||
public void onCallStateChanged(LinphoneCall call, State state,
|
public void onCallStateChanged(LinphoneCall call, State state,
|
||||||
String message) {
|
String message) {
|
||||||
|
if (state==State.OutgoingInit || state==State.IncomingReceived) {
|
||||||
|
boolean sendCamera = shareMyCamera() && mLc.getConferenceSize() == 0;
|
||||||
|
call.enableCamera(sendCamera);
|
||||||
|
}
|
||||||
if (state == State.CallEnd && call == requestedVideoCall) {
|
if (state == State.CallEnd && call == requestedVideoCall) {
|
||||||
requestedVideoCall = null; // drop reference
|
requestedVideoCall = null; // drop reference
|
||||||
}
|
}
|
||||||
|
@ -1191,4 +1196,15 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
return instance != null;
|
return instance != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized LinphoneCall getPendingIncomingCall() {
|
||||||
|
LinphoneCall currentCall = mLc.getCurrentCall();
|
||||||
|
if (currentCall == null) return null;
|
||||||
|
|
||||||
|
LinphoneCall.State state = currentCall.getState();
|
||||||
|
boolean incomingPending = currentCall.getDirection() == CallDirection.Incoming
|
||||||
|
&& (state == State.IncomingReceived || state == State.CallIncomingEarlyMedia);
|
||||||
|
|
||||||
|
return incomingPending ? currentCall : null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,7 @@ public class VideoCallActivity extends Activity implements LinphoneOnCallStateCh
|
||||||
if (mVideoViewReady != null)
|
if (mVideoViewReady != null)
|
||||||
((GLSurfaceView)mVideoViewReady).onResume();
|
((GLSurfaceView)mVideoViewReady).onResume();
|
||||||
launched=true;
|
launched=true;
|
||||||
LinphoneManager.getInstance().addListener(this);
|
LinphoneManager.addListener(this);
|
||||||
refreshHandler.postDelayed(mCallQualityUpdater=new Runnable(){
|
refreshHandler.postDelayed(mCallQualityUpdater=new Runnable(){
|
||||||
LinphoneCall mCurrentCall=LinphoneManager.getLc().getCurrentCall();
|
LinphoneCall mCurrentCall=LinphoneManager.getLc().getCurrentCall();
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -282,7 +282,7 @@ public class VideoCallActivity extends Activity implements LinphoneOnCallStateCh
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
Log.d("onPause VideoCallActivity (isFinishing:", isFinishing(), ", inCall:", LinphoneManager.getLc().isIncall(), ", changingConf:", getChangingConfigurations());
|
Log.d("onPause VideoCallActivity (isFinishing:", isFinishing(), ", inCall:", LinphoneManager.getLc().isIncall(), ", changingConf:", getChangingConfigurations());
|
||||||
LinphoneManager.getInstance().removeListener(this);
|
LinphoneManager.removeListener(this);
|
||||||
if (isFinishing()) {
|
if (isFinishing()) {
|
||||||
videoCall = null; // release reference
|
videoCall = null; // release reference
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 324551708e89dde781dc93a1eeae05532c8717f8
|
Subproject commit 973953df07d1c435bd738024400e0ab4603a4fba
|
Loading…
Reference in a new issue