Commit 93d57aa7184b0fdd37c7db35a6bdb2cba4d89de2

Authored by 王琳
1 parent dd175e59

私聊添加发送图片及语音消息

app/src/main/AndroidManifest.xml
... ... @@ -43,6 +43,9 @@
43 43 android:name=".ui.CommentActivity"
44 44 android:screenOrientation="portrait" />
45 45  
  46 + <activity android:name=".ui.PrivateActivity"
  47 + android:screenOrientation="portrait"/>
  48 +
46 49 <service
47 50 android:name="io.rong.imlib.ipc.RongService"
48 51 android:exported="true"
... ...
app/src/main/java/com/cnlive/im/adapter/ChatListAdapter.java
1   -package com.cnlive.im.adapter;
2   -
3   -/**
4   - * Created by Lynn on 2/13/2017.
5   - */
6   -
7   -public class ChatListAdapter {
8   -
9   - /* private List<Object> msgList;
10   - private LayoutInflater mInflater = null;
11   - private final RelativeLayout.LayoutParams layoutParams;
12   - Context mContext;
13   -
14   - public ChatListAdapter(Context context) {
15   - this.mContext = context;
16   - msgList = new ArrayList<>();
17   - mInflater = LayoutInflater.from(context);
18   - layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
19   - }
20   -
21   - @Override
22   - public int getCount() {
23   - return msgList.size();
24   - }
25   -
26   - @Override
27   - public Object getItem(int position) {
28   - return msgList.get(position);
29   - }
30   -
31   - @Override
32   - public long getItemId(int position) {
33   - return 0;
34   - }
35   -
36   - @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
37   - @Override
38   - public View getView(int position, View convertView, ViewGroup parent) {
39   -
40   - cnStringMessage(position, convertView, parent);
41   - cnImaMessage(position, convertView,parent);
42   -
43   -
44   - return convertView;
45   -
46   - }
47   -
48   - private void cnImaMessage(int position, View convertView,ViewGroup parent) {
49   - ImaViewHolder viewHolder;
50   - Object cnImagMessage = msgList.get(position);
51   - if (cnImagMessage instanceof ImagMessage) {
52   - if (convertView == null) {
53   - viewHolder = new ImaViewHolder();
54   - if (((ImagMessage) cnImagMessage).isUserSend()) {
55   - convertView = mInflater.inflate(R.layout.imag_layout_item_user, parent,false);
56   - viewHolder.userName = (TextView) convertView.findViewById(R.id.img_user_name);
57   - viewHolder.userImaView = (ImageView) convertView.findViewById(R.id.img_content);
58   - convertView.setTag(viewHolder);
59   - }
60   -
61   - } else {
62   - viewHolder = (ImaViewHolder) convertView.getTag();
63   - }
64   - ImagMessage cnImagMessage1 = (ImagMessage) cnImagMessage;
65   - viewHolder.userName.setText(cnImagMessage1.getCnImgMessage().getUserInfo().getUserName());
66   - Glide.with(mContext).load(cnImagMessage1.getCnImgMessage().getThumUri()).into(viewHolder.userImaView);
67   -
68   -
69   - }
70   -
71   -
72   -
73   - }
74   -
75   - @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
76   - private void cnStringMessage(int position, View convertView, ViewGroup parent) {
77   - ViewHolder viewHolder;
78   - Object o = msgList.get(position);
79   - if (o instanceof ChatRoomActivity.CNMessageInfo) {
80   - if (convertView == null) {
81   - viewHolder = new ViewHolder();
82   - convertView = mInflater.inflate(R.layout.msg_text_view, parent,false);
83   - viewHolder.mRelativeLayout = (RelativeLayout) convertView.findViewById(R.id.re_chat_room);
84   - viewHolder.userName = (TextView) convertView.findViewById(R.id.user_name);
85   - viewHolder.msgContent = (TextView) convertView.findViewById(R.id.msg_text);
86   - convertView.setTag(viewHolder);
87   - } else {
88   - viewHolder = (ViewHolder) convertView.getTag();
89   - }
90   - ChatRoomActivity.CNMessageInfo cnMessageInfo = (ChatRoomActivity.CNMessageInfo) msgList.get(position);
91   - if (cnMessageInfo.isSendMesageInfo()) {
92   - viewHolder.msgContent.setText(cnMessageInfo.getCnMessage().getUserInfo().getUserName() == null ? "" : " : " + cnMessageInfo.getCnMessage().getUserInfo().getUserName());
93   - try {
94   - viewHolder.userName.setText(cnMessageInfo.getCnMessage().getContent() == null ? "" : (String) new JSONObject(cnMessageInfo.getCnMessage().getContent()).get("message"));
95   - } catch (JSONException e) {
96   - e.printStackTrace();
97   - }
98   - layoutParams.removeRule(RelativeLayout.ALIGN_PARENT_START);
99   - layoutParams.addRule(RelativeLayout.ALIGN_PARENT_END);
100   - viewHolder.mRelativeLayout.setLayoutParams(layoutParams);
101   - viewHolder.msgContent.setTextColor(Color.parseColor("#d61d0c"));
102   - viewHolder.userName.setTextColor(Color.BLACK);
103   - } else {
104   - viewHolder.userName.setText(cnMessageInfo.getCnMessage().getUserInfo().getUserName() == null ? "" : cnMessageInfo.getCnMessage().getUserInfo().getUserName() + " : ");
105   - try {
106   - viewHolder.msgContent.setText(cnMessageInfo.getCnMessage().getContent() == null ? "" : cnMessageInfo.getCnMessage().getContent() == null ? "" : (String) new JSONObject(cnMessageInfo.getCnMessage().getContent()).get("message"));
107   - } catch (JSONException e) {
108   - e.printStackTrace();
109   - }
110   - viewHolder.mRelativeLayout.setLayoutParams(layoutParams);
111   - layoutParams.removeRule(RelativeLayout.ALIGN_PARENT_END);
112   - layoutParams.addRule(RelativeLayout.ALIGN_PARENT_START);
113   - viewHolder.userName.setTextColor(Color.parseColor("#d61d0c"));
114   - viewHolder.msgContent.setTextColor(Color.BLACK);
115   - }
116   -
117   -
118   - }
119   -
120   -
121   - }
122   -
123   -
124   - public void updateItems(List<Object> items) {
125   - if (items == null) return;
126   - msgList.clear();
127   - msgList.addAll(items);
128   - }
129   -
130   -
131   - private class ViewHolder {
132   - TextView userName;
133   - TextView msgContent;
134   - RelativeLayout mRelativeLayout;
135   -
136   - }
137   -
138   -
139   - private class ImaViewHolder {
140   - TextView userName;
141   - ImageView userImaView;
142   -
143   - }*/
144   -}
  1 +//package com.cnlive.im.adapter;
  2 +//
  3 +///**
  4 +// * Created by Lynn on 2/13/2017.
  5 +// */
  6 +//
  7 +//public class ChatListAdapter {
  8 +//
  9 +// /* private List<Object> msgList;
  10 +// private LayoutInflater mInflater = null;
  11 +// private final RelativeLayout.LayoutParams layoutParams;
  12 +// Context mContext;
  13 +//
  14 +// public ChatListAdapter(Context context) {
  15 +// this.mContext = context;
  16 +// msgList = new ArrayList<>();
  17 +// mInflater = LayoutInflater.from(context);
  18 +// layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
  19 +// }
  20 +//
  21 +// @Override
  22 +// public int getCount() {
  23 +// return msgList.size();
  24 +// }
  25 +//
  26 +// @Override
  27 +// public Object getItem(int position) {
  28 +// return msgList.get(position);
  29 +// }
  30 +//
  31 +// @Override
  32 +// public long getItemId(int position) {
  33 +// return 0;
  34 +// }
  35 +//
  36 +// @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
  37 +// @Override
  38 +// public View getView(int position, View convertView, ViewGroup parent) {
  39 +//
  40 +// cnStringMessage(position, convertView, parent);
  41 +// cnImaMessage(position, convertView,parent);
  42 +//
  43 +//
  44 +// return convertView;
  45 +//
  46 +// }
  47 +//
  48 +// private void cnImaMessage(int position, View convertView,ViewGroup parent) {
  49 +// ImaViewHolder viewHolder;
  50 +// Object cnImagMessage = msgList.get(position);
  51 +// if (cnImagMessage instanceof ImagMessage) {
  52 +// if (convertView == null) {
  53 +// viewHolder = new ImaViewHolder();
  54 +// if (((ImagMessage) cnImagMessage).isUserSend()) {
  55 +// convertView = mInflater.inflate(R.layout.imag_layout_item_user, parent,false);
  56 +// viewHolder.userName = (TextView) convertView.findViewById(R.id.img_user_name);
  57 +// viewHolder.userImaView = (ImageView) convertView.findViewById(R.id.img_content);
  58 +// convertView.setTag(viewHolder);
  59 +// }
  60 +//
  61 +// } else {
  62 +// viewHolder = (ImaViewHolder) convertView.getTag();
  63 +// }
  64 +// ImagMessage cnImagMessage1 = (ImagMessage) cnImagMessage;
  65 +// viewHolder.userName.setText(cnImagMessage1.getCnImgMessage().getUserInfo().getUserName());
  66 +// Glide.with(mContext).load(cnImagMessage1.getCnImgMessage().getThumUri()).into(viewHolder.userImaView);
  67 +//
  68 +//
  69 +// }
  70 +//
  71 +//
  72 +//
  73 +// }
  74 +//
  75 +// @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
  76 +// private void cnStringMessage(int position, View convertView, ViewGroup parent) {
  77 +// ViewHolder viewHolder;
  78 +// Object o = msgList.get(position);
  79 +// if (o instanceof ChatRoomActivity.CNMessageInfo) {
  80 +// if (convertView == null) {
  81 +// viewHolder = new ViewHolder();
  82 +// convertView = mInflater.inflate(R.layout.msg_text_view, parent,false);
  83 +// viewHolder.mRelativeLayout = (RelativeLayout) convertView.findViewById(R.id.re_chat_room);
  84 +// viewHolder.userName = (TextView) convertView.findViewById(R.id.user_name);
  85 +// viewHolder.msgContent = (TextView) convertView.findViewById(R.id.msg_text);
  86 +// convertView.setTag(viewHolder);
  87 +// } else {
  88 +// viewHolder = (ViewHolder) convertView.getTag();
  89 +// }
  90 +// ChatRoomActivity.CNMessageInfo cnMessageInfo = (ChatRoomActivity.CNMessageInfo) msgList.get(position);
  91 +// if (cnMessageInfo.isSendMesageInfo()) {
  92 +// viewHolder.msgContent.setText(cnMessageInfo.getCnMessage().getUserInfo().getUserName() == null ? "" : " : " + cnMessageInfo.getCnMessage().getUserInfo().getUserName());
  93 +// try {
  94 +// viewHolder.userName.setText(cnMessageInfo.getCnMessage().getContent() == null ? "" : (String) new JSONObject(cnMessageInfo.getCnMessage().getContent()).get("message"));
  95 +// } catch (JSONException e) {
  96 +// e.printStackTrace();
  97 +// }
  98 +// layoutParams.removeRule(RelativeLayout.ALIGN_PARENT_START);
  99 +// layoutParams.addRule(RelativeLayout.ALIGN_PARENT_END);
  100 +// viewHolder.mRelativeLayout.setLayoutParams(layoutParams);
  101 +// viewHolder.msgContent.setTextColor(Color.parseColor("#d61d0c"));
  102 +// viewHolder.userName.setTextColor(Color.BLACK);
  103 +// } else {
  104 +// viewHolder.userName.setText(cnMessageInfo.getCnMessage().getUserInfo().getUserName() == null ? "" : cnMessageInfo.getCnMessage().getUserInfo().getUserName() + " : ");
  105 +// try {
  106 +// viewHolder.msgContent.setText(cnMessageInfo.getCnMessage().getContent() == null ? "" : cnMessageInfo.getCnMessage().getContent() == null ? "" : (String) new JSONObject(cnMessageInfo.getCnMessage().getContent()).get("message"));
  107 +// } catch (JSONException e) {
  108 +// e.printStackTrace();
  109 +// }
  110 +// viewHolder.mRelativeLayout.setLayoutParams(layoutParams);
  111 +// layoutParams.removeRule(RelativeLayout.ALIGN_PARENT_END);
  112 +// layoutParams.addRule(RelativeLayout.ALIGN_PARENT_START);
  113 +// viewHolder.userName.setTextColor(Color.parseColor("#d61d0c"));
  114 +// viewHolder.msgContent.setTextColor(Color.BLACK);
  115 +// }
  116 +//
  117 +//
  118 +// }
  119 +//
  120 +//
  121 +// }
  122 +//
  123 +//
  124 +// public void updateItems(List<Object> items) {
  125 +// if (items == null) return;
  126 +// msgList.clear();
  127 +// msgList.addAll(items);
  128 +// }
  129 +//
  130 +//
  131 +// private class ViewHolder {
  132 +// TextView userName;
  133 +// TextView msgContent;
  134 +// RelativeLayout mRelativeLayout;
  135 +//
  136 +// }
  137 +//
  138 +//
  139 +// private class ImaViewHolder {
  140 +// TextView userName;
  141 +// ImageView userImaView;
  142 +//
  143 +// }*/
  144 +//}
... ...
app/src/main/java/com/cnlive/im/adapter/ChatRoomAdpter.java
... ... @@ -24,6 +24,9 @@ import com.cnlive.im.mode.ImagMessage;
24 24 import com.cnlive.im.mode.StringMessage;
25 25 import com.cnlive.im.mode.VoiceMessage;
26 26  
  27 +import org.json.JSONException;
  28 +import org.json.JSONObject;
  29 +
27 30 import java.text.SimpleDateFormat;
28 31 import java.util.Calendar;
29 32 import java.util.Date;
... ... @@ -46,10 +49,12 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter {
46 49 private Context mContext;
47 50 private VoiceItemClickListener mVoiceItemClickListener;
48 51  
49   - public ChatRoomAdpter(Context context) {
  52 + private boolean isPrivate;
  53 +
  54 + public ChatRoomAdpter(Context context, boolean isPrivate) {
50 55 super(context);
51 56 this.mContext = context;
52   -
  57 + this.isPrivate = isPrivate;
53 58 }
54 59  
55 60  
... ... @@ -103,7 +108,15 @@ public class ChatRoomAdpter extends BaseRecyclerAdapter {
103 108 StringMessageHolder holder1 = (StringMessageHolder) holder;
104 109 Object o = mItems.get(position);
105 110 StringMessage o1 = (StringMessage) o;
106   - holder1.msg_text.setText(o1.getCnMessage().getContent());
  111 + if (isPrivate) {
  112 + try {
  113 + holder1.msg_text.setText((String) (new JSONObject(o1.getCnMessage().getContent()).get("message")));
  114 + } catch (JSONException e) {
  115 + e.printStackTrace();
  116 + }
  117 + } else {
  118 + holder1.msg_text.setText(o1.getCnMessage().getContent());
  119 + }
107 120 holder1.user_name.setText(o1.getCnMessage().getUserInfo().getUserName());
108 121 holder1.user_name.setTextColor(Color.parseColor("#d61d0c"));
109 122 holder1.msg_text.setTextColor(Color.BLACK);
... ...
app/src/main/java/com/cnlive/im/ui/ChatRoomActivity.java
... ... @@ -103,7 +103,7 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL
103 103 public static final int PICTURE_REQUEST_CODE = 0x1003;
104 104 public static final int VOICE_REQUEST_CODE = 0x1004;
105 105 private long l;
106   - int i;
  106 + int duration;
107 107  
108 108 private String mFilePath;
109 109  
... ... @@ -166,7 +166,7 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL
166 166 foundChatBtn.setOnClickListener(this);
167 167 send_messageOneBtn.setOnClickListener(this);
168 168 groupChatOneListMy = new ArrayList<>();
169   - chatListAdapterOne = new ChatRoomAdpter(ChatRoomActivity.this);
  169 + chatListAdapterOne = new ChatRoomAdpter(ChatRoomActivity.this, false);
170 170 chatListAdapterOne.setonVoiceItemClickListener(this);
171 171 listViewOne.setLayoutManager(new LinearLayoutManager(ChatRoomActivity.this));
172 172 listViewOne.setAdapter(chatListAdapterOne);
... ... @@ -581,9 +581,9 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL
581 581  
582 582 @Override
583 583 public void onStop(String filePath) {
584   - i = (int) mAudioRecordUtil.getDuration();
  584 + duration = (int) mAudioRecordUtil.getDuration();
585 585 mFilePath = filePath;
586   - ChatUtil.sendVoiceMessage(IChat.CHATROOM, roomIdOne, Uri.parse(mFilePath), i, sendMessageListener);
  586 + ChatUtil.sendVoiceMessage(IChat.CHATROOM, roomIdOne, Uri.parse(mFilePath), duration, sendMessageListener);
587 587 }
588 588 };
589 589  
... ...
app/src/main/java/com/cnlive/im/ui/PrivateActivity.java 0 → 100644
  1 +package com.cnlive.im.ui;
  2 +
  3 +import android.Manifest;
  4 +import android.app.Activity;
  5 +import android.content.Context;
  6 +import android.content.Intent;
  7 +import android.content.pm.PackageManager;
  8 +import android.database.Cursor;
  9 +import android.net.Uri;
  10 +import android.os.Build;
  11 +import android.os.Bundle;
  12 +import android.os.Handler;
  13 +import android.provider.MediaStore;
  14 +import android.support.annotation.NonNull;
  15 +import android.support.v4.app.ActivityCompat;
  16 +import android.support.v4.content.ContextCompat;
  17 +import android.support.v7.app.AppCompatActivity;
  18 +import android.support.v7.widget.LinearLayoutManager;
  19 +import android.support.v7.widget.RecyclerView;
  20 +import android.text.Editable;
  21 +import android.text.TextUtils;
  22 +import android.text.TextWatcher;
  23 +import android.util.Log;
  24 +import android.view.Gravity;
  25 +import android.view.MotionEvent;
  26 +import android.view.View;
  27 +import android.view.inputmethod.InputMethodManager;
  28 +import android.widget.Button;
  29 +import android.widget.EditText;
  30 +import android.widget.ImageView;
  31 +import android.widget.LinearLayout;
  32 +import android.widget.ListView;
  33 +import android.widget.RelativeLayout;
  34 +import android.widget.TextView;
  35 +import android.widget.Toast;
  36 +
  37 +import com.cnlive.im.R;
  38 +import com.cnlive.im.adapter.ChatRoomAdpter;
  39 +import com.cnlive.im.adapter.base.VoiceItemClickListener;
  40 +import com.cnlive.im.mode.CNMessageModole;
  41 +import com.cnlive.im.mode.ImagMessage;
  42 +import com.cnlive.im.mode.StringMessage;
  43 +import com.cnlive.im.mode.VoiceMessage;
  44 +import com.cnlive.im.util.AudioRecordUtil;
  45 +import com.cnlive.im.util.MessageType;
  46 +import com.cnlive.im.util.PlayerUtil;
  47 +import com.cnlive.im.util.TimeUtils;
  48 +import com.cnlive.im.util.ToStringUtils;
  49 +import com.cnlive.libs.util.chat.ChatUtil;
  50 +import com.cnlive.libs.util.chat.base.IChat;
  51 +import com.cnlive.libs.util.chat.model.CNImgMessage;
  52 +import com.cnlive.libs.util.chat.model.CNMessage;
  53 +import com.cnlive.libs.util.chat.model.CNUserInfo;
  54 +import com.cnlive.libs.util.chat.model.CNVoiceMessage;
  55 +
  56 +import org.json.JSONException;
  57 +import org.json.JSONObject;
  58 +
  59 +import java.util.ArrayList;
  60 +
  61 +import static com.cnlive.im.R.id.opposite_id_edit;
  62 +
  63 +/**
  64 + * Created by Lynn on 2017/7/24.
  65 + */
  66 +
  67 +public class PrivateActivity extends AppCompatActivity implements View.OnClickListener, VoiceItemClickListener {
  68 +
  69 + private static final String TAG = "PrivateChatActivity";
  70 +
  71 + // 所需的全部权限
  72 + static final String[] PERMISSIONS = new String[]{
  73 + Manifest.permission.RECORD_AUDIO,
  74 + Manifest.permission.WRITE_EXTERNAL_STORAGE
  75 + };
  76 +
  77 + public static final int IMG_FROM_PICTURE = 0x1001;
  78 + public static final int VOICE = 0x1002;
  79 + public static final int PICTURE_REQUEST_CODE = 0x1003;
  80 + public static final int VOICE_REQUEST_CODE = 0x1004;
  81 +
  82 + public static final String IMAGE_MESSAGE = "image_message";
  83 + public static final String STRING_MESSAGE = "string_message";
  84 + public static final String VOICE_MESSAGE = "voice_message";
  85 +
  86 + private RecyclerView chatListView;
  87 + private EditText messageContent;
  88 + private Button sendMessageBtn;
  89 + private ChatRoomAdpter chatListAdapter;
  90 + private ArrayList<Object> messageList = new ArrayList<>();
  91 + // private CNMessage cnMessage;
  92 + private LinearLayout linearLayoutUseID;
  93 + private EditText user_id_edit;
  94 + private Button userId_btn_top;
  95 + private String oppositeID;
  96 + private LinearLayout edit_layout;
  97 + private Handler mHandler;
  98 + private EditText opposite_name_edit;
  99 + private String user_name_string;
  100 + private String user_id_string;
  101 + private int sendInfo = 3;
  102 + private Button agree_btn;
  103 + private Button reject_btn;
  104 + private LinearLayout agree_reject_lin;
  105 + boolean isCanSendMeaasge = false;
  106 + private Button vistor_btn;
  107 +
  108 + private ImageView keybordBtn;
  109 + private Button sendVoice;
  110 + private AudioRecordUtil mAudioRecordUtil;
  111 + private PlayerUtil playerUtil;
  112 + private String mFilePath;
  113 + private PopupWindowFactory mPop;
  114 + private RelativeLayout privateLayout;
  115 + private LinearLayout sendMsgLayout;
  116 + private LinearLayout cancelSendLayout;
  117 + private TextView mTextView;
  118 + private ImageView mImageView;
  119 + private ImageView ima_send;
  120 +
  121 + private boolean isVoiceBtnVisible = false;
  122 + private int duration;
  123 + private Context context;
  124 +
  125 + @Override
  126 + protected void onCreate(Bundle savedInstanceState) {
  127 + super.onCreate(savedInstanceState);
  128 + setContentView(R.layout.activity_private_chat);
  129 + context = this;
  130 + initView();
  131 + mAudioRecordUtil = new AudioRecordUtil();
  132 + mAudioRecordUtil.setOnAudioStatusUpdateListener(onAudioStatusUpdateListener);
  133 + mHandler = new Handler();
  134 + ChatUtil.setOnConnectStatusListener(connectStatusListener);
  135 + ChatUtil.setOnReceiveMessageListener(receiveMessageListener);
  136 + requestPermission();
  137 + playerUtil = new PlayerUtil(this);
  138 + }
  139 +
  140 + private void initView() {
  141 +
  142 + final View view = View.inflate(this, R.layout.layout_microphone, null);
  143 + mPop = new PopupWindowFactory(this, view);
  144 + sendMsgLayout = (LinearLayout) view.findViewById(R.id.send_layout);
  145 + cancelSendLayout = (LinearLayout) view.findViewById(R.id.cancel_send_layout);
  146 + mTextView = (TextView) view.findViewById(R.id.tv_recording_time);
  147 + mImageView = (ImageView) view.findViewById(R.id.iv_recording_icon);
  148 +
  149 + opposite_name_edit = (EditText) findViewById(R.id.opposite_name_edit);
  150 + chatListView = (RecyclerView) findViewById(R.id.private_list_view);
  151 +
  152 + privateLayout = (RelativeLayout) findViewById(R.id.activity_private_chat);
  153 +
  154 + messageContent = (EditText) findViewById(R.id.message_content);
  155 + messageContent.addTextChangedListener(textWatcher);
  156 + sendMessageBtn = (Button) findViewById(R.id.send_message);
  157 + sendMessageBtn.setOnClickListener(this);
  158 + linearLayoutUseID = (LinearLayout) findViewById(R.id.opposite_liner_useID);
  159 + userId_btn_top = (Button) findViewById(R.id.userId_btn_top);
  160 + userId_btn_top.setOnClickListener(this);
  161 + edit_layout = (LinearLayout) findViewById(R.id.edit_layout);
  162 + user_id_edit = (EditText) findViewById(opposite_id_edit);
  163 + Intent intent = getIntent();
  164 + user_name_string = intent.getStringExtra("user_name_string");
  165 + user_id_string = intent.getStringExtra("user_id_string");
  166 + agree_btn = (Button) findViewById(R.id.agree_btn);
  167 + reject_btn = (Button) findViewById(R.id.reject_btn);
  168 + agree_btn.setOnClickListener(this);
  169 + reject_btn.setOnClickListener(this);
  170 + agree_reject_lin = (LinearLayout) findViewById(R.id.agree_reject_lin);
  171 + vistor_btn = (Button) findViewById(R.id.vistor_Btn);
  172 + vistor_btn.setOnClickListener(this);
  173 +
  174 + keybordBtn = (ImageView) findViewById(R.id.keybord);
  175 + keybordBtn.setOnClickListener(this);
  176 +
  177 + ima_send = (ImageView) findViewById(R.id.ima_send);
  178 + ima_send.setOnClickListener(this);
  179 +
  180 + sendVoice = (Button) findViewById(R.id.send_voice);
  181 +
  182 + chatListAdapter = new ChatRoomAdpter(this, true);
  183 + chatListAdapter.setonVoiceItemClickListener(this);
  184 + chatListView.setLayoutManager(new LinearLayoutManager(PrivateActivity.this));
  185 + chatListView.setAdapter(chatListAdapter);
  186 +
  187 + StartListener();
  188 + }
  189 +
  190 + @Override
  191 + public void onClick(View v) {
  192 +
  193 + switch (v.getId()) {
  194 + case R.id.send_message:
  195 + sendMessage(STRING_MESSAGE);
  196 +
  197 + break;
  198 +
  199 + case R.id.userId_btn_top:
  200 + //发送私聊消息,需要传入目标ID与发送的消息内容
  201 + if (user_id_edit.getText().toString().isEmpty()) {
  202 + Toast.makeText(this, "对方ID不能为空", Toast.LENGTH_SHORT).show();
  203 + } else if (opposite_name_edit.getText().toString().isEmpty()) {
  204 + Toast.makeText(this, "对方name不能为空", Toast.LENGTH_SHORT).show();
  205 + } else {
  206 +
  207 + oppositeID = user_id_edit.getText().toString();
  208 + linearLayoutUseID.setVisibility(View.INVISIBLE);
  209 + edit_layout.setVisibility(View.VISIBLE);
  210 + chatListView.setVisibility(View.VISIBLE);
  211 + CNUserInfo cnName = new CNUserInfo(user_id_string, user_name_string, "");
  212 + ChatUtil.login(cnName, connectListener);
  213 +
  214 + }
  215 +
  216 + break;
  217 +
  218 + case R.id.agree_btn:
  219 + String objToJsonString = ToStringUtils.objToJsonString(new CNMessageModole("同意", "3"));
  220 + ChatUtil.sendMessage(IChat.PRIVATE, oppositeID, objToJsonString, sendMessageListener);
  221 + agree_reject_lin.setVisibility(View.GONE);
  222 + break;
  223 +
  224 + case R.id.reject_btn:
  225 + String objToJsonStringDis = ToStringUtils.objToJsonString(new CNMessageModole("拒绝", "3"));//私聊
  226 +
  227 + ChatUtil.sendMessage(IChat.PRIVATE, oppositeID, objToJsonStringDis, sendMessageListener);
  228 + agree_reject_lin.setVisibility(View.GONE);
  229 + break;
  230 + case R.id.vistor_Btn:
  231 + String objToJsonStringInvt = ToStringUtils.objToJsonString(new CNMessageModole("你好我们可以进行私聊吗", "3"));//私聊
  232 + ChatUtil.sendMessage(IChat.PRIVATE, oppositeID, objToJsonStringInvt, sendMessageListener);
  233 +
  234 + break;
  235 +
  236 + case R.id.keybord:
  237 + if (!isVoiceBtnVisible) {
  238 + messageContent.setVisibility(View.GONE);
  239 + sendVoice.setVisibility(View.VISIBLE);
  240 + keybordBtn.setImageResource(R.drawable.keybord);
  241 + InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
  242 + imm.hideSoftInputFromWindow(messageContent.getWindowToken(), 0);
  243 + isVoiceBtnVisible = true;
  244 + } else {
  245 + sendVoice.setVisibility(View.GONE);
  246 + messageContent.setVisibility(View.VISIBLE);
  247 + keybordBtn.setImageResource(R.drawable.voice);
  248 + isVoiceBtnVisible = false;
  249 + }
  250 + break;
  251 + case R.id.ima_send:
  252 + sendMessage(IMAGE_MESSAGE);
  253 + break;
  254 + }
  255 + }
  256 +
  257 + private void sendMessage(String type) {
  258 + if (sendInfo == 2) {
  259 + Toast.makeText(this, "等待对方接受邀请", Toast.LENGTH_SHORT).show();
  260 +
  261 + } else if (sendInfo == 4) {
  262 + Toast.makeText(this, "对方已经拒绝不能发送", Toast.LENGTH_SHORT).show();
  263 +
  264 + } else if (sendInfo == 3) {
  265 + Toast.makeText(this, "还没有邀请对方呦~", Toast.LENGTH_SHORT).show();
  266 + } else if (sendInfo == 5) {
  267 + Toast.makeText(this, "你已经拒绝对方不能发送消息", Toast.LENGTH_SHORT).show();
  268 + } else {
  269 + if (type.equals(STRING_MESSAGE)) {
  270 + if (messageContent.getText().toString().isEmpty()) {
  271 + Toast.makeText(this, "不能发送空消息呦~", Toast.LENGTH_SHORT).show();
  272 + } else {
  273 + String objToJsonString = ToStringUtils.objToJsonString(new CNMessageModole(messageContent.getText().toString(), "4"));//私聊消息
  274 + ChatUtil.sendMessage(IChat.PRIVATE, oppositeID, objToJsonString, sendMessageListener);
  275 + messageContent.setText("");
  276 + }
  277 + } else if (type.equals(IMAGE_MESSAGE)) {
  278 + fromPicture();
  279 + } else if (type.equals(VOICE_MESSAGE)) {
  280 + mPop.showAtLocation(privateLayout, Gravity.CENTER, 0, 0);
  281 +
  282 + sendVoice.setText("松开发送");
  283 + mAudioRecordUtil.startRecord();
  284 + }
  285 + }
  286 + }
  287 +
  288 + public void fromPicture() {
  289 + if (Build.VERSION.SDK_INT >= 23) {
  290 + int checkCallPhonePermission = ContextCompat.checkSelfPermission(PrivateActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
  291 + if (checkCallPhonePermission != PackageManager.PERMISSION_GRANTED) {
  292 + requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, PICTURE_REQUEST_CODE);
  293 + return;
  294 + } else {
  295 + toIntentPicture();
  296 + }
  297 + } else {
  298 + toIntentPicture();
  299 + }
  300 + }
  301 +
  302 +
  303 + private void toIntentPicture() {
  304 + Intent intent = new Intent();
  305 + intent.setType("image/*");
  306 + intent.setAction(Intent.ACTION_PICK);
  307 + startActivityForResult(Intent.createChooser(intent, "Complete action using"), IMG_FROM_PICTURE);
  308 + }
  309 +
  310 +
  311 + @Override
  312 + public void onActivityResult(int requestCode, int resultCode, Intent data) {
  313 + super.onActivityResult(requestCode, resultCode, data);
  314 + if (resultCode == Activity.RESULT_OK) {
  315 + switch (requestCode) {
  316 + case IMG_FROM_PICTURE:
  317 +// String localImagePath = "/sdcard/test.png";
  318 +// Uri selectedImage = Uri.parse("file://" + localImagePath);
  319 + Uri selectedImage = data.getData();
  320 + String[] filePathColumn = {MediaStore.Images.Media.DATA};
  321 +
  322 + Cursor cursor = getContentResolver().query(selectedImage,
  323 + filePathColumn, null, null, null);
  324 + cursor.moveToFirst();
  325 +
  326 + int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
  327 + final String picturePath = cursor.getString(columnIndex);
  328 +
  329 + Uri uri = Uri.parse("file://" + picturePath);
  330 + ChatUtil.sendImaMessage(IChat.PRIVATE, oppositeID, uri, uri, sendMessageListener);
  331 + break;
  332 +
  333 + default:
  334 + break;
  335 + }
  336 + }
  337 + }
  338 +
  339 + //连接监听
  340 + private IChat.OnConnectListener connectListener = new IChat.OnConnectListener() {
  341 +
  342 +
  343 + @Override
  344 + public void onTokenIncorrect(String s) {
  345 + Log.e(TAG, "ConnectListener TokenIncorrect");
  346 + Toast.makeText(PrivateActivity.this, "TokenIncorrect", Toast.LENGTH_SHORT).show();
  347 + }
  348 +
  349 + @Override
  350 + public void onSuccess(String s) {
  351 + Log.e(TAG, "ConnectListener 连接监听" + s);
  352 + Toast.makeText(PrivateActivity.this, s, Toast.LENGTH_SHORT).show();
  353 +
  354 + }
  355 +
  356 + @Override
  357 + public void onError(int i, String s) {
  358 + Log.e(TAG, "ConnectListener errorCode : " + i + " : errorMessage : " + s);
  359 + Toast.makeText(PrivateActivity.this, s, Toast.LENGTH_SHORT).show();
  360 +
  361 + }
  362 + };
  363 +
  364 +
  365 + /**
  366 + * 发送消息监听
  367 + */
  368 +
  369 + private IChat.OnSendMessageListener sendMessageListener = new IChat.OnSendMessageListener() {
  370 + @Override
  371 + public void onAttached(Object o) {
  372 + }
  373 +
  374 + @Override
  375 + public void onSuccess(final Object o) throws JSONException {
  376 + if (View.VISIBLE == vistor_btn.getVisibility()) {
  377 + vistor_btn.setVisibility(View.GONE);
  378 + }
  379 +
  380 + mHandler.post(new Runnable() {
  381 + @Override
  382 + public void run() {
  383 + if (o instanceof CNMessage) {
  384 + CNMessage o1 = (CNMessage) o;
  385 + JSONObject jsonObject = null;
  386 + try {
  387 + jsonObject = new JSONObject(o1.getContent().toString());
  388 + String type = (String) jsonObject.get("type");
  389 + String message = (String) jsonObject.get("message");
  390 + Toast.makeText(PrivateActivity.this, "发送消息成功", Toast.LENGTH_SHORT).show();
  391 + if ("3".equals(type) && message.equals("你好我们可以进行私聊吗")) {
  392 + sendInfo = 2;
  393 + Toast.makeText(PrivateActivity.this, "申请已发送等待对方验证", Toast.LENGTH_SHORT).show();
  394 + } else if ("3".equals(type) && message.equals("拒绝")) {
  395 + sendInfo = 5;
  396 + } else if ("3".equals(type) && message.equals("同意")) {
  397 + sendInfo = 1;
  398 + } else if ("4".equals(type)) {
  399 + chatListAdapter.addItem(new StringMessage(MessageType.stringMessage, o1, true));
  400 + chatListView.smoothScrollToPosition(chatListAdapter.getItemCount() - 1);
  401 +
  402 + }
  403 + } catch (JSONException e) {
  404 +
  405 +
  406 + }
  407 + } else if (o instanceof CNImgMessage) {
  408 + CNImgMessage o1 = (CNImgMessage) o;
  409 + chatListAdapter.addItem(new ImagMessage(MessageType.imaMessage, o1, true));
  410 + chatListView.smoothScrollToPosition(chatListAdapter.getItemCount() - 1);
  411 + } else if (o instanceof CNVoiceMessage) {
  412 + CNVoiceMessage o1 = (CNVoiceMessage) o;
  413 + VoiceMessage voiceMessage = new VoiceMessage(MessageType.voiceMessage, o1, true);
  414 + chatListAdapter.addItem(voiceMessage);
  415 + //发送成功后删除保存在本地的录制文件
  416 + mAudioRecordUtil.deleteRecordFile(mFilePath);
  417 + chatListView.smoothScrollToPosition(chatListAdapter.getItemCount() - 1);
  418 + }
  419 + }
  420 + });
  421 + }
  422 +
  423 + @Override
  424 + public void onError(Object o, int i, String s) {
  425 + }
  426 + };
  427 +
  428 +
  429 + //连接状态监听
  430 + private IChat.OnConnectStatusListener connectStatusListener = new IChat.OnConnectStatusListener() {
  431 + @Override
  432 + public void onConnectStatus(int i, String s) {
  433 + Log.i(TAG, "私聊连接状态监听私聊" + i + " " + s);
  434 +
  435 +
  436 + }
  437 + };
  438 + //接收消息监听
  439 + private IChat.OnReceiveMessageListener receiveMessageListener = new IChat.OnReceiveMessageListener() {
  440 + @Override
  441 + public void processMessage(final Object o) {
  442 + mHandler.post(new Runnable() {
  443 + @Override
  444 + public void run() {
  445 + if (o instanceof CNMessage) {
  446 + CNMessage o1 = (CNMessage) o;
  447 + JSONObject jsonObject = null;
  448 + try {
  449 + jsonObject = new JSONObject(o1.getContent().toString());
  450 + String type = (String) jsonObject.get("type");
  451 + if ("3".equals(type) && "你好我们可以进行私聊吗".equals(jsonObject.get("message"))) {
  452 + vistor_btn.setVisibility(View.GONE);
  453 + agree_reject_lin.setVisibility(View.VISIBLE);
  454 + } else if ("3".equals(type) && "同意".equals(jsonObject.get("message"))) {
  455 + sendInfo = 1;
  456 + } else if ("3".equals(type) && "拒绝".equals(jsonObject.get("message"))) {
  457 + sendInfo = 4;
  458 + } else if ("4".equals(type)) {
  459 + Log.v(TAG, o1.getContent().toString());
  460 + chatListAdapter.addItem(new StringMessage(MessageType.stringMessage, o1, false));
  461 + chatListView.smoothScrollToPosition(chatListAdapter.getItemCount() - 1);
  462 + }
  463 +
  464 + } catch (JSONException e) {
  465 + e.printStackTrace();
  466 + }
  467 + } else if (o instanceof CNImgMessage) {
  468 + CNImgMessage o1 = (CNImgMessage) o;
  469 + chatListAdapter.addItem(new ImagMessage(MessageType.imaMessage, o1, false));
  470 + chatListView.smoothScrollToPosition(chatListAdapter.getItemCount() - 1);
  471 + } else if (o instanceof CNVoiceMessage) {
  472 + CNVoiceMessage o1 = (CNVoiceMessage) o;
  473 + VoiceMessage voiceMessage = new VoiceMessage(MessageType.voiceMessage, o1, false);
  474 + chatListAdapter.addItem(voiceMessage);
  475 + chatListView.smoothScrollToPosition(chatListAdapter.getItemCount() - 1);
  476 + }
  477 + }
  478 + });
  479 +
  480 + }
  481 + };
  482 +
  483 + /**
  484 + * 开启扫描之前判断权限是否打开
  485 + */
  486 + private void requestPermission() {
  487 + //判断是否开启摄像头权限
  488 + if ((ContextCompat.checkSelfPermission(context,
  489 + Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) &&
  490 + (ContextCompat.checkSelfPermission(context,
  491 + Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED)
  492 + ) {
  493 + StartListener();
  494 +
  495 + //判断是否开启语音权限
  496 + } else {
  497 + //请求获取摄像头权限
  498 + ActivityCompat.requestPermissions((Activity) context,
  499 + new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.RECORD_AUDIO}, VOICE_REQUEST_CODE);
  500 + }
  501 + }
  502 +
  503 + @Override
  504 + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
  505 + super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  506 + if (requestCode == VOICE_REQUEST_CODE) {
  507 + if ((grantResults[0] == PackageManager.PERMISSION_GRANTED) && (grantResults[1] == PackageManager.PERMISSION_GRANTED)) {
  508 + StartListener();
  509 + } else {
  510 + Toast.makeText(context, "已拒绝权限!", Toast.LENGTH_SHORT).show();
  511 + }
  512 + }
  513 + }
  514 +
  515 + float downX;
  516 + float downY;
  517 +
  518 + public void StartListener() {
  519 +
  520 + //Button的touch监听
  521 + sendVoice.setOnTouchListener(new View.OnTouchListener() {
  522 + @Override
  523 + public boolean onTouch(View v, MotionEvent event) {
  524 + if (lacksPermissions(PERMISSIONS)) {
  525 + if (lacksPermission(PERMISSIONS[0])) {
  526 + Toast.makeText(PrivateActivity.this, "没有麦克风权限,请前往“设置 - 应用 - 权限”中开启权限", Toast.LENGTH_SHORT).show();
  527 +
  528 + } else if (lacksPermission(PERMISSIONS[1])) {
  529 + Toast.makeText(PrivateActivity.this, "没有文件读写权限,请前往“设置 - 应用 - 权限”中开启权限", Toast.LENGTH_SHORT).show();
  530 +
  531 + }
  532 + } else {
  533 +
  534 + switch (event.getAction()) {
  535 +
  536 + case MotionEvent.ACTION_DOWN:
  537 + sendMessage(VOICE_MESSAGE);
  538 +// mPop.showAtLocation(privateLayout, Gravity.CENTER, 0, 0);
  539 +//
  540 +// sendVoice.setText("松开发送");
  541 +// mAudioRecordUtil.startRecord();
  542 + downX = event.getX();
  543 + downY = event.getY();
  544 +
  545 + break;
  546 +
  547 + case MotionEvent.ACTION_UP:
  548 +
  549 + if (cancelSendLayout.getVisibility() == View.VISIBLE) {
  550 + cancelSendLayout.setVisibility(View.GONE);
  551 + sendMsgLayout.setVisibility(View.VISIBLE);
  552 + }
  553 + float moveX = Math.abs(event.getX() - downX);
  554 + float moveY = Math.abs(event.getY() - downY);
  555 + if (moveY > 100) {
  556 +// Toast.makeText(ChatRoomActivity.this, "cancel", Toast.LENGTH_SHORT).show();
  557 + mAudioRecordUtil.cancelRecord();
  558 + } else {
  559 + mAudioRecordUtil.stopRecord(); //结束录音(保存录音文件)
  560 + }
  561 + mPop.dismiss();
  562 + mTextView.setText("00:00");
  563 + sendVoice.setText("按住说话");
  564 + break;
  565 + case MotionEvent.ACTION_MOVE:
  566 + float moveXm = Math.abs(event.getX() - downX);
  567 + float moveYm = Math.abs(event.getY() - downY);
  568 + if (moveYm > 100) {
  569 +// Toast.makeText(ChatRoomActivity.this, "cancel", Toast.LENGTH_SHORT).show();
  570 + if (sendMsgLayout.getVisibility() == View.VISIBLE) {
  571 + sendMsgLayout.setVisibility(View.GONE);
  572 + cancelSendLayout.setVisibility(View.VISIBLE);
  573 + }
  574 + } else {
  575 + if (cancelSendLayout.getVisibility() == View.VISIBLE) {
  576 + cancelSendLayout.setVisibility(View.GONE);
  577 + sendMsgLayout.setVisibility(View.VISIBLE);
  578 + }
  579 + }
  580 + break;
  581 + }
  582 + }
  583 + return true;
  584 + }
  585 + });
  586 +
  587 + }
  588 +
  589 + // 判断权限集合
  590 + public boolean lacksPermissions(String... permissions) {
  591 + for (String permission : permissions) {
  592 + if (lacksPermission(permission)) {
  593 + return true;
  594 + }
  595 + }
  596 + return false;
  597 + }
  598 +
  599 + // 判断是否缺少权限
  600 + private boolean lacksPermission(String permission) {
  601 + return ContextCompat.checkSelfPermission(this, permission) == PackageManager.PERMISSION_DENIED;
  602 + }
  603 +
  604 + private AudioRecordUtil.OnAudioStatusUpdateListener onAudioStatusUpdateListener = new AudioRecordUtil.OnAudioStatusUpdateListener() {
  605 + @Override
  606 + public void onUpdate(double db, long time) {
  607 + mImageView.getDrawable().setLevel((int) (3000 + 6000 * db / 100));
  608 + mTextView.setText(TimeUtils.long2String(time));
  609 + }
  610 +
  611 + @Override
  612 + public void onStop(String filePath) {
  613 + duration = (int) mAudioRecordUtil.getDuration();
  614 + mFilePath = filePath;
  615 + ChatUtil.sendVoiceMessage(IChat.PRIVATE, oppositeID, Uri.parse(mFilePath), duration, sendMessageListener);
  616 + }
  617 + };
  618 +
  619 + private TextWatcher textWatcher = new TextWatcher() {
  620 + @Override
  621 + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  622 + }
  623 +
  624 + @Override
  625 + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  626 +
  627 + }
  628 +
  629 + @Override
  630 + public void afterTextChanged(Editable editable) {
  631 + if (!TextUtils.isEmpty(editable)) {
  632 + ima_send.setVisibility(View.GONE);
  633 + sendMessageBtn.setVisibility(View.VISIBLE);
  634 + } else {
  635 + sendMessageBtn.setVisibility(View.GONE);
  636 + ima_send.setVisibility(View.VISIBLE);
  637 + }
  638 + }
  639 + };
  640 +
  641 + @Override
  642 + public void onItemClick(Uri uri) {
  643 + playerUtil.start(uri);
  644 + }
  645 +}
... ...
app/src/main/java/com/cnlive/im/ui/PrivateChatActivity.java
1   -package com.cnlive.im.ui;
2   -
3   -/**
4   - * @author 陈硕
5   - * @time 2017/3/7 14:36
6   - * @desc ${TODD}
7   - */
8   -public class PrivateChatActivity {
9   -/*
10   -
11   - private static final String TAG = "PrivateChatActivity";
12   - private RecyclerView chatListView;
13   - private EditText messageContent;
14   - private Button sendMessageBtn;
15   - private ChatListAdapter chatListAdapter;
16   - private ArrayList<Object> messageList = new ArrayList<>();
17   - private CNMessage cnMessage;
18   - private LinearLayout linearLayoutUseID;
19   - private EditText user_id_edit;
20   - private Button userId_btn_top;
21   - private String oppositeID;
22   - private LinearLayout edit_layout;
23   - private Handler mHandler;
24   - private EditText opposite_name_edit;
25   - private String user_name_string;
26   - private String user_id_string;
27   - private int sendInfo = 3;
28   - private Button agree_btn;
29   - private Button reject_btn;
30   - private LinearLayout agree_reject_lin;
31   - boolean isCanSendMeaasge = false;
32   - private Button vistor_btn;
33   - private ChatRoomAdpter chatRoomAdpter;
34   -
35   -
36   - @Override
37   - protected void onCreate(Bundle savedInstanceState) {
38   - super.onCreate(savedInstanceState);
39   - setContentView(R.layout.activity_private_chat);
40   - initView();
41   - mHandler = new Handler();
42   - ChatUtil.setOnConnectStatusListener(connectStatusListener);
43   - ChatUtil.setOnReceiveMessageListener(receiveMessageListener);
44   - }
45   -
46   - private void initView() {
47   - opposite_name_edit = (EditText) findViewById(R.id.opposite_name_edit);
48   - chatListView = (RecyclerView) findViewById(R.id.private_list_view);
49   -
50   - messageContent = (EditText) findViewById(R.id.message_content);
51   - sendMessageBtn = (Button) findViewById(R.id.send_message);
52   - sendMessageBtn.setOnClickListener(this);
53   - linearLayoutUseID = (LinearLayout) findViewById(R.id.opposite_liner_useID);
54   - userId_btn_top = (Button) findViewById(R.id.userId_btn_top);
55   - userId_btn_top.setOnClickListener(this);
56   - edit_layout = (LinearLayout) findViewById(R.id.edit_layout);
57   - user_id_edit = (EditText) findViewById(opposite_id_edit);
58   - Intent intent = getIntent();
59   - user_name_string = intent.getStringExtra("user_name_string");
60   - user_id_string = intent.getStringExtra("user_id_string");
61   - agree_btn = (Button) findViewById(R.id.agree_btn);
62   - reject_btn = (Button) findViewById(R.id.reject_btn);
63   - agree_btn.setOnClickListener(this);
64   - reject_btn.setOnClickListener(this);
65   - agree_reject_lin = (LinearLayout) findViewById(R.id.agree_reject_lin);
66   - vistor_btn = (Button) findViewById(R.id.vistor_Btn);
67   - vistor_btn.setOnClickListener(this);
68   - chatRoomAdpter = new ChatRoomAdpter(this);
69   - chatListView.setLayoutManager(new LinearLayoutManager(this));
70   - chatListView.setAdapter(chatRoomAdpter);
71   - }
72   -
73   -
74   - @Override
75   - public void onClick(View v) {
76   -
77   - switch (v.getId()) {
78   - case R.id.send_message:
79   - //发送私聊消息,需要传入目标ID与发送的消息内容
80   - if (sendInfo == 2) {
81   - Toast.makeText(this, "等待对方接受邀请", Toast.LENGTH_SHORT).show();
82   -
83   - } else if (sendInfo == 4) {
84   - Toast.makeText(this, "对方已经拒绝不能发送", Toast.LENGTH_SHORT).show();
85   -
86   - } else if (sendInfo == 3) {
87   - Toast.makeText(this, "还没有邀请对方呦~", Toast.LENGTH_SHORT).show();
88   - } else if (sendInfo == 5) {
89   - Toast.makeText(this, "你已经拒绝对方不能发送消息", Toast.LENGTH_SHORT).show();
90   - } else {
91   - if (messageContent.getText().toString().isEmpty()) {
92   - Toast.makeText(this, "不能发送空消息呦~", Toast.LENGTH_SHORT).show();
93   - } else {
94   - String objToJsonString = ToStringUtils.objToJsonString(new CNMessageModole(messageContent.getText().toString(), "4"));//私聊消息
95   - ChatUtil.sendMessage(IChat.PRIVATE, oppositeID, objToJsonString, sendMessageListener);
96   - messageContent.setText("");
97   - }
98   - }
99   -
100   - break;
101   -
102   - case R.id.userId_btn_top:
103   - //发送私聊消息,需要传入目标ID与发送的消息内容
104   - if (user_id_edit.getText().toString().isEmpty()) {
105   - Toast.makeText(this, "对方ID不能为空", Toast.LENGTH_SHORT).show();
106   - } else if (opposite_name_edit.getText().toString().isEmpty()) {
107   - Toast.makeText(this, "对方name不能为空", Toast.LENGTH_SHORT).show();
108   - } else {
109   -
110   - oppositeID = user_id_edit.getText().toString();
111   - linearLayoutUseID.setVisibility(View.INVISIBLE);
112   - edit_layout.setVisibility(View.VISIBLE);
113   - chatListView.setVisibility(View.VISIBLE);
114   - CNUserInfo cnName = new CNUserInfo(user_id_string, user_name_string, "");
115   - ChatUtil.login(cnName, connectListener);
116   -
117   - }
118   -
119   - break;
120   -
121   - case R.id.agree_btn:
122   - String objToJsonString = ToStringUtils.objToJsonString(new CNMessageModole("同意", "3"));
123   - ChatUtil.sendMessage(IChat.PRIVATE, oppositeID, objToJsonString, sendMessageListener);
124   - agree_reject_lin.setVisibility(View.GONE);
125   - break;
126   -
127   - case R.id.reject_btn:
128   - String objToJsonStringDis = ToStringUtils.objToJsonString(new CNMessageModole("拒绝", "3"));//私聊
129   -
130   - ChatUtil.sendMessage(IChat.PRIVATE, oppositeID, objToJsonStringDis, sendMessageListener);
131   - agree_reject_lin.setVisibility(View.GONE);
132   - break;
133   - case R.id.vistor_Btn:
134   - String objToJsonStringInvt = ToStringUtils.objToJsonString(new CNMessageModole("你好我们可以进行私聊吗", "3"));//私聊
135   - ChatUtil.sendMessage(IChat.PRIVATE, oppositeID, objToJsonStringInvt, sendMessageListener);
136   -
137   - break;
138   - }
139   - }
140   -
141   -
142   - //连接监听
143   - private IChat.OnConnectListener connectListener = new IChat.OnConnectListener() {
144   -
145   -
146   - @Override
147   - public void onTokenIncorrect(String s) {
148   - Log.e(TAG, "ConnectListener TokenIncorrect");
149   - Toast.makeText(PrivateChatActivity.this, "TokenIncorrect", Toast.LENGTH_SHORT).show();
150   - }
151   -
152   - @Override
153   - public void onSuccess(String s) {
154   - Log.e(TAG, "ConnectListener 连接监听" + s);
155   - Toast.makeText(PrivateChatActivity.this, s, Toast.LENGTH_SHORT).show();
156   -
157   - }
158   -
159   - @Override
160   - public void onError(int i, String s) {
161   - Log.e(TAG, "ConnectListener errorCode : " + i + " : errorMessage : " + s);
162   - Toast.makeText(PrivateChatActivity.this, s, Toast.LENGTH_SHORT).show();
163   -
164   - }
165   - };
166   -
167   -
168   - *//**
169   - * 发送消息监听
170   - *//*
171   -
172   - private IChat.OnSendMessageListener sendMessageListener = new IChat.OnSendMessageListener() {
173   - @Override
174   - public void onAttached(Object o) {
175   -
176   - }
177   -
178   - @Override
179   - public void onSuccess(final Object o) throws JSONException {
180   -
181   -
182   - if (View.VISIBLE == vistor_btn.getVisibility()) {
183   - vistor_btn.setVisibility(View.GONE);
184   - }
185   - mHandler.post(new Runnable() {
186   - @Override
187   - public void run() {
188   - JSONObject jsonObject = null;
189   - if (o instanceof CNMessage) {
190   - final CNMessage cnMessage = (CNMessage) o;
191   - try {
192   - jsonObject = new JSONObject(cnMessage.getContent().toString());
193   - String type = (String) jsonObject.get("type");
194   - String message = (String) jsonObject.get("message");
195   - Toast.makeText(PrivateChatActivity.this, "发送消息成功", Toast.LENGTH_SHORT).show();
196   - if ("3".equals(type) && message.equals("你好我们可以进行私聊吗")) {
197   - sendInfo = 2;
198   - Toast.makeText(PrivateChatActivity.this, "申请已发送等待对方验证", Toast.LENGTH_SHORT).show();
199   - } else if ("3".equals(type) && message.equals("拒绝")) {
200   - sendInfo = 5;
201   - } else if ("3".equals(type) && message.equals("同意")) {
202   - sendInfo = 1;
203   - } else if ("4".equals(type)) {
204   - messageList.add(new StringMessage(MessageType.stringMessage, cnMessage, true));
205   - }
206   - } catch (JSONException e) {
207   -
208   -
209   - }
210   -
211   - }
212   -
213   -
214   - }
215   - });
216   - }
217   -
218   - @Override
219   - public void onError(Object o, int i, String s) {
220   -
221   - }
222   - };
223   -
224   -
225   - //连接状态监听
226   - private IChat.OnConnectStatusListener connectStatusListener = new IChat.OnConnectStatusListener() {
227   - @Override
228   - public void onConnectStatus(int i, String s) {
229   - Log.i(TAG, "私聊连接状态监听私聊" + i + " " + s);
230   -
231   -
232   - }
233   - };
234   - //接收消息监听
235   - private IChat.OnReceiveMessageListener receiveMessageListener = new IChat.OnReceiveMessageListener() {
236   - @Override
237   - public void processMessage(Object o) {
238   - final CNMessage cnMessage = (CNMessage) o;
239   - mHandler.post(new Runnable() {
240   - @Override
241   - public void run() {
242   - Log.v("cnMessage", cnMessage.getTargetId() + "," + cnMessage.getUserInfo().getUserId());
243   - JSONObject jsonObject = null;
244   - try {
245   - jsonObject = new JSONObject(cnMessage.getContent().toString());
246   - String type = (String) jsonObject.get("type");
247   - if ("3".equals(type) && "你好我们可以进行私聊吗".equals(jsonObject.get("message"))) {
248   - vistor_btn.setVisibility(View.GONE);
249   - agree_reject_lin.setVisibility(View.VISIBLE);
250   - } else if ("3".equals(type) && "同意".equals(jsonObject.get("message"))) {
251   - sendInfo = 1;
252   - } else if ("3".equals(type) && "拒绝".equals(jsonObject.get("message"))) {
253   - sendInfo = 4;
254   - } else if ("4".equals(type)) {
255   - Log.v(TAG, cnMessage.getContent().toString());
256   - messageList.add(new StringMessage(MessageType.stringMessage, cnMessage, false));
257   -
258   - }
259   -
260   - } catch (JSONException e) {
261   - e.printStackTrace();
262   - }
263   -
264   -
265   - }
266   - });
267   -
268   - }
269   - };*/
270   -
271   -
272   -}
273   -
  1 +//package com.cnlive.im.ui;
  2 +//
  3 +///**
  4 +// * @author 陈硕
  5 +// * @time 2017/3/7 14:36
  6 +// * @desc ${TODD}
  7 +// */
  8 +//public class PrivateChatActivity {
  9 +///*
  10 +//
  11 +// private static final String TAG = "PrivateChatActivity";
  12 +// private RecyclerView chatListView;
  13 +// private EditText messageContent;
  14 +// private Button sendMessageBtn;
  15 +// private ChatListAdapter chatListAdapter;
  16 +// private ArrayList<Object> messageList = new ArrayList<>();
  17 +// private CNMessage cnMessage;
  18 +// private LinearLayout linearLayoutUseID;
  19 +// private EditText user_id_edit;
  20 +// private Button userId_btn_top;
  21 +// private String oppositeID;
  22 +// private LinearLayout edit_layout;
  23 +// private Handler mHandler;
  24 +// private EditText opposite_name_edit;
  25 +// private String user_name_string;
  26 +// private String user_id_string;
  27 +// private int sendInfo = 3;
  28 +// private Button agree_btn;
  29 +// private Button reject_btn;
  30 +// private LinearLayout agree_reject_lin;
  31 +// boolean isCanSendMeaasge = false;
  32 +// private Button vistor_btn;
  33 +// private ChatRoomAdpter chatRoomAdpter;
  34 +//
  35 +//
  36 +// @Override
  37 +// protected void onCreate(Bundle savedInstanceState) {
  38 +// super.onCreate(savedInstanceState);
  39 +// setContentView(R.layout.activity_private_chat);
  40 +// initView();
  41 +// mHandler = new Handler();
  42 +// ChatUtil.setOnConnectStatusListener(connectStatusListener);
  43 +// ChatUtil.setOnReceiveMessageListener(receiveMessageListener);
  44 +// }
  45 +//
  46 +// private void initView() {
  47 +// opposite_name_edit = (EditText) findViewById(R.id.opposite_name_edit);
  48 +// chatListView = (RecyclerView) findViewById(R.id.private_list_view);
  49 +//
  50 +// messageContent = (EditText) findViewById(R.id.message_content);
  51 +// sendMessageBtn = (Button) findViewById(R.id.send_message);
  52 +// sendMessageBtn.setOnClickListener(this);
  53 +// linearLayoutUseID = (LinearLayout) findViewById(R.id.opposite_liner_useID);
  54 +// userId_btn_top = (Button) findViewById(R.id.userId_btn_top);
  55 +// userId_btn_top.setOnClickListener(this);
  56 +// edit_layout = (LinearLayout) findViewById(R.id.edit_layout);
  57 +// user_id_edit = (EditText) findViewById(opposite_id_edit);
  58 +// Intent intent = getIntent();
  59 +// user_name_string = intent.getStringExtra("user_name_string");
  60 +// user_id_string = intent.getStringExtra("user_id_string");
  61 +// agree_btn = (Button) findViewById(R.id.agree_btn);
  62 +// reject_btn = (Button) findViewById(R.id.reject_btn);
  63 +// agree_btn.setOnClickListener(this);
  64 +// reject_btn.setOnClickListener(this);
  65 +// agree_reject_lin = (LinearLayout) findViewById(R.id.agree_reject_lin);
  66 +// vistor_btn = (Button) findViewById(R.id.vistor_Btn);
  67 +// vistor_btn.setOnClickListener(this);
  68 +// chatRoomAdpter = new ChatRoomAdpter(this);
  69 +// chatListView.setLayoutManager(new LinearLayoutManager(this));
  70 +// chatListView.setAdapter(chatRoomAdpter);
  71 +// }
  72 +//
  73 +//
  74 +// @Override
  75 +// public void onClick(View v) {
  76 +//
  77 +// switch (v.getId()) {
  78 +// case R.id.send_message:
  79 +// //发送私聊消息,需要传入目标ID与发送的消息内容
  80 +// if (sendInfo == 2) {
  81 +// Toast.makeText(this, "等待对方接受邀请", Toast.LENGTH_SHORT).show();
  82 +//
  83 +// } else if (sendInfo == 4) {
  84 +// Toast.makeText(this, "对方已经拒绝不能发送", Toast.LENGTH_SHORT).show();
  85 +//
  86 +// } else if (sendInfo == 3) {
  87 +// Toast.makeText(this, "还没有邀请对方呦~", Toast.LENGTH_SHORT).show();
  88 +// } else if (sendInfo == 5) {
  89 +// Toast.makeText(this, "你已经拒绝对方不能发送消息", Toast.LENGTH_SHORT).show();
  90 +// } else {
  91 +// if (messageContent.getText().toString().isEmpty()) {
  92 +// Toast.makeText(this, "不能发送空消息呦~", Toast.LENGTH_SHORT).show();
  93 +// } else {
  94 +// String objToJsonString = ToStringUtils.objToJsonString(new CNMessageModole(messageContent.getText().toString(), "4"));//私聊消息
  95 +// ChatUtil.sendMessage(IChat.PRIVATE, oppositeID, objToJsonString, sendMessageListener);
  96 +// messageContent.setText("");
  97 +// }
  98 +// }
  99 +//
  100 +// break;
  101 +//
  102 +// case R.id.userId_btn_top:
  103 +// //发送私聊消息,需要传入目标ID与发送的消息内容
  104 +// if (user_id_edit.getText().toString().isEmpty()) {
  105 +// Toast.makeText(this, "对方ID不能为空", Toast.LENGTH_SHORT).show();
  106 +// } else if (opposite_name_edit.getText().toString().isEmpty()) {
  107 +// Toast.makeText(this, "对方name不能为空", Toast.LENGTH_SHORT).show();
  108 +// } else {
  109 +//
  110 +// oppositeID = user_id_edit.getText().toString();
  111 +// linearLayoutUseID.setVisibility(View.INVISIBLE);
  112 +// edit_layout.setVisibility(View.VISIBLE);
  113 +// chatListView.setVisibility(View.VISIBLE);
  114 +// CNUserInfo cnName = new CNUserInfo(user_id_string, user_name_string, "");
  115 +// ChatUtil.login(cnName, connectListener);
  116 +//
  117 +// }
  118 +//
  119 +// break;
  120 +//
  121 +// case R.id.agree_btn:
  122 +// String objToJsonString = ToStringUtils.objToJsonString(new CNMessageModole("同意", "3"));
  123 +// ChatUtil.sendMessage(IChat.PRIVATE, oppositeID, objToJsonString, sendMessageListener);
  124 +// agree_reject_lin.setVisibility(View.GONE);
  125 +// break;
  126 +//
  127 +// case R.id.reject_btn:
  128 +// String objToJsonStringDis = ToStringUtils.objToJsonString(new CNMessageModole("拒绝", "3"));//私聊
  129 +//
  130 +// ChatUtil.sendMessage(IChat.PRIVATE, oppositeID, objToJsonStringDis, sendMessageListener);
  131 +// agree_reject_lin.setVisibility(View.GONE);
  132 +// break;
  133 +// case R.id.vistor_Btn:
  134 +// String objToJsonStringInvt = ToStringUtils.objToJsonString(new CNMessageModole("你好我们可以进行私聊吗", "3"));//私聊
  135 +// ChatUtil.sendMessage(IChat.PRIVATE, oppositeID, objToJsonStringInvt, sendMessageListener);
  136 +//
  137 +// break;
  138 +// }
  139 +// }
  140 +//
  141 +//
  142 +// //连接监听
  143 +// private IChat.OnConnectListener connectListener = new IChat.OnConnectListener() {
  144 +//
  145 +//
  146 +// @Override
  147 +// public void onTokenIncorrect(String s) {
  148 +// Log.e(TAG, "ConnectListener TokenIncorrect");
  149 +// Toast.makeText(PrivateChatActivity.this, "TokenIncorrect", Toast.LENGTH_SHORT).show();
  150 +// }
  151 +//
  152 +// @Override
  153 +// public void onSuccess(String s) {
  154 +// Log.e(TAG, "ConnectListener 连接监听" + s);
  155 +// Toast.makeText(PrivateChatActivity.this, s, Toast.LENGTH_SHORT).show();
  156 +//
  157 +// }
  158 +//
  159 +// @Override
  160 +// public void onError(int i, String s) {
  161 +// Log.e(TAG, "ConnectListener errorCode : " + i + " : errorMessage : " + s);
  162 +// Toast.makeText(PrivateChatActivity.this, s, Toast.LENGTH_SHORT).show();
  163 +//
  164 +// }
  165 +// };
  166 +//
  167 +//
  168 +// *//**
  169 +// * 发送消息监听
  170 +// *//*
  171 +//
  172 +// private IChat.OnSendMessageListener sendMessageListener = new IChat.OnSendMessageListener() {
  173 +// @Override
  174 +// public void onAttached(Object o) {
  175 +//
  176 +// }
  177 +//
  178 +// @Override
  179 +// public void onSuccess(final Object o) throws JSONException {
  180 +//
  181 +//
  182 +// if (View.VISIBLE == vistor_btn.getVisibility()) {
  183 +// vistor_btn.setVisibility(View.GONE);
  184 +// }
  185 +// mHandler.post(new Runnable() {
  186 +// @Override
  187 +// public void run() {
  188 +// JSONObject jsonObject = null;
  189 +// if (o instanceof CNMessage) {
  190 +// final CNMessage cnMessage = (CNMessage) o;
  191 +// try {
  192 +// jsonObject = new JSONObject(cnMessage.getContent().toString());
  193 +// String type = (String) jsonObject.get("type");
  194 +// String message = (String) jsonObject.get("message");
  195 +// Toast.makeText(PrivateChatActivity.this, "发送消息成功", Toast.LENGTH_SHORT).show();
  196 +// if ("3".equals(type) && message.equals("你好我们可以进行私聊吗")) {
  197 +// sendInfo = 2;
  198 +// Toast.makeText(PrivateChatActivity.this, "申请已发送等待对方验证", Toast.LENGTH_SHORT).show();
  199 +// } else if ("3".equals(type) && message.equals("拒绝")) {
  200 +// sendInfo = 5;
  201 +// } else if ("3".equals(type) && message.equals("同意")) {
  202 +// sendInfo = 1;
  203 +// } else if ("4".equals(type)) {
  204 +// messageList.add(new StringMessage(MessageType.stringMessage, cnMessage, true));
  205 +// }
  206 +// } catch (JSONException e) {
  207 +//
  208 +//
  209 +// }
  210 +//
  211 +// }
  212 +//
  213 +//
  214 +// }
  215 +// });
  216 +// }
  217 +//
  218 +// @Override
  219 +// public void onError(Object o, int i, String s) {
  220 +//
  221 +// }
  222 +// };
  223 +//
  224 +//
  225 +// //连接状态监听
  226 +// private IChat.OnConnectStatusListener connectStatusListener = new IChat.OnConnectStatusListener() {
  227 +// @Override
  228 +// public void onConnectStatus(int i, String s) {
  229 +// Log.i(TAG, "私聊连接状态监听私聊" + i + " " + s);
  230 +//
  231 +//
  232 +// }
  233 +// };
  234 +// //接收消息监听
  235 +// private IChat.OnReceiveMessageListener receiveMessageListener = new IChat.OnReceiveMessageListener() {
  236 +// @Override
  237 +// public void processMessage(Object o) {
  238 +// final CNMessage cnMessage = (CNMessage) o;
  239 +// mHandler.post(new Runnable() {
  240 +// @Override
  241 +// public void run() {
  242 +// Log.v("cnMessage", cnMessage.getTargetId() + "," + cnMessage.getUserInfo().getUserId());
  243 +// JSONObject jsonObject = null;
  244 +// try {
  245 +// jsonObject = new JSONObject(cnMessage.getContent().toString());
  246 +// String type = (String) jsonObject.get("type");
  247 +// if ("3".equals(type) && "你好我们可以进行私聊吗".equals(jsonObject.get("message"))) {
  248 +// vistor_btn.setVisibility(View.GONE);
  249 +// agree_reject_lin.setVisibility(View.VISIBLE);
  250 +// } else if ("3".equals(type) && "同意".equals(jsonObject.get("message"))) {
  251 +// sendInfo = 1;
  252 +// } else if ("3".equals(type) && "拒绝".equals(jsonObject.get("message"))) {
  253 +// sendInfo = 4;
  254 +// } else if ("4".equals(type)) {
  255 +// Log.v(TAG, cnMessage.getContent().toString());
  256 +// messageList.add(new StringMessage(MessageType.stringMessage, cnMessage, false));
  257 +//
  258 +// }
  259 +//
  260 +// } catch (JSONException e) {
  261 +// e.printStackTrace();
  262 +// }
  263 +//
  264 +//
  265 +// }
  266 +// });
  267 +//
  268 +// }
  269 +// };*/
  270 +//
  271 +//
  272 +//}
  273 +//
... ...
app/src/main/java/com/cnlive/im/ui/UserLoginActivity.java
... ... @@ -50,7 +50,7 @@ public class UserLoginActivity extends AppCompatActivity implements View.OnClick
50 50 doIntentChatRoom(ChatRoomActivity.class);
51 51 break;
52 52 case R.id.private_chat:
53   - doIntentChatRoom(PrivateChatActivity.class);
  53 + doIntentChatRoom(PrivateActivity.class);
54 54  
55 55 break;
56 56 }
... ...
app/src/main/res/layout/activity_private_chat.xml
... ... @@ -2,7 +2,8 @@
2 2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 3 android:id="@+id/activity_private_chat"
4 4 android:layout_width="match_parent"
5   - android:layout_height="match_parent">
  5 + android:layout_height="match_parent"
  6 + android:clickable="true">
6 7  
7 8 <LinearLayout
8 9 android:layout_width="match_parent"
... ... @@ -37,16 +38,45 @@
37 38  
38 39  
39 40 <LinearLayout
  41 + android:id="@+id/edit_layout_se"
40 42 android:layout_width="match_parent"
41 43 android:layout_height="wrap_content"
  44 + android:layout_alignParentBottom="true"
42 45 android:orientation="horizontal">
43 46  
  47 + <ImageView
  48 + android:id="@+id/keybord"
  49 + android:layout_width="0dp"
  50 + android:layout_height="wrap_content"
  51 + android:layout_gravity="center_vertical"
  52 + android:layout_weight="0.1"
  53 + android:src="@drawable/voice" />
  54 +
44 55 <EditText
45 56 android:id="@+id/message_content"
46 57 android:layout_width="0dp"
47 58 android:layout_height="wrap_content"
48 59 android:layout_gravity="center"
49   - android:layout_weight="0.7" />
  60 + android:layout_weight="0.6" />
  61 +
  62 + <Button
  63 + android:id="@+id/send_voice"
  64 + android:layout_width="0dp"
  65 + android:layout_height="40dp"
  66 + android:layout_margin="10dp"
  67 + android:layout_weight="0.6"
  68 + android:background="@drawable/voice_bg"
  69 + android:text="按住说话"
  70 + android:visibility="gone" />
  71 +
  72 + <ImageView
  73 + android:id="@+id/ima_send"
  74 + android:layout_width="0dp"
  75 + android:layout_height="wrap_content"
  76 + android:layout_gravity="center_vertical"
  77 + android:layout_weight="0.1"
  78 + android:src="@drawable/pic"
  79 + android:visibility="visible" />
50 80  
51 81 <Button
52 82 android:id="@+id/send_message"
... ... @@ -54,9 +84,10 @@
54 84 android:layout_height="wrap_content"
55 85 android:layout_gravity="center"
56 86 android:layout_weight="0.2"
57   - android:text="发送" />
58   - </LinearLayout>
  87 + android:text="发送"
  88 + android:visibility="gone" />
59 89  
  90 + </LinearLayout>
60 91 </LinearLayout>
61 92  
62 93  
... ... @@ -135,8 +166,8 @@
135 166 <TextView
136 167 android:layout_width="match_parent"
137 168 android:layout_height="wrap_content"
138   - android:text="有人请求和您进行私聊"
139   - android:gravity="center"/>
  169 + android:gravity="center"
  170 + android:text="有人请求和您进行私聊" />
140 171  
141 172 <LinearLayout
142 173 android:layout_width="wrap_content"
... ... @@ -144,16 +175,16 @@
144 175  
145 176 <Button
146 177 android:id="@+id/agree_btn"
147   - android:background="#00000000"
148 178 android:layout_width="wrap_content"
149 179 android:layout_height="wrap_content"
  180 + android:background="#00000000"
150 181 android:text="同意" />
151 182  
152 183 <Button
153 184 android:id="@+id/reject_btn"
154   - android:background="#00000000"
155 185 android:layout_width="wrap_content"
156 186 android:layout_height="wrap_content"
  187 + android:background="#00000000"
157 188 android:text="拒绝" />
158 189 </LinearLayout>
159 190  
... ...