Fixes and improvements on previous migration

This commit is contained in:
Sylvain Berfini 2017-10-18 09:39:11 +02:00
parent 857c0ed130
commit 809a29c8fe
9 changed files with 127 additions and 87 deletions

View file

@ -147,10 +147,17 @@ public class CallVideoFragment extends Fragment implements OnGestureListener, On
public void switchCamera() {
try {
/*int videoDeviceId = LinphoneManager.getLc().getVideoDevice();
videoDeviceId = (videoDeviceId + 1) % AndroidCameraConfiguration.retrieveCameras().length;
LinphoneManager.getLc().setVideoDevice(videoDeviceId);*/
Log.e("TODO FIXME switchCamera");
String currentDevice = LinphoneManager.getLc().getVideoDevice();
String[] devices = LinphoneManager.getLc().getVideoDevicesList();
int index = 0;
for (String d : devices) {
if (d == currentDevice) {
break;
}
index++;
}
String newDevice = devices[(index + 1) % devices.length];
LinphoneManager.getLc().setVideoDevice(newDevice);
CallManager.getInstance().updateCall();

View file

@ -112,7 +112,7 @@ interface ChatUpdatedListener {
void onChatUpdated();
}
public class ChatFragment extends Fragment implements OnClickListener, ChatMessageListener, ContactsUpdatedListener{
public class ChatFragment extends Fragment implements OnClickListener, ChatMessageListener, ContactsUpdatedListener {
private static final int ADD_PHOTO = 1337;
private static final int MENU_DELETE_MESSAGE = 0;
private static final int MENU_PICTURE_SMALL = 2;

View file

@ -289,7 +289,7 @@ public class ContactsManager extends ContentObserver {
} else {
if (friend.getRefKey() != null) {
// Friend has a refkey and but no LinphoneContact => represents a native contact stored in db from a previous version of Linphone, remove it
//lc.removeFriend(friend); //TODO FIXME
list.removeFriend(friend);
} else {
// No refkey so it's a standalone contact
contact = new LinphoneContact();
@ -359,7 +359,9 @@ public class ContactsManager extends ContentObserver {
String id = contact.getAndroidId();
if (id != null && !nativeIds.contains(id)) {
// Has been removed since last fetch
//lc.removeFriend(contact.getFriend()); //TODO FIXME
for (FriendList list : lc.getFriendsLists()) {
list.removeFriend(contact.getFriend());
}
contacts.remove(contact);
}
}

View file

@ -30,6 +30,7 @@ import org.linphone.core.Core;
import org.linphone.core.CoreException;
import org.linphone.core.Friend;
import org.linphone.core.Friend.SubscribePolicy;
import org.linphone.core.FriendList;
import org.linphone.core.PresenceBasicStatus;
import org.linphone.core.PresenceModel;
import org.linphone.mediastream.Log;
@ -486,8 +487,11 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
}
public void deleteFriend() {
if (friend != null) {
//LinphoneManager.getLcIfManagerNotDestroyedOrNull().removeFriend(friend); //TODO FIXME
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (friend != null && lc != null) {
for (FriendList list : lc.getFriendsLists()) {
list.removeFriend(friend);
}
}
}

View file

@ -87,6 +87,7 @@ import org.linphone.core.CallStats;
import org.linphone.core.ChatMessage;
import org.linphone.core.ChatMessageListener;
import org.linphone.core.ChatRoom;
import org.linphone.core.ChatRoomListener;
import org.linphone.core.Content;
import org.linphone.core.Core;
import org.linphone.core.Core.AuthMethod;
@ -102,6 +103,7 @@ import org.linphone.core.Event;
import org.linphone.core.Friend;
import org.linphone.core.FriendList;
import org.linphone.core.InfoMessage;
import org.linphone.core.Participant;
import org.linphone.core.PresenceActivity;
import org.linphone.core.ProxyConfig;
import org.linphone.core.VersionUpdateCheckResult;
@ -153,7 +155,7 @@ import static android.media.AudioManager.STREAM_VOICE_CALL;
* Add Service Listener to react to Linphone state changes.
*
*/
public class LinphoneManager implements CoreListener, ChatMessageListener, SensorEventListener, AccountCreatorListener {
public class LinphoneManager implements CoreListener, ChatMessageListener, SensorEventListener, AccountCreatorListener, ChatRoomListener {
private static LinphoneManager instance;
private Context mServiceContext;
@ -598,15 +600,100 @@ public class LinphoneManager implements CoreListener, ChatMessageListener, Senso
private void resetCameraFromPreferences() {
boolean useFrontCam = mPrefs.useFrontCam();
/*int camId = 0;
int camId = 0;
AndroidCamera[] cameras = AndroidCameraConfiguration.retrieveCameras();
for (AndroidCamera androidCamera : cameras) {
if (androidCamera.frontFacing == useFrontCam)
camId = androidCamera.id;
}
LinphoneManager.getLc().setVideoDevice(camId);*/
// TODO FIXME
String[] devices = getLc().getVideoDevicesList();
String newDevice = devices[camId];
LinphoneManager.getLc().setVideoDevice(newDevice);
}
@Override
public void onUndecryptableMessageReceived(ChatRoom cr, ChatMessage message) {
if (mServiceContext.getResources().getBoolean(R.bool.disable_chat)) {
return;
}
final Address from = message.getFromAddress();
String to = message.getToAddress().asString();
try {
final LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(from);
if (LinphoneActivity.instance().isOnBackground()) {
if (!mServiceContext.getResources().getBoolean(R.bool.disable_chat_message_notification)) {
if (contact != null) {
LinphoneService.instance().removedNotification(to, from.asStringUriOnly(), contact.getFullName()
, getString(R.string.message_cant_be_decrypted_notif));
} else {
LinphoneService.instance().removedNotification(to, from.asStringUriOnly(), from.getUsername()
, getString(R.string.message_cant_be_decrypted_notif));
}
}
} else if (!mAreDisplayAlertMessage){
mAreDisplayAlertMessage = true;
final Dialog dialog = LinphoneActivity.instance().displayDialog(
getString(R.string.message_cant_be_decrypted).replace("%s"
, (contact != null) ? contact.getFullName() : from.getUsername()));
Button delete = (Button) dialog.findViewById(R.id.delete_button);
delete.setText(getString(R.string.call));
Button cancel = (Button) dialog.findViewById(R.id.cancel);
cancel.setText(getString(R.string.ok));
delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LinphoneManager.getInstance().newOutgoingCall(from.asStringUriOnly()
, (contact != null) ? contact.getFullName() : from.getUsername());
dialog.dismiss();
LinphoneManager.getInstance().setAreDisplayAlertMessage(false);
}
});
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
LinphoneManager.getInstance().setAreDisplayAlertMessage(false);
}
});
if(LinphoneManager.getLc().limeEnabled() == Core.LimeState.Mandatory)
dialog.show();
}
} catch (Exception e) {
Log.e(e);
}
}
@Override
public void onParticipantAdded(ChatRoom cr, Participant participant) {
}
@Override
public void onSubjectChanged(ChatRoom cr, String subject) {
}
@Override
public void onMessageReceived(ChatRoom cr, ChatMessage msg) {
}
@Override
public void onIsComposingReceived(ChatRoom cr, Address remoteAddr, boolean isComposing) {
}
@Override
public void onParticipantAdminStatusChanged(ChatRoom cr, Participant participant, boolean isAdmin) {
}
@Override
public void onParticipantRemoved(ChatRoom cr, Participant participant) {
}
public static interface AddressType {
@ -677,7 +764,7 @@ public class LinphoneManager implements CoreListener, ChatMessageListener, Senso
}
private boolean isTunnelNeeded(NetworkInfo info) {
if (info == null) {
/*if (info == null) {
Log.i("No connectivity: tunnel should be disabled");
return false;
}
@ -692,7 +779,7 @@ public class LinphoneManager implements CoreListener, ChatMessageListener, Senso
&& getString(R.string.tunnel_mode_entry_value_3G_only).equals(pref)) {
Log.i("need tunnel: 'no wifi' connection");
return true;
}
}*/ // TODO FIXME
return false;
}
@ -1255,62 +1342,6 @@ public class LinphoneManager implements CoreListener, ChatMessageListener, Senso
Log.i("Set audio mode on 'Normal'");
}
public void messageReceivedUnableToDecrypted(Core lc, ChatRoom cr,
ChatMessage message) {
//TODO FIXME
if (mServiceContext.getResources().getBoolean(R.bool.disable_chat)) {
return;
}
final Address from = message.getFromAddress();
String to = message.getToAddress().asString();
try {
final LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(from);
if (LinphoneActivity.instance().isOnBackground()) {
if (!mServiceContext.getResources().getBoolean(R.bool.disable_chat_message_notification)) {
if (contact != null) {
LinphoneService.instance().removedNotification(to, from.asStringUriOnly(), contact.getFullName()
, getString(R.string.message_cant_be_decrypted_notif));
} else {
LinphoneService.instance().removedNotification(to, from.asStringUriOnly(), from.getUsername()
, getString(R.string.message_cant_be_decrypted_notif));
}
}
} else if (!mAreDisplayAlertMessage){
mAreDisplayAlertMessage = true;
final Dialog dialog = LinphoneActivity.instance().displayDialog(
getString(R.string.message_cant_be_decrypted).replace("%s"
, (contact != null) ? contact.getFullName() : from.getUsername()));
Button delete = (Button) dialog.findViewById(R.id.delete_button);
delete.setText(getString(R.string.call));
Button cancel = (Button) dialog.findViewById(R.id.cancel);
cancel.setText(getString(R.string.ok));
delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LinphoneManager.getInstance().newOutgoingCall(from.asStringUriOnly()
, (contact != null) ? contact.getFullName() : from.getUsername());
dialog.dismiss();
LinphoneManager.getInstance().setAreDisplayAlertMessage(false);
}
});
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
LinphoneManager.getInstance().setAreDisplayAlertMessage(false);
}
});
if(LinphoneManager.getLc().limeEnabled() == Core.LimeState.Mandatory)
dialog.show();
}
} catch (Exception e) {
Log.e(e);
}
}
public void setAreDisplayAlertMessage(boolean b) {
mAreDisplayAlertMessage = b;
}
@ -1881,10 +1912,6 @@ public class LinphoneManager implements CoreListener, ChatMessageListener, Senso
}
}
@Override
public void removed(Core lc, Call call,
Address from, byte[] event) {
}
@Override
public void onTransferStateChanged(Core lc, Call call,
State new_call_state) {
@ -1893,7 +1920,7 @@ public class LinphoneManager implements CoreListener, ChatMessageListener, Senso
@Override
public void onChatRoomInstantiated(Core lc, ChatRoom cr) {
cr.setListener(this);
}
@Override

View file

@ -1235,7 +1235,9 @@ public class LinphonePreferences {
}
public void setDefaultDisplayName(String displayName) {
//getLc().setPrimaryContact(displayName, getDefaultUsername()); //TODO FIXME
Address primary = getLc().getPrimaryContactParsed();
primary.setDisplayName(displayName);
getLc().setPrimaryContact(primary.asString());
}
public String getDefaultDisplayName() {
@ -1243,7 +1245,9 @@ public class LinphonePreferences {
}
public void setDefaultUsername(String username) {
//getLc().setPrimaryContact(getDefaultDisplayName(), username); // TODO FIXME
Address primary = getLc().getPrimaryContactParsed();
primary.setUsername(username);
getLc().setPrimaryContact(primary.asString());
}
public String getDefaultUsername() {

View file

@ -200,11 +200,7 @@ public class CodecDownloaderFragment extends Fragment {
}
if (h264 != null) {
try {
LinphoneManager.getLc().enablePayloadType(h264, enable);
} catch (CoreException e) {
e.printStackTrace();
}
h264.enable(enable);
}
}
}

View file

@ -56,7 +56,7 @@ public class EchoCancellerCalibrationFragment extends Fragment implements XmlRpc
mListener = new CoreListenerStub(){
@Override
public void onEcCalibrationResult(Core lc, Core.EcCalibratorStatus status, int delay_ms, Object data) {
public void onEcCalibrationResult(Core lc, Core.EcCalibratorStatus status, int delay_ms) {
LinphoneManager.getInstance().routeAudioToReceiver();
if (mSendEcCalibrationResult) {
sendEcCalibrationResult(status, delay_ms);

View file

@ -79,8 +79,8 @@ public class LinphoneOverlay extends org.linphone.mediastream.video.display.GL2J
Call call = LinphoneManager.getLc().getCurrentCall();
CallParams callParams = call.getCurrentParams();
params.width = callParams.getReceivedVideoDefinition().width;
params.height = callParams.getReceivedVideoDefinition().height;
params.width = callParams.getReceivedVideoDefinition().getWidth();
params.height = callParams.getReceivedVideoDefinition().getHeight();
LinphoneManager.getLc().setNativeVideoWindowId(androidVideoWindowImpl);
setOnClickListener(new OnClickListener() {