Enhance conference activity style + permute calls.

This commit is contained in:
Guillaume Beraudo 2011-10-07 09:52:59 +02:00
parent 5965b1b33c
commit 9f1ee3f868
12 changed files with 120 additions and 56 deletions

View file

@ -61,7 +61,7 @@
</intent-filter>
</activity>
<activity android:name="org.linphone.ConferenceActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:theme="@android:style/Theme.NoTitleBar"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

BIN
res/drawable/numpad_big.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
res/drawable/plus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

@ -7,35 +7,36 @@
android:paddingRight="8dp">
<LinearLayout android:id="@+id/conf_header" android:layout_alignParentTop="true"
<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_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"
android:drawableTop="@drawable/conf_merge"
android:text="@string/conf_simple_merge_bt_txt"/>
<Button android:id="@+id/conf_simple_transfer" style="@style/conf_icon_text_button"
android:drawableTop="@drawable/conf_transfer"
android:text="@string/conf_simple_transfer_bt_txt" />
</LinearLayout>
<LinearLayout android:id="@+id/conf_header" android:layout_below="@id/conf_control_buttons"
android:orientation="vertical" android:layout_marginBottom="10dip"
android:layout_width="fill_parent" android:layout_height="wrap_content" >
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_alignWithParentIfMissing="true">
<TextView android:text="@string/conf_text_you_host_a_conference"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:gravity="center"/>
<!-- <TextView android:id="@+id/conf_self_attending"-->
<!-- android:layout_width="fill_parent" android:layout_height="wrap_content"/>-->
</LinearLayout>
<LinearLayout android:id="@+id/conf_bottom_row" android:layout_alignParentBottom="true"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<Button android:text="@string/AddCallButtonText" android:id="@+id/addCall"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<org.linphone.ui.HangCallButton android:id="@+id/incallHang" android:layout_width="0dip" android:layout_height="wrap_content"
android:src="@drawable/mini_stopcall_red" android:layout_weight="1" />
<Button android:id="@+id/incallNumpadShow" android:text="@string/show_send_dtmfs_button"
android:layout_width="wrap_content" android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout android:id="@+id/conf_menu_row"
android:layout_above="@id/conf_bottom_row"
<LinearLayout android:id="@+id/conf_speaker_mic_row"
android:layout_alignParentBottom="true"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ToggleButton android:id="@+id/toggleMuteMic" style="@style/conf_toggle_button"
android:textOn="@string/mutemic_button_txt" android:textOff="@string/mutemic_button_txt" />
@ -46,15 +47,20 @@
android:visibility="gone"/>
</LinearLayout>
<LinearLayout android:id="@+id/conf_simple_actions" android:visibility="visible"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_above="@id/conf_menu_row"
android:layout_centerInParent="true">
<Button android:id="@+id/conf_simple_merge" android:text="@string/conf_simple_merge" android:visibility="gone"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<LinearLayout android:id="@+id/conf_terminate_row"
android:layout_above="@id/conf_speaker_mic_row"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<Button android:text="@string/AddCallButtonText" android:id="@+id/addCall"
style="@style/conf_icon_text_button" android:drawableTop="@drawable/plus" />
<Button android:id="@+id/incallHang" style="@style/conf_icon_text_button"
android:drawableTop="@drawable/stopcall_red" android:text="@string/hangup"/>
<Button android:id="@+id/incallNumpadShow" style="@style/conf_icon_text_button"
android:text="@string/show_send_dtmfs_button" android:drawableTop="@drawable/numpad_big" />
</LinearLayout>
<FrameLayout android:id="@+id/incall_picture_box" android:layout_above="@id/conf_simple_actions"
<FrameLayout android:id="@+id/incall_picture_box" android:layout_above="@id/conf_terminate_row"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_centerInParent="true">
<ImageView android:id="@+id/incall_picture" android:visibility="gone"

View file

@ -5,6 +5,8 @@
<item name="android:layout_height">fill_parent</item>
<item name="android:layout_weight">1</item>
<item name="android:gravity">fill_vertical</item>
<item name="android:singleLine">true</item>
<item name="android:ellipsize">marquee</item>
</style>
<style name="callee_address" parent="@android:style/TextAppearance.Medium">

12
res/values/conf_style.xml Normal file
View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="conf_icon_text_button" parent="@android:style/Widget.Button">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">0dip</item>
<item name="android:layout_weight">1</item>
<item name="android:gravity">bottom|center_horizontal</item>
<item name="android:paddingLeft">15sp</item>
<item name="android:paddingRight">15sp</item>
</style>
</resources>

View file

