Incall/conference activities handle finish by themselves

Should avoid all cases where empty activities are shown
This commit is contained in:
Guillaume Beraudo 2011-11-28 20:01:38 +01:00
parent c4a81663cf
commit ea894d9c6e
4 changed files with 17 additions and 20 deletions

View file

@ -99,21 +99,22 @@ public abstract class AbstractCalleesActivity extends ListActivity implements Li
@Override @Override
protected void onResume() { protected void onResume() {
mSpecificCalls = updateSpecificCallsList(); mSpecificCalls = updateSpecificCallsList();
if (!finishOnEmptySpecificCallsWhileResuming() || mSpecificCalls.size() != 0) { if (shouldFinishCalleeActivity()) {
finish();
} else {
setActive(true); setActive(true);
updateUI(); updateUI();
mSpeakerButton.setChecked(LinphoneManager.getInstance().isSpeakerOn()); mSpeakerButton.setChecked(LinphoneManager.getInstance().isSpeakerOn());
mMuteMicButton.setChecked(LinphoneManager.getLc().isMicMuted()); mMuteMicButton.setChecked(LinphoneManager.getLc().isMicMuted());
LinphoneManager.addListener(this); LinphoneManager.addListener(this);
LinphoneManager.startProximitySensorForActivity(this); LinphoneManager.startProximitySensorForActivity(this);
} else {
finish();
} }
super.onResume(); super.onResume();
} }
protected boolean finishOnEmptySpecificCallsWhileResuming() { // Hook
return false; protected boolean shouldFinishCalleeActivity() {
return mSpecificCalls.size() == 0;
} }
@Override @Override
@ -132,8 +133,12 @@ public abstract class AbstractCalleesActivity extends ListActivity implements Li
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
public void run() { public void run() {
mSpecificCalls = updateSpecificCallsList(); mSpecificCalls = updateSpecificCallsList();
if (shouldFinishCalleeActivity()) {
finish();
} else {
updateUI(); updateUI();
} }
}
}); });
} }

View file

@ -55,11 +55,6 @@ public class ConferenceDetailsActivity extends AbstractCalleesActivity {
return new ConfListAdapter(); return new ConfListAdapter();
} }
@Override
protected boolean finishOnEmptySpecificCallsWhileResuming() {
return true;
}
private class ConfListAdapter extends CalleeListAdapter { private class ConfListAdapter extends CalleeListAdapter {
@Override @Override
public View getView(int position, View v, ViewGroup parent) { public View getView(int position, View v, ViewGroup parent) {

View file

@ -119,7 +119,10 @@ public class IncallActivity extends AbstractCalleesActivity implements
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
} }
@Override
protected boolean shouldFinishCalleeActivity() {
return lc().getCallsNb() == 0;
}
@Override @Override
protected CalleeListAdapter createCalleeListAdapter() { protected CalleeListAdapter createCalleeListAdapter() {

View file

@ -161,8 +161,6 @@ public class LinphoneActivity extends TabActivity implements
stopService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class)); stopService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class));
} }
break; break;
case incall_activity:
break;
default: default:
break; break;
} }
@ -456,11 +454,8 @@ public class LinphoneActivity extends TabActivity implements
if (IncallActivity.active) { if (IncallActivity.active) {
return; return;
} }
startActivityForResult(new Intent().setClass( Intent intent = new Intent().setClass(this, IncallActivity.class);
LinphoneActivity.this, startActivityForResult(intent, incall_activity);
IncallActivity.class),
incall_activity);
IncallActivity.active = true;
} }
public void startIncomingCallActivity(LinphoneCall pendingCall) { public void startIncomingCallActivity(LinphoneCall pendingCall) {
@ -532,7 +527,6 @@ public class LinphoneActivity extends TabActivity implements
private void exitIncallActivity() { private void exitIncallActivity() {
finishActivity(incall_activity);
setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE); setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE);
} }