Commit 9df45dc03dcd26035ffe407399a1c79ea24544e7

Authored by 陈硕
1 parent 12ab30a5

添加用户输入布局

.idea/modules.xml
... ... @@ -5,7 +5,6 @@
5 5 <module fileurl="file://$PROJECT_DIR$/CNChatNDemo.iml" filepath="$PROJECT_DIR$/CNChatNDemo.iml" />
6 6 <module fileurl="file://$PROJECT_DIR$/CNIMDemo.iml" filepath="$PROJECT_DIR$/CNIMDemo.iml" />
7 7 <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
8   - <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
9 8 </modules>
10 9 </component>
11 10 </project>
12 11 \ No newline at end of file
... ...
app/build.gradle
... ... @@ -13,8 +13,14 @@ android {
13 13 }
14 14 buildTypes {
15 15 release {
  16 + minifyEnabled true
  17 + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  18 +
  19 + }
  20 + debug {
16 21 minifyEnabled false
17 22 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  23 + debuggable true
18 24 }
19 25 }
20 26 }
... ...
app/doc/聊天SDK文档.docx deleted 100644 → 0
No preview for this file type
app/proguard-rules.pro
  1 +# 通用混淆配置
  2 +#不混淆泛型 -keepattributes SourceFile
  3 +-keepattributes Signature,InnerClasses,Exceptions,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod
  4 +
  5 + -optimizationpasses 5
  6 + -dontusemixedcaseclassnames
  7 + -dontskipnonpubliclibraryclasses
  8 + -dontpreverify
  9 + -verbose
  10 + -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
  11 +
  12 + #忽略警告 也可以用-ignorewarnings
  13 + -dontwarn
  14 +
  15 + -keep public class * extends android.app.Activity
  16 + -keep public class * extends android.app.Application
  17 + -keep public class * extends android.app.Service
  18 + -keep public class * extends android.content.BroadcastReceiver
  19 + -keep public class * extends android.content.ContentProvider
  20 + -keep public class * extends android.app.backup.BackupAgentHelper
  21 + -keep public class * extends android.preference.Preference
  22 + -keep public class com.android.vending.licensing.ILicensingService
  23 +
  24 + -keepclasseswithmembernames class * {
  25 + native <methods>;
  26 + }
  27 +
  28 + -keepclasseswithmembers class * {
  29 + public <init>(android.content.Context, android.util.AttributeSet);
  30 + }
  31 +
  32 + -keepclasseswithmembers class * {
  33 + public <init>(android.content.Context, android.util.AttributeSet, int);
  34 + }
  35 +
  36 + -keepclassmembers class * extends android.app.Activity {
  37 + public void *(android.view.View);
  38 + }
  39 +
  40 + -keepclassmembers enum * {
  41 + public static **[] values();
  42 + public static ** valueOf(java.lang.String);
  43 + }
  44 +
  45 + -keep class * implements android.os.Parcelable {
  46 + public static final android.os.Parcelable$Creator *;
  47 + }
  48 +
  49 +
  50 +
  51 +-dontwarn com.cnlive.libs.util.**
  52 + -keep class com.cnlive.libs.util. { *;}
  53 +
  54 +
  55 +
1 56 # Add project specific ProGuard rules here.
2 57 # By default, the flags in this file are appended to flags specified
3 58 # in D:\AndroidSDK/tools/proguard/proguard-android.txt
... ...
app/src/main/AndroidManifest.xml
... ... @@ -36,7 +36,10 @@
36 36 android:name="com.cnlive.im.ui.ChatRoomActivity"
37 37 android:launchMode="singleTop"
38 38 android:screenOrientation="portrait"
39   - android:windowSoftInputMode="adjustResize" />
  39 + android:windowSoftInputMode="adjustResize"
  40 + android:theme="@style/Theme.AppCompat.Light.NoActionBar"
  41 + >
  42 + </activity>
40 43  
41 44  
42 45 <activity
... ... @@ -44,7 +47,7 @@
44 47 android:launchMode="singleTop"
45 48 android:screenOrientation="portrait"
46 49 android:windowSoftInputMode="adjustResize"
47   - />
  50 + android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
48 51  
49 52 <service
50 53 android:name="io.rong.imlib.ipc.RongService"
... ...
app/src/main/java/com/cnlive/im/ui/ChatRoomActivity.java
... ... @@ -7,7 +7,9 @@ import android.util.Log;
7 7 import android.view.View;
8 8 import android.widget.Button;
9 9 import android.widget.EditText;
  10 +import android.widget.LinearLayout;
10 11 import android.widget.ListView;
  12 +import android.widget.RelativeLayout;
11 13 import android.widget.Toast;
12 14  
13 15 import com.cnlive.im.R;
... ... @@ -37,11 +39,17 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL
37 39 private Button user_switchBtn, reconnectionBtn, switch_visitorsBtn, foundChatBtn, disconnectBtn;
38 40 private Button creatChat2Btn;
39 41 private Handler mHandler;
  42 + private RelativeLayout re_chat;
  43 + private LinearLayout lin_user;
  44 + private Button user_imfor_send;
  45 + private EditText user_id, user_name;
  46 + private CNUserInfo cnUser;
40 47  
41 48  
42 49 @Override
43 50 protected void onCreate(Bundle savedInstanceState) {
44 51 super.onCreate(savedInstanceState);
  52 + //取消状态栏
45 53 setContentView(R.layout.activity_groupchat);
46 54 initUI();
47 55 //设置监听
... ... @@ -54,6 +62,11 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL
54 62  
55 63  
56 64 private void initUI() {
  65 + user_id = (EditText) findViewById(R.id.user_ID);
  66 + user_name = (EditText) findViewById(R.id.user_name);
  67 + user_imfor_send = (Button) findViewById(R.id.user_imfor_send);
  68 + lin_user = (LinearLayout) findViewById(R.id.lin_user);
  69 + re_chat = (RelativeLayout) findViewById(R.id.re_chat);
57 70 creatChat2Btn = (Button) findViewById(R.id.creatChat2);
58 71 disconnectBtn = (Button) findViewById(R.id.disconnect);
59 72 foundChatBtn = (Button) findViewById(R.id.creatChat);
... ... @@ -65,6 +78,7 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL
65 78 editText = (EditText) findViewById(R.id.message_content);
66 79 send_messageOneBtn = (Button) findViewById(R.id.send_messageOne);
67 80 send_messageOneTwo = (Button) findViewById(R.id.send_messageTwo);
  81 + user_imfor_send.setOnClickListener(this);
68 82 disconnectBtn.setOnClickListener(this);
69 83 foundChatBtn.setOnClickListener(this);
70 84 send_messageOneBtn.setOnClickListener(this);
... ... @@ -292,7 +306,7 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL
292 306 break;
293 307 // 用户
294 308 case R.id.user_switch:
295   - ChatUtil.login(new CNUserInfo("5969", "testUser", ""), connectListener);
  309 + ChatUtil.login(cnUser, connectListener);
296 310 break;
297 311 //连接
298 312 case R.id.connectionBtn:
... ... @@ -311,14 +325,27 @@ public class ChatRoomActivity extends AppCompatActivity implements View.OnClickL
311 325 break;
312 326 // 断开连接
313 327 case R.id.disconnect:
314   - ChatUtil.disconnect(true);
  328 + ChatUtil.disconnect(false);
315 329 break;
316   -
  330 + //加入聊天室2
317 331 case R.id.creatChat2:
318 332 ChatUtil.joinChatRoom(roomIdTwo, -1, onOperationListener);
319 333 break;
320 334  
321 335  
  336 + case R.id.user_imfor_send:
  337 + if (user_id.getText().toString().isEmpty())
  338 + Toast.makeText(ChatRoomActivity.this, "用户id不能为空", Toast.LENGTH_SHORT).show();
  339 + else if (user_name.getText().toString().isEmpty())
  340 + Toast.makeText(ChatRoomActivity.this, "用户名不能为空", Toast.LENGTH_SHORT).show();
  341 + else {
  342 + cnUser = new CNUserInfo(user_id.getText().toString(), user_name.getText().toString(), "");
  343 + lin_user.setVisibility(View.INVISIBLE);
  344 + re_chat.setVisibility(View.VISIBLE);
  345 + }
  346 + break;
  347 +
  348 +
322 349 }
323 350 }
324 351  
... ...
app/src/main/java/com/cnlive/im/ui/PrivateChatActivity.java
... ... @@ -211,7 +211,7 @@ public class PrivateChatActivity extends AppCompatActivity implements View.OnCli
211 211 @Override
212 212 protected void onPause() {
213 213 super.onPause();
214   - ChatUtil.disconnect(true);
  214 + ChatUtil.disconnect(false);
215 215  
216 216 }
217 217  
... ...
app/src/main/res/layout/activity_groupchat.xml
... ... @@ -2,127 +2,246 @@
2 2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 3 android:id="@+id/activity_chat_room"
4 4 android:layout_width="match_parent"
5   - android:layout_height="match_parent"
6   - >
  5 + android:layout_height="match_parent">
