Fix some issues

This commit is contained in:
Sylvain Berfini 2012-07-23 17:09:36 +02:00
parent 9ce3a07a46
commit 704fefc80a
5 changed files with 53 additions and 39 deletions

View file

@ -54,7 +54,7 @@
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar"
android:screenOrientation="portrait"
android:launchMode="singleInstance">
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
@ -63,7 +63,7 @@
<activity android:name="org.linphone.IncomingCallActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:launchMode="singleInstance"
android:launchMode="singleTop"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View file

@ -173,6 +173,11 @@ public class AudioCallFragment extends Fragment {
callsList.removeAllViews();
int index = 0;
if (LinphoneManager.getLc().getCallsNb() == 0) {
inCallActivity.goBackToDialer();
return;
}
for (LinphoneCall call : LinphoneManager.getLc().getCalls()) {
LinearLayout callView = (LinearLayout) inflater.inflate(R.layout.active_call, container, false);

View file

@ -77,7 +77,7 @@ public class InCallActivity extends FragmentActivity implements
if (LinphoneManager.getLc().getCallsNb() > 0) {
LinphoneCall call = LinphoneManager.getLc().getCalls()[0];
if (isCallEstablished(call)) {
if (LinphoneUtils.isCallEstablished(call)) {
enableAndRefreshInCallActions();
isVideoEnabled = call.getCurrentParamsCopy().getVideoEnabled();
}
@ -204,8 +204,7 @@ public class InCallActivity extends FragmentActivity implements
toogleSpeaker();
}
else if (id == R.id.addCall) {
setResult(Activity.RESULT_FIRST_USER);
finish();
goBackToDialer();
}
else if (id == R.id.pause) {
pause();
@ -317,7 +316,7 @@ public class InCallActivity extends FragmentActivity implements
private void pause() {
LinphoneCore lc = LinphoneManager.getLc();
LinphoneCall call = lc.getCurrentCall();
if (call != null && isCallRunning(call)) {
if (call != null && LinphoneUtils.isCallRunning(call)) {
lc.pauseCall(call);
pause.setImageResource(R.drawable.pause_on);
} else {
@ -482,32 +481,9 @@ public class InCallActivity extends FragmentActivity implements
}
}
private boolean isCallRunning(LinphoneCall call)
{
if (call == null) {
return false;
}
LinphoneCall.State state = call.getState();
return state == LinphoneCall.State.Connected ||
state == LinphoneCall.State.CallUpdated ||
state == LinphoneCall.State.CallUpdatedByRemote ||
state == LinphoneCall.State.StreamsRunning ||
state == LinphoneCall.State.Resuming;
}
private boolean isCallEstablished(LinphoneCall call) {
if (call == null) {
return false;
}
LinphoneCall.State state = call.getState();
return isCallRunning(call) ||
state == LinphoneCall.State.Paused ||
state == LinphoneCall.State.PausedByRemote ||
state == LinphoneCall.State.Pausing;
public void goBackToDialer() {
setResult(Activity.RESULT_FIRST_USER);
finish();
}
@Override

View file

@ -495,11 +495,9 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
}
@Override
public void onCallStateChanged(LinphoneCall call, State state,
String message) {
public void onCallStateChanged(LinphoneCall call, State state, String message) {
if (state == State.IncomingReceived) {
Intent intent = new Intent(this, IncomingCallActivity.class);
startActivity(intent);
startActivity(new Intent(this, IncomingCallActivity.class));
} else if (state == State.OutgoingInit) {
if (call.getCurrentParamsCopy().getVideoEnabled()) {
startVideoActivity(call);
@ -681,14 +679,21 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
updateMissedChatCount();
displayMissedCalls(LinphoneManager.getLc().getMissedCallsCount());
if (LinphoneManager.getLc().getCalls().length > 0) {
LinphoneCall call = LinphoneManager.getLc().getCalls()[0];
LinphoneCall.State callState = call.getState();
if (callState == State.IncomingReceived) {
startActivity(new Intent(this, IncomingCallActivity.class));
}
}
}
@Override
protected void onPause() {
super.onPause();
protected void onDestroy() {
chatStorage.close();
chatStorage = null;
super.onDestroy();
}
@Override

View file

@ -241,5 +241,33 @@ public final class LinphoneUtils {
public static int pixelsToDpi(Resources res, int pixels) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) pixels, res.getDisplayMetrics());
}
public static boolean isCallRunning(LinphoneCall call)
{
if (call == null) {
return false;
}
LinphoneCall.State state = call.getState();
return state == LinphoneCall.State.Connected ||
state == LinphoneCall.State.CallUpdated ||
state == LinphoneCall.State.CallUpdatedByRemote ||
state == LinphoneCall.State.StreamsRunning ||
state == LinphoneCall.State.Resuming;
}
public static boolean isCallEstablished(LinphoneCall call) {
if (call == null) {
return false;
}
LinphoneCall.State state = call.getState();
return isCallRunning(call) ||
state == LinphoneCall.State.Paused ||
state == LinphoneCall.State.PausedByRemote ||
state == LinphoneCall.State.Pausing;
}
}