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" /> <action android:name="android.intent.action.MAIN" />
</intent-filter> </intent-filter>
</activity> </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"> <activity android:name="org.linphone.LinphonePreferencesActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

View file

@ -12,18 +12,10 @@
android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_width="wrap_content" android:layout_height="fill_parent"
android:layout_centerVertical="true"> android:layout_centerVertical="true">
<ImageButton android:id="@+id/addVideo" android:src="@drawable/conf_video" <ImageButton android:id="@+id/addVideo" android:src="@drawable/conf_video"
android:visibility="gone"
android:layout_width="wrap_content" android:layout_height="wrap_content" /> android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ImageButton android:id="@+id/merge_to_conference" android:src="@drawable/conf_merge" <ImageButton android:id="@+id/merge_to_conference" android:src="@drawable/conf_merge"
android:layout_width="wrap_content" android:layout_height="wrap_content" /> android:visibility="gone"
<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:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
@ -31,8 +23,7 @@
android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_width="wrap_content" android:layout_height="fill_parent"
android:layout_centerVertical="true"> android:layout_centerVertical="true">
<TextView android:id="@+id/status_label" style="@style/callee_status" /> <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_paused" style="@style/callee_status" android:src="@drawable/conf_status_paused" android:visibility="gone"/>
<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"/> <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_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"/> <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" <ImageButton android:id="@+id/merge_to_conference"
android:src="@drawable/conf_merge" android:layout_width="wrap_content" android:src="@drawable/conf_merge" android:layout_width="wrap_content"
android:layout_height="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" <TextView android:id="@+id/status_label" style="@style/callee_status"
android:layout_height="fill_parent" /> android:layout_height="fill_parent" />
<ImageView android:id="@+id/callee_status_paused" style="@style/callee_status" <ImageView android:id="@+id/callee_status_paused" style="@style/callee_status"
android:src="@drawable/conf_status_paused" /> 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" <ImageView android:id="@+id/callee_status_secured" style="@style/callee_status"
android:src="@drawable/conf_secured" android:visibility="gone"/> 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" /> android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout> </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" <LinearLayout android:id="@+id/merge_to_conference"
android:layout_width="fill_parent" android:layout_height="wrap_content"> android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageButton android:src="@drawable/conf_merge" android:clickable="false" <ImageButton android:src="@drawable/conf_merge" android:clickable="false"
@ -58,22 +49,6 @@
android:layout_width="wrap_content" android:layout_height="wrap_content" /> android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout> </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" <LinearLayout android:id="@+id/terminate_call"
android:layout_width="fill_parent" android:layout_height="wrap_content"> android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageButton android:src="@drawable/conf_terminate" android:clickable="false" <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" <LinearLayout android:id="@+id/conf_control_buttons"
android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_alignParentTop="true"> 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" <Button android:id="@+id/conf_simple_merge" style="@style/conf_icon_text_button"
android:drawableTop="@drawable/conf_merge" android:drawableTop="@drawable/conf_merge"
android:text="@string/conf_simple_merge_bt_txt"/> 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" <LinearLayout android:id="@+id/conf_header" android:layout_below="@id/conf_control_buttons"
android:orientation="vertical" android:layout_marginBottom="10dip" android:orientation="vertical" android:layout_marginBottom="10dip"
android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_alignWithParentIfMissing="true"> android:layout_alignWithParentIfMissing="true"
<TextView android:text="@string/conf_text_you_host_a_conference" 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:layout_width="fill_parent" android:layout_height="wrap_content"
android:gravity="center"/> android:gravity="center"/>
</LinearLayout> </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> <item name="android:ellipsize">marquee</item>
</style> </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_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">wrap_content</item>
<item name="android:gravity">center_vertical</item> <item name="android:gravity">center_vertical</item>

View file

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

View file

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

View file

