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

View file

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

View file

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

View file

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

View file

@ -241,5 +241,33 @@ public final class LinphoneUtils {
public static int pixelsToDpi(Resources res, int pixels) { public static int pixelsToDpi(Resources res, int pixels) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) pixels, res.getDisplayMetrics()); 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;
}
} }