Update the chat view
This commit is contained in:
parent
92939a7028
commit
a836e839b3
9 changed files with 345 additions and 490 deletions
Binary file not shown.
Before Width: | Height: | Size: 366 B After Width: | Height: | Size: 223 B |
|
@ -8,15 +8,13 @@
|
||||||
android:id="@+id/top_bar"
|
android:id="@+id/top_bar"
|
||||||
android:background="@color/colorF"
|
android:background="@color/colorF"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="60dp"
|
android:layout_height="60dp">
|
||||||
android:layout_gravity="bottom">
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/back"
|
android:id="@+id/back"
|
||||||
android:src="@drawable/back"
|
android:src="@drawable/back"
|
||||||
android:background="@drawable/toolbar_button"
|
android:background="@drawable/toolbar_button"
|
||||||
android:contentDescription="@string/content_description_back"
|
android:layout_width="60dp"
|
||||||
android:layout_width="70dp"
|
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:padding="20dp"/>
|
android:padding="20dp"/>
|
||||||
|
@ -26,7 +24,7 @@
|
||||||
android:src="@drawable/edit_list_button"
|
android:src="@drawable/edit_list_button"
|
||||||
android:background="@drawable/toolbar_button"
|
android:background="@drawable/toolbar_button"
|
||||||
android:contentDescription="@string/content_description_edit"
|
android:contentDescription="@string/content_description_edit"
|
||||||
android:layout_width="70dp"
|
android:layout_width="60dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:padding="15dp"/>
|
android:padding="15dp"/>
|
||||||
|
@ -37,7 +35,7 @@
|
||||||
android:background="@drawable/toolbar_button"
|
android:background="@drawable/toolbar_button"
|
||||||
android:contentDescription="@string/content_description_call"
|
android:contentDescription="@string/content_description_call"
|
||||||
android:layout_toLeftOf="@id/edit"
|
android:layout_toLeftOf="@id/edit"
|
||||||
android:layout_width="70dp"
|
android:layout_width="60dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:padding="15dp"/>
|
android:padding="15dp"/>
|
||||||
|
|
||||||
|
@ -45,9 +43,8 @@
|
||||||
android:id="@+id/back_to_call"
|
android:id="@+id/back_to_call"
|
||||||
android:src="@drawable/call_back"
|
android:src="@drawable/call_back"
|
||||||
android:background="@drawable/toolbar_button"
|
android:background="@drawable/toolbar_button"
|
||||||
android:contentDescription="@string/content_description_call"
|
|
||||||
android:layout_toLeftOf="@id/edit"
|
android:layout_toLeftOf="@id/edit"
|
||||||
android:layout_width="70dp"
|
android:layout_width="60dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:padding="15dp"/>
|
android:padding="15dp"/>
|
||||||
|
@ -61,100 +58,92 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_toRightOf="@id/back"
|
android:layout_toRightOf="@id/back"
|
||||||
android:layout_toLeftOf="@id/start_call"
|
android:layout_toLeftOf="@id/start_call"
|
||||||
android:paddingLeft="10dp"
|
android:gravity="center_vertical"
|
||||||
android:gravity="center_vertical"/>
|
android:paddingLeft="5dp"/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<include layout="@layout/edit_list"/>
|
<include layout="@layout/edit_list"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/footer"
|
android:id="@+id/footer"
|
||||||
|
android:background="@color/colorF"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="60dp"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true">
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:background="@color/colorF">
|
|
||||||
|
|
||||||
<RelativeLayout
|
<LinearLayout
|
||||||
android:id="@+id/messageLayout"
|
android:id="@+id/message_layout"
|
||||||
|
android:orientation="horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/sendPicture"
|
android:id="@+id/send_picture"
|
||||||
|
android:src="@drawable/chat_send_file"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:scaleType="center"
|
android:layout_weight="0.1"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content" />
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:src="@drawable/chat_send_file" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/sendMessage"
|
|
||||||
android:gravity="center"
|
|
||||||
android:padding="5dp"
|
|
||||||
android:scaleType="center"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:src="@drawable/chat_send_message"
|
|
||||||
android:layout_alignTop="@+id/message"
|
|
||||||
android:layout_alignParentRight="true"/>
|
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
|
android:id="@+id/message"
|
||||||
|
android:textColor="@color/colorB"
|
||||||
android:imeOptions="flagNoExtractUi"
|
android:imeOptions="flagNoExtractUi"
|
||||||
android:textCursorDrawable="@null"
|
android:textCursorDrawable="@null"
|
||||||
android:id="@+id/message"
|
|
||||||
android:inputType="textMultiLine"
|
android:inputType="textMultiLine"
|
||||||
android:maxLines="3"
|
android:maxLines="3"
|
||||||
android:textColor="@android:color/black"
|
android:padding="5dp"
|
||||||
|
android:layout_weight="1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_toRightOf="@id/sendPicture"
|
|
||||||
android:layout_toLeftOf="@id/sendMessage"
|
|
||||||
android:background="@drawable/resizable_textfield"
|
android:background="@drawable/resizable_textfield"
|
||||||
android:layout_centerVertical="true"/>
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
<ImageView
|
||||||
|
android:id="@+id/send_message"
|
||||||
|
android:src="@drawable/chat_send_message"
|
||||||
|
android:padding="5dp"
|
||||||
|
android:layout_weight="0.1"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/remoteComposing"
|
android:id="@+id/remote_composing"
|
||||||
|
android:text="@string/remote_composing"
|
||||||
|
style="@style/font11"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="@color/colorB"
|
|
||||||
android:text="@string/remote_composing"
|
|
||||||
android:layout_above="@id/footer"/>
|
android:layout_above="@id/footer"/>
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/chatMessageList"
|
android:id="@+id/chat_message_list"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:divider="@android:color/transparent"
|
android:divider="@android:color/transparent"
|
||||||
android:stackFromBottom="true"
|
android:stackFromBottom="true"
|
||||||
android:transcriptMode="alwaysScroll"
|
android:transcriptMode="alwaysScroll"
|
||||||
android:cacheColorHint="@color/transparent"
|
|
||||||
android:layout_above="@id/remoteComposing"
|
|
||||||
android:dividerHeight="10dp"
|
android:dividerHeight="10dp"
|
||||||
android:layout_marginLeft="10dp"
|
android:cacheColorHint="@color/transparent"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_above="@id/remote_composing"
|
||||||
android:layout_marginBottom="10dp"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_margin="10dp"
|
||||||
android:layout_below="@+id/top_bar"/>
|
android:layout_below="@+id/top_bar"/>
|
||||||
|
|
||||||
<AutoCompleteTextView
|
<AutoCompleteTextView
|
||||||
android:id="@+id/searchContactField"
|
android:id="@+id/search_contact_field"
|
||||||
android:background="@drawable/resizable_textfield"
|
android:background="@drawable/resizable_textfield"
|
||||||
android:hint="@string/search"
|
android:hint="@string/search"
|
||||||
android:inputType="textPersonName"
|
android:inputType="textPersonName"
|
||||||
android:completionThreshold="1"
|
android:completionThreshold="1"
|
||||||
android:textCursorDrawable="@null"
|
android:textCursorDrawable="@null"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:layout_below="@id/top_bar"
|
android:layout_below="@id/top_bar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:paddingRight="5dp"/>
|
android:paddingRight="5dp"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
|
@ -4,106 +4,94 @@
|
||||||
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
|
<LinearLayout
|
||||||
|
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:background="@drawable/resizable_chat_bubble_incoming"
|
android:padding="10dp"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/avatar_layout"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingTop="10dp">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/contact_picture"
|
|
||||||
android:src="@drawable/avatar"
|
|
||||||
android:contentDescription="@string/content_description_contact_picture"
|
|
||||||
android:layout_width="40dp"
|
|
||||||
android:layout_height="40dp"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_marginLeft="5dp"/>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/mask"
|
|
||||||
android:src="@drawable/avatar_chat_mask"
|
|
||||||
android:contentDescription="@string/content_description_contact_picture"
|
|
||||||
android:layout_width="40dp"
|
|
||||||
android:layout_height="40dp"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_marginLeft="5dp"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="12dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/contact_header"
|
|
||||||
style="@style/font9"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/message"
|
|
||||||
style="@style/font11"
|
|
||||||
android:linksClickable="true"
|
|
||||||
android:autoLink="web"
|
|
||||||
android:layout_gravity="left"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/image"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:layout_width="150dp"
|
|
||||||
android:layout_height="150dp"
|
|
||||||
android:scaleType="centerInside"
|
|
||||||
android:maxWidth="250dp"
|
|
||||||
android:maxHeight="250dp" />
|
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/imageLayout"
|
android:id="@+id/avatar_layout"
|
||||||
android:visibility="gone"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<ProgressBar
|
<ImageView
|
||||||
android:id="@+id/progress_bar"
|
android:id="@+id/contact_picture"
|
||||||
android:paddingRight="5dp"
|
android:src="@drawable/avatar"
|
||||||
android:layout_marginTop="10dp"
|
android:contentDescription="@string/content_description_contact_picture"
|
||||||
android:layout_marginBottom="10dp"
|
android:layout_width="40dp"
|
||||||
style="@android:style/Widget.ProgressBar.Horizontal"
|
android:layout_height="40dp"/>
|
||||||
android:layout_width="150dp"
|
|
||||||
android:layout_height="5dp"/>
|
|
||||||
|
|
||||||
<Button
|
<ImageView
|
||||||
android:id="@+id/accept_download"
|
android:id="@+id/mask"
|
||||||
android:text="@string/accept"
|
android:src="@drawable/avatar_chat_mask"
|
||||||
android:background="@drawable/resizable_assistant_button"
|
android:contentDescription="@string/content_description_contact_picture"
|
||||||
style="@style/font8"
|
android:layout_width="40dp"
|
||||||
android:contentDescription="@string/content_description_validate"
|
android:layout_height="40dp"/>
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:layout_below="@id/progress_bar"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingLeft="10dp">
|
||||||
|
|
||||||
</LinearLayout>
|
<TextView
|
||||||
|
android:id="@+id/contact_header"
|
||||||
|
style="@style/font9"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/message"
|
||||||
|
style="@style/font11"
|
||||||
|
android:linksClickable="true"
|
||||||
|
android:autoLink="web"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/image"
|
||||||
|
android:layout_width="150dp"
|
||||||
|
android:layout_height="150dp"
|
||||||
|
android:scaleType="centerInside"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:maxWidth="250dp"
|
||||||
|
android:maxHeight="250dp"/>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/file_transfer_layout"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progress_bar"
|
||||||
|
style="@android:style/Widget.ProgressBar.Horizontal"
|
||||||
|
android:paddingRight="5dp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:layout_width="150dp"
|
||||||
|
android:layout_height="5dp"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/accept_download"
|
||||||
|
android:text="@string/accept"
|
||||||
|
android:background="@drawable/resizable_assistant_button"
|
||||||
|
style="@style/font8"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/progress_bar"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/delete"
|
android:id="@+id/delete"
|
||||||
|
@ -116,6 +104,4 @@
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -3,7 +3,7 @@
|
||||||
android:id="@+id/bubble"
|
android:id="@+id/bubble"
|
||||||
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">
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/delete"
|
android:id="@+id/delete"
|
||||||
|
@ -15,28 +15,28 @@
|
||||||
android:layout_height="30dp"
|
android:layout_height="30dp"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:visibility="gone" />
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
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:layout_toLeftOf="@id/delete"
|
android:layout_toLeftOf="@id/delete"
|
||||||
android:background="@drawable/resizable_chat_bubble_outgoing"
|
android:orientation="horizontal">
|
||||||
android:orientation="horizontal" >
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/contact_picture"
|
android:id="@+id/contact_picture"
|
||||||
android:src="@drawable/avatar"
|
android:src="@drawable/avatar"
|
||||||
android:layout_width="50dp"
|
android:paddingLeft="10dp"
|
||||||
android:layout_height="50dp"
|
|
||||||
android:paddingTop="10dp"
|
android:paddingTop="10dp"
|
||||||
android:paddingLeft="10dp"/>
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="40dp"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="12dp">
|
android:padding="10dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/contact_header"
|
android:id="@+id/contact_header"
|
||||||
|
@ -63,25 +63,25 @@
|
||||||
android:layout_centerInParent="true" />
|
android:layout_centerInParent="true" />
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/imageLayout"
|
android:id="@+id/file_transfer_layout"
|
||||||
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
|
<ProgressBar
|
||||||
android:id="@+id/progress_bar"
|
android:id="@+id/progress_bar"
|
||||||
|
style="@android:style/Widget.ProgressBar.Horizontal"
|
||||||
android:paddingRight="5dp"
|
android:paddingRight="5dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:layout_marginBottom="10dp"
|
android:layout_marginBottom="10dp"
|
||||||
style="@android:style/Widget.ProgressBar.Horizontal"
|
|
||||||
android:layout_width="150dp"
|
android:layout_width="150dp"
|
||||||
android:layout_height="5dp"/>
|
android:layout_height="5dp"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/cancel_upload"
|
android:id="@+id/cancel_upload"
|
||||||
android:text="@string/cancel"
|
android:text="@string/cancel"
|
||||||
android:background="@drawable/resizable_confirm_delete_button"
|
android:background="@drawable/resizable_confirm_delete_button"
|
||||||
style="@style/font15"
|
style="@style/font15"
|
||||||
android:contentDescription="@string/content_description_validate"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/progress_bar"/>
|
android:layout_below="@id/progress_bar"/>
|
||||||
|
@ -94,8 +94,7 @@
|
||||||
android:id="@+id/status"
|
android:id="@+id/status"
|
||||||
android:contentDescription="@string/content_description_message_status"
|
android:contentDescription="@string/content_description_message_status"
|
||||||
android:visibility="invisible"
|
android:visibility="invisible"
|
||||||
android:paddingRight="5dp"
|
android:padding="5dp"
|
||||||
android:paddingTop="5dp"
|
|
||||||
android:layout_gravity="top|right"
|
android:layout_gravity="top|right"
|
||||||
android:layout_width="20dp"
|
android:layout_width="20dp"
|
||||||
android:layout_height="20dp"
|
android:layout_height="20dp"
|
||||||
|
|
|
@ -1,30 +1,26 @@
|
||||||
<?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/layout"
|
android:id="@+id/layout"
|
||||||
|
android:background="@drawable/list_selector"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="60dp"
|
android:layout_height="60dp"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:background="@drawable/list_selector"
|
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical" >
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/Contact_name"
|
android:id="@+id/contact_name"
|
||||||
|
style="@style/font6"
|
||||||
android:lines="1"
|
android:lines="1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_toRightOf="@id/icon"
|
android:layout_centerVertical="true" />
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
|
||||||
android:textColor="@color/colorB" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/contact_address"
|
android:id="@+id/contact_address"
|
||||||
style="@style/font3"
|
style="@style/font2"
|
||||||
|
android:lines="1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_centerVertical="true"/>
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:scaleType="centerInside" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
<style name="font3" parent="@android:style/TextAppearance.Small">
|
<style name="font3" parent="@android:style/TextAppearance.Small">
|
||||||
<item name="android:textColor">@color/colorA</item>
|
<item name="android:textColor">@color/colorA</item>
|
||||||
<item name="android:textSize">16sp</item>
|
<item name="android:textSize">15sp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="font4" parent="@android:style/TextAppearance.Medium">
|
<style name="font4" parent="@android:style/TextAppearance.Medium">
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
<style name="font6" parent="@android:style/TextAppearance.Medium">
|
<style name="font6" parent="@android:style/TextAppearance.Medium">
|
||||||
<item name="android:textColor">@color/colorC</item>
|
<item name="android:textColor">@color/colorC</item>
|
||||||
<item name="android:textSize">20sp</item>
|
<item name="android:textSize">18sp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="font7" parent="@android:style/TextAppearance.Medium">
|
<style name="font7" parent="@android:style/TextAppearance.Medium">
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
|
|
||||||
<style name="font9" parent="@android:style/TextAppearance.Small">
|
<style name="font9" parent="@android:style/TextAppearance.Small">
|
||||||
<item name="android:textColor">@color/colorC</item>
|
<item name="android:textColor">@color/colorC</item>
|
||||||
<item name="android:textSize">16sp</item>
|
<item name="android:textSize">15sp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="font10" parent="@android:style/TextAppearance.Medium">
|
<style name="font10" parent="@android:style/TextAppearance.Medium">
|
||||||
|
|
|
@ -82,8 +82,8 @@ 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.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
@ -110,14 +110,14 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
private String displayName;
|
private String displayName;
|
||||||
private String pictureUri;
|
private String pictureUri;
|
||||||
private EditText message;
|
private EditText message;
|
||||||
private ImageView cancelUpload, edit, selectAll, deselectAll, startCall, delete, sendImage, sendMessage, cancel;
|
private ImageView edit, selectAll, deselectAll, startCall, delete, sendImage, sendMessage, cancel;
|
||||||
private TextView contactName, remoteComposing;
|
private TextView contactName, remoteComposing;
|
||||||
private ImageView back, backToCall;
|
private ImageView back, backToCall;
|
||||||
private AutoCompleteTextView searchContactField;
|
private AutoCompleteTextView searchContactField;
|
||||||
private RelativeLayout uploadLayout, textLayout, topBar, editList;
|
private RelativeLayout topBar, editList;
|
||||||
|
private LinearLayout textLayout;
|
||||||
private ListView messagesList;
|
private ListView messagesList;
|
||||||
|
|
||||||
private ProgressBar progressBar;
|
|
||||||
private boolean isEditMode = false;
|
private boolean isEditMode = false;
|
||||||
private Contact contact;
|
private Contact contact;
|
||||||
private Uri imageToUploadUri;
|
private Uri imageToUploadUri;
|
||||||
|
@ -128,7 +128,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
|
|
||||||
private LinphoneCoreListenerBase mListener;
|
private LinphoneCoreListenerBase mListener;
|
||||||
private ByteArrayInputStream mUploadingImageStream;
|
private ByteArrayInputStream mUploadingImageStream;
|
||||||
private LinphoneChatMessage currentMessageInFileTransferUploadState;
|
|
||||||
private boolean newChatConversation = false;
|
private boolean newChatConversation = false;
|
||||||
|
|
||||||
public static boolean isInstanciated() {
|
public static boolean isInstanciated() {
|
||||||
|
@ -147,6 +146,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
|
|
||||||
if(getArguments() == null || getArguments().getString("SipUri") == null) {
|
if(getArguments() == null || getArguments().getString("SipUri") == null) {
|
||||||
newChatConversation = true;
|
newChatConversation = true;
|
||||||
|
Log.w("lala");
|
||||||
} else {
|
} else {
|
||||||
//Retrieve parameter from intent
|
//Retrieve parameter from intent
|
||||||
sipUri = getArguments().getString("SipUri");
|
sipUri = getArguments().getString("SipUri");
|
||||||
|
@ -156,17 +156,17 @@ 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);
|
||||||
messagesList = (ListView) view.findViewById(R.id.chatMessageList);
|
messagesList = (ListView) view.findViewById(R.id.chat_message_list);
|
||||||
searchContactField = (AutoCompleteTextView) view.findViewById(R.id.searchContactField);
|
searchContactField = (AutoCompleteTextView) view.findViewById(R.id.search_contact_field);
|
||||||
|
|
||||||
editList = (RelativeLayout) view.findViewById(R.id.edit_list);
|
editList = (RelativeLayout) view.findViewById(R.id.edit_list);
|
||||||
textLayout = (RelativeLayout) view.findViewById(R.id.messageLayout);
|
textLayout = (LinearLayout) view.findViewById(R.id.message_layout);
|
||||||
topBar = (RelativeLayout) view.findViewById(R.id.top_bar);
|
topBar = (RelativeLayout) view.findViewById(R.id.top_bar);
|
||||||
|
|
||||||
sendMessage = (ImageView) view.findViewById(R.id.sendMessage);
|
sendMessage = (ImageView) view.findViewById(R.id.send_message);
|
||||||
sendMessage.setOnClickListener(this);
|
sendMessage.setOnClickListener(this);
|
||||||
|
|
||||||
remoteComposing = (TextView) view.findViewById(R.id.remoteComposing);
|
remoteComposing = (TextView) view.findViewById(R.id.remote_composing);
|
||||||
remoteComposing.setVisibility(View.GONE);
|
remoteComposing.setVisibility(View.GONE);
|
||||||
|
|
||||||
cancel = (ImageView) view.findViewById(R.id.cancel);
|
cancel = (ImageView) view.findViewById(R.id.cancel);
|
||||||
|
@ -193,34 +193,18 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
if (newChatConversation) {
|
if (newChatConversation) {
|
||||||
messagesList.setVisibility(View.GONE);
|
messagesList.setVisibility(View.GONE);
|
||||||
searchContactField.setVisibility(View.VISIBLE);
|
searchContactField.setVisibility(View.VISIBLE);
|
||||||
searchContactField.setAdapter(new SearchContactsListAdapter(ContactsManager.getInstance().getAllContacts(), null, inflater));
|
searchContactField.setAdapter(new SearchContactsListAdapter(inflater));
|
||||||
searchContactField.showDropDown();
|
searchContactField.showDropDown();
|
||||||
searchContactField.requestFocus();
|
searchContactField.requestFocus();
|
||||||
edit.setVisibility(View.INVISIBLE);
|
edit.setVisibility(View.INVISIBLE);
|
||||||
startCall.setVisibility(View.INVISIBLE);
|
startCall.setVisibility(View.INVISIBLE);
|
||||||
contactName.setVisibility(View.INVISIBLE);
|
contactName.setVisibility(View.INVISIBLE);
|
||||||
} else {
|
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
|
||||||
if (lc != null) {
|
|
||||||
chatRoom = lc.getOrCreateChatRoom(sipUri);
|
|
||||||
chatRoom.markAsRead();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LinphoneAddress lAddress = null;
|
|
||||||
try {
|
|
||||||
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
|
|
||||||
contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
|
||||||
} catch (Exception e){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
displayChatHeader(lAddress);
|
|
||||||
|
|
||||||
//Manage multiline
|
//Manage multiline
|
||||||
message = (EditText) view.findViewById(R.id.message);
|
message = (EditText) view.findViewById(R.id.message);
|
||||||
|
|
||||||
sendImage = (ImageView) view.findViewById(R.id.sendPicture);
|
sendImage = (ImageView) view.findViewById(R.id.send_picture);
|
||||||
if (!getResources().getBoolean(R.bool.disable_chat_send_file)) {
|
if (!getResources().getBoolean(R.bool.disable_chat_send_file)) {
|
||||||
sendImage.setOnClickListener(new View.OnClickListener() {
|
sendImage.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -277,8 +261,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Force hide keyboard
|
|
||||||
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,10 +268,13 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSipUri() {
|
||||||
|
return sipUri;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
outState.putString("messageDraft", message.getText().toString());
|
outState.putString("messageDraft", message.getText().toString());
|
||||||
|
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,9 +287,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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -318,8 +303,9 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
public void showKeyboardVisibleMode() {
|
public void showKeyboardVisibleMode() {
|
||||||
boolean isOrientationLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
|
boolean isOrientationLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
|
||||||
if (isOrientationLandscape && topBar != null) {
|
if (isOrientationLandscape && topBar != null) {
|
||||||
topBar.setVisibility(View.GONE);
|
//topBar.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
LinphoneActivity.instance().hideTabBar(true);
|
||||||
//contactPicture.setVisibility(View.GONE);
|
//contactPicture.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,8 +313,9 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
boolean isOrientationLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
|
boolean isOrientationLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
|
||||||
//contactPicture.setVisibility(View.VISIBLE);
|
//contactPicture.setVisibility(View.VISIBLE);
|
||||||
if (isOrientationLandscape && topBar != null) {
|
if (isOrientationLandscape && topBar != null) {
|
||||||
topBar.setVisibility(View.VISIBLE);
|
//topBar.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
LinphoneActivity.instance().hideTabBar(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNbItemsChecked(){
|
public int getNbItemsChecked(){
|
||||||
|
@ -415,13 +402,11 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
CheckBox deleteChatBubble = (CheckBox) v.findViewById(R.id.delete);
|
CheckBox deleteChatBubble = (CheckBox) v.findViewById(R.id.delete);
|
||||||
|
|
||||||
if(isEditMode) {
|
if(isEditMode) {
|
||||||
Log.w("edit mode");
|
|
||||||
deleteChatBubble.setVisibility(View.VISIBLE);
|
deleteChatBubble.setVisibility(View.VISIBLE);
|
||||||
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);
|
||||||
layoutParams.setMargins(0, 10, 0, 10);
|
layoutParams.setMargins(0, 10, 0, 10);
|
||||||
v.setLayoutParams(layoutParams);
|
v.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
deleteChatBubble.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
deleteChatBubble.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||||
|
@ -469,6 +454,25 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void initChatRoom(String sipUri) {
|
||||||
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
|
||||||
|
LinphoneAddress lAddress = null;
|
||||||
|
try {
|
||||||
|
lAddress = lc.interpretUrl(sipUri);
|
||||||
|
} catch (Exception e){
|
||||||
|
//TODO Error popup and quit chat
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lAddress != null) {
|
||||||
|
chatRoom = lc.getChatRoom(lAddress);
|
||||||
|
chatRoom.markAsRead();
|
||||||
|
contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
||||||
|
displayChatHeader(lAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void dispayMessageList() {
|
public void dispayMessageList() {
|
||||||
messagesList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
|
messagesList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
|
||||||
adapter = new ChatMessageAdapter(getActivity(), chatRoom.getHistory());
|
adapter = new ChatMessageAdapter(getActivity(), chatRoom.getHistory());
|
||||||
|
@ -488,52 +492,18 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
this.displayName = displayName;
|
this.displayName = displayName;
|
||||||
this.pictureUri = pictureUri;
|
this.pictureUri = pictureUri;
|
||||||
|
|
||||||
if (!message.getText().toString().equals("") && LinphoneActivity.isInstanciated()) {
|
initChatRoom(sipUri);
|
||||||
ChatStorage chatStorage = LinphoneActivity.instance().getChatStorage();
|
|
||||||
if (chatStorage.getDraft(sipUri) == null) {
|
|
||||||
chatStorage.saveDraft(sipUri, message.getText().toString());
|
|
||||||
} else {
|
|
||||||
chatStorage.updateDraft(sipUri, message.getText().toString());
|
|
||||||
}
|
|
||||||
} else if (LinphoneActivity.isInstanciated()) {
|
|
||||||
LinphoneActivity.instance().getChatStorage().deleteDraft(sipUri);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
if(chatRoom != null) {
|
||||||
String draft = LinphoneActivity.instance().getChatStorage().getDraft(sipUri);
|
LinphoneAddress lAddress = chatRoom.getPeerAddress();
|
||||||
if (draft == null)
|
displayChatHeader(lAddress);
|
||||||
draft = "";
|
dispayMessageList();
|
||||||
message.setText(draft);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LinphoneAddress lAddress = null;
|
|
||||||
try {
|
|
||||||
lAddress = LinphoneManager.getLc().interpretUrl(sipUri);
|
|
||||||
if(contact == null)
|
|
||||||
contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
|
||||||
} catch (Exception e){
|
|
||||||
Log.w("error");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(lAddress == null){
|
|
||||||
//TODO SHOW POPUP
|
|
||||||
LinphoneActivity.instance().displayChatList();
|
|
||||||
}
|
|
||||||
|
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
|
||||||
if (lc != null) {
|
|
||||||
chatRoom = lc.getOrCreateChatRoom(sipUri);
|
|
||||||
//Only works if using liblinphone storage
|
|
||||||
chatRoom.markAsRead();
|
|
||||||
}
|
|
||||||
|
|
||||||
displayChatHeader(lAddress);
|
|
||||||
dispayMessageList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
||||||
if (v.getId() == R.id.sendPicture) {
|
if (v.getId() == R.id.send_picture) {
|
||||||
menu.add(0, MENU_PICTURE_SMALL, 0, getString(R.string.share_picture_size_small));
|
menu.add(0, MENU_PICTURE_SMALL, 0, getString(R.string.share_picture_size_small));
|
||||||
menu.add(0, MENU_PICTURE_MEDIUM, 0, getString(R.string.share_picture_size_medium));
|
menu.add(0, MENU_PICTURE_MEDIUM, 0, getString(R.string.share_picture_size_medium));
|
||||||
menu.add(0, MENU_PICTURE_LARGE, 0, getString(R.string.share_picture_size_large));
|
menu.add(0, MENU_PICTURE_LARGE, 0, getString(R.string.share_picture_size_large));
|
||||||
|
@ -586,9 +556,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();
|
||||||
|
|
||||||
|
@ -602,13 +571,8 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
|
|
||||||
LinphoneManager.removeListener(this);
|
LinphoneManager.removeListener(this);
|
||||||
|
|
||||||
onSaveInstanceState(getArguments());
|
onSaveInstanceState(getArguments());
|
||||||
|
|
||||||
// uploadLayout.setVisibility(View.GONE);
|
|
||||||
// textLayout.setVisibility(View.VISIBLE);
|
|
||||||
//progressBar.setProgress(0);
|
|
||||||
|
|
||||||
//Hide keybord
|
//Hide keybord
|
||||||
InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
imm.hideSoftInputFromWindow(message.getWindowToken(), 0);
|
imm.hideSoftInputFromWindow(message.getWindowToken(), 0);
|
||||||
|
@ -618,8 +582,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) {
|
||||||
|
@ -629,7 +593,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CHAT);
|
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CHAT);
|
||||||
LinphoneActivity.instance().updateChatFragment(this);
|
LinphoneActivity.instance().updateChatFragment(this);
|
||||||
LinphoneActivity.instance().hideTabBar(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(LinphoneManager.getLc().isIncall()){
|
if(LinphoneManager.getLc().isIncall()){
|
||||||
|
@ -642,42 +605,21 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LinphoneAddress lAddress;
|
|
||||||
try {
|
|
||||||
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
|
|
||||||
contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
|
||||||
} catch (Exception e){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
LinphoneManager.addListener(this);
|
LinphoneManager.addListener(this);
|
||||||
|
|
||||||
final LinphoneChatMessage msg = LinphoneManager.getInstance().getMessageUploadPending();
|
// Force hide keyboard
|
||||||
if(msg != null && msg.getTo().asString().equals(sipUri)){
|
boolean isOrientationLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
|
||||||
//uploadLayout.setVisibility(View.VISIBLE);
|
if(isOrientationLandscape) {
|
||||||
// textLayout.setVisibility(View.GONE);
|
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
|
||||||
// if(msg.getFileTransferInformation() != null){
|
} else {
|
||||||
// progressBar.setProgress(msg.getFileTransferInformation().getRealSize());
|
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
||||||
// }
|
|
||||||
|
|
||||||
/* cancelUpload.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
uploadLayout.setVisibility(View.GONE);
|
|
||||||
textLayout.setVisibility(View.VISIBLE);
|
|
||||||
progressBar.setProgress(0);
|
|
||||||
msg.cancelFileTransfer();
|
|
||||||
LinphoneManager.getInstance().setUploadPendingFileMessage(null);
|
|
||||||
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String draft = getArguments().getString("messageDraft");
|
String draft = getArguments().getString("messageDraft");
|
||||||
message.setText(draft);
|
message.setText(draft);
|
||||||
|
|
||||||
|
|
||||||
if(!newChatConversation) {
|
if(!newChatConversation) {
|
||||||
|
initChatRoom(sipUri);
|
||||||
remoteComposing.setVisibility(chatRoom.isRemoteComposing() ? View.VISIBLE : View.GONE);
|
remoteComposing.setVisibility(chatRoom.isRemoteComposing() ? View.VISIBLE : View.GONE);
|
||||||
dispayMessageList();
|
dispayMessageList();
|
||||||
}
|
}
|
||||||
|
@ -713,13 +655,10 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
int id = v.getId();
|
int id = v.getId();
|
||||||
|
|
||||||
Log.w(id);
|
|
||||||
|
|
||||||
if (id == R.id.back_to_call) {
|
if (id == R.id.back_to_call) {
|
||||||
LinphoneActivity.instance().resetClassicMenuLayoutAndGoBackToCallIfStillRunning();
|
LinphoneActivity.instance().resetClassicMenuLayoutAndGoBackToCallIfStillRunning();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
@ -734,12 +673,10 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
selectAllList(false);
|
selectAllList(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id == R.id.cancel) {
|
if (id == R.id.cancel) {
|
||||||
quitEditMode();
|
quitEditMode();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id == R.id.delete) {
|
if (id == R.id.delete) {
|
||||||
final Dialog dialog = LinphoneActivity.instance().displayDialog(getString(R.string.delete_text));
|
final Dialog dialog = LinphoneActivity.instance().displayDialog(getString(R.string.delete_text));
|
||||||
Button delete = (Button) dialog.findViewById(R.id.delete);
|
Button delete = (Button) dialog.findViewById(R.id.delete);
|
||||||
|
@ -764,21 +701,16 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
dialog.show();
|
dialog.show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(id == R.id.send_message){
|
||||||
if(id == R.id.sendMessage){
|
|
||||||
sendTextMessage();
|
sendTextMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id == R.id.edit) {
|
if (id == R.id.edit) {
|
||||||
topBar.setVisibility(View.INVISIBLE);
|
topBar.setVisibility(View.INVISIBLE);
|
||||||
editList.setVisibility(View.VISIBLE);
|
editList.setVisibility(View.VISIBLE);
|
||||||
isEditMode = true;
|
isEditMode = true;
|
||||||
dispayMessageList();
|
dispayMessageList();
|
||||||
}
|
}
|
||||||
else if (id == R.id.new_discussion) {
|
if(id == R.id.start_call){
|
||||||
//TODO call sipUri
|
|
||||||
}
|
|
||||||
else if(id == R.id.start_call){
|
|
||||||
LinphoneActivity.instance().setAddresGoToDialerAndCall(sipUri, LinphoneUtils.getUsernameFromAddress(sipUri), null);
|
LinphoneActivity.instance().setAddresGoToDialerAndCall(sipUri, LinphoneUtils.getUsernameFromAddress(sipUri), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -788,7 +720,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
message.setText("");
|
message.setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void displayBubbleChat(LinphoneChatMessage message){
|
private void displayBubbleChat(LinphoneChatMessage message){
|
||||||
adapter.addMessage(message);
|
adapter.addMessage(message);
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
|
@ -797,44 +728,33 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
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();
|
||||||
|
LinphoneAddress lAddress = null;
|
||||||
|
|
||||||
//Start new conversation in fast chat
|
//Start new conversation in fast chat
|
||||||
if(newChatConversation){
|
if(newChatConversation && chatRoom == null) {
|
||||||
String address = searchContactField.getText().toString();
|
String address = searchContactField.getText().toString();
|
||||||
if(address != null && !address.equals("")) {
|
if (address != null && !address.equals("")) {
|
||||||
LinphoneAddress lAddress = LinphoneManager.getLc().getDefaultProxyConfig().normalizeSipUri(address);
|
initChatRoom(address);
|
||||||
if(lAddress != null) {
|
|
||||||
chatRoom = lc.getChatRoom(lAddress);
|
|
||||||
if (chatRoom != null && messageToSend != null && messageToSend.length() > 0 && isNetworkReachable) {
|
|
||||||
LinphoneChatMessage message = chatRoom.createLinphoneChatMessage(messageToSend);
|
|
||||||
chatRoom.sendChatMessage(message);
|
|
||||||
message.setListener(LinphoneManager.getInstance());
|
|
||||||
Contact lContact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
|
||||||
if (lContact != null)
|
|
||||||
exitNewConversationMode(lContact, lAddress.asStringUriOnly(), null);
|
|
||||||
else
|
|
||||||
exitNewConversationMode(null, lAddress.asStringUriOnly(), lAddress.getUserName());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//TODO ERROR MESSAGE
|
|
||||||
LinphoneActivity.instance().displayCustomToast(getString(R.string.error_user_not_found), Toast.LENGTH_LONG);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} 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);
|
||||||
|
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
LinphoneActivity.instance().onMessageSent(sipUri, messageToSend);
|
LinphoneActivity.instance().onMessageSent(sipUri, messageToSend);
|
||||||
}
|
}
|
||||||
|
|
||||||
message.setListener(LinphoneManager.getInstance());
|
message.setListener(LinphoneManager.getInstance());
|
||||||
|
if (newChatConversation) {
|
||||||
|
exitNewConversationMode(contact, lAddress.asStringUriOnly(), null);
|
||||||
|
} else {
|
||||||
invalidate();
|
invalidate();
|
||||||
Log.i("Sent message current status: " + message.getStatus());
|
|
||||||
} else if (!isNetworkReachable && LinphoneActivity.isInstanciated()) {
|
|
||||||
LinphoneActivity.instance().displayCustomToast(getString(R.string.error_network_unreachable), Toast.LENGTH_LONG);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.i("Sent message current status: " + message.getStatus());
|
||||||
|
} else if (!isNetworkReachable && LinphoneActivity.isInstanciated()) {
|
||||||
|
LinphoneActivity.instance().displayCustomToast(getString(R.string.error_network_unreachable), Toast.LENGTH_LONG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -860,6 +780,76 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private LinphoneChatMessage getMessageForId(int id) {
|
||||||
|
for (LinphoneChatMessage message : chatRoom.getHistory()) {
|
||||||
|
if (message.getStorageId() == id) {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void invalidate() {
|
||||||
|
adapter.refreshHistory();
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
chatRoom.markAsRead();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resendMessage(int id) {
|
||||||
|
LinphoneChatMessage message = getMessageForId(id);
|
||||||
|
if (message == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
chatRoom.deleteMessage(getMessageForId(id));
|
||||||
|
invalidate();
|
||||||
|
|
||||||
|
if (message.getText() != null && message.getText().length() > 0) {
|
||||||
|
sendTextMessage(message.getText());
|
||||||
|
} else {
|
||||||
|
sendImageMessage(message.getAppData(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void copyTextMessageToClipboard(int id) {
|
||||||
|
String msg = LinphoneActivity.instance().getChatStorage().getTextMessageForId(chatRoom, id);
|
||||||
|
if (msg != null) {
|
||||||
|
Compatibility.copyTextToClipboard(getActivity(), msg);
|
||||||
|
LinphoneActivity.instance().displayCustomToast(getString(R.string.text_copied_to_clipboard), Toast.LENGTH_SHORT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//File transfer
|
||||||
|
private void pickImage() {
|
||||||
|
List<Intent> cameraIntents = new ArrayList<Intent>();
|
||||||
|
Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
File file = new File(Environment.getExternalStorageDirectory(), getString(R.string.temp_photo_name_with_date).replace("%s", String.valueOf(System.currentTimeMillis())));
|
||||||
|
imageToUploadUri = Uri.fromFile(file);
|
||||||
|
captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageToUploadUri);
|
||||||
|
cameraIntents.add(captureIntent);
|
||||||
|
|
||||||
|
Intent galleryIntent = new Intent();
|
||||||
|
galleryIntent.setType("image/*");
|
||||||
|
galleryIntent.setAction(Intent.ACTION_PICK);
|
||||||
|
|
||||||
|
Intent chooserIntent = Intent.createChooser(galleryIntent, getString(R.string.image_picker_title));
|
||||||
|
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[]{}));
|
||||||
|
|
||||||
|
startActivityForResult(chooserIntent, ADD_PHOTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRealPathFromURI(Uri contentUri) {
|
||||||
|
String[] proj = {MediaStore.Images.Media.DATA};
|
||||||
|
CursorLoader loader = new CursorLoader(getActivity(), contentUri, proj, null, null, null);
|
||||||
|
Cursor cursor = loader.loadInBackground();
|
||||||
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
|
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||||
|
String result = cursor.getString(column_index);
|
||||||
|
cursor.close();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
class FileUploadPrepareTask extends AsyncTask<Bitmap, Void, byte[]> {
|
class FileUploadPrepareTask extends AsyncTask<Bitmap, Void, byte[]> {
|
||||||
private String path;
|
private String path;
|
||||||
private int imageSize;
|
private int imageSize;
|
||||||
|
@ -868,8 +858,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
public FileUploadPrepareTask(Context context, String fileToUploadPath, int size) {
|
public FileUploadPrepareTask(Context context, String fileToUploadPath, int size) {
|
||||||
path = fileToUploadPath;
|
path = fileToUploadPath;
|
||||||
imageSize = size;
|
imageSize = size;
|
||||||
//uploadLayout.setVisibility(View.VISIBLE);
|
|
||||||
//textLayout.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
progressDialog = new ProgressDialog(context);
|
progressDialog = new ProgressDialog(context);
|
||||||
progressDialog.setIndeterminate(true);
|
progressDialog.setIndeterminate(true);
|
||||||
|
@ -917,9 +905,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
if (progressDialog != null && progressDialog.isShowing()) {
|
if (progressDialog != null && progressDialog.isShowing()) {
|
||||||
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);
|
||||||
|
@ -930,110 +915,14 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
message.setListener(LinphoneManager.getInstance());
|
message.setListener(LinphoneManager.getInstance());
|
||||||
message.setAppData(path);
|
message.setAppData(path);
|
||||||
|
|
||||||
LinphoneManager.getInstance().setUploadPendingFileMessage(message);
|
LinphoneManager.getInstance().setUploadPendingFileMessage(message);
|
||||||
LinphoneManager.getInstance().setUploadingImageStream(mUploadingImageStream);
|
LinphoneManager.getInstance().setUploadingImageStream(mUploadingImageStream);
|
||||||
|
|
||||||
chatRoom.sendChatMessage(message);
|
chatRoom.sendChatMessage(message);
|
||||||
currentMessageInFileTransferUploadState = message;
|
|
||||||
|
|
||||||
displayBubbleChat(message);
|
displayBubbleChat(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private LinphoneChatMessage getMessageForId(int id) {
|
|
||||||
for (LinphoneChatMessage message : chatRoom.getHistory()) {
|
|
||||||
if (message.getStorageId() == id) {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void invalidate() {
|
|
||||||
adapter.refreshHistory();
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
chatRoom.markAsRead();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void resendMessage(int id) {
|
|
||||||
LinphoneChatMessage message = getMessageForId(id);
|
|
||||||
if (message == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
chatRoom.deleteMessage(getMessageForId(id));
|
|
||||||
invalidate();
|
|
||||||
|
|
||||||
if (message.getText() != null && message.getText().length() > 0) {
|
|
||||||
sendTextMessage(message.getText());
|
|
||||||
} else {
|
|
||||||
sendImageMessage(message.getAppData(), 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void copyTextMessageToClipboard(int id) {
|
|
||||||
String msg = LinphoneActivity.instance().getChatStorage().getTextMessageForId(chatRoom, id);
|
|
||||||
if (msg != null) {
|
|
||||||
Compatibility.copyTextToClipboard(getActivity(), msg);
|
|
||||||
LinphoneActivity.instance().displayCustomToast(getString(R.string.text_copied_to_clipboard), Toast.LENGTH_SHORT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSipUri() {
|
|
||||||
return sipUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void pickImage() {
|
|
||||||
List<Intent> cameraIntents = new ArrayList<Intent>();
|
|
||||||
Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
|
||||||
File file = new File(Environment.getExternalStorageDirectory(), getString(R.string.temp_photo_name_with_date).replace("%s", String.valueOf(System.currentTimeMillis())));
|
|
||||||
imageToUploadUri = Uri.fromFile(file);
|
|
||||||
captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageToUploadUri);
|
|
||||||
cameraIntents.add(captureIntent);
|
|
||||||
|
|
||||||
Intent galleryIntent = new Intent();
|
|
||||||
galleryIntent.setType("image/*");
|
|
||||||
galleryIntent.setAction(Intent.ACTION_PICK);
|
|
||||||
|
|
||||||
Intent chooserIntent = Intent.createChooser(galleryIntent, getString(R.string.image_picker_title));
|
|
||||||
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[]{}));
|
|
||||||
|
|
||||||
startActivityForResult(chooserIntent, ADD_PHOTO);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRealPathFromURI(Uri contentUri) {
|
|
||||||
String[] proj = {MediaStore.Images.Media.DATA};
|
|
||||||
CursorLoader loader = new CursorLoader(getActivity(), contentUri, proj, null, null, null);
|
|
||||||
Cursor cursor = loader.loadInBackground();
|
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
|
||||||
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
|
||||||
String result = cursor.getString(column_index);
|
|
||||||
cursor.close();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void exitNewConversationMode(Contact c, String address, String username){
|
|
||||||
searchContactField.setVisibility(View.GONE);
|
|
||||||
sipUri = address;
|
|
||||||
messagesList.setVisibility(View.VISIBLE);
|
|
||||||
contactName.setVisibility(View.VISIBLE);
|
|
||||||
edit.setVisibility(View.VISIBLE);
|
|
||||||
back.setVisibility(View.VISIBLE);
|
|
||||||
startCall.setVisibility(View.VISIBLE);
|
|
||||||
newChatConversation = false;
|
|
||||||
chatRoom = LinphoneManager.getLc().getOrCreateChatRoom(address);
|
|
||||||
|
|
||||||
if(c != null) {
|
|
||||||
contact = c;
|
|
||||||
changeDisplayedChat(address,c.getName(),null);
|
|
||||||
} else {
|
|
||||||
changeDisplayedChat(address,username,null);
|
|
||||||
}
|
|
||||||
dispayMessageList();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showPopupMenuAskingImageSize(final String filePath) {
|
private void showPopupMenuAskingImageSize(final String filePath) {
|
||||||
filePathToUpload = filePath;
|
filePathToUpload = filePath;
|
||||||
try {
|
try {
|
||||||
|
@ -1063,28 +952,20 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
//New conversation
|
||||||
public void onLinphoneChatMessageStateChanged(LinphoneChatMessage msg, State state) {
|
private void exitNewConversationMode(Contact c, String address, String username){
|
||||||
if (state == State.FileTransferDone || state == State.FileTransferError) {
|
sipUri = address;
|
||||||
currentMessageInFileTransferUploadState = null;
|
searchContactField.setVisibility(View.GONE);
|
||||||
}
|
messagesList.setVisibility(View.VISIBLE);
|
||||||
invalidate();
|
contactName.setVisibility(View.VISIBLE);
|
||||||
|
edit.setVisibility(View.VISIBLE);
|
||||||
|
back.setVisibility(View.VISIBLE);
|
||||||
|
startCall.setVisibility(View.VISIBLE);
|
||||||
|
newChatConversation = false;
|
||||||
|
initChatRoom(sipUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private class ContactAddress {
|
||||||
public void onLinphoneChatMessageFileTransferReceived(LinphoneChatMessage msg, LinphoneContent content, LinphoneBuffer buffer) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLinphoneChatMessageFileTransferSent(LinphoneChatMessage msg, LinphoneContent content, int offset, int size, LinphoneBuffer bufferToFill) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLinphoneChatMessageFileTransferProgressChanged(LinphoneChatMessage msg, LinphoneContent content, int offset, int total) {
|
|
||||||
//progressBar.setProgress(offset * 100 / total);
|
|
||||||
}
|
|
||||||
|
|
||||||
class ContactAddress {
|
|
||||||
Contact contact;
|
Contact contact;
|
||||||
String address;
|
String address;
|
||||||
|
|
||||||
|
@ -1096,11 +977,9 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
|
|
||||||
class SearchContactsListAdapter extends BaseAdapter implements Filterable {
|
class SearchContactsListAdapter extends BaseAdapter implements Filterable {
|
||||||
private List<ContactAddress> contacts;
|
private List<ContactAddress> contacts;
|
||||||
private Cursor cursor;
|
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
|
|
||||||
SearchContactsListAdapter(List<Contact> contactsList, Cursor c, LayoutInflater inflater) {
|
SearchContactsListAdapter(LayoutInflater inflater) {
|
||||||
cursor = c;
|
|
||||||
mInflater = inflater;
|
mInflater = inflater;
|
||||||
contacts = getContactsList();
|
contacts = getContactsList();
|
||||||
}
|
}
|
||||||
|
@ -1109,9 +988,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
public Filter getFilter() {
|
public Filter getFilter() {
|
||||||
return new Filter() {
|
return new Filter() {
|
||||||
@Override
|
@Override
|
||||||
protected void publishResults(CharSequence constraint,
|
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||||
FilterResults results) {
|
|
||||||
|
|
||||||
if (results.count > 0) {
|
if (results.count > 0) {
|
||||||
contacts.clear();
|
contacts.clear();
|
||||||
contacts = (List<ContactAddress>) results.values;
|
contacts = (List<ContactAddress>) results.values;
|
||||||
|
@ -1186,17 +1063,16 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
final String a = contact.address;
|
final String a = contact.address;
|
||||||
final Contact c = contact.contact;
|
final Contact c = contact.contact;
|
||||||
|
|
||||||
TextView name = (TextView) view.findViewById(R.id.Contact_name);
|
TextView name = (TextView) view.findViewById(R.id.contact_name);
|
||||||
name.setText(c.getName());
|
name.setText(c.getName());
|
||||||
|
|
||||||
final TextView address = (TextView) view.findViewById(R.id.contact_address);
|
TextView address = (TextView) view.findViewById(R.id.contact_address);
|
||||||
address.setText(a);
|
address.setText(a);
|
||||||
|
|
||||||
view.setOnClickListener(new OnClickListener() {
|
view.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
exitNewConversationMode(c, a,null);
|
exitNewConversationMode(c, a, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1204,5 +1080,18 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//LinphoneChatMessage Listener
|
||||||
|
@Override
|
||||||
|
public void onLinphoneChatMessageStateChanged(LinphoneChatMessage msg, State state) {
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLinphoneChatMessageFileTransferReceived(LinphoneChatMessage msg, LinphoneContent content, LinphoneBuffer buffer) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLinphoneChatMessageFileTransferSent(LinphoneChatMessage msg, LinphoneContent content, int offset, int size, LinphoneBuffer bufferToFill) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLinphoneChatMessageFileTransferProgressChanged(LinphoneChatMessage msg, LinphoneContent content, int offset, int total) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -280,10 +280,9 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
this.mUploadingImageStream = array;
|
this.mUploadingImageStream = array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLinphoneChatMessageStateChanged(LinphoneChatMessage msg, LinphoneChatMessage.State state) {
|
public void onLinphoneChatMessageStateChanged(LinphoneChatMessage msg, LinphoneChatMessage.State state) {
|
||||||
if (state == LinphoneChatMessage.State.FileTransferDone || state == LinphoneChatMessage.State.FileTransferError) {
|
if (state == LinphoneChatMessage.State.FileTransferDone) {
|
||||||
if(msg.isOutgoing() && mUploadingImageStream != null){
|
if(msg.isOutgoing() && mUploadingImageStream != null){
|
||||||
mUploadPendingFileMessage = null;
|
mUploadPendingFileMessage = null;
|
||||||
mUploadingImageStream = null;
|
mUploadingImageStream = null;
|
||||||
|
@ -300,6 +299,10 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(state == LinphoneChatMessage.State.FileTransferError) {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
for (LinphoneChatMessage.LinphoneChatMessageListener l: simpleListeners) {
|
for (LinphoneChatMessage.LinphoneChatMessageListener l: simpleListeners) {
|
||||||
l.onLinphoneChatMessageStateChanged(msg, state);
|
l.onLinphoneChatMessageStateChanged(msg, state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.linphone.Contact;
|
import org.linphone.Contact;
|
||||||
import org.linphone.ContactsManager;
|
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphoneUtils;
|
import org.linphone.LinphoneUtils;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
|
@ -45,7 +44,6 @@ import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.media.Image;
|
|
||||||
import android.media.ThumbnailUtils;
|
import android.media.ThumbnailUtils;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
@ -62,7 +60,6 @@ import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -96,12 +93,10 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
|
||||||
} else {
|
} else {
|
||||||
view = LayoutInflater.from(context).inflate(R.layout.chat_bubble_incoming, null);
|
view = LayoutInflater.from(context).inflate(R.layout.chat_bubble_incoming, null);
|
||||||
}
|
}
|
||||||
|
view.setId(message.getStorageId());
|
||||||
|
|
||||||
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);
|
inprogress = (ProgressBar) view.findViewById(R.id.inprogress);
|
||||||
|
|
||||||
view.setId(message.getStorageId());
|
|
||||||
|
|
||||||
progressBar = (ProgressBar) view.findViewById(R.id.progress_bar);
|
progressBar = (ProgressBar) view.findViewById(R.id.progress_bar);
|
||||||
|
|
||||||
LinphoneChatMessage.State status = message.getStatus();
|
LinphoneChatMessage.State status = message.getStatus();
|
||||||
|
@ -120,6 +115,9 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String externalBodyUrl = message.getExternalBodyUrl();
|
||||||
|
LinphoneContent fileTransferContent = message.getFileTransferInformation();
|
||||||
|
|
||||||
if(nativeMessage.isOutgoing()){
|
if(nativeMessage.isOutgoing()){
|
||||||
cancelUpload = (Button) view.findViewById(R.id.cancel_upload);
|
cancelUpload = (Button) view.findViewById(R.id.cancel_upload);
|
||||||
cancelUpload.setOnClickListener(new View.OnClickListener() {
|
cancelUpload.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -127,8 +125,6 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (LinphoneManager.getInstance().getMessageUploadPending() != null) {
|
if (LinphoneManager.getInstance().getMessageUploadPending() != null) {
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
//tex.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
progressBar.setProgress(0);
|
progressBar.setProgress(0);
|
||||||
nativeMessage.cancelFileTransfer();
|
nativeMessage.cancelFileTransfer();
|
||||||
LinphoneManager.getInstance().setUploadPendingFileMessage(null);
|
LinphoneManager.getInstance().setUploadPendingFileMessage(null);
|
||||||
|
@ -137,9 +133,6 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
String externalBodyUrl = message.getExternalBodyUrl();
|
|
||||||
LinphoneContent fileTransferContent = message.getFileTransferInformation();
|
|
||||||
|
|
||||||
if(LinphoneManager.getInstance().getMessageUploadPending() != null){
|
if(LinphoneManager.getInstance().getMessageUploadPending() != null){
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
LinphoneManager.addListener(this);
|
LinphoneManager.addListener(this);
|
||||||
|
@ -153,7 +146,7 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
|
||||||
imageView.setVisibility(View.VISIBLE);
|
imageView.setVisibility(View.VISIBLE);
|
||||||
loadBitmap(appData, imageView);
|
loadBitmap(appData, imageView);
|
||||||
|
|
||||||
RelativeLayout imageLayout = (RelativeLayout) view.findViewById(R.id.imageLayout);
|
RelativeLayout imageLayout = (RelativeLayout) view.findViewById(R.id.file_transfer_layout);
|
||||||
if(LinphoneManager.getInstance().getMessageUploadPending() != null && LinphoneManager.getInstance().getMessageUploadPending().getStorageId() == nativeMessage.getStorageId()){
|
if(LinphoneManager.getInstance().getMessageUploadPending() != null && LinphoneManager.getInstance().getMessageUploadPending().getStorageId() == nativeMessage.getStorageId()){
|
||||||
inprogress.setVisibility(View.INVISIBLE);
|
inprogress.setVisibility(View.INVISIBLE);
|
||||||
imageLayout.setVisibility(View.VISIBLE);
|
imageLayout.setVisibility(View.VISIBLE);
|
||||||
|
@ -165,8 +158,8 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
|
||||||
appData = null;
|
appData = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
RelativeLayout imageLayout = (RelativeLayout) view.findViewById(R.id.imageLayout);
|
RelativeLayout imageLayout = (RelativeLayout) view.findViewById(R.id.file_transfer_layout);
|
||||||
Button acceptDownload = (Button) view.findViewById(R.id.accept_download);
|
acceptDownload = (Button) view.findViewById(R.id.accept_download);
|
||||||
|
|
||||||
if (appData == null) {
|
if (appData == null) {
|
||||||
LinphoneManager.addListener(this);
|
LinphoneManager.addListener(this);
|
||||||
|
|
Loading…
Reference in a new issue