Fix manager waiter API.
This commit is contained in:
parent
b52433c3c3
commit
c655746a1f
3 changed files with 37 additions and 117 deletions
|
@ -26,6 +26,7 @@ import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.linphone.LinphoneManagerWaitHelper.LinphoneManagerReadyListener;
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
|
import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
|
||||||
import org.linphone.core.LinphoneCall;
|
import org.linphone.core.LinphoneCall;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
|
@ -58,6 +59,7 @@ import android.widget.ToggleButton;
|
||||||
* @author Guillaume Beraudo
|
* @author Guillaume Beraudo
|
||||||
*/
|
*/
|
||||||
public class ConferenceActivity extends ListActivity implements
|
public class ConferenceActivity extends ListActivity implements
|
||||||
|
LinphoneManagerReadyListener,
|
||||||
LinphoneOnCallStateChangedListener, Comparator<LinphoneCall>,
|
LinphoneOnCallStateChangedListener, Comparator<LinphoneCall>,
|
||||||
OnClickListener {
|
OnClickListener {
|
||||||
|
|
||||||
|
@ -90,6 +92,7 @@ public class ConferenceActivity extends ListActivity implements
|
||||||
private static final int ID_TRANSFER_CALL = 2;
|
private static final int ID_TRANSFER_CALL = 2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void workaroundStatusBarBug() {
|
private void workaroundStatusBarBug() {
|
||||||
getWindow().setFlags(
|
getWindow().setFlags(
|
||||||
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
|
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
|
||||||
|
@ -102,6 +105,7 @@ public class ConferenceActivity extends ListActivity implements
|
||||||
lc().leaveConference();
|
lc().leaveConference();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private LinphoneManagerWaitHelper waitHelper;
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
setContentView(R.layout.conferencing);
|
setContentView(R.layout.conferencing);
|
||||||
|
@ -119,9 +123,22 @@ public class ConferenceActivity extends ListActivity implements
|
||||||
findViewById(R.id.toggleMuteMic).setOnClickListener(this);
|
findViewById(R.id.toggleMuteMic).setOnClickListener(this);
|
||||||
findViewById(R.id.toggleSpeaker).setOnClickListener(this);
|
findViewById(R.id.toggleSpeaker).setOnClickListener(this);
|
||||||
|
|
||||||
|
waitHelper = new LinphoneManagerWaitHelper(this, this);
|
||||||
|
waitHelper.doManagerDependentOnCreate();
|
||||||
|
workaroundStatusBarBug();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateWhenManagerReady() {
|
||||||
List<LinphoneCall> calls = getInitialCalls();
|
List<LinphoneCall> calls = getInitialCalls();
|
||||||
setListAdapter(new CalleeListAdapter(calls));
|
setListAdapter(new CalleeListAdapter(calls));
|
||||||
workaroundStatusBarBug();
|
}
|
||||||
|
@Override
|
||||||
|
public void onResumeWhenManagerReady() {
|
||||||
|
registerLinphoneListener(true);
|
||||||
|
updateConfState();
|
||||||
|
boolean showSimpleActions = lc().getConferenceSize() == 0 && lc().getCallsNb() == 2;
|
||||||
|
findViewById(R.id.conf_simple_merge).setVisibility(showSimpleActions ? VISIBLE : GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -136,13 +153,12 @@ public class ConferenceActivity extends ListActivity implements
|
||||||
LinphoneManager.getInstance().removeListener(this);
|
LinphoneManager.getInstance().removeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
active=true;
|
active=true;
|
||||||
registerLinphoneListener(true);
|
waitHelper.doManagerDependentOnResume();
|
||||||
updateConfState();
|
|
||||||
boolean showSimpleActions = lc().getConferenceSize() == 0 && lc().getCallsNb() == 2;
|
|
||||||
findViewById(R.id.conf_simple_merge).setVisibility(showSimpleActions ? VISIBLE : GONE);
|
|
||||||
super.onResume();
|
super.onResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,6 +605,7 @@ public class ConferenceActivity extends ListActivity implements
|
||||||
throw new RuntimeException("unhandled request code " + requestCode);
|
throw new RuntimeException("unhandled request code " + requestCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* public int compare(LinphoneCall c1, LinphoneCall c2) { if (c1 == c2)
|
* public int compare(LinphoneCall c1, LinphoneCall c2) { if (c1 == c2)
|
||||||
|
|
|
@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
package org.linphone;
|
package org.linphone;
|
||||||
|
|
||||||
import org.linphone.LinphoneManager.NewOutgoingCallUiListener;
|
import org.linphone.LinphoneManager.NewOutgoingCallUiListener;
|
||||||
|
import org.linphone.LinphoneManagerWaitHelper.LinphoneManagerReadyListener;
|
||||||
import org.linphone.LinphoneService.LinphoneGuiListener;
|
import org.linphone.LinphoneService.LinphoneGuiListener;
|
||||||
import org.linphone.core.CallDirection;
|
import org.linphone.core.CallDirection;
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
|
@ -63,7 +64,7 @@ import android.widget.Toast;
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DialerActivity extends LinphoneManagerWaitActivity implements LinphoneGuiListener, NewOutgoingCallUiListener, OnClickListener {
|
public class DialerActivity extends SoftVolumeActivity implements LinphoneGuiListener, LinphoneManagerReadyListener, NewOutgoingCallUiListener, OnClickListener {
|
||||||
|
|
||||||
private TextView mStatus;
|
private TextView mStatus;
|
||||||
private View mHangup;
|
private View mHangup;
|
||||||
|
@ -101,7 +102,7 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private LinphoneManagerWaitHelper waitHelper;
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.dialer);
|
setContentView(R.layout.dialer);
|
||||||
|
@ -151,11 +152,13 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
|
||||||
|
|
||||||
checkIfOutgoingCallIntentReceived();
|
checkIfOutgoingCallIntentReceived();
|
||||||
|
|
||||||
|
waitHelper = new LinphoneManagerWaitHelper(this, this);
|
||||||
|
waitHelper.doManagerDependentOnCreate();
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onLinphoneManagerAvailable(LinphoneManager m) {
|
public void onCreateWhenManagerReady() {
|
||||||
LinphoneCore lc = LinphoneManager.getLc();
|
LinphoneCore lc = LinphoneManager.getLc();
|
||||||
if (lc.isIncall()) {
|
if (lc.isIncall()) {
|
||||||
if(lc.isInComingInvitePending()) {
|
if(lc.isInComingInvitePending()) {
|
||||||
|
@ -344,8 +347,6 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
|
||||||
@Override
|
@Override
|
||||||
protected Dialog onCreateDialog(int id) {
|
protected Dialog onCreateDialog(int id) {
|
||||||
if (id == incomingCallDialogId) {
|
if (id == incomingCallDialogId) {
|
||||||
LinphoneAddress address = LinphoneManager.getLc().getRemoteAddress();
|
|
||||||
String from = LinphoneManager.extractIncomingRemoteName(getResources(), address);
|
|
||||||
View incomingCallView = getLayoutInflater().inflate(R.layout.incoming_call, null);
|
View incomingCallView = getLayoutInflater().inflate(R.layout.incoming_call, null);
|
||||||
|
|
||||||
final Dialog dialog = new AlertDialog.Builder(this)
|
final Dialog dialog = new AlertDialog.Builder(this)
|
||||||
|
@ -375,6 +376,8 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
|
||||||
});
|
});
|
||||||
|
|
||||||
return dialog;
|
return dialog;
|
||||||
|
} else if (id == LinphoneManagerWaitHelper.DIALOG_ID) {
|
||||||
|
return waitHelper.createWaitDialog();
|
||||||
} else {
|
} else {
|
||||||
return super.onCreateDialog(id);
|
return super.onCreateDialog(id);
|
||||||
}
|
}
|
||||||
|
@ -502,7 +505,7 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
public void onResumeWhenManagerReady() {
|
||||||
updateCallControlRow();
|
updateCallControlRow();
|
||||||
|
|
||||||
// When coming back from a video call, if the phone orientation is different
|
// When coming back from a video call, if the phone orientation is different
|
||||||
|
@ -511,9 +514,12 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
|
||||||
// and set to the to be destroyed Dialer.
|
// and set to the to be destroyed Dialer.
|
||||||
// Note1: We wait as long as possible before setting the last message.
|
// Note1: We wait as long as possible before setting the last message.
|
||||||
// Note2: Linphone service is in charge of instantiating LinphoneManager
|
// Note2: Linphone service is in charge of instantiating LinphoneManager
|
||||||
if (LinphoneService.isReady()) {
|
mStatus.setText(LinphoneManager.getInstance().getLastLcStatusMessage());
|
||||||
mStatus.setText(LinphoneManager.getInstance().getLastLcStatusMessage());
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
waitHelper.doManagerDependentOnResume();
|
||||||
super.onResume();
|
super.onResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,103 +0,0 @@
|
||||||
/*
|
|
||||||
LinphoneManagerWaitActivity.java
|
|
||||||
Copyright (C) 2011 Belledonne Communications, Grenoble, France
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
package org.linphone;
|
|
||||||
|
|
||||||
import org.linphone.core.Log;
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Activity requiring access to LinphoneManager should inherit from this class.
|
|
||||||
*
|
|
||||||
* @author Guillaume Beraudo
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public abstract class LinphoneManagerWaitActivity extends SoftVolumeActivity {
|
|
||||||
|
|
||||||
private final int waitServiceDialogId = 314159265;
|
|
||||||
private Handler mHandler = new Handler();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
if (LinphoneService.isReady()) {
|
|
||||||
onLinphoneManagerAvailable(LinphoneManager.getInstance());
|
|
||||||
} else {
|
|
||||||
showDialog(waitServiceDialogId);
|
|
||||||
thread = new ServiceWaitThread();
|
|
||||||
thread.start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ServiceWaitThread thread;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
if (thread != null) thread.interrupt();
|
|
||||||
super.onDestroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Dialog onCreateDialog(int id) {
|
|
||||||
if (id == waitServiceDialogId) {
|
|
||||||
View v = getLayoutInflater().inflate((R.layout.wait_service_dialog), null);
|
|
||||||
return new AlertDialog.Builder(this).setView(v).setCancelable(false).create();
|
|
||||||
}
|
|
||||||
return super.onCreateDialog(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void onLinphoneManagerAvailable(LinphoneManager m);
|
|
||||||
|
|
||||||
private void dismissDialogFromThread(final int id) {
|
|
||||||
mHandler.post(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
dismissDialog(id);
|
|
||||||
} catch (Throwable e) {
|
|
||||||
// Discarding exception which may be thrown if the dialog wasn't showing.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ServiceWaitThread extends Thread {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
while (!LinphoneService.isReady()) {
|
|
||||||
try {
|
|
||||||
sleep(30);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Log.e("waiting thread sleep() has been interrupted, exiting as requested");
|
|
||||||
dismissDialogFromThread(waitServiceDialogId); // FIXME, may not be the best thing to do
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onLinphoneManagerAvailable(LinphoneManager.getInstance());
|
|
||||||
dismissDialogFromThread(waitServiceDialogId);
|
|
||||||
super.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in a new issue