소스 검색

upgrade

master
chenbin 4 년 전
부모
커밋
2ce5beace4

+ 3
- 2
app/src/main/java/com/tianrun/sipcall/SipEngine.java 파일 보기

@@ -117,6 +117,7 @@ public class SipEngine implements BluetelInterface {
117 117
         this.ip = ip;
118 118
         this.port = port;
119 119
         myBluetelEngine.Register(name, pw, ip, port);
120
+        isRelogin = false;
120 121
     }
121 122
 
122 123
     /**
@@ -132,6 +133,7 @@ public class SipEngine implements BluetelInterface {
132 133
 
133 134
     @Override
134 135
     public void AccountState(String uri, boolean state) {
136
+        if(isRelogin) return;
135 137
         logmy.e(uri + "-->" + state);
136 138
         if (state) {
137 139
             if (!onLine) {
@@ -150,12 +152,11 @@ public class SipEngine implements BluetelInterface {
150 152
                 }, null);
151 153
             }
152 154
         } else {
153
-            if(!onLine && !isRelogin) {
155
+            if(!onLine) {
154 156
                 UIUtl.toastI("Sip登陆失败");
155 157
                 ActivityMgr.sendMsg(CONS.LOGINFAILED, null);
156 158
             }
157 159
         }
158
-        isRelogin = false;
159 160
     }
160 161
 
161 162
     public boolean isMeetingCall(String phoneNo) {

+ 6
- 0
app/src/main/java/com/tianrun/sipcall/call/CreateGroupActivity.java 파일 보기

@@ -56,6 +56,7 @@ public class CreateGroupActivity extends TrBaseActivity {
56 56
         DBUser u = new DBUser("", "添加分机号", "");
57 57
         u.isAddFlag = true;
58 58
         users.add(u);
59
+        users.add(DBUser.mySelf);
59 60
 
60 61
         setList(null);
61 62
     }
@@ -219,6 +220,11 @@ public class CreateGroupActivity extends TrBaseActivity {
219 220
     }
220 221
 
221 222
     public void createGroup(View view) {
223
+        String name = meetingTopic.getText().toString();
224
+        if(name == null || name.isEmpty()) {
225
+            UIUtl.toastI("分组名不能为空");
226
+            return;
227
+        }
222 228
         String userStr = getSelectedUsers();
223 229
         if (userStr == null || userStr == "") {
224 230
             UIUtl.toastI("请添加要加入会议的分机号");

+ 12
- 11
app/src/main/java/com/tianrun/sipcall/call/CreateMeetingActivity.java 파일 보기

@@ -174,7 +174,7 @@ public class CreateMeetingActivity extends TrBaseActivity {
174 174
         List<String> list = new ArrayList<>();
175 175
         List<String> listPhone = new ArrayList<>();
176 176
         for (DBUser u : DBUser.allUser) {
177
-            if (mapUsers.get(u.phone) == null) {
177
+            if (mapUsers.get(u.phone) == null && (!u.isBusy())) { // 只有空间的才加入
178 178
                 listPhone.add(u.phone);
179 179
                 list.add(u.phone + " | " + u.name);
180 180
             }
@@ -256,16 +256,17 @@ public class CreateMeetingActivity extends TrBaseActivity {
256 256
         Net.createMeeting(meetingTopic.getText().toString(), meetingDesc.getText().toString(), userStr, new HttpUtl.CallBack() {
257 257
             @Override
258 258
             public void onRequestComplete(int cmd, String result, Object orgs) {
259
-                JSONObject jo = JSONObject.parseObject(result);
260
-                if (jo != null) {
261
-                    String code = "";
262
-                    if(isVideo) {
263
-                        code = jo.getString("video_code");
264
-                    } else {
265
-                        code = jo.getString("audio_code");
266
-                    }
267
-                    SipEngine.getInstance().CallNumber(code, isVideo);
268
-                }
259
+//                JSONObject jo = JSONObject.parseObject(result);
260
+//                if (jo != null) {
261
+//                    String code = "";
262
+//                    if(isVideo) {
263
+//                        code = jo.getString("video_code");
264
+//                    } else {
265
+//                        code = jo.getString("audio_code");
266
+//                    }
267
+//                    SipEngine.getInstance().CallNumber(code, isVideo);
268
+//                }
269
+                UIUtl.toastS("临时会议创建成功");
269 270
                 dialog.dismiss();
270 271
                 finish();
271 272
             }

+ 21
- 4
app/src/main/java/com/tianrun/sipcall/call/InCallMeetingActivity.java 파일 보기

@@ -147,9 +147,21 @@ public class InCallMeetingActivity extends TrBaseActivity implements OnClickList
147 147
         allUsers.clear();
148 148
         setUsers();
149 149
         getMembers();
150
+        getMemberTimer();
150 151
         initTabAndPager();
151 152
     }
152 153
 
154
+    static void getMemberTimer() {
155
+        CONS.SENDMESSAGETO(handler_CallActivity, -1, null);
156
+        handler_CallActivity.postDelayed(getMemberRunner, 2000);
157
+    }
158
+    static Runnable getMemberRunner = new Runnable() {
159
+        @Override
160
+        public void run() {
161
+            getMemberTimer();
162
+        }
163
+    };
164
+
153 165
     private void initview() {
154 166
         View view = findViewById(R.id.IncallMeetingRoot);
155 167
         gridUser = view.findViewById(R.id.GridUser);
@@ -393,7 +405,7 @@ public class InCallMeetingActivity extends TrBaseActivity implements OnClickList
393 405
                                 ));
394 406
                             }
395 407
 
396
-                            qa.addAction(new QMUIQuickAction.Action().icon(R.drawable.fullscreen).text("切到主界面").onClick(
408
+                            qa.addAction(new QMUIQuickAction.Action().icon(R.drawable.fullscreen).text("主界面").onClick(
397 409
                                     new QMUIQuickAction.OnClickListener() {
398 410
                                         @Override
399 411
                                         public void onClick(QMUIQuickAction quickAction, QMUIQuickAction.Action action, int position) {
@@ -490,11 +502,13 @@ public class InCallMeetingActivity extends TrBaseActivity implements OnClickList
490 502
         stopVideoStream(true);
491 503
         super.onDestroy();
492 504
         SipEngine.getInstance().hangup(callid);
505
+        handler_CallActivity.removeCallbacks(getMemberRunner);
493 506
         handler_CallActivity = null;
494 507
         if (wakeLock != null) {
495 508
             wakeLock.release();
496 509
             wakeLock = null;
497 510
         }
511
+
498 512
     }
499 513
 
500 514
     /**
@@ -553,6 +567,9 @@ public class InCallMeetingActivity extends TrBaseActivity implements OnClickList
553 567
             case Net
554 568
                     .CMD_getGroupMenbers:
555 569
                 break;
570
+            case  -1:
571
+                getMembers();
572
+                break;
556 573
         }
557 574
         return true;
558 575
     }
@@ -658,7 +675,7 @@ public class InCallMeetingActivity extends TrBaseActivity implements OnClickList
658 675
                     }
659 676
                 }
660 677
         ));
661
-        qa.addAction(new QMUIQuickAction.Action().icon(R.drawable.unmute).text("全部取消禁言").onClick(
678
+        qa.addAction(new QMUIQuickAction.Action().icon(R.drawable.unmute).text("取消禁言").onClick(
662 679
                 new QMUIQuickAction.OnClickListener() {
663 680
                     @Override
664 681
                     public void onClick(QMUIQuickAction quickAction, QMUIQuickAction.Action action, int position) {
@@ -687,7 +704,7 @@ public class InCallMeetingActivity extends TrBaseActivity implements OnClickList
687 704
                 .dimAmount(0.5f)
688 705
                 .skinManager(QMUISkinManager.defaultInstance(InCallMeetingActivity.this))
689 706
                 .edgeProtection(QMUIDisplayHelper.dp2px(InCallMeetingActivity.this, 20));
690
-        qa.addAction(new QMUIQuickAction.Action().icon(R.drawable.unvideo).text("全部关闭视频").onClick(
707
+        qa.addAction(new QMUIQuickAction.Action().icon(R.drawable.unvideo).text("全部关闭").onClick(
691 708
                 new QMUIQuickAction.OnClickListener() {
692 709
                     @Override
693 710
                     public void onClick(QMUIQuickAction quickAction, QMUIQuickAction.Action action, int position) {
@@ -705,7 +722,7 @@ public class InCallMeetingActivity extends TrBaseActivity implements OnClickList
705 722
                     }
706 723
                 }
707 724
         ));
708
-        qa.addAction(new QMUIQuickAction.Action().icon(R.drawable.video).text("全部恢复视频").onClick(
725
+        qa.addAction(new QMUIQuickAction.Action().icon(R.drawable.video).text("全部恢复").onClick(
709 726
                 new QMUIQuickAction.OnClickListener() {
710 727
                     @Override
711 728
                     public void onClick(QMUIQuickAction quickAction, QMUIQuickAction.Action action, int position) {

+ 3
- 3
app/src/main/java/com/tianrun/sipcall/db/DBUser.java 파일 보기

@@ -18,7 +18,7 @@ public class DBUser {
18 18
     public String name = "";
19 19
     public String phone = "";
20 20
     public String status = "";
21
-    public boolean isManager = false;
21
+    public boolean isManager = true;
22 22
     public boolean isAddFlag = false;
23 23
 
24 24
     public boolean isMute = false;
@@ -37,7 +37,7 @@ public class DBUser {
37 37
         this.status = d.getString("sip_state");
38 38
         String weight = d.getString("weight");
39 39
         if (weight != null) {
40
-            this.isManager = weight.equals("1");
40
+            this.isManager = weight.equals("1") ? true : false;
41 41
         } else {
42 42
             this.isManager = false;
43 43
         }
@@ -66,7 +66,7 @@ public class DBUser {
66 66
             u = new DBUser((JSONObject) o);
67 67
             allUser.add(u);
68 68
             mapUsers.put(u.phone, u);
69
-            if (mySelf != null && u.phone == mySelf.phone) {
69
+            if (mySelf != null && u.phone.equals(mySelf.phone)) {
70 70
                 mySelf = u;
71 71
             }
72 72
         }

+ 29
- 4
app/src/main/java/com/tianrun/sipcall/login/LoginActivity.java 파일 보기

@@ -45,7 +45,7 @@ import java.util.List;
45 45
 
46 46
 public class LoginActivity extends TrBaseActivity {
47 47
     private TextView show;
48
-    private EditText username, userpw, userip, userport;
48
+    private EditText username, userpw, userip, userport, httpHost, httpPort;
49 49
 
50 50
     /**
51 51
      * 账号密码服务器地址端口直接在这输入
@@ -54,6 +54,8 @@ public class LoginActivity extends TrBaseActivity {
54 54
     private String pw = "";
55 55
     private int port = 0;
56 56
     private String ip = "";
57
+    private String http_ip = "";
58
+    private int http_port = 0;
57 59
     QMUITipDialog dialogLoading;
58 60
 
59 61
     @Override
@@ -65,6 +67,8 @@ public class LoginActivity extends TrBaseActivity {
65 67
         userpw = findViewById(R.id.userpw);
66 68
         userip = findViewById(R.id.userip);
67 69
         userport = findViewById(R.id.userport);
70
+        httpHost = findViewById(R.id.http_host);
71
+        httpPort = findViewById(R.id.http_port);
68 72
         if (Build.VERSION.SDK_INT >= 23) {//6.0才用动态权限
69 73
             initPermission();
70 74
         }
@@ -75,7 +79,11 @@ public class LoginActivity extends TrBaseActivity {
75 79
             username.setText(obj.getString("name"));
76 80
             userpw.setText(obj.getString("password"));
77 81
             userip.setText(obj.getString("ip"));
78
-            userport.setText(obj.getInteger("port").toString());
82
+            Integer port = obj.getInteger("port");
83
+            userport.setText(port == null? "" : port.toString());
84
+            httpHost.setText(obj.getString("http_ip"));
85
+            port = obj.getInteger("http_port");
86
+            httpPort.setText(port == null? "" : port.toString());
79 87
 
80 88
             handler.postDelayed(new Runnable() {
81 89
                 @Override
@@ -122,9 +130,13 @@ public class LoginActivity extends TrBaseActivity {
122 130
     public void doLogin() {
123 131
         if (SipEngine.getInstance().isonLine())
124 132
             return;
125
-        if (!isEnable())
133
+        if (!isEnable()) {
134
+            UIUtl.toastI("请填写完整的设置信息");
126 135
             return;
136
+        }
127 137
         dialogLoading = UIUtl.toastLoading("");
138
+        Net.ip = http_ip;
139
+        Net.port = http_port;
128 140
         SipEngine.getInstance().init();//先初始化
129 141
         new Handler().postDelayed(new Runnable() {
130 142
             @Override
@@ -143,6 +155,8 @@ public class LoginActivity extends TrBaseActivity {
143 155
         boolean b = false;
144 156
         boolean c = false;
145 157
         boolean d = false;
158
+        boolean e = false;
159
+        boolean f = false;
146 160
         if (username.getText().toString() != null && !username.getText().toString().equals("")) {
147 161
             name = username.getText().toString();
148 162
             a = true;
@@ -160,7 +174,16 @@ public class LoginActivity extends TrBaseActivity {
160 174
             d = true;
161 175
         }
162 176
 
163
-        return a && b && c && d;
177
+        if (httpHost.getText().toString() != null && !httpHost.getText().toString().equals("")) {
178
+            http_ip = httpHost.getText().toString();
179
+            e = true;
180
+        }
181
+        if (httpPort.getText().toString() != null && !httpPort.getText().toString().equals("")) {
182
+            http_port = Integer.parseInt(httpPort.getText().toString());
183
+            f = true;
184
+        }
185
+
186
+        return a && b && c && d && e && f;
164 187
 
165 188
     }
166 189
 
@@ -175,6 +198,8 @@ public class LoginActivity extends TrBaseActivity {
175 198
         jo.put("password", password);
176 199
         jo.put("ip", ip);
177 200
         jo.put("port", port);
201
+        jo.put("http_ip", http_ip);
202
+        jo.put("http_port", http_port);
178 203
         SharedPreferences sp = getSharedPreferences("UserInfor", MODE_PRIVATE);
179 204
         sp.edit().putString("content", jo.toJSONString()).commit();
180 205
     }

+ 28
- 8
app/src/main/java/com/tianrun/sipcall/login/MainActivity.java 파일 보기

@@ -7,6 +7,7 @@ import android.graphics.Color;
7 7
 import android.media.AudioManager;
8 8
 import android.os.Build;
9 9
 import android.os.Bundle;
10
+import android.os.Handler;
10 11
 import android.os.Message;
11 12
 import android.view.View;
12 13
 import android.view.ViewGroup;
@@ -56,6 +57,7 @@ import java.util.ArrayList;
56 57
 import java.util.List;
57 58
 
58 59
 public class MainActivity extends TrBaseActivity {
60
+    public static Handler mainHandler;
59 61
     TextView textVolum;
60 62
     TextView textSelfNum;
61 63
     QMUITabSegment mTabSegment;
@@ -71,6 +73,8 @@ public class MainActivity extends TrBaseActivity {
71 73
     ImageView buttonAddVol;
72 74
     ImageView buttonDelVol;
73 75
     DBHead currSelectData;
76
+    ImageView imageViewSelfStatus;
77
+    TextView textViewSelfStatus;
74 78
 
75 79
     GridView gridUser;
76 80
     List<Object> allUsers = new ArrayList<>();
@@ -119,6 +123,8 @@ public class MainActivity extends TrBaseActivity {
119 123
         setContentView(R.layout.activity_main);
120 124
         textVolum = findViewById(R.id.Volumne);
121 125
         textSelfNum = findViewById(R.id.textViewSelfNum);
126
+        imageViewSelfStatus = findViewById(R.id.imageViewSelfStatus);
127
+        textViewSelfStatus = findViewById(R.id.textViewSelfStatus);
122 128
         mTabSegment = findViewById(R.id.HeadList);
123 129
         gridUser = findViewById(R.id.GridUser);
124 130
         mContentViewPager = findViewById(R.id.contentViewPager);
@@ -144,6 +150,7 @@ public class MainActivity extends TrBaseActivity {
144 150
                 return true;
145 151
             }
146 152
         });
153
+        mainHandler = this.handler;
147 154
 
148 155
         ButtonDelGroup.setVisibility(View.INVISIBLE);
149 156
         StartMeetingVoice.setVisibility(View.INVISIBLE);
@@ -155,7 +162,7 @@ public class MainActivity extends TrBaseActivity {
155 162
         headers.add(currSelectData);
156 163
         initTabAndPager();
157 164
         Net.getGroups(null, null);
158
-        Net.getUsers(null, null);
165
+        getUsersData();
159 166
         checkBeforeMeetingState();
160 167
     }
161 168
 
@@ -243,6 +250,7 @@ public class MainActivity extends TrBaseActivity {
243 250
                 if (currSelectData.isAll()) {
244 251
                     allUsers.addAll(DBUser.allUser);
245 252
                     setUsers();
253
+                    Net.getUsers(null, null);
246 254
                 } else {
247 255
                     DBGroup group = DBGroup.getGroup(currSelectData.id);
248 256
                     if (group != null) {
@@ -290,6 +298,17 @@ public class MainActivity extends TrBaseActivity {
290 298
             buttonAddGroup.setVisibility(View.INVISIBLE);
291 299
             imageViewAddGroupIcon.setVisibility(View.INVISIBLE);
292 300
         }
301
+
302
+        if (DBUser.mySelf.isBusy()) {
303
+            imageViewSelfStatus.setColorFilter(Color.RED);
304
+            textViewSelfStatus.setText("通话中");
305
+        } else if (DBUser.mySelf.isOnline()) {
306
+            imageViewSelfStatus.setColorFilter(Color.GREEN);
307
+            textViewSelfStatus.setText("在线");
308
+        } else {
309
+            imageViewSelfStatus.setColorFilter(Color.GRAY);
310
+            textViewSelfStatus.setText("离线");
311
+        }
293 312
     }
294 313
 
295 314
     void chgVolum(View v, boolean isAdd) {
@@ -314,7 +333,7 @@ public class MainActivity extends TrBaseActivity {
314 333
     static Runnable runGetUsers = new Runnable() {
315 334
         @Override
316 335
         public void run() {
317
-            Net.getUsers(null, null);
336
+            getUsersData();
318 337
         }
319 338
     };
320 339
 
@@ -322,8 +341,9 @@ public class MainActivity extends TrBaseActivity {
322 341
         return gridUser;
323 342
     }
324 343
 
325
-    public void getUsersData() {
326
-        handler.postDelayed(runGetUsers, 3000);
344
+    public static void getUsersData() {
345
+        Net.getUsers(null, null);
346
+        mainHandler.postDelayed(runGetUsers, 3000);
327 347
     }
328 348
 
329 349
     public void setUsers() {
@@ -404,7 +424,7 @@ public class MainActivity extends TrBaseActivity {
404 424
                                     public void onClick(QMUIQuickAction quickAction, QMUIQuickAction.Action action, int position) {
405 425
                                         quickAction.dismiss();
406 426
                                         QMUITipDialog dialog = UIUtl.toastLoading("");
407
-                                        Net.kickMember4Group(currSelectData.audio_code, d.phone, new HttpUtl.CallBack() {
427
+                                        Net.deleteMember4Group(currSelectData.id, d.phone, new HttpUtl.CallBack() {
408 428
                                             @Override
409 429
                                             public void onRequestComplete(int cmd, String result, Object orgs) {
410 430
                                                 UIUtl.toastS("移除分机成功");
@@ -526,6 +546,7 @@ public class MainActivity extends TrBaseActivity {
526 546
     @Override
527 547
     protected void onDestroy() {
528 548
         super.onDestroy();
549
+        mainHandler.removeCallbacks(runGetUsers);
529 550
     }
530 551
 
531 552
     @Override
@@ -535,12 +556,12 @@ public class MainActivity extends TrBaseActivity {
535 556
                 finish();
536 557
                 break;
537 558
             case Net.CMD_getUsers:
538
-                getUsersData();
539 559
                 if (currSelectData.isAll()) {
540 560
                     allUsers.clear();
541 561
                     allUsers.addAll(DBUser.allUser);
542 562
                     setUsers();
543 563
                 }
564
+                refreshView();
544 565
                 break;
545 566
             case Net.CMD_getGroupMenbers:
546 567
                 NetPkg pkg = (NetPkg) (m.obj);
@@ -555,8 +576,8 @@ public class MainActivity extends TrBaseActivity {
555 576
                         u.isAddFlag = true;
556 577
                         allUsers.add(u);
557 578
                     }
558
-                    setUsers();
559 579
                 }
580
+                setUsers();
560 581
                 break;
561 582
             case Net.CMD_getGroups:
562 583
                 refreshHeaders();
@@ -568,7 +589,6 @@ public class MainActivity extends TrBaseActivity {
568 589
     @Override
569 590
     protected void onStop() {
570 591
         super.onStop();
571
-        handler.removeCallbacks(runGetUsers);
572 592
     }
573 593
 
574 594
     public void addVolume(View view) {

+ 9
- 1
app/src/main/java/com/tianrun/sipcall/net/Net.java 파일 보기

@@ -32,6 +32,7 @@ public class Net {
32 32
     public static final int CMD_unvmuteMember4Group = 7013;
33 33
     public static final int CMD_vidlayoutMember4Group = 7014;
34 34
     public static final int CMD_vidfloorMember4Group = 7015;
35
+    public static final int CMD_deleteMember4Group = 7016;
35 36
 
36 37
     static HttpUtl.CallBack _callback = new HttpUtl.CallBack() {
37 38
         @Override
@@ -97,7 +98,7 @@ public class Net {
97 98
 
98 99
     public static void createMeeting(String topic, String description, String members, HttpUtl.CallBack callBack, Object orgs) {
99 100
         String url = "http://" + ip + ":" + port + "/api/conferences/conference/insert";
100
-        String _params = "topic=" + topic + "&description=" + description + "&members=" + members + "&typ=prompt" + "&start_member=" + DBUser.mySelf.phone;
101
+        String _params = "topic=" + topic + "&description=" + description + "&members=" + members + "&type=prompt" + "&start_member=" + DBUser.mySelf.phone;
101 102
         Object[] params = {callBack, orgs};
102 103
         HttpUtl.doPostAsyn(url, _params, _callback, CMD_createMeeting, params);
103 104
     }
@@ -135,6 +136,13 @@ public class Net {
135 136
         HttpUtl.doPostAsyn(url, _params, _callback, CMD_addUser2Group, params);
136 137
     }
137 138
 
139
+    public static void deleteMember4Group(String task_uuid, String members, HttpUtl.CallBack callBack, Object orgs) {
140
+        String url = "http://" + ip + ":" + port + "/api/conferences/conference/delete";
141
+        String _params = "task_uuid=" + task_uuid + "&members=" + members;
142
+        Object[] params = {callBack, orgs};
143
+        HttpUtl.doPostAsyn(url, _params, _callback, CMD_deleteMember4Group, params);
144
+    }
145
+
138 146
     public static void kickMember4Group(String task_uuid, String members, HttpUtl.CallBack callBack, Object orgs) {
139 147
         String url = "http://" + ip + ":" + port + "/api/conferences/conference/update";
140 148
         String _params = "opr_nbr=" + task_uuid + "&opr_member=" + members + "&opr_action=kick";

+ 11
- 2
app/src/main/java/com/tianrun/sipcall/ui/TrBaseActivity.java 파일 보기

@@ -18,17 +18,26 @@ public class TrBaseActivity extends AppCompatActivity implements Handler.Callbac
18 18
     }
19 19
 
20 20
 
21
+
21 22
     @Override
22 23
     protected void onResume() {
23 24
         super.onResume();
24 25
         ActivityMgr.onShowActivity(this);
25 26
     }
26 27
 
28
+    @Override
29
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
30
+        super.onCreate(savedInstanceState);
31
+    }
32
+
27 33
     @Override
28 34
     protected void onStop() {
29 35
         super.onStop();
30
-        ActivityMgr.onHideActivity(this);
31 36
     }
32 37
 
33
-
38
+    @Override
39
+    protected void onDestroy() {
40
+        super.onDestroy();
41
+        ActivityMgr.onHideActivity(this);
42
+    }
34 43
 }

+ 1
- 1
app/src/main/java/com/tianrun/sipcall/ui/UIUtl.java 파일 보기

@@ -114,7 +114,7 @@ public class UIUtl {
114 114
                     System.out.println(e);
115 115
                 }
116 116
             }
117
-        }, 1200);
117
+        }, 1000);
118 118
     }
119 119
 
120 120
     public static TrAdapter setList(Context context, GridView grid, int convertViewId, Object list, TrAdapter.Callback callback) {

+ 33
- 1
app/src/main/java/com/tianrun/sipcall/utils/HttpUtl.java 파일 보기

@@ -1,10 +1,19 @@
1 1
 package com.tianrun.sipcall.utils;
2 2
 
3
+import android.content.Intent;
4
+import android.content.pm.PackageItemInfo;
3 5
 import android.graphics.Bitmap;
4 6
 import android.graphics.BitmapFactory;
5 7
 import android.net.Uri;
8
+import android.os.Bundle;
6 9
 import android.util.Log;
7 10
 
11
+import com.tianrun.sipcall.App;
12
+import com.tianrun.sipcall.SipEngine;
13
+import com.tianrun.sipcall.login.LoginActivity;
14
+import com.tianrun.sipcall.ui.ActivityMgr;
15
+import com.tianrun.sipcall.ui.UIUtl;
16
+
8 17
 import java.io.BufferedReader;
9 18
 import java.io.ByteArrayOutputStream;
10 19
 import java.io.DataOutputStream;
@@ -137,13 +146,14 @@ public class HttpUtl {
137 146
                     baos.write(buf, 0, len);
138 147
                 }
139 148
                 baos.flush();
140
-                if (baos.toString()==null||baos.toString().equals("")) {
149
+                if (baos.toString() == null || baos.toString().equals("")) {
141 150
                     Log.i("http", "result为空");
142 151
                 } else {
143 152
                     Log.i("http", baos.toString());
144 153
                 }
145 154
                 return baos.toString();
146 155
             } else {
156
+                checkTokenFailed(retCode);
147 157
                 throw new RuntimeException(" responseCode :" + retCode);
148 158
             }
149 159
 
@@ -166,6 +176,25 @@ public class HttpUtl {
166 176
 //        return null;
167 177
     }
168 178
 
179
+    static void checkTokenFailed(int code) {
180
+        if(code == 401) {
181
+            UIUtl.toastI("Token 失效");
182
+
183
+            if(ActivityMgr.topActivity != null) {
184
+                SipEngine.getInstance().onLine = false;
185
+                SipEngine.getInstance().isRelogin = true;
186
+//        SipEngine.getInstance().Unregister();
187
+//        SipEngine.getInstance().stop();
188
+                Intent intent = new Intent(App.getContext(), LoginActivity.class);
189
+                Bundle bundle = new Bundle();
190
+                bundle.putBoolean("donotAutoLogin", true);
191
+                intent.putExtras(bundle);
192
+                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
193
+                ActivityMgr.topActivity.startActivity(intent);
194
+            }
195
+        }
196
+    }
197
+
169 198
     /**
170 199
      * 向指定 URL 发送POST方法的请求
171 200
      *
@@ -217,6 +246,9 @@ public class HttpUtl {
217 246
             if (result .equals("{}")){
218 247
                 result = conn.getResponseCode()+"";
219 248
             }
249
+
250
+            int retCode = conn.getResponseCode();
251
+            checkTokenFailed(retCode);
220 252
         } catch (Exception e) {
221 253
             e.printStackTrace();
222 254
             Log.i("http", e.toString());

+ 227
- 58
app/src/main/res/layout/activity_login.xml 파일 보기

@@ -1,4 +1,5 @@
1
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
1
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2
+    xmlns:tools="http://schemas.android.com/tools"
2 3
     android:layout_width="fill_parent"
3 4
     android:layout_height="fill_parent"
4 5
     android:background="@color/whitesmoke"
@@ -11,8 +12,8 @@
11 12
         android:layout_height="wrap_content"
12 13
         android:layout_gravity="center"
13 14
         android:layout_marginTop="20dp"
14
-        android:text="null"
15
-        android:textColor="#FFFFFF"
15
+        android:text="设置"
16
+        android:textColor="#363636"
16 17
         android:textSize="20sp"
17 18
         android:visibility="gone" />
18 19
 
@@ -23,62 +24,229 @@
23 24
         <LinearLayout
24 25
             android:layout_width="match_parent"
25 26
             android:layout_height="wrap_content"
26
-            android:layout_marginTop="10dp"
27
-            android:gravity="center"
28
-            android:orientation="vertical"
29
-            android:padding="10dp">
27
+            android:orientation="vertical">
30 28
 
31
-            <EditText
32
-                android:id="@+id/username"
33
-                android:layout_width="fill_parent"
34
-                android:layout_height="50sp"
35
-                android:layout_marginTop="10dp"
36
-                android:background="@drawable/corners_black"
37
-                android:hint="账号"
38
-                android:padding="5dp"
39
-                android:text="5503"
40
-                android:textColor="@color/blackcolor"
41
-                android:textColorHint="@color/gray"
42
-                android:textSize="15sp" />
43
-
44
-            <EditText
45
-                android:id="@+id/userpw"
46
-                android:layout_width="fill_parent"
47
-                android:layout_height="50sp"
48
-                android:layout_marginTop="10dp"
49
-                android:background="@drawable/corners_black"
50
-                android:hint="密码"
51
-                android:padding="5dp"
52
-                android:text="!@#123Qw"
53
-                android:textColor="@color/blackcolor"
54
-                android:textColorHint="@color/gray"
55
-                android:textSize="15sp" />
56
-
57
-            <EditText
58
-                android:id="@+id/userip"
29
+            <TextView
30
+                android:id="@+id/textView3"
31
+                android:layout_width="match_parent"
32
+                android:layout_height="40dp"
33
+                android:layout_marginLeft="5dp"
34
+                android:layout_weight="1"
35
+                android:gravity="center_vertical"
36
+                android:singleLine="true"
37
+                android:text="SIP设置"
38
+                android:textColor="#CCCCCC"
39
+                android:textSize="18sp"
40
+                android:textStyle="bold" />
41
+
42
+            <LinearLayout
59 43
                 android:layout_width="fill_parent"
60
-                android:layout_height="50sp"
61
-                android:layout_marginTop="10dp"
62
-                android:background="@drawable/corners_black"
63
-                android:hint="服务器地址"
64
-                android:padding="5dp"
65
-                android:text="47.111.20.34"
66
-                android:textColor="@color/blackcolor"
67
-                android:textColorHint="@color/gray"
68
-                android:textSize="15sp" />
69
-
70
-            <EditText
71
-                android:id="@+id/userport"
44
+                android:layout_height="50dp"
45
+                android:background="#FFFFFF"
46
+                android:orientation="horizontal"
47
+                android:visibility="visible">
48
+
49
+                <TextView
50
+                    android:layout_width="0dp"
51
+                    android:layout_height="fill_parent"
52
+                    android:layout_marginLeft="5dp"
53
+                    android:layout_weight="0.5"
54
+                    android:gravity="center_vertical"
55
+                    android:singleLine="true"
56
+                    android:text="分机号"
57
+                    android:textColor="#000000"
58
+                    android:textSize="18sp"
59
+                    android:textStyle="bold" />
60
+
61
+                <EditText
62
+                    android:id="@+id/username"
63
+                    android:layout_width="0dp"
64
+                    android:layout_height="fill_parent"
65
+                    android:layout_weight="1.5"
66
+                    android:hint="请输入"
67
+                    android:singleLine="true"
68
+                    android:textColor="#000000"
69
+                    android:textSize="16sp" />
70
+
71
+            </LinearLayout>
72
+
73
+            <LinearLayout
74
+                android:layout_width="match_parent"
75
+                android:layout_height="match_parent"
76
+                android:layout_marginTop="5dp"
77
+                android:background="#FFFFFF"
78
+                android:orientation="horizontal"
79
+                android:visibility="visible">
80
+
81
+                <TextView
82
+                    android:layout_width="0dp"
83
+                    android:layout_height="fill_parent"
84
+                    android:layout_marginLeft="5dp"
85
+                    android:layout_weight="0.5"
86
+                    android:gravity="center_vertical"
87
+                    android:singleLine="true"
88
+                    android:text="密码"
89
+                    android:textColor="#000000"
90
+                    android:textSize="18sp"
91
+                    android:textStyle="bold" />
92
+
93
+                <EditText
94
+                    android:id="@+id/userpw"
95
+                    android:layout_width="0dp"
96
+                    android:layout_height="fill_parent"
97
+                    android:layout_weight="1.5"
98
+                    android:hint="请输入"
99
+                    android:singleLine="true"
100
+                    android:textColor="#000000"
101
+                    android:textSize="16sp" />
102
+
103
+            </LinearLayout>
104
+
105
+            <LinearLayout
106
+                android:layout_width="match_parent"
107
+                android:layout_height="match_parent"
108
+                android:layout_marginTop="5dp"
109
+                android:background="#FFFFFF"
110
+                android:orientation="horizontal"
111
+                android:visibility="visible">
112
+
113
+                <TextView
114
+                    android:layout_width="0dp"
115
+                    android:layout_height="fill_parent"
116
+                    android:layout_marginLeft="5dp"
117
+                    android:layout_weight="0.5"
118
+                    android:gravity="center_vertical"
119
+                    android:singleLine="true"
120
+                    android:text="SIP服务器"
121
+                    android:textColor="#000000"
122
+                    android:textSize="18sp"
123
+                    android:textStyle="bold" />
124
+
125
+                <EditText
126
+                    android:id="@+id/userip"
127
+                    android:layout_width="0dp"
128
+                    android:layout_height="fill_parent"
129
+                    android:layout_weight="1.5"
130
+                    android:hint="请输入"
131
+                    android:singleLine="true"
132
+                    android:textColor="#000000"
133
+                    android:textSize="16sp" />
134
+
135
+            </LinearLayout>
136
+
137
+            <LinearLayout
138
+                android:layout_width="match_parent"
139
+                android:layout_height="match_parent"
140
+                android:layout_marginTop="5dp"
141
+                android:background="#FFFFFF"
142
+                android:orientation="horizontal"
143
+                android:visibility="visible">
144
+
145
+                <TextView
146
+                    android:layout_width="0dp"
147
+                    android:layout_height="fill_parent"
148
+                    android:layout_marginLeft="5dp"
149
+                    android:layout_weight="0.5"
150
+                    android:gravity="center_vertical"
151
+                    android:singleLine="true"
152
+                    android:text="SIP端口"
153
+                    android:textColor="#000000"
154
+                    android:textSize="18sp"
155
+                    android:textStyle="bold" />
156
+
157
+                <EditText
158
+                    android:id="@+id/userport"
159
+                    android:layout_width="0dp"
160
+                    android:layout_height="fill_parent"
161
+                    android:layout_weight="1.5"
162
+                    android:hint="请输入"
163
+                    android:singleLine="true"
164
+                    android:textColor="#000000"
165
+                    android:textSize="16sp" />
166
+
167
+            </LinearLayout>
168
+
169
+            <TextView
170
+                android:id="@+id/textView4"
171
+                android:layout_width="match_parent"
172
+                android:layout_height="40dp"
173
+                android:layout_marginLeft="5dp"
174
+                android:layout_weight="1"
175
+                android:gravity="center_vertical"
176
+                android:singleLine="true"
177
+                android:text="服务器设置"
178
+                android:textColor="#CCCCCC"
179
+                android:textSize="18sp"
180
+                android:textStyle="bold" />
181
+            <LinearLayout
182
+                android:layout_width="match_parent"
183
+                android:layout_height="match_parent"
184
+                android:layout_marginTop="5dp"
185
+                android:background="#FFFFFF"
186
+                android:orientation="horizontal"
187
+                android:visibility="visible">
188
+
189
+                <TextView
190
+                    android:layout_width="0dp"
191
+                    android:layout_height="fill_parent"
192
+                    android:layout_marginLeft="5dp"
193
+                    android:layout_weight="0.5"
194
+                    android:gravity="center_vertical"
195
+                    android:singleLine="true"
196
+                    android:text="服务器"
197
+                    android:textColor="#000000"
198
+                    android:textSize="18sp"
199
+                    android:textStyle="bold" />
200
+
201
+                <EditText
202
+                    android:id="@+id/http_host"
203
+                    android:layout_width="0dp"
204
+                    android:layout_height="fill_parent"
205
+                    android:layout_weight="1.5"
206
+                    android:hint="请输入"
207
+                    android:singleLine="true"
208
+                    android:textColor="#000000"
209
+                    android:textSize="16sp" />
210
+
211
+            </LinearLayout>
212
+
213
+            <LinearLayout
72 214
                 android:layout_width="fill_parent"
73
-                android:layout_height="50sp"
74
-                android:layout_marginTop="10dp"
75
-                android:background="@drawable/corners_black"
76
-                android:hint="端口"
77
-                android:padding="5dp"
78
-                android:text="5060"
79
-                android:textColor="@color/blackcolor"
80
-                android:textColorHint="@color/gray"
81
-                android:textSize="15sp" />
215
+                android:layout_height="50dp"
216
+                android:layout_marginTop="5dp"
217
+                android:background="#FFFFFF"
218
+                android:orientation="horizontal"
219
+                android:visibility="visible">
220
+
221
+                <TextView
222
+                    android:layout_width="0dp"
223
+                    android:layout_height="fill_parent"
224
+                    android:layout_marginLeft="5dp"
225
+                    android:layout_weight="0.5"
226
+                    android:gravity="center_vertical"
227
+                    android:singleLine="true"
228
+                    android:text="端口"
229
+                    android:textColor="#000000"
230
+                    android:textSize="18sp"
231
+                    android:textStyle="bold" />
232
+
233
+                <EditText
234
+                    android:id="@+id/http_port"
235
+                    android:layout_width="0dp"
236
+                    android:layout_height="fill_parent"
237
+                    android:layout_weight="1.5"
238
+                    android:hint="请输入"
239
+                    android:singleLine="true"
240
+                    android:textColor="#000000"
241
+                    android:textSize="16sp" />
242
+
243
+            </LinearLayout>
244
+
245
+            <TextView
246
+                android:id="@+id/textView5"
247
+                android:layout_width="match_parent"
248
+                android:layout_height="30dp"
249
+                android:layout_weight="1" />
82 250
 
83 251
             <Button
84 252
                 android:layout_width="fill_parent"
@@ -86,7 +254,7 @@
86 254
                 android:layout_margin="10dp"
87 255
                 android:background="@drawable/callpad_bg"
88 256
                 android:onClick="login"
89
-                android:text="登录"
257
+                android:text="确定"
90 258
                 android:textColor="#FFFFFF"
91 259
                 android:textSize="20sp" />
92 260
 
@@ -102,7 +270,8 @@
102 270
                 android:textColor="#FFFFFF"
103 271
                 android:textSize="20sp"
104 272
                 android:visibility="invisible" />
273
+
105 274
         </LinearLayout>
106 275
     </ScrollView>
107 276
 
108
-</LinearLayout>
277
+</RelativeLayout>

+ 26
- 2
app/src/main/res/layout/activity_main.xml 파일 보기

@@ -94,9 +94,33 @@
94 94
         android:layout_marginBottom="50dp"
95 95
         android:background="@drawable/bt_bgd"
96 96
         android:onClick="logout"
97
-        android:text="退出"
97
+        android:text="设置"
98 98
         android:textColor="#FFFFFF" />
99 99
 
100
+    <ImageView
101
+        android:id="@+id/imageViewSelfStatus"
102
+        android:layout_width="10dp"
103
+        android:layout_height="10dp"
104
+        android:layout_alignParentStart="true"
105
+        android:layout_alignParentBottom="true"
106
+        android:layout_marginStart="18dp"
107
+        android:layout_marginBottom="7dp"
108
+        android:layout_weight="1"
109
+        app:srcCompat="@drawable/circle"
110
+        app:tint="#5EE463" />
111
+
112
+    <TextView
113
+        android:id="@+id/textViewSelfStatus"
114
+        android:layout_width="wrap_content"
115
+        android:layout_height="wrap_content"
116
+        android:layout_alignParentStart="true"
117
+        android:layout_alignParentBottom="true"
118
+        android:layout_marginStart="30dp"
119
+        android:layout_marginBottom="5dp"
120
+        android:text="在线"
121
+        android:textAlignment="textStart"
122
+        android:textSize="12sp" />
123
+
100 124
     <TextView
101 125
         android:id="@+id/textViewSelfNum"
102 126
         android:layout_width="wrap_content"
@@ -105,7 +129,7 @@
105 129
         android:layout_alignParentStart="true"
106 130
         android:layout_alignParentBottom="true"
107 131
         android:layout_marginEnd="5dp"
108
-        android:layout_marginBottom="20dp"
132
+        android:layout_marginBottom="24dp"
109 133
         android:text="号码:xxxx"
110 134
         android:textAlignment="center"
111 135
         android:textSize="12sp" />

+ 4
- 1
app/src/main/res/layout/creatgroup_view.xml 파일 보기

@@ -78,6 +78,7 @@
78 78
             android:layout_width="wrap_content"
79 79
             android:layout_height="wrap_content"
80 80
             android:layout_weight="1"
81
+            android:background="@drawable/qmui_divider"
81 82
             android:onClick="exit"
82 83
             android:text="取消"
83 84
             android:textColor="@color/redcolor"
@@ -88,8 +89,10 @@
88 89
             android:layout_width="wrap_content"
89 90
             android:layout_height="wrap_content"
90 91
             android:layout_weight="1"
92
+            android:background="@drawable/callpad_bg"
91 93
             android:onClick="createGroup"
92
-            android:text="创建分组" />
94
+            android:text="创建分组"
95
+            android:textColor="#FFFFFF" />
93 96
 
94 97
     </LinearLayout>
95 98
 

+ 4
- 5
app/src/main/res/layout/incallmeetingactivity.xml 파일 보기

@@ -4,8 +4,7 @@
4 4
     xmlns:tools="http://schemas.android.com/tools"
5 5
     android:id="@+id/IncallMeetingRoot"
6 6
     android:layout_width="fill_parent"
7
-    android:layout_height="fill_parent"
8
-    android:background="@drawable/callbackground">
7
+    android:layout_height="fill_parent">
9 8
 
10 9
     <ImageView
11 10
         android:id="@+id/imageView3"
@@ -94,8 +93,8 @@
94 93
             android:layout_width="0dp"
95 94
             android:layout_height="fill_parent"
96 95
             android:layout_weight="1"
97
-            android:background="@drawable/qmui_divider"
98
-            android:src="@drawable/voice2"
96
+            android:background="@drawable/bt_bgd"
97
+            android:src="@drawable/mute"
99 98
             tools:visibility="visible" />
100 99
 
101 100
         <ImageButton
@@ -103,7 +102,7 @@
103 102
             android:layout_width="0dp"
104 103
             android:layout_height="fill_parent"
105 104
             android:layout_weight="1"
106
-            android:background="@drawable/qmui_divider"
105
+            android:background="@drawable/bt_bgd"
107 106
             android:src="@drawable/unvideo"
108 107
             tools:visibility="visible" />
109 108
 

Loading…
취소
저장