7 6  
8   - <LinearLayout
9   - android:id="@+id/listVIewTop"
  7 + <RelativeLayout
  8 + android:id="@+id/re_chat"
10 9 android:layout_width="match_parent"
11   - android:layout_height="wrap_content"
12   - android:orientation="horizontal"
13   - android:layout_alignParentTop="true"
14   - android:layout_alignParentLeft="true"
15   - android:layout_alignParentStart="true">
16   -
17   - <ListView
18   - android:id="@+id/chat_list_viewOne"
19   - android:layout_width="0dp"
20   - android:layout_height="150dp"
21   - android:layout_above="@+id/edit_layout"
22   - android:layout_alignParentTop="true"
23   - android:layout_weight="1"
24   - android:divider="@null"
25   - android:scrollbars="none"
26   - android:transcriptMode="alwaysScroll" />
27   -
28   - <ListView
29   - android:id="@+id/chat_list_viewTwo"
30   - android:layout_width="0dp"
31   - android:layout_height="150dp"
32   - android:layout_above="@+id/edit_layout"
33   - android:layout_alignParentTop="true"
34   - android:layout_toRightOf="@id/chat_list_viewOne"
35   - android:layout_weight="1"
36   - android:divider="@null"
37   - android:scrollbars="none"
38   - android:transcriptMode="alwaysScroll" />
  10 + android:layout_height="match_parent"
  11 + android:visibility="invisible">
39 12  
40   - </LinearLayout>
  13 + <LinearLayout
  14 + android:id="@+id/listVIewTop"
  15 + android:layout_width="match_parent"
  16 + android:layout_height="wrap_content"
  17 + android:layout_alignParentLeft="true"
  18 + android:layout_alignParentStart="true"
  19 + android:layout_alignParentTop="true"
  20 + android:orientation="horizontal">
  21 +
  22 + <LinearLayout
  23 + android:layout_width="0dp"
  24 + android:layout_height="match_parent"
  25 + android:layout_weight="1"
  26 + android:orientation="vertical">
  27 +
  28 + <TextView
  29 + android:layout_width="match_parent"
  30 + android:layout_height="wrap_content"
  31 + android:gravity="center"
  32 + android:text="聊天室一" />
  33 +
  34 + <ListView
  35 + android:id="@+id/chat_list_viewOne"
  36 + android:layout_width="match_parent"
  37 + android:layout_height="150dp"
  38 + android:layout_above="@+id/edit_layout"
  39 + android:layout_alignParentTop="true"
  40 + android:divider="@null"
  41 + android:scrollbars="none"
  42 + android:transcriptMode="alwaysScroll" />
  43 +
  44 + </LinearLayout>
  45 +
  46 + <LinearLayout
  47 + android:layout_width="0dp"
  48 + android:layout_height="match_parent"
  49 + android:layout_weight="1"
  50 + android:orientation="vertical">
  51 +
  52 + <TextView
  53 + android:layout_width="match_parent"
  54 + android:layout_height="wrap_content"
  55 + android:gravity="center"
  56 + android:text="聊天室二" />
  57 +
  58 + <ListView
  59 + android:id="@+id/chat_list_viewTwo"
  60 + android:layout_width="match_parent"
  61 + android:layout_height="150dp"
  62 + android:layout_above="@+id/edit_layout"
  63 + android:layout_alignParentTop="true"
  64 + android:layout_toRightOf="@id/chat_list_viewOne"
  65 + android:divider="@null"
  66 + android:scrollbars="none"
  67 + android:transcriptMode="alwaysScroll" />
  68 +
  69 + </LinearLayout>
  70 +
  71 +
  72 + </LinearLayout>
  73 +
  74 +
  75 + <LinearLayout
  76 + android:id="@+id/edit_layout"
  77 + android:layout_width="match_parent"
  78 + android:layout_height="wrap_content"
  79 + android:layout_alignParentBottom="true"
  80 + android:orientation="horizontal">
  81 +
  82 + <EditText
  83 + android:id="@+id/message_content"
  84 + android:layout_width="0dp"
  85 + android:layout_height="wrap_content"
  86 + android:layout_gravity="center"
  87 + android:layout_weight="0.7" />
  88 +
  89 + <Button
  90 + android:id="@+id/send_messageOne"
  91 + android:layout_width="0dp"
  92 + android:layout_height="wrap_content"
  93 + android:layout_gravity="center"
  94 + android:layout_weight="0.2"
  95 + android:text="聊天室1发送" />
  96 +
  97 +
  98 + <Button
  99 + android:id="@+id/send_messageTwo"
  100 + android:layout_width="0dp"
  101 + android:layout_height="wrap_content"
  102 + android:layout_gravity="center"
  103 + android:layout_weight="0.2"
  104 + android:text="聊天室2发送" />
  105 + </LinearLayout>
  106 +
  107 + <LinearLayout
  108 + android:layout_width="match_parent"
  109 + android:layout_height="wrap_content"
  110 + android:layout_above="@id/edit_layout"
  111 + android:orientation="vertical">
  112 +
  113 + <LinearLayout
  114 + android:layout_width="match_parent"
  115 + android:layout_height="wrap_content"
  116 + android:orientation="horizontal">
  117 +
  118 + <Button
  119 + android:id="@+id/connectionBtn"
  120 + android:layout_width="wrap_content"
  121 + android:layout_height="wrap_content"
  122 + android:text="连接服务器" />
  123 +
  124 + <Button
  125 + android:id="@+id/disconnect"
  126 + android:layout_width="wrap_content"
  127 + android:layout_height="wrap_content"
  128 + android:text="断开连接" />
  129 +
  130 + <Button
  131 + android:id="@+id/creatChat"
  132 + android:layout_width="wrap_content"
  133 + android:layout_height="wrap_content"
  134 + android:text="加入聊天室1" />
  135 +
  136 + <Button
  137 + android:id="@+id/creatChat2"
  138 + android:layout_width="wrap_content"
  139 + android:layout_height="wrap_content"
  140 + android:text="加入聊天室2" />
  141 +
  142 + </LinearLayout>
  143 +
  144 + <LinearLayout
  145 + android:layout_width="match_parent"
  146 + android:layout_height="wrap_content"
  147 + android:orientation="horizontal">
  148 +
  149 +
  150 + </LinearLayout>
  151 +
  152 + <LinearLayout
  153 + android:layout_width="match_parent"
  154 + android:layout_height="wrap_content"
  155 + android:orientation="horizontal">
  156 +
  157 + <Button
  158 + android:id="@+id/user_switch"
  159 + android:layout_width="wrap_content"
  160 + android:layout_height="wrap_content"
  161 + android:text="切换用户" />
  162 +
  163 + <Button
  164 + android:id="@+id/switch_visitors"
  165 + android:layout_width="wrap_content"
  166 + android:layout_height="wrap_content"
  167 + android:text="切换游客" />
  168 +
  169 + <Button
  170 + android:id="@+id/button"
  171 + android:layout_width="wrap_content"
  172 + android:layout_height="wrap_content"
  173 + android:text="退出聊天室2" />
  174 +
  175 + <Button
  176 + android:id="@+id/button2"
  177 + android:layout_width="wrap_content"
  178 + android:layout_height="wrap_content"
  179 + android:text="退出聊天室1" />
  180 +
  181 + </LinearLayout>
  182 + </LinearLayout>
  183 + </RelativeLayout>
41 184  
42   - <Button
43   - android:id="@+id/user_switch"
44   - android:layout_width="wrap_content"
45   - android:layout_height="wrap_content"
46   - android:text="切换用户"
47   - android:layout_above="@+id/edit_layout"
48   - android:layout_alignParentStart="true" />
49 185  
50 186 <LinearLayout
51   - android:id="@+id/edit_layout"
  187 + android:id="@+id/lin_user"
52 188 android:layout_width="match_parent"
53 189 android:layout_height="wrap_content"
54   - android:layout_alignParentBottom="true"
55   - android:orientation="horizontal">
56   -
57   - <EditText
58   - android:id="@+id/message_content"
59   - android:layout_width="0dp"
60   - android:layout_height="wrap_content"
61   - android:layout_gravity="center"
62   - android:layout_weight="0.7" />
  190 + android:layout_centerVertical="true"
  191 + android:orientation="vertical">
  192 +
  193 +
  194 + <LinearLayout
  195 + android:layout_width="match_parent"
  196 + android:layout_height="wrap_content">
  197 +
  198 + <TextView
  199 + android:layout_width="wrap_content"
  200 + android:layout_height="match_parent"
  201 + android:gravity="center"
  202 + android:text="userID :" />
  203 +
  204 + <EditText
  205 + android:id="@+id/user_ID"
  206 + android:layout_width="0dp"
  207 + android:layout_height="match_parent"
  208 + android:layout_weight="0.7" />
  209 +
  210 + <Button
  211 + android:layout_width="0dp"
  212 + android:layout_height="match_parent"
  213 + android:layout_weight="0.2"
  214 + android:text="确认"
  215 + android:visibility="invisible" />
  216 +
  217 + </LinearLayout>
  218 +
  219 +
  220 + <LinearLayout
  221 + android:layout_width="match_parent"
  222 + android:layout_height="wrap_content">
  223 +
  224 + <TextView
  225 + android:layout_width="wrap_content"
  226 + android:layout_height="match_parent"
  227 + android:gravity="center"
  228 + android:text="userName:" />
  229 +
  230 + <EditText
  231 + android:id="@+id/user_name"
  232 + android:layout_width="0dp"
  233 + android:layout_height="match_parent"
  234 + android:layout_weight="0.7" />
  235 +
  236 + <Button
  237 + android:id="@+id/user_imfor_send"
  238 + android:layout_width="0dp"
  239 + android:layout_height="match_parent"
  240 + android:layout_weight="0.2"
  241 + android:text="确认" />
  242 + </LinearLayout>
