Update Chat ui
This commit is contained in:
parent
3aae0ef4c3
commit
a1f30e0531
10 changed files with 621 additions and 627 deletions
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item android:maxLevel="0" android:drawable="@drawable/status_orange" />
|
<item android:maxLevel="0" android:drawable="@drawable/linphone_user" />
|
||||||
<item android:maxLevel="1" android:drawable="@drawable/status_green" />
|
<item android:maxLevel="1" android:drawable="@drawable/status_green" />
|
||||||
<item android:maxLevel="2" android:drawable="@drawable/status_red" />
|
<item android:maxLevel="2" android:drawable="@drawable/status_red" />
|
||||||
<item android:maxLevel="3" android:drawable="@drawable/status_offline" />
|
<item android:maxLevel="3" android:drawable="@drawable/status_offline" />
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/bubble"
|
android:id="@+id/bubble"
|
||||||
android:background="@drawable/resizable_chat_bubble_incoming"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/resizable_chat_bubble_incoming"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/avatar_layout"
|
android:id="@+id/avatar_layout"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -65,24 +70,50 @@
|
||||||
android:layout_width="150dp"
|
android:layout_width="150dp"
|
||||||
android:layout_height="150dp"
|
android:layout_height="150dp"
|
||||||
android:scaleType="center"
|
android:scaleType="center"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
android:maxWidth="250dp"
|
android:maxWidth="250dp"
|
||||||
android:maxHeight="250dp" />
|
android:maxHeight="250dp" />
|
||||||
|
|
||||||
<Button
|
<RelativeLayout
|
||||||
android:id="@+id/download"
|
android:id="@+id/imageLayout"
|
||||||
android:text="@string/download_image"
|
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progress_bar"
|
||||||
|
android:paddingRight="5dp"
|
||||||
|
style="@android:style/Widget.ProgressBar.Horizontal"
|
||||||
|
android:layout_width="200dp"
|
||||||
|
android:layout_height="5dp"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/accept_download"
|
||||||
|
android:text="@string/accept"
|
||||||
|
android:background="@drawable/resizable_assistant_button"
|
||||||
|
style="@style/font8"
|
||||||
|
android:contentDescription="@string/content_description_validate"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_below="@id/progress_bar"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<ProgressBar
|
</LinearLayout>
|
||||||
android:id="@+id/spinner"
|
|
||||||
style="@android:style/Widget.ProgressBar.Horizontal"
|
<CheckBox
|
||||||
android:visibility="gone"
|
android:id="@+id/delete"
|
||||||
android:layout_marginTop="20dp"
|
android:button="@drawable/checkbox"
|
||||||
|
android:contentDescription="@string/content_description_delete"
|
||||||
|
android:paddingRight="5dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="5dp"/>
|
android:layout_height="wrap_content"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -1,11 +1,16 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/bubble"
|
android:id="@+id/bubble"
|
||||||
android:background="@drawable/resizable_chat_bubble_outgoing"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/resizable_chat_bubble_outgoing"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/contact_picture"
|
android:id="@+id/contact_picture"
|
||||||
android:src="@drawable/avatar"
|
android:src="@drawable/avatar"
|
||||||
|
@ -36,22 +41,49 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/inprogress"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:paddingRight="5dp"
|
||||||
|
android:paddingTop="5dp"
|
||||||
|
android:layout_gravity="top|right"
|
||||||
|
android:layout_width="20dp"
|
||||||
|
android:layout_height="20dp"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/image"
|
android:id="@+id/image"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:layout_width="150dp"
|
android:layout_width="150dp"
|
||||||
android:layout_height="150dp"
|
android:layout_height="150dp"
|
||||||
android:scaleType="center"
|
android:scaleType="center"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
android:maxWidth="250dp"
|
android:maxWidth="250dp"
|
||||||
android:maxHeight="250dp" />
|
android:maxHeight="250dp" />
|
||||||
|
|
||||||
<ProgressBar
|
<RelativeLayout
|
||||||
android:id="@+id/spinner"
|
android:id="@+id/imageLayout"
|
||||||
style="@android:style/Widget.ProgressBar.Horizontal"
|
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progress_bar"
|
||||||
|
android:paddingRight="5dp"
|
||||||
|
style="@android:style/Widget.ProgressBar.Horizontal"
|
||||||
|
android:layout_width="200dp"
|
||||||
android:layout_height="5dp"/>
|
android:layout_height="5dp"/>
|
||||||
|
<Button
|
||||||
|
android:id="@+id/cancel_upload"
|
||||||
|
android:text="@string/cancel"
|
||||||
|
android:background="@drawable/resizable_confirm_delete_button"
|
||||||
|
style="@style/font15"
|
||||||
|
android:contentDescription="@string/content_description_validate"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_below="@id/progress_bar"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -66,20 +98,20 @@
|
||||||
android:layout_height="20dp"
|
android:layout_height="20dp"
|
||||||
android:adjustViewBounds="true" />
|
android:adjustViewBounds="true" />
|
||||||
|
|
||||||
<ProgressBar
|
</LinearLayout>
|
||||||
android:id="@+id/inprogress"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:paddingRight="5dp"
|
|
||||||
android:paddingTop="5dp"
|
|
||||||
android:layout_gravity="top|right"
|
|
||||||
android:layout_width="20dp"
|
|
||||||
android:layout_height="20dp"/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/download"
|
|
||||||
android:text="@string/download_image"
|
<CheckBox
|
||||||
android:visibility="gone"
|
android:id="@+id/delete"
|
||||||
|
android:button="@drawable/checkbox"
|
||||||
|
android:contentDescription="@string/content_description_delete"
|
||||||
|
android:paddingRight="5dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
|
|
||||||
<Chronometer
|
<Chronometer
|
||||||
android:id="@+id/callTimer"
|
android:id="@+id/call_timer"
|
||||||
style="@style/font2"
|
style="@style/font2"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -103,6 +103,7 @@
|
||||||
android:scrollHorizontally="true"
|
android:scrollHorizontally="true"
|
||||||
android:fadingEdge="horizontal"
|
android:fadingEdge="horizontal"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
|
android:gravity="center_vertical"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_toRightOf="@id/icon"
|
android:layout_toRightOf="@id/icon"
|
||||||
|
|
|
@ -1,32 +1,18 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<!-- New settings -->
|
<!-- New settings -->
|
||||||
|
<!-- TODO Migrate it in linphonerc -->
|
||||||
<bool name="assistant_use_linphone_login_as_first_fragment">false</bool>
|
<bool name="assistant_use_linphone_login_as_first_fragment">false</bool>
|
||||||
<string name="default_domain">sip.linphone.org</string>
|
<string name="default_domain">sip.linphone.org</string>
|
||||||
|
<string name="default_stun">stun.linphone.org</string>
|
||||||
|
|
||||||
|
<string name="wizard_url">https://www.linphone.org/wizard.php</string>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Tutorial settings -->
|
|
||||||
<bool name="show_tutorials_instead_of_app">false</bool> <!-- Be careful ! Setting this to true prevent the app from working ! It will only display tutorial activities -->
|
|
||||||
|
|
||||||
<!-- Push notification settings -->
|
<!-- Push notification settings -->
|
||||||
<bool name="enable_push_id">true</bool>
|
<bool name="enable_push_id">true</bool>
|
||||||
<string name="push_sender_id">622464153529</string>
|
<string name="push_sender_id">622464153529</string>
|
||||||
|
|
||||||
|
|
||||||
<string name="default_stun">stun.linphone.org</string>
|
|
||||||
<bool name="override_domain_using_default_one">false</bool> <!-- Replace the domain for outgoing calls by the one above -->
|
|
||||||
<string name="wizard_url">https://www.linphone.org/wizard.php</string>
|
|
||||||
|
|
||||||
<!-- Interface settings -->
|
|
||||||
|
|
||||||
<bool name="hide_camera_settings">false</bool>
|
<bool name="hide_camera_settings">false</bool>
|
||||||
<bool name="replace_wizard_with_old_interface">false</bool>
|
|
||||||
<bool name="hide_wizard">false</bool>
|
<bool name="hide_wizard">false</bool>
|
||||||
<string name="setup_forced_proxy"></string>
|
|
||||||
<bool name="setup_cancel_move_to_back">false</bool>
|
|
||||||
|
|
||||||
<bool name="setup_account_validation_mandatory">false</bool>
|
<bool name="setup_account_validation_mandatory">false</bool>
|
||||||
<bool name="hide_linphone_accounts_wizard">false</bool>
|
<bool name="hide_linphone_accounts_wizard">false</bool>
|
||||||
|
@ -38,59 +24,58 @@
|
||||||
<bool name="use_linphone_server_ports">true</bool>
|
<bool name="use_linphone_server_ports">true</bool>
|
||||||
<bool name="allow_only_phone_numbers_in_wizard">false</bool>
|
<bool name="allow_only_phone_numbers_in_wizard">false</bool>
|
||||||
|
|
||||||
<bool name="use_android_native_contact_edit_interface">false</bool>
|
|
||||||
<!-- The following settings are only usefull if use_android_native_contact_edit_interface = false -->
|
|
||||||
<bool name="hide_phone_numbers_in_editor">false</bool>
|
|
||||||
<bool name="hide_sip_addresses_in_editor">false</bool>
|
|
||||||
<bool name="forbid_empty_new_contact_in_editor">true</bool>
|
|
||||||
|
|
||||||
<bool name="disable_animations">false</bool>
|
|
||||||
<bool name="show_statusbar_only_on_dialer">true</bool>
|
|
||||||
<bool name="emoticons_in_messages">true</bool>
|
|
||||||
<bool name="only_display_username_if_unknown">true</bool> <!-- Display username for all sip addresses (if not in contact and display name empty) -->
|
|
||||||
<bool name="never_display_sip_addresses">false</bool> <!-- To use only with the above setting set to true -->
|
|
||||||
<bool name="display_messages_time_and_status">true</bool> <!-- Used to show the time of each message arrival -->
|
|
||||||
|
|
||||||
<bool name="enable_linphone_friends">false</bool>
|
<bool name="enable_linphone_friends">false</bool>
|
||||||
<bool name="use_linphone_tag">true</bool>
|
<bool name="use_linphone_tag">true</bool>
|
||||||
|
|
||||||
<bool name="display_call_stats">true</bool>
|
|
||||||
<bool name="show_current_calls_above_video">false</bool>
|
|
||||||
<bool name="disable_options_in_call">false</bool>
|
<bool name="disable_options_in_call">false</bool>
|
||||||
|
|
||||||
<!-- Behavior Settings -->
|
|
||||||
<bool name="pre_fill_email_in_wizard">true</bool> <!-- Set the email field of the wizard with one of the gmail account registered on the device -->
|
<bool name="pre_fill_email_in_wizard">true</bool> <!-- Set the email field of the wizard with one of the gmail account registered on the device -->
|
||||||
<bool name="allow_chat_multiline">false</bool>
|
|
||||||
<bool name="call_last_log_if_adress_is_empty">true</bool>
|
<bool name="call_last_log_if_adress_is_empty">true</bool>
|
||||||
|
|
||||||
<bool name="allow_ringing_while_early_media">true</bool>
|
<bool name="allow_ringing_while_early_media">true</bool>
|
||||||
<bool name="allow_transfers">true</bool>
|
|
||||||
<bool name="allow_edit_in_dialer">true</bool>
|
|
||||||
<bool name="forbid_self_call">false</bool>
|
|
||||||
<bool name="disable_chat">false</bool>
|
<bool name="disable_chat">false</bool>
|
||||||
<bool name="disable_chat__message_notification">false</bool>
|
<bool name="disable_chat_message_notification">false</bool>
|
||||||
|
|
||||||
<bool name="disable_chat_send_file">false</bool>
|
<bool name="disable_chat_send_file">false</bool>
|
||||||
<bool name="use_linphone_chat_storage">true</bool>
|
|
||||||
<bool name="auto_answer_calls">false</bool>
|
<bool name="auto_answer_calls">false</bool>
|
||||||
<bool name="intercept_outgoing_gsm_calls">false</bool>
|
|
||||||
|
<bool name="allow_transfers">true</bool>
|
||||||
|
|
||||||
|
<bool name="forbid_self_call">false</bool>
|
||||||
|
|
||||||
|
<bool name="disable_animations">false</bool>
|
||||||
|
|
||||||
<bool name="automatically_start_intercepted_outgoing_gsm_call">true</bool>
|
<bool name="automatically_start_intercepted_outgoing_gsm_call">true</bool>
|
||||||
<bool name="use_linphonecore_ringing">false</bool>
|
|
||||||
<!-- This settings handle the behavior of the view waiting for the remote provisioning configuration to be done -->
|
<!-- This settings handle the behavior of the view waiting for the remote provisioning configuration to be done -->
|
||||||
<bool name="display_sms_remote_provisioning_activity">false</bool>
|
<bool name="display_sms_remote_provisioning_activity">false</bool>
|
||||||
<bool name="forbid_app_usage_until_remote_provisioning_completed">false</bool>
|
<bool name="forbid_app_usage_until_remote_provisioning_completed">false</bool>
|
||||||
<bool name="display_confirmation_popup_after_first_configuration">false</bool>
|
<bool name="display_confirmation_popup_after_first_configuration">false</bool>
|
||||||
|
|
||||||
<bool name="hash_images_as_name_before_upload">true</bool>
|
|
||||||
|
|
||||||
<bool name="enable_log_collect">false</bool>
|
<bool name="enable_log_collect">false</bool>
|
||||||
<bool name="disable_every_log">false</bool>
|
<bool name="disable_every_log">false</bool>
|
||||||
<bool name="disable_all_security_features_for_markets">false</bool> <!-- Disable TLS/SRTP/ZRTP -->
|
<bool name="disable_all_security_features_for_markets">false</bool> <!-- Disable TLS/SRTP/ZRTP -->
|
||||||
<bool name="disable_all_patented_codecs_for_markets">false</bool> <!-- Disable MPEG4/H264 -->
|
<bool name="disable_all_patented_codecs_for_markets">false</bool> <!-- Disable MPEG4/H264 -->
|
||||||
|
|
||||||
<string name="about_bugreport_email">linphone-android@belledonne-communications.com</string>
|
<string name="about_bugreport_email">linphone-android@belledonne-communications.com</string>
|
||||||
|
<bool name="use_linphonecore_ringing">false</bool>
|
||||||
|
|
||||||
|
|
||||||
<string name="temp_photo_name">linphone-android-photo-temp.jpg</string>
|
<string name="temp_photo_name">linphone-android-photo-temp.jpg</string>
|
||||||
<string name="temp_photo_name_with_date">linphone-android-photo-%s.jpg</string>
|
<string name="temp_photo_name_with_date">linphone-android-photo-%s.jpg</string>
|
||||||
|
|
||||||
|
|
||||||
|
<bool name="hide_phone_numbers_in_editor">false</bool>
|
||||||
|
<bool name="hide_sip_addresses_in_editor">false</bool>
|
||||||
|
<bool name="setup_cancel_move_to_back">false</bool>
|
||||||
|
<bool name="replace_wizard_with_old_interface">false</bool>
|
||||||
|
|
||||||
|
|
||||||
<bool name="enable_call_notification">true</bool>
|
<bool name="enable_call_notification">true</bool>
|
||||||
<bool name="kill_service_with_task_manager">true</bool>
|
<bool name="kill_service_with_task_manager">true</bool>
|
||||||
|
|
||||||
|
<bool name="hash_images_as_name_before_upload">true</bool>
|
||||||
|
|
||||||
|
<!-- Tutorial settings -->
|
||||||
|
<bool name="show_tutorials_instead_of_app">false</bool> <!-- Be careful ! Setting this to true prevent the app from working ! It will only display tutorial activities -->
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.zip.Inflater;
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
import org.linphone.compatibility.Compatibility;
|
import org.linphone.compatibility.Compatibility;
|
||||||
|
@ -40,11 +40,8 @@ import org.linphone.core.LinphoneChatRoom;
|
||||||
import org.linphone.core.LinphoneContent;
|
import org.linphone.core.LinphoneContent;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneChatMessage.State;
|
import org.linphone.core.LinphoneChatMessage.State;
|
||||||
import org.linphone.core.LinphoneCoreException;
|
|
||||||
import org.linphone.core.LinphoneCoreFactory;
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
import org.linphone.core.LinphoneCoreListenerBase;
|
import org.linphone.core.LinphoneCoreListenerBase;
|
||||||
import org.linphone.core.LinphoneFriend;
|
|
||||||
import org.linphone.core.PresenceActivityType;
|
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
import org.linphone.ui.BubbleChat;
|
import org.linphone.ui.BubbleChat;
|
||||||
|
|
||||||
|
@ -79,21 +76,17 @@ import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
import android.view.ViewTreeObserver;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.AbsListView;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.AutoCompleteTextView;
|
import android.widget.AutoCompleteTextView;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CheckBox;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Filter;
|
import android.widget.Filter;
|
||||||
import android.widget.Filterable;
|
import android.widget.Filterable;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.SectionIndexer;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
@ -147,7 +140,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
instance = this;
|
instance = this;
|
||||||
View view = inflater.inflate(R.layout.chat, container, false);
|
final View view = inflater.inflate(R.layout.chat, container, false);
|
||||||
|
|
||||||
LinphoneManager.addListener(this);
|
LinphoneManager.addListener(this);
|
||||||
// Retain the fragment across configuration changes
|
// Retain the fragment across configuration changes
|
||||||
|
@ -164,10 +157,10 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
|
|
||||||
//Initialize UI
|
//Initialize UI
|
||||||
contactName = (TextView) view.findViewById(R.id.contact_name);
|
contactName = (TextView) view.findViewById(R.id.contact_name);
|
||||||
//contactPicture = (ImageView) view.findViewById(R.id.contactPicture);
|
|
||||||
messagesList = (ListView) view.findViewById(R.id.chatMessageList);
|
messagesList = (ListView) view.findViewById(R.id.chatMessageList);
|
||||||
searchContactField = (AutoCompleteTextView) view.findViewById(R.id.searchContactField);
|
searchContactField = (AutoCompleteTextView) view.findViewById(R.id.searchContactField);
|
||||||
|
|
||||||
|
editList = (RelativeLayout) view.findViewById(R.id.edit_list);
|
||||||
textLayout = (RelativeLayout) view.findViewById(R.id.messageLayout);
|
textLayout = (RelativeLayout) view.findViewById(R.id.messageLayout);
|
||||||
topBar = (RelativeLayout) view.findViewById(R.id.top_bar);
|
topBar = (RelativeLayout) view.findViewById(R.id.top_bar);
|
||||||
|
|
||||||
|
@ -180,8 +173,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
uploadLayout = (RelativeLayout) view.findViewById(R.id.uploadLayout);
|
uploadLayout = (RelativeLayout) view.findViewById(R.id.uploadLayout);
|
||||||
uploadLayout.setVisibility(View.GONE);
|
uploadLayout.setVisibility(View.GONE);
|
||||||
|
|
||||||
editList = (RelativeLayout) view.findViewById(R.id.edit_list);
|
|
||||||
|
|
||||||
cancel = (ImageView) view.findViewById(R.id.cancel);
|
cancel = (ImageView) view.findViewById(R.id.cancel);
|
||||||
cancel.setOnClickListener(this);
|
cancel.setOnClickListener(this);
|
||||||
|
|
||||||
|
@ -207,7 +198,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
edit.setVisibility(View.INVISIBLE);
|
edit.setVisibility(View.INVISIBLE);
|
||||||
startCall.setVisibility(View.INVISIBLE);
|
startCall.setVisibility(View.INVISIBLE);
|
||||||
} else {
|
} else {
|
||||||
displayChatHeader(displayName, pictureUri);
|
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
chatRoom = lc.getOrCreateChatRoom(sipUri);
|
chatRoom = lc.getOrCreateChatRoom(sipUri);
|
||||||
|
@ -215,7 +205,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LinphoneAddress lAddress;
|
LinphoneAddress lAddress = null;
|
||||||
try {
|
try {
|
||||||
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
|
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
|
||||||
contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
||||||
|
@ -223,12 +213,10 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
displayChatHeader(lAddress);
|
||||||
|
|
||||||
//Manage multiline
|
//Manage multiline
|
||||||
message = (EditText) view.findViewById(R.id.message);
|
message = (EditText) view.findViewById(R.id.message);
|
||||||
if (!getResources().getBoolean(R.bool.allow_chat_multiline)) {
|
|
||||||
message.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE);
|
|
||||||
message.setMaxLines(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
sendImage = (ImageView) view.findViewById(R.id.sendPicture);
|
sendImage = (ImageView) view.findViewById(R.id.sendPicture);
|
||||||
if (!getResources().getBoolean(R.bool.disable_chat_send_file)) {
|
if (!getResources().getBoolean(R.bool.disable_chat_send_file)) {
|
||||||
|
@ -260,7 +248,8 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
if (currentMessageInFileTransferUploadState != null) {
|
if (currentMessageInFileTransferUploadState != null) {
|
||||||
uploadLayout.setVisibility(View.GONE);
|
uploadLayout.setVisibility(View.GONE);
|
||||||
textLayout.setVisibility(View.VISIBLE);
|
textLayout.setVisibility(View.VISIBLE);
|
||||||
progressBar.setProgress(0);
|
|
||||||
|
//progressBar.setProgress(0);
|
||||||
currentMessageInFileTransferUploadState.cancelFileTransfer();
|
currentMessageInFileTransferUploadState.cancelFileTransfer();
|
||||||
currentMessageInFileTransferUploadState = null;
|
currentMessageInFileTransferUploadState = null;
|
||||||
LinphoneManager.getInstance().setUploadPendingFileMessage(null);
|
LinphoneManager.getInstance().setUploadPendingFileMessage(null);
|
||||||
|
@ -327,9 +316,9 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
|
|
||||||
int heightDiff = getActivity().getWindow().getDecorView().getRootView().getHeight() - (visibleArea.bottom - visibleArea.top);
|
int heightDiff = getActivity().getWindow().getDecorView().getRootView().getHeight() - (visibleArea.bottom - visibleArea.top);
|
||||||
if (heightDiff > 200) {
|
if (heightDiff > 200) {
|
||||||
showKeyboardVisibleMode();
|
//showKeyboardVisibleMode();
|
||||||
} else {
|
} else {
|
||||||
hideKeyboardVisibleMode();
|
//hideKeyboardVisibleMode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -366,9 +355,29 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshHistory() {
|
public void refreshHistory() {
|
||||||
|
this.history = null;
|
||||||
this.history = chatRoom.getHistory();
|
this.history = chatRoom.getHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addMessage(LinphoneChatMessage message) {
|
||||||
|
LinphoneChatMessage[] newHist = new LinphoneChatMessage[getCount() +1];
|
||||||
|
for(int i=0; i< getCount(); i++){
|
||||||
|
newHist[i] = this.history[i];
|
||||||
|
}
|
||||||
|
newHist[getCount()] = message;
|
||||||
|
this.history = newHist;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeMessage(LinphoneChatMessage message) {
|
||||||
|
LinphoneChatMessage[] newHist = new LinphoneChatMessage[getCount() -1];
|
||||||
|
for(int i=0; i< getCount(); i++){
|
||||||
|
if(this.history[i].getStorageId() != newHist[i].getStorageId())
|
||||||
|
newHist[i] = this.history[i];
|
||||||
|
}
|
||||||
|
newHist[getCount()] = message;
|
||||||
|
this.history = newHist;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return history.length;
|
return history.length;
|
||||||
|
@ -394,6 +403,14 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
registerForContextMenu(v);
|
registerForContextMenu(v);
|
||||||
RelativeLayout rlayout = new RelativeLayout(context);
|
RelativeLayout rlayout = new RelativeLayout(context);
|
||||||
|
|
||||||
|
if(isEditMode) {
|
||||||
|
v.findViewById(R.id.delete).setVisibility(View.VISIBLE);
|
||||||
|
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
|
||||||
|
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||||
|
layoutParams.setMargins(0, 10, 30, 10);
|
||||||
|
v.setLayoutParams(layoutParams);
|
||||||
|
rlayout.addView(v);
|
||||||
|
} else {
|
||||||
if(message.isOutgoing()){
|
if(message.isOutgoing()){
|
||||||
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
|
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
|
||||||
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||||
|
@ -406,6 +423,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
v.setLayoutParams(layoutParams);
|
v.setLayoutParams(layoutParams);
|
||||||
}
|
}
|
||||||
rlayout.addView(v);
|
rlayout.addView(v);
|
||||||
|
}
|
||||||
return rlayout;
|
return rlayout;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -416,15 +434,11 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayChatHeader(String displayName, String pictureUri) {
|
private void displayChatHeader(LinphoneAddress address) {
|
||||||
if(contact != null) {
|
if(contact != null) {
|
||||||
contactName.setText(contact.getName());
|
contactName.setText(contact.getName());
|
||||||
} else if (displayName == null && getResources().getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(sipUri)) {
|
} else if(address != null){
|
||||||
contactName.setText(LinphoneUtils.getUsernameFromAddress(sipUri));
|
contactName.setText(LinphoneUtils.getAddressDisplayName(address));
|
||||||
} else if (displayName == null) {
|
|
||||||
contactName.setText(sipUri);
|
|
||||||
} else {
|
|
||||||
contactName.setText(displayName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,12 +465,12 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
message.setText(draft);
|
message.setText(draft);
|
||||||
}
|
}
|
||||||
|
|
||||||
LinphoneAddress lAddress;
|
LinphoneAddress lAddress = null;
|
||||||
try {
|
try {
|
||||||
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
|
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
|
||||||
contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
|
Log.w("error");
|
||||||
}
|
}
|
||||||
|
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
@ -466,7 +480,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
chatRoom.markAsRead();
|
chatRoom.markAsRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
displayChatHeader(displayName, pictureUri);
|
displayChatHeader(lAddress);
|
||||||
dispayMessageList();
|
dispayMessageList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,8 +539,8 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
message.removeTextChangedListener(textWatcher);
|
//message.removeTextChangedListener(textWatcher);
|
||||||
removeVirtualKeyboardVisiblityListener();
|
//removeVirtualKeyboardVisiblityListener();
|
||||||
|
|
||||||
|
|
||||||
LinphoneService.instance().removeMessageNotification();
|
LinphoneService.instance().removeMessageNotification();
|
||||||
|
@ -557,8 +571,8 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
@SuppressLint("UseSparseArrays")
|
@SuppressLint("UseSparseArrays")
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
message.addTextChangedListener(textWatcher);
|
//message.addTextChangedListener(textWatcher);
|
||||||
addVirtualKeyboardVisiblityListener();
|
//addVirtualKeyboardVisiblityListener();
|
||||||
|
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
|
@ -566,10 +580,9 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
if (getResources().getBoolean(R.bool.show_statusbar_only_on_dialer)) {
|
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CHAT);
|
||||||
LinphoneActivity.instance().hideStatusBar();
|
|
||||||
}
|
|
||||||
LinphoneActivity.instance().updateChatFragment(this);
|
LinphoneActivity.instance().updateChatFragment(this);
|
||||||
|
LinphoneActivity.instance().hideTabBar(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
LinphoneAddress lAddress;
|
LinphoneAddress lAddress;
|
||||||
|
@ -622,6 +635,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
isEditMode = false;
|
isEditMode = false;
|
||||||
editList.setVisibility(View.GONE);
|
editList.setVisibility(View.GONE);
|
||||||
topBar.setVisibility(View.VISIBLE);
|
topBar.setVisibility(View.VISIBLE);
|
||||||
|
dispayMessageList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -642,6 +656,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id == R.id.cancel) {
|
if (id == R.id.cancel) {
|
||||||
|
Log.w("Cancel");
|
||||||
quitEditMode();
|
quitEditMode();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -676,6 +691,8 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
} else if (id == R.id.edit) {
|
} else if (id == R.id.edit) {
|
||||||
topBar.setVisibility(View.GONE);
|
topBar.setVisibility(View.GONE);
|
||||||
editList.setVisibility(View.VISIBLE);
|
editList.setVisibility(View.VISIBLE);
|
||||||
|
isEditMode = true;
|
||||||
|
dispayMessageList();
|
||||||
}
|
}
|
||||||
else if (id == R.id.new_discussion) {
|
else if (id == R.id.new_discussion) {
|
||||||
//TODO call sipUri
|
//TODO call sipUri
|
||||||
|
@ -690,45 +707,39 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
message.setText("");
|
message.setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void displayBubbleChat(LinphoneChatMessage message){
|
||||||
|
adapter.addMessage(message);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
private void sendTextMessage(String messageToSend) {
|
private void sendTextMessage(String messageToSend) {
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
boolean isNetworkReachable = lc == null ? false : lc.isNetworkReachable();
|
boolean isNetworkReachable = lc == null ? false : lc.isNetworkReachable();
|
||||||
|
|
||||||
|
//Start new conversation in fast chat
|
||||||
if(newChatConversation){
|
if(newChatConversation){
|
||||||
String address = searchContactField.getText().toString();
|
String address = searchContactField.getText().toString();
|
||||||
if(address != null && !address.equals("")) {
|
if(address != null && !address.equals("")) {
|
||||||
if(!address.startsWith("sip:"))
|
LinphoneAddress lAddress = LinphoneManager.getLc().getDefaultProxyConfig().normalizeSipUri(address);
|
||||||
address = "sip:" + address;
|
if(lAddress != null) {
|
||||||
if (!LinphoneUtils.isSipAddress(address)) {
|
chatRoom = lc.getChatRoom(lAddress);
|
||||||
if (LinphoneManager.getLc().getDefaultProxyConfig() == null) {
|
|
||||||
Log.w("Error");
|
|
||||||
}
|
|
||||||
address = address + "@" + LinphoneManager.getLc().getDefaultProxyConfig().getDomain();
|
|
||||||
}
|
|
||||||
|
|
||||||
LinphoneAddress lAddress;
|
|
||||||
try {
|
|
||||||
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(address);
|
|
||||||
} catch (LinphoneCoreException e) {
|
|
||||||
Log.e("Cannot display chat",e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
chatRoom = lc.getOrCreateChatRoom(lAddress.toString());
|
|
||||||
|
|
||||||
if (chatRoom != null && messageToSend != null && messageToSend.length() > 0 && isNetworkReachable) {
|
if (chatRoom != null && messageToSend != null && messageToSend.length() > 0 && isNetworkReachable) {
|
||||||
LinphoneChatMessage message = chatRoom.createLinphoneChatMessage(messageToSend);
|
LinphoneChatMessage message = chatRoom.createLinphoneChatMessage(messageToSend);
|
||||||
chatRoom.sendChatMessage(message);
|
chatRoom.sendChatMessage(message);
|
||||||
message.setListener(LinphoneManager.getInstance());
|
message.setListener(LinphoneManager.getInstance());
|
||||||
Contact lContact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
Contact lContact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
||||||
if(lContact != null)
|
if (lContact != null)
|
||||||
exitNewConversationMode(lContact,lAddress.asStringUriOnly(),null);
|
exitNewConversationMode(lContact, lAddress.asStringUriOnly(), null);
|
||||||
else
|
else
|
||||||
exitNewConversationMode(null,lAddress.asStringUriOnly(),lAddress.getUserName());
|
exitNewConversationMode(null, lAddress.asStringUriOnly(), lAddress.getUserName());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//TODO ERROR MESSAGE
|
||||||
|
LinphoneActivity.instance().displayCustomToast(getString(R.string.error_user_not_found), Toast.LENGTH_LONG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (chatRoom != null && messageToSend != null && messageToSend.length() > 0 && isNetworkReachable) {
|
if (chatRoom != null && messageToSend != null && messageToSend.length() > 0 && isNetworkReachable) {
|
||||||
LinphoneChatMessage message = chatRoom.createLinphoneChatMessage(messageToSend);
|
LinphoneChatMessage message = chatRoom.createLinphoneChatMessage(messageToSend);
|
||||||
chatRoom.sendChatMessage(message);
|
chatRoom.sendChatMessage(message);
|
||||||
|
@ -826,6 +837,8 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
progressDialog.dismiss();
|
progressDialog.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.w("Post execute");
|
||||||
|
|
||||||
mUploadingImageStream = new ByteArrayInputStream(result);
|
mUploadingImageStream = new ByteArrayInputStream(result);
|
||||||
|
|
||||||
LinphoneContent content = LinphoneCoreFactory.instance().createLinphoneContent("image", "jpeg", result, null);
|
LinphoneContent content = LinphoneCoreFactory.instance().createLinphoneContent("image", "jpeg", result, null);
|
||||||
|
@ -841,6 +854,8 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
|
|
||||||
chatRoom.sendChatMessage(message);
|
chatRoom.sendChatMessage(message);
|
||||||
currentMessageInFileTransferUploadState = message;
|
currentMessageInFileTransferUploadState = message;
|
||||||
|
|
||||||
|
displayBubbleChat(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -967,12 +982,10 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLinphoneChatMessageStateChanged(LinphoneChatMessage msg, State state) {
|
public void onLinphoneChatMessageStateChanged(LinphoneChatMessage msg, State state) {
|
||||||
//if (state == State.FileTransferDone || state == State.FileTransferError) {
|
Log.w("ICI");
|
||||||
// uploadLayout.setVisibility(View.GONE);
|
if (state == State.FileTransferDone || state == State.FileTransferError) {
|
||||||
// textLayout.setVisibility(View.VISIBLE);
|
currentMessageInFileTransferUploadState = null;
|
||||||
// progressBar.setProgress(0);
|
}
|
||||||
// currentMessageInFileTransferUploadState = null;
|
|
||||||
//}
|
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -986,21 +999,24 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLinphoneChatMessageFileTransferProgressChanged(LinphoneChatMessage msg, LinphoneContent content, int offset, int total) {
|
public void onLinphoneChatMessageFileTransferProgressChanged(LinphoneChatMessage msg, LinphoneContent content, int offset, int total) {
|
||||||
progressBar.setProgress(offset * 100 / total);
|
//progressBar.setProgress(offset * 100 / total);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SearchContactsListAdapter extends BaseAdapter implements Filterable {
|
class SearchContactsListAdapter extends BaseAdapter implements Filterable {
|
||||||
private List<ContactAddress> contacts;
|
//private List<ContactAddress> contacts;
|
||||||
|
private HashMap<Contact, String> contactsList2;
|
||||||
private Cursor cursor;
|
private Cursor cursor;
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
|
|
||||||
SearchContactsListAdapter(List<Contact> contactsList, Cursor c, LayoutInflater inflater) {
|
SearchContactsListAdapter(List<Contact> contactsList, Cursor c, LayoutInflater inflater) {
|
||||||
cursor = c;
|
cursor = c;
|
||||||
mInflater = inflater;
|
mInflater = inflater;
|
||||||
contacts = new ArrayList<ContactAddress>();
|
contactsList2 = new HashMap<Contact, String>();
|
||||||
|
//contacts = new ArrayList<ContactAddress>();
|
||||||
for(Contact con: ContactsManager.getInstance().getAllContacts()){
|
for(Contact con: ContactsManager.getInstance().getAllContacts()){
|
||||||
for(String numberOrAddress : con.getNumbersOrAddresses()){
|
for(String numberOrAddress : con.getNumbersOrAddresses()){
|
||||||
contacts.add(new ContactAddress(con,numberOrAddress));
|
contactsList2.put(con,numberOrAddress);
|
||||||
|
//contacts.add(new ContactAddress(con,numberOrAddress));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1013,23 +1029,27 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
FilterResults results) {
|
FilterResults results) {
|
||||||
|
|
||||||
if (results.count > 0) {
|
if (results.count > 0) {
|
||||||
contacts.clear();
|
//contacts.clear();
|
||||||
contacts = (List<ContactAddress>) results.values;
|
contactsList2.clear();
|
||||||
|
contactsList2 = ( HashMap<Contact, String>) results.values;
|
||||||
|
//contacts = (List<ContactAddress>) results.values;
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
} else {;
|
} else {;
|
||||||
contacts.clear();
|
//contacts.clear();
|
||||||
contacts = getContactsList();
|
contactsList2.clear();
|
||||||
|
contactsList2 = getContactsList();
|
||||||
notifyDataSetInvalidated();
|
notifyDataSetInvalidated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FilterResults performFiltering(CharSequence constraint) {
|
protected FilterResults performFiltering(CharSequence constraint) {
|
||||||
List<ContactAddress> result = new ArrayList<ContactAddress>();
|
//List<ContactAddress> result = new ArrayList<ContactAddress>();
|
||||||
|
HashMap<Contact, String> result = new HashMap<Contact, String>();
|
||||||
if(constraint != null) {
|
if(constraint != null) {
|
||||||
for (ContactAddress c : contacts) {
|
for (HashMap.Entry<Contact, String> entry : contactsList2.entrySet()) {
|
||||||
if (c.mContact.getName().toLowerCase().startsWith(constraint.toString()) || c.mAddress.startsWith(constraint.toString())) {
|
if (entry.getKey().getName().toLowerCase().startsWith(constraint.toString()) || entry.getValue().startsWith(constraint.toString())) {
|
||||||
result.add(c);
|
result.put(entry.getKey(),entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1041,36 +1061,29 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ContactAddress> getContactsList(){
|
public HashMap<Contact, String> getContactsList(){
|
||||||
List<ContactAddress> contacts = new ArrayList<ContactAddress>();
|
HashMap<Contact, String> contacts = new HashMap<Contact, String>();
|
||||||
contacts = new ArrayList<ContactAddress>();
|
|
||||||
for(Contact con: ContactsManager.getInstance().getAllContacts()){
|
for(Contact con: ContactsManager.getInstance().getAllContacts()){
|
||||||
for(String numberOrAddress : con.getNumbersOrAddresses()){
|
for(String numberOrAddress : con.getNumbersOrAddresses()){
|
||||||
contacts.add(new ContactAddress(con,numberOrAddress));
|
contacts.put(con, numberOrAddress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return contacts;
|
return contacts;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ContactAddress {
|
|
||||||
public Contact mContact;
|
|
||||||
public String mAddress;
|
|
||||||
|
|
||||||
ContactAddress(Contact contact, String address){
|
|
||||||
mContact = contact;
|
|
||||||
mAddress = address;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return contacts.size();
|
return contactsList2.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getItem(int position) {
|
public Contact getItem(int position) {
|
||||||
if (contacts == null || position >= contacts.size()) {
|
if (contactsList2 == null || position >= contactsList2.size()) {
|
||||||
return getContactsList().get(position);
|
contactsList2 = getContactsList();
|
||||||
|
Contact[] s = (Contact[]) contactsList2.keySet().toArray();
|
||||||
|
return s[position];
|
||||||
} else {
|
} else {
|
||||||
return contacts.get(position);
|
Object[] s = (Object[]) contactsList2.keySet().toArray();
|
||||||
|
return (Contact) s[position];
|
||||||
|
//return contactsList2.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1080,9 +1093,9 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
|
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
View view = null;
|
View view = null;
|
||||||
ContactAddress contact;
|
Contact contact;
|
||||||
do {
|
do {
|
||||||
contact = (ContactAddress) getItem(position);
|
contact = getItem(position);
|
||||||
} while (contact == null);
|
} while (contact == null);
|
||||||
|
|
||||||
if (convertView != null) {
|
if (convertView != null) {
|
||||||
|
@ -1092,13 +1105,13 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
|
|
||||||
TextView name = (TextView) view.findViewById(R.id.Contact_name);
|
TextView name = (TextView) view.findViewById(R.id.Contact_name);
|
||||||
name.setText(contact.mContact.getName());
|
name.setText(contact.getName());
|
||||||
|
|
||||||
final TextView address = (TextView) view.findViewById(R.id.contact_address);
|
final TextView address = (TextView) view.findViewById(R.id.contact_address);
|
||||||
address.setText(contact.mAddress);
|
address.setText(contactsList2.get(contact));
|
||||||
|
|
||||||
final String a = contact.mAddress;
|
final String a = contactsList2.get(contact);
|
||||||
final Contact c = contact.mContact;
|
final Contact c = contact;
|
||||||
|
|
||||||
view.setOnClickListener(new OnClickListener() {
|
view.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,8 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
|
@ -37,6 +35,7 @@ import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.Typeface;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
@ -73,7 +72,6 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
private ImageView edit, selectAll, deselectAll, delete, newDiscussion, contactPicture, cancel;
|
private ImageView edit, selectAll, deselectAll, delete, newDiscussion, contactPicture, cancel;
|
||||||
private RelativeLayout editList, topbar;
|
private RelativeLayout editList, topbar;
|
||||||
private boolean isEditMode = false;
|
private boolean isEditMode = false;
|
||||||
private boolean useLinphoneStorage;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
@ -119,7 +117,6 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
|
|
||||||
private void removeChatsConversation(){
|
private void removeChatsConversation(){
|
||||||
int size = chatList.getAdapter().getCount();
|
int size = chatList.getAdapter().getCount();
|
||||||
|
|
||||||
for(int i=0; i<size; i++) {
|
for(int i=0; i<size; i++) {
|
||||||
if(chatList.isItemChecked(i)){
|
if(chatList.isItemChecked(i)){
|
||||||
View item = chatList.getAdapter().getView(i, null, null);
|
View item = chatList.getAdapter().getView(i, null, null);
|
||||||
|
@ -130,6 +127,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LinphoneActivity.instance().updateMissedChatCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void quitEditMode(){
|
public void quitEditMode(){
|
||||||
|
@ -139,6 +137,29 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getNbItemsChecked(){
|
||||||
|
int size = chatList.getAdapter().getCount();
|
||||||
|
int nb = 0;
|
||||||
|
for(int i=0; i<size; i++) {
|
||||||
|
if(chatList.isItemChecked(i)) {
|
||||||
|
nb ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enabledDeleteButton(Boolean enabled){
|
||||||
|
if(enabled){
|
||||||
|
delete.setEnabled(true);
|
||||||
|
delete.setAlpha(1f);
|
||||||
|
} else {
|
||||||
|
if (getNbItemsChecked() == 0){
|
||||||
|
delete.setEnabled(false);
|
||||||
|
delete.setAlpha(0.2f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void hideAndDisplayMessageIfNoChat() {
|
private void hideAndDisplayMessageIfNoChat() {
|
||||||
if (mConversations.size() == 0 && mDrafts.size() == 0) {
|
if (mConversations.size() == 0 && mDrafts.size() == 0) {
|
||||||
noChatHistory.setVisibility(View.VISIBLE);
|
noChatHistory.setVisibility(View.VISIBLE);
|
||||||
|
@ -148,7 +169,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
noChatHistory.setVisibility(View.GONE);
|
noChatHistory.setVisibility(View.GONE);
|
||||||
chatList.setVisibility(View.VISIBLE);
|
chatList.setVisibility(View.VISIBLE);
|
||||||
chatList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
|
chatList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
|
||||||
chatList.setAdapter(new ChatListAdapter(useLinphoneStorage));
|
chatList.setAdapter(new ChatListAdapter());
|
||||||
edit.setEnabled(true);
|
edit.setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,12 +195,10 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
//Check if the is the first time we show the chat view since we use liblinphone chat storage
|
|
||||||
useLinphoneStorage = getResources().getBoolean(R.bool.use_linphone_chat_storage);
|
|
||||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(LinphoneActivity.instance());
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(LinphoneActivity.instance());
|
||||||
boolean updateNeeded = prefs.getBoolean(getString(R.string.pref_first_time_linphone_chat_storage), true);
|
boolean updateNeeded = prefs.getBoolean(getString(R.string.pref_first_time_linphone_chat_storage), true);
|
||||||
updateNeeded = updateNeeded && !isVersionUsingNewChatStorage();
|
updateNeeded = updateNeeded && !isVersionUsingNewChatStorage();
|
||||||
if (useLinphoneStorage && updateNeeded) {
|
if (updateNeeded) {
|
||||||
AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
|
AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
|
||||||
private ProgressDialog pd;
|
private ProgressDialog pd;
|
||||||
@Override
|
@Override
|
||||||
|
@ -214,10 +233,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CHATLIST);
|
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CHATLIST);
|
||||||
LinphoneActivity.instance().updateChatListFragment(this);
|
LinphoneActivity.instance().updateChatListFragment(this);
|
||||||
|
LinphoneActivity.instance().hideTabBar(false);
|
||||||
if (getResources().getBoolean(R.bool.show_statusbar_only_on_dialer)) {
|
|
||||||
LinphoneActivity.instance().hideStatusBar();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
|
@ -252,12 +268,14 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
if (id == R.id.select_all) {
|
if (id == R.id.select_all) {
|
||||||
deselectAll.setVisibility(View.VISIBLE);
|
deselectAll.setVisibility(View.VISIBLE);
|
||||||
selectAll.setVisibility(View.GONE);
|
selectAll.setVisibility(View.GONE);
|
||||||
|
enabledDeleteButton(true);
|
||||||
selectAllList(true);
|
selectAllList(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (id == R.id.deselect_all) {
|
if (id == R.id.deselect_all) {
|
||||||
deselectAll.setVisibility(View.GONE);
|
deselectAll.setVisibility(View.GONE);
|
||||||
selectAll.setVisibility(View.VISIBLE);
|
selectAll.setVisibility(View.VISIBLE);
|
||||||
|
enabledDeleteButton(false);
|
||||||
selectAllList(false);
|
selectAllList(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -296,6 +314,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
editList.setVisibility(View.VISIBLE);
|
editList.setVisibility(View.VISIBLE);
|
||||||
isEditMode = true;
|
isEditMode = true;
|
||||||
hideAndDisplayMessageIfNoChat();
|
hideAndDisplayMessageIfNoChat();
|
||||||
|
enabledDeleteButton(false);
|
||||||
}
|
}
|
||||||
else if (id == R.id.new_discussion) {
|
else if (id == R.id.new_discussion) {
|
||||||
LinphoneActivity.instance().displayChat(null);
|
LinphoneActivity.instance().displayChat(null);
|
||||||
|
@ -323,16 +342,6 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
|
|
||||||
if (LinphoneActivity.isInstanciated() && !isEditMode) {
|
if (LinphoneActivity.isInstanciated() && !isEditMode) {
|
||||||
LinphoneActivity.instance().displayChat(sipUri);
|
LinphoneActivity.instance().displayChat(sipUri);
|
||||||
} else if (LinphoneActivity.isInstanciated()) {
|
|
||||||
LinphoneActivity.instance().removeFromChatList(sipUri);
|
|
||||||
LinphoneActivity.instance().removeFromDrafts(sipUri);
|
|
||||||
|
|
||||||
mConversations = LinphoneActivity.instance().getChatList();
|
|
||||||
mDrafts = LinphoneActivity.instance().getDraftChatList();
|
|
||||||
mConversations.removeAll(mDrafts);
|
|
||||||
hideAndDisplayMessageIfNoChat();
|
|
||||||
|
|
||||||
LinphoneActivity.instance().updateMissedChatCount();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,47 +398,12 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String timestampToHumanDate(long timestamp) {
|
|
||||||
try {
|
|
||||||
Calendar cal = Calendar.getInstance();
|
|
||||||
cal.setTimeInMillis(timestamp);
|
|
||||||
|
|
||||||
SimpleDateFormat dateFormat;
|
|
||||||
if (isToday(cal)) {
|
|
||||||
dateFormat = new SimpleDateFormat(getResources().getString(R.string.today_date_format));
|
|
||||||
} else {
|
|
||||||
dateFormat = new SimpleDateFormat(getResources().getString(R.string.messages_list_date_format));
|
|
||||||
}
|
|
||||||
|
|
||||||
return dateFormat.format(cal.getTime());
|
|
||||||
} catch (NumberFormatException nfe) {
|
|
||||||
return String.valueOf(timestamp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isToday(Calendar cal) {
|
|
||||||
return isSameDay(cal, Calendar.getInstance());
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isSameDay(Calendar cal1, Calendar cal2) {
|
|
||||||
if (cal1 == null || cal2 == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA) &&
|
|
||||||
cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
|
|
||||||
cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR));
|
|
||||||
}
|
|
||||||
|
|
||||||
class ChatListAdapter extends BaseAdapter {
|
class ChatListAdapter extends BaseAdapter {
|
||||||
private boolean useNativeAPI;
|
|
||||||
|
|
||||||
ChatListAdapter(boolean useNativeAPI) {
|
ChatListAdapter() {}
|
||||||
this.useNativeAPI = useNativeAPI;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return mConversations.size() + mDrafts.size();
|
return mConversations.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getItem(int position) {
|
public Object getItem(int position) {
|
||||||
|
@ -447,62 +421,68 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
view = convertView;
|
view = convertView;
|
||||||
} else {
|
} else {
|
||||||
view = mInflater.inflate(R.layout.chatlist_cell, parent, false);
|
view = mInflater.inflate(R.layout.chatlist_cell, parent, false);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
String sipUri = mConversations.get(position);
|
||||||
String contact;
|
view.setTag(sipUri);
|
||||||
boolean isDraft = false;
|
|
||||||
if (position >= mDrafts.size()) {
|
|
||||||
contact = mConversations.get(position - mDrafts.size());
|
|
||||||
} else {
|
|
||||||
contact = mDrafts.get(position);
|
|
||||||
isDraft = true;
|
|
||||||
}
|
|
||||||
view.setTag(contact);
|
|
||||||
int unreadMessagesCount = LinphoneActivity.instance().getChatStorage().getUnreadMessageCount(contact);
|
|
||||||
|
|
||||||
LinphoneAddress address;
|
LinphoneAddress address;
|
||||||
try {
|
try {
|
||||||
address = LinphoneCoreFactory.instance().createLinphoneAddress(contact);
|
address = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
|
||||||
} catch (LinphoneCoreException e) {
|
} catch (LinphoneCoreException e) {
|
||||||
Log.e("Chat view cannot parse address",e);
|
Log.e("Chat view cannot parse address",e);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
Contact lContact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), address);
|
|
||||||
|
|
||||||
|
Contact contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), address);
|
||||||
String message = "";
|
String message = "";
|
||||||
Long time;
|
Long time;
|
||||||
|
|
||||||
TextView lastMessageView = (TextView) view.findViewById(R.id.lastMessage);
|
TextView lastMessageView = (TextView) view.findViewById(R.id.lastMessage);
|
||||||
LinphoneChatRoom chatRoom = LinphoneManager.getLc().getOrCreateChatRoom(contact);
|
TextView date = (TextView) view.findViewById(R.id.date);
|
||||||
|
TextView displayName = (TextView) view.findViewById(R.id.sipUri);
|
||||||
|
TextView unreadMessages = (TextView) view.findViewById(R.id.unreadMessages);
|
||||||
|
CheckBox select = (CheckBox) view.findViewById(R.id.delete);
|
||||||
|
ImageView contactPicture = (ImageView) view.findViewById(R.id.contact_picture);
|
||||||
|
|
||||||
|
LinphoneChatRoom chatRoom = LinphoneManager.getLc().getChatRoom(address);
|
||||||
|
int unreadMessagesCount = chatRoom.getUnreadMessagesCount();
|
||||||
LinphoneChatMessage[] history = chatRoom.getHistory(1);
|
LinphoneChatMessage[] history = chatRoom.getHistory(1);
|
||||||
LinphoneChatMessage msg = history[0];
|
LinphoneChatMessage msg = history[0];
|
||||||
TextView date = (TextView) view.findViewById(R.id.date);
|
|
||||||
if(msg.getFileTransferInformation() != null || msg.getExternalBodyUrl() != null || msg.getAppData() != null ){
|
if(msg.getFileTransferInformation() != null || msg.getExternalBodyUrl() != null || msg.getAppData() != null ){
|
||||||
lastMessageView.setBackgroundResource(R.drawable.chat_file_message);
|
lastMessageView.setBackgroundResource(R.drawable.chat_file_message);
|
||||||
time = msg.getTime();
|
time = msg.getTime();
|
||||||
date.setText(timestampToHumanDate(time));
|
date.setText(LinphoneUtils.timestampToHumanDate(getActivity(),time,getString(R.string.messages_list_date_format)));
|
||||||
|
lastMessageView.setText("");
|
||||||
} else if (msg.getText() != null && msg.getText().length() > 0 ){
|
} else if (msg.getText() != null && msg.getText().length() > 0 ){
|
||||||
message = msg.getText();
|
message = msg.getText();
|
||||||
|
lastMessageView.setBackgroundResource(0);
|
||||||
time = msg.getTime();
|
time = msg.getTime();
|
||||||
date.setText(timestampToHumanDate(time));
|
date.setText(LinphoneUtils.timestampToHumanDate(getActivity(),time,getString(R.string.messages_list_date_format)));
|
||||||
lastMessageView.setText(message);
|
lastMessageView.setText(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextView sipUri = (TextView) view.findViewById(R.id.sipUri);
|
displayName.setSelected(true); // For animation
|
||||||
sipUri.setSelected(true); // For animation
|
displayName.setText(contact == null ? LinphoneUtils.getAddressDisplayName(address) : contact.getName());
|
||||||
|
|
||||||
if (getResources().getBoolean(R.bool.only_display_username_if_unknown)) {
|
|
||||||
sipUri.setText(lContact == null ? address.getUserName() : lContact.getName());
|
if(contact != null){
|
||||||
|
LinphoneUtils.setImagePictureFromUri(view.getContext(), contactPicture, contact.getPhotoUri(), contact.getThumbnailUri());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unreadMessagesCount > 0) {
|
||||||
|
unreadMessages.setVisibility(View.VISIBLE);
|
||||||
|
unreadMessages.setText(String.valueOf(unreadMessagesCount));
|
||||||
|
if(unreadMessagesCount > 99){
|
||||||
|
unreadMessages.setTextSize(12);
|
||||||
|
}
|
||||||
|
displayName.setTypeface(null, Typeface.BOLD);
|
||||||
} else {
|
} else {
|
||||||
sipUri.setText(lContact == null ? address.asStringUriOnly() : lContact.getName());
|
unreadMessages.setVisibility(View.GONE);
|
||||||
|
displayName.setTypeface(null, Typeface.NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDraft) {
|
|
||||||
view.findViewById(R.id.draft).setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
TextView unreadMessages = (TextView) view.findViewById(R.id.unreadMessages);
|
|
||||||
|
|
||||||
CheckBox select = (CheckBox) view.findViewById(R.id.delete);
|
|
||||||
if (isEditMode) {
|
if (isEditMode) {
|
||||||
unreadMessages.setVisibility(View.GONE);
|
unreadMessages.setVisibility(View.GONE);
|
||||||
select.setVisibility(View.VISIBLE);
|
select.setVisibility(View.VISIBLE);
|
||||||
|
@ -510,23 +490,32 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||||
chatList.setItemChecked(position, b);
|
chatList.setItemChecked(position, b);
|
||||||
|
if(getNbItemsChecked() == getCount()){
|
||||||
|
deselectAll.setVisibility(View.VISIBLE);
|
||||||
|
selectAll.setVisibility(View.GONE);
|
||||||
|
enabledDeleteButton(true);
|
||||||
|
} else {
|
||||||
|
if(getNbItemsChecked() == 0){
|
||||||
|
deselectAll.setVisibility(View.GONE);
|
||||||
|
selectAll.setVisibility(View.VISIBLE);
|
||||||
|
enabledDeleteButton(false);
|
||||||
|
} else {
|
||||||
|
deselectAll.setVisibility(View.GONE);
|
||||||
|
selectAll.setVisibility(View.VISIBLE);
|
||||||
|
enabledDeleteButton(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(chatList.isItemChecked(position)) {
|
if(chatList.isItemChecked(position)) {
|
||||||
select.setChecked(true);
|
enabledDeleteButton(true);
|
||||||
} else {
|
} else {
|
||||||
select.setChecked(false);
|
select.setChecked(false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unreadMessages.setVisibility(View.GONE);
|
|
||||||
//delete.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unreadMessagesCount > 0) {
|
if (unreadMessagesCount > 0) {
|
||||||
unreadMessages.setVisibility(View.VISIBLE);
|
unreadMessages.setVisibility(View.VISIBLE);
|
||||||
unreadMessages.setText(String.valueOf(unreadMessagesCount));
|
}
|
||||||
} else {
|
|
||||||
unreadMessages.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class ChatStorage {
|
||||||
|
|
||||||
private ChatStorage(Context c) {
|
private ChatStorage(Context c) {
|
||||||
context = c;
|
context = c;
|
||||||
boolean useLinphoneStorage = c.getResources().getBoolean(R.bool.use_linphone_chat_storage);
|
boolean useLinphoneStorage = false;
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(LinphoneService.instance());
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(LinphoneService.instance());
|
||||||
boolean updateNeeded = prefs.getBoolean(c.getString(R.string.pref_first_time_linphone_chat_storage), !LinphonePreferences.instance().isFirstLaunch());
|
boolean updateNeeded = prefs.getBoolean(c.getString(R.string.pref_first_time_linphone_chat_storage), !LinphonePreferences.instance().isFirstLaunch());
|
||||||
updateNeeded = updateNeeded && !isVersionUsingNewChatStorage();
|
updateNeeded = updateNeeded && !isVersionUsingNewChatStorage();
|
||||||
|
@ -356,35 +356,29 @@ public class ChatStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinphoneChatMessage getMessage(LinphoneChatRoom chatroom, int id) {
|
public LinphoneChatMessage getMessage(LinphoneChatRoom chatroom, int id) {
|
||||||
if (useNativeAPI) {
|
|
||||||
LinphoneChatMessage[] history = chatroom.getHistory();
|
LinphoneChatMessage[] history = chatroom.getHistory();
|
||||||
for (LinphoneChatMessage msg : history) {
|
for (LinphoneChatMessage msg : history) {
|
||||||
if (msg.getStorageId() == id) {
|
if (msg.getStorageId() == id) {
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeDiscussion(String correspondent) {
|
public void removeDiscussion(String correspondent) {
|
||||||
if (useNativeAPI) {
|
|
||||||
LinphoneChatRoom chatroom = LinphoneManager.getLc().getOrCreateChatRoom(correspondent);
|
LinphoneChatRoom chatroom = LinphoneManager.getLc().getOrCreateChatRoom(correspondent);
|
||||||
chatroom.deleteHistory();
|
chatroom.deleteHistory();
|
||||||
} else {
|
|
||||||
db.delete(TABLE_NAME, "remoteContact LIKE \"" + correspondent + "\"", null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> getChatList() {
|
public ArrayList<String> getChatList() {
|
||||||
ArrayList<String> chatList = new ArrayList<String>();
|
ArrayList<String> chatList = new ArrayList<String>();
|
||||||
|
|
||||||
if (useNativeAPI) {
|
|
||||||
LinphoneChatRoom[] chats = LinphoneManager.getLc().getChatRooms();
|
LinphoneChatRoom[] chats = LinphoneManager.getLc().getChatRooms();
|
||||||
List<LinphoneChatRoom> rooms = new ArrayList<LinphoneChatRoom>();
|
List<LinphoneChatRoom> rooms = new ArrayList<LinphoneChatRoom>();
|
||||||
|
|
||||||
for (LinphoneChatRoom chatroom : chats) {
|
for (LinphoneChatRoom chatroom : chats) {
|
||||||
if (chatroom.getHistory(1).length > 0) {
|
if (chatroom.getHistory(1).length > 0) {
|
||||||
|
Log.w("History non nul " + chatroom.getPeerAddress().asString());
|
||||||
rooms.add(chatroom);
|
rooms.add(chatroom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -411,17 +405,6 @@ public class ChatStorage {
|
||||||
for (LinphoneChatRoom chatroom : rooms) {
|
for (LinphoneChatRoom chatroom : rooms) {
|
||||||
chatList.add(chatroom.getPeerAddress().asStringUriOnly());
|
chatList.add(chatroom.getPeerAddress().asStringUriOnly());
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Cursor c = db.query(TABLE_NAME, null, null, null, "remoteContact", null, "id DESC");
|
|
||||||
while (c != null && c.moveToNext()) {
|
|
||||||
try {
|
|
||||||
String remoteContact = c.getString(c.getColumnIndex("remoteContact"));
|
|
||||||
chatList.add(remoteContact);
|
|
||||||
} catch (IllegalStateException ise) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
return chatList;
|
return chatList;
|
||||||
}
|
}
|
||||||
|
@ -454,53 +437,6 @@ public class ChatStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getUnreadMessageCount() {
|
|
||||||
int count;
|
|
||||||
if (!useNativeAPI) {
|
|
||||||
Cursor c = db.query(TABLE_NAME, null, "read LIKE " + NOT_READ, null, null, null, null);
|
|
||||||
count = c.getCount();
|
|
||||||
c.close();
|
|
||||||
} else {
|
|
||||||
count = 0;
|
|
||||||
LinphoneChatRoom[] chats = LinphoneManager.getLc().getChatRooms();
|
|
||||||
for (LinphoneChatRoom chatroom : chats) {
|
|
||||||
count += chatroom.getUnreadMessagesCount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getUnreadMessageCount(String contact) {
|
|
||||||
int count;
|
|
||||||
if (!useNativeAPI) {
|
|
||||||
Cursor c = db.query(TABLE_NAME, null, "remoteContact LIKE \"" + contact + "\" AND read LIKE " + NOT_READ, null, null, null, null);
|
|
||||||
count = c.getCount();
|
|
||||||
c.close();
|
|
||||||
} else {
|
|
||||||
LinphoneChatRoom chatroom = LinphoneManager.getLc().getOrCreateChatRoom(contact);
|
|
||||||
count = chatroom.getUnreadMessagesCount();
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getRawImageFromMessage(int id) {
|
|
||||||
if (useNativeAPI) {
|
|
||||||
//Handled before this point
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] columns = { "image" };
|
|
||||||
Cursor c = db.query(TABLE_NAME, columns, "id LIKE " + id + "", null, null, null, null);
|
|
||||||
|
|
||||||
if (c.moveToFirst()) {
|
|
||||||
byte[] rawImage = c.getBlob(c.getColumnIndex("image"));
|
|
||||||
c.close();
|
|
||||||
return (rawImage == null || rawImage.length == 0) ? null : rawImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
c.close();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
class ChatHelper extends SQLiteOpenHelper {
|
class ChatHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.Spinner;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,7 +79,7 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
|
||||||
private LinphoneChatMessage nativeMessage;
|
private LinphoneChatMessage nativeMessage;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private static final int SIZE_MAX = 512;
|
private static final int SIZE_MAX = 512;
|
||||||
private ProgressBar spinner, inprogress;
|
private ProgressBar progressBar, inprogress;
|
||||||
private Bitmap defaultBitmap;
|
private Bitmap defaultBitmap;
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
|
@ -97,38 +97,66 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.chat_picture_over);
|
defaultBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.chat_picture_over);
|
||||||
|
inprogress = (ProgressBar) view.findViewById(R.id.inprogress);
|
||||||
|
|
||||||
view.setId(message.getStorageId());
|
view.setId(message.getStorageId());
|
||||||
|
|
||||||
spinner = (ProgressBar) view.findViewById(R.id.spinner);
|
progressBar = (ProgressBar) view.findViewById(R.id.progress_bar);
|
||||||
|
|
||||||
|
LinphoneChatMessage.State status = message.getStatus();
|
||||||
|
statusView = (ImageView) view.findViewById(R.id.status);
|
||||||
|
|
||||||
|
if (statusView != null) {
|
||||||
|
if (status == LinphoneChatMessage.State.Delivered) {
|
||||||
|
statusView.setVisibility(View.INVISIBLE);
|
||||||
|
inprogress.setVisibility(View.GONE);
|
||||||
|
} else if (status == LinphoneChatMessage.State.NotDelivered) {
|
||||||
|
statusView.setVisibility(View.VISIBLE);
|
||||||
|
statusView.setImageResource(R.drawable.chat_message_not_delivered);
|
||||||
|
} else {
|
||||||
|
statusView.setVisibility(View.GONE);
|
||||||
|
inprogress.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String externalBodyUrl = message.getExternalBodyUrl();
|
String externalBodyUrl = message.getExternalBodyUrl();
|
||||||
LinphoneContent fileTransferContent = message.getFileTransferInformation();
|
LinphoneContent fileTransferContent = message.getFileTransferInformation();
|
||||||
|
|
||||||
if(LinphoneManager.getInstance().getMessageUploadPending() != null){
|
if(LinphoneManager.getInstance().getMessageUploadPending() != null){
|
||||||
spinner.setVisibility(View.VISIBLE);
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
nativeMessage.setListener(LinphoneManager.getInstance());
|
nativeMessage.setListener(LinphoneManager.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (externalBodyUrl != null || fileTransferContent != null) {
|
if (externalBodyUrl != null || fileTransferContent != null ) {
|
||||||
Button download = (Button) view.findViewById(R.id.download);
|
String appData = message.getAppData();
|
||||||
ImageView imageView = (ImageView) view.findViewById(R.id.image);
|
ImageView imageView = (ImageView) view.findViewById(R.id.image);
|
||||||
|
|
||||||
String appData = message.getAppData();
|
if(nativeMessage.isOutgoing() && appData != null){
|
||||||
if(appData != null && !LinphoneManager.getInstance().isMessagePending(nativeMessage) &&
|
imageView.setVisibility(View.VISIBLE);
|
||||||
!nativeMessage.isOutgoing() && appData.contains(context.getString(R.string.temp_photo_name_with_date).split("%s")[0])){
|
loadBitmap(appData, imageView);
|
||||||
|
|
||||||
|
RelativeLayout imageLayout = (RelativeLayout) view.findViewById(R.id.imageLayout);
|
||||||
|
if(LinphoneManager.getInstance().getMessageUploadPending() != null && LinphoneManager.getInstance().getMessageUploadPending().getStorageId() == nativeMessage.getStorageId()){
|
||||||
|
inprogress.setVisibility(View.INVISIBLE);
|
||||||
|
imageLayout.setVisibility(View.VISIBLE);
|
||||||
|
nativeMessage.setListener(LinphoneManager.getInstance());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (appData != null && !LinphoneManager.getInstance().isMessagePending(nativeMessage) &&
|
||||||
|
appData.contains(context.getString(R.string.temp_photo_name_with_date).split("%s")[0])) {
|
||||||
appData = null;
|
appData = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appData == null ){
|
RelativeLayout imageLayout = (RelativeLayout) view.findViewById(R.id.imageLayout);
|
||||||
|
Button acceptDownload = (Button) view.findViewById(R.id.accept_download);
|
||||||
|
|
||||||
|
if (appData == null) {
|
||||||
LinphoneManager.addListener(this);
|
LinphoneManager.addListener(this);
|
||||||
download.setVisibility(View.VISIBLE);
|
imageLayout.setVisibility(View.VISIBLE);
|
||||||
download.setOnClickListener(new OnClickListener() {
|
acceptDownload.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
v.setEnabled(false);
|
v.setEnabled(false);
|
||||||
v.setVisibility(View.GONE);
|
|
||||||
spinner.setVisibility(View.VISIBLE);
|
|
||||||
String filename = context.getString(R.string.temp_photo_name_with_date).replace("%s", String.valueOf(System.currentTimeMillis()));
|
String filename = context.getString(R.string.temp_photo_name_with_date).replace("%s", String.valueOf(System.currentTimeMillis()));
|
||||||
File file = new File(Environment.getExternalStorageDirectory(), filename);
|
File file = new File(Environment.getExternalStorageDirectory(), filename);
|
||||||
nativeMessage.setAppData(filename);
|
nativeMessage.setAppData(filename);
|
||||||
|
@ -141,28 +169,23 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
|
||||||
} else {
|
} else {
|
||||||
if (LinphoneManager.getInstance().isMessagePending(nativeMessage)) {
|
if (LinphoneManager.getInstance().isMessagePending(nativeMessage)) {
|
||||||
LinphoneManager.addListener(this);
|
LinphoneManager.addListener(this);
|
||||||
download.setEnabled(false);
|
acceptDownload.setEnabled(false);
|
||||||
ProgressBar spinner = (ProgressBar) view.findViewById(R.id.spinner);
|
imageLayout.setVisibility(View.VISIBLE);
|
||||||
spinner.setVisibility(View.VISIBLE);
|
|
||||||
download.setVisibility(View.GONE);
|
|
||||||
} else {
|
} else {
|
||||||
LinphoneManager.removeListener(this);
|
LinphoneManager.removeListener(this);
|
||||||
|
imageLayout.setVisibility(View.GONE);
|
||||||
imageView.setVisibility(View.VISIBLE);
|
imageView.setVisibility(View.VISIBLE);
|
||||||
download.setVisibility(View.GONE);
|
|
||||||
loadBitmap(appData, imageView);
|
loadBitmap(appData, imageView);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
TextView msgView = (TextView) view.findViewById(R.id.message);
|
TextView msgView = (TextView) view.findViewById(R.id.message);
|
||||||
if (msgView != null) {
|
if (msgView != null) {
|
||||||
Spanned text = null;
|
Spanned text = null;
|
||||||
String msg = message.getText();
|
String msg = message.getText();
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
if (context.getResources().getBoolean(R.bool.emoticons_in_messages)) {
|
|
||||||
text = getSmiledText(context, getTextWithHttpLinks(msg));
|
text = getSmiledText(context, getTextWithHttpLinks(msg));
|
||||||
} else {
|
|
||||||
text = getTextWithHttpLinks(msg);
|
|
||||||
}
|
|
||||||
msgView.setText(text);
|
msgView.setText(text);
|
||||||
msgView.setMovementMethod(LinkMovementMethod.getInstance());
|
msgView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
msgView.setVisibility(View.VISIBLE);
|
msgView.setVisibility(View.VISIBLE);
|
||||||
|
@ -189,22 +212,6 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
|
||||||
|
|
||||||
contact.setText(timestampToHumanDate(context, message.getTime()) + " - " + displayName);
|
contact.setText(timestampToHumanDate(context, message.getTime()) + " - " + displayName);
|
||||||
|
|
||||||
LinphoneChatMessage.State status = message.getStatus();
|
|
||||||
statusView = (ImageView) view.findViewById(R.id.status);
|
|
||||||
inprogress = (ProgressBar) view.findViewById(R.id.inprogress);
|
|
||||||
if (statusView != null) {
|
|
||||||
if (status == LinphoneChatMessage.State.Delivered) {
|
|
||||||
statusView.setVisibility(View.INVISIBLE);
|
|
||||||
inprogress.setVisibility(View.GONE);
|
|
||||||
} else if (status == LinphoneChatMessage.State.NotDelivered) {
|
|
||||||
statusView.setVisibility(View.VISIBLE);
|
|
||||||
statusView.setImageResource(R.drawable.chat_message_not_delivered);
|
|
||||||
} else {
|
|
||||||
statusView.setVisibility(View.GONE);
|
|
||||||
inprogress.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public View getView() {
|
public View getView() {
|
||||||
|
@ -429,6 +436,6 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
|
||||||
@Override
|
@Override
|
||||||
public void onLinphoneChatMessageFileTransferProgressChanged(LinphoneChatMessage msg, LinphoneContent content, int offset, int total) {
|
public void onLinphoneChatMessageFileTransferProgressChanged(LinphoneChatMessage msg, LinphoneContent content, int offset, int total) {
|
||||||
if(nativeMessage.getStorageId() == msg.getStorageId())
|
if(nativeMessage.getStorageId() == msg.getStorageId())
|
||||||
spinner.setProgress(offset * 100 / total);
|
progressBar.setProgress(offset * 100 / total);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue