|
@@ -24,12 +24,11 @@ import android.view.inputmethod.InputMethodManager;
|
|
import android.webkit.MimeTypeMap;
|
|
import android.webkit.MimeTypeMap;
|
|
import android.widget.Button;
|
|
import android.widget.Button;
|
|
import android.widget.EditText;
|
|
import android.widget.EditText;
|
|
|
|
+import android.widget.FrameLayout;
|
|
import android.widget.ImageView;
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
-import androidx.annotation.Nullable;
|
|
|
|
-import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
-import androidx.fragment.app.FragmentManager;
|
|
|
|
|
|
+
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.JsonSyntaxException;
|
|
import com.google.gson.JsonSyntaxException;
|
|
import com.tencent.imsdk.v2.V2TIMManager;
|
|
import com.tencent.imsdk.v2.V2TIMManager;
|
|
@@ -68,6 +67,7 @@ import com.tencent.qcloud.tuikit.tuichat.util.ChatMessageParser;
|
|
import com.tencent.qcloud.tuikit.tuichat.util.PermissionHelper;
|
|
import com.tencent.qcloud.tuikit.tuichat.util.PermissionHelper;
|
|
import com.tencent.qcloud.tuikit.tuichat.util.TUIChatLog;
|
|
import com.tencent.qcloud.tuikit.tuichat.util.TUIChatLog;
|
|
import com.tencent.qcloud.tuikit.tuichat.util.TUIChatUtils;
|
|
import com.tencent.qcloud.tuikit.tuichat.util.TUIChatUtils;
|
|
|
|
+
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
@@ -76,9 +76,13 @@ import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
+import androidx.annotation.Nullable;
|
|
|
|
+import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
+import androidx.fragment.app.FragmentManager;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 聊天界面,底部发送图片、拍照、摄像、文件面板
|
|
* 聊天界面,底部发送图片、拍照、摄像、文件面板
|
|
- *
|
|
|
|
|
|
+ * <p>
|
|
* Chat interface, send pictures, take pictures, video, file panels at the bottom
|
|
* Chat interface, send pictures, take pictures, video, file panels at the bottom
|
|
*/
|
|
*/
|
|
|
|
|
|
@@ -97,7 +101,7 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
|
|
|
|
|
/**
|
|
/**
|
|
* 语音/文字切换输入控件
|
|
* 语音/文字切换输入控件
|
|
- *
|
|
|
|
|
|
+ * <p>
|
|
* Voice/text switch input controls
|
|
* Voice/text switch input controls
|
|
*/
|
|
*/
|
|
protected ImageView mAudioInputSwitchButton;
|
|
protected ImageView mAudioInputSwitchButton;
|
|
@@ -105,7 +109,7 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
|
|
|
|
|
/**
|
|
/**
|
|
* 表情按钮
|
|
* 表情按钮
|
|
- *
|
|
|
|
|
|
+ * <p>
|
|
* emoji button
|
|
* emoji button
|
|
*/
|
|
*/
|
|
protected ImageView mEmojiInputButton;
|
|
protected ImageView mEmojiInputButton;
|
|
@@ -113,7 +117,7 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
|
|
|
|
|
/**
|
|
/**
|
|
* 更多按钮
|
|
* 更多按钮
|
|
- *
|
|
|
|
|
|
+ * <p>
|
|
* more button
|
|
* more button
|
|
*/
|
|
*/
|
|
protected ImageView mMoreInputButton;
|
|
protected ImageView mMoreInputButton;
|
|
@@ -122,21 +126,21 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
|
|
|
|
|
/**
|
|
/**
|
|
* 消息发送按钮
|
|
* 消息发送按钮
|
|
- *
|
|
|
|
|
|
+ * <p>
|
|
* message send button
|
|
* message send button
|
|
*/
|
|
*/
|
|
protected TextView mSendTextButton;
|
|
protected TextView mSendTextButton;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 语音长按按钮
|
|
* 语音长按按钮
|
|
- *
|
|
|
|
|
|
+ * <p>
|
|
* voice send button
|
|
* voice send button
|
|
*/
|
|
*/
|
|
protected Button mSendAudioButton;
|
|
protected Button mSendAudioButton;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 文本输入框
|
|
* 文本输入框
|
|
- *
|
|
|
|
|
|
+ * <p>
|
|
* input text
|
|
* input text
|
|
*/
|
|
*/
|
|
protected TIMMentionEditText mTextInput;
|
|
protected TIMMentionEditText mTextInput;
|
|
@@ -184,6 +188,7 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
|
private ImageView quoteCloseBtn;
|
|
private ImageView quoteCloseBtn;
|
|
private boolean isShowCustomFace = true;
|
|
private boolean isShowCustomFace = true;
|
|
private ChatInputMoreListener chatInputMoreListener;
|
|
private ChatInputMoreListener chatInputMoreListener;
|
|
|
|
+ private FrameLayout mFlMute;
|
|
|
|
|
|
public InputView(Context context) {
|
|
public InputView(Context context) {
|
|
super(context);
|
|
super(context);
|
|
@@ -222,6 +227,8 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
|
quoteTv = quotePreviewBar.findViewById(R.id.reply_text);
|
|
quoteTv = quotePreviewBar.findViewById(R.id.reply_text);
|
|
quoteCloseBtn = quotePreviewBar.findViewById(R.id.reply_close_btn);
|
|
quoteCloseBtn = quotePreviewBar.findViewById(R.id.reply_close_btn);
|
|
|
|
|
|
|
|
+ mFlMute = findViewById(R.id.fl_mute);
|
|
|
|
+
|
|
int iconSize = getResources().getDimensionPixelSize(R.dimen.chat_input_icon_size);
|
|
int iconSize = getResources().getDimensionPixelSize(R.dimen.chat_input_icon_size);
|
|
ViewGroup.LayoutParams layoutParams = mEmojiInputButton.getLayoutParams();
|
|
ViewGroup.LayoutParams layoutParams = mEmojiInputButton.getLayoutParams();
|
|
layoutParams.width = iconSize;
|
|
layoutParams.width = iconSize;
|
|
@@ -312,7 +319,8 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void onVoiceDb(double db) {}
|
|
|
|
|
|
+ public void onVoiceDb(double db) {
|
|
|
|
+ }
|
|
});
|
|
});
|
|
break;
|
|
break;
|
|
case MotionEvent.ACTION_MOVE:
|
|
case MotionEvent.ACTION_MOVE:
|
|
@@ -358,7 +366,7 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
|
@Override
|
|
@Override
|
|
public void onMentionCharacterInput(String tag) {
|
|
public void onMentionCharacterInput(String tag) {
|
|
if ((tag.equals(TIMMentionEditText.TIM_MENTION_TAG) || tag.equals(TIMMentionEditText.TIM_MENTION_TAG_FULL))
|
|
if ((tag.equals(TIMMentionEditText.TIM_MENTION_TAG) || tag.equals(TIMMentionEditText.TIM_MENTION_TAG_FULL))
|
|
- && TUIChatUtils.isGroupChat(mChatLayout.getChatInfo().getType())) {
|
|
|
|
|
|
+ && TUIChatUtils.isGroupChat(mChatLayout.getChatInfo().getType())) {
|
|
if (mOnInputViewListener != null) {
|
|
if (mOnInputViewListener != null) {
|
|
mOnInputViewListener.onStartGroupMemberSelectActivity();
|
|
mOnInputViewListener.onStartGroupMemberSelectActivity();
|
|
}
|
|
}
|
|
@@ -379,18 +387,27 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
|
exitReply();
|
|
exitReply();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ mFlMute.setOnClickListener(this);
|
|
}
|
|
}
|
|
|
|
|
|
public void addInputText(String name, String id) {
|
|
public void addInputText(String name, String id) {
|
|
if (id == null || id.isEmpty()) {
|
|
if (id == null || id.isEmpty()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ if (isMute()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
ArrayList<String> nameList = new ArrayList<String>() {
|
|
ArrayList<String> nameList = new ArrayList<String>() {
|
|
- { add(name); }
|
|
|
|
|
|
+ {
|
|
|
|
+ add(name);
|
|
|
|
+ }
|
|
};
|
|
};
|
|
ArrayList<String> idList = new ArrayList<String>() {
|
|
ArrayList<String> idList = new ArrayList<String>() {
|
|
- { add(id); }
|
|
|
|
|
|
+ {
|
|
|
|
+ add(id);
|
|
|
|
+ }
|
|
};
|
|
};
|
|
|
|
|
|
updateAtUserInfoMap(nameList, idList);
|
|
updateAtUserInfoMap(nameList, idList);
|
|
@@ -508,15 +525,16 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
|
protected void startSendPhoto() {
|
|
protected void startSendPhoto() {
|
|
TUIChatLog.i(TAG, "startSendPhoto");
|
|
TUIChatLog.i(TAG, "startSendPhoto");
|
|
ActivityResultResolver.getMultipleContent(mInputMoreFragment.getActivity(),
|
|
ActivityResultResolver.getMultipleContent(mInputMoreFragment.getActivity(),
|
|
- new String[] {ActivityResultResolver.CONTENT_TYPE_IMAGE, ActivityResultResolver.CONTENT_TYPE_VIDEO}, new TUIValueCallback<List<Uri>>() {
|
|
|
|
- @Override
|
|
|
|
- public void onSuccess(List<Uri> uris) {
|
|
|
|
- ThreadUtils.runOnUiThread(() -> sendPhotoVideoMessage(uris));
|
|
|
|
- }
|
|
|
|
|
|
+ new String[]{ActivityResultResolver.CONTENT_TYPE_IMAGE, ActivityResultResolver.CONTENT_TYPE_VIDEO}, new TUIValueCallback<List<Uri>>() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onSuccess(List<Uri> uris) {
|
|
|
|
+ ThreadUtils.runOnUiThread(() -> sendPhotoVideoMessage(uris));
|
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
|
- public void onError(int errorCode, String errorMessage) {}
|
|
|
|
- });
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void onError(int errorCode, String errorMessage) {
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
private void sendPhotoVideoMessage(List<Uri> uris) {
|
|
private void sendPhotoVideoMessage(List<Uri> uris) {
|
|
@@ -676,7 +694,8 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void onError(int errorCode, String errorMessage) {}
|
|
|
|
|
|
+ public void onError(int errorCode, String errorMessage) {
|
|
|
|
+ }
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -749,7 +768,8 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void onError(int errorCode, String errorMessage) {}
|
|
|
|
|
|
+ public void onError(int errorCode, String errorMessage) {
|
|
|
|
+ }
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -766,7 +786,7 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
|
if (videoUri != null) {
|
|
if (videoUri != null) {
|
|
List list = new ArrayList();
|
|
List list = new ArrayList();
|
|
list.add(videoUri);
|
|
list.add(videoUri);
|
|
- sendPhotoVideoMessage(list);
|
|
|
|
|
|
+ ThreadUtils.runOnUiThread(() -> sendPhotoVideoMessage(list));
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -791,7 +811,8 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void onError(int errorCode, String errorMessage) {}
|
|
|
|
|
|
+ public void onError(int errorCode, String errorMessage) {
|
|
|
|
+ }
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -814,8 +835,8 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
|
@Override
|
|
@Override
|
|
public void onClick(View view) {
|
|
public void onClick(View view) {
|
|
TUIChatLog.i(TAG,
|
|
TUIChatLog.i(TAG,
|
|
- "onClick id:" + view.getId() + "|voice_input_switch:" + R.id.voice_input_switch + "|face_btn:" + R.id.face_btn + "|more_btn:" + R.id.more_btn
|
|
|
|
- + "|send_btn:" + R.id.send_btn + "|mCurrentState:" + mCurrentState + "|mSendEnable:" + mSendEnable + "|mMoreInputEvent:" + mMoreInputEvent);
|
|
|
|
|
|
+ "onClick id:" + view.getId() + "|voice_input_switch:" + R.id.voice_input_switch + "|face_btn:" + R.id.face_btn + "|more_btn:" + R.id.more_btn
|
|
|
|
+ + "|send_btn:" + R.id.send_btn + "|mCurrentState:" + mCurrentState + "|mSendEnable:" + mSendEnable + "|mMoreInputEvent:" + mMoreInputEvent);
|
|
if (view.getId() == R.id.voice_input_switch) {
|
|
if (view.getId() == R.id.voice_input_switch) {
|
|
if (mCurrentState == STATE_FACE_INPUT || mCurrentState == STATE_ACTION_INPUT) {
|
|
if (mCurrentState == STATE_FACE_INPUT || mCurrentState == STATE_ACTION_INPUT) {
|
|
mCurrentState = STATE_VOICE_INPUT;
|
|
mCurrentState = STATE_VOICE_INPUT;
|
|
@@ -857,8 +878,8 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
|
}
|
|
}
|
|
} else if (view.getId() == R.id.more_btn) {
|
|
} else if (view.getId() == R.id.more_btn) {
|
|
hideSoftInput();
|
|
hideSoftInput();
|
|
- if (mMoreInputEvent instanceof View.OnClickListener) {
|
|
|
|
- ((View.OnClickListener) mMoreInputEvent).onClick(view);
|
|
|
|
|
|
+ if (mMoreInputEvent instanceof OnClickListener) {
|
|
|
|
+ ((OnClickListener) mMoreInputEvent).onClick(view);
|
|
} else if (mMoreInputEvent instanceof BaseInputFragment) {
|
|
} else if (mMoreInputEvent instanceof BaseInputFragment) {
|
|
showCustomInputMoreFragment();
|
|
showCustomInputMoreFragment();
|
|
} else {
|
|
} else {
|
|
@@ -884,7 +905,7 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
|
if (TUIChatUtils.isGroupChat(mChatLayout.getChatInfo().getType()) && !mTextInput.getMentionIdList().isEmpty()) {
|
|
if (TUIChatUtils.isGroupChat(mChatLayout.getChatInfo().getType()) && !mTextInput.getMentionIdList().isEmpty()) {
|
|
List<String> atUserList = new ArrayList<>(mTextInput.getMentionIdList());
|
|
List<String> atUserList = new ArrayList<>(mTextInput.getMentionIdList());
|
|
mMessageHandler.sendMessage(
|
|
mMessageHandler.sendMessage(
|
|
- ChatMessageBuilder.buildAtReplyMessage(mTextInput.getText().toString(), atUserList, replyPreviewBean));
|
|
|
|
|
|
+ ChatMessageBuilder.buildAtReplyMessage(mTextInput.getText().toString(), atUserList, replyPreviewBean));
|
|
} else {
|
|
} else {
|
|
mMessageHandler.sendMessage(ChatMessageBuilder.buildReplyMessage(mTextInput.getText().toString(), replyPreviewBean));
|
|
mMessageHandler.sendMessage(ChatMessageBuilder.buildReplyMessage(mTextInput.getText().toString(), replyPreviewBean));
|
|
}
|
|
}
|
|
@@ -1136,7 +1157,8 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
|
|
|
|
|
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void afterTextChanged(Editable s) {
|
|
public void afterTextChanged(Editable s) {
|
|
@@ -1318,7 +1340,6 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
|
|
|
|
|
Map<String, Object> param = new HashMap<>();
|
|
Map<String, Object> param = new HashMap<>();
|
|
param.put(TUIConstants.TUIChat.Extension.InputMore.CONTEXT, getContext());
|
|
param.put(TUIConstants.TUIChat.Extension.InputMore.CONTEXT, getContext());
|
|
- param.put(TUIConstants.TUIChat.FRAGMENT, mInputMoreFragment);
|
|
|
|
if (ChatInfo.TYPE_C2C == mChatInfo.getType()) {
|
|
if (ChatInfo.TYPE_C2C == mChatInfo.getType()) {
|
|
param.put(TUIConstants.TUIChat.Extension.InputMore.USER_ID, mChatInfo.getId());
|
|
param.put(TUIConstants.TUIChat.Extension.InputMore.USER_ID, mChatInfo.getId());
|
|
} else {
|
|
} else {
|
|
@@ -1433,6 +1454,9 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
|
}
|
|
}
|
|
|
|
|
|
public void showReplyPreview(ReplyPreviewBean previewBean) {
|
|
public void showReplyPreview(ReplyPreviewBean previewBean) {
|
|
|
|
+ if (isMute()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
exitReply();
|
|
exitReply();
|
|
replyPreviewBean = previewBean;
|
|
replyPreviewBean = previewBean;
|
|
String replyMessageAbstract = previewBean.getMessageAbstract();
|
|
String replyMessageAbstract = previewBean.getMessageAbstract();
|
|
@@ -1487,6 +1511,25 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
|
mEmojiInputButton.setVisibility(visibility);
|
|
mEmojiInputButton.setVisibility(visibility);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public ViewGroup getInputMuteContainer() {
|
|
|
|
+ return mFlMute;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void controlMuteViewVisibility(int visibility) {
|
|
|
|
+ if (mFlMute != null) {
|
|
|
|
+ mFlMute.setVisibility(visibility);
|
|
|
|
+ if (visibility == View.VISIBLE) {
|
|
|
|
+ mTextInput.setText("");
|
|
|
|
+ exitReply();
|
|
|
|
+ onEmptyClick();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public boolean isMute() {
|
|
|
|
+ return mFlMute.getVisibility() == View.VISIBLE;
|
|
|
|
+ }
|
|
|
|
+
|
|
public void clearCustomActionList() {
|
|
public void clearCustomActionList() {
|
|
mInputMoreCustomActionList.clear();
|
|
mInputMoreCustomActionList.clear();
|
|
}
|
|
}
|
|
@@ -1498,7 +1541,8 @@ public class InputView extends LinearLayout implements View.OnClickListener, Tex
|
|
public interface MessageHandler {
|
|
public interface MessageHandler {
|
|
void sendMessage(TUIMessageBean msg);
|
|
void sendMessage(TUIMessageBean msg);
|
|
|
|
|
|
- default void sendMessages(List<TUIMessageBean> messageBeans) {}
|
|
|
|
|
|
+ default void sendMessages(List<TUIMessageBean> messageBeans) {
|
|
|
|
+ }
|
|
|
|
|
|
void scrollToEnd();
|
|
void scrollToEnd();
|
|
}
|
|
}
|