@ -41,8 +41,11 @@
<string name="conf_choice_remove_from_conference">Remove from the conference</string>
<string name="conf_choice_terminate">Terminate</string>
<string name="conf_simple_merge">Merge calls</string>
<string name="hangup">Hang up</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>
<string name="conf_simple_no_current_call">No active call</string>
<string name="show_send_dtmfs_button">DTMFs</string>
<string name="conf_text_you_host_a_conference">You host a conference</string>

View file

@ -76,9 +76,8 @@ public class ConferenceActivity extends ListActivity implements
return LinphoneManager.getLc();
}
@SuppressWarnings("unchecked")
protected List<LinphoneCall> getInitialCalls() {
return lc().getCalls();
return LinphoneUtils.getLinphoneCalls(lc());
}
// End override to test block
@ -92,7 +91,10 @@ public class ConferenceActivity extends ListActivity implements
@SuppressWarnings("unused")
private void workaroundStatusBarBug() {
// call from onCreate to get a clean display on full screen no icons
// otherwise the upper side of the activity may be corrupted
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
@ -114,30 +116,33 @@ public class ConferenceActivity extends ListActivity implements
confHeaderView.setOnClickListener(this);
findViewById(R.id.addCall).setOnClickListener(this);
findViewById(R.id.incallHang).setOnClickListener(this);
findViewById(R.id.incallNumpadShow).setOnClickListener(this);
findViewById(R.id.conf_simple_merge).setOnClickListener(this);
findViewById(R.id.conf_simple_transfer).setOnClickListener(this);
findViewById(R.id.conf_simple_permute).setOnClickListener(this);
findViewById(R.id.toggleMuteMic).setOnClickListener(this);
findViewById(R.id.toggleSpeaker).setOnClickListener(this);
waitHelper = new LinphoneManagerWaitHelper(this, this);
waitHelper.doManagerDependentOnCreate();
workaroundStatusBarBug();
// workaroundStatusBarBug();
}
@Override
public void onCreateWhenManagerReady() {
List<LinphoneCall> calls = getInitialCalls();
setListAdapter(new CalleeListAdapter(calls));
findViewById(R.id.incallHang).setOnClickListener(this);
}
@Override
public void onResumeWhenManagerReady() {
registerLinphoneListener(true);
updateCalleeImage();
updateConfState();
updateMergeButtonState();
updateSimpleControlButtons();
}
@Override
@ -251,6 +256,7 @@ public class ConferenceActivity extends ListActivity implements
intent.putExtra(UriPickerActivity.EXTRA_PICKER_TYPE, UriPickerActivity.EXTRA_PICKER_TYPE_ADD);
startActivityForResult(intent, ID_ADD_CALL);
pauseCurrentCallOrLeaveConference();
updateConfState();
break;
case R.id.conf_header:
View content = getLayoutInflater().inflate(R.layout.conf_choices_admin, null);
@ -261,12 +267,15 @@ public class ConferenceActivity extends ListActivity implements
switch (v.getId()) {
case R.id.conf_add_all_to_conference_button:
lc().addAllToConference();
updateConfState();
break;
case R.id.conf_enter_button:
lc().enterConference();
updateConfState();
break;
case R.id.conf_leave_button:
lc().leaveConference();
updateConfState();
break;
case R.id.conf_terminate_button:
lc().terminateConference();
@ -294,8 +303,27 @@ public class ConferenceActivity extends ListActivity implements
showDialog(numpad_dialog_id);
break;
case R.id.conf_simple_merge:
findViewById(R.id.conf_control_buttons).setVisibility(GONE);
lc().addAllToConference();
break;
case R.id.conf_simple_transfer:
findViewById(R.id.conf_control_buttons).setVisibility(GONE);
LinphoneCall tCall = lc().getCurrentCall();
if (tCall != null) {
prepareForTransferingExistingCall(tCall);
} else {
Toast.makeText(this, R.string.conf_simple_no_current_call, Toast.LENGTH_SHORT).show();
}
break;
case R.id.conf_simple_permute:
findViewById(R.id.conf_control_buttons).setVisibility(GONE);
for (LinphoneCall call : LinphoneUtils.getLinphoneCalls(lc())) {
if (State.Paused == call.getState()) {
lc().resumeCall(call);
break;
}
}
break;
case R.id.toggleMuteMic:
lc().muteMic(((ToggleButton) v).isChecked());
break;
@ -312,6 +340,23 @@ public class ConferenceActivity extends ListActivity implements
}
private void prepareForTransferingExistingCall(final LinphoneCall call) {
final List<LinphoneCall> existingCalls = LinphoneUtils.getLinphoneCalls(lc());
existingCalls.remove(call);
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().transferCallToAnother(call, existingCalls.get(which));
}
};
new AlertDialog.Builder(ConferenceActivity.this).setAdapter(adapter, l).create().show();
}
private class CallActionListener implements OnClickListener {
private LinphoneCall call;
private Dialog dialog;
@ -344,20 +389,7 @@ public class ConferenceActivity extends ListActivity implements
}
break;
case R.id.transfer_existing:
@SuppressWarnings("unchecked") final List<LinphoneCall> existingCalls = lc().getCalls();
existingCalls.remove(call);
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().transferCallToAnother(call, existingCalls.get(which));
}
};
new AlertDialog.Builder(ConferenceActivity.this).setAdapter(adapter, l).create().show();
prepareForTransferingExistingCall(call);
break;
case R.id.transfer_new:
Intent intent = new Intent().setClass(ConferenceActivity.this, UriPickerActivity.class);
@ -429,6 +461,7 @@ public class ConferenceActivity extends ListActivity implements
}
public View getView(int position, View v, ViewGroup parent) {
Log.i("ConferenceActivity.getView(",position,") out of ", linphoneCalls.size());
if (v == null) {
if (Version.sdkAboveOrEqual(Version.API06_ECLAIR_20)) {
v = getLayoutInflater().inflate(R.layout.conf_callee, null);
@ -542,7 +575,7 @@ public class ConferenceActivity extends ListActivity implements
ImageView pictureView = (ImageView) v.findViewById(R.id.picture);
if (numberOfCalls != 1) {
// May be greatly sped up using a drawable cache
Uri uri = LinphoneUtils.findUriPictureOfContactAndSetDisplayName(call.getRemoteAddress(), getContentResolver());
Uri uri = LinphoneUtils.findUriPictureOfContactAndSetDisplayName(address, getContentResolver());
LinphoneUtils.setImagePictureFromUri(ConferenceActivity.this, pictureView, uri, R.drawable.unknown_person);
pictureView.setVisibility(VISIBLE);
} else {
@ -571,13 +604,14 @@ public class ConferenceActivity extends ListActivity implements
private Handler mHandler = new Handler();
private void updateMergeButtonState() {
private void updateSimpleControlButtons() {
LinphoneCall activeCall = lc().getCurrentCall();
View controlLayout = findViewById(R.id.conf_control_buttons);
int callNb = lc().getCallsNb();
int confSize = lc().getConferenceSize();
if (lc().isInConference()) confSize--;
boolean showSimpleActions = callNb >= 2 && confSize != callNb;
findViewById(R.id.conf_simple_merge).setVisibility(showSimpleActions ? VISIBLE : GONE);
boolean hide = activeCall == null || callNb !=2 || lc().getConferenceSize() > 0;
controlLayout.setVisibility(hide ? GONE : VISIBLE);
}
public void onCallStateChanged(final LinphoneCall call, final State state,
final String message) {
final String stateStr = call + " " + state.toString();
@ -586,7 +620,7 @@ public class ConferenceActivity extends ListActivity implements
public void run() {
CalleeListAdapter adapter = (CalleeListAdapter) getListAdapter();
Log.d("ConferenceActivity applying state ",stateStr);
updateMergeButtonState();
updateSimpleControlButtons();
updateCalleeImage();
if (state == State.IncomingReceived || state == State.OutgoingRinging) {
if (!adapter.linphoneCalls.contains(call)) {

View file

@ -22,8 +22,11 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCore;
import org.linphone.core.Log;
import org.linphone.mediastream.Version;
import org.linphone.mediastream.video.capture.hwconf.Hacks;
@ -124,5 +127,9 @@ public final class LinphoneUtils {
}
}
@SuppressWarnings("unchecked")
public static final List<LinphoneCall> getLinphoneCalls(LinphoneCore lc) {
return (List<LinphoneCall>) lc.getCalls();
}
}

View file

@ -522,12 +522,12 @@ class LinphoneCoreImpl implements LinphoneCore {
public synchronized void terminateAllCalls() {
terminateAllCalls(nativePtr);
}
private native long getCall(long nativePtr, int position);
private native Object getCall(long nativePtr, int position);
@SuppressWarnings("unchecked") public synchronized List getCalls() {
int size = getCallsNb(nativePtr);
List<LinphoneCall> calls = new ArrayList<LinphoneCall>(size);
for (int i=0; i < size; i++) {
calls.add(new LinphoneCallImpl(getCall(nativePtr, i)));
calls.add((LinphoneCall)getCall(nativePtr, i));
}
return calls;
}

@ -1 +1 @@
Subproject commit b7dacbd01a6a9f84560033413f000597f469a718
Subproject commit 490945660d975abd2520f92a95ef781b1eaff7e3