Simple resume button in conferencing.

This commit is contained in:
Guillaume Beraudo 2011-10-21 14:21:40 +02:00
parent 90f97a665a
commit 6bfe63cc93
8 changed files with 74 additions and 6 deletions

View file

@ -8,5 +8,5 @@
<classpathentry kind="src" path="submodules/linphone/coreapi/help/java"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View file

@ -10,6 +10,8 @@
<LinearLayout android:id="@+id/conf_control_buttons"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_alignParentTop="true">
<Button android:id="@+id/conf_simple_resume" style="@style/conf_icon_text_button"
android:drawableTop="@drawable/conf_resume" android:text="@string/conf_simple_resume_bt_txt"/>
<Button android:id="@+id/conf_simple_permute" style="@style/conf_icon_text_button"
android:drawableTop="@drawable/conf_permute" android:text="@string/conf_simple_permute_bt_txt"/>
<Button android:id="@+id/conf_simple_merge" style="@style/conf_icon_text_button"

View file

@ -48,3 +48,5 @@ ng_floorgain=0.01
[video]
size=vga
[misc]
max_calls=10

View file

@ -8,6 +8,7 @@
<string name="error_adding_new_call">Error adding new call</string>
<string name="transfer_started">Transfer initiated</string>
<string name="transfer_dialog_title">Transfer call to</string>
<string name="resume_dialog_title">Resume call</string>
<string name="skipable_error_service_not_ready">Warning: service is not ready</string>
@ -43,6 +44,7 @@
<string name="conf_choice_terminate">Terminate</string>
<string name="hangup">Hang up</string>
<string name="conf_simple_resume_bt_txt">Resume</string>
<string name="conf_simple_merge_bt_txt">Merge</string>
<string name="conf_simple_transfer_bt_txt">Transfer</string>
<string name="conf_simple_permute_bt_txt">Permute</string>

View file

@ -132,6 +132,7 @@ public class ConferenceActivity extends ListActivity implements
findViewById(R.id.incallNumpadShow).setOnClickListener(this);
findViewById(R.id.conf_simple_merge).setOnClickListener(this);
findViewById(R.id.conf_simple_resume).setOnClickListener(this);
View transferView = findViewById(R.id.conf_simple_transfer);
transferView.setOnClickListener(this);
if (!allowTransfers) {
@ -365,6 +366,10 @@ public class ConferenceActivity extends ListActivity implements
findViewById(R.id.conf_control_buttons).setVisibility(GONE);
lc().addAllToConference();
break;
case R.id.conf_simple_resume:
findViewById(R.id.conf_control_buttons).setVisibility(GONE);
handleSimpleResume();
break;
case R.id.conf_simple_transfer:
findViewById(R.id.conf_control_buttons).setVisibility(GONE);
LinphoneCall tCall = lc().getCurrentCall();
@ -399,6 +404,36 @@ public class ConferenceActivity extends ListActivity implements
}
private void handleSimpleResume() {
int nbCalls = lc().getCallsNb();
if (nbCalls == 0) {
return;
} else if (nbCalls == 1) {
// resume first one
for (LinphoneCall call : LinphoneUtils.getLinphoneCalls(lc())) {
if (call.getState() == State.Paused) {
lc().resumeCall(call);
break;
}
}
} else {
// Create a dialog for user to select
final List<LinphoneCall> existingCalls = LinphoneUtils.getLinphoneCalls(lc());
final List<String> numbers = new ArrayList<String>(existingCalls.size());
Resources r = getResources();
for(LinphoneCall c : existingCalls) {
numbers.add(LinphoneManager.extractADisplayName(r, c.getRemoteAddress()));
}
ListAdapter adapter = new ArrayAdapter<String>(ConferenceActivity.this, android.R.layout.select_dialog_item, numbers);
DialogInterface.OnClickListener l = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
lc().resumeCall(existingCalls.get(which));
}
};
new AlertDialog.Builder(ConferenceActivity.this).setTitle(R.string.resume_dialog_title).setAdapter(adapter, l).create().show();
}
}
private void prepareForTransferingExistingCall(final LinphoneCall call) {
final List<LinphoneCall> existingCalls = LinphoneUtils.getLinphoneCalls(lc());
existingCalls.remove(call);
@ -669,10 +704,27 @@ public class ConferenceActivity extends ListActivity implements
private void updateSimpleControlButtons() {
LinphoneCall activeCall = lc().getCurrentCall();
View controlLayout = findViewById(R.id.conf_control_buttons);
View control = findViewById(R.id.conf_control_buttons);
int callNb = lc().getCallsNb();
boolean hide = activeCall == null || callNb !=2 || lc().getConferenceSize() > 0;
controlLayout.setVisibility(hide ? GONE : VISIBLE);
View permute = control.findViewById(R.id.conf_simple_permute);
boolean showPermute = activeCall != null && callNb == 2;
permute.setVisibility(showPermute ? VISIBLE : GONE);
View resume = control.findViewById(R.id.conf_simple_resume);
boolean showResume = activeCall == null && LinphoneUtils.hasExistingResumeableCall(lc());
resume.setVisibility(showResume ? VISIBLE : GONE);
View merge = control.findViewById(R.id.conf_simple_merge);
boolean showMerge = callNb >= 2;
merge.setVisibility(showMerge ? VISIBLE : GONE);
View transfer = control.findViewById(R.id.conf_simple_transfer);
boolean showTransfer = callNb >=2 && activeCall != null && allowTransfers;
transfer.setVisibility(showTransfer ? VISIBLE : GONE);
boolean showControl = (showMerge || showPermute || showResume || showTransfer) || lc().getConferenceSize() > 0;
control.setVisibility(showControl ? VISIBLE : GONE);
}
private void tryToStartVideoActivity(LinphoneCall call, State state) {

View file

@ -28,6 +28,7 @@ import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCore;
import org.linphone.core.Log;
import org.linphone.core.LinphoneCall.State;
import org.linphone.mediastream.Version;
import org.linphone.mediastream.video.capture.hwconf.Hacks;
@ -131,5 +132,14 @@ public final class LinphoneUtils {
public static final List<LinphoneCall> getLinphoneCalls(LinphoneCore lc) {
return (List<LinphoneCall>) lc.getCalls();
}
public static final boolean hasExistingResumeableCall(LinphoneCore lc) {
for (LinphoneCall c : getLinphoneCalls(lc)) {
if (c.getState() == State.Paused) {
return true;
}
}
return false;
}
}

@ -1 +1 @@
Subproject commit ce927e6b891a9d9129ab50d0666f6f22f37228a1
Subproject commit 0a98b96e5c72191d42fb8727e1088db126edf005

@ -1 +1 @@
Subproject commit c6d065690599ed7993d252776f552482dbed267f
Subproject commit 2b16115ebf7e8016ce61ddfef9399137d8c7208f