63 243  
64   - <Button
65   - android:id="@+id/send_messageOne"
66   - android:layout_width="0dp"
67   - android:layout_height="wrap_content"
68   - android:layout_gravity="center"
69   - android:layout_weight="0.2"
70   - android:text="聊天室1发送" />
71   -
72   -
73   - <Button
74   - android:id="@+id/send_messageTwo"
75   - android:layout_width="0dp"
76   - android:layout_height="wrap_content"
77   - android:layout_gravity="center"
78   - android:layout_weight="0.2"
79   - android:text="聊天室2发送" />
80 244 </LinearLayout>
81 245  
82   - <Button
83   - android:id="@+id/connectionBtn"
84   - android:layout_width="wrap_content"
85   - android:layout_height="wrap_content"
86   - android:text="连接服务器"
87   - android:layout_above="@+id/user_switch"
88   - android:layout_alignParentStart="true" />
89   -
90   - <Button
91   - android:id="@+id/switch_visitors"
92   - android:layout_width="wrap_content"
93   - android:layout_height="wrap_content"
94   - android:text="切换游客"
95   - android:layout_alignBaseline="@+id/user_switch"
96   - android:layout_alignBottom="@+id/user_switch"
97   - android:layout_toEndOf="@+id/user_switch" />
98   -
99   - <Button
100   - android:id="@+id/creatChat"
101   - android:layout_width="wrap_content"
102   - android:layout_height="wrap_content"
103   - android:text="加入聊天室1"
104   - android:layout_alignBaseline="@+id/creatChat2"
105   - android:layout_alignBottom="@+id/creatChat2"
106   - android:layout_toRightOf="@+id/connectionBtn" />
107   -
108   - <Button
109   - android:id="@+id/disconnect"
110   - android:layout_width="wrap_content"
111   - android:layout_height="wrap_content"
112   - android:text="断开连接"
113   - android:layout_marginLeft="11dp"
114   - android:layout_above="@+id/edit_layout"
115   - android:layout_toEndOf="@+id/switch_visitors" />
116   -
117   - <Button
118   - android:id="@+id/creatChat2"
119   - android:layout_width="wrap_content"
120   - android:layout_height="wrap_content"
121   - android:text="加入聊天室2"
122   - android:layout_alignBaseline="@+id/connectionBtn"
123   - android:layout_alignBottom="@+id/connectionBtn"
124   - android:layout_toRightOf="@+id/creatChat"
125   - android:layout_toEndOf="@+id/creatChat" />
126   -
127 246  
128 247 </RelativeLayout>
... ...
app/src/main/res/layout/activity_main.xml
... ... @@ -13,20 +13,18 @@
13 13  
14 14 <Button
15 15 android:text="群聊"
16   - android:layout_width="wrap_content"
  16 + android:layout_width="match_parent"
17 17 android:layout_height="wrap_content"
18 18 android:layout_marginTop="140dp"
19 19 android:id="@+id/groupChat"
20   - android:layout_alignParentEnd="true"
21   - android:layout_alignParentStart="true" />
  20 + />
22 21  
23 22 <Button
24 23 android:text="私聊"
25   - android:layout_width="wrap_content"
  24 + android:layout_width="match_parent"
26 25 android:layout_height="wrap_content"
27 26 android:layout_below="@+id/groupChat"
28   - android:layout_alignStart="@+id/groupChat"
29 27 android:layout_marginTop="34dp"
30 28 android:id="@+id/privateChat"
31   - android:layout_alignParentEnd="true" />
  29 + />
32 30 </RelativeLayout>
... ...