@ -15,7 +15,10 @@
<string name="error_adding_new_call">Error adding new call</string> <string name="error_adding_new_call">Error adding new call</string>
<string name="transfer_started">Transfer initiated</string> <string name="transfer_started">Transfer initiated</string>
<string name="transfer_dialog_title">Transfer call to</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="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> <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="conf_simple_no_current_call">No active call</string>
<string name="show_send_dtmfs_button">DTMFs</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">You are part of it</string>
<string name="in_conf_leave">Go out</string> <string name="in_conf_leave">Go out</string>
<string name="out_conf">You are out of it</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 * @author Guillaume Beraudo
* *
*/ */
public abstract class AbstractContactPickerActivity extends Activity implements FilterQueryProvider { public abstract class AbstractContactPickerActivityNew extends Activity implements FilterQueryProvider {
private ListView mContactList; private ListView mContactList;
protected EditText mcontactFilter; 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 * @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; package org.linphone;
import org.linphone.LinphoneManager.NewOutgoingCallUiListener;
import org.linphone.LinphoneService.LinphoneGuiListener; import org.linphone.LinphoneService.LinphoneGuiListener;
import org.linphone.core.LinphoneCall; import org.linphone.core.LinphoneCall;
import org.linphone.core.Log; import org.linphone.core.Log;
@ -49,7 +48,7 @@ import android.widget.Toast;
* </ul> * </ul>
* *
*/ */
public class DialerActivity extends Activity implements LinphoneGuiListener, NewOutgoingCallUiListener { public class DialerActivity extends Activity implements LinphoneGuiListener {
private TextView mStatus; private TextView mStatus;
private Handler mHandler; 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 @Override
protected void onResume() { protected void onResume() {
// When coming back from a video call, if the phone orientation is different // 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(); LinphoneManager.getInstance().initializePayloads();
try { try {
LinphoneManager.getInstance().initFromConf(getApplicationContext()); LinphoneManager.getInstance().initFromConf();
} catch (Throwable e) { } catch (Throwable e) {
Log.e(e, "Error while initializing from config in first login activity"); Log.e(e, "Error while initializing from config in first login activity");
toast(R.string.error);; toast(R.string.error);;

View file

@ -51,8 +51,8 @@ import android.text.TextUtils;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import android.widget.ImageView; import android.widget.ImageView;
@ -69,22 +69,18 @@ public class IncallActivity extends ListActivity implements
LinphoneOnCallStateChangedListener, LinphoneOnCallStateChangedListener,
LinphoneOnCallEncryptionChangedListener, LinphoneOnCallEncryptionChangedListener,
Comparator<LinphoneCall>, Comparator<LinphoneCall>,
OnLongClickListener,
OnClickListener { OnClickListener {
private View confHeaderView;
static boolean active; static boolean active;
private boolean unMuteOnReturnFromUriPicker; private boolean mUnMuteOnReturnFromUriPicker;
// Start Override to test block // Start Override to test block
protected LinphoneCore lc() { protected LinphoneCore lc() {
return LinphoneManager.getLc(); return LinphoneManager.getLc();
} }
protected List<LinphoneCall> getInitialCalls() {
return LinphoneUtils.getLinphoneCalls(lc());
}
// End override to test block // End override to test block
private static final int numpad_dialog_id = 1; private static final int numpad_dialog_id = 1;
@ -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() { private void pauseCurrentCallOrLeaveConference() {
LinphoneCall call = lc().getCurrentCall(); LinphoneCall call = lc().getCurrentCall();
if (call != null) lc().pauseCall(call); if (call != null) lc().pauseCall(call);
@ -110,41 +97,41 @@ public class IncallActivity extends ListActivity implements
private ToggleButton mMuteMicButton; private ToggleButton mMuteMicButton;
private ToggleButton mSpeakerButton; private ToggleButton mSpeakerButton;
private int multipleCallsLimit; private View mConferenceVirtualCallee;
private boolean allowTransfers; private int mMultipleCallsLimit;
private boolean mAllowTransfers;
private List<LinphoneCall> mNotInConfCalls = Collections.emptyList();
private CalleeListAdapter mListAdapter;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.conferencing); setContentView(R.layout.incall_layout);
allowTransfers = getResources().getBoolean(R.bool.allow_transfers); mAllowTransfers = getResources().getBoolean(R.bool.allow_transfers);
confHeaderView = findViewById(R.id.conf_header);
confHeaderView.setOnClickListener(this);
findViewById(R.id.addCall).setOnClickListener(this); findViewById(R.id.addCall).setOnClickListener(this);
findViewById(R.id.incallNumpadShow).setOnClickListener(this); findViewById(R.id.incallNumpadShow).setOnClickListener(this);
findViewById(R.id.conf_simple_merge).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); View transferView = findViewById(R.id.conf_simple_transfer);
transferView.setOnClickListener(this); transferView.setOnClickListener(this);
if (!allowTransfers) { if (!mAllowTransfers) {
transferView.setVisibility(View.GONE); transferView.setVisibility(View.GONE);
} }
findViewById(R.id.conf_simple_permute).setOnClickListener(this);
mMuteMicButton = (ToggleButton) findViewById(R.id.toggleMuteMic); mMuteMicButton = (ToggleButton) findViewById(R.id.toggleMuteMic);
mMuteMicButton.setOnClickListener(this); mMuteMicButton.setOnClickListener(this);
mSpeakerButton = (ToggleButton) findViewById(R.id.toggleSpeaker); mSpeakerButton = (ToggleButton) findViewById(R.id.toggleSpeaker);
mSpeakerButton.setOnClickListener(this); mSpeakerButton.setOnClickListener(this);
List<LinphoneCall> calls = getInitialCalls(); setListAdapter(mListAdapter = new CalleeListAdapter());
setListAdapter(new CalleeListAdapter(calls));
findViewById(R.id.incallHang).setOnClickListener(this); 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(); // workaroundStatusBarBug();
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
} }
@ -156,8 +143,8 @@ public class IncallActivity extends ListActivity implements
private void updateAddCallButton() { private void updateAddCallButton() {
boolean limitReached = false; boolean limitReached = false;
if (multipleCallsLimit > 0) { if (mMultipleCallsLimit > 0) {
limitReached = lc().getCallsNb() >= multipleCallsLimit; limitReached = lc().getCallsNb() >= mMultipleCallsLimit;
} }
int establishedCallsNb = LinphoneUtils.getRunningOrPausedCalls(lc()).size(); int establishedCallsNb = LinphoneUtils.getRunningOrPausedCalls(lc()).size();
@ -175,42 +162,23 @@ public class IncallActivity extends ListActivity implements
super.onNewIntent(intent); super.onNewIntent(intent);
} }
protected void registerLinphoneListener(boolean register) {
if (register)
LinphoneManager.addListener(this);
else
LinphoneManager.removeListener(this);
}
@Override @Override
protected void onResume() { protected void onResume() {
active=true; active=true;
registerLinphoneListener(true); mNotInConfCalls = LinphoneUtils.getLinphoneCallsNotInConf(lc());
updateCalleeImage(); LinphoneManager.addListener(this);
updateConfState();
updateSimpleControlButtons();
updateSoundLock();
updateDtmfButton();
CalleeListAdapter adapter = (CalleeListAdapter) getListAdapter();
if (adapter.linphoneCalls.size() != lc().getCallsNb()) {
adapter.linphoneCalls.clear();
adapter.linphoneCalls.addAll(getInitialCalls());
}
recreateActivity(adapter);
LinphoneManager.startProximitySensorForActivity(this); LinphoneManager.startProximitySensorForActivity(this);
mSpeakerButton.setChecked(LinphoneManager.getInstance().isSpeakerOn()); mSpeakerButton.setChecked(LinphoneManager.getInstance().isSpeakerOn());
mMuteMicButton.setChecked(LinphoneManager.getLc().isMicMuted()); mMuteMicButton.setChecked(LinphoneManager.getLc().isMicMuted());
updateAddCallButton(); recreateActivity();
super.onResume(); super.onResume();
} }
@Override @Override
protected void onPause() { protected void onPause() {
active=false; active=false;
registerLinphoneListener(false); LinphoneManager.removeListener(this);
LinphoneManager.stopProximitySensorForActivity(this); LinphoneManager.stopProximitySensorForActivity(this);
super.onPause(); super.onPause();
} }
@ -219,7 +187,7 @@ public class IncallActivity extends ListActivity implements
ImageView view = (ImageView) findViewById(R.id.incall_picture); ImageView view = (ImageView) findViewById(R.id.incall_picture);
LinphoneCall currentCall = lc().getCurrentCall(); LinphoneCall currentCall = lc().getCurrentCall();
if (lc().getCallsNb() != 1 || currentCall == null) { if (currentCall == null || lc().getCallsNb() != 1) {
view.setVisibility(GONE); view.setVisibility(GONE);
return; return;
} }
@ -231,10 +199,9 @@ public class IncallActivity extends ListActivity implements
} }
private void enableView(View root, int id, OnClickListener l, boolean enable) { private void enableView(View root, int id, OnClickListener l, boolean enable) {
View v = root.findViewById(id); LinphoneUtils.enableView(root, id, l, enable);
v.setVisibility(enable ? VISIBLE : GONE);
v.setOnClickListener(l);
} }
@Override @Override
protected Dialog onCreateDialog(final int id) { protected Dialog onCreateDialog(final int id) {
switch (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 LinphoneCall activateCallOnReturnFromUriPicker;
private boolean enterConferenceOnReturnFromUriPicker; private boolean enterConferenceOnReturnFromUriPicker;
private void openUriPicker(String pickerType, int requestCode) { private void openUriPicker(String pickerType, int requestCode) {
@ -301,57 +238,67 @@ public class IncallActivity extends ListActivity implements
intent.putExtra(UriPickerActivity.EXTRA_PICKER_TYPE, pickerType); intent.putExtra(UriPickerActivity.EXTRA_PICKER_TYPE, pickerType);
startActivityForResult(intent, requestCode); startActivityForResult(intent, requestCode);
if (!lc().isMicMuted()) { if (!lc().isMicMuted()) {
unMuteOnReturnFromUriPicker = true; mUnMuteOnReturnFromUriPicker = true;
lc().muteMic(true); lc().muteMic(true);
((ToggleButton) findViewById(R.id.toggleMuteMic)).setChecked(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) { public void onClick(View v) {
switch (v.getId()) { switch (v.getId()) {
case R.id.addCall: case R.id.addCall:
openUriPicker(UriPickerActivity.EXTRA_PICKER_TYPE_ADD, ID_ADD_CALL); openUriPicker(UriPickerActivity.EXTRA_PICKER_TYPE_ADD, ID_ADD_CALL);
break; 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: case R.id.incallHang:
lc().terminateAllCalls(); terminateCurrentCallOrConferenceOrAll();
setResult(RESULT_OK); break;
finish(); case R.id.conf_header:
boolean enterConf = !lc().isInConference();
enterConferenceAndUpdateUI(enterConf);
break; break;
case R.id.incallNumpadShow: case R.id.incallNumpadShow:
showDialog(numpad_dialog_id); showDialog(numpad_dialog_id);
@ -360,28 +307,15 @@ public class IncallActivity extends ListActivity implements
findViewById(R.id.conf_control_buttons).setVisibility(GONE); findViewById(R.id.conf_control_buttons).setVisibility(GONE);
lc().addAllToConference(); lc().addAllToConference();
break; break;
case R.id.conf_simple_resume:
findViewById(R.id.conf_control_buttons).setVisibility(GONE);
handleSimpleResume();
break;
case R.id.conf_simple_transfer: case R.id.conf_simple_transfer:
findViewById(R.id.conf_control_buttons).setVisibility(GONE); findViewById(R.id.conf_control_buttons).setVisibility(GONE);
LinphoneCall tCall = lc().getCurrentCall(); LinphoneCall tCall = lc().getCurrentCall();
if (tCall != null) { if (tCall != null) {
prepareForTransferingExistingCall(tCall); prepareForTransferingExistingOrNewCall(tCall);
} else { } else {
Toast.makeText(this, R.string.conf_simple_no_current_call, Toast.LENGTH_SHORT).show(); Toast.makeText(this, R.string.conf_simple_no_current_call, Toast.LENGTH_SHORT).show();
} }
break; 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: case R.id.toggleMuteMic:
lc().muteMic(((ToggleButton) v).isChecked()); lc().muteMic(((ToggleButton) v).isChecked());
break; break;
@ -398,49 +332,32 @@ public class IncallActivity extends ListActivity implements
} }
private void handleSimpleResume() { private void prepareForTransferingExistingOrNewCall(final LinphoneCall call) {
int nbCalls = lc().getCallsNb(); final List<LinphoneCall> existingCalls = LinphoneUtils.getLinphoneCalls(lc());
if (nbCalls == 0) { 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; 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) {
final List<LinphoneCall> existingCalls = LinphoneUtils.getLinphoneCalls(lc());
existingCalls.remove(call); 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(); Resources r = getResources();
for(LinphoneCall c : existingCalls) { for(LinphoneCall c : existingCalls) {
numbers.add(LinphoneManager.extractADisplayName(r, c.getRemoteAddress())); 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); ListAdapter adapter = new ArrayAdapter<String>(IncallActivity.this, android.R.layout.select_dialog_item, numbers);
DialogInterface.OnClickListener l = new DialogInterface.OnClickListener() { DialogInterface.OnClickListener l = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int 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)); lc().transferCallToAnother(call, existingCalls.get(which));
} }
}
}; };
new AlertDialog.Builder(IncallActivity.this).setTitle(R.string.transfer_dialog_title).setAdapter(adapter, l).create().show(); 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: case R.id.terminate_call:
lc().terminateCall(call); lc().terminateCall(call);
break; 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: case R.id.transfer_existing:
prepareForTransferingExistingCall(call); prepareForTransferingExistingOrNewCall(call);
break; break;
case R.id.transfer_new: case R.id.transfer_new:
openUriPicker(UriPickerActivity.EXTRA_PICKER_TYPE_TRANSFER, ID_TRANSFER_CALL); openUriPicker(UriPickerActivity.EXTRA_PICKER_TYPE_TRANSFER, ID_TRANSFER_CALL);
callToTransfer = call; mCallToTransfer = call;
break;
case R.id.remove_from_conference:
lc().removeFromConference(call);
break; break;
case R.id.addVideo: case R.id.addVideo:
if (!LinphoneManager.getInstance().addVideo()) { if (!LinphoneManager.getInstance().addVideo()) {
@ -507,18 +408,12 @@ public class IncallActivity extends ListActivity implements
} }
} }
private class CalleeListAdapter extends BaseAdapter { private class CalleeListAdapter extends BaseAdapter {
private List<LinphoneCall> linphoneCalls;
public CalleeListAdapter(List<LinphoneCall> calls) {
linphoneCalls = calls;
}
public int getCount() { public int getCount() {
return linphoneCalls != null ? linphoneCalls.size() : 0; return mNotInConfCalls.size();
} }
public Object getItem(int position) { public Object getItem(int position) {
return linphoneCalls.get(position); return mNotInConfCalls.get(position);
} }
public long getItemId(int position) { public long getItemId(int position) {
@ -530,7 +425,7 @@ public class IncallActivity extends ListActivity implements
return false; return false;
} }
int count = 0; int count = 0;
for (LinphoneCall call : linphoneCalls) { for (LinphoneCall call : mNotInConfCalls) {
final LinphoneCall.State state = call.getState(); final LinphoneCall.State state = call.getState();
boolean connectionEstablished = state == State.StreamsRunning boolean connectionEstablished = state == State.StreamsRunning
|| state == State.Paused || state == State.Paused
@ -544,25 +439,28 @@ public class IncallActivity extends ListActivity implements
} }
private void setVisibility(View v, int id, boolean visible) { 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) { 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); 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); ((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) { 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 (v == null) {
if (Version.sdkAboveOrEqual(Version.API06_ECLAIR_201)) { if (Version.sdkAboveOrEqual(Version.API06_ECLAIR_201)) {
v = getLayoutInflater().inflate(R.layout.conf_callee, null); 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(); final LinphoneCall.State state = call.getState();
LinphoneAddress address = call.getRemoteAddress(); LinphoneAddress address = call.getRemoteAddress();
String mainText = address.getDisplayName(); String mainText = address.getDisplayName();
String complText = address.getUserName(); 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 mainTextView = (TextView) v.findViewById(R.id.name);
TextView complTextView = (TextView) v.findViewById(R.id.address); TextView complTextView = (TextView) v.findViewById(R.id.address);
if (TextUtils.isEmpty(mainText)) { if (TextUtils.isEmpty(mainText)) {
@ -592,20 +486,15 @@ public class IncallActivity extends ListActivity implements
complTextView.setVisibility(View.VISIBLE); complTextView.setVisibility(View.VISIBLE);
} }
final boolean isInConference = call.isInConference(); boolean highlighted = highlightCall(call);
boolean currentlyActiveCall = !isInConference setStatusLabel(v, state, highlighted);
&& state == State.StreamsRunning;
setStatusLabel(v, state, isInConference, currentlyActiveCall);
int bgDrawableId = R.drawable.conf_callee_selector_normal; int bgDrawableId = R.drawable.conf_callee_selector_normal;
if (state == State.IncomingReceived) { if (state == State.IncomingReceived) {
bgDrawableId = R.drawable.conf_callee_selector_incoming; bgDrawableId = R.drawable.conf_callee_selector_incoming;
} else if (currentlyActiveCall) { } else if (highlighted) {
bgDrawableId = R.drawable.conf_callee_selector_active; bgDrawableId = R.drawable.conf_callee_selector_active;
} else if (isInConference) {
bgDrawableId = R.drawable.conf_callee_selector_inconf;
} }
v.setBackgroundResource(bgDrawableId); v.setBackgroundResource(bgDrawableId);
@ -613,35 +502,11 @@ public class IncallActivity extends ListActivity implements
|| state == State.Paused || state == State.Paused
|| state == State.PausedByRemote; || state == State.PausedByRemote;
View confButton = v.findViewById(R.id.merge_to_conference); View confButton = v.findViewById(R.id.merge_to_conference);
final boolean showMergeToConf = !isInConference && connectionEstablished final boolean showMergeToConf = connectionEstablished && aConferenceIsPossible();
&& aConferenceIsPossible();
setVisibility(confButton, false); setVisibility(confButton, false);
View unhookCallButton = v.findViewById(R.id.unhook_call); final int numberOfCalls = mNotInConfCalls.size();
boolean showUnhook = state == State.IncomingReceived; boolean showAddVideo = State.StreamsRunning == state
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
&& Version.isVideoCapable() && Version.isVideoCapable()
&& LinphoneManager.getInstance().isVideoEnabled(); && LinphoneManager.getInstance().isVideoEnabled();
View addVideoButton = v.findViewById(R.id.addVideo); 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; boolean statusPaused = state== State.Paused || state == State.PausedByRemote;
setVisibility(v, R.id.callee_status_paused, statusPaused); setVisibility(v, R.id.callee_status_paused, statusPaused);
setVisibility(v, R.id.callee_status_inconf, isInConference);
final OnClickListener l = new CallActionListener(call); final OnClickListener l = new CallActionListener(call);
confButton.setOnClickListener(l); confButton.setOnClickListener(l);
terminateCallButton.setOnClickListener(l);
pauseButton.setOnClickListener(l);
resumeButton.setOnClickListener(l);
unhookCallButton.setOnClickListener(l);
removeFromConfButton.setOnClickListener(l);
addVideoButton.setOnClickListener(l); addVideoButton.setOnClickListener(l);
String mediaEncryption = call.getCurrentParamsCopy().getMediaEncryption(); String mediaEncryption = call.getCurrentParamsCopy().getMediaEncryption();
if ("none".equals(mediaEncryption)) { if ("none".equals(mediaEncryption)) {
boolean showUnencrypted = Version.hasZrtp();
setVisibility(v, R.id.callee_status_secured, false); setVisibility(v, R.id.callee_status_secured, false);
setVisibility(v, R.id.callee_status_maybe_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 { } else {
boolean reallySecured = !Version.hasZrtp() || call.isAuthenticationTokenVerified(); boolean reallySecured = !Version.hasZrtp() || call.isAuthenticationTokenVerified();
setVisibility(v, R.id.callee_status_secured, reallySecured); 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); setVisibility(v, R.id.callee_status_not_secured, false);
} }
v.setOnClickListener(new OnClickListener() { v.setOnLongClickListener(new OnLongClickListener() {
public void onClick(View v) { public boolean onLongClick(View v) {
if (lc().soundResourcesLocked()) { if (lc().soundResourcesLocked()) {
return; return false;
} }
View content = getLayoutInflater().inflate(R.layout.conf_choices_dialog, null); View content = getLayoutInflater().inflate(R.layout.conf_choices_dialog, null);
Dialog dialog = new AlertDialog.Builder(IncallActivity.this).setView(content).create(); Dialog dialog = new AlertDialog.Builder(IncallActivity.this).setView(content).create();
OnClickListener l = new CallActionListener(call, dialog); OnClickListener l = new CallActionListener(call, dialog);
enableView(content, R.id.transfer_existing, l, allowTransfers && !isInConference && numberOfCalls >=2); enableView(content, R.id.transfer_existing, l, mAllowTransfers && numberOfCalls >=2);
enableView(content, R.id.transfer_new, l, allowTransfers && !isInConference); enableView(content, R.id.transfer_new, l, mAllowTransfers);
enableView(content, R.id.remove_from_conference, l, isInConference);
enableView(content, R.id.merge_to_conference, l, showMergeToConf); 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); enableView(content, R.id.terminate_call, l, true);
String mediaEncryption = call.getCurrentParamsCopy().getMediaEncryption(); String mediaEncryption = call.getCurrentParamsCopy().getMediaEncryption();
@ -710,6 +564,21 @@ public class IncallActivity extends ListActivity implements
} }
dialog.show(); 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) { private String getStateText(State state) {
int id; int id;
if (state == State.IncomingReceived) { if (state == State.StreamsRunning) {
id=R.string.state_incoming_received; id=R.string.status_active_call;
} else if (state == State.OutgoingRinging) {
id=R.string.state_outgoing_ringing;
} else if (state == State.Paused) { } else if (state == State.Paused) {
id=R.string.state_paused; id=R.string.state_paused;
} else if (state == State.PausedByRemote) { } else if (state == State.PausedByRemote) {
id=R.string.state_paused_by_remote; 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 { } else {
return ""; return "";
} }
@ -746,78 +617,56 @@ public class IncallActivity extends ListActivity implements
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
private static int conferenceCalleesNb(LinphoneCore lc) {
int count = lc.getConferenceSize();
if (lc.isInConference()) count--;
return count;
}
private void updateSimpleControlButtons() { private void updateSimpleControlButtons() {
LinphoneCall activeCall = lc().getCurrentCall(); LinphoneCall activeCall = lc().getCurrentCall();
View control = findViewById(R.id.conf_control_buttons); View control = findViewById(R.id.conf_control_buttons);
int callNb = lc().getCallsNb(); int nonConfCallsNb = LinphoneUtils.countNonConferenceCalls(lc());
View permute = control.findViewById(R.id.conf_simple_permute);
boolean showPermute = activeCall != null && callNb == 2;
permute.setVisibility(showPermute ? VISIBLE : GONE);
View resume = control.findViewById(R.id.conf_simple_resume);
boolean showResume = activeCall == null && LinphoneUtils.hasExistingResumeableCall(lc());
resume.setVisibility(showResume ? VISIBLE : GONE);
View merge = control.findViewById(R.id.conf_simple_merge); 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); merge.setVisibility(showMerge ? VISIBLE : GONE);
View transfer = control.findViewById(R.id.conf_simple_transfer); 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); transfer.setVisibility(showTransfer ? VISIBLE : GONE);
boolean showControl = (showMerge || showPermute || showResume || showTransfer) || lc().getConferenceSize() > 0; boolean showControl = showMerge || showTransfer;
control.setVisibility(showControl ? VISIBLE : GONE); control.setVisibility(showControl ? VISIBLE : GONE);
} }
public void onCallStateChanged(final LinphoneCall call, final State state, public void onCallStateChanged(final LinphoneCall c, final State s, String m) {
final String message) {
final String stateStr = call + " " + state.toString();
Log.d("IncallActivity received state ",stateStr);
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
public void run() { public void run() {
CalleeListAdapter adapter = (CalleeListAdapter) getListAdapter(); mNotInConfCalls = LinphoneUtils.getLinphoneCallsNotInConf(lc());
Log.d("IncallActivity applying state ",stateStr); recreateActivity();
}
});
}
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(); updateSimpleControlButtons();
updateCalleeImage(); updateCalleeImage();
updateSoundLock(); updateSoundLock();
updateAddCallButton(); updateAddCallButton();
updateDtmfButton(); updateDtmfButton();
if (state == State.IncomingReceived || state == State.OutgoingRinging) { updateConfItem();
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(); mListAdapter.notifyDataSetChanged();
}
});
}
private void recreateActivity(CalleeListAdapter adapter) {
adapter.notifyDataSetInvalidated();
adapter.notifyDataSetChanged();
} }
public int compare(LinphoneCall c1, LinphoneCall c2) { public int compare(LinphoneCall c1, LinphoneCall c2) {
@ -853,10 +702,10 @@ public class IncallActivity extends ListActivity implements
return true; return true;
} }
private LinphoneCall callToTransfer; private LinphoneCall mCallToTransfer;
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (unMuteOnReturnFromUriPicker) { if (mUnMuteOnReturnFromUriPicker) {
lc().muteMic(false); lc().muteMic(false);
((ToggleButton) findViewById(R.id.toggleMuteMic)).setChecked(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); uri = data.getStringExtra(UriPickerActivity.EXTRA_CALLEE_URI);
} }
if (resultCode != RESULT_OK || TextUtils.isEmpty(uri)) { if (resultCode != RESULT_OK || TextUtils.isEmpty(uri)) {
callToTransfer = null; mCallToTransfer = null;
Toast.makeText(this, R.string.uri_picking_canceled, Toast.LENGTH_LONG).show(); Toast.makeText(this, R.string.uri_picking_canceled, Toast.LENGTH_LONG).show();
eventuallyResumeConfOrCallOnPickerReturn(true); eventuallyResumeConfOrCallOnPickerReturn(true);
return; return;
@ -895,11 +744,11 @@ public class IncallActivity extends ListActivity implements
} }
break; break;
case ID_TRANSFER_CALL: case ID_TRANSFER_CALL:
lc().transferCall(callToTransfer, uri); lc().transferCall(mCallToTransfer, uri);
// don't re-enter conference if call to transfer from conference // 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 // don't resume call if it is the call to transfer
doResume &= activateCallOnReturnFromUriPicker != callToTransfer; doResume &= activateCallOnReturnFromUriPicker != mCallToTransfer;
eventuallyResumeConfOrCallOnPickerReturn(doResume); eventuallyResumeConfOrCallOnPickerReturn(doResume);
Toast.makeText(this, R.string.transfer_started, Toast.LENGTH_LONG).show(); Toast.makeText(this, R.string.transfer_started, Toast.LENGTH_LONG).show();
break; break;
@ -913,7 +762,7 @@ public class IncallActivity extends ListActivity implements
if (activateCallOnReturnFromUriPicker != null) { if (activateCallOnReturnFromUriPicker != null) {
lc().resumeCall(activateCallOnReturnFromUriPicker); lc().resumeCall(activateCallOnReturnFromUriPicker);
} else if (enterConferenceOnReturnFromUriPicker) { } else if (enterConferenceOnReturnFromUriPicker) {
lc().enterConference(); enterConferenceAndUpdateUI(true);
} }
} }
activateCallOnReturnFromUriPicker = null; activateCallOnReturnFromUriPicker = null;
@ -951,8 +800,7 @@ public class IncallActivity extends ListActivity implements
String authenticationToken) { String authenticationToken) {
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
public void run() { public void run() {
CalleeListAdapter adapter = (CalleeListAdapter) getListAdapter(); recreateActivity();
recreateActivity(adapter);
} }
}); });
} }

View file

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

View file

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

View file

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

View file

@ -18,11 +18,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package org.linphone; package org.linphone;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;
import org.linphone.core.LinphoneAddress; import org.linphone.core.LinphoneAddress;
@ -41,6 +45,8 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.net.Uri; import android.net.Uri;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView; import android.widget.ImageView;
/** /**
@ -116,6 +122,7 @@ public final class LinphoneUtils {
return null; return null;
} }
public static void setImagePictureFromUri(Context c, ImageView view, Uri uri, int notFoundResource) { public static void setImagePictureFromUri(Context c, ImageView view, Uri uri, int notFoundResource) {
if (uri == null) { if (uri == null) {
view.setImageResource(notFoundResource); view.setImageResource(notFoundResource);
@ -129,12 +136,33 @@ public final class LinphoneUtils {
if (Version.sdkAboveOrEqual(Version.API06_ECLAIR_201)) { if (Version.sdkAboveOrEqual(Version.API06_ECLAIR_201)) {
view.setImageURI(uri); view.setImageURI(uri);
} else { } else {
@SuppressWarnings("deprecation")
Bitmap bitmap = android.provider.Contacts.People.loadContactPhoto(c, uri, notFoundResource, null); Bitmap bitmap = android.provider.Contacts.People.loadContactPhoto(c, uri, notFoundResource, null);
view.setImageBitmap(bitmap); 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") @SuppressWarnings("unchecked")
public static final List<LinphoneCall> getLinphoneCalls(LinphoneCore lc) { public static final List<LinphoneCall> getLinphoneCalls(LinphoneCore lc) {
return (List<LinphoneCall>) lc.getCalls(); return (List<LinphoneCall>) lc.getCalls();
@ -159,5 +187,31 @@ public final class LinphoneUtils {
} }
return foundCalls; 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); leaveConference(nativePtr);
} }
private native void enterConference(long nativePtr); private native boolean enterConference(long nativePtr);
public synchronized void enterConference() { public synchronized boolean enterConference() {
enterConference(nativePtr); return enterConference(nativePtr);
} }
private native boolean isInConference(long nativePtr); private native boolean isInConference(long nativePtr);

View file

@ -65,29 +65,7 @@ public class IncallTimer extends TextView {
} }
} }
public void setDuration(int duration) {
/** super.setText(formatTime(duration));
* 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();
}
*/
} }

@ -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!)
}
}