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.LinphoneCoreListenerBase;
|
||||
import org.linphone.core.LinphonePlayer;
|
||||
import org.linphone.core.Reason;
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
||||
import org.linphone.ui.Numpad;
|
||||
|
@ -180,18 +181,14 @@ public class CallActivity extends Activity implements OnClickListener, SensorEve
|
|||
if (state == State.IncomingReceived) {
|
||||
startIncomingCallActivity();
|
||||
return;
|
||||
}
|
||||
|
||||
if (state == State.Paused || state == State.PausedByRemote || state == State.Pausing) {
|
||||
} else if (state == State.Paused || state == State.PausedByRemote || state == State.Pausing) {
|
||||
if(LinphoneManager.getLc().getCurrentCall() != null) {
|
||||
enabledVideoButton(false);
|
||||
}
|
||||
if(isVideoEnabled(call)){
|
||||
showAudioView();
|
||||
}
|
||||
}
|
||||
|
||||
if (state == State.Resuming) {
|
||||
} else if (state == State.Resuming) {
|
||||
if(LinphonePreferences.instance().isVideoEnabled()){
|
||||
status.refreshStatusItems(call, isVideoEnabled(call));
|
||||
if(call.getCurrentParamsCopy().getVideoEnabled()){
|
||||
|
@ -201,9 +198,7 @@ public class CallActivity extends Activity implements OnClickListener, SensorEve
|
|||
if(LinphoneManager.getLc().getCurrentCall() != null) {
|
||||
enabledVideoButton(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (state == State.StreamsRunning) {
|
||||
} else if (state == State.StreamsRunning) {
|
||||
switchVideo(isVideoEnabled(call));
|
||||
enableAndRefreshInCallActions();
|
||||
|
||||
|
@ -211,9 +206,7 @@ public class CallActivity extends Activity implements OnClickListener, SensorEve
|
|||
videoProgress.setVisibility(View.GONE);
|
||||
status.refreshStatusItems(call, isVideoEnabled(call));
|
||||
}
|
||||
}
|
||||
|
||||
if (state == State.CallUpdatedByRemote) {
|
||||
} else if (state == State.CallUpdatedByRemote) {
|
||||
// If the correspondent proposes video while audio call
|
||||
boolean videoEnabled = LinphonePreferences.instance().isVideoEnabled();
|
||||
if (!videoEnabled) {
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.linphone.core.LinphoneCall.State;
|
|||
import org.linphone.core.LinphoneCallParams;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCoreListenerBase;
|
||||
import org.linphone.core.Reason;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
import android.app.Activity;
|
||||
|
@ -33,10 +34,14 @@ import android.content.pm.ActivityInfo;
|
|||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class CallOutgoingActivity extends Activity implements OnClickListener{
|
||||
|
||||
|
@ -88,16 +93,8 @@ public class CallOutgoingActivity extends Activity implements OnClickListener{
|
|||
|
||||
mListener = new LinphoneCoreListenerBase(){
|
||||
@Override
|
||||
public void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) {
|
||||
if (LinphoneManager.getLc().getCallsNb() == 0) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
if (call == mCall && State.CallEnd == state) {
|
||||
finish();
|
||||
}
|
||||
|
||||
if (call == mCall && (State.Connected == state)){
|
||||
public void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) {
|
||||
if (call == mCall && State.Connected == state) {
|
||||
if (!LinphoneActivity.isInstanciated()) {
|
||||
return;
|
||||
}
|
||||
|
@ -109,6 +106,22 @@ public class CallOutgoingActivity extends Activity implements OnClickListener{
|
|||
}
|
||||
finish();
|
||||
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);
|
||||
}
|
||||
|
||||
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() {
|
||||
LinphoneManager.getLc().terminateCall(mCall);
|
||||
}
|
||||
|
|
|
@ -242,16 +242,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
checkAndRequestAudioPermission(false);
|
||||
}
|
||||
} 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();
|
||||
}
|
||||
|
||||
|
@ -880,8 +870,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void displayCustomToast(final String message, final int duration) {
|
||||
LayoutInflater inflater = getLayoutInflater();
|
||||
View layout = inflater.inflate(R.layout.toast, (ViewGroup) findViewById(R.id.toastRoot));
|
||||
|
|
Loading…
Reference in a new issue