This commit is contained in:
18401019693 2022-07-21 18:35:06 +08:00
parent 01bdab01f6
commit 0cd6ab5e9d
16 changed files with 378 additions and 472 deletions

View File

@ -1,26 +1,35 @@
package com.yunbao.common.manager;
import android.content.Context;
import android.os.Handler;
import android.util.Log;
import androidx.annotation.NonNull;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.google.gson.Gson;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient;
import com.yunbao.common.manager.base.BaseCacheManager;
import java.util.Map;
/**
* 登录者信息管理
*/
public class IMLoginManager extends BaseCacheManager {
private final static String KEY_USER_INFO = "keyUserInfo";
private static IMLoginManager manager;
private IMLoginModel userInfo;
//根据用户信息
private Handler netHandler = new Handler();
private Context context;
private IMLoginManager(Context context) {
super(context);
this.context = context;
}
/**
@ -54,19 +63,46 @@ public class IMLoginManager extends BaseCacheManager {
* @param model
*/
public void setupLoginUser(@NonNull IMLoginModel model) {
put(KEY_USER_INFO, new Gson().toJson(model));
this.userInfo = model;
netHandler.post(isInstructorRunnable);
}
/**
* 获取是不是新手指导员的身份
*/
private Runnable isInstructorRunnable = new Runnable() {
@Override
public void run() {
HttpClient.getInstance().get("User.isInstructor", "isInstructor")
.params("uid", userInfo.getId())
.params("token", userInfo.getToken())
.execute(new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (info.length > 0) {
if ("1".equals(info[0])) {
userInfo.setIsAdmin("1");
InstructorRemarkManager.get(context).getNetInstructorRemark();
} else {
userInfo.setIsAdmin("0");
}
}
put(KEY_USER_INFO, new Gson().toJson(userInfo));
}
});
}
};
/**
* 退出登录
*/
public void logout() {
//删除用户登录信息
deleteByKey(KEY_USER_INFO);
//用户对象置空
userInfo=null;
deleteByKey(KEY_USER_INFO);
//用户对象置空
userInfo = null;
manager = null;
}

View File

@ -0,0 +1,111 @@
package com.yunbao.common.manager;
import android.content.Context;
import android.os.Handler;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.google.gson.Gson;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient;
import com.yunbao.common.manager.base.BaseCacheManager;
import java.util.Map;
/**
* 新手指导员备注列表
*/
public class InstructorRemarkManager extends BaseCacheManager {
private final static String KEY_INSTRUCTOR_REMARK = "InstructorRemark";
private static InstructorRemarkManager manager;
private Context context;
private Map<String, String> instructorRemarkMap;
private Handler netHandler = new Handler();
private InstructorRemarkManager(Context context) {
super(context);
this.context = context;
}
/**
* 获取指导员备注信息
*
* @return
*/
public Map<String, String> getInstructorRemark() {
if (null == instructorRemarkMap) {
instructorRemarkMap = JSON.parseObject(getString(KEY_INSTRUCTOR_REMARK), new TypeReference<Map<String, String>>() {
});
}
return instructorRemarkMap;
}
/**
* 设置指导员备注信息
*/
public void setInstructorRemark(String map) {
this.instructorRemarkMap = JSON.parseObject(map, new TypeReference<Map<String, String>>() {
});
put(KEY_INSTRUCTOR_REMARK, map);
}
/**
* 新增备注
*
* @param key 用户id
* @param value 备注信息
*/
public void addInstructorRemark(String key, String value) {
this.instructorRemarkMap.put(key, value);
String json = new Gson().toJson(instructorRemarkMap).toString();
put(KEY_INSTRUCTOR_REMARK, json);
}
/**
* 从服务器获取信息
*/
public void getNetInstructorRemark() {
netHandler.post(getInstructorRemarkRunnable);
}
/**
* 获取单利
*
* @return
*/
public static InstructorRemarkManager get(Context context) {
if (null == manager) {
manager = new InstructorRemarkManager(context);
}
return manager;
}
/**
* 获取备注信息
*/
private Runnable getInstructorRemarkRunnable = new Runnable() {
@Override
public void run() {
IMLoginModel userInfo = IMLoginManager.get(context).getUserInfo();
HttpClient.getInstance().get("User.getInstructorRemark", "getInstructorRemark")
.params("uid", userInfo.getId())
.params("token", userInfo.getToken())
.execute(new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
instructorRemarkMap = JSON.parseObject(info[0], new TypeReference<Map<String, String>>() {
});
setInstructorRemark(info[0]);
}
}
});
}
};
}

View File

@ -91,6 +91,9 @@
android:windowSoftInputMode="stateHidden|adjustResize">
</activity>
<activity
android:name=".activity.EditNameRemarksActivity"
android:screenOrientation="portrait" />
</application>
</manifest>

View File

@ -1,22 +1,28 @@
package com.yunbao.live.activity;
import android.net.Uri;
import android.text.InputFilter;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import com.google.gson.Gson;
import com.yunbao.common.Constants;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.GsonUtils;
import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.bean.ChatRemarksBean;
import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.utils.SpUtil;
import com.yunbao.common.manager.InstructorRemarkManager;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R;
import com.yunbao.live.bean.SearchUserBean;
import com.yunbao.live.http.LiveHttpUtil;
import static com.yunbao.live.views.SystemMessageViewHolder.updataNkname;
import org.greenrobot.eventbus.EventBus;
import io.rong.imkit.userinfo.RongUserInfoManager;
import io.rong.imlib.model.UserInfo;
/**
@ -27,6 +33,9 @@ import static com.yunbao.live.views.SystemMessageViewHolder.updataNkname;
public class EditNameRemarksActivity extends AbsActivity implements View.OnClickListener {
private EditText mEditText;
private String userId;
public final static String NAMEREMARK = "NameRemark";
@Override
protected int getLayoutId() {
@ -36,21 +45,18 @@ public class EditNameRemarksActivity extends AbsActivity implements View.OnClick
@Override
protected void main() {
setTitle(WordUtil.getString(R.string.edit_profile_update_remarks));
userId = getIntent().getStringExtra(NAMEREMARK);
mEditText = (EditText) findViewById(R.id.edit);
mEditText.setFilters(new InputFilter[]{
new InputFilter.LengthFilter(10)
});
String content = InstructorRemarkManager.get(mContext).getInstructorRemark().get(userId);
findViewById(R.id.btn_save).setOnClickListener(this);
String content = getIntent().getStringExtra(Constants.REMARKS);
if (!TextUtils.isEmpty(content)) {
if (content.length() > 10) {
content = content.substring(0, 10);
}
mEditText.setText(content);
mEditText.setSelection(content.length());
}
mEditText.setText(content);
mEditText.setSelection(content.length());
}
@Override
public void onClick(View v) {
if (!canClick()) {
@ -62,25 +68,44 @@ public class EditNameRemarksActivity extends AbsActivity implements View.OnClick
return;
}
LiveHttpUtil.setInstructorRemark(SystemMessageActivity.nowUid, content, new HttpCallback() {
LiveHttpUtil.setInstructorRemark(userId, content, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
ToastUtil.show(msg);
if (code == 0) {
Constants.isSetRemark = SystemMessageActivity.nowUid;
Constants.isSetRemarkText = content;
updataNkname();
//增加备注本地存储
Constants.remarksListNow.add(new ChatRemarksBean(SystemMessageActivity.nowUid,content));
String remarksList = new Gson().toJson(Constants.remarksListNow);
SpUtil.setStringValue("remarksList", remarksList);
finish();
InstructorRemarkManager.get(mContext).addInstructorRemark(userId, content);
//刷新列表内用户信息
addUserInfoProvider(content);
}
}
});
}
/**
* 刷新用户信息
*/
public void addUserInfoProvider(String remark) {
CommonHttpUtil.getUserBaseinfo(userId, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
JSONObject obj = JSON.parseObject(info[0]);
SearchUserBean userBean = JSON.toJavaObject(obj, SearchUserBean.class);
String userNiceName = userBean.getUserNiceName() + "(" + remark + ")";
UserInfo userInfo = new UserInfo(userId, userNiceName, Uri.parse(userBean.getAvatar()));
//使用空白字段存储自己服务器用户的所有的信息
userInfo.setExtra(GsonUtils.toJson(userBean));
RongUserInfoManager.getInstance().refreshUserInfoCache(userInfo);
EventBus.getDefault().post(userNiceName);
finish();
}
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();

View File

@ -6,7 +6,6 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
@ -29,6 +28,10 @@ import com.yunbao.live.bean.SearchUserBean;
import com.yunbao.live.dialog.MenuPopuwWindow;
import com.yunbao.live.views.InputPanelViewHolder;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import io.rong.imkit.conversation.ConversationFragment;
@ -60,6 +63,7 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
@Override
protected void main() {
super.main();
EventBus.getDefault().register(this);
mContext = this;
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
initView();
@ -105,17 +109,17 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
titleView = findViewById(R.id.titleView);
imgMore = findViewById(R.id.img_more);
imBack = findViewById(R.id.btn_back);
imgMore.setOnClickListener(this);
imBack.setOnClickListener(this);
findViewById(R.id.container).setOnTouchListener(new View.OnTouchListener() {
findViewById(R.id.root_layout).setOnClickListener(new View.OnClickListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
public void onClick(View v) {
InputMethodManager imm = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
return false;
}
});
imgMore.setOnClickListener(this);
imBack.setOnClickListener(this);
inputPanel.addMediaMessageCallback(new InputPanelViewHolder.MediaMessageCallback() {
@Override
public void choosePic(int intoIndex) {
@ -182,4 +186,18 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
}
}
}
@Override
protected void onDestroy() {
super.onDestroy();
EventBus.getDefault().unregister(this);
}
//消息中心
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageIMEvent(String event) {
if (!TextUtils.isEmpty(event)) {
titleView.setText(event);
}
}
}

View File

@ -1,6 +1,7 @@
package com.yunbao.live.dialog;
import android.app.Activity;
import android.content.Intent;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
@ -10,8 +11,10 @@ import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import com.yunbao.common.Constants;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.EditNameRemarksActivity;
import io.rong.imlib.RongIMClient;
@ -24,7 +27,7 @@ public class MenuPopuwWindow implements View.OnClickListener {
private View popupView;
private TextView tvBlack, tvBlackMove;
private LinearLayout ltRemarks;
private PopupWindow popupWindow;
private PopupWindow popupWindow;
public MenuPopuwWindow(Activity context) {
this.mContext = context;
@ -81,7 +84,7 @@ public class MenuPopuwWindow implements View.OnClickListener {
* @return
*/
public void show(View view) {
popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
popupWindow.showAsDropDown(view);
WindowManager.LayoutParams lp = mContext.getWindow().getAttributes();
lp.alpha = 0.8f;
@ -132,7 +135,10 @@ public class MenuPopuwWindow implements View.OnClickListener {
}
});
} else if (id == R.id.lt_remarks) {//添加备注
Intent intent = new Intent(mContext, EditNameRemarksActivity.class);
intent.putExtra(EditNameRemarksActivity.NAMEREMARK, userId);
mContext.startActivity(intent);
popupWindow.dismiss();
}
}
}

View File

@ -1,408 +0,0 @@
package com.yunbao.live.views;
import android.annotation.SuppressLint;
import android.content.Context;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import com.yunbao.live.R;
import io.rong.imkit.IMCenter;
import io.rong.imkit.conversation.extension.InputMode;
import io.rong.imkit.conversation.extension.RongExtensionCacheHelper;
import io.rong.imkit.conversation.extension.RongExtensionViewModel;
import io.rong.imkit.manager.AudioPlayManager;
import io.rong.imkit.manager.AudioRecordManager;
import io.rong.imkit.utils.PermissionCheckUtil;
import io.rong.imkit.utils.RongUtils;
import io.rong.imlib.IMLibExtensionModuleManager;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.HardwareResource;
import static android.view.View.VISIBLE;
public class InputPanel {
private final String TAG = this.getClass().getSimpleName();
private Conversation.ConversationType mConversationType;
private Context mContext;
private String mTargetId;
private InputPanel.InputStyle mInputStyle;
private Fragment mFragment;
private View mInputPanel;
private boolean mIsVoiceInputMode;
private ImageView mVoiceToggleBtn;
private EditText mEditText;
private TextView mVoiceInputBtn;
private ImageView mEmojiToggleBtn;
private Button mSendBtn;
private ImageView mAddBtn;
private ViewGroup mAddOrSendBtn;
private RongExtensionViewModel mExtensionViewModel;
private String mInitialDraft = "";
private float mLastTouchY;
private boolean mUpDirection;
private View.OnTouchListener mOnVoiceBtnTouchListener = new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
float mOffsetLimit = 70.0F * v.getContext().getResources().getDisplayMetrics().density;
String[] permissions = new String[]{"android.permission.RECORD_AUDIO"};
if (!PermissionCheckUtil.checkPermissions(v.getContext(), permissions) && event.getAction() == 0) {
PermissionCheckUtil.requestPermissions(InputPanel.this.mFragment, permissions, 100);
return true;
} else {
if (event.getAction() == 0) {
if (AudioPlayManager.getInstance().isPlaying()) {
AudioPlayManager.getInstance().stopPlay();
}
if (RongUtils.phoneIsInUse(v.getContext()) || IMLibExtensionModuleManager.getInstance().onRequestHardwareResource(HardwareResource.ResourceType.VIDEO) || IMLibExtensionModuleManager.getInstance().onRequestHardwareResource(HardwareResource.ResourceType.AUDIO)) {
Toast.makeText(v.getContext(), v.getContext().getResources().getString(R.string.rc_voip_occupying), Toast.LENGTH_SHORT).show();
return true;
}
AudioRecordManager.getInstance().startRecord(v.getRootView(), InputPanel.this.mConversationType, InputPanel.this.mTargetId);
InputPanel.this.mLastTouchY = event.getY();
InputPanel.this.mUpDirection = false;
((TextView) v).setText(R.string.rc_voice_release_to_send);
((TextView) v).setBackground(v.getContext().getResources().getDrawable(R.drawable.rc_ext_voice_touched_button));
} else if (event.getAction() == 2) {
if (InputPanel.this.mLastTouchY - event.getY() > mOffsetLimit && !InputPanel.this.mUpDirection) {
AudioRecordManager.getInstance().willCancelRecord();
InputPanel.this.mUpDirection = true;
((TextView) v).setText(R.string.rc_voice_press_to_input);
((TextView) v).setBackground(v.getContext().getResources().getDrawable(R.drawable.rc_ext_voice_idle_button));
} else if (event.getY() - InputPanel.this.mLastTouchY > -mOffsetLimit && InputPanel.this.mUpDirection) {
AudioRecordManager.getInstance().continueRecord();
InputPanel.this.mUpDirection = false;
((TextView) v).setBackground(v.getContext().getResources().getDrawable(R.drawable.rc_ext_voice_touched_button));
((TextView) v).setText(R.string.rc_voice_release_to_send);
}
} else if (event.getAction() == 1 || event.getAction() == 3) {
AudioRecordManager.getInstance().stopRecord();
((TextView) v).setText(R.string.rc_voice_press_to_input);
((TextView) v).setBackground(v.getContext().getResources().getDrawable(R.drawable.rc_ext_voice_idle_button));
}
if (InputPanel.this.mConversationType.equals(Conversation.ConversationType.PRIVATE)) {
RongIMClient.getInstance().sendTypingStatus(InputPanel.this.mConversationType, InputPanel.this.mTargetId, "RC:VcMsg");
}
return true;
}
}
};
private View.OnClickListener mOnSendBtnClick = new View.OnClickListener() {
public void onClick(View v) {
InputPanel.this.mExtensionViewModel.onSendClick();
}
};
private View.OnFocusChangeListener mOnEditTextFocusChangeListener = new View.OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
if (InputPanel.this.mExtensionViewModel != null && InputPanel.this.mExtensionViewModel.getInputModeLiveData() != null) {
InputPanel.this.mExtensionViewModel.getInputModeLiveData().postValue(InputMode.TextInput);
}
if (!TextUtils.isEmpty(InputPanel.this.mEditText.getText())) {
InputPanel.this.mSendBtn.setVisibility(VISIBLE);
InputPanel.this.mAddBtn.setVisibility(View.GONE);
}
} else {
EditText editText = InputPanel.this.mExtensionViewModel.getEditTextWidget();
if (editText.getText() != null && editText.getText().length() == 0) {
InputPanel.this.mSendBtn.setVisibility(View.GONE);
InputPanel.this.mAddBtn.setVisibility(VISIBLE);
}
}
}
};
private TextWatcher mEditTextWatcher = new TextWatcher() {
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s != null && s.length() != 0) {
InputPanel.this.mAddOrSendBtn.setVisibility(VISIBLE);
InputPanel.this.mSendBtn.setVisibility(VISIBLE);
InputPanel.this.mAddBtn.setVisibility(View.GONE);
} else {
IMCenter.getInstance().saveTextMessageDraft(InputPanel.this.mConversationType, InputPanel.this.mTargetId, InputPanel.this.mEditText.getText().toString(), (RongIMClient.ResultCallback) null);
if (!InputPanel.this.mInputStyle.equals(InputPanel.InputStyle.STYLE_CONTAINER_EXTENSION) && !InputPanel.this.mInputStyle.equals(InputPanel.InputStyle.STYLE_SWITCH_CONTAINER_EXTENSION)) {
InputPanel.this.mAddOrSendBtn.setVisibility(View.GONE);
} else {
InputPanel.this.mAddOrSendBtn.setVisibility(VISIBLE);
InputPanel.this.mAddBtn.setVisibility(VISIBLE);
InputPanel.this.mSendBtn.setVisibility(View.GONE);
}
}
int offset;
if (count == 0) {
int var10000 = start + before;
offset = -before;
} else {
offset = count;
}
if (Conversation.ConversationType.PRIVATE.equals(InputPanel.this.mConversationType) && offset != 0) {
RongIMClient.getInstance().sendTypingStatus(InputPanel.this.mConversationType, InputPanel.this.mTargetId, "RC:TxtMsg");
}
}
public void afterTextChanged(Editable s) {
}
};
public InputPanel(Fragment fragment, ViewGroup parent, InputPanel.InputStyle inputStyle, Conversation.ConversationType type, String targetId) {
this.mFragment = fragment;
this.mInputStyle = inputStyle;
this.mConversationType = type;
this.mTargetId = targetId;
this.initView(fragment.getContext(), parent);
this.mExtensionViewModel = (RongExtensionViewModel) (new ViewModelProvider(fragment)).get(RongExtensionViewModel.class);
this.mExtensionViewModel.getInputModeLiveData().observe(fragment.getViewLifecycleOwner(), new Observer<InputMode>() {
public void onChanged(InputMode inputMode) {
InputPanel.this.updateViewByInputMode(inputMode);
}
});
if (fragment.getContext() != null) {
this.mIsVoiceInputMode = RongExtensionCacheHelper.isVoiceInputMode(fragment.getContext(), this.mConversationType, this.mTargetId);
}
if (this.mIsVoiceInputMode) {
this.mExtensionViewModel.getInputModeLiveData().setValue(InputMode.VoiceInput);
} else {
this.getDraft();
this.mExtensionViewModel.getInputModeLiveData().setValue(InputMode.TextInput);
}
}
@SuppressLint({"ClickableViewAccessibility"})
private void initView(final Context context, ViewGroup parent) {
this.mContext = context;
this.mInputPanel = LayoutInflater.from(context).inflate(R.layout.rc_extension_input_panel, parent, false);
this.mVoiceToggleBtn = (ImageView) this.mInputPanel.findViewById(R.id.input_panel_voice_toggle);
this.mEditText = (EditText) this.mInputPanel.findViewById(R.id.edit_btn);
this.mVoiceInputBtn = (TextView) this.mInputPanel.findViewById((R.id.press_to_speech_btn));
this.mEmojiToggleBtn = (ImageView) this.mInputPanel.findViewById((R.id.input_panel_emoji_btn));
this.mAddOrSendBtn = (ViewGroup) this.mInputPanel.findViewById((R.id.input_panel_add_or_send));
this.mSendBtn = (Button) this.mInputPanel.findViewById((R.id.input_panel_send_btn));
this.mAddBtn = (ImageView) this.mInputPanel.findViewById((R.id.input_panel_add_btn));
this.mSendBtn.setOnClickListener(this.mOnSendBtnClick);
this.mEditText.setOnFocusChangeListener(this.mOnEditTextFocusChangeListener);
this.mEditText.addTextChangedListener(this.mEditTextWatcher);
this.mVoiceToggleBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (InputPanel.this.mIsVoiceInputMode) {
InputPanel.this.mIsVoiceInputMode = false;
InputPanel.this.mExtensionViewModel.getInputModeLiveData().setValue(InputMode.TextInput);
InputPanel.this.mEditText.requestFocus();
if (TextUtils.isEmpty(InputPanel.this.mInitialDraft)) {
InputPanel.this.getDraft();
}
} else {
InputPanel.this.mExtensionViewModel.getInputModeLiveData().postValue(InputMode.VoiceInput);
InputPanel.this.mIsVoiceInputMode = true;
}
RongExtensionCacheHelper.saveVoiceInputMode(context, InputPanel.this.mConversationType, InputPanel.this.mTargetId, InputPanel.this.mIsVoiceInputMode);
}
});
this.mEmojiToggleBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (InputPanel.this.mExtensionViewModel != null) {
if (InputPanel.this.mExtensionViewModel.getInputModeLiveData().getValue() != null && ((InputMode) InputPanel.this.mExtensionViewModel.getInputModeLiveData().getValue()).equals(InputMode.EmoticonMode)) {
InputPanel.this.mEditText.requestFocus();
InputPanel.this.mExtensionViewModel.getInputModeLiveData().postValue(InputMode.TextInput);
} else {
InputPanel.this.mExtensionViewModel.getInputModeLiveData().postValue(InputMode.EmoticonMode);
}
}
}
});
this.mAddBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (InputPanel.this.mExtensionViewModel.getInputModeLiveData().getValue() != null && ((InputMode) InputPanel.this.mExtensionViewModel.getInputModeLiveData().getValue()).equals(InputMode.PluginMode)) {
InputPanel.this.mEditText.requestFocus();
InputPanel.this.mExtensionViewModel.getInputModeLiveData().setValue(InputMode.TextInput);
}
InputPanel.this.mExtensionViewModel.getInputModeLiveData().setValue(InputMode.PluginMode);
}
});
this.mVoiceInputBtn.setOnTouchListener(this.mOnVoiceBtnTouchListener);
this.setInputPanelStyle(this.mInputStyle);
}
private void updateViewByInputMode(InputMode inputMode) {
if (!inputMode.equals(InputMode.TextInput) && !inputMode.equals(InputMode.PluginMode)) {
if (inputMode.equals(InputMode.VoiceInput)) {
this.mVoiceToggleBtn.setImageDrawable(this.mContext.getResources().getDrawable((R.drawable.rc_ext_toggle_keyboard_btn)));
this.mVoiceInputBtn.setVisibility(VISIBLE);
this.mEditText.setVisibility(View.GONE);
this.mEmojiToggleBtn.setImageDrawable(this.mContext.getResources().getDrawable((R.drawable.rc_ext_input_panel_emoji)));
} else if (inputMode.equals(InputMode.EmoticonMode)) {
this.mVoiceToggleBtn.setImageDrawable(this.mContext.getResources().getDrawable((R.drawable.rc_ext_toggle_voice_btn)));
this.mEmojiToggleBtn.setImageDrawable(this.mContext.getResources().getDrawable((R.drawable.rc_ext_toggle_keyboard_btn)));
this.mEditText.setVisibility(View.GONE);
this.mVoiceInputBtn.setVisibility(View.GONE);
}
} else {
if (inputMode.equals(InputMode.TextInput)) {
this.mIsVoiceInputMode = false;
}
this.mVoiceToggleBtn.setImageDrawable(this.mContext.getResources().getDrawable((R.drawable.rc_ext_toggle_voice_btn)));
this.mEmojiToggleBtn.setImageDrawable(this.mContext.getResources().getDrawable((R.drawable.rc_ext_input_panel_emoji)));
this.mEditText.setVisibility(VISIBLE);
this.mVoiceInputBtn.setVisibility(View.GONE);
this.mEmojiToggleBtn.setImageDrawable(this.mContext.getResources().getDrawable((R.drawable.rc_ext_input_panel_emoji)));
}
}
public EditText getEditText() {
return this.mEditText;
}
public View getRootView() {
return this.mInputPanel;
}
public void setVisible(int viewId, boolean visible) {
this.mInputPanel.findViewById(viewId).setVisibility(visible ? VISIBLE : View.GONE);
}
public void setInputPanelStyle(InputPanel.InputStyle style) {
switch (style) {
case STYLE_SWITCH_CONTAINER_EXTENSION:
this.setSCE();
break;
case STYLE_CONTAINER:
this.setC();
break;
case STYLE_CONTAINER_EXTENSION:
this.setCE();
break;
case STYLE_SWITCH_CONTAINER:
this.setSC();
break;
default:
this.setSCE();
}
this.mInputStyle = style;
}
private void setSCE() {
if (this.mInputPanel != null) {
this.mVoiceToggleBtn.setVisibility(VISIBLE);
this.mEmojiToggleBtn.setVisibility(VISIBLE);
this.mAddBtn.setVisibility(VISIBLE);
}
}
private void setC() {
if (this.mInputPanel != null) {
this.mVoiceToggleBtn.setVisibility(View.GONE);
this.mAddOrSendBtn.setVisibility(View.GONE);
this.mEmojiToggleBtn.setVisibility(View.GONE);
this.mAddBtn.setVisibility(View.GONE);
this.mSendBtn.setVisibility(View.GONE);
}
}
private void setCE() {
if (this.mInputPanel != null) {
this.mVoiceToggleBtn.setVisibility(View.GONE);
this.mAddOrSendBtn.setVisibility(VISIBLE);
this.mEmojiToggleBtn.setVisibility(VISIBLE);
this.mAddBtn.setVisibility(VISIBLE);
}
}
private void setSC() {
if (this.mInputPanel != null) {
this.mVoiceToggleBtn.setVisibility(VISIBLE);
this.mAddOrSendBtn.setVisibility(View.GONE);
this.mAddBtn.setVisibility(View.GONE);
}
}
private void getDraft() {
RongIMClient.getInstance().getTextMessageDraft(this.mConversationType, this.mTargetId, new RongIMClient.ResultCallback<String>() {
public void onSuccess(String s) {
if (!TextUtils.isEmpty(s)) {
InputPanel.this.mInitialDraft = s;
InputPanel.this.mEditText.setText(s);
InputPanel.this.mEditText.setSelection(s.length());
InputPanel.this.mEditText.requestFocus();
}
}
public void onError(RongIMClient.ErrorCode errorCode) {
}
});
}
public void onDestroy() {
this.mFragment = null;
this.mExtensionViewModel = null;
if (this.mEditText != null && this.mEditText.getText() != null && !this.mInitialDraft.equals(this.mEditText.getText().toString())) {
IMCenter.getInstance().saveTextMessageDraft(this.mConversationType, this.mTargetId, this.mEditText.getText().toString(), (RongIMClient.ResultCallback) null);
}
}
public static enum InputStyle {
STYLE_SWITCH_CONTAINER_EXTENSION(291),
STYLE_SWITCH_CONTAINER(288),
STYLE_CONTAINER_EXTENSION(35),
STYLE_CONTAINER(32);
int v;
private InputStyle(int v) {
this.v = v;
}
public static InputPanel.InputStyle getStyle(int v) {
InputPanel.InputStyle result = null;
InputPanel.InputStyle[] var2 = values();
int var3 = var2.length;
for (int var4 = 0; var4 < var3; ++var4) {
InputPanel.InputStyle style = var2[var4];
if (style.v == v) {
result = style;
break;
}
}
return result;
}
}
}

View File

@ -188,6 +188,7 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi
}
public void afterTextChanged(Editable s) {
editBtn.clearFocus();
}
};

View File

@ -11,12 +11,6 @@ import android.media.MediaMetadataRetriever;
import android.net.Uri;
import android.os.Handler;
import android.os.Parcelable;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
@ -36,6 +30,13 @@ import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.fastjson.JSON;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
@ -1522,9 +1523,9 @@ public class SystemMessageViewHolder extends AbsViewHolder implements View.OnCli
}
public static void updataNkname() {
if (!TextUtils.isEmpty(Constants.isSetRemarkText)) {
titleView.setText(SystemMessageActivity.nowTitle + "(" + Constants.isSetRemarkText + ")");
public static void updataNkname(String remarkText) {
if (!TextUtils.isEmpty(remarkText)) {
titleView.setText(SystemMessageActivity.nowTitle + "(" + remarkText + ")");
}
}

View File

@ -1,7 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:focusable="true"
android:orientation="vertical">
<include layout="@layout/view_title" />

View File

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/input_panel_voice_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginBottom="6.5dp"
android:src="@drawable/rc_ext_toggle_voice"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/edit_btn"
style="@style/EditTextStyle.Alignment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="6.5dp"
android:layout_marginEnd="5dp"
android:layout_marginBottom="6.5dp"
android:background="@drawable/rc_ext_panel_editbox_background"
android:maxLines="4"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/input_panel_emoji_btn"
app:layout_constraintStart_toEndOf="@+id/input_panel_voice_toggle"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/press_to_speech_btn"
style="@style/TextStyle.Alignment"
android:layout_width="0dp"
android:layout_height="@dimen/rc_ext_input_panel_editbox_height"
android:layout_marginStart="8dp"
android:layout_marginEnd="5dp"
android:layout_marginTop="6.5dp"
android:layout_marginBottom="6.5dp"
android:background="@drawable/rc_ext_voice_idle_button"
android:gravity="center"
android:text="@string/rc_voice_press_to_input"
android:textColor="@color/rc_text_main_color"
android:textSize="@dimen/rc_font_nav_or_date_size"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/input_panel_emoji_btn"
app:layout_constraintStart_toEndOf="@+id/input_panel_voice_toggle"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/input_panel_emoji_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6.5dp"
android:layout_marginBottom="6.5dp"
android:layout_marginEnd="5dp"
android:src="@drawable/rc_ext_input_panel_emoji"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toStartOf="@+id/input_panel_add_or_send" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/input_panel_add_or_send"
android:layout_width="41dp"
android:layout_height="wrap_content"
android:layout_marginTop="6.5dp"
android:layout_marginEnd="5dp"
android:layout_marginBottom="6.5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/input_panel_add_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="4dp"
android:src="@drawable/rc_ext_input_panel_add"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/input_panel_send_btn"
android:layout_width="wrap_content"
android:layout_height="34dp"
android:background="@drawable/rc_send_background"
android:text="@string/rc_send"
android:textColor="@color/rc_white_color"
android:textSize="@dimen/rc_font_text_third_size"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -133,6 +133,7 @@
android:screenOrientation="portrait"
android:theme="@style/noAnimationStyle"
android:windowSoftInputMode="stateHidden|adjustResize" />
</application>
</manifest>

View File

@ -8,6 +8,7 @@ import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.event.LoginInvalidEvent;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.main.R;
@ -37,11 +38,7 @@ public class LoginInvalidActivity extends AbsActivity implements View.OnClickLis
public void onClick(View v) {
EventBus.getDefault().post(new LoginInvalidEvent());
CommonAppConfig.getInstance().clearLoginInfo();
//退出极光
// ImMessageUtil.getInstance().logoutImClient();
// ImPushUtil.getInstance().logout();
//友盟统计登出
// MobclickAgent.onProfileSignOff();
IMLoginManager.get(this).logout();
LoginActivity.forward();
finish();
}

View File

@ -52,6 +52,7 @@ import com.yunbao.common.event.UpdateTablePointMe;
import com.yunbao.common.http.CommonHttpConsts;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.GifCacheUtil;
@ -340,7 +341,6 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
initTXIM();
mViewPager.setCurrentItem(0);
mTabButtonGroup.setCurPosition(0);
isInstructor();
}
@ -382,6 +382,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
@Override
public void onKickedOffline() {
super.onKickedOffline();
IMLoginManager.get(mContext).logout();
CommonAppConfig.getInstance().clearLoginInfo();
LoginActivity.forward();

View File

@ -18,6 +18,7 @@ import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.GlideCatchUtil;
import com.yunbao.common.utils.ToastUtil;
@ -127,14 +128,8 @@ public class SettingActivity extends AbsActivity implements OnItemClickListener<
* 退出登录
*/
private void logout() {
IMLoginManager.get(this).logout();
CommonAppConfig.getInstance().clearLoginInfo();
//退出极光
// ImMessageUtil.getInstance().logoutImClient();
// ImPushUtil.getInstance().logout();
//友盟统计登出
// MobclickAgent.onProfileSignOff();
// SettingActivity.this.startActivity(new Intent(SettingActivity.this,EntryActivity.class));
RCRTCEngine.getInstance().unInit();
RongIMClient.getInstance().logout();
Intent intent = new Intent(SettingActivity.this, EntryActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);

View File

@ -5,12 +5,14 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.GsonUtils;
import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.manager.InstructorRemarkManager;
import com.yunbao.live.activity.PDLIiveChatActivity;
import com.yunbao.live.activity.PDLiveConversationActivity;
import com.yunbao.live.bean.SearchUserBean;
@ -76,6 +78,7 @@ public class ConversationIMListManager {
intent.putExtras(extras);
mContext.startActivity(intent);
}
/**
* 跳转消息列表
*
@ -87,12 +90,14 @@ public class ConversationIMListManager {
intent.putExtras(extras);
mContext.startActivity(intent);
}
/**
* 跳转会话页面
* @param context 上下文
*
* @param context 上下文
* @param targetId 用户id
*/
public void jumpConversation(Activity context,String targetId) {
public void jumpConversation(Activity context, String targetId) {
Intent intent = new Intent(context, PDLiveConversationActivity.class);
intent.putExtra(RouteUtils.TARGET_ID, targetId);
@ -111,7 +116,14 @@ public class ConversationIMListManager {
if (code == 0 && info.length > 0) {
JSONObject obj = JSON.parseObject(info[0]);
SearchUserBean userBean = JSON.toJavaObject(obj, SearchUserBean.class);
UserInfo userInfo = new UserInfo(userId, userBean.getUserNiceName(), Uri.parse(userBean.getAvatar()));
String userNiceName = "";
String remark = InstructorRemarkManager.get(mContext).getInstructorRemark().get(userId);
if (!TextUtils.isEmpty(remark)) {
userNiceName = userBean.getUserNiceName() + "(" + remark + ")";
} else {
userNiceName = userBean.getUserNiceName();
}
UserInfo userInfo = new UserInfo(userId, userNiceName, Uri.parse(userBean.getAvatar()));
//使用空白字段存储自己服务器用户的所有的信息
userInfo.setExtra(GsonUtils.toJson(userBean));
RongUserInfoManager.getInstance().refreshUserInfoCache(userInfo);