Browse Source

聊天批量删除

gongpm 10 years ago
parent
commit
22cb0934df

+ 21 - 4
WeiChat/src/main/java/com/sk/weichat/db/dao/ChatMessageDao.java

@@ -9,7 +9,6 @@ import com.j256.ormlite.dao.Dao;
 import com.j256.ormlite.stmt.QueryBuilder;
 import com.j256.ormlite.stmt.UpdateBuilder;
 import com.j256.ormlite.table.DatabaseTableConfig;
-import com.j256.ormlite.table.TableUtils;
 import com.sk.weichat.BuildConfig;
 import com.sk.weichat.MyApplication;
 import com.sk.weichat.bean.message.ChatMessage;
@@ -19,6 +18,7 @@ import com.sk.weichat.db.UnlimitDaoManager;
 import com.sk.weichat.util.TimeUtils;
 
 import java.sql.SQLException;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -60,7 +60,7 @@ public class ChatMessageDao {
         if (mDaoMap.containsKey(tableName)) {
             return mDaoMap.get(tableName);
         }
-        Log.i("table","tableName="+tableName);
+        Log.i("table", "tableName=" + tableName);
         Dao<ChatMessage, Integer> dao = null;
         try {
             DatabaseTableConfig<ChatMessage> config = DatabaseTableConfigUtil.fromClass(mHelper.getConnectionSource(), ChatMessage.class);
@@ -70,7 +70,7 @@ public class ChatMessageDao {
             dao = UnlimitDaoManager.createDao(mHelper.getConnectionSource(), config);
         } catch (SQLException e) {
             e.printStackTrace();
-            Log.i("table", "create table has an exception! 消息表" );
+            Log.i("table", "create table has an exception! 消息表");
         }
         if (dao != null)
             mDaoMap.put(tableName, dao);
@@ -94,9 +94,25 @@ public class ChatMessageDao {
         return false;
     }
 
+    public boolean deleteSingleChatMessage(String ownerId, String friendId, ArrayList<ChatMessage> messages) {
+        Dao<ChatMessage, Integer> dao = getDao(ownerId, friendId);
+        if (dao == null) {
+            return false;
+        }
+        try {
+            List<ChatMessage> chatMessages = dao.queryForEq("packetId", messages.get(0).getPacketId());
+            if (chatMessages != null && chatMessages.size() > 0) {
+                dao.delete(messages);
+                return true;
+            }
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
+
     /**
      * 保存一条新的聊天记录
-     *
      */
     public boolean saveNewSingleChatMessage(String ownerId, String friendId, ChatMessage message) {
         Dao<ChatMessage, Integer> dao = getDao(ownerId, friendId);
@@ -204,6 +220,7 @@ public class ChatMessageDao {
 
     /**
      * OK 取与某人的聊天记录
+     *
      * @param mMinId   大于此ID
      * @param pageSize 查询几条数据
      * @return

+ 85 - 25
WeiChat/src/main/java/com/sk/weichat/ui/message/ChatActivity.java

@@ -20,6 +20,8 @@ import android.util.Log;
 import android.view.KeyEvent;
 import android.view.Menu;
 import android.view.MenuItem;
+import android.view.View;
+import android.widget.LinearLayout;
 import android.widget.TextView;
 import android.widget.Toast;
 
@@ -90,6 +92,8 @@ public class ChatActivity extends ActionBackActivity
 
     @SuppressWarnings("unused")
     private TextView mAuthStateTipTv;
+    private TextView tv_none;
+    private LinearLayout botton_ll;
     private ChatContentView mChatContentView;
     private ChatBottomView mChatBottomView;
     private AudioManager mAudioManager = null;
@@ -102,7 +106,7 @@ public class ChatActivity extends ActionBackActivity
         public void handleMessage(Message msg) {
             switch (msg.what) {
                 case 5:
-                       Log.i("push",msg.getData().getString("result"));
+                    Log.i("push", msg.getData().getString("result"));
                     break;
             }
         }
@@ -117,6 +121,7 @@ public class ChatActivity extends ActionBackActivity
     private ChatMessage instantMessage;//转发消息传过来的message
     private String instantFilePath;//转发文件传过来的path
     private FastVolley mFastVolley;
+    private TextView tv_delete;
 
 
     protected void onCreate(Bundle savedInstanceState) {
@@ -156,21 +161,32 @@ public class ChatActivity extends ActionBackActivity
         @Override
         public void onReceive(Context context, Intent intent) {
             Log.d("wang", "接收到广播");
-            if (mChatContentView != null) {
-                int position = intent.getIntExtra(Constants.CHAT_REMOVE_MESSAGE_POSITION, 10000);
-                if (position == 10000) {
-                    return;
+            if (intent.getIntExtra(Constants.CHAT_REMOVE_MESSAGE_FALG, 10000) == 1) {//当广播为删除一个信息时候
+                if (mChatContentView != null) {
+                    int position = intent.getIntExtra(Constants.CHAT_REMOVE_MESSAGE_POSITION, 10000);
+                    if (position == 10000) {
+                        return;
+                    }
+                    ChatMessage message = mChatMessages.get(position);
+                    boolean isSuccess = ChatMessageDao.getInstance().deleteSingleChatMessage(mLoginUserId, mFriend.getUserId(), message);
+                    if (isSuccess) {
+
+                        mChatMessages.remove(position);
+                        mChatContentView.notifyDataSetInvalidated(true);
+                        MsgBroadcast.broadcastMsgUiUpdate(mContext);
+                    } else {
+                        Toast.makeText(mContext, "删除失败", Toast.LENGTH_SHORT).show();
+                    }
                 }
-                ChatMessage message = mChatMessages.get(position);
-                boolean isSuccess = ChatMessageDao.getInstance().deleteSingleChatMessage(mLoginUserId, mFriend.getUserId(), message);
-                if (isSuccess) {
-
-                    mChatMessages.remove(position);
-                    mChatContentView.notifyDataSetInvalidated(true);
-                    MsgBroadcast.broadcastMsgUiUpdate(mContext);
-                } else {
-                    Toast.makeText(mContext, "删除失败", Toast.LENGTH_SHORT).show();
+            } else {//当广播为删除一个信息时候
+                Log.i("gongpengming", "点击更多时候接受到广播");
+                if (botton_ll != null) {
+                    botton_ll.setVisibility(View.VISIBLE);
                 }
+                if (mChatBottomView != null) {
+                    mChatBottomView.setVisibility(View.GONE);
+                }
+
             }
 
         }
@@ -208,9 +224,10 @@ public class ChatActivity extends ActionBackActivity
         mAuthStateTipTv = (TextView) findViewById(R.id.auth_state_tip);
         mChatContentView = (ChatContentView) findViewById(R.id.chat_content_view);
         mChatContentView.setToUserId(mFriend.getUserId());
-
+        tv_delete = (TextView) findViewById(R.id.tv_delete);
+        tv_none = (TextView) findViewById(R.id.tv_none);
         mChatContentView.setData(mChatMessages);
-
+        botton_ll= (LinearLayout) findViewById(R.id.botton_ll);
         mChatContentView.setMessageEventListener(this);
         mChatContentView.setRefreshListener(new PullDownListView.RefreshingListener() {
             @Override
@@ -220,6 +237,49 @@ public class ChatActivity extends ActionBackActivity
         });
         mChatBottomView = (ChatBottomView) findViewById(R.id.chat_bottom_view);
         mChatBottomView.setChatBottomListener(this);
+        tv_none.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                if (botton_ll != null) {
+                    botton_ll.setVisibility(View.GONE);
+                }
+                if (mChatBottomView != null) {
+                    mChatBottomView.setVisibility(View.VISIBLE);
+                }
+                mChatContentView.setShowCB(false);
+                mChatContentView.notifyDataSetChanged();
+            }
+        });
+        tv_delete.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                //TODO 确定删除选择聊天记录
+                if (botton_ll != null) {
+                    botton_ll.setVisibility(View.GONE);
+                }
+                if (mChatBottomView != null) {
+                    mChatBottomView.setVisibility(View.VISIBLE);
+                }
+                //点击删除记录时候
+                onDeleteMore();
+            }
+        });
+    }
+
+    private void onDeleteMore() {
+        List<Integer> ints = mChatContentView.getInts();
+        ArrayList<ChatMessage> messages = new ArrayList<>();
+        for (int i = 0; i < ints.size(); i++) {
+            Log.i("gongpengming", "当前i=" + i);
+            messages.add(mChatMessages.get(ints.get(i)));
+        }
+        boolean isSuccess = ChatMessageDao.getInstance().deleteSingleChatMessage(mLoginUserId, mFriend.getUserId(), messages);
+        if (isSuccess) {
+            mChatMessages.removeAll(messages);
+            mChatContentView.notifyDataSetInvalidated(true);
+            MsgBroadcast.broadcastMsgUiUpdate(mContext);
+//            mChatContentView.notifyDataSetChanged();
+        }
     }
 
     private void doBack() {
@@ -251,8 +311,8 @@ public class ChatActivity extends ActionBackActivity
     protected void onDestroy() {
         super.onDestroy();
         mChatBottomView.recordCancel();
-        if (mFastVolley!=null )
-        mFastVolley.cancelAll(FRIEND);
+        if (mFastVolley != null)
+            mFastVolley.cancelAll(FRIEND);
         ListenerManager.getInstance().removeChatMessageListener(this);
         unbindService(mConnection);
         unregisterReceiver(broadcastReceiver);
@@ -448,7 +508,7 @@ public class ChatActivity extends ActionBackActivity
                 Log.d("roamer", "sendChatMessage....");
                 mService.sendChatMessage(mFriend.getUserId(), message);
             }
-        }  else {
+        } else {
             Log.d("roamer", "sendChatMessage");
             mService.sendChatMessage(mFriend.getUserId(), message);
             //进行百度推送
@@ -623,7 +683,7 @@ public class ChatActivity extends ActionBackActivity
 
     //TODO 发送卡片
     public void sendCard(String ObjectId) {
-            this.objectId = ObjectId;
+        this.objectId = ObjectId;
 //        ChatMessage message = new ChatMessage();
 //        message.setType(XmppMessage.TYPE_CARD);
 //        message.setFromUserName(mLoginNickName);
@@ -766,7 +826,7 @@ public class ChatActivity extends ActionBackActivity
                     }
                 }
                 mChatMessages.add(0, message);
-                Log.i("table","cardId="+message.getCardId());
+                Log.i("table", "cardId=" + message.getCardId());
             }
         }
 
@@ -880,7 +940,7 @@ public class ChatActivity extends ActionBackActivity
             mChatContentView.notifyDataSetInvalidated(true);
 //            message.setContent(MyApplication.getInstance().mLoginUser.getSex() + "");// 性别
 //            // 0表示女,1表示男
-           // sendMessage(message);
+            // sendMessage(message);
         }
     }
 
@@ -907,17 +967,17 @@ public class ChatActivity extends ActionBackActivity
                 boolean success = Result.defaultParser(mContext, result, true);
                 if (success && result.getData() != null) {
                     User mUser = result.getData();
-                    message.setContent(mUser.getSex()+ "");//   成功时候显示性别
+                    message.setContent(mUser.getSex() + "");//   成功时候显示性别
                     // 0表示女,1表示男
                     sendMessage(message);
                 } else {
-                    message.setContent(-1+ "");//   当失败时候显示保密
+                    message.setContent(-1 + "");//   当失败时候显示保密
                     // 0表示女,1表示男
                     sendMessage(message);
                 }
             }
         }, User.class, params);
-        mFastVolley.addDefaultRequest(FRIEND , request);
+        mFastVolley.addDefaultRequest(FRIEND, request);
     }
 
 

+ 4 - 1
WeiChat/src/main/java/com/sk/weichat/ui/message/SelectMessageWindow.java

@@ -15,7 +15,7 @@ import com.sk.weichat.R;
 import com.sk.weichat.bean.message.XmppMessage;
 
 public class SelectMessageWindow extends PopupWindow {
-	private Button mCopy, mInstant, mCancle, mDelete;
+	private Button mCopy, mInstant, mCancle, mDelete,mMore;
 	private View mMenuView;
 	int type;
 
@@ -47,6 +47,8 @@ public class SelectMessageWindow extends PopupWindow {
 		mInstant = (Button) mMenuView.findViewById(R.id.btn_instant);
 		mCancle = (Button) mMenuView.findViewById(R.id.btn_cancle);
 		mDelete = (Button) mMenuView.findViewById(R.id.btn_delete);
+		mMore = (Button) mMenuView.findViewById(R.id.btn_more);
+
 		this.type = type;
 		hideButton();
 		// 取消按钮
@@ -60,6 +62,7 @@ public class SelectMessageWindow extends PopupWindow {
 		mInstant.setOnClickListener(itemsOnClick);
 		mCancle.setOnClickListener(itemsOnClick);
 		mDelete.setOnClickListener(itemsOnClick);
+		mMore.setOnClickListener(itemsOnClick);
 		// 设置SelectPicPopupWindow的View
 		this.setContentView(mMenuView);
 		// 设置SelectPicPopupWindow弹出窗体的宽

+ 1 - 1
WeiChat/src/main/java/com/sk/weichat/util/Constants.java

@@ -6,7 +6,7 @@ public class Constants {
     public static String INSTANT_SEND="instant_send";//转发
     public static String CHAT_MESSAGE_DELETE_ACTION="chat_message_delete";
     public static String CHAT_MESSAGE_DELETE_FRIENDID="chat_message_delete_friendid";//删除消息要带过去的朋友id
-
+    public static String CHAT_REMOVE_MESSAGE_FALG="CHAT_REMOVE_MESSAGE_FALG";
     public static String CHAT_REMOVE_MESSAGE_POSITION="CHAT_REMOVE_MESSAGE_POSITION";
     public static String ONRECORDSTART="onrecordstart";
     public static String GROUP_JOIN_NOTICE="group_join_notice";//加入新群的通知

+ 59 - 9
WeiChat/src/main/java/com/sk/weichat/view/ChatContentView.java

@@ -26,6 +26,8 @@ import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.BaseAdapter;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
 import android.widget.FrameLayout;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
@@ -69,6 +71,7 @@ import com.sk.weichat.util.downloadTask;
 import com.sk.weichat.xmpp.listener.ChatMessageListener;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.List;
 
 import pl.droidsonroids.gif.GifImageView;
@@ -77,11 +80,11 @@ import pl.droidsonroids.gif.GifImageView;
 public class ChatContentView extends PullDownListView implements OnMediaStateChange {
     private static final String TAG = ChatContentView.class.getSimpleName();
     private Context mContext;
-
+    private ArrayList<Integer> ints;
     /* 根据mLoginUserId和mToUserId 唯一确定一张表 */
     private String mLoginUserId;
     private String mToUserId;
-
+    private boolean isShowCB = false;
     private List<ChatMessage> mChatMessages;
     private MessageEventListener mMessageEventListener;
     private int mDelayTime = 0;
@@ -107,6 +110,23 @@ public class ChatContentView extends PullDownListView implements OnMediaStateCha
         init(context);
     }
 
+    public boolean isShowCB() {
+        return isShowCB;
+    }
+
+    public void setShowCB(boolean showCB) {
+        isShowCB = showCB;
+    }
+
+    public ArrayList<Integer> getInts() {
+        isShowCB=false;
+        return ints;
+    }
+
+    public void setInts(ArrayList<Integer> ints) {
+        this.ints = ints;
+    }
+
     public ChatContentView(Context context, AttributeSet attrs) {
         super(context, attrs);
         init(context);
@@ -331,7 +351,7 @@ public class ChatContentView extends PullDownListView implements OnMediaStateCha
         }
 
         @SuppressLint("NewApi")
-        public View getView(int position, View convertView, ViewGroup parent) {
+        public View getView(final int position, View convertView, ViewGroup parent) {
             final int viewType = getItemViewType(position);
             SystemViewHolder systemViewHolder = null;
             ContentViewHolder contentViewHolder = null;
@@ -476,6 +496,7 @@ public class ChatContentView extends PullDownListView implements OnMediaStateCha
                 if (systemViewHolder != null) {
                     convertView.setTag(R.id.tag_key_list_item_view, systemViewHolder);
                 } else if (contentViewHolder != null) {
+                    contentViewHolder.cb_choose = (CheckBox) convertView.findViewById(R.id.cb_remove);
                     contentViewHolder.time_tv = (TextView) convertView.findViewById(R.id.time_tv);
                     contentViewHolder.chat_head_iv = (ImageView) convertView.findViewById(R.id.chat_head_iv);
                     contentViewHolder.nick_name = (TextView) convertView.findViewById(R.id.nick_name);
@@ -496,8 +517,21 @@ public class ChatContentView extends PullDownListView implements OnMediaStateCha
                 systemViewHolder.chat_content_tv.setText(message.getContent());
                 return convertView;
             }
-
-			/* 是否显示日期 */
+            if (isShowCB) {    //点击更多时候
+                contentViewHolder.cb_choose.setVisibility(VISIBLE);
+                contentViewHolder.cb_choose.setSelected(false);
+                contentViewHolder.cb_choose.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+                    @Override
+                    public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
+                        if (b) {
+                            ints.add(position);
+                        }
+                    }
+                });
+            }else{
+                contentViewHolder.cb_choose.setVisibility(GONE);
+            }
+            /* 是否显示日期 */
             boolean showTime = true;
             if (position >= 1) {
                 ChatMessage prevMessage = mChatMessages.get(position - 1);
@@ -1081,8 +1115,8 @@ public class ChatContentView extends PullDownListView implements OnMediaStateCha
 
         //读取下载线程数,如果为空,则单线程下载
         int downloadTN = 2;
-	/*//如果下载文件名为空则获取Url尾为文件名
-	int fileNameStart = url.lastIndexOf("/");
+    /*//如果下载文件名为空则获取Url尾为文件名
+    int fileNameStart = url.lastIndexOf("/");
 	String fileName =  url.substring(fileNameStart);*/
         //启动文件下载线程
         new downloadTask(url, Integer
@@ -1122,14 +1156,30 @@ public class ChatContentView extends PullDownListView implements OnMediaStateCha
                 case R.id.btn_delete:// 删除
                     Toast.makeText(mContext, "已成功删除", Toast.LENGTH_SHORT).show();
               /* if(mChatMessages!=null){
-            	   mChatMessages.remove(position);
+                   mChatMessages.remove(position);
                }*/
                     Intent broadcast = new Intent(Constants.CHAT_MESSAGE_DELETE_ACTION);//发送广播去界面更新
+                    broadcast.putExtra(Constants.CHAT_REMOVE_MESSAGE_FALG, 1);
                     broadcast.putExtra(Constants.CHAT_REMOVE_MESSAGE_POSITION, position);
                     mContext.sendBroadcast(broadcast);
                     break;
                 case R.id.btn_cancle:// 取消
 
+                    break;
+                case R.id.btn_more:// 更多
+                    //TODO 点击更多时候显示选择按钮
+                    if (ints == null) {
+                        ints = new ArrayList<>();
+                    }
+                    ints.clear();
+                    if (mChatContentAdapter != null) {
+                        isShowCB = true;
+                        mChatContentAdapter.notifyDataSetChanged();
+                    }
+                    Intent broadcast1 = new Intent(Constants.CHAT_MESSAGE_DELETE_ACTION);//发送广播去界面更新
+                    broadcast1.putExtra(Constants.CHAT_REMOVE_MESSAGE_FALG, 2);
+                    mContext.sendBroadcast(broadcast1);
+                    Log.i("gongpengming","点击更多");
                     break;
                 default:
                     break;
@@ -1352,7 +1402,7 @@ public class ChatContentView extends PullDownListView implements OnMediaStateCha
     abstract class ContentViewHolder {
         TextView time_tv;
         ImageView chat_head_iv;
-
+        CheckBox cb_choose;
         ProgressBar progress;// 只有From的item有
         ImageView failed_img_view;// 只有From的item有
         TextView nick_name;

+ 50 - 14
WeiChat/src/main/res/layout/chat.xml

@@ -2,14 +2,14 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/root_view"
     android:layout_width="fill_parent"
-    android:orientation="vertical"
     android:layout_height="fill_parent"
-    android:background="@drawable/bg_main" >
-   
+    android:background="@drawable/bg_main"
+    android:orientation="vertical">
+
     <RelativeLayout
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
-        android:orientation="vertical" >
+        android:orientation="vertical">
 
         <TextView
             android:id="@+id/auth_state_tip"
@@ -25,22 +25,58 @@
             android:id="@+id/chat_content_view"
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"
-            android:background="@drawable/bg_main"
-            android:layout_above="@+id/chat_bottom_view"
+            android:layout_above="@+id/bottom_fl"
             android:layout_below="@+id/auth_state_tip"
+            android:background="@drawable/bg_main"
             android:cacheColorHint="#00000000"
             android:divider="#00000000"
             android:fadingEdge="none" />
 
-        <com.sk.weichat.view.ChatBottomView
-            android:id="@+id/chat_bottom_view"
-            android:layout_width="fill_parent"
+        <FrameLayout
+            android:id="@+id/bottom_fl"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_alignParentBottom="true"
-            android:cacheColorHint="#6c7eb7"
-            android:divider="#6c7eb7"
-            android:background="@color/bg_main"
-            android:fadingEdge="none" />
+            android:layout_alignParentBottom="true">
+
+            <com.sk.weichat.view.ChatBottomView
+                android:id="@+id/chat_bottom_view"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:background="@color/bg_main"
+                android:cacheColorHint="#6c7eb7"
+                android:divider="#6c7eb7"
+                android:fadingEdge="none" />
+
+            <LinearLayout
+                android:id="@+id/botton_ll"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:visibility="gone"
+                android:orientation="horizontal">
+
+                <TextView
+                    android:id="@+id/tv_delete"
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    android:background="@color/item_color1"
+                    android:gravity="center_horizontal"
+                    android:text="删除记录"
+                    android:textSize="30sp"
+                    />
+                <TextView
+                    android:id="@+id/tv_none"
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    android:background="@color/item_color1"
+                    android:gravity="center_horizontal"
+                    android:text="取消"
+                    android:textSize="30sp"
+                    />
+            </LinearLayout>
+
+        </FrameLayout>
     </RelativeLayout>
 
 </LinearLayout>

+ 14 - 4
WeiChat/src/main/res/layout/chat_from_item_card.xml

@@ -1,18 +1,28 @@
 <?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:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:orientation="vertical" >
+    >
 
     <TextView
+        android:layout_centerHorizontal="true"
         android:id="@+id/time_tv"
         style="@style/ChattingUISystem"
         android:layout_gravity="center_horizontal"
         android:layout_marginTop="5dp"
         android:background="@drawable/chatsystem_bg"
         android:gravity="center" />
-
+    <CheckBox
+        android:id="@+id/cb_remove"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentRight="true"
+        android:layout_below="@+id/time_tv"
+        android:layout_marginTop="15dp"
+        android:visibility="gone"/>
     <RelativeLayout
+        android:layout_below="@+id/time_tv"
+        android:layout_toLeftOf="@+id/cb_remove"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:gravity="right"
@@ -118,4 +128,4 @@
         </RelativeLayout>
     </RelativeLayout>
 
-</LinearLayout>
+</RelativeLayout>

+ 14 - 4
WeiChat/src/main/res/layout/chat_from_item_file.xml

@@ -1,18 +1,28 @@
 <?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:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:orientation="vertical" >
+ >
 
     <TextView
         android:id="@+id/time_tv"
         style="@style/ChattingUISystem"
         android:layout_gravity="center_horizontal"
         android:layout_marginTop="5dp"
+		android:layout_centerHorizontal="true"
         android:background="@drawable/chatsystem_bg"
         android:gravity="center" />
-
+	<CheckBox
+		android:id="@+id/cb_remove"
+		android:layout_width="wrap_content"
+		android:layout_height="wrap_content"
+		android:layout_alignParentRight="true"
+		android:layout_below="@+id/time_tv"
+		android:layout_marginTop="15dp"
+		android:visibility="gone"/>
     <RelativeLayout
+		android:layout_below="@+id/time_tv"
+		android:layout_toLeftOf="@+id/cb_remove"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:gravity="right"
@@ -103,4 +113,4 @@
         </RelativeLayout>
     </RelativeLayout>
 
-</LinearLayout>
+</RelativeLayout>

+ 17 - 6
WeiChat/src/main/res/layout/chat_from_item_gif.xml

@@ -1,23 +1,34 @@
 <?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:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:orientation="vertical" >
+    android:layout_height="wrap_content">
 
     <TextView
         android:id="@+id/time_tv"
         style="@style/ChattingUISystem"
+        android:layout_centerHorizontal="true"
         android:layout_gravity="center_horizontal"
         android:layout_marginTop="5dp"
         android:background="@drawable/chatsystem_bg"
         android:gravity="center" />
 
+    <CheckBox
+        android:id="@+id/cb_remove"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentRight="true"
+        android:layout_below="@+id/time_tv"
+        android:layout_marginTop="15dp"
+        android:visibility="gone" />
+
     <RelativeLayout
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
+        android:layout_below="@+id/time_tv"
+        android:layout_toLeftOf="@+id/cb_remove"
         android:gravity="right"
         android:orientation="horizontal"
-        android:padding="3dip" >
+        android:padding="3dip">
 
         <ImageView
             android:id="@+id/chat_head_iv"
@@ -40,7 +51,7 @@
             android:layout_width="275dip"
             android:layout_height="wrap_content"
             android:layout_below="@+id/nick_name"
-            android:layout_toLeftOf="@+id/chat_head_iv" >
+            android:layout_toLeftOf="@+id/chat_head_iv">
 
             <pl.droidsonroids.gif.GifImageView
                 android:id="@+id/chat_from_gif_view"
@@ -78,4 +89,4 @@
         </RelativeLayout>
     </RelativeLayout>
 
-</LinearLayout>
+</RelativeLayout>

+ 17 - 6
WeiChat/src/main/res/layout/chat_from_item_image.xml

@@ -1,31 +1,42 @@
 <?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:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:orientation="vertical">
+    android:layout_height="wrap_content">
 
     <TextView
         android:id="@+id/time_tv"
         style="@style/ChattingUISystem"
-        android:layout_gravity="center_horizontal"
+        android:layout_centerHorizontal="true"
         android:layout_marginTop="5dp"
         android:background="@drawable/chatsystem_bg"
         android:gravity="center" />
 
+    <CheckBox
+        android:id="@+id/cb_remove"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentRight="true"
+        android:layout_below="@+id/time_tv"
+        android:layout_marginTop="15dp"
+        android:visibility="gone" />
+
     <RelativeLayout
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
+        android:layout_below="@+id/time_tv"
+        android:layout_toLeftOf="@+id/cb_remove"
         android:gravity="right"
         android:orientation="horizontal"
         android:padding="3dip">
 
+
         <com.sk.weichat.view.RoundCornerImageView
             android:id="@+id/chat_head_iv"
             android:layout_width="48dip"
             android:layout_height="48dip"
-            android:scaleType="centerCrop"
             android:layout_alignParentRight="true"
             android:contentDescription="@string/app_name"
+            android:scaleType="centerCrop"
             android:src="@drawable/avatar_normal" />
 
         <TextView
@@ -97,4 +108,4 @@
         </RelativeLayout>
     </RelativeLayout>
 
-</LinearLayout>
+</RelativeLayout>

+ 14 - 4
WeiChat/src/main/res/layout/chat_from_item_location.xml

@@ -1,18 +1,28 @@
 <?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:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:orientation="vertical" >
+    >
 
     <TextView
         android:id="@+id/time_tv"
         style="@style/ChattingUISystem"
         android:layout_gravity="center_horizontal"
         android:layout_marginTop="5dp"
+        android:layout_centerHorizontal="true"
         android:background="@drawable/chatsystem_bg"
         android:gravity="center" />
-
+    <CheckBox
+        android:id="@+id/cb_remove"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentRight="true"
+        android:layout_below="@+id/time_tv"
+        android:layout_marginTop="15dp"
+        android:visibility="gone"/>
     <RelativeLayout
+        android:layout_below="@+id/time_tv"
+        android:layout_toLeftOf="@+id/cb_remove"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:gravity="right"
@@ -98,4 +108,4 @@
         </RelativeLayout>
     </RelativeLayout>
 
-</LinearLayout>
+</RelativeLayout>

+ 18 - 10
WeiChat/src/main/res/layout/chat_from_item_text.xml

@@ -1,23 +1,31 @@
 <?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:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:orientation="vertical" >
+    android:layout_height="wrap_content">
 
     <TextView
         android:id="@+id/time_tv"
         style="@style/ChattingUISystem"
-        android:layout_gravity="center_horizontal"
+        android:layout_centerHorizontal="true"
         android:layout_marginTop="5dp"
         android:background="@drawable/chatsystem_bg"
         android:gravity="center" />
-
+    <CheckBox
+        android:id="@+id/cb_remove"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentRight="true"
+        android:layout_below="@+id/time_tv"
+        android:layout_marginTop="15dp"
+        android:visibility="gone" />
     <RelativeLayout
+        android:layout_toLeftOf="@+id/cb_remove"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
+        android:layout_below="@+id/time_tv"
         android:gravity="right"
         android:orientation="horizontal"
-        android:padding="3dip" >
+        android:padding="3dip">
 
         <ImageView
             android:id="@+id/chat_head_iv"
@@ -40,7 +48,7 @@
             android:layout_width="275dip"
             android:layout_height="wrap_content"
             android:layout_below="@+id/nick_name"
-            android:layout_toLeftOf="@+id/chat_head_iv" >
+            android:layout_toLeftOf="@+id/chat_head_iv">
 
             <LinearLayout
                 android:id="@+id/chat_from_warp_view"
@@ -52,16 +60,16 @@
                 android:clickable="true"
                 android:focusable="true"
                 android:gravity="center"
-                android:orientation="vertical" >
+                android:orientation="vertical">
 
                 <TextView
-                    android:textColor="@color/text_main"
                     android:id="@+id/chat_from_text"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:layout_gravity="center"
                     android:maxWidth="210dp"
                     android:padding="6dp"
+                    android:textColor="@color/text_main"
                     android:textSize="18sp" />
             </LinearLayout>
 
@@ -87,4 +95,4 @@
         </RelativeLayout>
     </RelativeLayout>
 
-</LinearLayout>
+</RelativeLayout>

+ 14 - 4
WeiChat/src/main/res/layout/chat_from_item_video.xml

@@ -1,18 +1,28 @@
 <?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:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:orientation="vertical" >
+      >
 
     <TextView
         android:id="@+id/time_tv"
         style="@style/ChattingUISystem"
+        android:layout_centerHorizontal="true"
         android:layout_gravity="center_horizontal"
         android:layout_marginTop="5dp"
         android:background="@drawable/chatsystem_bg"
         android:gravity="center" />
-
+    <CheckBox
+        android:id="@+id/cb_remove"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentRight="true"
+        android:layout_below="@+id/time_tv"
+        android:layout_marginTop="15dp"
+        android:visibility="gone"/>
     <RelativeLayout
+        android:layout_below="@+id/time_tv"
+        android:layout_toLeftOf="@+id/cb_remove"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:gravity="right"
@@ -98,4 +108,4 @@
         </RelativeLayout>
     </RelativeLayout>
 
-</LinearLayout>
+</RelativeLayout>

+ 20 - 9
WeiChat/src/main/res/layout/chat_from_item_voice.xml

@@ -1,23 +1,34 @@
 <?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:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:orientation="vertical" >
+    android:layout_height="wrap_content">
 
     <TextView
         android:id="@+id/time_tv"
         style="@style/ChattingUISystem"
+        android:layout_centerHorizontal="true"
         android:layout_gravity="center_horizontal"
         android:layout_marginTop="5dp"
         android:background="@drawable/chatsystem_bg"
         android:gravity="center" />
 
+    <CheckBox
+        android:id="@+id/cb_remove"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentRight="true"
+        android:layout_below="@+id/time_tv"
+        android:layout_marginTop="15dp"
+        android:visibility="gone"/>
+
     <RelativeLayout
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
+        android:layout_below="@+id/time_tv"
+        android:layout_toLeftOf="@+id/cb_remove"
         android:gravity="right"
         android:orientation="horizontal"
-        android:padding="3dip" >
+        android:padding="3dip">
 
         <ImageView
             android:id="@+id/chat_head_iv"
@@ -40,7 +51,7 @@
             android:layout_width="275dip"
             android:layout_height="wrap_content"
             android:layout_below="@+id/nick_name"
-            android:layout_toLeftOf="@+id/chat_head_iv" >
+            android:layout_toLeftOf="@+id/chat_head_iv">
 
             <LinearLayout
                 android:id="@+id/chat_from_warp_view"
@@ -52,14 +63,14 @@
                 android:clickable="true"
                 android:focusable="true"
                 android:gravity="center"
-                android:orientation="horizontal" >
+                android:orientation="horizontal">
 
                 <LinearLayout
                     android:id="@+id/chat_from_voice"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:gravity="left"
-                    android:orientation="horizontal" >
+                    android:orientation="horizontal">
 
                     <ImageView
                         android:id="@+id/chat_from_voice_icon"
@@ -83,8 +94,8 @@
                     android:layout_width="40dp"
                     android:layout_height="wrap_content"
                     android:gravity="center"
-                    android:singleLine="true"
                     android:padding="6dp"
+                    android:singleLine="true"
                     android:textColor="@color/text_main"
                     android:textSize="@dimen/text_main" />
             </LinearLayout>
@@ -111,4 +122,4 @@
         </RelativeLayout>
     </RelativeLayout>
 
-</LinearLayout>
+</RelativeLayout>

+ 15 - 5
WeiChat/src/main/res/layout/chat_to_item_card.xml

@@ -1,18 +1,28 @@
 <?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:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:orientation="vertical" >
+    >
 
     <TextView
         android:id="@+id/time_tv"
         style="@style/ChattingUISystem"
-        android:layout_gravity="center_horizontal"
+        android:layout_centerHorizontal="true"
         android:layout_marginTop="5dp"
         android:background="@drawable/chatsystem_bg"
         android:gravity="center" />
-
+    <CheckBox
+        android:id="@+id/cb_remove"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_below="@+id/time_tv"
+        android:layout_marginTop="15dp"
+        android:visibility="gone"
+        />
     <RelativeLayout
+        android:layout_below="@+id/time_tv"
+        android:layout_toRightOf="@+id/cb_remove"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:gravity="left"
@@ -122,4 +132,4 @@
         </RelativeLayout>
     </RelativeLayout>
 
-</LinearLayout>
+</RelativeLayout>

+ 15 - 5
WeiChat/src/main/res/layout/chat_to_item_file.xml

@@ -1,18 +1,28 @@
 <?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:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:orientation="vertical" >
+    >
 
     <TextView
         android:id="@+id/time_tv"
         style="@style/ChattingUISystem"
-        android:layout_gravity="center_horizontal"
+        android:layout_centerHorizontal="true"
         android:layout_marginTop="5dp"
         android:background="@drawable/chatsystem_bg"
         android:gravity="center" />
-
+    <CheckBox
+        android:id="@+id/cb_remove"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_below="@+id/time_tv"
+        android:layout_marginTop="15dp"
+        android:visibility="gone"
+        />
     <RelativeLayout
+        android:layout_below="@+id/time_tv"
+        android:layout_toRightOf="@+id/cb_remove"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:gravity="left"
@@ -99,4 +109,4 @@
         </RelativeLayout>
     </RelativeLayout>
 
-</LinearLayout>
+</RelativeLayout>

+ 15 - 5
WeiChat/src/main/res/layout/chat_to_item_gif.xml

@@ -1,18 +1,28 @@
 <?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:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:orientation="vertical" >
+    >
 
     <TextView
         android:id="@+id/time_tv"
         style="@style/ChattingUISystem"
-        android:layout_gravity="center_horizontal"
+        android:layout_centerHorizontal="true"
         android:layout_marginTop="5dp"
         android:background="@drawable/chatsystem_bg"
         android:gravity="center" />
-
+    <CheckBox
+        android:id="@+id/cb_remove"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_below="@+id/time_tv"
+        android:layout_marginTop="15dp"
+        android:visibility="gone"
+        />
     <RelativeLayout
+        android:layout_below="@+id/time_tv"
+        android:layout_toRightOf="@+id/cb_remove"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:gravity="left"
@@ -50,4 +60,4 @@
             android:scaleType="fitXY" />
     </RelativeLayout>
 
-</LinearLayout>
+</RelativeLayout>

+ 15 - 5
WeiChat/src/main/res/layout/chat_to_item_image.xml

@@ -1,18 +1,28 @@
 <?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:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:orientation="vertical" >
+    >
 
     <TextView
         android:id="@+id/time_tv"
         style="@style/ChattingUISystem"
-        android:layout_gravity="center_horizontal"
+       android:layout_centerHorizontal="true"
         android:layout_marginTop="5dp"
         android:background="@drawable/chatsystem_bg"
         android:gravity="center" />
-
+    <CheckBox
+        android:id="@+id/cb_remove"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_below="@+id/time_tv"
+        android:layout_marginTop="15dp"
+        android:visibility="gone"
+        />
     <RelativeLayout
+        android:layout_below="@+id/time_tv"
+        android:layout_toRightOf="@+id/cb_remove"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:gravity="left"
@@ -68,4 +78,4 @@
         </FrameLayout>
     </RelativeLayout>
 
-</LinearLayout>
+</RelativeLayout>

+ 15 - 5
WeiChat/src/main/res/layout/chat_to_item_location.xml

@@ -1,18 +1,28 @@
 <?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:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:orientation="vertical" >
+    >
 
     <TextView
         android:id="@+id/time_tv"
         style="@style/ChattingUISystem"
-        android:layout_gravity="center_horizontal"
+        android:layout_centerHorizontal="true"
         android:layout_marginTop="5dp"
         android:background="@drawable/chatsystem_bg"
         android:gravity="center" />
-
+    <CheckBox
+        android:id="@+id/cb_remove"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_below="@+id/time_tv"
+        android:layout_marginTop="15dp"
+        android:visibility="gone"
+        />
     <RelativeLayout
+        android:layout_below="@+id/time_tv"
+        android:layout_toRightOf="@+id/cb_remove"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:gravity="left"
@@ -70,4 +80,4 @@
         </LinearLayout>
     </RelativeLayout>
 
-</LinearLayout>
+</RelativeLayout>

+ 14 - 4
WeiChat/src/main/res/layout/chat_to_item_text.xml

@@ -1,5 +1,5 @@
 <?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:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical" >
@@ -7,12 +7,22 @@
     <TextView
         android:id="@+id/time_tv"
         style="@style/ChattingUISystem"
-        android:layout_gravity="center_horizontal"
+        android:layout_centerHorizontal="true"
         android:layout_marginTop="5dp"
         android:background="@drawable/chatsystem_bg"
         android:gravity="center" />
-
+    <CheckBox
+        android:id="@+id/cb_remove"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_below="@+id/time_tv"
+        android:layout_marginTop="15dp"
+        android:visibility="gone"
+        />
     <RelativeLayout
+        android:layout_below="@+id/time_tv"
+        android:layout_toRightOf="@+id/cb_remove"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:gravity="left"
@@ -58,4 +68,4 @@
         </LinearLayout>
     </RelativeLayout>
 
-</LinearLayout>
+</RelativeLayout>

+ 15 - 5
WeiChat/src/main/res/layout/chat_to_item_video.xml

@@ -1,18 +1,28 @@
 <?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:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:orientation="vertical" >
+    >
 
     <TextView
         android:id="@+id/time_tv"
         style="@style/ChattingUISystem"
-        android:layout_gravity="center_horizontal"
+        android:layout_centerHorizontal="true"
         android:layout_marginTop="5dp"
         android:background="@drawable/chatsystem_bg"
         android:gravity="center" />
-
+    <CheckBox
+        android:id="@+id/cb_remove"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_below="@+id/time_tv"
+        android:layout_marginTop="15dp"
+        android:visibility="gone"
+        />
     <RelativeLayout
+        android:layout_below="@+id/time_tv"
+        android:layout_toRightOf="@+id/cb_remove"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:gravity="left"
@@ -91,4 +101,4 @@
         </LinearLayout>
     </RelativeLayout>
 
-</LinearLayout>
+</RelativeLayout>

+ 15 - 5
WeiChat/src/main/res/layout/chat_to_item_voice.xml

@@ -1,18 +1,28 @@
 <?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:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:orientation="vertical" >
+     >
 
     <TextView
         android:id="@+id/time_tv"
         style="@style/ChattingUISystem"
-        android:layout_gravity="center_horizontal"
+android:layout_centerHorizontal="true"
         android:layout_marginTop="5dp"
         android:background="@drawable/chatsystem_bg"
         android:gravity="center" />
-
+    <CheckBox
+        android:id="@+id/cb_remove"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_below="@+id/time_tv"
+        android:layout_marginTop="15dp"
+        android:visibility="gone"
+        />
     <RelativeLayout
+        android:layout_below="@+id/time_tv"
+        android:layout_toRightOf="@+id/cb_remove"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:gravity="left"
@@ -114,4 +124,4 @@
         </RelativeLayout>
     </RelativeLayout>
 
-</LinearLayout>
+</RelativeLayout>