2020-09-10 22:38:32 +08:00
|
|
|
package com.tianrun.sipcall.login;
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
2020-09-11 22:59:19 +08:00
|
|
|
import android.content.DialogInterface;
|
2020-09-10 22:38:32 +08:00
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.graphics.Color;
|
|
|
|
|
import android.media.AudioManager;
|
|
|
|
|
import android.os.Build;
|
|
|
|
|
import android.os.Bundle;
|
2020-09-15 17:57:15 +08:00
|
|
|
import android.os.Handler;
|
2020-09-10 22:38:32 +08:00
|
|
|
import android.os.Message;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
|
import android.widget.AdapterView;
|
|
|
|
|
import android.widget.Button;
|
|
|
|
|
import android.widget.GridView;
|
|
|
|
|
import android.widget.ImageView;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
import androidx.annotation.RequiresApi;
|
|
|
|
|
import androidx.viewpager.widget.PagerAdapter;
|
|
|
|
|
import androidx.viewpager.widget.ViewPager;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.qmuiteam.qmui.skin.QMUISkinManager;
|
|
|
|
|
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
|
|
|
|
|
import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet;
|
|
|
|
|
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
|
|
|
|
|
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
|
|
|
|
|
import com.qmuiteam.qmui.widget.dialog.QMUITipDialog;
|
|
|
|
|
import com.qmuiteam.qmui.widget.popup.QMUIPopups;
|
|
|
|
|
import com.qmuiteam.qmui.widget.popup.QMUIQuickAction;
|
|
|
|
|
import com.qmuiteam.qmui.widget.tab.QMUITabBuilder;
|
|
|
|
|
import com.qmuiteam.qmui.widget.tab.QMUITabIndicator;
|
|
|
|
|
import com.qmuiteam.qmui.widget.tab.QMUITabSegment;
|
|
|
|
|
import com.tianrun.sipcall.App;
|
|
|
|
|
import com.tianrun.sipcall.R;
|
|
|
|
|
import com.tianrun.sipcall.SipEngine;
|
|
|
|
|
import com.tianrun.sipcall.call.CallActivity;
|
|
|
|
|
import com.tianrun.sipcall.call.CreateGroupActivity;
|
|
|
|
|
import com.tianrun.sipcall.call.CreateMeetingActivity;
|
2020-09-11 22:59:19 +08:00
|
|
|
import com.tianrun.sipcall.db.DBGroup;
|
2020-09-10 22:38:32 +08:00
|
|
|
import com.tianrun.sipcall.db.DBHead;
|
|
|
|
|
import com.tianrun.sipcall.db.DBUser;
|
2020-09-11 22:59:19 +08:00
|
|
|
import com.tianrun.sipcall.db.UserViews;
|
2020-09-10 22:38:32 +08:00
|
|
|
import com.tianrun.sipcall.net.Net;
|
|
|
|
|
import com.tianrun.sipcall.net.NetPkg;
|
|
|
|
|
import com.tianrun.sipcall.ui.TrAdapter;
|
|
|
|
|
import com.tianrun.sipcall.ui.TrBaseActivity;
|
|
|
|
|
import com.tianrun.sipcall.ui.UIUtl;
|
|
|
|
|
import com.tianrun.sipcall.utils.CONS;
|
|
|
|
|
import com.tianrun.sipcall.utils.HttpUtl;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class MainActivity extends TrBaseActivity {
|
2020-09-15 17:57:15 +08:00
|
|
|
public static Handler mainHandler;
|
2020-09-10 22:38:32 +08:00
|
|
|
TextView textVolum;
|
|
|
|
|
TextView textSelfNum;
|
|
|
|
|
QMUITabSegment mTabSegment;
|
|
|
|
|
ViewPager mContentViewPager;
|
|
|
|
|
Button buttonAddGroup;
|
|
|
|
|
ImageView imageViewAddGroupIcon;
|
|
|
|
|
View StartMeetingVideo;
|
|
|
|
|
View StartMeetingVoice;
|
|
|
|
|
View ButtonDelGroup;
|
|
|
|
|
// TrAdapter adapter;
|
|
|
|
|
TrAdapter adapterUser;
|
|
|
|
|
AudioManager audioManager;
|
|
|
|
|
ImageView buttonAddVol;
|
|
|
|
|
ImageView buttonDelVol;
|
|
|
|
|
DBHead currSelectData;
|
2020-09-15 17:57:15 +08:00
|
|
|
ImageView imageViewSelfStatus;
|
|
|
|
|
TextView textViewSelfStatus;
|
2020-09-10 22:38:32 +08:00
|
|
|
|
|
|
|
|
GridView gridUser;
|
|
|
|
|
List<Object> allUsers = new ArrayList<>();
|
|
|
|
|
List<DBHead> headers = new ArrayList<>();
|
|
|
|
|
private int mCurrentDialogStyle = com.qmuiteam.qmui.R.style.QMUI_Dialog;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private PagerAdapter mPagerAdapter = new PagerAdapter() {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isViewFromObject(View view, Object object) {
|
|
|
|
|
return view == object;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getCount() {
|
|
|
|
|
return headers.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Object instantiateItem(final ViewGroup container, int position) {
|
|
|
|
|
// ContentPage page = ContentPage.getPage(position);
|
|
|
|
|
View view = getPageView(position);
|
|
|
|
|
// view.setTag(page);
|
|
|
|
|
// ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
|
|
|
|
|
// ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
|
|
|
|
// container.addView(view, params);
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void destroyItem(ViewGroup container, int position, Object object) {
|
|
|
|
|
container.removeView((View) object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getItemPosition(@NonNull Object object) {
|
|
|
|
|
View view = (View) object;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@RequiresApi(api = Build.VERSION_CODES.M)
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
setContentView(R.layout.activity_main);
|
|
|
|
|
textVolum = findViewById(R.id.Volumne);
|
|
|
|
|
textSelfNum = findViewById(R.id.textViewSelfNum);
|
2020-09-15 17:57:15 +08:00
|
|
|
imageViewSelfStatus = findViewById(R.id.imageViewSelfStatus);
|
|
|
|
|
textViewSelfStatus = findViewById(R.id.textViewSelfStatus);
|
2020-09-10 22:38:32 +08:00
|
|
|
mTabSegment = findViewById(R.id.HeadList);
|
|
|
|
|
gridUser = findViewById(R.id.GridUser);
|
|
|
|
|
mContentViewPager = findViewById(R.id.contentViewPager);
|
|
|
|
|
buttonAddGroup = findViewById(R.id.buttonAddGroup);
|
|
|
|
|
imageViewAddGroupIcon = findViewById(R.id.imageViewAddGroupIcon);
|
|
|
|
|
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
|
|
|
|
StartMeetingVoice = findViewById(R.id.StartMeetingVoice);
|
|
|
|
|
StartMeetingVideo = findViewById(R.id.StartMeetingVideo);
|
|
|
|
|
ButtonDelGroup = findViewById(R.id.ButtonDelGroup);
|
|
|
|
|
buttonAddVol = findViewById(R.id.imageViewAddVoice);
|
|
|
|
|
buttonAddVol.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
|
chgVolum(v, true);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
buttonDelVol = findViewById(R.id.imageViewDelVoice);
|
|
|
|
|
buttonDelVol.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
|
chgVolum(v, false);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
});
|
2020-09-15 17:57:15 +08:00
|
|
|
mainHandler = this.handler;
|
2020-09-10 22:38:32 +08:00
|
|
|
|
|
|
|
|
ButtonDelGroup.setVisibility(View.INVISIBLE);
|
|
|
|
|
StartMeetingVoice.setVisibility(View.INVISIBLE);
|
|
|
|
|
StartMeetingVideo.setVisibility(View.INVISIBLE);
|
|
|
|
|
refreshView();
|
|
|
|
|
|
|
|
|
|
currSelectData = DBHead.newHead4Total();
|
|
|
|
|
currSelectData.isSelected = true;
|
|
|
|
|
headers.add(currSelectData);
|
|
|
|
|
initTabAndPager();
|
|
|
|
|
Net.getGroups(null, null);
|
2020-09-15 17:57:15 +08:00
|
|
|
getUsersData();
|
2020-09-10 22:38:32 +08:00
|
|
|
checkBeforeMeetingState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 处理当前分机号可能有需要加入的会议
|
|
|
|
|
private void checkBeforeMeetingState() {
|
|
|
|
|
Net.getUserInfor(DBUser.mySelf.phone, new HttpUtl.CallBack() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onRequestComplete(int cmd, String result, Object orgs) {
|
|
|
|
|
JSONArray array = JSONObject.parseObject(result).getJSONArray("agents");
|
|
|
|
|
JSONObject jo = array.getJSONObject(0);
|
|
|
|
|
JSONArray comment = jo.getJSONArray("comment");
|
|
|
|
|
if (comment != null && comment.size() > 0) {
|
|
|
|
|
List<String> list = new ArrayList<>();
|
|
|
|
|
for (Object o : comment) {
|
|
|
|
|
JSONObject com = (JSONObject) o;
|
|
|
|
|
String name = com.getString("topic") + "【" + ((com.getString("type").equals("video_profile")) ? "视频会议" : "语音会议") + "】";
|
|
|
|
|
list.add(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UIUtl.showBottomSheetList("您有会议需要加入", list, new QMUIBottomSheet.BottomListSheetBuilder.OnSheetItemClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(QMUIBottomSheet dialog, View itemView, int position, String tag) {
|
|
|
|
|
JSONObject o = comment.getJSONObject(position);
|
|
|
|
|
SipEngine.getInstance().CallNumber(o.getString("nbr"), (o.getString("type").equals("video_profile")) ? true : false);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onRequestError(int cmd, String result, Object orgs) {
|
|
|
|
|
}
|
|
|
|
|
}, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void refreshHeaders() {
|
|
|
|
|
DBHead h = headers.get(0);
|
|
|
|
|
headers.clear();
|
|
|
|
|
headers.add(h);
|
2020-09-11 22:59:19 +08:00
|
|
|
headers.addAll(DBHead.allHeads);
|
2020-09-10 22:38:32 +08:00
|
|
|
|
|
|
|
|
mPagerAdapter.notifyDataSetChanged();
|
|
|
|
|
mTabSegment.reset();
|
|
|
|
|
QMUITabBuilder tabBuilder = mTabSegment.tabBuilder();
|
|
|
|
|
for (int i = 0; i < headers.size(); i++) {
|
|
|
|
|
mTabSegment.addTab(tabBuilder.setText(headers.get(i).name).build(this));
|
|
|
|
|
}
|
|
|
|
|
mTabSegment.notifyDataChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initTabAndPager() {
|
|
|
|
|
mContentViewPager.setAdapter(mPagerAdapter);
|
|
|
|
|
// mContentViewPager.setCurrentItem(mDestPage.getPosition(), false);
|
|
|
|
|
QMUITabBuilder tabBuilder = mTabSegment.tabBuilder();
|
|
|
|
|
for (int i = 0; i < headers.size(); i++) {
|
|
|
|
|
mTabSegment.addTab(tabBuilder.setText(headers.get(i).name).build(this));
|
|
|
|
|
}
|
|
|
|
|
int space = QMUIDisplayHelper.dp2px(this, 16);
|
|
|
|
|
mTabSegment.setIndicator(new QMUITabIndicator(
|
|
|
|
|
QMUIDisplayHelper.dp2px(this, 2), false, true));
|
|
|
|
|
mTabSegment.setMode(QMUITabSegment.MODE_SCROLLABLE);
|
|
|
|
|
mTabSegment.setItemSpaceInScrollMode(space);
|
|
|
|
|
mTabSegment.setupWithViewPager(mContentViewPager, false);
|
|
|
|
|
mTabSegment.setPadding(space, 0, space, 0);
|
|
|
|
|
mTabSegment.addOnTabSelectedListener(new QMUITabSegment.OnTabSelectedListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onTabSelected(int index) {
|
|
|
|
|
currSelectData = headers.get(index);
|
|
|
|
|
if (currSelectData.isAll()) {
|
|
|
|
|
ButtonDelGroup.setVisibility(View.INVISIBLE);
|
|
|
|
|
StartMeetingVoice.setVisibility(View.INVISIBLE);
|
|
|
|
|
StartMeetingVideo.setVisibility(View.INVISIBLE);
|
|
|
|
|
} else {
|
|
|
|
|
StartMeetingVoice.setVisibility(View.VISIBLE);
|
|
|
|
|
StartMeetingVideo.setVisibility(View.VISIBLE);
|
|
|
|
|
if (DBUser.mySelf.isManager) {
|
|
|
|
|
ButtonDelGroup.setVisibility(View.VISIBLE);
|
|
|
|
|
} else {
|
|
|
|
|
ButtonDelGroup.setVisibility(View.INVISIBLE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//显示分机
|
|
|
|
|
allUsers.clear();
|
2020-09-11 22:59:19 +08:00
|
|
|
if (currSelectData.isAll()) {
|
2020-09-10 22:38:32 +08:00
|
|
|
allUsers.addAll(DBUser.allUser);
|
|
|
|
|
setUsers();
|
2020-09-15 17:57:15 +08:00
|
|
|
Net.getUsers(null, null);
|
2020-09-10 22:38:32 +08:00
|
|
|
} else {
|
2020-09-11 22:59:19 +08:00
|
|
|
DBGroup group = DBGroup.getGroup(currSelectData.id);
|
|
|
|
|
if (group != null) {
|
|
|
|
|
allUsers.addAll(group.users);
|
|
|
|
|
}
|
|
|
|
|
//根据权限来处理
|
|
|
|
|
if (DBUser.mySelf.isManager) {
|
|
|
|
|
DBUser u = new DBUser("", "添加分机", "false");
|
|
|
|
|
u.isAddFlag = true;
|
|
|
|
|
allUsers.add(u);
|
|
|
|
|
}
|
2020-09-10 22:38:32 +08:00
|
|
|
setUsers();
|
|
|
|
|
//取得数据
|
|
|
|
|
Net.getGroupMenbers(currSelectData.id, null, currSelectData.id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onTabUnselected(int index) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onTabReselected(int index) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onDoubleTap(int index) {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void refreshView() {
|
2020-09-11 22:59:19 +08:00
|
|
|
//通话音量
|
2020-09-10 22:38:32 +08:00
|
|
|
int max = audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL);
|
|
|
|
|
int current = audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL);
|
|
|
|
|
textVolum.setText("音量:" + current);
|
|
|
|
|
if (DBUser.mySelf != null && DBUser.mySelf.phone != null) {
|
|
|
|
|
textSelfNum.setText("分机号:" + DBUser.mySelf.phone);
|
|
|
|
|
}
|
|
|
|
|
if (DBUser.mySelf != null && DBUser.mySelf.isManager) {
|
|
|
|
|
buttonAddGroup.setVisibility(View.VISIBLE);
|
|
|
|
|
imageViewAddGroupIcon.setVisibility(View.VISIBLE);
|
|
|
|
|
} else {
|
|
|
|
|
buttonAddGroup.setVisibility(View.INVISIBLE);
|
|
|
|
|
imageViewAddGroupIcon.setVisibility(View.INVISIBLE);
|
|
|
|
|
}
|
2020-09-15 17:57:15 +08:00
|
|
|
|
|
|
|
|
if (DBUser.mySelf.isBusy()) {
|
|
|
|
|
imageViewSelfStatus.setColorFilter(Color.RED);
|
|
|
|
|
textViewSelfStatus.setText("通话中");
|
|
|
|
|
} else if (DBUser.mySelf.isOnline()) {
|
|
|
|
|
imageViewSelfStatus.setColorFilter(Color.GREEN);
|
|
|
|
|
textViewSelfStatus.setText("在线");
|
|
|
|
|
} else {
|
|
|
|
|
imageViewSelfStatus.setColorFilter(Color.GRAY);
|
|
|
|
|
textViewSelfStatus.setText("离线");
|
|
|
|
|
}
|
2020-09-10 22:38:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void chgVolum(View v, boolean isAdd) {
|
|
|
|
|
handler.postDelayed(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
if (!v.isPressed()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (isAdd) {
|
|
|
|
|
addVolume(v);
|
|
|
|
|
} else {
|
|
|
|
|
delVolume(v);
|
|
|
|
|
}
|
|
|
|
|
if (v.isPressed()) {
|
|
|
|
|
chgVolum(v, isAdd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, 100);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Runnable runGetUsers = new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
2020-09-15 17:57:15 +08:00
|
|
|
getUsersData();
|
2020-09-10 22:38:32 +08:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public View getPageView(int pos) {
|
|
|
|
|
return gridUser;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-15 17:57:15 +08:00
|
|
|
public static void getUsersData() {
|
|
|
|
|
Net.getUsers(null, null);
|
|
|
|
|
mainHandler.postDelayed(runGetUsers, 3000);
|
2020-09-10 22:38:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setUsers() {
|
|
|
|
|
if (DBUser.allUser == null) return;
|
|
|
|
|
if (adapterUser == null) {
|
|
|
|
|
adapterUser = UIUtl.setList(this, gridUser, R.layout.list_item_user, allUsers, new TrAdapter.Callback() {
|
|
|
|
|
@Override
|
|
|
|
|
public void initCallback(Object data, int position, View prefabView, ViewGroup parent) {
|
|
|
|
|
UserViews views = null;
|
|
|
|
|
if (prefabView.getTag() == null) {
|
|
|
|
|
views = new UserViews();
|
|
|
|
|
views.textViewName = prefabView.findViewById(R.id.textViewName);
|
|
|
|
|
views.textViewNum = prefabView.findViewById(R.id.textViewNum);
|
|
|
|
|
views.imageViewStatus = prefabView.findViewById(R.id.imageViewStatus);
|
|
|
|
|
views.imageViewAddflag = prefabView.findViewById(R.id.imageViewAddflag);
|
|
|
|
|
views.imageViewPhoneIcon = prefabView.findViewById(R.id.imageView3PhoneIcon);
|
|
|
|
|
prefabView.setTag(views);
|
|
|
|
|
} else {
|
|
|
|
|
views = (UserViews) (prefabView.getTag());
|
|
|
|
|
}
|
|
|
|
|
DBUser d = (DBUser) data;
|
|
|
|
|
views.textViewName.setText(d.name);
|
|
|
|
|
views.textViewNum.setText(d.phone);
|
|
|
|
|
if (d.isOffline()) {
|
|
|
|
|
views.imageViewStatus.setColorFilter(Color.GRAY);
|
|
|
|
|
} else if (d.isOnline()) {
|
|
|
|
|
views.imageViewStatus.setColorFilter(Color.GREEN);
|
|
|
|
|
} else if (d.isBusy()) {
|
|
|
|
|
views.imageViewStatus.setColorFilter(Color.RED);
|
|
|
|
|
} else {
|
|
|
|
|
views.imageViewStatus.setColorFilter(Color.GRAY);
|
|
|
|
|
}
|
|
|
|
|
if (d.isAddFlag) {
|
|
|
|
|
views.imageViewPhoneIcon.setVisibility(View.INVISIBLE);
|
|
|
|
|
views.imageViewAddflag.setVisibility(View.VISIBLE);
|
|
|
|
|
} else {
|
|
|
|
|
views.imageViewPhoneIcon.setVisibility(View.VISIBLE);
|
|
|
|
|
views.imageViewAddflag.setVisibility(View.INVISIBLE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void clickCallback(Object data, AdapterView<?> parent, View view, int position, long id) {
|
|
|
|
|
DBUser d = (DBUser) data;
|
|
|
|
|
if (d.isAddFlag) {
|
2020-09-11 22:59:19 +08:00
|
|
|
showUsersMultiChoiceDialog();
|
2020-09-10 22:38:32 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QMUIQuickAction qa = QMUIPopups.quickAction(MainActivity.this,
|
|
|
|
|
QMUIDisplayHelper.dp2px(MainActivity.this, 56),
|
|
|
|
|
QMUIDisplayHelper.dp2px(MainActivity.this, 56))
|
|
|
|
|
.shadow(true)
|
|
|
|
|
.dimAmount(0.5f)
|
|
|
|
|
.skinManager(QMUISkinManager.defaultInstance(MainActivity.this))
|
|
|
|
|
.edgeProtection(QMUIDisplayHelper.dp2px(MainActivity.this, 20))
|
|
|
|
|
.addAction(new QMUIQuickAction.Action().icon(R.drawable.voice2).text("语音").onClick(
|
|
|
|
|
new QMUIQuickAction.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(QMUIQuickAction quickAction, QMUIQuickAction.Action action, int position) {
|
|
|
|
|
quickAction.dismiss();
|
|
|
|
|
SipEngine.getInstance().CallNumber(d.phone, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
))
|
|
|
|
|
.addAction(new QMUIQuickAction.Action().icon(R.drawable.video).text("视频").onClick(
|
|
|
|
|
new QMUIQuickAction.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(QMUIQuickAction quickAction, QMUIQuickAction.Action action, int position) {
|
|
|
|
|
quickAction.dismiss();
|
|
|
|
|
SipEngine.getInstance().CallNumber(d.phone, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
));
|
|
|
|
|
if (DBUser.mySelf.isManager) {
|
|
|
|
|
qa.addAction(new QMUIQuickAction.Action().icon(android.R.drawable.ic_delete).text("移除").onClick(
|
|
|
|
|
new QMUIQuickAction.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(QMUIQuickAction quickAction, QMUIQuickAction.Action action, int position) {
|
|
|
|
|
quickAction.dismiss();
|
2020-09-11 22:59:19 +08:00
|
|
|
QMUITipDialog dialog = UIUtl.toastLoading("");
|
2020-09-15 17:57:15 +08:00
|
|
|
Net.deleteMember4Group(currSelectData.id, d.phone, new HttpUtl.CallBack() {
|
2020-09-11 22:59:19 +08:00
|
|
|
@Override
|
|
|
|
|
public void onRequestComplete(int cmd, String result, Object orgs) {
|
|
|
|
|
UIUtl.toastS("移除分机成功");
|
|
|
|
|
//取得数据
|
|
|
|
|
Net.getGroupMenbers(currSelectData.id, null, currSelectData.id);
|
|
|
|
|
dialog.dismiss();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onRequestError(int cmd, String result, Object orgs) {
|
|
|
|
|
dialog.dismiss();
|
|
|
|
|
}
|
|
|
|
|
}, null);
|
2020-09-10 22:38:32 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
qa.show(view);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
adapterUser.notifyDataSetChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-11 22:59:19 +08:00
|
|
|
private void showUsersMultiChoiceDialog() {
|
|
|
|
|
List<String> list = new ArrayList<>();
|
|
|
|
|
List<String> listPhone = new ArrayList<>();
|
|
|
|
|
DBGroup group = DBGroup.getGroup(currSelectData.id);
|
|
|
|
|
if (group == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for (DBUser u : DBUser.allUser) {
|
|
|
|
|
if (!group.containsUser(u.phone)) {
|
|
|
|
|
listPhone.add(u.phone);
|
|
|
|
|
list.add(u.phone + " | " + u.name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (list.size() == 0) {
|
|
|
|
|
UIUtl.toastI("所有分机已经添加");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final String[] items = new String[list.size()];
|
|
|
|
|
list.toArray(items);
|
|
|
|
|
final QMUIDialog.MultiCheckableDialogBuilder builder = new QMUIDialog.MultiCheckableDialogBuilder(this)
|
|
|
|
|
.setTitle("选择要加入的分机号")
|
|
|
|
|
// .setCheckedItems(new int[]{1, 3})
|
|
|
|
|
.setSkinManager(QMUISkinManager.defaultInstance(this))
|
|
|
|
|
.addItems(items, new DialogInterface.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
builder.addAction("取消", new QMUIDialogAction.ActionListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(QMUIDialog dialog, int index) {
|
|
|
|
|
dialog.dismiss();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
builder.addAction("确定", new QMUIDialogAction.ActionListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(QMUIDialog dialog, int index) {
|
|
|
|
|
int[] selectIndexs = builder.getCheckedItemIndexes();
|
|
|
|
|
if (selectIndexs.length > 0) {
|
|
|
|
|
List<DBUser> list = new ArrayList<>();
|
|
|
|
|
String members = "";
|
|
|
|
|
for (int i = 0; i < selectIndexs.length; i++) {
|
|
|
|
|
String phNum = listPhone.get(selectIndexs[i]);
|
|
|
|
|
members = members + phNum + ",";
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-14 16:43:36 +08:00
|
|
|
Net.addMember2Group(currSelectData.audio_code, members, new HttpUtl.CallBack() {
|
2020-09-11 22:59:19 +08:00
|
|
|
@Override
|
|
|
|
|
public void onRequestComplete(int cmd, String result, Object orgs) {
|
|
|
|
|
Net.getGroupMenbers(currSelectData.id, null, currSelectData.id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onRequestError(int cmd, String result, Object orgs) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dialog.dismiss();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
int mCurrentDialogStyle = com.qmuiteam.qmui.R.style.QMUI_Dialog;
|
|
|
|
|
builder.create(mCurrentDialogStyle).show();
|
|
|
|
|
}
|
2020-09-10 22:38:32 +08:00
|
|
|
|
|
|
|
|
public void call(View view) {
|
|
|
|
|
startActivity(new Intent(MainActivity.this, CallActivity.class));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void meeting(View view) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void message(View view) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void report(View view) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// public void exit(View view) {
|
|
|
|
|
// if (ActivityMgr.getActivity(LoginActivity.class) == null) {
|
|
|
|
|
// Intent intent = new Intent(this, LoginActivity.class);
|
|
|
|
|
// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
|
// startActivity(intent);
|
|
|
|
|
// }
|
|
|
|
|
// finish();
|
|
|
|
|
// SipEngine.getInstance().Unregister();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onDestroy() {
|
|
|
|
|
super.onDestroy();
|
2020-09-15 17:57:15 +08:00
|
|
|
mainHandler.removeCallbacks(runGetUsers);
|
2020-09-10 22:38:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean handleMessage(Message m) {
|
|
|
|
|
switch (m.what) {
|
|
|
|
|
case CONS.FINISH:
|
|
|
|
|
finish();
|
|
|
|
|
break;
|
|
|
|
|
case Net.CMD_getUsers:
|
|
|
|
|
if (currSelectData.isAll()) {
|
|
|
|
|
allUsers.clear();
|
|
|
|
|
allUsers.addAll(DBUser.allUser);
|
|
|
|
|
setUsers();
|
|
|
|
|
}
|
2020-09-15 17:57:15 +08:00
|
|
|
refreshView();
|
2020-09-10 22:38:32 +08:00
|
|
|
break;
|
|
|
|
|
case Net.CMD_getGroupMenbers:
|
2020-09-11 22:59:19 +08:00
|
|
|
NetPkg pkg = (NetPkg) (m.obj);
|
|
|
|
|
String oldUUID = pkg.orgs != null ? pkg.orgs.toString() : "";
|
2020-09-10 22:38:32 +08:00
|
|
|
if (!currSelectData.isAll() && oldUUID.equals(currSelectData.id)) {
|
2020-09-11 22:59:19 +08:00
|
|
|
DBGroup group = DBGroup.getGroup(currSelectData.id);
|
|
|
|
|
allUsers.clear();
|
|
|
|
|
allUsers.addAll(group.users);
|
2020-09-10 22:38:32 +08:00
|
|
|
//根据权限来处理
|
|
|
|
|
if (DBUser.mySelf.isManager) {
|
|
|
|
|
DBUser u = new DBUser("", "添加分机", "false");
|
|
|
|
|
u.isAddFlag = true;
|
|
|
|
|
allUsers.add(u);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-15 17:57:15 +08:00
|
|
|
setUsers();
|
2020-09-10 22:38:32 +08:00
|
|
|
break;
|
|
|
|
|
case Net.CMD_getGroups:
|
|
|
|
|
refreshHeaders();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onStop() {
|
|
|
|
|
super.onStop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addVolume(View view) {
|
|
|
|
|
// UIUtl.toast("音量加");
|
|
|
|
|
// int max = audioManager.getStreamMaxVolume( AudioManager.STREAM_VOICE_CALL );
|
|
|
|
|
audioManager.adjustStreamVolume(AudioManager.STREAM_VOICE_CALL, AudioManager.ADJUST_RAISE, 0);
|
|
|
|
|
int current = audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL);
|
|
|
|
|
textVolum.setText("音量:" + current);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void delVolume(View view) {
|
|
|
|
|
// UIUtl.toastW("音量减");
|
|
|
|
|
audioManager.adjustStreamVolume(AudioManager.STREAM_VOICE_CALL, AudioManager.ADJUST_LOWER, 0);
|
|
|
|
|
int current = audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL);
|
|
|
|
|
textVolum.setText("音量:" + current);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addGroup(View view) {
|
|
|
|
|
startActivity(new Intent(this, CreateGroupActivity.class));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addTmpMeeting(View view) {
|
|
|
|
|
startActivity(new Intent(this, CreateMeetingActivity.class));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void logout(View v) {
|
|
|
|
|
SipEngine.getInstance().onLine = false;
|
|
|
|
|
SipEngine.getInstance().isRelogin = true;
|
|
|
|
|
// SipEngine.getInstance().Unregister();
|
|
|
|
|
// SipEngine.getInstance().stop();
|
|
|
|
|
Intent intent = new Intent(App.getContext(), LoginActivity.class);
|
|
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
|
bundle.putBoolean("donotAutoLogin", true);
|
|
|
|
|
intent.putExtras(bundle);
|
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
finish();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void doMeetingVoice4Group(View v) {
|
|
|
|
|
if (currSelectData.isAll()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SipEngine.getInstance().CallNumber(currSelectData.audio_code, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void doMeetingVideo4Group(View v) {
|
|
|
|
|
if (currSelectData.isAll()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SipEngine.getInstance().CallNumber(currSelectData.video_code, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void deleteGroup(View v) {
|
|
|
|
|
if (currSelectData.isAll()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
new QMUIDialog.MessageDialogBuilder(this)
|
|
|
|
|
.setTitle("提示")
|
|
|
|
|
.setMessage("确定要删除分组吗?")
|
|
|
|
|
.setSkinManager(QMUISkinManager.defaultInstance(this))
|
|
|
|
|
.addAction("取消", new QMUIDialogAction.ActionListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(QMUIDialog dialog, int index) {
|
|
|
|
|
dialog.dismiss();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.addAction(0, "删除", QMUIDialogAction.ACTION_PROP_NEGATIVE, new QMUIDialogAction.ActionListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(QMUIDialog dialog, int index) {
|
2020-09-11 22:59:19 +08:00
|
|
|
Net.deleteGroup(currSelectData.id, new HttpUtl.CallBack() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onRequestComplete(int cmd, String result, Object orgs) {
|
|
|
|
|
UIUtl.toastS("分组删除成功");
|
|
|
|
|
Net.getGroups(null, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onRequestError(int cmd, String result, Object orgs) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}, null);
|
2020-09-10 22:38:32 +08:00
|
|
|
dialog.dismiss();
|
2020-09-11 22:59:19 +08:00
|
|
|
|
2020-09-10 22:38:32 +08:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.create(mCurrentDialogStyle).show();
|
|
|
|
|
}
|
|
|
|
|
}
|