Conferencing: transfer and new call working.

This commit is contained in:
Guillaume Beraudo 2011-09-27 10:28:51 +02:00
parent 54388a2026
commit 3ea4fdb5be
8 changed files with 271 additions and 16 deletions

View file

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:linphone="http://schemas.android.com/apk/res/linphone"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="@+id/Addresslayout">
<org.linphone.ui.AddressText android:id="@+id/SipUri"
android:background="@drawable/clavier_bg_grey" android:hint="sip:"
android:layout_width="fill_parent" android:lines="1"
android:layout_weight="0.2" android:layout_height="fill_parent"
android:padding="10px" android:maxLines="1" android:editable="@bool/allow_edit_in_dialer" />
<org.linphone.ui.EraseButton
android:layout_height="fill_parent" android:background="@drawable/clavier_bg"
android:id="@+id/Erase" android:layout_width="fill_parent"
android:layout_weight="0.8" android:textSize="20sp"
android:textStyle="bold" android:text="&lt;" android:layout_gravity="top"
android:textColor="@android:color/black" />
</LinearLayout>
<org.linphone.ui.Numpad android:id="@+id/Dialer"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_weight="4" />
<LinearLayout android:gravity="bottom"
android:layout_height="wrap_content" android:layout_width="fill_parent">
<Button android:id="@+id/AddCallButton" android:text="@string/AddCallButtonText"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:layout_weight="1" android:background="@drawable/clavier_bg" />
<Button android:id="@+id/AddCallCancelButton" android:text="@string/CancelButtonText"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:layout_weight="1" android:background="@drawable/clavier_bg" />
</LinearLayout>
</LinearLayout>

19
res/layout/uri_picker.xml Normal file
View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_frame" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabHost android:id="@android:id/tabhost" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<!--
android:padding="5dp"
-->
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent" android:layout_height="wrap_content" />
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent" android:layout_height="fill_parent" />
</LinearLayout>
</TabHost>
</FrameLayout>

View file

@ -1,6 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="uri_picking_canceled">Canceled</string>
<string name="error_adding_new_call">Error adding new call</string>
<string name="transfer_started">Transfer started</string>
<string name="status_conf_call">conf</string>
<string name="status_active_call">active</string>
<string name="state_paused">paused</string>

View file

@ -155,7 +155,7 @@ public abstract class AbstractContactPickerActivity extends Activity implements
finish();
}*/
LinphoneActivity.setAddressAndGoToDialer(number, name, photo);
((ContactPicked) getParent()).setAddressAndGoToDialer(number, name, photo);
}

View file

