Add chat edition for deleting chat message
fix new conversation
This commit is contained in:
parent
5e7b18b2ff
commit
0da770e015
6 changed files with 245 additions and 196 deletions
|
@ -62,89 +62,71 @@
|
||||||
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:paddingLeft="10dp"
|
||||||
android:gravity="center"/>
|
android:gravity="center_vertical"/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<include layout="@layout/edit_list"/>
|
<include layout="@layout/edit_list"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/footer"
|
android:id="@+id/footer"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:background="@color/colorF">
|
android:background="@color/colorF">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/messageLayout"
|
android:id="@+id/messageLayout"
|
||||||
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/sendPicture"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:scaleType="center"
|
android:scaleType="center"
|
||||||
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_alignParentLeft="true"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:src="@drawable/chat_send_file" />
|
android:src="@drawable/chat_send_file" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/sendMessage"
|
android:id="@+id/sendMessage"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:scaleType="center"
|
android:scaleType="center"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:src="@drawable/chat_send_message"
|
android:src="@drawable/chat_send_message"
|
||||||
android:layout_alignTop="@+id/message"
|
android:layout_alignTop="@+id/message"
|
||||||
android:layout_alignParentRight="true"/>
|
android:layout_alignParentRight="true"/>
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:imeOptions="flagNoExtractUi"
|
android:imeOptions="flagNoExtractUi"
|
||||||
android:textCursorDrawable="@null"
|
android:textCursorDrawable="@null"
|
||||||
android:id="@+id/message"
|
android:id="@+id/message"
|
||||||
android:inputType="textMultiLine"
|
android:inputType="textMultiLine"
|
||||||
android:maxLines="3"
|
android:maxLines="3"
|
||||||
android:textColor="@android:color/black"
|
android:textColor="@android:color/black"
|
||||||
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_toRightOf="@id/sendPicture"
|
||||||
android:layout_toLeftOf="@id/sendMessage"
|
android:layout_toLeftOf="@id/sendMessage"
|
||||||
android:background="@drawable/resizable_textfield"
|
android:background="@drawable/resizable_textfield"
|
||||||
android:layout_centerVertical="true"/>
|
android:layout_centerVertical="true"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/uploadLayout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:contentDescription="@string/content_description_cancel"
|
|
||||||
android:id="@+id/cancelUpload"
|
|
||||||
android:src="@drawable/clean_field_default"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:padding="20dp" />
|
|
||||||
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/remoteComposing"
|
android:id="@+id/remoteComposing"
|
||||||
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:textColor="@color/colorB"
|
||||||
android:text="@string/remote_composing"
|
android:text="@string/remote_composing"
|
||||||
android:layout_above="@id/footer"/>
|
android:layout_above="@id/footer"/>
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/chatMessageList"
|
android:id="@+id/chatMessageList"
|
||||||
|
@ -154,8 +136,8 @@
|
||||||
android:stackFromBottom="true"
|
android:stackFromBottom="true"
|
||||||
android:transcriptMode="alwaysScroll"
|
android:transcriptMode="alwaysScroll"
|
||||||
android:cacheColorHint="@color/transparent"
|
android:cacheColorHint="@color/transparent"
|
||||||
android:dividerHeight="10dp"
|
|
||||||
android:layout_above="@id/remoteComposing"
|
android:layout_above="@id/remoteComposing"
|
||||||
|
android:dividerHeight="10dp"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
android:layout_marginBottom="10dp"
|
android:layout_marginBottom="10dp"
|
||||||
|
@ -166,6 +148,7 @@
|
||||||
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:id="@+id/searchContactField"
|
android:id="@+id/searchContactField"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
|
@ -173,9 +156,7 @@
|
||||||
android:background="@drawable/resizable_textfield"
|
android:background="@drawable/resizable_textfield"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:completionThreshold="1"
|
android:completionThreshold="1"
|
||||||
android:layout_below="@+id/top_bar"
|
|
||||||
android:paddingRight="5dp"
|
android:paddingRight="5dp"
|
||||||
android:inputType="textPersonName"/>
|
android:inputType="textPersonName"/>
|
||||||
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
|
@ -108,12 +108,13 @@
|
||||||
android:id="@+id/delete"
|
android:id="@+id/delete"
|
||||||
android:button="@drawable/checkbox"
|
android:button="@drawable/checkbox"
|
||||||
android:contentDescription="@string/content_description_delete"
|
android:contentDescription="@string/content_description_delete"
|
||||||
android:paddingRight="5dp"
|
android:layout_marginLeft="5dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_marginRight="5dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="30dp"
|
||||||
|
android:layout_height="30dp"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -1,13 +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"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
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
|
||||||
|
android:id="@+id/delete"
|
||||||
|
android:button="@drawable/checkbox"
|
||||||
|
android:contentDescription="@string/content_description_delete"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:layout_marginRight="5dp"
|
||||||
|
android:layout_width="30dp"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
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:background="@drawable/resizable_chat_bubble_outgoing"
|
android:background="@drawable/resizable_chat_bubble_outgoing"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
@ -41,15 +54,6 @@
|
||||||
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"
|
||||||
|
@ -70,7 +74,7 @@
|
||||||
android:id="@+id/progress_bar"
|
android:id="@+id/progress_bar"
|
||||||
android:paddingRight="5dp"
|
android:paddingRight="5dp"
|
||||||
style="@android:style/Widget.ProgressBar.Horizontal"
|
style="@android:style/Widget.ProgressBar.Horizontal"
|
||||||
android:layout_width="200dp"
|
android:layout_width="150dp"
|
||||||
android:layout_height="5dp"/>
|
android:layout_height="5dp"/>
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/cancel_upload"
|
android:id="@+id/cancel_upload"
|
||||||
|
@ -87,31 +91,24 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
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:paddingRight="5dp"
|
||||||
android:paddingTop="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"
|
||||||
android:adjustViewBounds="true" />
|
android:adjustViewBounds="true" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/inprogress"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:paddingRight="5dp"
|
||||||
|
android:layout_gravity="top|right"
|
||||||
|
android:layout_width="20dp"
|
||||||
|
android:layout_height="20dp"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<CheckBox
|
|
||||||
android:id="@+id/delete"
|
|
||||||
android:button="@drawable/checkbox"
|
|
||||||
android:contentDescription="@string/content_description_delete"
|
|
||||||
android:paddingRight="5dp"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
|
@ -26,10 +26,7 @@ import android.app.Dialog;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
|
|
||||||
import org.linphone.compatibility.Compatibility;
|
import org.linphone.compatibility.Compatibility;
|
||||||
|
@ -65,7 +62,6 @@ import android.os.Environment;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.InputType;
|
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -76,9 +72,12 @@ 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.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.CompoundButton;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Filter;
|
import android.widget.Filter;
|
||||||
import android.widget.Filterable;
|
import android.widget.Filterable;
|
||||||
|
@ -86,10 +85,10 @@ import android.widget.ImageView;
|
||||||
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.Spinner;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
|
||||||
public class ChatFragment extends Fragment implements OnClickListener, LinphoneChatMessage.LinphoneChatMessageListener {
|
public class ChatFragment extends Fragment implements OnClickListener, LinphoneChatMessage.LinphoneChatMessageListener {
|
||||||
private static ChatFragment instance;
|
private static ChatFragment instance;
|
||||||
|
|
||||||
|
@ -170,9 +169,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
remoteComposing = (TextView) view.findViewById(R.id.remoteComposing);
|
remoteComposing = (TextView) view.findViewById(R.id.remoteComposing);
|
||||||
remoteComposing.setVisibility(View.GONE);
|
remoteComposing.setVisibility(View.GONE);
|
||||||
|
|
||||||
uploadLayout = (RelativeLayout) view.findViewById(R.id.uploadLayout);
|
|
||||||
uploadLayout.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
cancel = (ImageView) view.findViewById(R.id.cancel);
|
cancel = (ImageView) view.findViewById(R.id.cancel);
|
||||||
cancel.setOnClickListener(this);
|
cancel.setOnClickListener(this);
|
||||||
|
|
||||||
|
@ -200,6 +196,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
searchContactField.setAdapter(new SearchContactsListAdapter(ContactsManager.getInstance().getAllContacts(), null, inflater));
|
searchContactField.setAdapter(new SearchContactsListAdapter(ContactsManager.getInstance().getAllContacts(), null, inflater));
|
||||||
edit.setVisibility(View.INVISIBLE);
|
edit.setVisibility(View.INVISIBLE);
|
||||||
startCall.setVisibility(View.INVISIBLE);
|
startCall.setVisibility(View.INVISIBLE);
|
||||||
|
contactName.setVisibility(View.INVISIBLE);
|
||||||
} else {
|
} else {
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
|
@ -244,22 +241,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelUpload = (ImageView) view.findViewById(R.id.cancelUpload);
|
|
||||||
cancelUpload.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (currentMessageInFileTransferUploadState != null) {
|
|
||||||
uploadLayout.setVisibility(View.GONE);
|
|
||||||
textLayout.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
//progressBar.setProgress(0);
|
|
||||||
currentMessageInFileTransferUploadState.cancelFileTransfer();
|
|
||||||
currentMessageInFileTransferUploadState = null;
|
|
||||||
LinphoneManager.getInstance().setUploadPendingFileMessage(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
mListener = new LinphoneCoreListenerBase(){
|
mListener = new LinphoneCoreListenerBase(){
|
||||||
@Override
|
@Override
|
||||||
public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) {
|
public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) {
|
||||||
|
@ -348,6 +329,29 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getNbItemsChecked(){
|
||||||
|
int size = messagesList.getAdapter().getCount();
|
||||||
|
int nb = 0;
|
||||||
|
for(int i=0; i<size; i++) {
|
||||||
|
if(messagesList.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class ChatMessageAdapter extends BaseAdapter {
|
class ChatMessageAdapter extends BaseAdapter {
|
||||||
LinphoneChatMessage[] history;
|
LinphoneChatMessage[] history;
|
||||||
Context context;
|
Context context;
|
||||||
|
@ -397,7 +401,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||||
LinphoneChatMessage message = history[position];
|
LinphoneChatMessage message = history[position];
|
||||||
|
|
||||||
BubbleChat bubble = new BubbleChat(context, message, contact);
|
BubbleChat bubble = new BubbleChat(context, message, contact);
|
||||||
|
@ -406,12 +410,44 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
registerForContextMenu(v);
|
registerForContextMenu(v);
|
||||||
RelativeLayout rlayout = new RelativeLayout(context);
|
RelativeLayout rlayout = new RelativeLayout(context);
|
||||||
|
|
||||||
|
CheckBox deleteChatBubble = (CheckBox) v.findViewById(R.id.delete);
|
||||||
|
|
||||||
if(isEditMode) {
|
if(isEditMode) {
|
||||||
v.findViewById(R.id.delete).setVisibility(View.VISIBLE);
|
Log.w("edit mode");
|
||||||
|
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, 30, 10);
|
layoutParams.setMargins(0, 10, 0, 10);
|
||||||
v.setLayoutParams(layoutParams);
|
v.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
|
deleteChatBubble.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||||
|
messagesList.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(messagesList.isItemChecked(position)) {
|
||||||
|
deleteChatBubble.setChecked(true);
|
||||||
|
} else {
|
||||||
|
deleteChatBubble.setChecked(false);
|
||||||
|
}
|
||||||
|
|
||||||
rlayout.addView(v);
|
rlayout.addView(v);
|
||||||
} else {
|
} else {
|
||||||
if(message.isOutgoing()){
|
if(message.isOutgoing()){
|
||||||
|
@ -432,9 +468,9 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispayMessageList() {
|
public void dispayMessageList() {
|
||||||
|
messagesList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
|
||||||
adapter = new ChatMessageAdapter(getActivity(), chatRoom.getHistory());
|
adapter = new ChatMessageAdapter(getActivity(), chatRoom.getHistory());
|
||||||
messagesList.setAdapter(adapter);
|
messagesList.setAdapter(adapter);
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayChatHeader(LinphoneAddress address) {
|
private void displayChatHeader(LinphoneAddress address) {
|
||||||
|
@ -592,8 +628,10 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
backToCall.setVisibility(View.VISIBLE);
|
backToCall.setVisibility(View.VISIBLE);
|
||||||
startCall.setVisibility(View.INVISIBLE);
|
startCall.setVisibility(View.INVISIBLE);
|
||||||
} else {
|
} else {
|
||||||
backToCall.setVisibility(View.INVISIBLE);
|
if(!newChatConversation) {
|
||||||
startCall.setVisibility(View.VISIBLE);
|
backToCall.setVisibility(View.INVISIBLE);
|
||||||
|
startCall.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LinphoneAddress lAddress;
|
LinphoneAddress lAddress;
|
||||||
|
@ -639,7 +677,10 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectAllList(boolean isSelectAll){
|
private void selectAllList(boolean isSelectAll){
|
||||||
//TODO
|
int size = messagesList.getAdapter().getCount();
|
||||||
|
for(int i=0; i<size; i++) {
|
||||||
|
messagesList.setItemChecked(i,isSelectAll);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void quitEditMode(){
|
public void quitEditMode(){
|
||||||
|
@ -649,10 +690,23 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
dispayMessageList();
|
dispayMessageList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeChats(){
|
||||||
|
int size = messagesList.getAdapter().getCount();
|
||||||
|
for(int i=0; i<size; i++) {
|
||||||
|
if(messagesList.isItemChecked(i)){
|
||||||
|
LinphoneChatMessage message = (LinphoneChatMessage) messagesList.getAdapter().getItem(i);
|
||||||
|
chatRoom.deleteMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
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;
|
||||||
|
@ -661,18 +715,19 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
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);
|
||||||
//selectAllList(true);
|
enabledDeleteButton(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);
|
||||||
//selectAllList(false);
|
enabledDeleteButton(false);
|
||||||
|
selectAllList(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id == R.id.cancel) {
|
if (id == R.id.cancel) {
|
||||||
Log.w("Cancel");
|
|
||||||
quitEditMode();
|
quitEditMode();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -685,7 +740,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
delete.setOnClickListener(new OnClickListener() {
|
delete.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
// removeCallLogs();
|
removeChats();
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
quitEditMode();
|
quitEditMode();
|
||||||
}
|
}
|
||||||
|
@ -704,8 +759,10 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
|
|
||||||
if(id == R.id.sendMessage){
|
if(id == R.id.sendMessage){
|
||||||
sendTextMessage();
|
sendTextMessage();
|
||||||
} else if (id == R.id.edit) {
|
}
|
||||||
topBar.setVisibility(View.GONE);
|
|
||||||
|
if (id == R.id.edit) {
|
||||||
|
topBar.setVisibility(View.INVISIBLE);
|
||||||
editList.setVisibility(View.VISIBLE);
|
editList.setVisibility(View.VISIBLE);
|
||||||
isEditMode = true;
|
isEditMode = true;
|
||||||
dispayMessageList();
|
dispayMessageList();
|
||||||
|
@ -998,7 +1055,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLinphoneChatMessageStateChanged(LinphoneChatMessage msg, State state) {
|
public void onLinphoneChatMessageStateChanged(LinphoneChatMessage msg, State state) {
|
||||||
Log.w("ICI");
|
|
||||||
if (state == State.FileTransferDone || state == State.FileTransferError) {
|
if (state == State.FileTransferDone || state == State.FileTransferError) {
|
||||||
currentMessageInFileTransferUploadState = null;
|
currentMessageInFileTransferUploadState = null;
|
||||||
}
|
}
|
||||||
|
@ -1018,23 +1074,25 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
//progressBar.setProgress(offset * 100 / total);
|
//progressBar.setProgress(offset * 100 / total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ContactAddress {
|
||||||
|
Contact contact;
|
||||||
|
String address;
|
||||||
|
|
||||||
|
private ContactAddress(Contact c, String a){
|
||||||
|
this.contact = c;
|
||||||
|
this.address = a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
contactsList2 = new HashMap<Contact, String>();
|
contacts = getContactsList();
|
||||||
//contacts = new ArrayList<ContactAddress>();
|
|
||||||
for(Contact con: ContactsManager.getInstance().getAllContacts()){
|
|
||||||
for(String numberOrAddress : con.getNumbersOrAddresses()){
|
|
||||||
contactsList2.put(con,numberOrAddress);
|
|
||||||
//contacts.add(new ContactAddress(con,numberOrAddress));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1045,27 +1103,25 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
FilterResults results) {
|
FilterResults results) {
|
||||||
|
|
||||||
if (results.count > 0) {
|
if (results.count > 0) {
|
||||||
//contacts.clear();
|
contacts.clear();
|
||||||
contactsList2.clear();
|
contacts = (List<ContactAddress>) results.values;
|
||||||
contactsList2 = ( HashMap<Contact, String>) results.values;
|
|
||||||
//contacts = (List<ContactAddress>) results.values;
|
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
} else {;
|
} else {;
|
||||||
//contacts.clear();
|
contacts.clear();
|
||||||
contactsList2.clear();
|
contacts = getContactsList();
|
||||||
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 (HashMap.Entry<Contact, String> entry : contactsList2.entrySet()) {
|
for (ContactAddress c : contacts) {
|
||||||
if (entry.getKey().getName().toLowerCase().startsWith(constraint.toString()) || entry.getValue().startsWith(constraint.toString())) {
|
String address = c.address;
|
||||||
result.put(entry.getKey(),entry.getValue());
|
if(address.startsWith("sip")) address.substring(4);
|
||||||
|
if (c.contact.getName().toLowerCase().startsWith(constraint.toString()) || address.toLowerCase().startsWith(constraint.toString())) {
|
||||||
|
result.add(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1077,29 +1133,26 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<Contact, String> getContactsList(){
|
public List<ContactAddress>getContactsList(){
|
||||||
HashMap<Contact, String> contacts = new HashMap<Contact, String>();
|
List<ContactAddress> list = 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.put(con, numberOrAddress);
|
list.add(new ContactAddress(con, numberOrAddress));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return contacts;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return contactsList2.size();
|
return contacts.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Contact getItem(int position) {
|
public ContactAddress getItem(int position) {
|
||||||
if (contactsList2 == null || position >= contactsList2.size()) {
|
if (contacts == null || position >= contacts.size()) {
|
||||||
contactsList2 = getContactsList();
|
contacts = getContactsList();
|
||||||
Contact[] s = (Contact[]) contactsList2.keySet().toArray();
|
return contacts.get(position);
|
||||||
return s[position];
|
|
||||||
} else {
|
} else {
|
||||||
Object[] s = (Object[]) contactsList2.keySet().toArray();
|
return contacts.get(position);
|
||||||
return (Contact) s[position];
|
|
||||||
//return contactsList2.get();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1109,7 +1162,7 @@ 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;
|
||||||
Contact contact;
|
ContactAddress contact;
|
||||||
do {
|
do {
|
||||||
contact = getItem(position);
|
contact = getItem(position);
|
||||||
} while (contact == null);
|
} while (contact == null);
|
||||||
|
@ -1120,14 +1173,14 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
view = mInflater.inflate(R.layout.search_contact_cell, parent, false);
|
view = mInflater.inflate(R.layout.search_contact_cell, parent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String a = contact.address;
|
||||||
|
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(contact.getName());
|
name.setText(c.getName());
|
||||||
|
|
||||||
final TextView address = (TextView) view.findViewById(R.id.contact_address);
|
final TextView address = (TextView) view.findViewById(R.id.contact_address);
|
||||||
address.setText(contactsList2.get(contact));
|
address.setText(a);
|
||||||
|
|
||||||
final String a = contactsList2.get(contact);
|
|
||||||
final Contact c = contact;
|
|
||||||
|
|
||||||
view.setOnClickListener(new OnClickListener() {
|
view.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class ChatStorage {
|
||||||
|
|
||||||
private ChatStorage(Context c) {
|
private ChatStorage(Context c) {
|
||||||
context = c;
|
context = c;
|
||||||
boolean useLinphoneStorage = false;
|
boolean useLinphoneStorage = true;
|
||||||
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();
|
||||||
|
@ -378,7 +378,6 @@ public class ChatStorage {
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,10 +74,11 @@ import android.widget.TextView;
|
||||||
public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListener {
|
public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListener {
|
||||||
private static final HashMap<String, Integer> emoticons = new HashMap<String, Integer>();
|
private static final HashMap<String, Integer> emoticons = new HashMap<String, Integer>();
|
||||||
|
|
||||||
private LinearLayout view;
|
private View view;
|
||||||
private ImageView statusView, contactPicture;
|
private ImageView statusView, contactPicture;
|
||||||
private LinphoneChatMessage nativeMessage;
|
private LinphoneChatMessage nativeMessage;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
private Button cancelUpload, acceptDownload;
|
||||||
private static final int SIZE_MAX = 512;
|
private static final int SIZE_MAX = 512;
|
||||||
private ProgressBar progressBar, inprogress;
|
private ProgressBar progressBar, inprogress;
|
||||||
private Bitmap defaultBitmap;
|
private Bitmap defaultBitmap;
|
||||||
|
@ -91,9 +92,9 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
|
||||||
mContext = context;
|
mContext = context;
|
||||||
|
|
||||||
if (message.isOutgoing()) {
|
if (message.isOutgoing()) {
|
||||||
view = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.chat_bubble_outgoing, null);
|
view = LayoutInflater.from(context).inflate(R.layout.chat_bubble_outgoing, null);
|
||||||
} else {
|
} else {
|
||||||
view = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.chat_bubble_incoming, null);
|
view = LayoutInflater.from(context).inflate(R.layout.chat_bubble_incoming, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.chat_picture_over);
|
defaultBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.chat_picture_over);
|
||||||
|
@ -119,12 +120,29 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(nativeMessage.isOutgoing()){
|
||||||
|
cancelUpload = (Button) view.findViewById(R.id.cancel_upload);
|
||||||
|
cancelUpload.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (LinphoneManager.getInstance().getMessageUploadPending() != null) {
|
||||||
|
progressBar.setVisibility(View.GONE);
|
||||||
|
//tex.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
progressBar.setProgress(0);
|
||||||
|
nativeMessage.cancelFileTransfer();
|
||||||
|
LinphoneManager.getInstance().setUploadPendingFileMessage(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
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){
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
nativeMessage.setListener(LinphoneManager.getInstance());
|
LinphoneManager.addListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (externalBodyUrl != null || fileTransferContent != null ) {
|
if (externalBodyUrl != null || fileTransferContent != null ) {
|
||||||
|
|
Loading…
Reference in a new issue