Fixed toast messages on outgoing call error
This commit is contained in:
parent
eafeeaffce
commit
d603eb25ec
3 changed files with 42 additions and 34 deletions
|
@ -30,6 +30,7 @@ import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCoreException;
|
import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneCoreListenerBase;
|
import org.linphone.core.LinphoneCoreListenerBase;
|
||||||
import org.linphone.core.LinphonePlayer;
|
import org.linphone.core.LinphonePlayer;
|
||||||
|
import org.linphone.core.Reason;
|
||||||
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;
|
||||||
import org.linphone.ui.Numpad;
|
import org.linphone.ui.Numpad;
|
||||||
|
@ -180,18 +181,14 @@ public class CallActivity extends Activity implements OnClickListener, SensorEve
|
||||||
if (state == State.IncomingReceived) {
|
if (state == State.IncomingReceived) {
|
||||||
startIncomingCallActivity();
|
startIncomingCallActivity();
|
||||||
return;
|
return;
|
||||||
}
|
} else if (state == State.Paused || state == State.PausedByRemote || state == State.Pausing) {
|
||||||
|
|
||||||
if (state == State.Paused || state == State.PausedByRemote || state == State.Pausing) {
|
|
||||||
if(LinphoneManager.getLc().getCurrentCall() != null) {
|
if(LinphoneManager.getLc().getCurrentCall() != null) {
|
||||||
enabledVideoButton(false);
|
enabledVideoButton(false);
|
||||||
}
|
}
|
||||||
if(isVideoEnabled(call)){
|
if(isVideoEnabled(call)){
|
||||||
showAudioView();
|
showAudioView();
|
||||||
}
|
}
|
||||||
}
|
} else if (state == State.Resuming) {
|
||||||
|
|
||||||
if (state == State.Resuming) {
|
|
||||||
if(LinphonePreferences.instance().isVideoEnabled()){
|
if(LinphonePreferences.instance().isVideoEnabled()){
|
||||||
status.refreshStatusItems(call, isVideoEnabled(call));
|
status.refreshStatusItems(call, isVideoEnabled(call));
|
||||||
if(call.getCurrentParamsCopy().getVideoEnabled()){
|
if(call.getCurrentParamsCopy().getVideoEnabled()){
|
||||||
|
@ -201,9 +198,7 @@ public class CallActivity extends Activity implements OnClickListener, SensorEve
|
||||||
if(LinphoneManager.getLc().getCurrentCall() != null) {
|
if(LinphoneManager.getLc().getCurrentCall() != null) {
|
||||||
enabledVideoButton(true);
|
enabledVideoButton(true);
|
||||||
}
|
}
|
||||||
}
|
} else if (state == State.StreamsRunning) {
|
||||||
|
|
||||||
if (state == State.StreamsRunning) {
|
|
||||||
switchVideo(isVideoEnabled(call));
|
switchVideo(isVideoEnabled(call));
|
||||||
enableAndRefreshInCallActions();
|
enableAndRefreshInCallActions();
|
||||||
|
|
||||||
|
@ -211,9 +206,7 @@ public class CallActivity extends Activity implements OnClickListener, SensorEve
|
||||||
videoProgress.setVisibility(View.GONE);
|
videoProgress.setVisibility(View.GONE);
|
||||||
status.refreshStatusItems(call, isVideoEnabled(call));
|
status.refreshStatusItems(call, isVideoEnabled(call));
|
||||||
}
|
}
|
||||||
}
|
} else if (state == State.CallUpdatedByRemote) {
|
||||||
|
|
||||||
if (state == State.CallUpdatedByRemote) {
|
|
||||||
// If the correspondent proposes video while audio call
|
// If the correspondent proposes video while audio call
|
||||||
boolean videoEnabled = LinphonePreferences.instance().isVideoEnabled();
|
boolean videoEnabled = LinphonePreferences.instance().isVideoEnabled();
|
||||||
if (!videoEnabled) {
|
if (!videoEnabled) {
|
||||||
|
|
|
@ -26,6 +26,7 @@ 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.LinphoneCoreListenerBase;
|
import org.linphone.core.LinphoneCoreListenerBase;
|
||||||
|
import org.linphone.core.Reason;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
@ -33,10 +34,14 @@ import android.content.pm.ActivityInfo;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class CallOutgoingActivity extends Activity implements OnClickListener{
|
public class CallOutgoingActivity extends Activity implements OnClickListener{
|
||||||
|
|
||||||
|
@ -89,15 +94,7 @@ public class CallOutgoingActivity extends Activity implements OnClickListener{
|
||||||
mListener = new LinphoneCoreListenerBase(){
|
mListener = new LinphoneCoreListenerBase(){
|
||||||
@Override
|
@Override
|
||||||
public void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) {
|
public void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) {
|
||||||
if (LinphoneManager.getLc().getCallsNb() == 0) {
|
if (call == mCall && State.Connected == state) {
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (call == mCall && State.CallEnd == state) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (call == mCall && (State.Connected == state)){
|
|
||||||
if (!LinphoneActivity.isInstanciated()) {
|
if (!LinphoneActivity.isInstanciated()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -109,6 +106,22 @@ public class CallOutgoingActivity extends Activity implements OnClickListener{
|
||||||
}
|
}
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
|
} else if (state == State.Error) {
|
||||||
|
// Convert LinphoneCore message for internalization
|
||||||
|
if (message != null && call.getErrorInfo().getReason() == Reason.Declined) {
|
||||||
|
displayCustomToast(getString(R.string.error_call_declined), Toast.LENGTH_SHORT);
|
||||||
|
} else if (message != null && call.getErrorInfo().getReason() == Reason.NotFound) {
|
||||||
|
displayCustomToast(getString(R.string.error_user_not_found), Toast.LENGTH_SHORT);
|
||||||
|
} else if (message != null && call.getErrorInfo().getReason() == Reason.Media) {
|
||||||
|
displayCustomToast(getString(R.string.error_incompatible_media), Toast.LENGTH_SHORT);
|
||||||
|
} else if (message != null) {
|
||||||
|
displayCustomToast(getString(R.string.error_unknown) + " - " + message, Toast.LENGTH_SHORT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LinphoneManager.getLc().getCallsNb() == 0) {
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -204,6 +217,20 @@ public class CallOutgoingActivity extends Activity implements OnClickListener{
|
||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void displayCustomToast(final String message, final int duration) {
|
||||||
|
LayoutInflater inflater = getLayoutInflater();
|
||||||
|
View layout = inflater.inflate(R.layout.toast, (ViewGroup) findViewById(R.id.toastRoot));
|
||||||
|
|
||||||
|
TextView toastText = (TextView) layout.findViewById(R.id.toastMessage);
|
||||||
|
toastText.setText(message);
|
||||||
|
|
||||||
|
final Toast toast = new Toast(getApplicationContext());
|
||||||
|
toast.setGravity(Gravity.CENTER, 0, 0);
|
||||||
|
toast.setDuration(duration);
|
||||||
|
toast.setView(layout);
|
||||||
|
toast.show();
|
||||||
|
}
|
||||||
|
|
||||||
private void decline() {
|
private void decline() {
|
||||||
LinphoneManager.getLc().terminateCall(mCall);
|
LinphoneManager.getLc().terminateCall(mCall);
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,16 +242,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
checkAndRequestAudioPermission(false);
|
checkAndRequestAudioPermission(false);
|
||||||
}
|
}
|
||||||
} else if (state == State.CallEnd || state == State.Error || state == State.CallReleased) {
|
} else if (state == State.CallEnd || state == State.Error || state == State.CallReleased) {
|
||||||
// Convert LinphoneCore message for internalization
|
|
||||||
if (message != null && call.getErrorInfo().getReason() == Reason.Declined) {
|
|
||||||
displayCustomToast(getString(R.string.error_call_declined), Toast.LENGTH_SHORT);
|
|
||||||
} else if (message != null && call.getErrorInfo().getReason() == Reason.NotFound) {
|
|
||||||
displayCustomToast(getString(R.string.error_user_not_found), Toast.LENGTH_SHORT);
|
|
||||||
} else if (message != null && call.getErrorInfo().getReason() == Reason.Media) {
|
|
||||||
displayCustomToast(getString(R.string.error_incompatible_media), Toast.LENGTH_SHORT);
|
|
||||||
} else if (message != null && state == State.Error) {
|
|
||||||
displayCustomToast(getString(R.string.error_unknown) + " - " + message, Toast.LENGTH_SHORT);
|
|
||||||
}
|
|
||||||
resetClassicMenuLayoutAndGoBackToCallIfStillRunning();
|
resetClassicMenuLayoutAndGoBackToCallIfStillRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -880,8 +870,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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));
|
||||||
|
|
Loading…
Reference in a new issue