Rework linphoneListener
This commit is contained in:
parent
8102d6a5f3
commit
90ea41dd24
13 changed files with 471 additions and 421 deletions
|
@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCore.LogCollectionUploadState;
|
import org.linphone.core.LinphoneCore.LogCollectionUploadState;
|
||||||
import org.linphone.core.LinphoneCoreListener;
|
import org.linphone.core.LinphoneCoreListener;
|
||||||
|
import org.linphone.core.LinphoneCoreListenerBase;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -36,10 +37,11 @@ import android.widget.TextView;
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class AboutFragment extends Fragment implements OnClickListener, LinphoneCoreListener.LinphoneLogCollectionUploadListener {
|
public class AboutFragment extends Fragment implements OnClickListener {
|
||||||
private FragmentsAvailable about = FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT;
|
private FragmentsAvailable about = FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT;
|
||||||
View exitButton = null;
|
View exitButton = null;
|
||||||
View sendLogButton = null;
|
View sendLogButton = null;
|
||||||
|
LinphoneCoreListener mListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
@ -66,7 +68,34 @@ public class AboutFragment extends Fragment implements OnClickListener, Linphone
|
||||||
|
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.addListener(this);
|
mListener = new LinphoneCoreListenerBase(){
|
||||||
|
@Override
|
||||||
|
public void uploadProgressIndication(LinphoneCore lc, int offset, int total) {
|
||||||
|
Log.d("Log upload progress: currently uploaded = " + offset + " , total = " + total + ", % = " + String.valueOf((offset * 100) / total));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uploadStateChanged(LinphoneCore lc, LogCollectionUploadState state, String info) {
|
||||||
|
Log.d("Log upload state: " + state.toString() + ", info = " + info);
|
||||||
|
|
||||||
|
if (state == LogCollectionUploadState.LogCollectionUploadStateDelivered) {
|
||||||
|
final String appName = getString(R.string.app_name);
|
||||||
|
|
||||||
|
Intent i = new Intent(Intent.ACTION_SEND);
|
||||||
|
i.putExtra(Intent.EXTRA_EMAIL, new String[]{ getString(R.string.about_bugreport_email) });
|
||||||
|
i.putExtra(Intent.EXTRA_SUBJECT, appName + " Logs");
|
||||||
|
i.putExtra(Intent.EXTRA_TEXT, info);
|
||||||
|
i.setType("application/zip");
|
||||||
|
|
||||||
|
try {
|
||||||
|
startActivity(Intent.createChooser(i, "Send mail..."));
|
||||||
|
} catch (android.content.ActivityNotFoundException ex) {
|
||||||
|
Log.e(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
lc.addListener(mListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
|
@ -105,35 +134,11 @@ public class AboutFragment extends Fragment implements OnClickListener, Linphone
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.removeListener(this);
|
lc.removeListener(mListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void uploadProgressIndication(LinphoneCore lc, int offset, int total) {
|
|
||||||
Log.d("Log upload progress: currently uploaded = " + offset + " , total = " + total + ", % = " + String.valueOf((offset * 100) / total));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void uploadStateChanged(LinphoneCore lc, LogCollectionUploadState state, String info) {
|
|
||||||
Log.d("Log upload state: " + state.toString() + ", info = " + info);
|
|
||||||
|
|
||||||
if (state == LogCollectionUploadState.LogCollectionUploadStateDelivered) {
|
|
||||||
final String appName = getString(R.string.app_name);
|
|
||||||
|
|
||||||
Intent i = new Intent(Intent.ACTION_SEND);
|
|
||||||
i.putExtra(Intent.EXTRA_EMAIL, new String[]{ getString(R.string.about_bugreport_email) });
|
|
||||||
i.putExtra(Intent.EXTRA_SUBJECT, appName + " Logs");
|
|
||||||
i.putExtra(Intent.EXTRA_TEXT, info);
|
|
||||||
i.setType("application/zip");
|
|
||||||
|
|
||||||
try {
|
|
||||||
startActivity(Intent.createChooser(i, "Send mail..."));
|
|
||||||
} catch (android.content.ActivityNotFoundException ex) {
|
|
||||||
Log.e(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,6 @@ import android.preference.Preference.OnPreferenceClickListener;
|
||||||
import android.preference.PreferenceCategory;
|
import android.preference.PreferenceCategory;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.text.method.PasswordTransformationMethod;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
|
|
|
@ -63,6 +63,7 @@ import org.linphone.core.LinphoneAddress;
|
||||||
import org.linphone.core.LinphoneChatMessage;
|
import org.linphone.core.LinphoneChatMessage;
|
||||||
import org.linphone.core.LinphoneChatRoom;
|
import org.linphone.core.LinphoneChatRoom;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
|
import org.linphone.core.LinphoneCoreListenerBase;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
import org.linphone.ui.AvatarWithShadow;
|
import org.linphone.ui.AvatarWithShadow;
|
||||||
import org.linphone.ui.BubbleChat;
|
import org.linphone.ui.BubbleChat;
|
||||||
|
@ -83,13 +84,11 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.linphone.core.LinphoneChatMessage.StateListener;
|
import org.linphone.core.LinphoneChatMessage.StateListener;
|
||||||
import org.linphone.core.LinphoneCoreListener.LinphoneComposingListener;
|
|
||||||
import org.linphone.core.LinphoneCoreListener.LinphoneMessageListener;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Margaux Clerc
|
* @author Margaux Clerc
|
||||||
*/
|
*/
|
||||||
public class ChatActivity extends FragmentActivity implements OnClickListener, LinphoneMessageListener, StateListener, LinphoneComposingListener {
|
public class ChatActivity extends FragmentActivity implements OnClickListener, StateListener {
|
||||||
private static ChatActivity instance;
|
private static ChatActivity instance;
|
||||||
|
|
||||||
private static final int ADD_PHOTO = 1337;
|
private static final int ADD_PHOTO = 1337;
|
||||||
|
@ -131,6 +130,7 @@ public class ChatActivity extends FragmentActivity implements OnClickListener, L
|
||||||
private TextWatcher textWatcher;
|
private TextWatcher textWatcher;
|
||||||
private ViewTreeObserver.OnGlobalLayoutListener keyboardListener;
|
private ViewTreeObserver.OnGlobalLayoutListener keyboardListener;
|
||||||
private ChatMessageAdapter adapter;
|
private ChatMessageAdapter adapter;
|
||||||
|
private LinphoneCoreListenerBase mListener;
|
||||||
|
|
||||||
public static boolean isInstanciated() {
|
public static boolean isInstanciated() {
|
||||||
return instance != null;
|
return instance != null;
|
||||||
|
@ -216,6 +216,30 @@ public class ChatActivity extends FragmentActivity implements OnClickListener, L
|
||||||
chatRoom.markAsRead();
|
chatRoom.markAsRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mListener = new LinphoneCoreListenerBase(){
|
||||||
|
@Override
|
||||||
|
public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) {
|
||||||
|
LinphoneAddress from = cr.getPeerAddress();
|
||||||
|
if (from.asStringUriOnly().equals(sipUri)) {
|
||||||
|
if (message.getText() != null) {
|
||||||
|
adapter.refreshHistory();
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
} else if (message.getExternalBodyUrl() != null) {
|
||||||
|
adapter.refreshHistory();
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
scrollToEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void isComposingReceived(LinphoneCore lc, LinphoneChatRoom room) {
|
||||||
|
if (chatRoom != null && room != null && chatRoom.getPeerAddress().asStringUriOnly().equals(room.getPeerAddress().asStringUriOnly())) {
|
||||||
|
remoteComposing.setVisibility(chatRoom.isRemoteComposing() ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
textWatcher = new TextWatcher() {
|
textWatcher = new TextWatcher() {
|
||||||
public void afterTextChanged(Editable arg0) {}
|
public void afterTextChanged(Editable arg0) {}
|
||||||
|
|
||||||
|
@ -531,7 +555,7 @@ public class ChatActivity extends FragmentActivity implements OnClickListener, L
|
||||||
|
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.removeListener(this);
|
lc.removeListener(mListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
getIntent().putExtra("MessageDraft", message.getText());
|
getIntent().putExtra("MessageDraft", message.getText());
|
||||||
|
@ -548,8 +572,11 @@ public class ChatActivity extends FragmentActivity implements OnClickListener, L
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.addListener(this);
|
lc.addListener(mListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
|
@ -681,20 +708,7 @@ public class ChatActivity extends FragmentActivity implements OnClickListener, L
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) {
|
|
||||||
LinphoneAddress from = cr.getPeerAddress();
|
|
||||||
if (from.asStringUriOnly().equals(sipUri)) {
|
|
||||||
if (message.getText() != null) {
|
|
||||||
adapter.refreshHistory();
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
} else if (message.getExternalBodyUrl() != null) {
|
|
||||||
adapter.refreshHistory();
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
scrollToEnd();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void onLinphoneChatMessageStateChanged(LinphoneChatMessage msg, LinphoneChatMessage.State state) {
|
public synchronized void onLinphoneChatMessageStateChanged(LinphoneChatMessage msg, LinphoneChatMessage.State state) {
|
||||||
|
@ -1077,12 +1091,5 @@ public class ChatActivity extends FragmentActivity implements OnClickListener, L
|
||||||
LARGE,
|
LARGE,
|
||||||
REAL;
|
REAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void isComposingReceived(LinphoneCore lc, LinphoneChatRoom room) {
|
|
||||||
if (chatRoom != null && room != null && chatRoom.getPeerAddress().asStringUriOnly().equals(room.getPeerAddress().asStringUriOnly())) {
|
|
||||||
remoteComposing.setVisibility(chatRoom.isRemoteComposing() ? View.VISIBLE : View.GONE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,7 @@ import org.linphone.core.LinphoneCallParams;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCoreException;
|
import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneCoreFactory;
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
import org.linphone.core.LinphoneCoreListener.LinphoneCallEncryptionStateListener;
|
import org.linphone.core.LinphoneCoreListenerBase;
|
||||||
import org.linphone.core.LinphoneCoreListener.LinphoneCallStateListener;
|
|
||||||
import org.linphone.core.LinphonePlayer;
|
import org.linphone.core.LinphonePlayer;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
||||||
|
@ -70,7 +69,7 @@ import android.widget.Toast;
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class InCallActivity extends FragmentActivity implements LinphoneCallStateListener, LinphoneCallEncryptionStateListener, OnClickListener {
|
public class InCallActivity extends FragmentActivity implements OnClickListener {
|
||||||
private final static int SECONDS_BEFORE_HIDING_CONTROLS = 3000;
|
private final static int SECONDS_BEFORE_HIDING_CONTROLS = 3000;
|
||||||
private final static int SECONDS_BEFORE_DENYING_CALL_UPDATE = 30000;
|
private final static int SECONDS_BEFORE_DENYING_CALL_UPDATE = 30000;
|
||||||
|
|
||||||
|
@ -99,6 +98,7 @@ public class InCallActivity extends FragmentActivity implements LinphoneCallStat
|
||||||
private ViewGroup container;
|
private ViewGroup container;
|
||||||
private boolean isConferenceRunning = false;
|
private boolean isConferenceRunning = false;
|
||||||
private boolean showCallListInVideo = false;
|
private boolean showCallListInVideo = false;
|
||||||
|
private LinphoneCoreListenerBase mListener;
|
||||||
|
|
||||||
public static InCallActivity instance() {
|
public static InCallActivity instance() {
|
||||||
return instance;
|
return instance;
|
||||||
|
@ -123,6 +123,100 @@ public class InCallActivity extends FragmentActivity implements LinphoneCallStat
|
||||||
isAnimationDisabled = getApplicationContext().getResources().getBoolean(R.bool.disable_animations) || !LinphonePreferences.instance().areAnimationsEnabled();
|
isAnimationDisabled = getApplicationContext().getResources().getBoolean(R.bool.disable_animations) || !LinphonePreferences.instance().areAnimationsEnabled();
|
||||||
cameraNumber = AndroidCameraConfiguration.retrieveCameras().length;
|
cameraNumber = AndroidCameraConfiguration.retrieveCameras().length;
|
||||||
|
|
||||||
|
mListener = new LinphoneCoreListenerBase(){
|
||||||
|
@Override
|
||||||
|
public void callState(LinphoneCore lc, final LinphoneCall call, LinphoneCall.State state, String message) {
|
||||||
|
if (LinphoneManager.getLc().getCallsNb() == 0) {
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!LinphonePreferences.instance().isVideoEnabled()){
|
||||||
|
video.setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == State.IncomingReceived) {
|
||||||
|
startIncomingCallActivity();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == State.Paused || state == State.PausedByRemote || state == State.Pausing) {
|
||||||
|
video.setEnabled(false);
|
||||||
|
if(isVideoEnabled(call)){
|
||||||
|
showAudioView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == State.Resuming) {
|
||||||
|
if(LinphonePreferences.instance().isVideoEnabled()){
|
||||||
|
status.refreshStatusItems(call, isVideoEnabled(call));
|
||||||
|
if(call.getCurrentParamsCopy().getVideoEnabled()){
|
||||||
|
showVideoView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == State.StreamsRunning) {
|
||||||
|
switchVideo(isVideoEnabled(call));
|
||||||
|
|
||||||
|
LinphoneManager.getLc().enableSpeaker(isSpeakerEnabled);
|
||||||
|
|
||||||
|
isMicMuted = LinphoneManager.getLc().isMicMuted();
|
||||||
|
enableAndRefreshInCallActions();
|
||||||
|
|
||||||
|
if (status != null) {
|
||||||
|
videoProgress.setVisibility(View.GONE);
|
||||||
|
status.refreshStatusItems(call, isVideoEnabled(call));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshInCallActions();
|
||||||
|
|
||||||
|
refreshCallList(getResources());
|
||||||
|
|
||||||
|
if (state == State.CallUpdatedByRemote) {
|
||||||
|
// If the correspondent proposes video while audio call
|
||||||
|
boolean videoEnabled = LinphonePreferences.instance().isVideoEnabled();
|
||||||
|
if (!videoEnabled) {
|
||||||
|
acceptCallUpdate(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean remoteVideo = call.getRemoteParams().getVideoEnabled();
|
||||||
|
boolean localVideo = call.getCurrentParamsCopy().getVideoEnabled();
|
||||||
|
boolean autoAcceptCameraPolicy = LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests();
|
||||||
|
if (remoteVideo && !localVideo && !autoAcceptCameraPolicy && !LinphoneManager.getLc().isInConference()) {
|
||||||
|
showAcceptCallUpdateDialog();
|
||||||
|
|
||||||
|
timer = new CountDownTimer(SECONDS_BEFORE_DENYING_CALL_UPDATE, 1000) {
|
||||||
|
public void onTick(long millisUntilFinished) { }
|
||||||
|
public void onFinish() {
|
||||||
|
acceptCallUpdate(false);
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
}
|
||||||
|
// else if (remoteVideo && !LinphoneManager.getLc().isInConference() && autoAcceptCameraPolicy) {
|
||||||
|
// mHandler.post(new Runnable() {
|
||||||
|
// @Override
|
||||||
|
// public void run() {
|
||||||
|
// acceptCallUpdate(true);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
transfer.setEnabled(LinphoneManager.getLc().getCurrentCall() != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void callEncryptionChanged(LinphoneCore lc, final LinphoneCall call, boolean encrypted, String authenticationToken) {
|
||||||
|
if (status != null) {
|
||||||
|
status.refreshStatusItems(call, call.getCurrentParamsCopy().getVideoEnabled());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
if (findViewById(R.id.fragmentContainer) != null) {
|
if (findViewById(R.id.fragmentContainer) != null) {
|
||||||
initUI();
|
initUI();
|
||||||
|
|
||||||
|
@ -1039,89 +1133,7 @@ public class InCallActivity extends FragmentActivity implements LinphoneCallStat
|
||||||
startActivity(new Intent(this, IncomingCallActivity.class));
|
startActivity(new Intent(this, IncomingCallActivity.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void callState(LinphoneCore lc, final LinphoneCall call, LinphoneCall.State state, String message) {
|
|
||||||
if (LinphoneManager.getLc().getCallsNb() == 0) {
|
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!LinphonePreferences.instance().isVideoEnabled()){
|
|
||||||
video.setEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state == State.IncomingReceived) {
|
|
||||||
startIncomingCallActivity();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state == State.Paused || state == State.PausedByRemote || state == State.Pausing) {
|
|
||||||
video.setEnabled(false);
|
|
||||||
if(isVideoEnabled(call)){
|
|
||||||
showAudioView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state == State.Resuming) {
|
|
||||||
if(LinphonePreferences.instance().isVideoEnabled()){
|
|
||||||
status.refreshStatusItems(call, isVideoEnabled(call));
|
|
||||||
if(call.getCurrentParamsCopy().getVideoEnabled()){
|
|
||||||
showVideoView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state == State.StreamsRunning) {
|
|
||||||
switchVideo(isVideoEnabled(call));
|
|
||||||
|
|
||||||
LinphoneManager.getLc().enableSpeaker(isSpeakerEnabled);
|
|
||||||
|
|
||||||
isMicMuted = LinphoneManager.getLc().isMicMuted();
|
|
||||||
enableAndRefreshInCallActions();
|
|
||||||
|
|
||||||
if (status != null) {
|
|
||||||
videoProgress.setVisibility(View.GONE);
|
|
||||||
status.refreshStatusItems(call, isVideoEnabled(call));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
refreshInCallActions();
|
|
||||||
|
|
||||||
refreshCallList(getResources());
|
|
||||||
|
|
||||||
if (state == State.CallUpdatedByRemote) {
|
|
||||||
// If the correspondent proposes video while audio call
|
|
||||||
boolean videoEnabled = LinphonePreferences.instance().isVideoEnabled();
|
|
||||||
if (!videoEnabled) {
|
|
||||||
acceptCallUpdate(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean remoteVideo = call.getRemoteParams().getVideoEnabled();
|
|
||||||
boolean localVideo = call.getCurrentParamsCopy().getVideoEnabled();
|
|
||||||
boolean autoAcceptCameraPolicy = LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests();
|
|
||||||
if (remoteVideo && !localVideo && !autoAcceptCameraPolicy && !LinphoneManager.getLc().isInConference()) {
|
|
||||||
showAcceptCallUpdateDialog();
|
|
||||||
|
|
||||||
timer = new CountDownTimer(SECONDS_BEFORE_DENYING_CALL_UPDATE, 1000) {
|
|
||||||
public void onTick(long millisUntilFinished) { }
|
|
||||||
public void onFinish() {
|
|
||||||
acceptCallUpdate(false);
|
|
||||||
}
|
|
||||||
}.start();
|
|
||||||
}
|
|
||||||
// else if (remoteVideo && !LinphoneManager.getLc().isInConference() && autoAcceptCameraPolicy) {
|
|
||||||
// mHandler.post(new Runnable() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
// acceptCallUpdate(true);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
transfer.setEnabled(LinphoneManager.getLc().getCurrentCall() != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showAcceptCallUpdateDialog() {
|
private void showAcceptCallUpdateDialog() {
|
||||||
FragmentManager fm = getSupportFragmentManager();
|
FragmentManager fm = getSupportFragmentManager();
|
||||||
|
@ -1129,13 +1141,6 @@ public class InCallActivity extends FragmentActivity implements LinphoneCallStat
|
||||||
callUpdateDialog.show(fm, "Accept Call Update Dialog");
|
callUpdateDialog.show(fm, "Accept Call Update Dialog");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void callEncryptionChanged(LinphoneCore lc, final LinphoneCall call, boolean encrypted, String authenticationToken) {
|
|
||||||
if (status != null) {
|
|
||||||
status.refreshStatusItems(call, call.getCurrentParamsCopy().getVideoEnabled());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
@ -1151,7 +1156,7 @@ public class InCallActivity extends FragmentActivity implements LinphoneCallStat
|
||||||
|
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.addListener(this);
|
lc.addListener(mListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshCallList(getResources());
|
refreshCallList(getResources());
|
||||||
|
@ -1195,7 +1200,7 @@ public class InCallActivity extends FragmentActivity implements LinphoneCallStat
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.removeListener(this);
|
lc.removeListener(mListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
|
@ -25,7 +25,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.LinphoneCoreListener.LinphoneCallStateListener;
|
import org.linphone.core.LinphoneCoreListenerBase;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
import org.linphone.ui.AvatarWithShadow;
|
import org.linphone.ui.AvatarWithShadow;
|
||||||
import org.linphone.ui.LinphoneSliders;
|
import org.linphone.ui.LinphoneSliders;
|
||||||
|
@ -45,7 +45,7 @@ import android.widget.Toast;
|
||||||
*
|
*
|
||||||
* @author Guillaume Beraudo
|
* @author Guillaume Beraudo
|
||||||
*/
|
*/
|
||||||
public class IncomingCallActivity extends Activity implements LinphoneCallStateListener, LinphoneSliderTriggered {
|
public class IncomingCallActivity extends Activity implements LinphoneSliderTriggered {
|
||||||
|
|
||||||
private static IncomingCallActivity instance;
|
private static IncomingCallActivity instance;
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ public class IncomingCallActivity extends Activity implements LinphoneCallStateL
|
||||||
private AvatarWithShadow mPictureView;
|
private AvatarWithShadow mPictureView;
|
||||||
private LinphoneCall mCall;
|
private LinphoneCall mCall;
|
||||||
private LinphoneSliders mIncomingCallWidget;
|
private LinphoneSliders mIncomingCallWidget;
|
||||||
|
private LinphoneCoreListenerBase mListener;
|
||||||
|
|
||||||
public static IncomingCallActivity instance() {
|
public static IncomingCallActivity instance() {
|
||||||
return instance;
|
return instance;
|
||||||
|
@ -80,6 +81,19 @@ public class IncomingCallActivity extends Activity implements LinphoneCallStateL
|
||||||
mIncomingCallWidget = (LinphoneSliders) findViewById(R.id.sliding_widget);
|
mIncomingCallWidget = (LinphoneSliders) findViewById(R.id.sliding_widget);
|
||||||
mIncomingCallWidget.setOnTriggerListener(this);
|
mIncomingCallWidget.setOnTriggerListener(this);
|
||||||
|
|
||||||
|
mListener = new LinphoneCoreListenerBase(){
|
||||||
|
@Override
|
||||||
|
public void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) {
|
||||||
|
if (call == mCall && State.CallEnd == state) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
if (state == State.StreamsRunning) {
|
||||||
|
// The following should not be needed except some devices need it (e.g. Galaxy S).
|
||||||
|
LinphoneManager.getLc().enableSpeaker(LinphoneManager.getLc().isSpeakerEnabled());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +104,7 @@ public class IncomingCallActivity extends Activity implements LinphoneCallStateL
|
||||||
instance = this;
|
instance = this;
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.addListener(this);
|
lc.addListener(mListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only one call ringing at a time is allowed
|
// Only one call ringing at a time is allowed
|
||||||
|
@ -126,7 +140,7 @@ public class IncomingCallActivity extends Activity implements LinphoneCallStateL
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.removeListener(this);
|
lc.removeListener(mListener);
|
||||||
}
|
}
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
@ -146,16 +160,7 @@ public class IncomingCallActivity extends Activity implements LinphoneCallStateL
|
||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) {
|
|
||||||
if (call == mCall && State.CallEnd == state) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
if (state == State.StreamsRunning) {
|
|
||||||
// The following should not be needed except some devices need it (e.g. Galaxy S).
|
|
||||||
LinphoneManager.getLc().enableSpeaker(LinphoneManager.getLc().isSpeakerEnabled());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void decline() {
|
private void decline() {
|
||||||
LinphoneManager.getLc().terminateCall(mCall);
|
LinphoneManager.getLc().terminateCall(mCall);
|
||||||
|
|
|
@ -41,9 +41,7 @@ import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||||
import org.linphone.core.LinphoneCoreException;
|
import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneCoreFactory;
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
import org.linphone.core.LinphoneCoreListener.LinphoneCallStateListener;
|
import org.linphone.core.LinphoneCoreListenerBase;
|
||||||
import org.linphone.core.LinphoneCoreListener.LinphoneMessageListener;
|
|
||||||
import org.linphone.core.LinphoneCoreListener.LinphoneRegistrationStateListener;
|
|
||||||
import org.linphone.core.LinphoneFriend;
|
import org.linphone.core.LinphoneFriend;
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
import org.linphone.core.LinphoneProxyConfig;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
@ -88,7 +86,7 @@ import android.widget.Toast;
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class LinphoneActivity extends FragmentActivity implements OnClickListener, ContactPicked, LinphoneCallStateListener, LinphoneMessageListener, LinphoneRegistrationStateListener {
|
public class LinphoneActivity extends FragmentActivity implements OnClickListener, ContactPicked {
|
||||||
public static final String PREF_FIRST_LAUNCH = "pref_first_launch";
|
public static final String PREF_FIRST_LAUNCH = "pref_first_launch";
|
||||||
private static final int SETTINGS_ACTIVITY = 123;
|
private static final int SETTINGS_ACTIVITY = 123;
|
||||||
private static final int FIRST_LOGIN_ACTIVITY = 101;
|
private static final int FIRST_LOGIN_ACTIVITY = 101;
|
||||||
|
@ -111,6 +109,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
private List<Contact> contactList, sipContactList;
|
private List<Contact> contactList, sipContactList;
|
||||||
private Cursor contactCursor, sipContactCursor;
|
private Cursor contactCursor, sipContactCursor;
|
||||||
private OrientationEventListener mOrientationHelper;
|
private OrientationEventListener mOrientationHelper;
|
||||||
|
private LinphoneCoreListenerBase mListener;
|
||||||
|
|
||||||
static final boolean isInstanciated() {
|
static final boolean isInstanciated() {
|
||||||
return instance != null;
|
return instance != null;
|
||||||
|
@ -170,6 +169,53 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mListener = new LinphoneCoreListenerBase(){
|
||||||
|
@Override
|
||||||
|
public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) {
|
||||||
|
displayMissedChats(getChatStorage().getUnreadMessageCount());
|
||||||
|
if (messageListFragment != null && messageListFragment.isVisible()) {
|
||||||
|
((ChatListFragment) messageListFragment).refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registrationState(LinphoneCore lc, LinphoneProxyConfig proxy, LinphoneCore.RegistrationState state, String smessage) {
|
||||||
|
if (state.equals(RegistrationState.RegistrationCleared)) {
|
||||||
|
if (lc != null) {
|
||||||
|
LinphoneAuthInfo authInfo = lc.findAuthInfo(proxy.getIdentity(), proxy.getRealm(), proxy.getDomain());
|
||||||
|
if (authInfo != null)
|
||||||
|
lc.removeAuthInfo(authInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) {
|
||||||
|
if (state == State.IncomingReceived) {
|
||||||
|
startActivity(new Intent(LinphoneActivity.instance(), IncomingCallActivity.class));
|
||||||
|
} else if (state == State.OutgoingInit) {
|
||||||
|
if (call.getCurrentParamsCopy().getVideoEnabled()) {
|
||||||
|
startVideoActivity(call);
|
||||||
|
} else {
|
||||||
|
startIncallActivity(call);
|
||||||
|
}
|
||||||
|
} else if (state == State.CallEnd || state == State.Error || state == State.CallReleased) {
|
||||||
|
// Convert LinphoneCore message for internalization
|
||||||
|
if (message != null && message.equals("Call declined.")) {
|
||||||
|
displayCustomToast(getString(R.string.error_call_declined), Toast.LENGTH_LONG);
|
||||||
|
} else if (message != null && message.equals("Not Found")) {
|
||||||
|
displayCustomToast(getString(R.string.error_user_not_found), Toast.LENGTH_LONG);
|
||||||
|
} else if (message != null && message.equals("Unsupported media type")) {
|
||||||
|
displayCustomToast(getString(R.string.error_incompatible_media), Toast.LENGTH_LONG);
|
||||||
|
}
|
||||||
|
resetClassicMenuLayoutAndGoBackToCallIfStillRunning();
|
||||||
|
}
|
||||||
|
|
||||||
|
int missedCalls = LinphoneManager.getLc().getMissedCallsCount();
|
||||||
|
displayMissedCalls(missedCalls);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
int missedCalls = LinphoneManager.getLc().getMissedCallsCount();
|
int missedCalls = LinphoneManager.getLc().getMissedCallsCount();
|
||||||
displayMissedCalls(missedCalls);
|
displayMissedCalls(missedCalls);
|
||||||
|
|
||||||
|
@ -711,13 +757,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
getChatStorage().deleteDraft(sipUri);
|
getChatStorage().deleteDraft(sipUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) {
|
|
||||||
displayMissedChats(getChatStorage().getUnreadMessageCount());
|
|
||||||
if (messageListFragment != null && messageListFragment.isVisible()) {
|
|
||||||
((ChatListFragment) messageListFragment).refresh();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateMissedChatCount() {
|
public void updateMissedChatCount() {
|
||||||
displayMissedChats(getChatStorage().getUnreadMessageCount());
|
displayMissedChats(getChatStorage().getUnreadMessageCount());
|
||||||
|
@ -741,17 +781,6 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
getChatStorage().updateMessageStatus(to, id, newState);
|
getChatStorage().updateMessageStatus(to, id, newState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registrationState(LinphoneCore lc, LinphoneProxyConfig proxy, LinphoneCore.RegistrationState state, String smessage) {
|
|
||||||
if (state.equals(RegistrationState.RegistrationCleared)) {
|
|
||||||
if (lc != null) {
|
|
||||||
LinphoneAuthInfo authInfo = lc.findAuthInfo(proxy.getIdentity(), proxy.getRealm(), proxy.getDomain());
|
|
||||||
if (authInfo != null)
|
|
||||||
lc.removeAuthInfo(authInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void displayMissedCalls(final int missedCallsCount) {
|
private void displayMissedCalls(final int missedCallsCount) {
|
||||||
if (missedCallsCount > 0) {
|
if (missedCallsCount > 0) {
|
||||||
missedCalls.setText(missedCallsCount + "");
|
missedCalls.setText(missedCallsCount + "");
|
||||||
|
@ -783,32 +812,6 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) {
|
|
||||||
if (state == State.IncomingReceived) {
|
|
||||||
startActivity(new Intent(this, IncomingCallActivity.class));
|
|
||||||
} else if (state == State.OutgoingInit) {
|
|
||||||
if (call.getCurrentParamsCopy().getVideoEnabled()) {
|
|
||||||
startVideoActivity(call);
|
|
||||||
} else {
|
|
||||||
startIncallActivity(call);
|
|
||||||
}
|
|
||||||
} else if (state == State.CallEnd || state == State.Error || state == State.CallReleased) {
|
|
||||||
// Convert LinphoneCore message for internalization
|
|
||||||
if (message != null && message.equals("Call declined.")) {
|
|
||||||
displayCustomToast(getString(R.string.error_call_declined), Toast.LENGTH_LONG);
|
|
||||||
} else if (message != null && message.equals("Not Found")) {
|
|
||||||
displayCustomToast(getString(R.string.error_user_not_found), Toast.LENGTH_LONG);
|
|
||||||
} else if (message != null && message.equals("Unsupported media type")) {
|
|
||||||
displayCustomToast(getString(R.string.error_incompatible_media), Toast.LENGTH_LONG);
|
|
||||||
}
|
|
||||||
resetClassicMenuLayoutAndGoBackToCallIfStillRunning();
|
|
||||||
}
|
|
||||||
|
|
||||||
int missedCalls = LinphoneManager.getLc().getMissedCallsCount();
|
|
||||||
displayMissedCalls(missedCalls);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void displayCustomToast(final String message, final int duration) {
|
public void displayCustomToast(final String message, final int duration) {
|
||||||
LayoutInflater inflater = getLayoutInflater();
|
LayoutInflater inflater = getLayoutInflater();
|
||||||
View layout = inflater.inflate(R.layout.toast, (ViewGroup) findViewById(R.id.toastRoot));
|
View layout = inflater.inflate(R.layout.toast, (ViewGroup) findViewById(R.id.toastRoot));
|
||||||
|
@ -1209,7 +1212,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.removeListener(this);
|
lc.removeListener(mListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
getIntent().putExtra("PreviousActivity", 0);
|
getIntent().putExtra("PreviousActivity", 0);
|
||||||
|
@ -1226,7 +1229,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
|
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.addListener(this);
|
lc.addListener(mListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareContactsInBackground();
|
prepareContactsInBackground();
|
||||||
|
|
|
@ -53,7 +53,6 @@ import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneCoreFactory;
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
import org.linphone.core.LinphoneCoreFactoryImpl;
|
import org.linphone.core.LinphoneCoreFactoryImpl;
|
||||||
import org.linphone.core.LinphoneCoreListener;
|
import org.linphone.core.LinphoneCoreListener;
|
||||||
import org.linphone.core.LinphoneCoreListener.LinphoneListener;
|
|
||||||
import org.linphone.core.LinphoneEvent;
|
import org.linphone.core.LinphoneEvent;
|
||||||
import org.linphone.core.LinphoneFriend;
|
import org.linphone.core.LinphoneFriend;
|
||||||
import org.linphone.core.LinphoneInfoMessage;
|
import org.linphone.core.LinphoneInfoMessage;
|
||||||
|
@ -118,7 +117,7 @@ import android.widget.Toast;
|
||||||
* @author Guillaume Beraudo
|
* @author Guillaume Beraudo
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class LinphoneManager implements LinphoneListener {
|
public class LinphoneManager implements LinphoneCoreListener {
|
||||||
|
|
||||||
private static LinphoneManager instance;
|
private static LinphoneManager instance;
|
||||||
private Context mServiceContext;
|
private Context mServiceContext;
|
||||||
|
@ -448,7 +447,6 @@ public class LinphoneManager implements LinphoneListener {
|
||||||
LinphoneCoreFactory.instance().setDebugMode(isDebugLogEnabled, getString(R.string.app_name));
|
LinphoneCoreFactory.instance().setDebugMode(isDebugLogEnabled, getString(R.string.app_name));
|
||||||
|
|
||||||
mLc = LinphoneCoreFactory.instance().createLinphoneCore(this, mLinphoneConfigFile, mLinphoneFactoryConfigFile, null, c);
|
mLc = LinphoneCoreFactory.instance().createLinphoneCore(this, mLinphoneConfigFile, mLinphoneFactoryConfigFile, null, c);
|
||||||
mLc.addListener((LinphoneCoreListener) c);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
initLiblinphone();
|
initLiblinphone();
|
||||||
|
@ -897,7 +895,7 @@ public class LinphoneManager implements LinphoneListener {
|
||||||
boolean encrypted, String authenticationToken) {
|
boolean encrypted, String authenticationToken) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startEcCalibration(LinphoneEchoCalibrationListener l) throws LinphoneCoreException {
|
public void startEcCalibration(LinphoneCoreListener l) throws LinphoneCoreException {
|
||||||
routeAudioToSpeaker();
|
routeAudioToSpeaker();
|
||||||
int oldVolume = mAudioManager.getStreamVolume(STREAM_VOICE_CALL);
|
int oldVolume = mAudioManager.getStreamVolume(STREAM_VOICE_CALL);
|
||||||
int maxVolume = mAudioManager.getStreamMaxVolume(STREAM_VOICE_CALL);
|
int maxVolume = mAudioManager.getStreamMaxVolume(STREAM_VOICE_CALL);
|
||||||
|
@ -1285,4 +1283,11 @@ public class LinphoneManager implements LinphoneListener {
|
||||||
LogCollectionUploadState state, String info) {
|
LogCollectionUploadState state, String info) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ecCalibrationStatus(LinphoneCore lc, EcCalibratorStatus status,
|
||||||
|
int delay_ms, Object data) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,7 @@ import org.linphone.core.LinphoneCore.RegistrationState;
|
||||||
import org.linphone.core.LinphoneCoreException;
|
import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneCoreFactoryImpl;
|
import org.linphone.core.LinphoneCoreFactoryImpl;
|
||||||
import org.linphone.core.LinphoneCoreImpl;
|
import org.linphone.core.LinphoneCoreImpl;
|
||||||
import org.linphone.core.LinphoneCoreListener.LinphoneCallStateListener;
|
import org.linphone.core.LinphoneCoreListenerBase;
|
||||||
import org.linphone.core.LinphoneCoreListener.LinphoneGlobalStateListener;
|
|
||||||
import org.linphone.core.LinphoneCoreListener.LinphoneRegistrationStateListener;
|
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
import org.linphone.core.LinphoneProxyConfig;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
import org.linphone.mediastream.Version;
|
import org.linphone.mediastream.Version;
|
||||||
|
@ -74,8 +72,7 @@ import android.provider.MediaStore;
|
||||||
* @author Guillaume Beraudo
|
* @author Guillaume Beraudo
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public final class LinphoneService extends Service implements LinphoneCallStateListener,
|
public final class LinphoneService extends Service {
|
||||||
LinphoneGlobalStateListener, LinphoneRegistrationStateListener {
|
|
||||||
/* Listener needs to be implemented in the Service as it calls
|
/* Listener needs to be implemented in the Service as it calls
|
||||||
* setLatestEventInfo and startActivity() which needs a context.
|
* setLatestEventInfo and startActivity() which needs a context.
|
||||||
*/
|
*/
|
||||||
|
@ -122,6 +119,7 @@ public final class LinphoneService extends Service implements LinphoneCallStateL
|
||||||
private PendingIntent mkeepAlivePendingIntent;
|
private PendingIntent mkeepAlivePendingIntent;
|
||||||
private String mNotificationTitle;
|
private String mNotificationTitle;
|
||||||
private boolean mDisableRegistrationStatus;
|
private boolean mDisableRegistrationStatus;
|
||||||
|
private LinphoneCoreListenerBase mListener;
|
||||||
|
|
||||||
public int getMessageNotifCount() {
|
public int getMessageNotifCount() {
|
||||||
return mMsgNotifCount;
|
return mMsgNotifCount;
|
||||||
|
@ -170,6 +168,80 @@ public final class LinphoneService extends Service implements LinphoneCallStateL
|
||||||
}
|
}
|
||||||
instance = this; // instance is ready once linphone manager has been created
|
instance = this; // instance is ready once linphone manager has been created
|
||||||
|
|
||||||
|
mListener = new LinphoneCoreListenerBase(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) {
|
||||||
|
if (instance == null) {
|
||||||
|
Log.i("Service not ready, discarding call state change to ",state.toString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == LinphoneCall.State.IncomingReceived) {
|
||||||
|
onIncomingReceived();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == State.CallUpdatedByRemote) {
|
||||||
|
// If the correspondent proposes video while audio call
|
||||||
|
boolean remoteVideo = call.getRemoteParams().getVideoEnabled();
|
||||||
|
boolean localVideo = call.getCurrentParamsCopy().getVideoEnabled();
|
||||||
|
boolean autoAcceptCameraPolicy = LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests();
|
||||||
|
if (remoteVideo && !localVideo && !autoAcceptCameraPolicy && !LinphoneManager.getLc().isInConference()) {
|
||||||
|
try {
|
||||||
|
LinphoneManager.getLc().deferCallUpdate(call);
|
||||||
|
} catch (LinphoneCoreException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == State.StreamsRunning) {
|
||||||
|
// Workaround bug current call seems to be updated after state changed to streams running
|
||||||
|
if (getResources().getBoolean(R.bool.enable_call_notification))
|
||||||
|
refreshIncallIcon(call);
|
||||||
|
if (Version.sdkAboveOrEqual(Version.API12_HONEYCOMB_MR1_31X)) {
|
||||||
|
mWifiLock.acquire();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (getResources().getBoolean(R.bool.enable_call_notification))
|
||||||
|
refreshIncallIcon(LinphoneManager.getLc().getCurrentCall());
|
||||||
|
}
|
||||||
|
if ((state == State.CallEnd || state == State.Error) && LinphoneManager.getLc().getCallsNb() < 1) {
|
||||||
|
if (Version.sdkAboveOrEqual(Version.API12_HONEYCOMB_MR1_31X)) {
|
||||||
|
mWifiLock.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void globalState(LinphoneCore lc,LinphoneCore.GlobalState state, String message) {
|
||||||
|
if (state == GlobalState.GlobalOn) {
|
||||||
|
sendNotification(IC_LEVEL_OFFLINE, R.string.notification_started);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState state, String smessage) {
|
||||||
|
// if (instance == null) {
|
||||||
|
// Log.i("Service not ready, discarding registration state change to ",state.toString());
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
if (!mDisableRegistrationStatus) {
|
||||||
|
if (state == RegistrationState.RegistrationOk && LinphoneManager.getLc().getDefaultProxyConfig() != null && LinphoneManager.getLc().getDefaultProxyConfig().isRegistered()) {
|
||||||
|
sendNotification(IC_LEVEL_ORANGE, R.string.notification_registered);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((state == RegistrationState.RegistrationFailed || state == RegistrationState.RegistrationCleared) && (LinphoneManager.getLc().getDefaultProxyConfig() == null || !LinphoneManager.getLc().getDefaultProxyConfig().isRegistered())) {
|
||||||
|
sendNotification(IC_LEVEL_OFFLINE, R.string.notification_register_failure);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == RegistrationState.RegistrationNone) {
|
||||||
|
sendNotification(IC_LEVEL_OFFLINE, R.string.notification_started);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Retrieve methods to publish notification and keep Android
|
// Retrieve methods to publish notification and keep Android
|
||||||
// from killing us and keep the audio quality high.
|
// from killing us and keep the audio quality high.
|
||||||
if (Version.sdkStrictlyBelow(Version.API05_ECLAIR_20)) {
|
if (Version.sdkStrictlyBelow(Version.API05_ECLAIR_20)) {
|
||||||
|
@ -490,7 +562,7 @@ public final class LinphoneService extends Service implements LinphoneCallStateL
|
||||||
public synchronized void onDestroy() {
|
public synchronized void onDestroy() {
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.removeListener(this);
|
lc.removeListener(mListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
instance = null;
|
instance = null;
|
||||||
|
@ -508,34 +580,6 @@ public final class LinphoneService extends Service implements LinphoneCallStateL
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void globalState(LinphoneCore lc,LinphoneCore.GlobalState state, String message) {
|
|
||||||
if (state == GlobalState.GlobalOn) {
|
|
||||||
sendNotification(IC_LEVEL_OFFLINE, R.string.notification_started);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState state, String smessage) {
|
|
||||||
// if (instance == null) {
|
|
||||||
// Log.i("Service not ready, discarding registration state change to ",state.toString());
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
if (!mDisableRegistrationStatus) {
|
|
||||||
if (state == RegistrationState.RegistrationOk && LinphoneManager.getLc().getDefaultProxyConfig() != null && LinphoneManager.getLc().getDefaultProxyConfig().isRegistered()) {
|
|
||||||
sendNotification(IC_LEVEL_ORANGE, R.string.notification_registered);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((state == RegistrationState.RegistrationFailed || state == RegistrationState.RegistrationCleared) && (LinphoneManager.getLc().getDefaultProxyConfig() == null || !LinphoneManager.getLc().getDefaultProxyConfig().isRegistered())) {
|
|
||||||
sendNotification(IC_LEVEL_OFFLINE, R.string.notification_register_failure);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state == RegistrationState.RegistrationNone) {
|
|
||||||
sendNotification(IC_LEVEL_OFFLINE, R.string.notification_started);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActivityToLaunchOnIncomingReceived(Class<? extends Activity> activity) {
|
public void setActivityToLaunchOnIncomingReceived(Class<? extends Activity> activity) {
|
||||||
incomingReceivedActivity = activity;
|
incomingReceivedActivity = activity;
|
||||||
resetIntentLaunchedOnNotificationClick();
|
resetIntentLaunchedOnNotificationClick();
|
||||||
|
@ -558,48 +602,6 @@ public final class LinphoneService extends Service implements LinphoneCallStateL
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) {
|
|
||||||
if (instance == null) {
|
|
||||||
Log.i("Service not ready, discarding call state change to ",state.toString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state == LinphoneCall.State.IncomingReceived) {
|
|
||||||
onIncomingReceived();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state == State.CallUpdatedByRemote) {
|
|
||||||
// If the correspondent proposes video while audio call
|
|
||||||
boolean remoteVideo = call.getRemoteParams().getVideoEnabled();
|
|
||||||
boolean localVideo = call.getCurrentParamsCopy().getVideoEnabled();
|
|
||||||
boolean autoAcceptCameraPolicy = LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests();
|
|
||||||
if (remoteVideo && !localVideo && !autoAcceptCameraPolicy && !LinphoneManager.getLc().isInConference()) {
|
|
||||||
try {
|
|
||||||
LinphoneManager.getLc().deferCallUpdate(call);
|
|
||||||
} catch (LinphoneCoreException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state == State.StreamsRunning) {
|
|
||||||
// Workaround bug current call seems to be updated after state changed to streams running
|
|
||||||
if (getResources().getBoolean(R.bool.enable_call_notification))
|
|
||||||
refreshIncallIcon(call);
|
|
||||||
if (Version.sdkAboveOrEqual(Version.API12_HONEYCOMB_MR1_31X)) {
|
|
||||||
mWifiLock.acquire();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (getResources().getBoolean(R.bool.enable_call_notification))
|
|
||||||
refreshIncallIcon(LinphoneManager.getLc().getCurrentCall());
|
|
||||||
}
|
|
||||||
if ((state == State.CallEnd || state == State.Error) && LinphoneManager.getLc().getCallsNb() < 1) {
|
|
||||||
if (Version.sdkAboveOrEqual(Version.API12_HONEYCOMB_MR1_31X)) {
|
|
||||||
mWifiLock.release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void tryingNewOutgoingCallButAlreadyInCall() {
|
public void tryingNewOutgoingCallButAlreadyInCall() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||||
import org.linphone.core.LinphoneCore.MediaEncryption;
|
import org.linphone.core.LinphoneCore.MediaEncryption;
|
||||||
import org.linphone.core.LinphoneCoreException;
|
import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneCoreFactory;
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
import org.linphone.core.LinphoneCoreListener.LinphoneEchoCalibrationListener;
|
import org.linphone.core.LinphoneCoreListenerBase;
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
import org.linphone.core.LinphoneProxyConfig;
|
||||||
import org.linphone.core.PayloadType;
|
import org.linphone.core.PayloadType;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
@ -54,10 +54,11 @@ import android.preference.PreferenceScreen;
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class SettingsFragment extends PreferencesListFragment implements LinphoneEchoCalibrationListener {
|
public class SettingsFragment extends PreferencesListFragment {
|
||||||
private static final int WIZARD_INTENT = 1;
|
private static final int WIZARD_INTENT = 1;
|
||||||
private LinphonePreferences mPrefs;
|
private LinphonePreferences mPrefs;
|
||||||
private Handler mHandler = new Handler();
|
private Handler mHandler = new Handler();
|
||||||
|
private LinphoneCoreListenerBase mListener;
|
||||||
|
|
||||||
public SettingsFragment() {
|
public SettingsFragment() {
|
||||||
super(R.xml.preferences);
|
super(R.xml.preferences);
|
||||||
|
@ -72,6 +73,30 @@ public class SettingsFragment extends PreferencesListFragment implements Linphon
|
||||||
initSettings();
|
initSettings();
|
||||||
setListeners();
|
setListeners();
|
||||||
hideSettings();
|
hideSettings();
|
||||||
|
|
||||||
|
mListener = new LinphoneCoreListenerBase(){
|
||||||
|
@Override
|
||||||
|
public void ecCalibrationStatus(LinphoneCore lc, final EcCalibratorStatus status, final int delayMs, Object data) {
|
||||||
|
LinphoneManager.getInstance().routeAudioToReceiver();
|
||||||
|
|
||||||
|
CheckBoxPreference echoCancellation = (CheckBoxPreference) findPreference(getString(R.string.pref_echo_cancellation_key));
|
||||||
|
Preference echoCancellerCalibration = findPreference(getString(R.string.pref_echo_canceller_calibration_key));
|
||||||
|
|
||||||
|
if (status == EcCalibratorStatus.DoneNoEcho) {
|
||||||
|
echoCancellerCalibration.setSummary(R.string.no_echo);
|
||||||
|
echoCancellation.setChecked(false);
|
||||||
|
LinphonePreferences.instance().setEchoCancellation(false);
|
||||||
|
} else if (status == EcCalibratorStatus.Done) {
|
||||||
|
echoCancellerCalibration.setSummary(String.format(getString(R.string.ec_calibrated), delayMs));
|
||||||
|
echoCancellation.setChecked(true);
|
||||||
|
LinphonePreferences.instance().setEchoCancellation(true);
|
||||||
|
} else if (status == EcCalibratorStatus.Failed) {
|
||||||
|
echoCancellerCalibration.setSummary(R.string.failed);
|
||||||
|
echoCancellation.setChecked(true);
|
||||||
|
LinphonePreferences.instance().setEchoCancellation(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inits the values or the listener on some settings
|
// Inits the values or the listener on some settings
|
||||||
|
@ -531,7 +556,7 @@ public class SettingsFragment extends PreferencesListFragment implements Linphon
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
synchronized (SettingsFragment.this) {
|
synchronized (SettingsFragment.this) {
|
||||||
try {
|
try {
|
||||||
LinphoneManager.getInstance().startEcCalibration(SettingsFragment.this);
|
LinphoneManager.getInstance().startEcCalibration(mListener);
|
||||||
preference.setSummary(R.string.ec_calibrating);
|
preference.setSummary(R.string.ec_calibrating);
|
||||||
} catch (LinphoneCoreException e) {
|
} catch (LinphoneCoreException e) {
|
||||||
Log.w(e, "Cannot calibrate EC");
|
Log.w(e, "Cannot calibrate EC");
|
||||||
|
@ -925,28 +950,6 @@ public class SettingsFragment extends PreferencesListFragment implements Linphon
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ecCalibrationStatus(LinphoneCore lc, final EcCalibratorStatus status, final int delayMs, Object data) {
|
|
||||||
LinphoneManager.getInstance().routeAudioToReceiver();
|
|
||||||
|
|
||||||
CheckBoxPreference echoCancellation = (CheckBoxPreference) findPreference(getString(R.string.pref_echo_cancellation_key));
|
|
||||||
Preference echoCancellerCalibration = findPreference(getString(R.string.pref_echo_canceller_calibration_key));
|
|
||||||
|
|
||||||
if (status == EcCalibratorStatus.DoneNoEcho) {
|
|
||||||
echoCancellerCalibration.setSummary(R.string.no_echo);
|
|
||||||
echoCancellation.setChecked(false);
|
|
||||||
LinphonePreferences.instance().setEchoCancellation(false);
|
|
||||||
} else if (status == EcCalibratorStatus.Done) {
|
|
||||||
echoCancellerCalibration.setSummary(String.format(getString(R.string.ec_calibrated), delayMs));
|
|
||||||
echoCancellation.setChecked(true);
|
|
||||||
LinphonePreferences.instance().setEchoCancellation(true);
|
|
||||||
} else if (status == EcCalibratorStatus.Failed) {
|
|
||||||
echoCancellerCalibration.setSummary(R.string.failed);
|
|
||||||
echoCancellation.setChecked(true);
|
|
||||||
LinphonePreferences.instance().setEchoCancellation(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
|
@ -29,8 +29,7 @@ import org.linphone.core.LinphoneContent;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCore.MediaEncryption;
|
import org.linphone.core.LinphoneCore.MediaEncryption;
|
||||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||||
import org.linphone.core.LinphoneCoreListener.LinphoneNotifyListener;
|
import org.linphone.core.LinphoneCoreListenerBase;
|
||||||
import org.linphone.core.LinphoneCoreListener.LinphoneRegistrationStateListener;
|
|
||||||
import org.linphone.core.LinphoneEvent;
|
import org.linphone.core.LinphoneEvent;
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
import org.linphone.core.LinphoneProxyConfig;
|
||||||
import org.linphone.core.PayloadType;
|
import org.linphone.core.PayloadType;
|
||||||
|
@ -59,7 +58,7 @@ import android.widget.TextView;
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class StatusFragment extends Fragment implements LinphoneNotifyListener, LinphoneRegistrationStateListener {
|
public class StatusFragment extends Fragment {
|
||||||
private Handler mHandler = new Handler();
|
private Handler mHandler = new Handler();
|
||||||
private Handler refreshHandler = new Handler();
|
private Handler refreshHandler = new Handler();
|
||||||
private TextView statusText, exit, voicemailCount;
|
private TextView statusText, exit, voicemailCount;
|
||||||
|
@ -72,6 +71,7 @@ public class StatusFragment extends Fragment implements LinphoneNotifyListener,
|
||||||
private boolean isInCall, isAttached = false;
|
private boolean isInCall, isAttached = false;
|
||||||
private Timer mTimer;
|
private Timer mTimer;
|
||||||
private TimerTask mTask;
|
private TimerTask mTask;
|
||||||
|
private LinphoneCoreListenerBase mListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
@ -113,13 +113,64 @@ public class StatusFragment extends Fragment implements LinphoneNotifyListener,
|
||||||
// We create it once to not delay the first display
|
// We create it once to not delay the first display
|
||||||
populateSliderContent();
|
populateSliderContent();
|
||||||
|
|
||||||
|
mListener = new LinphoneCoreListenerBase(){
|
||||||
|
@Override
|
||||||
|
public void registrationState(final LinphoneCore lc, LinphoneProxyConfig proxy, final LinphoneCore.RegistrationState state, String smessage) {
|
||||||
|
if (!isAttached || !LinphoneService.isReady()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mHandler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
statusLed.setImageResource(getStatusIconResource(state, true));
|
||||||
|
statusText.setText(getStatusIconText(state));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (getResources().getBoolean(R.bool.lock_statusbar)) {
|
||||||
|
statusText.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
lc.refreshRegisters();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// setMiniLedsForEachAccount();
|
||||||
|
populateSliderContent();
|
||||||
|
sliderContentAccounts.invalidate();
|
||||||
|
} catch (IllegalStateException ise) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyReceived(LinphoneCore lc, LinphoneEvent ev, String eventName, LinphoneContent content) {
|
||||||
|
|
||||||
|
if(!content.getType().equals("application")) return;
|
||||||
|
if(!content.getSubtype().equals("imple-message-summary")) return;
|
||||||
|
|
||||||
|
if (content.getData() == null) return;
|
||||||
|
|
||||||
|
//TODO Parse
|
||||||
|
int unreadCount = -1;
|
||||||
|
|
||||||
|
if (unreadCount > 0) {
|
||||||
|
voicemailCount.setText(unreadCount + " unread messages");
|
||||||
|
voicemailCount.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
voicemailCount.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.addListener(this);
|
lc.addListener(mListener);
|
||||||
|
|
||||||
LinphoneProxyConfig lpc = lc.getDefaultProxyConfig();
|
LinphoneProxyConfig lpc = lc.getDefaultProxyConfig();
|
||||||
if (lpc != null) {
|
if (lpc != null) {
|
||||||
registrationState(lc, lpc, lpc.getState(), null);
|
mListener.registrationState(lc, lpc, lpc.getState(), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,35 +244,6 @@ public class StatusFragment extends Fragment implements LinphoneNotifyListener,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registrationState(final LinphoneCore lc, LinphoneProxyConfig proxy, final LinphoneCore.RegistrationState state, String smessage) {
|
|
||||||
if (!isAttached || !LinphoneService.isReady()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mHandler.post(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
statusLed.setImageResource(getStatusIconResource(state, true));
|
|
||||||
statusText.setText(getStatusIconText(state));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (getResources().getBoolean(R.bool.lock_statusbar)) {
|
|
||||||
statusText.setOnClickListener(new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
lc.refreshRegisters();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// setMiniLedsForEachAccount();
|
|
||||||
populateSliderContent();
|
|
||||||
sliderContentAccounts.invalidate();
|
|
||||||
} catch (IllegalStateException ise) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// private void setMiniLedsForEachAccount() {
|
// private void setMiniLedsForEachAccount() {
|
||||||
// if (allAccountsLed == null)
|
// if (allAccountsLed == null)
|
||||||
// return;
|
// return;
|
||||||
|
@ -381,7 +403,7 @@ public class StatusFragment extends Fragment implements LinphoneNotifyListener,
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.removeListener(this);
|
lc.removeListener(mListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
@ -495,7 +517,7 @@ public class StatusFragment extends Fragment implements LinphoneNotifyListener,
|
||||||
ice.setText(videoStats.getIceState().toString());
|
ice.setText(videoStats.getIceState().toString());
|
||||||
|
|
||||||
videoResolutionLayout.setVisibility(View.VISIBLE);
|
videoResolutionLayout.setVisibility(View.VISIBLE);
|
||||||
videoResolution.setText("↑ " + params.getSentVideoSize().toDisplayableString() + " / ↓ " + params.getReceivedVideoSize().toDisplayableString());
|
videoResolution.setText("<EFBFBD><EFBFBD><EFBFBD> " + params.getSentVideoSize().toDisplayableString() + " / <EFBFBD><EFBFBD><EFBFBD> " + params.getReceivedVideoSize().toDisplayableString());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final LinphoneCallStats audioStats = call.getAudioStats();
|
final LinphoneCallStats audioStats = call.getAudioStats();
|
||||||
|
@ -646,22 +668,4 @@ public class StatusFragment extends Fragment implements LinphoneNotifyListener,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void notifyReceived(LinphoneCore lc, LinphoneEvent ev, String eventName, LinphoneContent content) {
|
|
||||||
|
|
||||||
if(!content.getType().equals("application")) return;
|
|
||||||
if(!content.getSubtype().equals("imple-message-summary")) return;
|
|
||||||
|
|
||||||
if (content.getData() == null) return;
|
|
||||||
|
|
||||||
//TODO Parse
|
|
||||||
int unreadCount = -1;
|
|
||||||
|
|
||||||
if (unreadCount > 0) {
|
|
||||||
voicemailCount.setText(unreadCount + " unread messages");
|
|
||||||
voicemailCount.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
voicemailCount.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.linphone.R;
|
||||||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCoreException;
|
import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneCoreListener.LinphoneEchoCalibrationListener;
|
import org.linphone.core.LinphoneCoreListenerBase;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
@ -45,38 +45,43 @@ import de.timroes.axmlrpc.XMLRPCServerException;
|
||||||
/**
|
/**
|
||||||
* @author Ghislain MARY
|
* @author Ghislain MARY
|
||||||
*/
|
*/
|
||||||
public class EchoCancellerCalibrationFragment extends Fragment implements LinphoneEchoCalibrationListener {
|
public class EchoCancellerCalibrationFragment extends Fragment {
|
||||||
private Handler mHandler = new Handler();
|
private Handler mHandler = new Handler();
|
||||||
private boolean mSendEcCalibrationResult = false;
|
private boolean mSendEcCalibrationResult = false;
|
||||||
|
private LinphoneCoreListenerBase mListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.setup_ec_calibration, container, false);
|
View view = inflater.inflate(R.layout.setup_ec_calibration, container, false);
|
||||||
|
|
||||||
|
mListener = new LinphoneCoreListenerBase(){
|
||||||
|
@Override
|
||||||
|
public void ecCalibrationStatus(LinphoneCore lc,LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data) {
|
||||||
|
LinphoneManager.getInstance().routeAudioToReceiver();
|
||||||
|
|
||||||
|
if (status == EcCalibratorStatus.DoneNoEcho) {
|
||||||
|
LinphonePreferences.instance().setEchoCancellation(false);
|
||||||
|
} else if ((status == EcCalibratorStatus.Done) || (status == EcCalibratorStatus.Failed)) {
|
||||||
|
LinphonePreferences.instance().setEchoCancellation(true);
|
||||||
|
}
|
||||||
|
if (mSendEcCalibrationResult) {
|
||||||
|
sendEcCalibrationResult(status, delay_ms);
|
||||||
|
} else {
|
||||||
|
SetupActivity.instance().isEchoCalibrationFinished();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LinphoneManager.getInstance().startEcCalibration(this);
|
LinphoneManager.getInstance().startEcCalibration(mListener);
|
||||||
} catch (LinphoneCoreException e) {
|
} catch (LinphoneCoreException e) {
|
||||||
Log.e(e, "Unable to calibrate EC");
|
Log.e(e, "Unable to calibrate EC");
|
||||||
}
|
}
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ecCalibrationStatus(LinphoneCore lc,LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data) {
|
|
||||||
LinphoneManager.getInstance().routeAudioToReceiver();
|
|
||||||
|
|
||||||
if (status == EcCalibratorStatus.DoneNoEcho) {
|
|
||||||
LinphonePreferences.instance().setEchoCancellation(false);
|
|
||||||
} else if ((status == EcCalibratorStatus.Done) || (status == EcCalibratorStatus.Failed)) {
|
|
||||||
LinphonePreferences.instance().setEchoCancellation(true);
|
|
||||||
}
|
|
||||||
if (mSendEcCalibrationResult) {
|
|
||||||
sendEcCalibrationResult(status, delay_ms);
|
|
||||||
} else {
|
|
||||||
SetupActivity.instance().isEchoCalibrationFinished();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enableEcCalibrationResultSending(boolean enabled) {
|
public void enableEcCalibrationResultSending(boolean enabled) {
|
||||||
mSendEcCalibrationResult = enabled;
|
mSendEcCalibrationResult = enabled;
|
||||||
|
|
|
@ -31,7 +31,7 @@ import org.linphone.LinphoneService;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCore.RemoteProvisioningState;
|
import org.linphone.core.LinphoneCore.RemoteProvisioningState;
|
||||||
import org.linphone.core.LinphoneCoreListener.LinphoneRemoteProvisioningListener;
|
import org.linphone.core.LinphoneCoreListenerBase;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
@ -48,16 +48,29 @@ import android.widget.Toast;
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class RemoteProvisioningActivity extends Activity implements LinphoneRemoteProvisioningListener {
|
public class RemoteProvisioningActivity extends Activity {
|
||||||
private Handler mHandler = new Handler();
|
private Handler mHandler = new Handler();
|
||||||
private String configUriParam = null;
|
private String configUriParam = null;
|
||||||
private ProgressBar spinner;
|
private ProgressBar spinner;
|
||||||
|
private LinphoneCoreListenerBase mListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.remote_provisioning);
|
setContentView(R.layout.remote_provisioning);
|
||||||
spinner = (ProgressBar) findViewById(R.id.spinner);
|
spinner = (ProgressBar) findViewById(R.id.spinner);
|
||||||
|
|
||||||
|
mListener = new LinphoneCoreListenerBase(){
|
||||||
|
@Override
|
||||||
|
public void configuringStatus(LinphoneCore lc, final RemoteProvisioningState state, String message) {
|
||||||
|
if (spinner != null) spinner.setVisibility(View.GONE);
|
||||||
|
if (state == RemoteProvisioningState.ConfiguringSuccessful) {
|
||||||
|
goToLinphoneActivity();
|
||||||
|
} else if (state == RemoteProvisioningState.ConfiguringFailed) {
|
||||||
|
Toast.makeText(RemoteProvisioningActivity.this, R.string.remote_provisioning_failure, Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -65,7 +78,7 @@ public class RemoteProvisioningActivity extends Activity implements LinphoneRemo
|
||||||
super.onResume();
|
super.onResume();
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.addListener(this);
|
lc.addListener(mListener);
|
||||||
}
|
}
|
||||||
LinphonePreferences.instance().setContext(this);
|
LinphonePreferences.instance().setContext(this);
|
||||||
|
|
||||||
|
@ -76,21 +89,11 @@ public class RemoteProvisioningActivity extends Activity implements LinphoneRemo
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.removeListener(this);
|
lc.removeListener(mListener);
|
||||||
}
|
}
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void configuringStatus(LinphoneCore lc, final RemoteProvisioningState state, String message) {
|
|
||||||
if (spinner != null) spinner.setVisibility(View.GONE);
|
|
||||||
if (state == RemoteProvisioningState.ConfiguringSuccessful) {
|
|
||||||
goToLinphoneActivity();
|
|
||||||
} else if (state == RemoteProvisioningState.ConfiguringFailed) {
|
|
||||||
Toast.makeText(RemoteProvisioningActivity.this, R.string.remote_provisioning_failure, Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNewIntent(Intent intent) {
|
protected void onNewIntent(Intent intent) {
|
||||||
super.onNewIntent(intent);
|
super.onNewIntent(intent);
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.linphone.core.LinphoneAddress.TransportType;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||||
import org.linphone.core.LinphoneCoreException;
|
import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneCoreListener;
|
import org.linphone.core.LinphoneCoreListenerBase;
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
import org.linphone.core.LinphoneProxyConfig;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
@ -44,7 +44,7 @@ import android.widget.Toast;
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class SetupActivity extends FragmentActivity implements OnClickListener, LinphoneCoreListener {
|
public class SetupActivity extends FragmentActivity implements OnClickListener {
|
||||||
private static SetupActivity instance;
|
private static SetupActivity instance;
|
||||||
private RelativeLayout back, next, cancel;
|
private RelativeLayout back, next, cancel;
|
||||||
private SetupFragmentsEnum currentFragment;
|
private SetupFragmentsEnum currentFragment;
|
||||||
|
@ -52,6 +52,7 @@ public class SetupActivity extends FragmentActivity implements OnClickListener,
|
||||||
private Fragment fragment;
|
private Fragment fragment;
|
||||||
private LinphonePreferences mPrefs;
|
private LinphonePreferences mPrefs;
|
||||||
private boolean accountCreated = false;
|
private boolean accountCreated = false;
|
||||||
|
private LinphoneCoreListenerBase mListener;
|
||||||
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -73,6 +74,20 @@ public class SetupActivity extends FragmentActivity implements OnClickListener,
|
||||||
mPrefs = LinphonePreferences.instance();
|
mPrefs = LinphonePreferences.instance();
|
||||||
|
|
||||||
initUI();
|
initUI();
|
||||||
|
|
||||||
|
mListener = new LinphoneCoreListenerBase(){
|
||||||
|
@Override
|
||||||
|
public void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState state, String smessage) {
|
||||||
|
if (state == RegistrationState.RegistrationOk) {
|
||||||
|
if (LinphoneManager.getLc().getDefaultProxyConfig() != null) {
|
||||||
|
launchEchoCancellerCalibration(true);
|
||||||
|
}
|
||||||
|
} else if (state == RegistrationState.RegistrationFailed) {
|
||||||
|
Toast.makeText(SetupActivity.this, getString(R.string.first_launch_bad_login_password), Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -82,7 +97,7 @@ public class SetupActivity extends FragmentActivity implements OnClickListener,
|
||||||
|
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.addListener(this);
|
lc.addListener(mListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +105,7 @@ public class SetupActivity extends FragmentActivity implements OnClickListener,
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.removeListener(this);
|
lc.removeListener(mListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
@ -220,16 +235,6 @@ public class SetupActivity extends FragmentActivity implements OnClickListener,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState state, String smessage) {
|
|
||||||
if (state == RegistrationState.RegistrationOk) {
|
|
||||||
if (LinphoneManager.getLc().getDefaultProxyConfig() != null) {
|
|
||||||
launchEchoCancellerCalibration(true);
|
|
||||||
}
|
|
||||||
} else if (state == RegistrationState.RegistrationFailed) {
|
|
||||||
Toast.makeText(SetupActivity.this, getString(R.string.first_launch_bad_login_password), Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkAccount(String username, String password, String domain) {
|
public void checkAccount(String username, String password, String domain) {
|
||||||
saveCreatedAccount(username, password, domain);
|
saveCreatedAccount(username, password, domain);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue