Fundamental incall UI changes.

- single click for resuming/pausing call;
- long click for advanced call/conference interaction;
- terminate call action according to situation;
- conference details activity;
- cleanings.
This commit is contained in:
Guillaume Beraudo 2011-11-22 11:12:57 +01:00
parent 7ac6600fc5
commit 886bdcd28a
32 changed files with 751 additions and 1155 deletions

View file

@ -79,6 +79,12 @@
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity android:name="org.linphone.ConferenceDetailsActivity"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity android:name="org.linphone.LinphonePreferencesActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View file

@ -12,27 +12,18 @@
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:layout_centerVertical="true">
<ImageButton android:id="@+id/addVideo" android:src="@drawable/conf_video"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
android:visibility="gone"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ImageButton android:id="@+id/merge_to_conference" android:src="@drawable/conf_merge"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ImageButton android:id="@+id/remove_from_conference" android:src="@drawable/conf_remove"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ImageButton android:id="@+id/unhook_call" android:src="@drawable/conf_unhook"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ImageButton android:id="@+id/terminate_call" android:src="@drawable/conf_terminate"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ImageButton android:id="@+id/pause" android:src="@drawable/conf_pause"
android:layout_width="wrap_content" android:layout_height="wrap_content"/>
<ImageButton android:id="@+id/resume" android:src="@drawable/conf_resume"
android:layout_width="wrap_content" android:layout_height="wrap_content"/>
android:visibility="gone"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:id="@+id/callee_statuses" android:layout_toLeftOf="@id/callee_buttons"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:layout_centerVertical="true">
<TextView android:id="@+id/status_label" style="@style/callee_status" />
<ImageView android:id="@+id/callee_status_paused" style="@style/callee_status" android:src="@drawable/conf_status_paused" />
<ImageView android:id="@+id/callee_status_inconf" style="@style/callee_status" android:src="@drawable/conf_status_inconf"/>
<ImageView android:id="@+id/callee_status_paused" style="@style/callee_status" android:src="@drawable/conf_status_paused" android:visibility="gone"/>
<ImageView android:id="@+id/callee_status_secured" style="@style/callee_status" android:src="@drawable/conf_secured" android:visibility="gone"/>
<ImageView android:id="@+id/callee_status_maybe_secured" style="@style/callee_status" android:src="@drawable/conf_maybe_secured" android:visibility="gone"/>
<ImageView android:id="@+id/callee_status_not_secured" style="@style/callee_status" android:src="@drawable/conf_not_secured" android:visibility="gone"/>

View file

@ -21,24 +21,11 @@
<ImageButton android:id="@+id/merge_to_conference"
android:src="@drawable/conf_merge" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageButton android:id="@+id/remove_from_conference"
android:src="@drawable/conf_remove" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageButton android:id="@+id/unhook_call" android:src="@drawable/conf_unhook"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ImageButton android:id="@+id/terminate_call" android:src="@drawable/conf_terminate"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ImageButton android:id="@+id/pause" android:src="@drawable/conf_pause"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ImageButton android:id="@+id/resume" android:src="@drawable/conf_resume"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:id="@+id/status_label" style="@style/callee_status"
android:layout_height="fill_parent" />
<ImageView android:id="@+id/callee_status_paused" style="@style/callee_status"
android:src="@drawable/conf_status_paused" />
<ImageView android:id="@+id/callee_status_inconf" style="@style/callee_status"
android:src="@drawable/conf_status_inconf" />
<ImageView android:id="@+id/callee_status_secured" style="@style/callee_status"
android:src="@drawable/conf_secured" android:visibility="gone"/>

View file

@ -1,37 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout android:id="@+id/conf_add_all_to_conference_button"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageButton android:src="@drawable/conf_merge_all"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:text="@string/conf_choice_merge_all_to_conference" android:layout_gravity="center_vertical"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:id="@+id/conf_enter_button"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageButton android:src="@drawable/conf_resume"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:text="@string/conf_admin_choice_enter" android:layout_gravity="center_vertical"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:id="@+id/conf_leave_button"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageButton android:src="@drawable/conf_pause"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:text="@string/conf_admin_choice_leave" android:layout_gravity="center_vertical"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:id="@+id/conf_terminate_button"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageButton android:src="@drawable/conf_terminate"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:text="@string/conf_admin_choice_terminate" android:layout_gravity="center_vertical"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>

View file

@ -41,15 +41,6 @@
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:id="@+id/remove_from_conference"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageButton android:src="@drawable/conf_remove" android:clickable="false"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:text="@string/conf_choice_remove_from_conference" android:layout_gravity="center_vertical"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:id="@+id/merge_to_conference"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageButton android:src="@drawable/conf_merge" android:clickable="false"
@ -58,22 +49,6 @@
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:id="@+id/pause"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageButton android:src="@drawable/conf_pause" android:clickable="false"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:text="@string/conf_choice_pause" android:layout_gravity="center_vertical"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:id="@+id/resume"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageButton android:src="@drawable/conf_resume" android:clickable="false"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:text="@string/conf_choice_resume" android:layout_gravity="center_vertical"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:id="@+id/terminate_call"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageButton android:src="@drawable/conf_terminate" android:clickable="false"

View file

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:minHeight="60sp"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="@drawable/conf_callee_bg">
<ImageView android:id="@+id/picture" android:layout_width="wrap_content"
android:src="@drawable/unknown_person" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_centerVertical="true"
android:paddingRight="3sp"/>
<LinearLayout android:id="@+id/callee_statuses" android:layout_alignParentRight="true"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:layout_centerVertical="true">
<TextView android:id="@+id/status_label" style="@style/callee_status" />
<ImageView android:id="@+id/callee_status_paused" style="@style/callee_status" android:src="@drawable/conf_status_paused" android:visibility="gone"/>
<ImageView android:id="@+id/callee_status_secured" style="@style/callee_status" android:src="@drawable/conf_secured" android:visibility="gone"/>
<ImageView android:id="@+id/callee_status_maybe_secured" style="@style/callee_status" android:src="@drawable/conf_maybe_secured" android:visibility="gone"/>
<ImageView android:id="@+id/callee_status_not_secured" style="@style/callee_status" android:src="@drawable/conf_not_secured" android:visibility="gone"/>
</LinearLayout>
<LinearLayout
android:id="@+id/callee_buttons"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" >
<ImageButton
android:id="@+id/remove_from_conference"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/conf_remove"
android:visibility="gone" />
</LinearLayout>
<LinearLayout android:id="@+id/callee_block" android:orientation="vertical"
android:layout_toRightOf="@id/picture" android:layout_toLeftOf="@id/callee_buttons"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_centerVertical="true">
<TextView android:id="@+id/name" style="@style/callee_name" />
<TextView android:id="@+id/address" style="@style/callee_address"/>
<org.linphone.ui.IncallTimer android:id="@+id/callee_duration" style="@style/callee_name"/>
</LinearLayout>
</RelativeLayout>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout android:id="@+id/remove_from_conference"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageButton android:src="@drawable/conf_remove" android:clickable="false"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:text="@string/conf_choice_remove_from_conference" android:layout_gravity="center_vertical"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:id="@+id/terminate_call"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageButton android:src="@drawable/conf_terminate" android:clickable="false"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:text="@string/conf_choice_terminate" android:layout_gravity="center_vertical"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</ScrollView>

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="8dp"
android:paddingRight="8dp">
<ListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
android:dividerHeight="10dip"
android:divider="@android:color/transparent"
android:fadeScrollbars="false"
/>
<View android:layout_weight="1" android:layout_width="0px" android:layout_height="0px" android:visibility="invisible"/>
<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" />
<ToggleButton android:id="@+id/toggleSpeaker" style="@style/conf_toggle_button"
android:textOn="@string/speaker_button_txt" android:textOff="@string/speaker_button_txt" />
<ToggleButton android:id="@+id/toggleBluetooth" style="@style/conf_toggle_button"
android:textOn="@string/bluetooth_button_txt" android:textOff="@string/bluetooth_button_txt"
android:visibility="gone"/>
</LinearLayout>
</LinearLayout>

View file

@ -10,10 +10,6 @@
<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"
android:drawableTop="@drawable/conf_merge"
android:text="@string/conf_simple_merge_bt_txt"/>
@ -25,8 +21,10 @@
<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_alignWithParentIfMissing="true">
<TextView android:text="@string/conf_text_you_host_a_conference"
android:layout_alignWithParentIfMissing="true"
android:minHeight="60sp"
android:background="@drawable/conf_callee_selector_normal" >
<TextView android:text="@string/conf_conference" style="@style/callee_address"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:gravity="center"/>
</LinearLayout>

View file

@ -1,59 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical">
<RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:id="@+id/incallContactName" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
<org.linphone.ui.IncallTimer android:id="@+id/incallElapsedTime" android:text="Calling..." android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/incallContactName"/>
</RelativeLayout>
<View android:layout_weight="1" android:layout_width="0px" android:layout_height="0px" android:visibility="invisible"/>
<FrameLayout android:layout_gravity="center" android:layout_margin="20dip"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<TableLayout android:id="@+id/incallButtonsZone"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<TableRow>
<org.linphone.ui.MuteMicButton checked="@drawable/mic_muted" unchecked="@drawable/mic_active" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<RelativeLayout android:layout_gravity="center" ><Button android:id="@+id/incallNumpadShow" android:background="@drawable/numpad"
android:layout_width="wrap_content" android:layout_height="wrap_content"/></RelativeLayout>
<org.linphone.ui.SpeakerButton checked="@drawable/speaker_32_on" unchecked="@drawable/speaker_32_off" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
</TableRow>
<TableRow>
</TableRow>
</TableLayout>
<org.linphone.ui.Numpad android:id="@+id/incallDialer" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
</FrameLayout>
<View android:layout_weight="1" android:layout_width="0px" android:layout_height="0px" android:visibility="invisible"/>
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content">
<Button android:text="+ Add call" android:id="@+id/toggleButton4" android:width="0px" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"/>
<Button android:text="Video" android:id="@+id/toggleButton4" android:width="0px" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"/>
<Button android:text="Chat" android:id="@+id/toggleButton4" android:width="0px" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"/>
</LinearLayout>
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content">
<ToggleButton android:text="Mute" android:id="@+id/toggleButton1" android:width="0px" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"></ToggleButton>
<ToggleButton android:text="Speaker" android:id="@+id/toggleButton2" android:width="0px" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"></ToggleButton>
<ToggleButton android:text="Bluetooth" android:id="@+id/toggleButton3" android:width="0px" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"></ToggleButton>
</LinearLayout>
<!-- <org.linphone.ui.AddVideoButton android:id="@+id/AddVideo" android:src="@drawable/startvideo_green"-->
<!-- android:layout_height="wrap_content" android:layout_width="fill_parent" android:width="0px" android:layout_weight="1"/>-->
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content">
<org.linphone.ui.HangCallButton android:id="@+id/incallHang" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/stopcall_red" android:background="@drawable/clavier_bg" android:layout_weight="10" />
<Button android:text="Close numpad" android:id="@+id/incallNumpadClose"
android:visibility="gone" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:background="@drawable/clavier_bg" />
</LinearLayout>
</LinearLayout>

View file

@ -18,7 +18,7 @@
<item name="android:ellipsize">marquee</item>
</style>
<style name="callee_status">
<style name="callee_status" parent="@android:style/TextAppearance.Medium">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:gravity">center_vertical</item>

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="DialerDigit">
<style name="DialerDigit" parent="@android:style/TextAppearance.Medium">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:textColor">@android:color/black</item>

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="TextAppearance.SlidingTabNormal"
parent="@android:attr/textAppearanceMedium">
parent="@android:style/TextAppearance.Medium">
<item name="android:textColor">?android:attr/textColorTertiary</item>
<item name="android:textSize">28sp</item>
<item name="android:shadowColor">@android:color/black</item>
@ -11,7 +11,7 @@
</style>
<style name="TextAppearance.SlidingTabActive"
parent="@android:attr/textAppearanceMedium">
parent="@android:style/TextAppearance.Medium">
<item name="android:textColor">@android:color/black</item>
<item name="android:textSize">28sp</item>
</style>

View file

@ -15,7 +15,10 @@
<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="transfer_to_new_call">New call</string>
<string name="resume_dialog_title">Resume call</string>
<string name="cannot_resume_paused_by_remote_call">Cannot resume call paused by remote</string>
<string name="conf_show_details_text">Show details</string>
<string name="skipable_error_service_not_ready">Warning: service is not ready</string>
@ -58,7 +61,7 @@
<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>
<string name="conf_conference">Conference</string>
<string name="in_conf">You are part of it</string>
<string name="in_conf_leave">Go out</string>
<string name="out_conf">You are out of it</string>

View file

@ -55,7 +55,7 @@ import android.widget.AdapterView.OnItemClickListener;
* @author Guillaume Beraudo
*
*/
public abstract class AbstractContactPickerActivity extends Activity implements FilterQueryProvider {
public abstract class AbstractContactPickerActivityNew extends Activity implements FilterQueryProvider {
private ListView mContactList;
protected EditText mcontactFilter;

View file

@ -0,0 +1,252 @@
/*
ConferenceActivity.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 java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
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.ui.IncallTimer;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ListActivity;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.ToggleButton;
/**
* List participants of a conference call.
*
* @author Guillaume Beraudo
*
*/
public class ConferenceDetailsActivity extends ListActivity implements LinphoneOnCallStateChangedListener, OnClickListener {
private ConfListAdapter mListAdapter;
private List<LinphoneCall> mLinphoneCalls = Collections.emptyList();
private Handler mHandler = new Handler();
public static boolean active;
private ToggleButton mMuteMicButton;
private ToggleButton mSpeakerButton;
private Runnable mDurationUpdateRunnable;
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.conference_details_layout);
setListAdapter(mListAdapter = new ConfListAdapter());
mMuteMicButton = (ToggleButton) findViewById(R.id.toggleMuteMic);
mMuteMicButton.setOnClickListener(this);
mSpeakerButton = (ToggleButton) findViewById(R.id.toggleSpeaker);
mSpeakerButton.setOnClickListener(this);
mDurationUpdateRunnable = new Runnable() {
@Override
public void run() {
updateCallDurations();
}
};
super.onCreate(savedInstanceState);
}
@Override
protected void onResume() {
mLinphoneCalls = LinphoneUtils.getLinphoneCallsInConf(lc());
if (mLinphoneCalls.size() != 0) {
active = true;
updateUI();
mSpeakerButton.setChecked(LinphoneManager.getInstance().isSpeakerOn());
mMuteMicButton.setChecked(LinphoneManager.getLc().isMicMuted());
LinphoneManager.addListener(this);
LinphoneManager.startProximitySensorForActivity(this);
mHandler.post(mDurationUpdateRunnable);
} else {
finish();
}
super.onResume();
}
@Override
protected void onPause() {
LinphoneManager.removeListener(this);
LinphoneManager.stopProximitySensorForActivity(this);
active = false;
super.onPause();
}
@Override
public void onCallStateChanged(LinphoneCall c, State s, String m) {
mHandler.post(new Runnable() {
public void run() {
mLinphoneCalls = LinphoneUtils.getLinphoneCallsInConf(lc());
updateUI();
}
});
}
private LinphoneCore lc() {
return LinphoneManager.getLc();
}
private void updateUI() {
mCallDurationsMap.clear();
mListAdapter.notifyDataSetChanged();
}
private Map<LinphoneCall, IncallTimer> mCallDurationsMap = new HashMap<LinphoneCall, IncallTimer>();
private void updateCallDurations() {
for (LinphoneCall call : mCallDurationsMap.keySet()) {
IncallTimer timer = mCallDurationsMap.get(call);
timer.setDuration(call.getDuration());
}
if (active) mHandler.postDelayed(mDurationUpdateRunnable, 1000);
}
private class ConfListAdapter extends BaseAdapter {
public int getCount() {
return mLinphoneCalls.size();
}
public Object getItem(int position) {
return mLinphoneCalls.get(position);
}
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View v, ViewGroup parent) {
Log.i("IncallActivity.getView(",position,") out of ", mLinphoneCalls.size());
if (v == null) {
if (Version.sdkAboveOrEqual(Version.API06_ECLAIR_201)) {
v = getLayoutInflater().inflate(R.layout.conf_details_participant, null);
} else {
throw new RuntimeException("to implement");
// v = getLayoutInflater().inflate(R.layout.conf_callee_older_devices, null);
}
}
final LinphoneCall call = mLinphoneCalls.get(position);
LinphoneAddress address = call.getRemoteAddress();
String mainText = address.getDisplayName();
String complText = address.getUserName();
if (Version.sdkAboveOrEqual(Version.API05_ECLAIR_20)
&& getResources().getBoolean(R.bool.show_full_remote_address_on_incoming_call)) {
complText += "@" + address.getDomain();
}
TextView mainTextView = (TextView) v.findViewById(R.id.name);
TextView complTextView = (TextView) v.findViewById(R.id.address);
if (TextUtils.isEmpty(mainText)) {
mainTextView.setText(complText);
complTextView.setVisibility(View.GONE);
} else {
mainTextView.setText(mainText);
complTextView.setText(complText);
complTextView.setVisibility(View.VISIBLE);
}
v.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (lc().soundResourcesLocked()) {
return;
}
View content = getLayoutInflater().inflate(R.layout.conf_details_participant_choices_dialog, null);
Dialog dialog = new AlertDialog.Builder(ConferenceDetailsActivity.this).setView(content).create();
OnClickListener l = new CallActionListener(call, dialog);
enableView(content, R.id.remove_from_conference, l, true);
enableView(content, R.id.terminate_call, l, true);
dialog.show();
}
private void enableView(View root, int id, OnClickListener l, boolean enable) {
LinphoneUtils.enableView(root, id, l, enable);
}
});
ImageView pictureView = (ImageView) v.findViewById(R.id.picture);
// May be greatly sped up using a drawable cache
Uri uri = LinphoneUtils.findUriPictureOfContactAndSetDisplayName(address, getContentResolver());
LinphoneUtils.setImagePictureFromUri(ConferenceDetailsActivity.this, pictureView, uri, R.drawable.unknown_person);
mCallDurationsMap.put(call, (IncallTimer) findViewById(R.id.callee_duration));
return v;
}
}
private class CallActionListener implements OnClickListener {
private LinphoneCall call;
private Dialog dialog;
public CallActionListener(LinphoneCall call, Dialog dialog) {
this.call = call;
this.dialog = dialog;
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.terminate_call:
lc().terminateCall(call);
break;
case R.id.remove_from_conference:
lc().removeFromConference(call);
if (LinphoneUtils.countConferenceCalls(lc()) == 0) {
finish();
}
break;
default:
throw new RuntimeException("unknown id " + v.getId());
}
if (dialog != null) dialog.dismiss();
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.toggleMuteMic:
lc().muteMic(((ToggleButton) v).isChecked());
break;
case R.id.toggleSpeaker:
if (((ToggleButton) v).isChecked()) {
LinphoneManager.getInstance().routeAudioToSpeaker();
} else {
LinphoneManager.getInstance().routeAudioToReceiver();
}
break;
default:
break;
}
}
}

View file

@ -48,7 +48,7 @@ import android.text.TextUtils;
* @author Guillaume Beraudo
*
*/
public class ContactPickerActivityNew extends AbstractContactPickerActivity {
public class ContactPickerActivityNew extends AbstractContactPickerActivityNew {

View file

@ -18,7 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone;
import org.linphone.LinphoneManager.NewOutgoingCallUiListener;
import org.linphone.LinphoneService.LinphoneGuiListener;
import org.linphone.core.LinphoneCall;
import org.linphone.core.Log;
@ -49,7 +48,7 @@ import android.widget.Toast;
* </ul>
*
*/
public class DialerActivity extends Activity implements LinphoneGuiListener, NewOutgoingCallUiListener {
public class DialerActivity extends Activity implements LinphoneGuiListener {
private TextView mStatus;
private Handler mHandler;
@ -221,11 +220,6 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, New
}
}
public void onCallEncryptionChanged(LinphoneCall call, boolean encrypted, String t) {
// done in incall view
}
@Override
protected void onResume() {
// When coming back from a video call, if the phone orientation is different

View file

@ -85,7 +85,7 @@ public class FirstLoginActivity extends Activity implements OnClickListener {
LinphoneManager.getInstance().initializePayloads();
try {
LinphoneManager.getInstance().initFromConf(getApplicationContext());
LinphoneManager.getInstance().initFromConf();
} catch (Throwable e) {
Log.e(e, "Error while initializing from config in first login activity");
toast(R.string.error);;

View file

@ -51,8 +51,8 @@ import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView;
@ -69,22 +69,18 @@ public class IncallActivity extends ListActivity implements
LinphoneOnCallStateChangedListener,
LinphoneOnCallEncryptionChangedListener,
Comparator<LinphoneCall>,
OnLongClickListener,
OnClickListener {
private View confHeaderView;
static boolean active;
private boolean unMuteOnReturnFromUriPicker;
private boolean mUnMuteOnReturnFromUriPicker;
// Start Override to test block
protected LinphoneCore lc() {
return LinphoneManager.getLc();
}
protected List<LinphoneCall> getInitialCalls() {
return LinphoneUtils.getLinphoneCalls(lc());
}
// End override to test block
private static final int numpad_dialog_id = 1;
@ -93,15 +89,6 @@ public class IncallActivity 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);
}
private void pauseCurrentCallOrLeaveConference() {
LinphoneCall call = lc().getCurrentCall();
if (call != null) lc().pauseCall(call);
@ -110,41 +97,41 @@ public class IncallActivity extends ListActivity implements
private ToggleButton mMuteMicButton;
private ToggleButton mSpeakerButton;
private int multipleCallsLimit;
private boolean allowTransfers;
private View mConferenceVirtualCallee;
private int mMultipleCallsLimit;
private boolean mAllowTransfers;
private List<LinphoneCall> mNotInConfCalls = Collections.emptyList();
private CalleeListAdapter mListAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.conferencing);
setContentView(R.layout.incall_layout);
allowTransfers = getResources().getBoolean(R.bool.allow_transfers);
confHeaderView = findViewById(R.id.conf_header);
confHeaderView.setOnClickListener(this);
mAllowTransfers = getResources().getBoolean(R.bool.allow_transfers);
findViewById(R.id.addCall).setOnClickListener(this);
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) {
if (!mAllowTransfers) {
transferView.setVisibility(View.GONE);
}
findViewById(R.id.conf_simple_permute).setOnClickListener(this);
mMuteMicButton = (ToggleButton) findViewById(R.id.toggleMuteMic);
mMuteMicButton.setOnClickListener(this);
mSpeakerButton = (ToggleButton) findViewById(R.id.toggleSpeaker);
mSpeakerButton.setOnClickListener(this);
List<LinphoneCall> calls = getInitialCalls();
setListAdapter(new CalleeListAdapter(calls));
setListAdapter(mListAdapter = new CalleeListAdapter());
findViewById(R.id.incallHang).setOnClickListener(this);
multipleCallsLimit = lc().getMaxCalls();
mMultipleCallsLimit = lc().getMaxCalls();
mConferenceVirtualCallee = findViewById(R.id.conf_header);
mConferenceVirtualCallee.setOnClickListener(this);
mConferenceVirtualCallee.setOnLongClickListener(this);
// workaroundStatusBarBug();
super.onCreate(savedInstanceState);
}
@ -156,8 +143,8 @@ public class IncallActivity extends ListActivity implements
private void updateAddCallButton() {
boolean limitReached = false;
if (multipleCallsLimit > 0) {
limitReached = lc().getCallsNb() >= multipleCallsLimit;
if (mMultipleCallsLimit > 0) {
limitReached = lc().getCallsNb() >= mMultipleCallsLimit;
}
int establishedCallsNb = LinphoneUtils.getRunningOrPausedCalls(lc()).size();
@ -175,42 +162,23 @@ public class IncallActivity extends ListActivity implements
super.onNewIntent(intent);
}
protected void registerLinphoneListener(boolean register) {
if (register)
LinphoneManager.addListener(this);
else
LinphoneManager.removeListener(this);
}
@Override
protected void onResume() {
active=true;
registerLinphoneListener(true);
updateCalleeImage();
updateConfState();
updateSimpleControlButtons();
updateSoundLock();
updateDtmfButton();
CalleeListAdapter adapter = (CalleeListAdapter) getListAdapter();
if (adapter.linphoneCalls.size() != lc().getCallsNb()) {
adapter.linphoneCalls.clear();
adapter.linphoneCalls.addAll(getInitialCalls());
}
recreateActivity(adapter);
mNotInConfCalls = LinphoneUtils.getLinphoneCallsNotInConf(lc());
LinphoneManager.addListener(this);
LinphoneManager.startProximitySensorForActivity(this);
mSpeakerButton.setChecked(LinphoneManager.getInstance().isSpeakerOn());
mMuteMicButton.setChecked(LinphoneManager.getLc().isMicMuted());
updateAddCallButton();
recreateActivity();
super.onResume();
}
@Override
protected void onPause() {
active=false;
registerLinphoneListener(false);
LinphoneManager.removeListener(this);
LinphoneManager.stopProximitySensorForActivity(this);
super.onPause();
}
@ -219,7 +187,7 @@ public class IncallActivity extends ListActivity implements
ImageView view = (ImageView) findViewById(R.id.incall_picture);
LinphoneCall currentCall = lc().getCurrentCall();
if (lc().getCallsNb() != 1 || currentCall == null) {
if (currentCall == null || lc().getCallsNb() != 1) {
view.setVisibility(GONE);
return;
}
@ -231,10 +199,9 @@ public class IncallActivity extends ListActivity implements
}
private void enableView(View root, int id, OnClickListener l, boolean enable) {
View v = root.findViewById(id);
v.setVisibility(enable ? VISIBLE : GONE);
v.setOnClickListener(l);
LinphoneUtils.enableView(root, id, l, enable);
}
@Override
protected Dialog onCreateDialog(final int id) {
switch (id) {
@ -257,36 +224,6 @@ public class IncallActivity extends ListActivity implements
}
// protected void conferenceMerge(boolean hostInTheConference, LinphoneCall
// ... calls) {
// for (LinphoneCall call: calls) {
// getLc().addToConference(call, false);
// }
// getLc().enterConference(hostInTheConference);
// }
// FIXME hack; should have an event?
protected final void hackTriggerConfStateUpdate() {
updateConfState();
}
private final void updateConfState() {
if (lc().getCallsNb() == 0) {
setResult(RESULT_OK);
finish();
}
boolean inConf = lc().isInConference();
int bgColor = getResources().getColor(inConf? R.color.conf_active_bg_color : android.R.color.transparent);
confHeaderView.setBackgroundColor(bgColor);
confHeaderView.setVisibility(lc().getConferenceSize() > 0 ? VISIBLE: GONE);
// TextView v = (TextView) confHeaderView
// .findViewById(R.id.conf_self_attending);
// v.setText(inConf ? R.string.in_conf : R.string.out_conf);
}
private LinphoneCall activateCallOnReturnFromUriPicker;
private boolean enterConferenceOnReturnFromUriPicker;
private void openUriPicker(String pickerType, int requestCode) {
@ -301,57 +238,67 @@ public class IncallActivity extends ListActivity implements
intent.putExtra(UriPickerActivity.EXTRA_PICKER_TYPE, pickerType);
startActivityForResult(intent, requestCode);
if (!lc().isMicMuted()) {
unMuteOnReturnFromUriPicker = true;
mUnMuteOnReturnFromUriPicker = true;
lc().muteMic(true);
((ToggleButton) findViewById(R.id.toggleMuteMic)).setChecked(true);
}
}
@Override
public boolean onLongClick(View v) {
switch (v.getId()) {
case R.id.conf_header:
if (Version.sdkAboveOrEqual(Version.API05_ECLAIR_20)) {
LinphoneActivity.instance().startConferenceDetailsActivity();
} else {
Log.i("conference details disabled for older phones");
}
break;
default:
break;
}
return false;
}
private void enterConferenceAndUpdateUI(boolean enterConf) {
if (enterConf) {
boolean success = lc().enterConference();
if (success) {
mConferenceVirtualCallee.setBackgroundResource(R.drawable.conf_callee_active_bg);
}
} else {
lc().leaveConference();
mConferenceVirtualCallee.setBackgroundResource(R.drawable.conf_callee_bg);
}
}
private void terminateCurrentCallOrConferenceOrAll() {
LinphoneCall currentCall = lc().getCurrentCall();
if (currentCall != null) {
lc().terminateCall(currentCall);
} else if (lc().isInConference()) {
lc().terminateConference();
} else {
lc().terminateAllCalls();
}
// activity should be closed automatically by LinphoneActivity when no more calls exist
// setResult(RESULT_OK);
// finish();
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.addCall:
openUriPicker(UriPickerActivity.EXTRA_PICKER_TYPE_ADD, ID_ADD_CALL);
break;
case R.id.conf_header:
View content = getLayoutInflater().inflate(R.layout.conf_choices_admin, null);
final Dialog dialog = new AlertDialog.Builder(IncallActivity.this).setView(content).create();
boolean isInConference = lc().isInConference();
OnClickListener l = new OnClickListener() {
public void onClick(View v) {
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();
findViewById(R.id.conf_header).setVisibility(GONE);
break;
default:
break;
}
dialog.dismiss();
}
};
enableView(content, R.id.conf_enter_button, l, !isInConference);
enableView(content, R.id.conf_leave_button, l, isInConference);
content.findViewById(R.id.conf_terminate_button).setOnClickListener(l);
content.findViewById(R.id.conf_add_all_to_conference_button).setOnClickListener(l);
dialog.show();
break;
case R.id.incallHang:
lc().terminateAllCalls();
setResult(RESULT_OK);
finish();
terminateCurrentCallOrConferenceOrAll();
break;
case R.id.conf_header:
boolean enterConf = !lc().isInConference();
enterConferenceAndUpdateUI(enterConf);
break;
case R.id.incallNumpadShow:
showDialog(numpad_dialog_id);
@ -360,28 +307,15 @@ public class IncallActivity 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();
if (tCall != null) {
prepareForTransferingExistingCall(tCall);
prepareForTransferingExistingOrNewCall(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;
@ -398,48 +332,31 @@ public class IncallActivity 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>(IncallActivity.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(IncallActivity.this).setTitle(R.string.resume_dialog_title).setAdapter(adapter, l).create().show();
}
}
private void prepareForTransferingExistingCall(final LinphoneCall call) {
private void prepareForTransferingExistingOrNewCall(final LinphoneCall call) {
final List<LinphoneCall> existingCalls = LinphoneUtils.getLinphoneCalls(lc());
if (existingCalls.size() == 1) {
// Only possible choice is transfer to new call: doing it directly.
mCallToTransfer = call;
openUriPicker(UriPickerActivity.EXTRA_PICKER_TYPE_TRANSFER, ID_TRANSFER_CALL);
return;
}
existingCalls.remove(call);
final List<String> numbers = new ArrayList<String>(existingCalls.size());
final List<String> numbers = new ArrayList<String>(existingCalls.size() + 1);
Resources r = getResources();
for(LinphoneCall c : existingCalls) {
numbers.add(LinphoneManager.extractADisplayName(r, c.getRemoteAddress()));
}
numbers.add(getString(R.string.transfer_to_new_call));
ListAdapter adapter = new ArrayAdapter<String>(IncallActivity.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));
if (which == numbers.size() -1) {
// Last one is transfer to new call
mCallToTransfer = call;
openUriPicker(UriPickerActivity.EXTRA_PICKER_TYPE_TRANSFER, ID_TRANSFER_CALL);
} else {
lc().transferCallToAnother(call, existingCalls.get(which));
}
}
};
new AlertDialog.Builder(IncallActivity.this).setTitle(R.string.transfer_dialog_title).setAdapter(adapter, l).create().show();
@ -463,28 +380,12 @@ public class IncallActivity extends ListActivity implements
case R.id.terminate_call:
lc().terminateCall(call);
break;
case R.id.pause:
lc().pauseCall(call);
break;
case R.id.resume:
lc().resumeCall(call);
break;
case R.id.unhook_call:
try {
lc().acceptCall(call);
} catch (LinphoneCoreException e) {
throw new RuntimeException(e);
}
break;
case R.id.transfer_existing:
prepareForTransferingExistingCall(call);
prepareForTransferingExistingOrNewCall(call);
break;
case R.id.transfer_new:
openUriPicker(UriPickerActivity.EXTRA_PICKER_TYPE_TRANSFER, ID_TRANSFER_CALL);
callToTransfer = call;
break;
case R.id.remove_from_conference:
lc().removeFromConference(call);
mCallToTransfer = call;
break;
case R.id.addVideo:
if (!LinphoneManager.getInstance().addVideo()) {
@ -507,18 +408,12 @@ public class IncallActivity extends ListActivity implements
}
}
private class CalleeListAdapter extends BaseAdapter {
private List<LinphoneCall> linphoneCalls;
public CalleeListAdapter(List<LinphoneCall> calls) {
linphoneCalls = calls;
}
public int getCount() {
return linphoneCalls != null ? linphoneCalls.size() : 0;
return mNotInConfCalls.size();
}
public Object getItem(int position) {
return linphoneCalls.get(position);
return mNotInConfCalls.get(position);
}
public long getItemId(int position) {
@ -530,7 +425,7 @@ public class IncallActivity extends ListActivity implements
return false;
}
int count = 0;
for (LinphoneCall call : linphoneCalls) {
for (LinphoneCall call : mNotInConfCalls) {
final LinphoneCall.State state = call.getState();
boolean connectionEstablished = state == State.StreamsRunning
|| state == State.Paused
@ -544,25 +439,28 @@ public class IncallActivity extends ListActivity implements
}
private void setVisibility(View v, int id, boolean visible) {
v.findViewById(id).setVisibility(visible ? VISIBLE : GONE);
LinphoneUtils.setVisibility(v, id, visible);
}
private void setVisibility(View v, boolean visible) {
v.setVisibility(visible ? VISIBLE : GONE);
LinphoneUtils.setVisibility(v, visible);
}
private void setStatusLabel(View v, State state, boolean inConf, boolean activeOne) {
private void setStatusLabel(View v, State state, boolean activeOne) {
String statusLabel = getStateText(state);
if (activeOne)
statusLabel=getString(R.string.status_active_call);
if (inConf)
statusLabel=getString(R.string.status_conf_call);
((TextView) v.findViewById(R.id.status_label)).setText(statusLabel);
}
private boolean highlightCall(LinphoneCall call) {
final State state = call.getState();
return state == State.StreamsRunning
|| state == State.OutgoingRinging
|| state == State.OutgoingEarlyMedia
|| state == State.OutgoingInit
|| state == State.OutgoingProgress
;
}
public View getView(int position, View v, ViewGroup parent) {
Log.i("IncallActivity.getView(",position,") out of ", linphoneCalls.size());
Log.i("IncallActivity.getView(",position,") out of ", mNotInConfCalls.size());
if (v == null) {
if (Version.sdkAboveOrEqual(Version.API06_ECLAIR_201)) {
v = getLayoutInflater().inflate(R.layout.conf_callee, null);
@ -571,16 +469,12 @@ public class IncallActivity extends ListActivity implements
}
}
final LinphoneCall call = linphoneCalls.get(position);
final LinphoneCall call = mNotInConfCalls.get(position);
final LinphoneCall.State state = call.getState();
LinphoneAddress address = call.getRemoteAddress();
String mainText = address.getDisplayName();
String complText = address.getUserName();
if (Version.sdkAboveOrEqual(Version.API05_ECLAIR_20)
&& getResources().getBoolean(R.bool.show_full_remote_address_on_incoming_call)) {
complText += "@" + address.getDomain();
}
TextView mainTextView = (TextView) v.findViewById(R.id.name);
TextView complTextView = (TextView) v.findViewById(R.id.address);
if (TextUtils.isEmpty(mainText)) {
@ -592,20 +486,15 @@ public class IncallActivity extends ListActivity implements
complTextView.setVisibility(View.VISIBLE);
}
final boolean isInConference = call.isInConference();
boolean currentlyActiveCall = !isInConference
&& state == State.StreamsRunning;
setStatusLabel(v, state, isInConference, currentlyActiveCall);
boolean highlighted = highlightCall(call);
setStatusLabel(v, state, highlighted);
int bgDrawableId = R.drawable.conf_callee_selector_normal;
if (state == State.IncomingReceived) {
bgDrawableId = R.drawable.conf_callee_selector_incoming;
} else if (currentlyActiveCall) {
} else if (highlighted) {
bgDrawableId = R.drawable.conf_callee_selector_active;
} else if (isInConference) {
bgDrawableId = R.drawable.conf_callee_selector_inconf;
}
v.setBackgroundResource(bgDrawableId);
@ -613,35 +502,11 @@ public class IncallActivity extends ListActivity implements
|| state == State.Paused
|| state == State.PausedByRemote;
View confButton = v.findViewById(R.id.merge_to_conference);
final boolean showMergeToConf = !isInConference && connectionEstablished
&& aConferenceIsPossible();
final boolean showMergeToConf = connectionEstablished && aConferenceIsPossible();
setVisibility(confButton, false);
View unhookCallButton = v.findViewById(R.id.unhook_call);
boolean showUnhook = state == State.IncomingReceived;
setVisibility(unhookCallButton, showUnhook);
View terminateCallButton = v.findViewById(R.id.terminate_call);
boolean showTerminate = state == State.IncomingReceived
|| state == State.OutgoingRinging || state == State.OutgoingEarlyMedia
|| state == State.OutgoingInit || state == State.OutgoingProgress;
setVisibility(terminateCallButton, showTerminate);
View pauseButton = v.findViewById(R.id.pause);
final boolean showPause = !isInConference
&& state == State.StreamsRunning;
setVisibility(pauseButton, false);
View resumeButton = v.findViewById(R.id.resume);
final boolean showResume = !isInConference
&& state == State.Paused;
setVisibility(resumeButton, false);
View removeFromConfButton = v.findViewById(R.id.remove_from_conference);
setVisibility(removeFromConfButton, false);
final int numberOfCalls = linphoneCalls.size();
boolean showAddVideo = State.StreamsRunning == state && !isInConference
final int numberOfCalls = mNotInConfCalls.size();
boolean showAddVideo = State.StreamsRunning == state
&& Version.isVideoCapable()
&& LinphoneManager.getInstance().isVideoEnabled();
View addVideoButton = v.findViewById(R.id.addVideo);
@ -650,23 +515,15 @@ public class IncallActivity extends ListActivity implements
boolean statusPaused = state== State.Paused || state == State.PausedByRemote;
setVisibility(v, R.id.callee_status_paused, statusPaused);
setVisibility(v, R.id.callee_status_inconf, isInConference);
final OnClickListener l = new CallActionListener(call);
confButton.setOnClickListener(l);
terminateCallButton.setOnClickListener(l);
pauseButton.setOnClickListener(l);
resumeButton.setOnClickListener(l);
unhookCallButton.setOnClickListener(l);
removeFromConfButton.setOnClickListener(l);
addVideoButton.setOnClickListener(l);
String mediaEncryption = call.getCurrentParamsCopy().getMediaEncryption();
if ("none".equals(mediaEncryption)) {
boolean showUnencrypted = Version.hasZrtp();
setVisibility(v, R.id.callee_status_secured, false);
setVisibility(v, R.id.callee_status_maybe_secured, false);
setVisibility(v, R.id.callee_status_not_secured, showUnencrypted);
setVisibility(v, R.id.callee_status_not_secured, false);
} else {
boolean reallySecured = !Version.hasZrtp() || call.isAuthenticationTokenVerified();
setVisibility(v, R.id.callee_status_secured, reallySecured);
@ -674,20 +531,17 @@ public class IncallActivity extends ListActivity implements
setVisibility(v, R.id.callee_status_not_secured, false);
}
v.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
v.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View v) {
if (lc().soundResourcesLocked()) {
return;
return false;
}
View content = getLayoutInflater().inflate(R.layout.conf_choices_dialog, null);
Dialog dialog = new AlertDialog.Builder(IncallActivity.this).setView(content).create();
OnClickListener l = new CallActionListener(call, dialog);
enableView(content, R.id.transfer_existing, l, allowTransfers && !isInConference && numberOfCalls >=2);
enableView(content, R.id.transfer_new, l, allowTransfers && !isInConference);
enableView(content, R.id.remove_from_conference, l, isInConference);
enableView(content, R.id.transfer_existing, l, mAllowTransfers && numberOfCalls >=2);
enableView(content, R.id.transfer_new, l, mAllowTransfers);
enableView(content, R.id.merge_to_conference, l, showMergeToConf);
enableView(content, R.id.pause, l,!isInConference && showPause);
enableView(content, R.id.resume, l, !isInConference && showResume);
enableView(content, R.id.terminate_call, l, true);
String mediaEncryption = call.getCurrentParamsCopy().getMediaEncryption();
@ -710,6 +564,21 @@ public class IncallActivity extends ListActivity implements
}
dialog.show();
return true;
}
});
v.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
State actualState = call.getState();
if (State.StreamsRunning == actualState) {
lc().pauseCall(call);
} else if (State.Paused == actualState) {
lc().resumeCall(call);
} else if (State.PausedByRemote == actualState) {
Toast.makeText(IncallActivity.this, getString(R.string.cannot_resume_paused_by_remote_call), Toast.LENGTH_SHORT).show();
}
}
});
@ -730,14 +599,16 @@ public class IncallActivity extends ListActivity implements
private String getStateText(State state) {
int id;
if (state == State.IncomingReceived) {
id=R.string.state_incoming_received;
} else if (state == State.OutgoingRinging) {
id=R.string.state_outgoing_ringing;
if (state == State.StreamsRunning) {
id=R.string.status_active_call;
} else if (state == State.Paused) {
id=R.string.state_paused;
} else if (state == State.PausedByRemote) {
id=R.string.state_paused_by_remote;
} else if (state == State.IncomingReceived) {
id=R.string.state_incoming_received;
} else if (state == State.OutgoingRinging) {
id=R.string.state_outgoing_ringing;
} else {
return "";
}
@ -746,78 +617,56 @@ public class IncallActivity extends ListActivity implements
private Handler mHandler = new Handler();
private static int conferenceCalleesNb(LinphoneCore lc) {
int count = lc.getConferenceSize();
if (lc.isInConference()) count--;
return count;
}
private void updateSimpleControlButtons() {
LinphoneCall activeCall = lc().getCurrentCall();
View control = findViewById(R.id.conf_control_buttons);
int callNb = lc().getCallsNb();
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);
int nonConfCallsNb = LinphoneUtils.countNonConferenceCalls(lc());
View merge = control.findViewById(R.id.conf_simple_merge);
boolean showMerge = callNb >= 2 && callNb > conferenceCalleesNb(lc());
boolean showMerge = nonConfCallsNb >=2
|| (lc().getConferenceSize() > 0 && nonConfCallsNb > 0);
merge.setVisibility(showMerge ? VISIBLE : GONE);
View transfer = control.findViewById(R.id.conf_simple_transfer);
boolean showTransfer = callNb >=2 && activeCall != null && allowTransfers;
boolean showTransfer = mAllowTransfers && activeCall != null;
transfer.setVisibility(showTransfer ? VISIBLE : GONE);
boolean showControl = (showMerge || showPermute || showResume || showTransfer) || lc().getConferenceSize() > 0;
boolean showControl = showMerge || showTransfer;
control.setVisibility(showControl ? VISIBLE : GONE);
}
public void onCallStateChanged(final LinphoneCall call, final State state,
final String message) {
final String stateStr = call + " " + state.toString();
Log.d("IncallActivity received state ",stateStr);
public void onCallStateChanged(final LinphoneCall c, final State s, String m) {
mHandler.post(new Runnable() {
public void run() {
CalleeListAdapter adapter = (CalleeListAdapter) getListAdapter();
Log.d("IncallActivity applying state ",stateStr);
updateSimpleControlButtons();
updateCalleeImage();
updateSoundLock();
updateAddCallButton();
updateDtmfButton();
if (state == State.IncomingReceived || state == State.OutgoingRinging) {
if (!adapter.linphoneCalls.contains(call)) {
adapter.linphoneCalls.add(call);
Collections.sort(adapter.linphoneCalls, IncallActivity.this);
recreateActivity(adapter);
} else {
Log.e("Call should not be in the call lists : ", stateStr);
}
} else if (state == State.Paused || state == State.PausedByRemote || state == State.StreamsRunning) {
Collections.sort(adapter.linphoneCalls, IncallActivity.this);
adapter.notifyDataSetChanged();
} else if (state == State.CallEnd || state == State.Error || state == State.CallReleased) {
if (adapter.linphoneCalls.contains(call)) {
adapter.linphoneCalls.remove(call);
Collections.sort(adapter.linphoneCalls, IncallActivity.this);
recreateActivity(adapter);
}
}
updateConfState();
mNotInConfCalls = LinphoneUtils.getLinphoneCallsNotInConf(lc());
recreateActivity();
}
});
}
private void recreateActivity(CalleeListAdapter adapter) {
adapter.notifyDataSetInvalidated();
adapter.notifyDataSetChanged();
private void updateConfItem() {
boolean confExists = lc().getConferenceSize() > 0;
View confView = findViewById(R.id.conf_header);
confView.setVisibility(confExists? VISIBLE : GONE);
if (confExists) {
if (lc().isInConference()) {
confView.setBackgroundResource(R.drawable.conf_callee_selector_active);
} else {
confView.setBackgroundResource(R.drawable.conf_callee_selector_normal);
}
}
}
private void recreateActivity() {
updateSimpleControlButtons();
updateCalleeImage();
updateSoundLock();
updateAddCallButton();
updateDtmfButton();
updateConfItem();
mListAdapter.notifyDataSetChanged();
}
public int compare(LinphoneCall c1, LinphoneCall c2) {
@ -853,10 +702,10 @@ public class IncallActivity extends ListActivity implements
return true;
}
private LinphoneCall callToTransfer;
private LinphoneCall mCallToTransfer;
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (unMuteOnReturnFromUriPicker) {
if (mUnMuteOnReturnFromUriPicker) {
lc().muteMic(false);
((ToggleButton) findViewById(R.id.toggleMuteMic)).setChecked(false);
}
@ -866,7 +715,7 @@ public class IncallActivity extends ListActivity implements
uri = data.getStringExtra(UriPickerActivity.EXTRA_CALLEE_URI);
}
if (resultCode != RESULT_OK || TextUtils.isEmpty(uri)) {
callToTransfer = null;
mCallToTransfer = null;
Toast.makeText(this, R.string.uri_picking_canceled, Toast.LENGTH_LONG).show();
eventuallyResumeConfOrCallOnPickerReturn(true);
return;
@ -895,11 +744,11 @@ public class IncallActivity extends ListActivity implements
}
break;
case ID_TRANSFER_CALL:
lc().transferCall(callToTransfer, uri);
lc().transferCall(mCallToTransfer, uri);
// don't re-enter conference if call to transfer from conference
boolean doResume = !callToTransfer.isInConference();
boolean doResume = !mCallToTransfer.isInConference();
// don't resume call if it is the call to transfer
doResume &= activateCallOnReturnFromUriPicker != callToTransfer;
doResume &= activateCallOnReturnFromUriPicker != mCallToTransfer;
eventuallyResumeConfOrCallOnPickerReturn(doResume);
Toast.makeText(this, R.string.transfer_started, Toast.LENGTH_LONG).show();
break;
@ -913,7 +762,7 @@ public class IncallActivity extends ListActivity implements
if (activateCallOnReturnFromUriPicker != null) {
lc().resumeCall(activateCallOnReturnFromUriPicker);
} else if (enterConferenceOnReturnFromUriPicker) {
lc().enterConference();
enterConferenceAndUpdateUI(true);
}
}
activateCallOnReturnFromUriPicker = null;
@ -951,8 +800,7 @@ public class IncallActivity extends ListActivity implements
String authenticationToken) {
mHandler.post(new Runnable() {
public void run() {
CalleeListAdapter adapter = (CalleeListAdapter) getListAdapter();
recreateActivity(adapter);
recreateActivity();
}
});
}

View file

@ -49,7 +49,6 @@ import android.media.AudioManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.text.Html;
import android.view.Menu;
@ -71,12 +70,11 @@ public class LinphoneActivity extends TabActivity implements
static final int FIRST_LOGIN_ACTIVITY = 101;
static final int INCOMING_CALL_ACTIVITY = 103;
private static final int incall_activity = 104;
private static final int conferenceDetailsActivity = 105;
private static final String PREF_CHECK_CONFIG = "pref_check_config";
private static LinphoneActivity instance;
private PowerManager.WakeLock mWakeLock;
private SensorManager mSensorManager;
private Sensor mAccelerometer;
private int previousRotation = -1;
@ -110,9 +108,6 @@ public class LinphoneActivity extends TabActivity implements
useMenuAbout = getResources().getBoolean(R.bool.useMenuAbout);
checkAccount = !useFirstLoginActivity;
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK|PowerManager.ON_AFTER_RELEASE,Log.TAG+"#"+getClass().getName());
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
@ -451,15 +446,10 @@ public class LinphoneActivity extends TabActivity implements
if (IncallActivity.active) {
return;
}
mHandler.post(new Runnable() {
public void run() {
startActivityForResult(new Intent().setClass(
LinphoneActivity.this,
IncallActivity.class),
incall_activity);
}
});
startActivityForResult(new Intent().setClass(
LinphoneActivity.this,
IncallActivity.class),
incall_activity);
}
public void startIncomingCallActivity(LinphoneCall pendingCall) {
@ -469,14 +459,7 @@ public class LinphoneActivity extends TabActivity implements
startActivityForResult(intent, INCOMING_CALL_ACTIVITY);
}
public void finishVideoActivity() {
mHandler.post(new Runnable() {
public void run() {
finishActivity(video_activity);
}
});
}
@Override
public void onCallStateChanged(LinphoneCall call, State state,
String message) {
@ -494,7 +477,6 @@ public class LinphoneActivity extends TabActivity implements
}
if (state==State.OutgoingInit || state==State.IncomingReceived) {
startOrientationSensor();
enterIncallMode();
} else if (state==State.Error || state==State.CallEnd){
stopOrientationSensor();
finishActivity(INCOMING_CALL_ACTIVITY);
@ -502,7 +484,6 @@ public class LinphoneActivity extends TabActivity implements
if (state==State.Connected) {
if (call.getDirection() == CallDirection.Incoming) {
startIncallActivity();
enterIncallMode();
}
}
if (state == LinphoneCall.State.StreamsRunning && Version.isVideoCapable()) {
@ -510,27 +491,30 @@ public class LinphoneActivity extends TabActivity implements
if (videoEnabled) {
startVideoActivity(call, 1000);
} else {
finishVideoActivity();
finishActivity(video_activity);
}
}
if (state == LinphoneCall.State.CallUpdatedByRemote && Version.isVideoCapable()) {
if (VideoCallActivity.launched && !call.getCurrentParamsCopy().getVideoEnabled()) {
finishVideoActivity();
finishActivity(video_activity);
}
}
if (state==State.Error){
showToast(R.string.call_error, message);
if (lc.getCallsNb() == 0){
if (mWakeLock.isHeld()) mWakeLock.release();
exitCallMode();
exitIncallActivity();
}
}else if (state==State.CallEnd){
if (lc.getCallsNb() == 0){
exitCallMode();
exitIncallActivity();
}
}
if (ConferenceDetailsActivity.active && lc.getConferenceSize() == 0) {
finishActivity(conferenceDetailsActivity);
}
}
private void showToast(int id, String txt) {
@ -542,30 +526,16 @@ public class LinphoneActivity extends TabActivity implements
});
}
private void enterIncallMode() {
LinphoneManager.startProximitySensorForActivity(this);
if (!mWakeLock.isHeld()) mWakeLock.acquire();
}
private void exitCallMode() {
private void exitIncallActivity() {
finishActivity(incall_activity);
if (mWakeLock.isHeld()) mWakeLock.release();
mHandler.post(new Runnable() {
@Override
public void run() {
LinphoneManager.stopProximitySensorForActivity(LinphoneActivity.this);
}
});
setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE);
}
@Override
protected void onDestroy() {
if (mWakeLock.isHeld()) mWakeLock.release();
super.onDestroy();
}
@ -575,21 +545,18 @@ public class LinphoneActivity extends TabActivity implements
super.onResume();
LinphoneCall pendingCall = LinphoneManager.getInstance().getPendingIncomingCall();
if (pendingCall != null) {
LinphoneActivity.instance().startIncomingCallActivity(pendingCall);
} else if (LinphoneManager.getLc().isIncall()) {
enterIncallMode();
}
if (LinphoneManager.getLc().getCallsNb() > 0) {
LinphoneManager.startProximitySensorForActivity(this);
// removing is done directly in LinphoneActivity.onPause()
}
startIncomingCallActivity(pendingCall);
}
}
@Override
public void goToDialer() {
selectDialerTab();
}
public void startConferenceDetailsActivity() {
startActivityForResult(new Intent().setClass(this, ConferenceDetailsActivity.class), conferenceDetailsActivity);
}
}
interface ContactPicked {

View file

@ -1,40 +0,0 @@
/*
LinphoneCoreException.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;
@SuppressWarnings("serial")
public class LinphoneConfigException extends LinphoneException {
public LinphoneConfigException() {
super();
}
public LinphoneConfigException(String detailMessage, Throwable throwable) {
super(detailMessage, throwable);
}
public LinphoneConfigException(String detailMessage) {
super(detailMessage);
}
public LinphoneConfigException(Throwable throwable) {
super(throwable);
}
}

View file

@ -20,12 +20,9 @@ package org.linphone;
import static android.content.Intent.ACTION_MAIN;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
/**
*

View file

@ -121,13 +121,15 @@ import android.view.WindowManager;
public final class LinphoneManager implements LinphoneCoreListener {
private static LinphoneManager instance;
private Context mServiceContext;
private AudioManager mAudioManager;
private PowerManager mPowerManager;
private ConnectivityManager mConnectivityManager;
private SharedPreferences mPref;
private Resources mR;
private LinphoneCore mLc;
private static Transports initialTransports;
private static LinphonePreferenceManager lpm;
private static LinphonePreferenceManager sLPref;
private String lastLcStatusMessage;
private String basePath;
private static boolean sExited;
@ -145,31 +147,34 @@ public final class LinphoneManager implements LinphoneCoreListener {
}
private LinphoneManager(final Context c) {
private LinphoneManager(final Context c, LinphoneServiceListener listener) {
sExited=false;
mServiceContext = c;
mListenerDispatcher = new ListenerDispatcher(listener);
basePath = c.getFilesDir().getAbsolutePath();
linphoneInitialConfigFile = basePath + "/linphonerc";
linphoneConfigFile = basePath + "/.linphonerc";
linphoneRootCaFile = basePath + "/rootca.pem";
ringSoundFile = basePath + "/oldphone_mono.wav";
ringbackSoundFile = basePath + "/ringback.wav";
mLinphoneInitialConfigFile = basePath + "/linphonerc";
mLinphoneConfigFile = basePath + "/.linphonerc";
mLinphoneRootCaFile = basePath + "/rootca.pem";
mRingSoundFile = basePath + "/oldphone_mono.wav";
mRingbackSoundFile = basePath + "/ringback.wav";
lpm = LinphonePreferenceManager.getInstance(c);
sLPref = LinphonePreferenceManager.getInstance(c);
mAudioManager = ((AudioManager) c.getSystemService(Context.AUDIO_SERVICE));
mVibrator = (Vibrator) c.getSystemService(Context.VIBRATOR_SERVICE);
mPref = PreferenceManager.getDefaultSharedPreferences(c);
mPowerManager = (PowerManager) c.getSystemService(Context.POWER_SERVICE);
mConnectivityManager = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE);
mR = c.getResources();
}
private static final int LINPHONE_VOLUME_STREAM = STREAM_VOICE_CALL;
private static final int dbStep = 4;
/** Called when the activity is first created. */
private final String linphoneInitialConfigFile;
private final String linphoneRootCaFile;
private final String linphoneConfigFile;
private final String ringSoundFile;
private final String ringbackSoundFile;
private final String mLinphoneInitialConfigFile;
private final String mLinphoneRootCaFile;
private final String mLinphoneConfigFile;
private final String mRingSoundFile;
private final String mRingbackSoundFile;
private Timer mTimer = new Timer("Linphone scheduler");
@ -187,13 +192,13 @@ public final class LinphoneManager implements LinphoneCoreListener {
speakerOn ? "speaker" : "earpiece");
return;
}
if (Hacks.needGalaxySAudioHack() || lpm.useGalaxySHack())
if (Hacks.needGalaxySAudioHack() || sLPref.useGalaxySHack())
setAudioModeIncallForGalaxyS();
if (lpm.useSpecificAudioModeHack() != -1)
mAudioManager.setMode(lpm.useSpecificAudioModeHack());
if (sLPref.useSpecificAudioModeHack() != -1)
mAudioManager.setMode(sLPref.useSpecificAudioModeHack());
if (Hacks.needRoutingAPI() || lpm.useAudioRoutingAPIHack()) {
if (Hacks.needRoutingAPI() || sLPref.useAudioRoutingAPIHack()) {
mAudioManager.setRouting(
MODE_NORMAL,
speakerOn? ROUTE_SPEAKER : ROUTE_EARPIECE,
@ -252,9 +257,8 @@ public final class LinphoneManager implements LinphoneCoreListener {
if (instance != null)
throw new RuntimeException("Linphone Manager is already initialized");
instance = new LinphoneManager(c);
instance.listenerDispatcher.setServiceListener(listener);
instance.startLibLinphone(c);
instance = new LinphoneManager(c, listener);
instance.startLibLinphone();
TelephonyManager tm = (TelephonyManager) c.getSystemService(Context.TELEPHONY_SERVICE);
boolean gsmIdle = tm.getCallState() == TelephonyManager.CALL_STATE_IDLE;
setGsmIdle(gsmIdle);
@ -282,7 +286,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
public boolean isSpeakerOn() {
if (Hacks.needRoutingAPI() || lpm.useAudioRoutingAPIHack()) {
if (Hacks.needRoutingAPI() || sLPref.useAudioRoutingAPIHack()) {
return mAudioManager.getRouting(MODE_NORMAL) == ROUTE_SPEAKER;
} else {
return mAudioManager.isSpeakerphoneOn();
@ -301,11 +305,11 @@ public final class LinphoneManager implements LinphoneCoreListener {
try {
lAddress = mLc.interpretUrl(to);
if (mLc.isMyself(lAddress.asStringUriOnly())) {
listenerDispatcher.tryingNewOutgoingCallButWrongDestinationAddress();
mListenerDispatcher.tryingNewOutgoingCallButWrongDestinationAddress();
return;
}
} catch (LinphoneCoreException e) {
listenerDispatcher.tryingNewOutgoingCallButWrongDestinationAddress();
mListenerDispatcher.tryingNewOutgoingCallButWrongDestinationAddress();
return;
}
lAddress.setDisplayName(address.getDisplayedName());
@ -322,7 +326,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
} catch (LinphoneCoreException e) {
listenerDispatcher.tryingNewOutgoingCallButCannotGetCallParameters();
mListenerDispatcher.tryingNewOutgoingCallButCannotGetCallParameters();
return;
}
}
@ -392,23 +396,23 @@ public final class LinphoneManager implements LinphoneCoreListener {
}
}
private synchronized void startLibLinphone(final Context context) {
private synchronized void startLibLinphone() {
try {
copyAssetsFromPackage(context);
copyAssetsFromPackage();
mLc = LinphoneCoreFactory.instance().createLinphoneCore(
this, linphoneConfigFile, linphoneInitialConfigFile, null);
this, mLinphoneConfigFile, mLinphoneInitialConfigFile, null);
mLc.enableIpv6(mPref.getBoolean(getString(R.string.pref_ipv6_key), false));
mLc.setZrtpSecretsCache(basePath+"/zrtp_secrets");
mLc.setPlaybackGain(3);
mLc.setRing(null);
mLc.setRootCA(linphoneRootCaFile);
mLc.setRootCA(mLinphoneRootCaFile);
try {
initFromConf(context);
initFromConf();
} catch (LinphoneException e) {
Log.w("no config ready yet");
}
@ -423,27 +427,27 @@ public final class LinphoneManager implements LinphoneCoreListener {
IntentFilter lFilter = new IntentFilter(Intent.ACTION_SCREEN_ON);
lFilter.addAction(Intent.ACTION_SCREEN_OFF);
context.registerReceiver(mKeepAliveReceiver, lFilter);
mServiceContext.registerReceiver(mKeepAliveReceiver, lFilter);
}
catch (Exception e) {
Log.e(e,"Cannot start linphone");
}
}
private void copyAssetsFromPackage(Context context) throws IOException {
copyIfNotExist(context, R.raw.oldphone_mono,ringSoundFile);
copyIfNotExist(context, R.raw.ringback,ringbackSoundFile);
copyFromPackage(context, R.raw.linphonerc, new File(linphoneInitialConfigFile).getName());
copyIfNotExist(context, R.raw.rootca, new File(linphoneRootCaFile).getName());
private void copyAssetsFromPackage() throws IOException {
copyIfNotExist(R.raw.oldphone_mono,mRingSoundFile);
copyIfNotExist(R.raw.ringback,mRingbackSoundFile);
copyFromPackage(R.raw.linphonerc, new File(mLinphoneInitialConfigFile).getName());
copyIfNotExist(R.raw.rootca, new File(mLinphoneRootCaFile).getName());
}
private void copyIfNotExist(Context context, int ressourceId,String target) throws IOException {
private void copyIfNotExist(int ressourceId,String target) throws IOException {
File lFileToCopy = new File(target);
if (!lFileToCopy.exists()) {
copyFromPackage(context, ressourceId,lFileToCopy.getName());
copyFromPackage(ressourceId,lFileToCopy.getName());
}
}
private void copyFromPackage(Context context, int ressourceId,String target) throws IOException{
FileOutputStream lOutputStream = context.openFileOutput (target, 0);
private void copyFromPackage(int ressourceId,String target) throws IOException{
FileOutputStream lOutputStream = mServiceContext.openFileOutput (target, 0);
InputStream lInputStream = mR.openRawResource(ressourceId);
int readByte;
byte[] buff = new byte[8048];
@ -469,7 +473,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
return false;
}
public void initFromConf(Context context) throws LinphoneConfigException {
public void initFromConf() throws LinphoneConfigException {
//traces
boolean lIsDebug = true;//mPref.getBoolean(getString(R.string.pref_debug_key), false);
LinphoneCoreFactory.instance().setDebugMode(lIsDebug);
@ -587,10 +591,8 @@ public final class LinphoneManager implements LinphoneCoreListener {
}
//init network state
ConnectivityManager lConnectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo lInfo = lConnectivityManager.getActiveNetworkInfo();
mLc.setNetworkReachable( lInfo !=null? lConnectivityManager.getActiveNetworkInfo().getState() ==NetworkInfo.State.CONNECTED:false);
NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkInfo();
mLc.setNetworkReachable(networkInfo !=null? networkInfo.getState() == NetworkInfo.State.CONNECTED:false);
} catch (LinphoneCoreException e) {
throw new LinphoneConfigException(getString(R.string.wrong_settings),e);
}
@ -668,19 +670,23 @@ public final class LinphoneManager implements LinphoneCoreListener {
mLc.enablePayloadType(videoCodec, enable);
}
public static synchronized void destroy(Context context) {
if (instance == null) return;
sExited=true;
private void doDestroy() {
try {
instance.mTimer.cancel();
instance.mLc.destroy();
context.unregisterReceiver(instance.mKeepAliveReceiver);
mTimer.cancel();
mLc.destroy();
mServiceContext.unregisterReceiver(instance.mKeepAliveReceiver);
} finally {
instance.mLc = null;
mLc = null;
instance = null;
}
}
public static synchronized void destroy() {
if (instance == null) return;
sExited=true;
instance.doDestroy();
}
private String getString(int key) {
return mR.getString(key);
}
@ -705,7 +711,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
void onEcCalibrationStatus(EcCalibratorStatus status, int delayMs);
}
private ListenerDispatcher listenerDispatcher = new ListenerDispatcher();
private ListenerDispatcher mListenerDispatcher;
private LinphoneCall ringingCall;
private MediaPlayer mRingerPlayer;
@ -730,20 +736,20 @@ public final class LinphoneManager implements LinphoneCoreListener {
public void displayStatus(final LinphoneCore lc, final String message) {
Log.i(message);
lastLcStatusMessage=message;
listenerDispatcher.onDisplayStatus(message);
mListenerDispatcher.onDisplayStatus(message);
}
public void globalState(final LinphoneCore lc, final LinphoneCore.GlobalState state, final String message) {
Log.i("new state [",state,"]");
listenerDispatcher.onGlobalStateChanged(state, message);
mListenerDispatcher.onGlobalStateChanged(state, message);
}
public void registrationState(final LinphoneCore lc, final LinphoneProxyConfig cfg,final LinphoneCore.RegistrationState state,final String message) {
Log.i("new state ["+state+"]");
listenerDispatcher.onRegistrationStateChanged(state, message);
mListenerDispatcher.onRegistrationStateChanged(state, message);
}
private int savedMaxCallWhileGsmIncall;
@ -807,7 +813,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
}
if (state == State.Connected) {
if (Hacks.needSoftvolume() || LinphonePreferenceManager.getInstance().useSoftvolume()) {
if (Hacks.needSoftvolume() || sLPref.useSoftvolume()) {
adjustSoftwareVolume(0); // Synchronize
}
}
@ -833,12 +839,12 @@ public final class LinphoneManager implements LinphoneCoreListener {
Log.i("New call active while incall (CPU only) wake lock already active");
}
}
listenerDispatcher.onCallStateChanged(call, state, message);
mListenerDispatcher.onCallStateChanged(call, state, message);
}
public void callEncryptionChanged(LinphoneCore lc, LinphoneCall call,
boolean encrypted, String authenticationToken) {
listenerDispatcher.onCallEncryptionChanged(call, encrypted, authenticationToken);
mListenerDispatcher.onCallEncryptionChanged(call, encrypted, authenticationToken);
}
public void ecCalibrationStatus(final LinphoneCore lc,final EcCalibratorStatus status, final int delayMs,
@ -881,7 +887,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
if (mRingerPlayer == null) {
mRingerPlayer = new MediaPlayer();
mRingerPlayer.setAudioStreamType(STREAM_RING);
listenerDispatcher.onRingerPlayerCreated(mRingerPlayer);
mListenerDispatcher.onRingerPlayerCreated(mRingerPlayer);
mRingerPlayer.prepare();
mRingerPlayer.setLooping(true);
mRingerPlayer.start();
@ -983,7 +989,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
}
public boolean acceptCallIfIncomingPending() throws LinphoneCoreException {
if (Hacks.needGalaxySAudioHack() || lpm.useGalaxySHack())
if (Hacks.needGalaxySAudioHack() || sLPref.useGalaxySHack())
setAudioModeIncallForGalaxyS();
if (mLc.isInComingInvitePending()) {
@ -994,7 +1000,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
}
public boolean acceptCall(LinphoneCall call) {
if (Hacks.needGalaxySAudioHack() || lpm.useGalaxySHack())
if (Hacks.needGalaxySAudioHack() || sLPref.useGalaxySHack())
setAudioModeIncallForGalaxyS();
try {
@ -1131,8 +1137,8 @@ public final class LinphoneManager implements LinphoneCoreListener {
private class ListenerDispatcher implements LinphoneServiceListener {
private LinphoneServiceListener serviceListener;
public void setServiceListener(LinphoneServiceListener s) {
this.serviceListener = s;
public ListenerDispatcher(LinphoneServiceListener listener) {
this.serviceListener = listener;
}
public void onCallEncryptionChanged(LinphoneCall call,
@ -1205,4 +1211,26 @@ public final class LinphoneManager implements LinphoneCoreListener {
return incomingPending ? currentCall : null;
}
@SuppressWarnings("serial")
public static class LinphoneConfigException extends LinphoneException {
public LinphoneConfigException() {
super();
}
public LinphoneConfigException(String detailMessage, Throwable throwable) {
super(detailMessage, throwable);
}
public LinphoneConfigException(String detailMessage) {
super(detailMessage);
}
public LinphoneConfigException(Throwable throwable) {
super(throwable);
}
}
}

View file

@ -37,14 +37,6 @@ public class LinphonePreferenceManager {
return c.getString(key);
}
public static final synchronized LinphonePreferenceManager getInstance() {
if (instance == null) {
throw new RuntimeException("LinphonePreferenceManager not instanciated");
}
return instance;
}
public boolean useSoftvolume() {
return p.getBoolean(
getString(R.string.pref_audio_soft_volume_key), false);

View file

@ -25,16 +25,16 @@ import static org.linphone.R.string.ec_calibration_launch_message;
import static org.linphone.R.string.pref_codec_amr_key;
import static org.linphone.R.string.pref_codec_ilbc_key;
import static org.linphone.R.string.pref_codec_speex16_key;
import static org.linphone.R.string.pref_echo_canceller_calibration_key;
import static org.linphone.R.string.pref_video_enable_key;
import static org.linphone.R.string.pref_echo_limiter_key;
import static org.linphone.R.string.pref_echo_cancellation_key;
import static org.linphone.R.string.pref_echo_canceller_calibration_key;
import static org.linphone.R.string.pref_echo_limiter_key;
import static org.linphone.R.string.pref_video_enable_key;
import java.util.Arrays;
import java.util.List;
import org.linphone.LinphoneManager.EcCalibrationListener;
import org.linphone.LinphoneManager.LinphoneConfigException;
import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCoreException;
import org.linphone.core.Log;
@ -280,9 +280,8 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
}
try {
LinphoneManager.getInstance().initFromConf(getApplicationContext());
LinphoneManager.getInstance().initFromConf();
} catch (LinphoneException e) {
if (! (e instanceof LinphoneConfigException)) {
Log.e(e, "Cannot update config");
return;

View file

@ -291,7 +291,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
stopForegroundCompat(NOTIF_ID);
LinphoneManager.getLcIfManagerNotDestroyedOrNull().setPresenceInfo(0, null, OnlineStatus.Offline);
LinphoneManager.destroy(this);
LinphoneManager.destroy();
instance=null;
}
@ -369,10 +369,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
public interface LinphoneGuiListener extends NewOutgoingCallUiListener {
void onDisplayStatus(String message);
void onGlobalStateChangedToOn(String message);
// void onRegistrationStateChanged(RegistrationState state, String message);
void onCallStateChanged(LinphoneCall call, State state, String message);
void onCallEncryptionChanged(LinphoneCall call, boolean encrypted,
String authenticationToken);
}
@ -414,12 +411,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
public void onCallEncryptionChanged(final LinphoneCall call, final boolean encrypted,
final String authenticationToken) {
mHandler.post(new Runnable() {
public void run() {
if (guiListener() != null)
guiListener().onCallEncryptionChanged(call, encrypted, authenticationToken);
}
});
// IncallActivity registers itself to this event and handle it.
}
}

View file

@ -18,11 +18,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.linphone.core.LinphoneAddress;
@ -41,6 +45,8 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
/**
@ -116,6 +122,7 @@ public final class LinphoneUtils {
return null;
}
public static void setImagePictureFromUri(Context c, ImageView view, Uri uri, int notFoundResource) {
if (uri == null) {
view.setImageResource(notFoundResource);
@ -129,12 +136,33 @@ public final class LinphoneUtils {
if (Version.sdkAboveOrEqual(Version.API06_ECLAIR_201)) {
view.setImageURI(uri);
} else {
@SuppressWarnings("deprecation")
Bitmap bitmap = android.provider.Contacts.People.loadContactPhoto(c, uri, notFoundResource, null);
view.setImageBitmap(bitmap);
}
}
}
public static final List<LinphoneCall> getLinphoneCallsNotInConf(LinphoneCore lc) {
List<LinphoneCall> calls = getLinphoneCalls(lc);
Iterator<LinphoneCall> iterator = calls.iterator();
while (iterator.hasNext()) {
LinphoneCall call = iterator.next();
if (call.isInConference()) iterator.remove();
}
return calls;
}
public static final List<LinphoneCall> getLinphoneCallsInConf(LinphoneCore lc) {
List<LinphoneCall> calls = getLinphoneCalls(lc);
Iterator<LinphoneCall> iterator = calls.iterator();
while (iterator.hasNext()) {
LinphoneCall call = iterator.next();
if (!call.isInConference()) iterator.remove();
}
return calls;
}
@SuppressWarnings("unchecked")
public static final List<LinphoneCall> getLinphoneCalls(LinphoneCore lc) {
return (List<LinphoneCall>) lc.getCalls();
@ -159,5 +187,31 @@ public final class LinphoneUtils {
}
return foundCalls;
}
public static final int countConferenceCalls(LinphoneCore lc) {
int count = lc.getConferenceSize();
if (lc.isInConference()) count--;
return count;
}
public static int countVirtualCalls(LinphoneCore lc) {
return lc.getCallsNb() - countConferenceCalls(lc);
}
public static int countNonConferenceCalls(LinphoneCore lc) {
return lc.getCallsNb() - countConferenceCalls(lc);
}
public static void setVisibility(View v, int id, boolean visible) {
v.findViewById(id).setVisibility(visible ? VISIBLE : GONE);
}
public static void setVisibility(View v, boolean visible) {
v.setVisibility(visible ? VISIBLE : GONE);
}
public static void enableView(View root, int id, OnClickListener l, boolean enable) {
View v = root.findViewById(id);
v.setVisibility(enable ? VISIBLE : GONE);
v.setOnClickListener(l);
}
}

View file

@ -501,9 +501,9 @@ class LinphoneCoreImpl implements LinphoneCore {
leaveConference(nativePtr);
}
private native void enterConference(long nativePtr);
public synchronized void enterConference() {
enterConference(nativePtr);
private native boolean enterConference(long nativePtr);
public synchronized boolean enterConference() {
return enterConference(nativePtr);
}
private native boolean isInConference(long nativePtr);

View file

@ -65,29 +65,7 @@ public class IncallTimer extends TextView {
}
}
/**
* Format time as "days - hh : mm : ss".
* @param seconds
* @return formated string
*/
/*protected String formatTime(final int seconds) {
int value = seconds;
StringBuilder sb = new StringBuilder();
for (int base : Arrays.asList(60, 60, 24)) {
if (value == 0) break;
int remainder = value % base;
value /= base;
if (sb.length() != 0) sb.insert(0, " : ");
sb.insert(0, remainder < 10 ? "0" + remainder : remainder);
}
if (value != 0) sb.insert(0, value + " - ");
return sb.toString();
public void setDuration(int duration) {
super.setText(formatTime(duration));
}
*/
}

@ -1 +1 @@
Subproject commit 50d784112932f7bcdfe2e7fb69dcfc5c27546d0a
Subproject commit ab498e8e8cea496d6eb96a72d76cd987e49be544

View file

@ -1,437 +0,0 @@
/*
TestIncallCalleeBoxes.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 java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.linphone.core.CallDirection;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneAuthInfo;
import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCallLog;
import org.linphone.core.LinphoneCallParams;
import org.linphone.core.LinphoneChatRoom;
import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneFriend;
import org.linphone.core.LinphoneProxyConfig;
import org.linphone.core.OnlineStatus;
import org.linphone.core.PayloadType;
import org.linphone.core.VideoSize;
import org.linphone.core.LinphoneCall.State;
import android.os.Bundle;
import android.os.Handler;
/**
* @author Guillaume Beraudo
*/
public class TestConferenceActivity extends IncallActivity {
private Handler mHandler = new Handler();
private LinphoneCoreTest mTestLc;
protected final LinphoneCore lc() {return mTestLc;}
private void simulateCallAccepted(final LinphoneCall call, int millis) {
mHandler.postDelayed(new Runnable() {
public void run() {
lc().pauseAllCalls();
((LinphoneCallTest)call).state = State.StreamsRunning;
onCallStateChanged(call, call.getState(), "simulated out call answered");
}
}, millis);
}
private void delayedCallEvent(final LinphoneCall call, final State targetState, int millis) {
mHandler.postDelayed(new Runnable() {
public void run() {
((LinphoneCallTest)call).state = targetState;
onCallStateChanged(call, call.getState(), "simulated delayed state change " + targetState);
}
}, millis);
}
protected final List<LinphoneCall> getInitialCalls() {
List<LinphoneCall> calls = new ArrayList<LinphoneCall>();
int duration=0;
mTestLc = new LinphoneCoreTest(calls);
calls.add(new LinphoneCallTest(duration++, "Tartampion", "06.25.45.98.54", State.StreamsRunning));
calls.add(new LinphoneCallTest(duration++, "Durand", "durand@sip.linphone.org", State.StreamsRunning));
// calls.add(new LinphoneCallTest(duration++, "Poupoux", "01.58.68.75.32", State.StreamsRunning));
calls.add(new LinphoneCallTest(duration++, "Tante Germaine", "+33 1.58.68.75.32", State.Paused));
// calls.add(new LinphoneCallTest(duration++, "M. Le président ", "3615 Elysée", State.Paused));
calls.add(new LinphoneCallTest(duration++, "01.58.68.75.32", "01.58.68.75.32", State.StreamsRunning));
calls.add(new LinphoneCallTest(duration++, "A ringing out guy", "out-ringing@sip.linphone.org", State.OutgoingRinging));
calls.add(new LinphoneCallTest(duration++, "A calling in guy", "in@sip.linphone.org", State.IncomingReceived));
((LinphoneCallTest)calls.get(0)).inConf=true;
((LinphoneCallTest)calls.get(1)).inConf=true;
simulateCallAccepted(calls.get(4), 5000);
Collections.sort(calls, this);
mTestLc = new LinphoneCoreTest(calls);
return calls;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
//if (!serviceStarted) startService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class));
findViewById(R.id.toggleMuteMic).setOnClickListener(null);
findViewById(R.id.toggleSpeaker).setOnClickListener(null);
super.onCreate(savedInstanceState);
}
private class LinphoneCoreTest implements LinphoneCore {
List<LinphoneCall> calls;
public LinphoneCoreTest(List<LinphoneCall> calls) {
this.calls = new ArrayList<LinphoneCall>(calls);
//don't keep only the list reference (concurrent access in onStateChanged).
}
public void acceptCall(LinphoneCall call) throws LinphoneCoreException {
if (isInConference()) {
leaveConference();
} else {
LinphoneCall current = getCurrentCall();
if (current != null) pauseCall(current);
}
changeState(call, State.StreamsRunning);
}
public void addAuthInfo(LinphoneAuthInfo info) {}
public void addFriend(LinphoneFriend lf) throws LinphoneCoreException {}
public void addProxyConfig(LinphoneProxyConfig p) throws LinphoneCoreException {}
public void adjustSoftwareVolume(int i) {}
public void clearAuthInfos() {}
public void clearCallLogs() {}
public void clearProxyConfigs() {}
public LinphoneChatRoom createChatRoom(String to) {return null;}
public LinphoneCallParams createDefaultCallParameters() {return null;}
public void destroy() {}
public void enableEchoCancellation(boolean enable) {}
public void enableEchoLimiter(boolean val) {}
public void enableIpv6(boolean enable) {}
public void enableKeepAlive(boolean enable) {}
public void enablePayloadType(PayloadType pt, boolean e)throws LinphoneCoreException {}
public void enableSpeaker(boolean value) {}
public void enableVideo(boolean vcapEnabled, boolean displayEnabled) {}
public PayloadType findPayloadType(String mime, int clockRate) {return null;}
public PayloadType[] getAudioCodecs() {return null;}
@SuppressWarnings("unchecked")
public List getCallLogs() {return null;}
public LinphoneCall getCurrentCall() {
LinphoneCall active = null;
for (LinphoneCall call : calls) {
if (call.isInConference() || !call.getState().equals(State.StreamsRunning)) continue;
if (active != null) throw new RuntimeException("There are several active calls!");
active = call;
}
return active;
}
public LinphoneProxyConfig getDefaultProxyConfig() {return null;}
public FirewallPolicy getFirewallPolicy() {return null;}
public int getPlayLevel() {return 0;}
public float getPlaybackGain() {return 0;}
public VideoSize getPreferredVideoSize() {return null;}
public LinphoneAddress getRemoteAddress() {return null;}
public String getRing() {return null;}
public Transports getSignalingTransportPorts() {return null;}
public String getStunServer() {return null;}
public PayloadType[] getVideoCodecs() {return null;}
public LinphoneAddress interpretUrl(String d)throws LinphoneCoreException {return null;}
public LinphoneCall invite(String d) throws LinphoneCoreException {return null;}
public LinphoneCall invite(LinphoneAddress to)throws LinphoneCoreException {return null;}
public LinphoneCall inviteAddressWithParams(LinphoneAddress d, LinphoneCallParams p)
throws LinphoneCoreException {return null;}
public boolean isEchoCancellationEnabled() {return false;}
public boolean isInComingInvitePending() {return false;}
public boolean isIncall() {return false;}
public boolean isKeepAliveEnabled() {return false;}
public boolean isMicMuted() {return false;}
public boolean isNetworkReachable() {return false;}
public boolean isSpeakerEnabled() {return false;}
public boolean isVideoEnabled() {return false;}
public void iterate() {}
public void muteMic(boolean isMuted) {}
public boolean pauseAllCalls() {
// FIXME may not be right
for (LinphoneCall call : calls) {
if (!call.isInConference()) {
if (call.getState().equals(State.StreamsRunning) || call.getState().equals(State.PausedByRemote))
pauseCall(call);
}
}
return false;
}
public boolean pauseCall(LinphoneCall call) {
changeState(call, State.Paused);
return true;
}
public void playDtmf(char number, int duration) {}
public boolean resumeCall(LinphoneCall call) {
if (isInConference()) leaveConference();
pauseAllCalls();
changeState(call, State.StreamsRunning);
return true;
}
public void sendDtmf(char number) {}
public void setDefaultProxyConfig(LinphoneProxyConfig proxyCfg) {}
public void setDownloadBandwidth(int bw) {}
public void setDownloadPtime(int ptime) {}
public void setFirewallPolicy(FirewallPolicy pol) {}
public void setNetworkReachable(boolean isReachable) {}
public void setPlayLevel(int level) {}
public void setPlaybackGain(float gain) {}
public void setPreferredVideoSize(VideoSize vSize) {}
public void setPresenceInfo(int m, String a, OnlineStatus s) {}
public void setPreviewWindow(Object w) {}
public void setRing(String path) {}
public void setRootCA(String path) {}
public void setSignalingTransportPorts(Transports transports) {}
public void setStunServer(String stunServer) {}
public void setUploadBandwidth(int bw) {}
public void setUploadPtime(int ptime) {}
public void setVideoWindow(Object w) {}
public void setZrtpSecretsCache(String file) {}
public void startEchoCalibration(Object d)throws LinphoneCoreException {}
public void stopDtmf() {}
public void terminateCall(LinphoneCall call) {
changeStateInConf(call, false);
changeState(call, State.CallEnd);
}
public int updateCall(LinphoneCall call, LinphoneCallParams params) {return 0;}
private boolean partOfConf;
public void enterConference() {
pauseAllCalls();
partOfConf=true;
hackTriggerConfStateUpdate(); // FIXME hack; should have an event?
}
public void leaveConference() {
partOfConf=false;
hackTriggerConfStateUpdate(); // FIXME hack; should have an event?
}
public boolean isInConference() {return partOfConf;}
public int getConferenceSize() {
int count=0;
for (LinphoneCall c : calls) {
if (c.isInConference()) count++;
}
return count;
}
public void addAllToConference() {
for (LinphoneCall c : calls) {
final LinphoneCall.State state = c.getState();
boolean connectionEstablished = state == State.StreamsRunning || state == State.Paused || state == State.PausedByRemote;
if (connectionEstablished) {
changeState(c, State.StreamsRunning);
changeStateInConf(c, true);
}
}
enterConference();
}
public void addToConference(LinphoneCall call) {
if (getConferenceSize() == 0) {
addAllToConference();
} else {
boolean mergingActiveCall = call.equals(getCurrentCall());
changeState(call, State.StreamsRunning);
changeStateInConf(call, true);
if (mergingActiveCall) enterConference();
}
}
public void terminateConference() {
leaveConference();
for (LinphoneCall call : calls) {
if (!call.isInConference()) continue;
terminateCall(call);
}
}
private void changeState(LinphoneCall call, State state) {
((LinphoneCallTest)call).state=state;
onCallStateChanged(call, state, "triggered by stub");
}
private void changeStateInConf(LinphoneCall call, boolean inConf) {
((LinphoneCallTest)call).inConf=inConf;
onCallStateChanged(call, call.getState(), "in conf state changed");
}
public int getCallsNb() {
int count=0;
for (LinphoneCall call : calls) {
if (!State.CallEnd.equals(call.getState())) count++;
}
return count;
}
public void terminateAllCalls() {
terminateConference();
for(LinphoneCall call : calls) {
if (!State.CallEnd.equals(call.getState())) terminateCall(call);
}
}
@SuppressWarnings("unchecked")
public List getCalls() {
return new ArrayList<LinphoneCall>(calls);
}
public void removeFromConference(LinphoneCall call) {
changeStateInConf(call, false);
changeState(call, State.Paused);
}
public void transferCall(LinphoneCall call, String referTo) {
terminateCall(call);
}
public void transferCallToAnother(LinphoneCall callToTransfer, LinphoneCall destination) {
if (!State.Paused.equals(callToTransfer.getState())) {
throw new RuntimeException("call to transfer should be paused first");
}
terminateCall(callToTransfer);
delayedCallEvent(destination, State.CallEnd, 3000);
}
public int getVideoDevice() {return 0;}
public void setDeviceRotation(int rotation) {}
public void setVideoDevice(int id) {}
@Override
public LinphoneCall findCallFromUri(String uri) {
for (LinphoneCall call : calls) {
if (call.getRemoteAddress().asStringUriOnly().equals(uri)) {
return call;
}
}
return null;
}
@Override
public int getMaxCalls() {
return 10;
}
@Override
public boolean isMyself(String uri) {
return false;
}
@Override
public boolean soundResourcesLocked() {
// TODO Auto-generated method stub
return false;
}
@Override
public void setMaxCalls(int max) {
// TODO Auto-generated method stub
}
@Override
public String getMediaEncryption() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean isMediaEncryptionMandatory() {
// TODO Auto-generated method stub
return false;
}
@Override
public void setMediaEncryption(String menc) {
// TODO Auto-generated method stub
}
@Override
public void setMediaEncryptionMandatory(boolean yesno) {
// TODO Auto-generated method stub
}
@Override
public boolean isEchoLimiterEnabled() {
// TODO Auto-generated method stub
return false;
}
}
private static class LinphoneAddressTest implements LinphoneAddress {
private String displayName;
private String number;
public LinphoneAddressTest(String niceName, String number) {
this.displayName = niceName;
this.number = number;}
public String asString() {return displayName;}
public String asStringUriOnly() {return getUserName() + "@" + getDomain();}
public String getDisplayName() {return displayName;}
public String getDomain() {return "example.org";}
public String getPort() {return "5060";}
public int getPortInt() {return 5060;}
public String getUserName() {return number;}
public void setDisplayName(String name) {}
public void setDomain(String domain) {}
public void setPort(String port) {}
public void setPortInt(int port) {}
public void setUserName(String username) {}
public void clean() {}
@Override public String toString() {return displayName;}
}
private static class LinphoneCallTest implements LinphoneCall {
private boolean inConf;
private State state;
private LinphoneAddress remoteAddress;
private int duration;
public LinphoneCallTest(int duration, String name, String number, State state) {
this.duration = duration;
this.state = state;
remoteAddress = new LinphoneAddressTest(name, number);
}
public void enableCamera(boolean enabled) {}
public void enableEchoCancellation(boolean enable) {}
public void enableEchoLimiter(boolean enable) {}
public String getAuthenticationToken() {return null;}
public float getAverageQuality() {return 0;}
public LinphoneCallLog getCallLog() {return null;}
public LinphoneCallParams getCurrentParamsCopy() {return null;}
public float getCurrentQuality() {return 0;}
public CallDirection getDirection() {return null;}
public int getDuration() {return duration;}
public LinphoneAddress getRemoteAddress() {return remoteAddress;}
public LinphoneCall getReplacedCall() {return null;}
public State getState() {return state;}
public boolean isAuthenticationTokenVerified() {return false;}
public boolean isEchoCancellationEnabled() {return false;}
public boolean isEchoLimiterEnabled() {return false;}
public boolean isInConference() { return inConf;}
public boolean cameraEnabled() {return false;}
@Override
public void setAuthenticationTokenVerified(boolean verified) {
// TODO Auto-generated method stub
}
}
@Override
protected void registerLinphoneListener(boolean register) {
// Do nothing (especially, don't call LinphoneManager!)
}
}