@ -84,6 +84,8 @@ public class ConferenceActivity extends ListActivity implements
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_TRANSFER_CALL = 2;
private void workaroundStatusBarBug() {
@ -196,11 +198,10 @@ public class ConferenceActivity extends ListActivity implements
Toast.makeText(this,
"Should now finish this activity to go back to dialer",
Toast.LENGTH_LONG).show();
// startActivityForResult(new Intent().setClass(this,
// LinphoneContactSelectorActivity.class), 0);
Intent intent = new Intent().setClass(this, UriPickerActivity.class);
intent.putExtra(UriPickerActivity.EXTRA_PICKER_TYPE, UriPickerActivity.EXTRA_PICKER_TYPE_ADD);
startActivityForResult(intent, ID_ADD_CALL);
lc().pauseAllCalls();
setResult(RESULT_OK, new Intent().putExtra(ADD_CALL, true));
finish();
break;
case R.id.conf_header:
View content = getLayoutInflater().inflate(R.layout.conf_choices_admin, null);
@ -304,9 +305,10 @@ public class ConferenceActivity extends ListActivity implements
break;
case R.id.transfer_new:
Toast.makeText(ConferenceActivity.this, "Transfer choice selected : to do, create activity to select new call", Toast.LENGTH_LONG).show();
// setResult(RESULT_OK, new Intent().putExtra(TRANSFER_TO_NEW_CALL, true));
// setResult(RESULT_OK, new Intent().putExtra(CALL_NATIVE_ID, Hacks.ptrOf(call)));
// finish();
Intent intent = new Intent().setClass(ConferenceActivity.this, UriPickerActivity.class);
intent.putExtra(UriPickerActivity.EXTRA_PICKER_TYPE, UriPickerActivity.EXTRA_PICKER_TYPE_TRANSFER);
callToTransfer = call;
startActivityForResult(intent, ID_TRANSFER_CALL);
break;
case R.id.remove_from_conference:
lc().removeFromConference(call);
@ -431,7 +433,8 @@ public class ConferenceActivity extends ListActivity implements
View removeFromConfButton = v.findViewById(R.id.remove_from_conference);
setVisibility(removeFromConfButton, false);
setVisibility(v, R.id.addVideo, !showUnhook && linphoneCalls.size() == 1);
final int numberOfCalls = linphoneCalls.size();
setVisibility(v, R.id.addVideo, !showUnhook && numberOfCalls == 1);
boolean statusPaused = state== State.Paused || state == State.PausedByRemote;
setVisibility(v, R.id.callee_status_paused, statusPaused);
@ -451,7 +454,7 @@ public class ConferenceActivity extends ListActivity implements
View content = getLayoutInflater().inflate(R.layout.conf_choices_dialog, null);
Dialog dialog = new AlertDialog.Builder(ConferenceActivity.this).setView(content).create();
OnClickListener l = new CallActionListener(call, dialog);
enableView(content, R.id.transfer_existing, l, !isInConference);
enableView(content, R.id.transfer_existing, l, !isInConference && numberOfCalls >=2);
enableView(content, R.id.transfer_new, l, !isInConference);
enableView(content, R.id.remove_from_conference, l, isInConference);
enableView(content, R.id.merge_to_conference, l, showMergeToConf);
@ -536,6 +539,35 @@ public class ConferenceActivity extends ListActivity implements
return durationDiff;
}
private LinphoneCall callToTransfer;
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode != RESULT_OK) {
callToTransfer = null;
Toast.makeText(this, R.string.uri_picking_canceled, Toast.LENGTH_LONG).show();
return;
}
String uri = data.getStringExtra(UriPickerActivity.EXTRA_CALLEE_URI);
switch (requestCode) {
case ID_ADD_CALL:
try {
lc().invite(uri);
} catch (LinphoneCoreException e) {
Log.e(e);
Toast.makeText(this, R.string.error_adding_new_call, Toast.LENGTH_LONG).show();
}
break;
case ID_TRANSFER_CALL:
lc().transferCall(callToTransfer, uri);
Toast.makeText(this, R.string.transfer_started, Toast.LENGTH_LONG).show();
break;
default:
throw new RuntimeException("unhandled request code " + requestCode);
}
}
/*
* public int compare(LinphoneCall c1, LinphoneCall c2) { if (c1 == c2)
* return 0;

View file

@ -57,11 +57,12 @@ public class HistoryActivity extends ListActivity {
super.onListItemClick(l, v, position, id);
TextView lFirstLineView = (TextView) v.findViewById(R.id.history_cell_first_line);
TextView lSecondLineView = (TextView) v.findViewById(R.id.history_cell_second_line);
ContactPicked parent = (ContactPicked) getParent();
if (lSecondLineView.getVisibility() == View.GONE) {
// no display name
LinphoneActivity.setAddressAndGoToDialer(lFirstLineView.getText().toString(), null, null);
parent.setAddressAndGoToDialer(lFirstLineView.getText().toString(), null, null);
} else {
LinphoneActivity.setAddressAndGoToDialer(
parent.setAddressAndGoToDialer(
lSecondLineView.getText().toString(),
lFirstLineView.getText().toString(),
null);

View file

@ -1,5 +1,5 @@
/*
iLinphoneActivity.java
LinphoneActivity.java
Copyright (C) 2010 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
@ -60,7 +60,7 @@ import android.widget.TextView;
import android.widget.Toast;
import android.widget.TabHost.TabSpec;
public class LinphoneActivity extends TabActivity implements SensorEventListener {
public class LinphoneActivity extends TabActivity implements SensorEventListener, ContactPicked {
public static final String DIALER_TAB = "dialer";
public static final String PREF_FIRST_LAUNCH = "pref_first_launch";
private static final int video_activity = 100;
@ -478,7 +478,7 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
builder.create().show();
}
static void setAddressAndGoToDialer(String number, String name, Uri photo) {
public void setAddressAndGoToDialer(String number, String name, Uri photo) {
DialerActivity.instance().setContactAddress(number, name, photo);
instance.gotToDialer();
}
@ -542,5 +542,8 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
}
});
}
}
interface ContactPicked {
void setAddressAndGoToDialer(String number, String name, Uri photo);
}

View file

@ -0,0 +1,159 @@
/*
LinphoneActivity.java
Copyright (C) 2010 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.mediastream.Version;
import org.linphone.ui.AddressText;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TabWidget;
import android.widget.TabHost.TabSpec;
/**
* @author Guillaume Beraudo
*/
public class UriPickerActivity extends TabActivity implements ContactPicked {
private static final String DIALER_TAB = "dialer";
public static final String EXTRA_CALLEE_NAME = "callee_name";
public static final String EXTRA_CALLEE_URI = "callee_uri";
public static final String EXTRA_CALLEE_PHOTO_URI = "callee_photo_uri";
public static final String EXTRA_PICKER_TYPE = "picker_type";
public static final String EXTRA_PICKER_TYPE_ADD = "picker_type_add";
public static final String EXTRA_PICKER_TYPE_TRANSFER = "picker_type_transfer";
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
fillTabHost();
}
private synchronized void fillTabHost() {
if (((TabWidget) findViewById(android.R.id.tabs)).getChildCount() != 0) return;
startActivityInTab("history",
new Intent().setClass(this, HistoryActivity.class),
R.string.tab_history, R.drawable.history_orange);
startActivityInTab(DIALER_TAB,
new Intent().setClass(this, DialerActivity.class).setData(getIntent().getData())
.putExtra(EXTRA_PICKER_TYPE, getIntent().getStringExtra(EXTRA_PICKER_TYPE)),
R.string.tab_dialer, R.drawable.dialer_orange);
startActivityInTab("contact",
new Intent().setClass(this, Version.sdkAboveOrEqual(5) ?
ContactPickerActivityNew.class : ContactPickerActivityOld.class),
R.string.tab_contact, R.drawable.contact_orange);
gotToDialer();
}
private void gotToDialer() {
getTabHost().setCurrentTabByTag(DIALER_TAB);
}
private void startActivityInTab(String tag, Intent intent, int indicatorId, int drawableId) {
Drawable tabDrawable = getResources().getDrawable(drawableId);
TabSpec spec = getTabHost().newTabSpec(tag)
.setIndicator(getString(indicatorId), tabDrawable)
.setContent(intent);
getTabHost().addTab(spec);
}
void terminate(String number, String name, Uri photo) {
Intent intent = new Intent()
.putExtra(EXTRA_CALLEE_NAME, name)
.putExtra(EXTRA_CALLEE_URI, number)
.putExtra(EXTRA_CALLEE_PHOTO_URI, photo);
setResult(Activity.RESULT_OK, intent);
finish();
}
public static class DialerActivity extends Activity implements OnClickListener {
private AddressText mAddress;
private Button addButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.simplified_dialer);
mAddress = (AddressText) findViewById(R.id.SipUri);
addButton = (Button) findViewById(R.id.AddCallButton);
addButton.setOnClickListener(this);
String type = getIntent().getStringExtra(EXTRA_PICKER_TYPE);
if (EXTRA_PICKER_TYPE_ADD.equals(type)) {
addButton.setText(getString(R.string.AddCallButtonText));
} else if (EXTRA_PICKER_TYPE_TRANSFER.equals(type)) {
addButton.setText(getString(R.string.TransferCallButtonText));
} else {
throw new RuntimeException("unknown type");
}
findViewById(R.id.AddCallCancelButton).setOnClickListener(this);
super.onCreate(savedInstanceState);
}
public void setContactAddress(String number, String name, Uri photo) {
mAddress.setText(number);
mAddress.setDisplayedName(name);
mAddress.setPictureUri(photo);
}
@Override
public void onClick(View v) {
if (v == addButton) {
UriPickerActivity parent = (UriPickerActivity) getParent();
parent.terminate(mAddress.getText().toString(), mAddress.getDisplayedName(), mAddress.getPictureUri());
} else {
// propagate finish to parent through finishFromChild
finish();
}
}
}
public void setAddressAndGoToDialer(String number, String name, Uri photo) {
DialerActivity dialer = (DialerActivity) getLocalActivityManager().getActivity(DIALER_TAB);
dialer.setContactAddress(number, name, photo);
gotToDialer();
}
}