Better add call, callee actions dialog, dtmf numpad.
Prevent situations where several calls use the sound resources at the same time.
This commit is contained in:
parent
6bcbe4bfc9
commit
27a25ce668
6 changed files with 69 additions and 14 deletions
|
@ -1,7 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<string name="bad_target_uri">Bad URI : %s</string>
|
<string name="not_ready_to_make_new_call">Not ready for a new call</string>
|
||||||
|
<string name="bad_target_uri">Bad contact : %s</string>
|
||||||
<string name="authenticationTokenFormat">Authentication token is %s</string>
|
<string name="authenticationTokenFormat">Authentication token is %s</string>
|
||||||
<string name="not_encrypted">Communication not encrypted</string>
|
<string name="not_encrypted">Communication not encrypted</string>
|
||||||
|
|
||||||
|
|
|
@ -92,9 +92,6 @@ public class ConferenceActivity extends ListActivity implements
|
||||||
// End override to test block
|
// End override to test block
|
||||||
|
|
||||||
private static final int numpad_dialog_id = 1;
|
private static final int numpad_dialog_id = 1;
|
||||||
public static final String ADD_CALL = "add_call";
|
|
||||||
public static final String TRANSFER_TO_NEW_CALL = "transfer_to_new_call";
|
|
||||||
public static final String CALL_NATIVE_ID = "call_native_id";
|
|
||||||
private static final int ID_ADD_CALL = 1;
|
private static final int ID_ADD_CALL = 1;
|
||||||
private static final int ID_TRANSFER_CALL = 2;
|
private static final int ID_TRANSFER_CALL = 2;
|
||||||
|
|
||||||
|
@ -170,6 +167,8 @@ public class ConferenceActivity extends ListActivity implements
|
||||||
updateCalleeImage();
|
updateCalleeImage();
|
||||||
updateConfState();
|
updateConfState();
|
||||||
updateSimpleControlButtons();
|
updateSimpleControlButtons();
|
||||||
|
updateSoundLock();
|
||||||
|
updateDtmfButton();
|
||||||
CalleeListAdapter adapter = (CalleeListAdapter) getListAdapter();
|
CalleeListAdapter adapter = (CalleeListAdapter) getListAdapter();
|
||||||
if (adapter.linphoneCalls.size() != lc().getCallsNb()) {
|
if (adapter.linphoneCalls.size() != lc().getCallsNb()) {
|
||||||
adapter.linphoneCalls.clear();
|
adapter.linphoneCalls.clear();
|
||||||
|
@ -180,9 +179,7 @@ public class ConferenceActivity extends ListActivity implements
|
||||||
mSpeakerButton.setChecked(LinphoneManager.getInstance().isSpeakerOn());
|
mSpeakerButton.setChecked(LinphoneManager.getInstance().isSpeakerOn());
|
||||||
mMuteMicButton.setChecked(LinphoneManager.getLc().isMicMuted());
|
mMuteMicButton.setChecked(LinphoneManager.getLc().isMicMuted());
|
||||||
|
|
||||||
if (multipleCallsLimit > 0) {
|
|
||||||
updateAddCallButton();
|
updateAddCallButton();
|
||||||
}
|
|
||||||
|
|
||||||
LinphoneCall currentCall = LinphoneManager.getLc().getCurrentCall();
|
LinphoneCall currentCall = LinphoneManager.getLc().getCurrentCall();
|
||||||
if (currentCall != null) {
|
if (currentCall != null) {
|
||||||
|
@ -190,11 +187,27 @@ public class ConferenceActivity extends ListActivity implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAddCallButton() {
|
private void updateSoundLock() {
|
||||||
boolean limitReached = lc().getCallsNb() >= multipleCallsLimit;
|
boolean locked = lc().soundResourcesLocked();
|
||||||
findViewById(R.id.addCall).setVisibility(limitReached ? GONE : VISIBLE);
|
findViewById(R.id.addCall).setEnabled(!locked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateAddCallButton() {
|
||||||
|
boolean limitReached = false;
|
||||||
|
if (multipleCallsLimit > 0) {
|
||||||
|
limitReached = lc().getCallsNb() >= multipleCallsLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
int establishedCallsNb = LinphoneUtils.getRunningOrPausedCalls(lc()).size();
|
||||||
|
boolean hideButton = limitReached || establishedCallsNb == 0;
|
||||||
|
findViewById(R.id.addCall).setVisibility(hideButton? GONE : VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateDtmfButton() {
|
||||||
|
LinphoneCall currentCall = lc().getCurrentCall();
|
||||||
|
boolean enableDtmf = currentCall != null && currentCall.getState() == State.StreamsRunning;
|
||||||
|
findViewById(R.id.incallNumpadShow).setEnabled(enableDtmf);
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void onNewIntent(Intent intent) {
|
protected void onNewIntent(Intent intent) {
|
||||||
super.onNewIntent(intent);
|
super.onNewIntent(intent);
|
||||||
|
@ -303,6 +316,10 @@ public class ConferenceActivity extends ListActivity implements
|
||||||
private LinphoneCall activateCallOnReturnFromUriPicker;
|
private LinphoneCall activateCallOnReturnFromUriPicker;
|
||||||
private boolean enterConferenceOnReturnFromUriPicker;
|
private boolean enterConferenceOnReturnFromUriPicker;
|
||||||
private void openUriPicker(String pickerType, int requestCode) {
|
private void openUriPicker(String pickerType, int requestCode) {
|
||||||
|
if (lc().soundResourcesLocked()) {
|
||||||
|
Toast.makeText(this, R.string.not_ready_to_make_new_call, Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
activateCallOnReturnFromUriPicker = lc().getCurrentCall();
|
activateCallOnReturnFromUriPicker = lc().getCurrentCall();
|
||||||
enterConferenceOnReturnFromUriPicker = lc().isInConference();
|
enterConferenceOnReturnFromUriPicker = lc().isInConference();
|
||||||
pauseCurrentCallOrLeaveConference();
|
pauseCurrentCallOrLeaveConference();
|
||||||
|
@ -620,7 +637,9 @@ public class ConferenceActivity extends ListActivity implements
|
||||||
setVisibility(unhookCallButton, showUnhook);
|
setVisibility(unhookCallButton, showUnhook);
|
||||||
|
|
||||||
View terminateCallButton = v.findViewById(R.id.terminate_call);
|
View terminateCallButton = v.findViewById(R.id.terminate_call);
|
||||||
boolean showTerminate = state == State.IncomingReceived;
|
boolean showTerminate = state == State.IncomingReceived
|
||||||
|
|| state == State.OutgoingRinging || state == State.OutgoingEarlyMedia
|
||||||
|
|| state == State.OutgoingInit || state == State.OutgoingProgress;
|
||||||
setVisibility(terminateCallButton, showTerminate);
|
setVisibility(terminateCallButton, showTerminate);
|
||||||
|
|
||||||
View pauseButton = v.findViewById(R.id.pause);
|
View pauseButton = v.findViewById(R.id.pause);
|
||||||
|
@ -670,6 +689,9 @@ public class ConferenceActivity extends ListActivity implements
|
||||||
|
|
||||||
v.setOnClickListener(new OnClickListener() {
|
v.setOnClickListener(new OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
if (lc().soundResourcesLocked()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
View content = getLayoutInflater().inflate(R.layout.conf_choices_dialog, null);
|
View content = getLayoutInflater().inflate(R.layout.conf_choices_dialog, null);
|
||||||
Dialog dialog = new AlertDialog.Builder(ConferenceActivity.this).setView(content).create();
|
Dialog dialog = new AlertDialog.Builder(ConferenceActivity.this).setView(content).create();
|
||||||
OnClickListener l = new CallActionListener(call, dialog);
|
OnClickListener l = new CallActionListener(call, dialog);
|
||||||
|
@ -779,6 +801,9 @@ public class ConferenceActivity extends ListActivity implements
|
||||||
Log.d("ConferenceActivity applying state ",stateStr);
|
Log.d("ConferenceActivity applying state ",stateStr);
|
||||||
updateSimpleControlButtons();
|
updateSimpleControlButtons();
|
||||||
updateCalleeImage();
|
updateCalleeImage();
|
||||||
|
updateSoundLock();
|
||||||
|
updateAddCallButton();
|
||||||
|
updateDtmfButton();
|
||||||
if (state == State.IncomingReceived || state == State.OutgoingRinging) {
|
if (state == State.IncomingReceived || state == State.OutgoingRinging) {
|
||||||
if (!adapter.linphoneCalls.contains(call)) {
|
if (!adapter.linphoneCalls.contains(call)) {
|
||||||
adapter.linphoneCalls.add(call);
|
adapter.linphoneCalls.add(call);
|
||||||
|
@ -793,7 +818,6 @@ public class ConferenceActivity extends ListActivity implements
|
||||||
} else if (state == State.CallEnd) {
|
} else if (state == State.CallEnd) {
|
||||||
adapter.linphoneCalls.remove(call);
|
adapter.linphoneCalls.remove(call);
|
||||||
Collections.sort(adapter.linphoneCalls, ConferenceActivity.this);
|
Collections.sort(adapter.linphoneCalls, ConferenceActivity.this);
|
||||||
updateAddCallButton();
|
|
||||||
recreateActivity(adapter);
|
recreateActivity(adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -862,6 +886,12 @@ public class ConferenceActivity extends ListActivity implements
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lc().soundResourcesLocked()) {
|
||||||
|
Toast.makeText(this, R.string.not_ready_to_make_new_call, Toast.LENGTH_LONG).show();
|
||||||
|
eventuallyResumeConfOrCallOnPickerReturn(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case ID_ADD_CALL:
|
case ID_ADD_CALL:
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
|
@ -141,5 +142,16 @@ public final class LinphoneUtils {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final List<LinphoneCall> getRunningOrPausedCalls(LinphoneCore lc) {
|
||||||
|
List<LinphoneCall> foundCalls = new ArrayList<LinphoneCall>();
|
||||||
|
for (LinphoneCall call : getLinphoneCalls(lc)) {
|
||||||
|
State state = call.getState();
|
||||||
|
if (state == State.Paused || state == State.PausedByRemote || state == State.StreamsRunning) {
|
||||||
|
foundCalls.add(call);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return foundCalls;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -590,6 +590,13 @@ class LinphoneCoreImpl implements LinphoneCore {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean isMyself(String uri) {
|
public boolean isMyself(String uri) {
|
||||||
return uri.equals(getDefaultProxyConfig().getIdentity());
|
LinphoneProxyConfig lpc = getDefaultProxyConfig();
|
||||||
|
if (lpc == null) return false;
|
||||||
|
return uri.equals(lpc.getIdentity());
|
||||||
|
}
|
||||||
|
|
||||||
|
private native boolean soundResourcesLocked(long nativePtr);
|
||||||
|
public boolean soundResourcesLocked() {
|
||||||
|
return soundResourcesLocked(nativePtr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit f203f8218267fcc6e06846b19f8e432dee719397
|
Subproject commit 598bafd4a8ec6541f67fb276c6e64d21193695fa
|
|
@ -328,6 +328,11 @@ public class TestConferenceActivity extends ConferenceActivity {
|
||||||
public boolean isMyself(String uri) {
|
public boolean isMyself(String uri) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public boolean soundResourcesLocked() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue