Commit 59ca457bd51ea3fc7cd80420879d6fff30746296
0 parents
聊天demo添加
Showing
47 changed files
with
1742 additions
and
0 deletions
.gitignore
0 → 100644
.idea/compiler.xml
0 → 100644
| 1 | +++ a/.idea/compiler.xml | |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<project version="4"> | |
| 3 | + <component name="CompilerConfiguration"> | |
| 4 | + <resourceExtensions /> | |
| 5 | + <wildcardResourcePatterns> | |
| 6 | + <entry name="!?*.java" /> | |
| 7 | + <entry name="!?*.form" /> | |
| 8 | + <entry name="!?*.class" /> | |
| 9 | + <entry name="!?*.groovy" /> | |
| 10 | + <entry name="!?*.scala" /> | |
| 11 | + <entry name="!?*.flex" /> | |
| 12 | + <entry name="!?*.kt" /> | |
| 13 | + <entry name="!?*.clj" /> | |
| 14 | + <entry name="!?*.aj" /> | |
| 15 | + </wildcardResourcePatterns> | |
| 16 | + <annotationProcessing> | |
| 17 | + <profile default="true" name="Default" enabled="false"> | |
| 18 | + <processorPath useClasspath="true" /> | |
| 19 | + </profile> | |
| 20 | + </annotationProcessing> | |
| 21 | + </component> | |
| 22 | +</project> | |
| 0 | 23 | \ No newline at end of file | ... | ... |
.idea/copyright/profiles_settings.xml
0 → 100644
.idea/gradle.xml
0 → 100644
| 1 | +++ a/.idea/gradle.xml | |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<project version="4"> | |
| 3 | + <component name="GradleSettings"> | |
| 4 | + <option name="linkedExternalProjectsSettings"> | |
| 5 | + <GradleProjectSettings> | |
| 6 | + <option name="distributionType" value="LOCAL" /> | |
| 7 | + <option name="externalProjectPath" value="$PROJECT_DIR$" /> | |
| 8 | + <option name="gradleHome" value="C:\Program Files\Android\Android Studio1\gradle\gradle-3.3" /> | |
| 9 | + <option name="modules"> | |
| 10 | + <set> | |
| 11 | + <option value="$PROJECT_DIR$" /> | |
| 12 | + <option value="$PROJECT_DIR$/app" /> | |
| 13 | + </set> | |
| 14 | + </option> | |
| 15 | + <option name="resolveModulePerSourceSet" value="false" /> | |
| 16 | + </GradleProjectSettings> | |
| 17 | + </option> | |
| 18 | + </component> | |
| 19 | +</project> | |
| 0 | 20 | \ No newline at end of file | ... | ... |
.idea/misc.xml
0 → 100644
| 1 | +++ a/.idea/misc.xml | |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<project version="4"> | |
| 3 | + <component name="EntryPointsManager"> | |
| 4 | + <entry_points version="2.0" /> | |
| 5 | + </component> | |
| 6 | + <component name="NullableNotNullManager"> | |
| 7 | + <option name="myDefaultNullable" value="android.support.annotation.Nullable" /> | |
| 8 | + <option name="myDefaultNotNull" value="android.support.annotation.NonNull" /> | |
| 9 | + <option name="myNullables"> | |
| 10 | + <value> | |
| 11 | + <list size="4"> | |
| 12 | + <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" /> | |
| 13 | + <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" /> | |
| 14 | + <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" /> | |
| 15 | + <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" /> | |
| 16 | + </list> | |
| 17 | + </value> | |
| 18 | + </option> | |
| 19 | + <option name="myNotNulls"> | |
| 20 | + <value> | |
| 21 | + <list size="4"> | |
| 22 | + <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" /> | |
| 23 | + <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" /> | |
| 24 | + <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" /> | |
| 25 | + <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" /> | |
| 26 | + </list> | |
| 27 | + </value> | |
| 28 | + </option> | |
| 29 | + </component> | |
| 30 | + <component name="ProjectLevelVcsManager" settingsEditedManually="false"> | |
| 31 | + <OptionsSetting value="true" id="Add" /> | |
| 32 | + <OptionsSetting value="true" id="Remove" /> | |
| 33 | + <OptionsSetting value="true" id="Checkout" /> | |
| 34 | + <OptionsSetting value="true" id="Update" /> | |
| 35 | + <OptionsSetting value="true" id="Status" /> | |
| 36 | + <OptionsSetting value="true" id="Edit" /> | |
| 37 | + <ConfirmationsSetting value="0" id="Add" /> | |
| 38 | + <ConfirmationsSetting value="0" id="Remove" /> | |
| 39 | + </component> | |
| 40 | + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> | |
| 41 | + <output url="file://$PROJECT_DIR$/build/classes" /> | |
| 42 | + </component> | |
| 43 | + <component name="ProjectType"> | |
| 44 | + <option name="id" value="Android" /> | |
| 45 | + </component> | |
| 46 | + <component name="masterDetails"> | |
| 47 | + <states> | |
| 48 | + <state key="ProjectJDKs.UI"> | |
| 49 | + <settings> | |
| 50 | + <last-edited>1.8</last-edited> | |
| 51 | + <splitter-proportions> | |
| 52 | + <option name="proportions"> | |
| 53 | + <list> | |
| 54 | + <option value="0.2" /> | |
| 55 | + </list> | |
| 56 | + </option> | |
| 57 | + </splitter-proportions> | |
| 58 | + </settings> | |
| 59 | + </state> | |
| 60 | + </states> | |
| 61 | + </component> | |
| 62 | +</project> | |
| 0 | 63 | \ No newline at end of file | ... | ... |
.idea/modules.xml
0 → 100644
| 1 | +++ a/.idea/modules.xml | |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<project version="4"> | |
| 3 | + <component name="ProjectModuleManager"> | |
| 4 | + <modules> | |
| 5 | + <module fileurl="file://$PROJECT_DIR$/CNChatNDemo.iml" filepath="$PROJECT_DIR$/CNChatNDemo.iml" /> | |
| 6 | + <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> | |
| 7 | + </modules> | |
| 8 | + </component> | |
| 9 | +</project> | |
| 0 | 10 | \ No newline at end of file | ... | ... |
.idea/runConfigurations.xml
0 → 100644
| 1 | +++ a/.idea/runConfigurations.xml | |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<project version="4"> | |
| 3 | + <component name="RunConfigurationProducerService"> | |
| 4 | + <option name="ignoredProducers"> | |
| 5 | + <set> | |
| 6 | + <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" /> | |
| 7 | + <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" /> | |
| 8 | + <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" /> | |
| 9 | + </set> | |
| 10 | + </option> | |
| 11 | + </component> | |
| 12 | +</project> | |
| 0 | 13 | \ No newline at end of file | ... | ... |
app/.gitignore
0 → 100644
app/build.gradle
0 → 100644
| 1 | +++ a/app/build.gradle | |
| 1 | +apply plugin: 'com.android.application' | |
| 2 | + | |
| 3 | +android { | |
| 4 | + compileSdkVersion 25 | |
| 5 | + buildToolsVersion "25.0.2" | |
| 6 | + defaultConfig { | |
| 7 | + applicationId "com.cnlive.im" | |
| 8 | + minSdkVersion 22 | |
| 9 | + targetSdkVersion 25 | |
| 10 | + versionCode 1 | |
| 11 | + versionName "1.0" | |
| 12 | + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | |
| 13 | + } | |
| 14 | + buildTypes { | |
| 15 | + release { | |
| 16 | + minifyEnabled false | |
| 17 | + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |
| 18 | + } | |
| 19 | + } | |
| 20 | +} | |
| 21 | + | |
| 22 | +dependencies { | |
| 23 | + compile fileTree(dir: 'libs', include: ['*.jar']) | |
| 24 | + androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { | |
| 25 | + exclude group: 'com.android.support', module: 'support-annotations' | |
| 26 | + }) | |
| 27 | + compile 'com.android.support:appcompat-v7:25.2.0' | |
| 28 | + compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9' | |
| 29 | + testCompile 'junit:junit:4.12' | |
| 30 | +} | ... | ... |
app/libs/libcnliveutil.jar
0 → 100644
No preview for this file type
app/proguard-rules.pro
0 → 100644
| 1 | +++ a/app/proguard-rules.pro | |
| 1 | +# Add project specific ProGuard rules here. | |
| 2 | +# By default, the flags in this file are appended to flags specified | |
| 3 | +# in D:\AndroidSDK/tools/proguard/proguard-android.txt | |
| 4 | +# You can edit the include path and order by changing the proguardFiles | |
| 5 | +# directive in build.gradle. | |
| 6 | +# | |
| 7 | +# For more details, see | |
| 8 | +# http://developer.android.com/guide/developing/tools/proguard.html | |
| 9 | + | |
| 10 | +# Add any project specific keep options here: | |
| 11 | + | |
| 12 | +# If your project uses WebView with JS, uncomment the following | |
| 13 | +# and specify the fully qualified class name to the JavaScript interface | |
| 14 | +# class: | |
| 15 | +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | |
| 16 | +# public *; | |
| 17 | +#} | |
| 18 | + | |
| 19 | +# Uncomment this to preserve the line number information for | |
| 20 | +# debugging stack traces. | |
| 21 | +#-keepattributes SourceFile,LineNumberTable | |
| 22 | + | |
| 23 | +# If you keep the line number information, uncomment this to | |
| 24 | +# hide the original source file name. | |
| 25 | +#-renamesourcefileattribute SourceFile | ... | ... |
app/src/androidTest/java/com/cnlive/im/ExampleInstrumentedTest.java
0 → 100644
| 1 | +++ a/app/src/androidTest/java/com/cnlive/im/ExampleInstrumentedTest.java | |
| 1 | +package com.cnlive.im; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.support.test.InstrumentationRegistry; | |
| 5 | +import android.support.test.runner.AndroidJUnit4; | |
| 6 | + | |
| 7 | +import org.junit.Test; | |
| 8 | +import org.junit.runner.RunWith; | |
| 9 | + | |
| 10 | +import static org.junit.Assert.*; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * Instrumentation test, which will execute on an Android device. | |
| 14 | + * | |
| 15 | + * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | |
| 16 | + */ | |
| 17 | +@RunWith(AndroidJUnit4.class) | |
| 18 | +public class ExampleInstrumentedTest { | |
| 19 | + @Test | |
| 20 | + public void useAppContext() throws Exception { | |
| 21 | + // Context of the app under test. | |
| 22 | + Context appContext = InstrumentationRegistry.getTargetContext(); | |
| 23 | + | |
| 24 | + assertEquals("com.cnlive.im", appContext.getPackageName()); | |
| 25 | + } | |
| 26 | +} | ... | ... |
app/src/main/AndroidManifest.xml
0 → 100644
| 1 | +++ a/app/src/main/AndroidManifest.xml | |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + package="com.cnlive.im"> | |
| 4 | + | |
| 5 | + | |
| 6 | + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | |
| 7 | + <uses-permission android:name="android.permission.INTERNET" /> | |
| 8 | + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | |
| 9 | + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | |
| 10 | + <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | |
| 11 | + <uses-permission android:name="android.permission.RECORD_AUDIO" /> | |
| 12 | + <uses-permission android:name="android.permission.GET_TASKS" /> | |
| 13 | + <uses-permission android:name="android.permission.WAKE_LOCK" /> | |
| 14 | + <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> | |
| 15 | + <uses-permission android:name="android.permission.VIBRATE" /> | |
| 16 | + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | |
| 17 | + <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | |
| 18 | + | |
| 19 | + <application | |
| 20 | + android:name="com.cnlive.im.CNLiveApplication" | |
| 21 | + android:allowBackup="true" | |
| 22 | + android:icon="@mipmap/ic_launcher" | |
| 23 | + android:label="@string/app_name" | |
| 24 | + android:supportsRtl="true" | |
| 25 | + android:theme="@style/AppTheme"> | |
| 26 | + <activity android:name="com.cnlive.im.ui.MainActivity"> | |
| 27 | + <intent-filter> | |
| 28 | + <action android:name="android.intent.action.MAIN" /> | |
| 29 | + | |
| 30 | + <category android:name="android.intent.category.LAUNCHER" /> | |
| 31 | + </intent-filter> | |
| 32 | + </activity> | |
| 33 | + | |
| 34 | + | |
| 35 | + <activity | |
| 36 | + android:name="com.cnlive.im.ui.ChatRoomActivity" | |
| 37 | + android:launchMode="singleTop" | |
| 38 | + android:screenOrientation="portrait" | |
| 39 | + android:windowSoftInputMode="adjustResize" /> | |
| 40 | + | |
| 41 | + | |
| 42 | + <activity | |
| 43 | + android:name="com.cnlive.im.ui.PrivateChatActivity" | |
| 44 | + /> | |
| 45 | + | |
| 46 | + <meta-data | |
| 47 | + android:name="RONG_CLOUD_APP_KEY" | |
| 48 | + android:value="此处添加APP_KEY" /> | |
| 49 | + | |
| 50 | + <service | |
| 51 | + android:name="io.rong.imlib.ipc.RongService" | |
| 52 | + android:exported="true" | |
| 53 | + android:process=":ipc" /> | |
| 54 | + | |
| 55 | + <service | |
| 56 | + android:name="io.rong.imlib.ReConnectService" | |
| 57 | + android:exported="true" /> | |
| 58 | + | |
| 59 | + <receiver | |
| 60 | + android:name="io.rong.imlib.ConnectChangeReceiver" | |
| 61 | + android:exported="true" /> | |
| 62 | + | |
| 63 | + <receiver | |
| 64 | + android:name="io.rong.imlib.HeartbeatReceiver" | |
| 65 | + android:process=":ipc" /> | |
| 66 | + <!-- com.cnlive.libs.chat config end --> | |
| 67 | + | |
| 68 | + | |
| 69 | + <!--必选: SDK 核心功能--> | |
| 70 | + <!--第三方相关,向第三方推送服务请求 token 的服务 --> | |
| 71 | + <service | |
| 72 | + android:name="io.rong.push.core.PushRegistrationService" | |
| 73 | + android:exported="false"></service> | |
| 74 | + | |
| 75 | + <!-- 处理 push 消息相关的服务 --> | |
| 76 | + <service | |
| 77 | + android:name="io.rong.push.core.MessageHandleService" | |
| 78 | + android:exported="true"></service> | |
| 79 | + | |
| 80 | + <!-- push服务 --> | |
| 81 | + <service | |
| 82 | + android:name="io.rong.push.PushService" | |
| 83 | + android:exported="true" | |
| 84 | + android:process="io.rong.push"> <!-- push进程,可以改名 --> | |
| 85 | + </service> | |
| 86 | + | |
| 87 | + <!-- push 相关事件接收器 --> | |
| 88 | + <receiver | |
| 89 | + android:name="io.rong.push.PushReceiver" | |
| 90 | + android:process="io.rong.push"> <!-- 此处进程可以改名,名称需要和PushService所在进程统一 --> | |
| 91 | + <!-- 心跳事件 --> | |
| 92 | + <intent-filter> | |
| 93 | + <action android:name="io.rong.push.intent.action.HEART_BEAT" /> | |
| 94 | + </intent-filter> | |
| 95 | + <!-- 网络变动事件 --> | |
| 96 | + <intent-filter> | |
| 97 | + <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> | |
| 98 | + </intent-filter> | |
| 99 | + <!-- 部分用户事件 --> | |
| 100 | + <intent-filter> | |
| 101 | + <action android:name="android.intent.action.BOOT_COMPLETED" /> | |
| 102 | + </intent-filter> | |
| 103 | + <intent-filter> | |
| 104 | + <action android:name="android.intent.action.USER_PRESENT" /> | |
| 105 | + <action android:name="android.intent.action.ACTION_POWER_CONNECTED" /> | |
| 106 | + <action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" /> | |
| 107 | + </intent-filter> | |
| 108 | + </receiver> | |
| 109 | + | |
| 110 | + <!--必选: SDK 核心功能--> | |
| 111 | + | |
| 112 | + <!-- end --> | |
| 113 | + </application> | |
| 114 | + | |
| 115 | +</manifest> | |
| 0 | 116 | \ No newline at end of file | ... | ... |
app/src/main/java/com/cnlive/im/CNLiveApplication.java
0 → 100644
| 1 | +++ a/app/src/main/java/com/cnlive/im/CNLiveApplication.java | |
| 1 | +package com.cnlive.im; | |
| 2 | + | |
| 3 | +import android.app.Application; | |
| 4 | + | |
| 5 | +import com.cnlive.libs.util.Config; | |
| 6 | + | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * @author 陈硕 | |
| 10 | + * @time 2017/3/7 14:23 | |
| 11 | + * @desc ${TODD} | |
| 12 | + */ | |
| 13 | +public class CNLiveApplication extends Application { | |
| 14 | + @Override | |
| 15 | + public void onCreate() { | |
| 16 | + super.onCreate(); | |
| 17 | + Config.init(this, "60_irn9cdak77", "a425987ebc86e352b3373c25d5bd082d0cc248b4043028"); | |
| 18 | + } | |
| 19 | +} | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | ... | ... |
app/src/main/java/com/cnlive/im/adapter/ChatListAdapter.java
0 → 100644
| 1 | +++ a/app/src/main/java/com/cnlive/im/adapter/ChatListAdapter.java | |
| 1 | +package com.cnlive.im.adapter; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.view.LayoutInflater; | |
| 5 | +import android.view.View; | |
| 6 | +import android.view.ViewGroup; | |
| 7 | +import android.widget.BaseAdapter; | |
| 8 | +import android.widget.TextView; | |
| 9 | + | |
| 10 | +import com.cnlive.im.R; | |
| 11 | +import com.cnlive.libs.util.chat.model.CNMessage; | |
| 12 | + | |
| 13 | +import java.util.ArrayList; | |
| 14 | +import java.util.List; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * Created by Lynn on 2/13/2017. | |
| 18 | + */ | |
| 19 | + | |
| 20 | +public class ChatListAdapter extends BaseAdapter { | |
| 21 | + | |
| 22 | + private ArrayList<CNMessage> msgList; | |
| 23 | + private LayoutInflater mInflater = null; | |
| 24 | + | |
| 25 | + public ChatListAdapter(Context context) { | |
| 26 | + msgList = new ArrayList<>(); | |
| 27 | + mInflater = LayoutInflater.from(context); | |
| 28 | + } | |
| 29 | + | |
| 30 | + @Override | |
| 31 | + public int getCount() { | |
| 32 | + return msgList.size(); | |
| 33 | + } | |
| 34 | + | |
| 35 | + @Override | |
| 36 | + public Object getItem(int position) { | |
| 37 | + return msgList.get(position); | |
| 38 | + } | |
| 39 | + | |
| 40 | + @Override | |
| 41 | + public long getItemId(int position) { | |
| 42 | + return 0; | |
| 43 | + } | |
| 44 | + | |
| 45 | + @Override | |
| 46 | + public View getView(int position, View convertView, ViewGroup parent) { | |
| 47 | + ViewHolder viewHolder; | |
| 48 | + if (convertView == null) { | |
| 49 | + viewHolder = new ViewHolder(); | |
| 50 | + convertView = mInflater.inflate(R.layout.msg_text_view, null); | |
| 51 | + viewHolder.userName = (TextView) convertView.findViewById(R.id.user_name); | |
| 52 | + viewHolder.msgContent = (TextView) convertView.findViewById(R.id.msg_text); | |
| 53 | + convertView.setTag(viewHolder); | |
| 54 | + } else { | |
| 55 | + viewHolder = (ViewHolder) convertView.getTag(); | |
| 56 | + } | |
| 57 | + viewHolder.userName.setText(msgList.get(position).getUserInfo().getUserName() == null ? "" : msgList.get(position).getUserInfo().getUserName() + " : "); | |
| 58 | + viewHolder.msgContent.setText(msgList.get(position).getContent() == null ? "" : msgList.get(position).getContent()); | |
| 59 | + return convertView; | |
| 60 | + | |
| 61 | + } | |
| 62 | + | |
| 63 | + public void addMessage(CNMessage msg) { | |
| 64 | + if (msgList == null) return; | |
| 65 | + msgList.add(msg); | |
| 66 | + } | |
| 67 | + | |
| 68 | + public void updateItems(List<CNMessage> items) { | |
| 69 | + if (items == null) return; | |
| 70 | + msgList.clear(); | |
| 71 | + msgList.addAll(items); | |
| 72 | + } | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + public class ViewHolder { | |
| 83 | + public TextView userName; | |
| 84 | + public TextView msgContent; | |
| 85 | + } | |
| 86 | +} | ... | ... |
app/src/main/java/com/cnlive/im/receiver/CNPushMessageReceiver.java
0 → 100644
| 1 | +++ a/app/src/main/java/com/cnlive/im/receiver/CNPushMessageReceiver.java | |
| 1 | +package com.cnlive.im.receiver; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | + | |
| 5 | +import com.cnlive.libs.util.chat.model.CNNotificationMessage; | |
| 6 | +import com.cnlive.libs.util.chat.receiver.SealNotificationReceiver; | |
| 7 | + | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * Created by Lynn on 2/17/2017. | |
| 11 | + */ | |
| 12 | + | |
| 13 | +public class CNPushMessageReceiver extends SealNotificationReceiver { | |
| 14 | + | |
| 15 | + @Override | |
| 16 | + public boolean onNotificationMessageArrived(Context var1, CNNotificationMessage var2) { | |
| 17 | + //返回false,会弹出SDK默认的通知;返回true,SDK不会弹出通知,通知需要您自定义 | |
| 18 | + return false; | |
| 19 | + } | |
| 20 | + | |
| 21 | + @Override | |
| 22 | + public boolean onNotificationMessageClicked(Context var1, CNNotificationMessage var2) { | |
| 23 | + //返回false,会走SDK默认的处理逻辑,即点击该通知则会打开会话列表或会话界面;返回true,则由您自定义处理逻辑 | |
| 24 | + return false; | |
| 25 | + } | |
| 26 | +} | ... | ... |
app/src/main/java/com/cnlive/im/ui/ChatRoomActivity.java
0 → 100644
| 1 | +++ a/app/src/main/java/com/cnlive/im/ui/ChatRoomActivity.java | |
| 1 | +package com.cnlive.im.ui; | |
| 2 | + | |
| 3 | +import android.os.Bundle; | |
| 4 | +import android.support.v7.app.AppCompatActivity; | |
| 5 | +import android.util.Log; | |
| 6 | +import android.view.View; | |
| 7 | +import android.widget.Button; | |
| 8 | +import android.widget.EditText; | |
| 9 | +import android.widget.ListView; | |
| 10 | +import android.widget.Toast; | |
| 11 | + | |
| 12 | +import com.cnlive.im.R; | |
| 13 | +import com.cnlive.im.adapter.ChatListAdapter; | |
| 14 | +import com.cnlive.libs.util.chat.ChatUtil; | |
| 15 | +import com.cnlive.libs.util.chat.base.IChat; | |
| 16 | +import com.cnlive.libs.util.chat.model.CNMessage; | |
| 17 | +import com.cnlive.libs.util.chat.model.CNUserInfo; | |
| 18 | + | |
| 19 | +import java.util.ArrayList; | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * @author 陈硕 | |
| 23 | + * @time 2017/3/7 14:36 | |
| 24 | + * @desc ${TODD} | |
| 25 | + */ | |
| 26 | +public class ChatRoomActivity extends AppCompatActivity implements View.OnClickListener { | |
| 27 | + private static final String TAG = "ChatRoomActivity"; | |
| 28 | + private ArrayList<CNMessage> groupChatOneListMy, groupChatTwoListMy; | |
| 29 | + private String roomIdOne = "ChatRoom05", roomIdTwo = "ChatRoom06"; | |
| 30 | + private EditText editText; | |
| 31 | + private Button send_messageOneBtn, send_messageOneTwo; | |
| 32 | + private ListView listViewOne; | |
| 33 | + private ChatListAdapter chatListAdapterOne, chatListAdapterTwo; | |
| 34 | + private ListView listViewTwo; | |
| 35 | + private Button user_switchBtn, reconnectionBtn, switch_visitorsBtn, foundChatBtn, disconnectBtn; | |
| 36 | + private Button creatChat2Btn; | |
| 37 | + | |
| 38 | + | |
| 39 | + @Override | |
| 40 | + protected void onCreate(Bundle savedInstanceState) { | |
| 41 | + super.onCreate(savedInstanceState); | |
| 42 | + setContentView(R.layout.activity_groupchat); | |
| 43 | + initUI(); | |
| 44 | + //设置监听 | |
| 45 | + ChatUtil.setConnectStatusListener(connectStatusListener); | |
| 46 | + ChatUtil.setOnChatRoomActionListener(chatRoomActionListener); | |
| 47 | + ChatUtil.setOnReceiveMessageListener(receiveMessageListener); | |
| 48 | + ChatUtil.setKickedOfflineListener(onKickedOfflineListener); | |
| 49 | + } | |
| 50 | + | |
| 51 | + | |
| 52 | + private void initUI() { | |
| 53 | + creatChat2Btn = (Button) findViewById(R.id.creatChat2); | |
| 54 | + disconnectBtn = (Button) findViewById(R.id.disconnect); | |
| 55 | + foundChatBtn = (Button) findViewById(R.id.creatChat); | |
| 56 | + switch_visitorsBtn = (Button) findViewById(R.id.switch_visitors); | |
| 57 | + reconnectionBtn = (Button) findViewById(R.id.connectionBtn); | |
| 58 | + user_switchBtn = (Button) findViewById(R.id.user_switch); | |
| 59 | + listViewOne = (ListView) findViewById(R.id.chat_list_viewOne); | |
| 60 | + listViewTwo = (ListView) findViewById(R.id.chat_list_viewTwo); | |
| 61 | + editText = (EditText) findViewById(R.id.message_content); | |
| 62 | + send_messageOneBtn = (Button) findViewById(R.id.send_messageOne); | |
| 63 | + send_messageOneTwo = (Button) findViewById(R.id.send_messageTwo); | |
| 64 | + disconnectBtn.setOnClickListener(this); | |
| 65 | + foundChatBtn.setOnClickListener(this); | |
| 66 | + send_messageOneBtn.setOnClickListener(this); | |
| 67 | + send_messageOneTwo.setOnClickListener(this); | |
| 68 | + reconnectionBtn.setOnClickListener(this); | |
| 69 | + user_switchBtn.setOnClickListener(this); | |
| 70 | + switch_visitorsBtn.setOnClickListener(this); | |
| 71 | + creatChat2Btn.setOnClickListener(this); | |
| 72 | + groupChatOneListMy = new ArrayList<>(); | |
| 73 | + groupChatTwoListMy = new ArrayList<>(); | |
| 74 | + chatListAdapterOne = new ChatListAdapter(ChatRoomActivity.this); | |
| 75 | + chatListAdapterTwo = new ChatListAdapter(ChatRoomActivity.this); | |
| 76 | + listViewOne.setAdapter(chatListAdapterOne); | |
| 77 | + listViewTwo.setAdapter(chatListAdapterTwo); | |
| 78 | + } | |
| 79 | + | |
| 80 | + | |
| 81 | + //连接监听 | |
| 82 | + private IChat.OnConnectListener connectListener = new IChat.OnConnectListener() { | |
| 83 | + @Override | |
| 84 | + public void onTokenIncorrect() { | |
| 85 | + Log.e(TAG, "ConnectListener TokenIncorrect"); | |
| 86 | + } | |
| 87 | + | |
| 88 | + @Override | |
| 89 | + public void onSuccess(String s) { | |
| 90 | + Log.e(TAG, "ConnectListener 连接监听" + s); | |
| 91 | + | |
| 92 | + } | |
| 93 | + | |
| 94 | + @Override | |
| 95 | + public void onError(int i, String s) { | |
| 96 | + Log.e(TAG, "ConnectListener errorCode : " + i + " : errorMessage : " + s); | |
| 97 | + } | |
| 98 | + }; | |
| 99 | + | |
| 100 | + | |
| 101 | + /** | |
| 102 | + * 发送消息监听 | |
| 103 | + */ | |
| 104 | + private IChat.OnSendMessageListener sendMessageListener = new IChat.OnSendMessageListener() { | |
| 105 | + | |
| 106 | + @Override | |
| 107 | + public void onAttached(CNMessage cnMessage) { | |
| 108 | + | |
| 109 | + Log.v(TAG, "SendMessageListener onAttached" + cnMessage.getTargetId() + cnMessage.getUserInfo().getUserName()); | |
| 110 | + | |
| 111 | + } | |
| 112 | + | |
| 113 | + @Override | |
| 114 | + public void onSuccess(CNMessage cnMessage) { | |
| 115 | + if (("60_" + roomIdOne).equals(cnMessage.getTargetId())) { | |
| 116 | + groupChatOneListMy.add(cnMessage); | |
| 117 | + chatListAdapterOne.updateItems(groupChatOneListMy); | |
| 118 | + chatListAdapterOne.notifyDataSetChanged(); | |
| 119 | + } | |
| 120 | + Log.v(TAG, "SendMessageListener SUCCESSES" + cnMessage.getTargetId() + cnMessage.getUserInfo().getUserName()); | |
| 121 | + | |
| 122 | + /** | |
| 123 | + * 连接两个聊天室30015 错误 | |
| 124 | + */ | |
| 125 | + if (("60_" + roomIdTwo).equals(cnMessage.getTargetId())) { | |
| 126 | + groupChatTwoListMy.add(cnMessage); | |
| 127 | + chatListAdapterTwo.updateItems(groupChatTwoListMy); | |
| 128 | + chatListAdapterTwo.notifyDataSetChanged(); | |
| 129 | + } | |
| 130 | + | |
| 131 | + } | |
| 132 | + | |
| 133 | + @Override | |
| 134 | + public void onError(CNMessage cnMessage, int i, String s) { | |
| 135 | + Log.v(TAG, "SendMessageListener 失败 " + i + " s" + s); | |
| 136 | + | |
| 137 | + } | |
| 138 | + }; | |
| 139 | + | |
| 140 | + //连接状态监听 | |
| 141 | + private IChat.OnConnectStatusListener connectStatusListener = new IChat.OnConnectStatusListener() { | |
| 142 | + @Override | |
| 143 | + public void onConnectStatus(int i, String s) { | |
| 144 | + Log.i(TAG, "连接状态监听" + i + " " + s); | |
| 145 | + | |
| 146 | + | |
| 147 | + } | |
| 148 | + }; | |
| 149 | + | |
| 150 | + //接收消息监听 | |
| 151 | + private IChat.OnReceiveMessageListener receiveMessageListener = new IChat.OnReceiveMessageListener() { | |
| 152 | + @Override | |
| 153 | + public void processMessage(CNMessage cnMessage) { | |
| 154 | + Log.v(TAG, "receiveMessageListener" + " " + cnMessage.getTargetId() + " " + cnMessage.getContent()); | |
| 155 | + } | |
| 156 | + }; | |
| 157 | + | |
| 158 | + | |
| 159 | + //聊天室操作 | |
| 160 | + private IChat.OnChatRoomActionListener chatRoomActionListener = new IChat.OnChatRoomActionListener() { | |
| 161 | + @Override | |
| 162 | + public void onJoining(String s) { | |
| 163 | + Log.i(TAG, "chatRoomActionListener" + " onJoining" + s); | |
| 164 | + | |
| 165 | + } | |
| 166 | + | |
| 167 | + @Override | |
| 168 | + public void onJoined(String s) { | |
| 169 | + Log.i(TAG, "chatRoomActionListener " + "onJoined" + s); | |
| 170 | + | |
| 171 | + } | |
| 172 | + | |
| 173 | + @Override | |
| 174 | + public void onQuited(String s) { | |
| 175 | + Log.i(TAG, "chatRoomActionListener " + "onQuited" + s); | |
| 176 | + | |
| 177 | + } | |
| 178 | + | |
| 179 | + @Override | |
| 180 | + public void onError(String s, int i, String s1) { | |
| 181 | + Log.i(TAG, "chatRoomActionListener " + "onError" + s); | |
| 182 | + | |
| 183 | + } | |
| 184 | + }; | |
| 185 | + | |
| 186 | + //被踢下线状态 | |
| 187 | + private IChat.OnKickedOfflineListener onKickedOfflineListener = new IChat.OnKickedOfflineListener() { | |
| 188 | + @Override | |
| 189 | + public void disconnected(int what, String extra) { | |
| 190 | + Log.e(TAG, what + " : " + extra); | |
| 191 | + } | |
| 192 | + | |
| 193 | + @Override | |
| 194 | + public void conByDevId(int what, String extra) { | |
| 195 | + Log.e(TAG, what + " : " + extra); | |
| 196 | + } | |
| 197 | + }; | |
| 198 | + | |
| 199 | + | |
| 200 | + // 加入聊天室监听 | |
| 201 | + private IChat.OnOperationListener onOperationListener = new IChat.OnOperationListener() { | |
| 202 | + @Override | |
| 203 | + public void onSuccess(int what, String extra) { | |
| 204 | + Log.v(TAG, "加入聊天室" + what + extra); | |
| 205 | + | |
| 206 | + } | |
| 207 | + | |
| 208 | + @Override | |
| 209 | + public void onError(int what, String extra) { | |
| 210 | + Log.v(TAG, "加入聊天室" + what + extra); | |
| 211 | + | |
| 212 | + } | |
| 213 | + }; | |
| 214 | + | |
| 215 | + @Override | |
| 216 | + public void onClick(View view) { | |
| 217 | + switch (view.getId()) { | |
| 218 | + //向聊天室1发送消息 | |
| 219 | + case R.id.send_messageOne: | |
| 220 | + //发送聊天室消息 | |
| 221 | + if (editText.getText().toString().isEmpty()) { | |
| 222 | + Toast.makeText(this, "不能发送空消息呦~", Toast.LENGTH_SHORT).show(); | |
| 223 | + } else { | |
| 224 | + ChatUtil.sendMessage(IChat.CHATROOM, roomIdOne, editText.getText().toString(), sendMessageListener); | |
| 225 | + editText.setText(""); | |
| 226 | + } | |
| 227 | + break; | |
| 228 | + // 向聊天室2发送消息 | |
| 229 | + case R.id.send_messageTwo: | |
| 230 | + //发送聊天室消息 | |
| 231 | + if (editText.getText().toString().isEmpty()) { | |
| 232 | + Toast.makeText(this, "不能发送空消息呦~", Toast.LENGTH_SHORT).show(); | |
| 233 | + } else { | |
| 234 | + ChatUtil.sendMessage(IChat.CHATROOM, roomIdTwo, editText.getText().toString(), sendMessageListener); | |
| 235 | + editText.setText(""); | |
| 236 | + } | |
| 237 | + break; | |
| 238 | + // 用户 | |
| 239 | + case R.id.user_switch: | |
| 240 | + ChatUtil.login(new CNUserInfo("5969", "testUser", ""), connectListener); | |
| 241 | + break; | |
| 242 | + //连接 | |
| 243 | + case R.id.connectionBtn: | |
| 244 | + ChatUtil.connect(connectListener); | |
| 245 | + break; | |
| 246 | + | |
| 247 | + // 切换成游客 | |
| 248 | + case R.id.switch_visitors: | |
| 249 | + | |
| 250 | + | |
| 251 | + ChatUtil.logOut(connectListener); | |
| 252 | + break; | |
| 253 | + // 创建聊天 | |
| 254 | + case R.id.creatChat: | |
| 255 | + ChatUtil.joinChatRoom(roomIdOne, -1, onOperationListener); | |
| 256 | + break; | |
| 257 | + // 断开连接 | |
| 258 | + case R.id.disconnect: | |
| 259 | + ChatUtil.quitChatRoom(roomIdOne, onOperationListener); | |
| 260 | + break; | |
| 261 | + | |
| 262 | + case R.id.creatChat2: | |
| 263 | + ChatUtil.joinChatRoom(roomIdTwo, -1, onOperationListener); | |
| 264 | + break; | |
| 265 | + | |
| 266 | + | |
| 267 | + } | |
| 268 | + } | |
| 269 | + | |
| 270 | + | |
| 271 | + @Override | |
| 272 | + protected void onPause() { | |
| 273 | + super.onPause(); | |
| 274 | + ChatUtil.disconnect(false); | |
| 275 | + } | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | +} | ... | ... |
app/src/main/java/com/cnlive/im/ui/MainActivity.java
0 → 100644
| 1 | +++ a/app/src/main/java/com/cnlive/im/ui/MainActivity.java | |
| 1 | +package com.cnlive.im.ui; | |
| 2 | + | |
| 3 | +import android.content.Intent; | |
| 4 | +import android.os.Bundle; | |
| 5 | +import android.support.v7.app.AppCompatActivity; | |
| 6 | +import android.view.View; | |
| 7 | +import android.widget.Button; | |
| 8 | + | |
| 9 | +import com.cnlive.im.R; | |
| 10 | + | |
| 11 | + | |
| 12 | +public class MainActivity extends AppCompatActivity implements View.OnClickListener { | |
| 13 | + | |
| 14 | + private Button groupChatBtn, privateChat; | |
| 15 | + | |
| 16 | + @Override | |
| 17 | + protected void onCreate(Bundle savedInstanceState) { | |
| 18 | + super.onCreate(savedInstanceState); | |
| 19 | + setContentView(R .layout.activity_main); | |
| 20 | + initUI(); | |
| 21 | + } | |
| 22 | + | |
| 23 | + private void initUI() { | |
| 24 | + groupChatBtn = (Button) findViewById(R.id.groupChat); | |
| 25 | + privateChat = (Button) findViewById(R.id.privateChat); | |
| 26 | + groupChatBtn.setOnClickListener(this); | |
| 27 | + privateChat.setOnClickListener(this); | |
| 28 | + | |
| 29 | + } | |
| 30 | + | |
| 31 | + | |
| 32 | + @Override | |
| 33 | + public void onClick(View view) { | |
| 34 | + switch (view.getId()) { | |
| 35 | + case R.id.groupChat: | |
| 36 | + Intent intent = new Intent(MainActivity.this, ChatRoomActivity.class); | |
| 37 | + startActivity(intent); | |
| 38 | + break; | |
| 39 | + case R.id.privateChat: | |
| 40 | + Intent intent1 = new Intent(MainActivity.this, PrivateChatActivity.class); | |
| 41 | + startActivity(intent1); | |
| 42 | + break; | |
| 43 | + } | |
| 44 | + } | |
| 45 | +} | |
| 46 | + | ... | ... |
app/src/main/java/com/cnlive/im/ui/PrivateChatActivity.java
0 → 100644
| 1 | +++ a/app/src/main/java/com/cnlive/im/ui/PrivateChatActivity.java | |
| 1 | +package com.cnlive.im.ui; | |
| 2 | + | |
| 3 | +import android.os.Bundle; | |
| 4 | +import android.support.v7.app.AppCompatActivity; | |
| 5 | +import android.util.Log; | |
| 6 | +import android.view.View; | |
| 7 | +import android.widget.Button; | |
| 8 | +import android.widget.EditText; | |
| 9 | +import android.widget.LinearLayout; | |
| 10 | +import android.widget.ListView; | |
| 11 | +import android.widget.Toast; | |
| 12 | + | |
| 13 | +import com.cnlive.im.R; | |
| 14 | +import com.cnlive.im.adapter.ChatListAdapter; | |
| 15 | +import com.cnlive.libs.util.chat.ChatUtil; | |
| 16 | +import com.cnlive.libs.util.chat.base.IChat; | |
| 17 | +import com.cnlive.libs.util.chat.model.CNMessage; | |
| 18 | +import com.cnlive.libs.util.chat.model.CNUserInfo; | |
| 19 | + | |
| 20 | +import java.util.ArrayList; | |
| 21 | + | |
| 22 | +import static com.cnlive.im.R.id.opposite_id_edit; | |
| 23 | + | |
| 24 | +/** | |
| 25 | + * @author 陈硕 | |
| 26 | + * @time 2017/3/7 14:36 | |
| 27 | + * @desc ${TODD} | |
| 28 | + */ | |
| 29 | +public class PrivateChatActivity extends AppCompatActivity implements View.OnClickListener { | |
| 30 | + | |
| 31 | + | |
| 32 | + private static final String TAG = "PrivateChatActivity"; | |
| 33 | + private ListView chatListView; | |
| 34 | + private EditText messageContent; | |
| 35 | + private Button sendMessageBtn; | |
| 36 | + private ChatListAdapter chatListAdapter; | |
| 37 | + private ArrayList<CNMessage> messageList = new ArrayList<>(); | |
| 38 | + private CNMessage cnMessage; | |
| 39 | + private LinearLayout linearLayoutUseID; | |
| 40 | + private EditText user_id_edit; | |
| 41 | + private Button userId_btn_top; | |
| 42 | + private String oppositeID; | |
| 43 | + private LinearLayout edit_layout; | |
| 44 | + private EditText my_id_edit; | |
| 45 | + private String my_id_editID; | |
| 46 | + private LinearLayout my_liner_userID; | |
| 47 | + | |
| 48 | + @Override | |
| 49 | + protected void onCreate(Bundle savedInstanceState) { | |
| 50 | + super.onCreate(savedInstanceState); | |
| 51 | + setContentView(R.layout.activity_private_chat); | |
| 52 | + initView(); | |
| 53 | + ChatUtil.setConnectStatusListener(connectStatusListener); | |
| 54 | + ChatUtil.setOnChatRoomActionListener(chatRoomActionListener); | |
| 55 | + ChatUtil.setOnReceiveMessageListener(receiveMessageListener); | |
| 56 | + ChatUtil.connect(connectListener); | |
| 57 | + | |
| 58 | + } | |
| 59 | + | |
| 60 | + private void initView() { | |
| 61 | + chatListView = (ListView) findViewById(R.id.private_list_view); | |
| 62 | + chatListAdapter = new ChatListAdapter(this); | |
| 63 | + chatListView.setAdapter(chatListAdapter); | |
| 64 | + messageContent = (EditText) findViewById(R.id.message_content); | |
| 65 | + sendMessageBtn = (Button) findViewById(R.id.send_message); | |
| 66 | + sendMessageBtn.setOnClickListener(this); | |
| 67 | + linearLayoutUseID = (LinearLayout) findViewById(R.id.opposite_liner_useID); | |
| 68 | + | |
| 69 | + userId_btn_top = (Button) findViewById(R.id.userId_btn_top); | |
| 70 | + userId_btn_top.setOnClickListener(this); | |
| 71 | + edit_layout = (LinearLayout) findViewById(R.id.edit_layout); | |
| 72 | + my_id_edit = (EditText) findViewById(R.id.my_id_edit); | |
| 73 | + user_id_edit = (EditText) findViewById(opposite_id_edit); | |
| 74 | + my_liner_userID = (LinearLayout) findViewById(R.id.my_liner_userID); | |
| 75 | + | |
| 76 | + } | |
| 77 | + | |
| 78 | + | |
| 79 | + @Override | |
| 80 | + public void onClick(View v) { | |
| 81 | + switch (v.getId()) { | |
| 82 | + case R.id.send_message: | |
| 83 | + //发送私聊消息,需要传入目标ID与发送的消息内容 | |
| 84 | + if (messageContent.getText().toString().isEmpty()) { | |
| 85 | + Toast.makeText(this, "不能发送空消息呦~", Toast.LENGTH_SHORT).show(); | |
| 86 | + } else { | |
| 87 | + ChatUtil.sendMessage(IChat.PRIVATE, oppositeID, messageContent.getText().toString(), sendMessageListener); | |
| 88 | + messageContent.setText(""); | |
| 89 | + } | |
| 90 | + break; | |
| 91 | + case R.id.userId_btn_top: | |
| 92 | + //发送私聊消息,需要传入目标ID与发送的消息内容 | |
| 93 | + if (user_id_edit.getText().toString().isEmpty()) { | |
| 94 | + Toast.makeText(this, "对方ID不能为空", Toast.LENGTH_SHORT).show(); | |
| 95 | + } else if (my_id_edit.getText().toString().isEmpty()) { | |
| 96 | + Toast.makeText(this, "你的ID不能为空", Toast.LENGTH_SHORT).show(); | |
| 97 | + } else { | |
| 98 | + user_id_edit.getText().toString(); | |
| 99 | + oppositeID = user_id_edit.getText().toString(); | |
| 100 | + my_id_editID = my_id_edit.getText().toString(); | |
| 101 | + linearLayoutUseID.setVisibility(View.INVISIBLE); | |
| 102 | + edit_layout.setVisibility(View.VISIBLE); | |
| 103 | + chatListView.setVisibility(View.VISIBLE); | |
| 104 | + my_liner_userID.setVisibility(View.INVISIBLE); | |
| 105 | + CNUserInfo cnName = new CNUserInfo(my_id_editID, "cnName", ""); | |
| 106 | + ChatUtil.login(cnName, connectListener); | |
| 107 | + } | |
| 108 | + | |
| 109 | + break; | |
| 110 | + } | |
| 111 | + } | |
| 112 | + | |
| 113 | + | |
| 114 | + //连接监听 | |
| 115 | + private IChat.OnConnectListener connectListener = new IChat.OnConnectListener() { | |
| 116 | + @Override | |
| 117 | + public void onTokenIncorrect() { | |
| 118 | + Log.e(TAG, "私聊ConnectListener TokenIncorrect"); | |
| 119 | + } | |
| 120 | + | |
| 121 | + @Override | |
| 122 | + public void onSuccess(String s) { | |
| 123 | + Log.e(TAG, "私聊ConnectListener 连接监听" + s); | |
| 124 | + | |
| 125 | + } | |
| 126 | + | |
| 127 | + @Override | |
| 128 | + public void onError(int i, String s) { | |
| 129 | + Log.e(TAG, "私聊ConnectListener errorCode : " + i + " : errorMessage : " + s); | |
| 130 | + } | |
| 131 | + }; | |
| 132 | + | |
| 133 | + | |
| 134 | + /** | |
| 135 | + * 发送消息监听 | |
| 136 | + */ | |
| 137 | + private IChat.OnSendMessageListener sendMessageListener = new IChat.OnSendMessageListener() { | |
| 138 | + | |
| 139 | + @Override | |
| 140 | + public void onAttached(CNMessage cnMessage) { | |
| 141 | +Toast.makeText(PrivateChatActivity.this,"onAttached",Toast.LENGTH_LONG).show(); | |
| 142 | + Log.v(TAG, "私聊SendMessageListener onAttached" + cnMessage.getTargetId() + cnMessage.getUserInfo().getUserName()); | |
| 143 | + | |
| 144 | + } | |
| 145 | + | |
| 146 | + @Override | |
| 147 | + public void onSuccess(CNMessage cnMessage) { | |
| 148 | + Toast.makeText(PrivateChatActivity.this,"onSuccess",Toast.LENGTH_LONG).show(); | |
| 149 | + | |
| 150 | + messageList.add(cnMessage); | |
| 151 | + chatListAdapter.updateItems(messageList); | |
| 152 | + chatListAdapter.notifyDataSetChanged(); | |
| 153 | + Log.v(TAG, "私聊SendMessageListener SUCCESSES" + cnMessage.getTargetId() + cnMessage.getUserInfo().getUserName()); | |
| 154 | + | |
| 155 | + | |
| 156 | + } | |
| 157 | + | |
| 158 | + @Override | |
| 159 | + public void onError(CNMessage cnMessage, int i, String s) { | |
| 160 | + Log.v(TAG, "私聊SendMessageListener 失败 " + i + " s" + s); | |
| 161 | + Toast.makeText(PrivateChatActivity.this,"失败",Toast.LENGTH_LONG).show(); | |
| 162 | + | |
| 163 | + | |
| 164 | + } | |
| 165 | + }; | |
| 166 | + | |
| 167 | + //连接状态监听 | |
| 168 | + private IChat.OnConnectStatusListener connectStatusListener = new IChat.OnConnectStatusListener() { | |
| 169 | + @Override | |
| 170 | + public void onConnectStatus(int i, String s) { | |
| 171 | + Log.i(TAG, "私聊连接状态监听私聊" + i + " " + s); | |
| 172 | + | |
| 173 | + | |
| 174 | + } | |
| 175 | + }; | |
| 176 | + | |
| 177 | + //接收消息监听 | |
| 178 | + private IChat.OnReceiveMessageListener receiveMessageListener = new IChat.OnReceiveMessageListener() { | |
| 179 | + @Override | |
| 180 | + public void processMessage(CNMessage cnMessage) { | |
| 181 | + Log.v(TAG, "私聊receiveMessageListener" + " " + cnMessage.getTargetId() + " " + cnMessage.getContent()); | |
| 182 | + | |
| 183 | + messageList.add(cnMessage); | |
| 184 | + chatListAdapter.updateItems(messageList); | |
| 185 | + chatListAdapter.notifyDataSetChanged(); | |
| 186 | + | |
| 187 | + } | |
| 188 | + }; | |
| 189 | + | |
| 190 | + | |
| 191 | + //聊天室操作 | |
| 192 | + private IChat.OnChatRoomActionListener chatRoomActionListener = new IChat.OnChatRoomActionListener() { | |
| 193 | + @Override | |
| 194 | + public void onJoining(String s) { | |
| 195 | + Log.i(TAG, "私聊chatRoomActionListener" + " onJoined" + s); | |
| 196 | + | |
| 197 | + } | |
| 198 | + | |
| 199 | + @Override | |
| 200 | + public void onJoined(String s) { | |
| 201 | + Log.i(TAG, "私聊chatRoomActionListener " + "onJoined" + s); | |
| 202 | + | |
| 203 | + } | |
| 204 | + | |
| 205 | + @Override | |
| 206 | + public void onQuited(String s) { | |
| 207 | + Log.i(TAG, "私聊chatRoomActionListener " + "onQuited" + s); | |
| 208 | + | |
| 209 | + } | |
| 210 | + | |
| 211 | + @Override | |
| 212 | + public void onError(String s, int i, String s1) { | |
| 213 | + Log.i(TAG, "私聊chatRoomActionListener " + "onError" + s); | |
| 214 | + | |
| 215 | + } | |
| 216 | + }; | |
| 217 | + | |
| 218 | + | |
| 219 | + //获取历史消息监听 | |
| 220 | +// private IChat.OnLatestMessageListener latestMessageListener = new IChat.OnLatestMessageListener() { | |
| 221 | +// @Override | |
| 222 | +// public void onSuccess(List<CNMessage> list) { | |
| 223 | +// | |
| 224 | +// } | |
| 225 | +// | |
| 226 | +// @Override | |
| 227 | +// public void onError(int i, String s) { | |
| 228 | +// | |
| 229 | +// } | |
| 230 | +// }; | |
| 231 | + | |
| 232 | + | |
| 233 | + @Override | |
| 234 | + protected void onPause() { | |
| 235 | + super.onPause(); | |
| 236 | + ChatUtil.disconnect(true); | |
| 237 | + | |
| 238 | + } | |
| 239 | + | |
| 240 | + | |
| 241 | +} | |
| 242 | + | ... | ... |
app/src/main/jniLibs/arm64-v8a/libRongIMLib.so
0 → 100644
No preview for this file type
app/src/main/jniLibs/armeabi-v7a/libRongIMLib.so
0 → 100644
No preview for this file type
app/src/main/jniLibs/armeabi/libRongIMLib.so
0 → 100644
No preview for this file type
app/src/main/jniLibs/x86/libRongIMLib.so
0 → 100644
No preview for this file type
app/src/main/res/layout/activity_groupchat.xml
0 → 100644
| 1 | +++ a/app/src/main/res/layout/activity_groupchat.xml | |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + android:id="@+id/activity_chat_room" | |
| 4 | + android:layout_width="match_parent" | |
| 5 | + android:layout_height="match_parent" | |
| 6 | + > | |
| 7 | + | |
| 8 | + <LinearLayout | |
| 9 | + android:id="@+id/listVIewTop" | |
| 10 | + 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" /> | |
| 39 | + | |
| 40 | + </LinearLayout> | |
| 41 | + | |
| 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_below="@+id/creatChat2" | |
| 48 | + android:layout_alignParentLeft="true" | |
| 49 | + android:layout_alignParentStart="true" /> | |
| 50 | + | |
| 51 | + <LinearLayout | |
| 52 | + android:id="@+id/edit_layout" | |
| 53 | + android:layout_width="match_parent" | |
| 54 | + android:layout_height="wrap_content" | |
| 55 | + android:layout_alignParentBottom="true" | |
| 56 | + android:orientation="horizontal"> | |
| 57 | + | |
| 58 | + <EditText | |
| 59 | + android:id="@+id/message_content" | |
| 60 | + android:layout_width="0dp" | |
| 61 | + android:layout_height="wrap_content" | |
| 62 | + android:layout_gravity="center" | |
| 63 | + android:layout_weight="0.7" /> | |
| 64 | + | |
| 65 | + <Button | |
| 66 | + android:id="@+id/send_messageOne" | |
| 67 | + android:layout_width="0dp" | |
| 68 | + android:layout_height="wrap_content" | |
| 69 | + android:layout_gravity="center" | |
| 70 | + android:layout_weight="0.2" | |
| 71 | + android:text="聊天室1" /> | |
| 72 | + | |
| 73 | + | |
| 74 | + <Button | |
| 75 | + android:id="@+id/send_messageTwo" | |
| 76 | + android:layout_width="0dp" | |
| 77 | + android:layout_height="wrap_content" | |
| 78 | + android:layout_gravity="center" | |
| 79 | + android:layout_weight="0.2" | |
| 80 | + android:text="聊天室2" /> | |
| 81 | + </LinearLayout> | |
| 82 | + | |
| 83 | + <Button | |
| 84 | + android:id="@+id/connectionBtn" | |
| 85 | + android:layout_width="wrap_content" | |
| 86 | + android:layout_height="wrap_content" | |
| 87 | + android:text="连接服务器" | |
| 88 | + android:layout_below="@+id/listVIewTop" | |
| 89 | + android:layout_alignParentLeft="true" | |
| 90 | + android:layout_alignParentStart="true" /> | |
| 91 | + | |
| 92 | + <Button | |
| 93 | + android:id="@+id/switch_visitors" | |
| 94 | + android:layout_width="wrap_content" | |
| 95 | + android:layout_height="wrap_content" | |
| 96 | + android:text="切换游客" | |
| 97 | + android:layout_below="@+id/creatChat" | |
| 98 | + android:layout_toRightOf="@+id/user_switch" | |
| 99 | + android:layout_toEndOf="@+id/user_switch" /> | |
| 100 | + | |
| 101 | + <Button | |
| 102 | + android:id="@+id/creatChat" | |
| 103 | + android:layout_width="wrap_content" | |
| 104 | + android:layout_height="wrap_content" | |
| 105 | + android:text="创建聊天室1" | |
| 106 | + android:layout_alignBaseline="@+id/creatChat2" | |
| 107 | + android:layout_alignBottom="@+id/creatChat2" | |
| 108 | + android:layout_toRightOf="@+id/connectionBtn" /> | |
| 109 | + | |
| 110 | + <Button | |
| 111 | + android:id="@+id/disconnect" | |
| 112 | + android:layout_width="wrap_content" | |
| 113 | + android:layout_height="wrap_content" | |
| 114 | + android:text="断开连接" | |
| 115 | + android:layout_marginLeft="11dp" | |
| 116 | + android:layout_marginStart="11dp" | |
| 117 | + android:layout_below="@+id/creatChat2" | |
| 118 | + android:layout_toRightOf="@+id/switch_visitors" | |
| 119 | + android:layout_toEndOf="@+id/switch_visitors" /> | |
| 120 | + | |
| 121 | + <Button | |
| 122 | + android:id="@+id/creatChat2" | |
| 123 | + android:layout_width="wrap_content" | |
| 124 | + android:layout_height="wrap_content" | |
| 125 | + android:text="创建聊天室2" | |
| 126 | + android:layout_alignBaseline="@+id/connectionBtn" | |
| 127 | + android:layout_alignBottom="@+id/connectionBtn" | |
| 128 | + android:layout_toRightOf="@+id/creatChat" | |
| 129 | + android:layout_toEndOf="@+id/creatChat" /> | |
| 130 | + | |
| 131 | + | |
| 132 | +</RelativeLayout> | ... | ... |
app/src/main/res/layout/activity_main.xml
0 → 100644
| 1 | +++ a/app/src/main/res/layout/activity_main.xml | |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + xmlns:tools="http://schemas.android.com/tools" | |
| 4 | + android:id="@+id/activity_main" | |
| 5 | + android:layout_width="match_parent" | |
| 6 | + android:layout_height="match_parent" | |
| 7 | + android:paddingBottom="@dimen/activity_vertical_margin" | |
| 8 | + android:paddingLeft="@dimen/activity_horizontal_margin" | |
| 9 | + android:paddingRight="@dimen/activity_horizontal_margin" | |
| 10 | + android:paddingTop="@dimen/activity_vertical_margin" | |
| 11 | + tools:context="com.cnlive.im.ui.MainActivity"> | |
| 12 | + | |
| 13 | + | |
| 14 | + <Button | |
| 15 | + android:text="群聊" | |
| 16 | + android:layout_width="wrap_content" | |
| 17 | + android:layout_height="wrap_content" | |
| 18 | + android:layout_marginTop="140dp" | |
| 19 | + android:id="@+id/groupChat" | |
| 20 | + android:layout_alignParentEnd="true" | |
| 21 | + android:layout_alignParentStart="true" /> | |
| 22 | + | |
| 23 | + <Button | |
| 24 | + android:text="私聊" | |
| 25 | + android:layout_width="wrap_content" | |
| 26 | + android:layout_height="wrap_content" | |
| 27 | + android:layout_below="@+id/groupChat" | |
| 28 | + android:layout_alignStart="@+id/groupChat" | |
| 29 | + android:layout_marginTop="34dp" | |
| 30 | + android:id="@+id/privateChat" | |
| 31 | + android:layout_alignParentEnd="true" /> | |
| 32 | +</RelativeLayout> | ... | ... |
app/src/main/res/layout/activity_private_chat.xml
0 → 100644
| 1 | +++ a/app/src/main/res/layout/activity_private_chat.xml | |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + android:id="@+id/activity_private_chat" | |
| 4 | + android:layout_width="match_parent" | |
| 5 | + android:layout_height="match_parent"> | |
| 6 | + | |
| 7 | + <ListView | |
| 8 | + android:id="@+id/private_list_view" | |
| 9 | + android:layout_width="match_parent" | |
| 10 | + android:layout_height="300dp" | |
| 11 | + android:divider="@null" | |
| 12 | + android:scrollbars="none" | |
| 13 | + android:transcriptMode="alwaysScroll" | |
| 14 | + android:visibility="invisible" /> | |
| 15 | + | |
| 16 | + <LinearLayout | |
| 17 | + android:id="@+id/edit_layout" | |
| 18 | + android:layout_width="match_parent" | |
| 19 | + android:layout_height="wrap_content" | |
| 20 | + android:layout_alignParentBottom="true" | |
| 21 | + android:orientation="horizontal" | |
| 22 | + android:visibility="invisible"> | |
| 23 | + | |
| 24 | + <EditText | |
| 25 | + android:id="@+id/message_content" | |
| 26 | + android:layout_width="0dp" | |
| 27 | + android:layout_height="wrap_content" | |
| 28 | + android:layout_gravity="center" | |
| 29 | + android:layout_weight="0.7" /> | |
| 30 | + | |
| 31 | + <Button | |
| 32 | + android:id="@+id/send_message" | |
| 33 | + android:layout_width="0dp" | |
| 34 | + android:layout_height="wrap_content" | |
| 35 | + android:layout_gravity="center" | |
| 36 | + android:layout_weight="0.2" | |
| 37 | + android:text="发送" /> | |
| 38 | + </LinearLayout> | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + <LinearLayout | |
| 44 | + android:id="@+id/opposite_liner_useID" | |
| 45 | + android:layout_width="match_parent" | |
| 46 | + android:layout_height="wrap_content" | |
| 47 | + android:layout_centerInParent="true" | |
| 48 | + android:orientation="horizontal"> | |
| 49 | + | |
| 50 | + <TextView | |
| 51 | + android:layout_width="wrap_content" | |
| 52 | + android:layout_height="wrap_content" | |
| 53 | + android:layout_gravity="center" | |
| 54 | + android:gravity="center" | |
| 55 | + android:text="对方id :" | |
| 56 | + android:textSize="22dp" | |
| 57 | + android:textStyle="bold" /> | |
| 58 | + | |
| 59 | + <EditText | |
| 60 | + android:id="@+id/opposite_id_edit" | |
| 61 | + android:layout_width="0dp" | |
| 62 | + android:layout_height="wrap_content" | |
| 63 | + android:layout_gravity="center" | |
| 64 | + android:layout_weight="1" /> | |
| 65 | + | |
| 66 | + | |
| 67 | + <Button | |
| 68 | + android:id="@+id/userId_btn_top" | |
| 69 | + android:layout_width="wrap_content" | |
| 70 | + android:layout_height="wrap_content" | |
| 71 | + android:layout_gravity="center" | |
| 72 | + android:text="完成" /> | |
| 73 | + | |
| 74 | + </LinearLayout> | |
| 75 | + <LinearLayout | |
| 76 | + android:id="@+id/my_liner_userID" | |
| 77 | + android:layout_width="match_parent" | |
| 78 | + android:layout_height="wrap_content" | |
| 79 | + android:layout_above="@id/opposite_liner_useID" | |
| 80 | + android:orientation="horizontal"> | |
| 81 | + | |
| 82 | + <TextView | |
| 83 | + android:layout_width="wrap_content" | |
| 84 | + android:layout_height="wrap_content" | |
| 85 | + android:layout_gravity="center" | |
| 86 | + android:gravity="center" | |
| 87 | + android:text="我的id :" | |
| 88 | + android:textSize="22dp" | |
| 89 | + android:textStyle="bold" /> | |
| 90 | + | |
| 91 | + <EditText | |
| 92 | + android:id="@+id/my_id_edit" | |
| 93 | + android:layout_width="0dp" | |
| 94 | + android:layout_height="wrap_content" | |
| 95 | + android:layout_gravity="center" | |
| 96 | + android:layout_weight="1" /> | |
| 97 | + | |
| 98 | + <Button | |
| 99 | + android:id="@+id/my_btn_top" | |
| 100 | + android:layout_width="wrap_content" | |
| 101 | + android:layout_height="wrap_content" | |
| 102 | + android:layout_gravity="center" | |
| 103 | + android:text="完成" | |
| 104 | + android:visibility="invisible" /> | |
| 105 | + | |
| 106 | + </LinearLayout> | |
| 107 | + | |
| 108 | + | |
| 109 | +</RelativeLayout> | ... | ... |
app/src/main/res/layout/holder_chat.xml
0 → 100644
| 1 | +++ a/app/src/main/res/layout/holder_chat.xml | |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + android:layout_width="match_parent" | |
| 4 | + android:layout_height="match_parent" | |
| 5 | + android:orientation="vertical"> | |
| 6 | + | |
| 7 | + <TextView | |
| 8 | + android:id="@+id/textView" | |
| 9 | + android:layout_width="match_parent" | |
| 10 | + android:layout_height="wrap_content" | |
| 11 | + android:text="TextView" /> | |
| 12 | +</LinearLayout> | |
| 0 | 13 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/msg_text_view.xml
0 → 100644
| 1 | +++ a/app/src/main/res/layout/msg_text_view.xml | |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + android:layout_width="match_parent" | |
| 4 | + android:layout_height="match_parent" | |
| 5 | + android:orientation="horizontal"> | |
| 6 | + | |
| 7 | + <TextView | |
| 8 | + android:id="@+id/user_name" | |
| 9 | + android:layout_width="wrap_content" | |
| 10 | + android:layout_height="wrap_content" | |
| 11 | + android:gravity="center_vertical" | |
| 12 | + android:textColor="#3ce1ff" | |
| 13 | + android:textSize="14sp" /> | |
| 14 | + | |
| 15 | + <TextView | |
| 16 | + android:id="@+id/msg_text" | |
| 17 | + android:layout_width="wrap_content" | |
| 18 | + android:layout_height="wrap_content" | |
| 19 | + android:textColor="@android:color/black" | |
| 20 | + android:textSize="15sp" /> | |
| 21 | +</LinearLayout> | |
| 0 | 22 | \ No newline at end of file | ... | ... |
app/src/main/res/mipmap-hdpi/ic_launcher.png
0 → 100644
3.34 KB
app/src/main/res/mipmap-mdpi/ic_launcher.png
0 → 100644
2.15 KB
app/src/main/res/mipmap-xhdpi/ic_launcher.png
0 → 100644
4.73 KB
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
0 → 100644
7.54 KB
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
0 → 100644
10.2 KB
app/src/main/res/values-v21/styles.xml
0 → 100644
| 1 | +++ a/app/src/main/res/values-v21/styles.xml | |
| 1 | +<resources> | |
| 2 | + | |
| 3 | + <style name="AppTheme.NoActionBar"> | |
| 4 | + <item name="windowActionBar">false</item> | |
| 5 | + <item name="windowNoTitle">true</item> | |
| 6 | + <item name="android:windowDrawsSystemBarBackgrounds">true</item> | |
| 7 | + <item name="android:statusBarColor">@android:color/transparent</item> | |
| 8 | + </style> | |
| 9 | +</resources> | ... | ... |
app/src/main/res/values-w820dp/dimens.xml
0 → 100644
| 1 | +++ a/app/src/main/res/values-w820dp/dimens.xml | |
| 1 | +<resources> | |
| 2 | + <!-- Example customization of dimensions originally defined in res/values/dimens.xml | |
| 3 | + (such as screen margins) for screens with more than 820dp of available width. This | |
| 4 | + would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> | |
| 5 | + <dimen name="activity_horizontal_margin">64dp</dimen> | |
| 6 | +</resources> | ... | ... |
app/src/main/res/values/colors.xml
0 → 100644
app/src/main/res/values/dimens.xml
0 → 100644
| 1 | +++ a/app/src/main/res/values/dimens.xml | |
| 1 | +<resources> | |
| 2 | + <!-- Default screen margins, per the Android Design guidelines. --> | |
| 3 | + <dimen name="activity_horizontal_margin">16dp</dimen> | |
| 4 | + <dimen name="activity_vertical_margin">16dp</dimen> | |
| 5 | + <dimen name="fab_margin">16dp</dimen> | |
| 6 | +</resources> | ... | ... |
app/src/main/res/values/strings.xml
0 → 100644
app/src/main/res/values/styles.xml
0 → 100644
| 1 | +++ a/app/src/main/res/values/styles.xml | |
| 1 | +<resources> | |
| 2 | + | |
| 3 | + <!-- Base application theme. --> | |
| 4 | + <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | |
| 5 | + <!-- Customize your theme here. --> | |
| 6 | + <item name="colorPrimary">@color/colorPrimary</item> | |
| 7 | + <item name="colorPrimaryDark">@color/colorPrimaryDark</item> | |
| 8 | + <item name="colorAccent">@color/colorAccent</item> | |
| 9 | + </style> | |
| 10 | + | |
| 11 | + <style name="AppTheme.NoActionBar"> | |
| 12 | + <item name="windowActionBar">false</item> | |
| 13 | + <item name="windowNoTitle">true</item> | |
| 14 | + </style> | |
| 15 | + | |
| 16 | + <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> | |
| 17 | + | |
| 18 | + <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> | |
| 19 | + | |
| 20 | +</resources> | ... | ... |
app/src/test/java/com/cnlive/im/ExampleUnitTest.java
0 → 100644
| 1 | +++ a/app/src/test/java/com/cnlive/im/ExampleUnitTest.java | |
| 1 | +package com.cnlive.im; | |
| 2 | + | |
| 3 | +import org.junit.Test; | |
| 4 | + | |
| 5 | +import static org.junit.Assert.*; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * Example local unit test, which will execute on the development machine (host). | |
| 9 | + * | |
| 10 | + * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | |
| 11 | + */ | |
| 12 | +public class ExampleUnitTest { | |
| 13 | + @Test | |
| 14 | + public void addition_isCorrect() throws Exception { | |
| 15 | + assertEquals(4, 2 + 2); | |
| 16 | + } | |
| 17 | +} | |
| 0 | 18 | \ No newline at end of file | ... | ... |
build.gradle
0 → 100644
| 1 | +++ a/build.gradle | |
| 1 | +// Top-level build file where you can add configuration options common to all sub-projects/modules. | |
| 2 | + | |
| 3 | +buildscript { | |
| 4 | + repositories { | |
| 5 | + jcenter() | |
| 6 | + } | |
| 7 | + dependencies { | |
| 8 | + classpath 'com.android.tools.build:gradle:2.3.0' | |
| 9 | + | |
| 10 | + // NOTE: Do not place your application dependencies here; they belong | |
| 11 | + // in the individual module build.gradle files | |
| 12 | + } | |
| 13 | +} | |
| 14 | + | |
| 15 | +allprojects { | |
| 16 | + repositories { | |
| 17 | + jcenter() | |
| 18 | + } | |
| 19 | +} | |
| 20 | + | |
| 21 | +task clean(type: Delete) { | |
| 22 | + delete rootProject.buildDir | |
| 23 | +} | ... | ... |
gradle.properties
0 → 100644
| 1 | +++ a/gradle.properties | |
| 1 | +# Project-wide Gradle settings. | |
| 2 | + | |
| 3 | +# IDE (e.g. Android Studio) users: | |
| 4 | +# Gradle settings configured through the IDE *will override* | |
| 5 | +# any settings specified in this file. | |
| 6 | + | |
| 7 | +# For more details on how to configure your build environment visit | |
| 8 | +# http://www.gradle.org/docs/current/userguide/build_environment.html | |
| 9 | + | |
| 10 | +# Specifies the JVM arguments used for the daemon process. | |
| 11 | +# The setting is particularly useful for tweaking memory settings. | |
| 12 | +org.gradle.jvmargs=-Xmx1536m | |
| 13 | + | |
| 14 | +# When configured, Gradle will run in incubating parallel mode. | |
| 15 | +# This option should only be used with decoupled projects. More details, visit | |
| 16 | +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | |
| 17 | +# org.gradle.parallel=true | ... | ... |
gradle/wrapper/gradle-wrapper.jar
0 → 100644
No preview for this file type
gradle/wrapper/gradle-wrapper.properties
0 → 100644
| 1 | +++ a/gradle/wrapper/gradle-wrapper.properties | |
| 1 | +#Mon Mar 13 13:17:39 CST 2017 | |
| 2 | +distributionBase=GRADLE_USER_HOME | |
| 3 | +distributionPath=wrapper/dists | |
| 4 | +zipStoreBase=GRADLE_USER_HOME | |
| 5 | +zipStorePath=wrapper/dists | |
| 6 | +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip | ... | ... |
gradlew
0 → 100644
| 1 | +++ a/gradlew | |
| 1 | +#!/usr/bin/env bash | |
| 2 | + | |
| 3 | +############################################################################## | |
| 4 | +## | |
| 5 | +## Gradle start up script for UN*X | |
| 6 | +## | |
| 7 | +############################################################################## | |
| 8 | + | |
| 9 | +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | |
| 10 | +DEFAULT_JVM_OPTS="" | |
| 11 | + | |
| 12 | +APP_NAME="Gradle" | |
| 13 | +APP_BASE_NAME=`basename "$0"` | |
| 14 | + | |
| 15 | +# Use the maximum available, or set MAX_FD != -1 to use that value. | |
| 16 | +MAX_FD="maximum" | |
| 17 | + | |
| 18 | +warn ( ) { | |
| 19 | + echo "$*" | |
| 20 | +} | |
| 21 | + | |
| 22 | +die ( ) { | |
| 23 | + echo | |
| 24 | + echo "$*" | |
| 25 | + echo | |
| 26 | + exit 1 | |
| 27 | +} | |
| 28 | + | |
| 29 | +# OS specific support (must be 'true' or 'false'). | |
| 30 | +cygwin=false | |
| 31 | +msys=false | |
| 32 | +darwin=false | |
| 33 | +case "`uname`" in | |
| 34 | + CYGWIN* ) | |
| 35 | + cygwin=true | |
| 36 | + ;; | |
| 37 | + Darwin* ) | |
| 38 | + darwin=true | |
| 39 | + ;; | |
| 40 | + MINGW* ) | |
| 41 | + msys=true | |
| 42 | + ;; | |
| 43 | +esac | |
| 44 | + | |
| 45 | +# Attempt to set APP_HOME | |
| 46 | +# Resolve links: $0 may be a link | |
| 47 | +PRG="$0" | |
| 48 | +# Need this for relative symlinks. | |
| 49 | +while [ -h "$PRG" ] ; do | |
| 50 | + ls=`ls -ld "$PRG"` | |
| 51 | + link=`expr "$ls" : '.*-> \(.*\)$'` | |
| 52 | + if expr "$link" : '/.*' > /dev/null; then | |
| 53 | + PRG="$link" | |
| 54 | + else | |
| 55 | + PRG=`dirname "$PRG"`"/$link" | |
| 56 | + fi | |
| 57 | +done | |
| 58 | +SAVED="`pwd`" | |
| 59 | +cd "`dirname \"$PRG\"`/" >/dev/null | |
| 60 | +APP_HOME="`pwd -P`" | |
| 61 | +cd "$SAVED" >/dev/null | |
| 62 | + | |
| 63 | +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar | |
| 64 | + | |
| 65 | +# Determine the Java command to use to start the JVM. | |
| 66 | +if [ -n "$JAVA_HOME" ] ; then | |
| 67 | + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then | |
| 68 | + # IBM's JDK on AIX uses strange locations for the executables | |
| 69 | + JAVACMD="$JAVA_HOME/jre/sh/java" | |
| 70 | + else | |
| 71 | + JAVACMD="$JAVA_HOME/bin/java" | |
| 72 | + fi | |
| 73 | + if [ ! -x "$JAVACMD" ] ; then | |
| 74 | + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME | |
| 75 | + | |
| 76 | +Please set the JAVA_HOME variable in your environment to match the | |
| 77 | +location of your Java installation." | |
| 78 | + fi | |
| 79 | +else | |
| 80 | + JAVACMD="java" | |
| 81 | + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | |
| 82 | + | |
| 83 | +Please set the JAVA_HOME variable in your environment to match the | |
| 84 | +location of your Java installation." | |
| 85 | +fi | |
| 86 | + | |
| 87 | +# Increase the maximum file descriptors if we can. | |
| 88 | +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then | |
| 89 | + MAX_FD_LIMIT=`ulimit -H -n` | |
| 90 | + if [ $? -eq 0 ] ; then | |
| 91 | + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then | |
| 92 | + MAX_FD="$MAX_FD_LIMIT" | |
| 93 | + fi | |
| 94 | + ulimit -n $MAX_FD | |
| 95 | + if [ $? -ne 0 ] ; then | |
| 96 | + warn "Could not set maximum file descriptor limit: $MAX_FD" | |
| 97 | + fi | |
| 98 | + else | |
| 99 | + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" | |
| 100 | + fi | |
| 101 | +fi | |
| 102 | + | |
| 103 | +# For Darwin, add options to specify how the application appears in the dock | |
| 104 | +if $darwin; then | |
| 105 | + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" | |
| 106 | +fi | |
| 107 | + | |
| 108 | +# For Cygwin, switch paths to Windows format before running java | |
| 109 | +if $cygwin ; then | |
| 110 | + APP_HOME=`cygpath --path --mixed "$APP_HOME"` | |
| 111 | + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` | |
| 112 | + JAVACMD=`cygpath --unix "$JAVACMD"` | |
| 113 | + | |
| 114 | + # We build the pattern for arguments to be converted via cygpath | |
| 115 | + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` | |
| 116 | + SEP="" | |
| 117 | + for dir in $ROOTDIRSRAW ; do | |
| 118 | + ROOTDIRS="$ROOTDIRS$SEP$dir" | |
| 119 | + SEP="|" | |
| 120 | + done | |
| 121 | + OURCYGPATTERN="(^($ROOTDIRS))" | |
| 122 | + # Add a user-defined pattern to the cygpath arguments | |
| 123 | + if [ "$GRADLE_CYGPATTERN" != "" ] ; then | |
| 124 | + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" | |
| 125 | + fi | |
| 126 | + # Now convert the arguments - kludge to limit ourselves to /bin/sh | |
| 127 | + i=0 | |
| 128 | + for arg in "$@" ; do | |
| 129 | + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` | |
| 130 | + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option | |
| 131 | + | |
| 132 | + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition | |
| 133 | + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` | |
| 134 | + else | |
| 135 | + eval `echo args$i`="\"$arg\"" | |
| 136 | + fi | |
| 137 | + i=$((i+1)) | |
| 138 | + done | |
| 139 | + case $i in | |
| 140 | + (0) set -- ;; | |
| 141 | + (1) set -- "$args0" ;; | |
| 142 | + (2) set -- "$args0" "$args1" ;; | |
| 143 | + (3) set -- "$args0" "$args1" "$args2" ;; | |
| 144 | + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; | |
| 145 | + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; | |
| 146 | + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; | |
| 147 | + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; | |
| 148 | + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; | |
| 149 | + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; | |
| 150 | + esac | |
| 151 | +fi | |
| 152 | + | |
| 153 | +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules | |
| 154 | +function splitJvmOpts() { | |
| 155 | + JVM_OPTS=("$@") | |
| 156 | +} | |
| 157 | +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS | |
| 158 | +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" | |
| 159 | + | |
| 160 | +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" | ... | ... |
gradlew.bat
0 → 100644
| 1 | +++ a/gradlew.bat | |
| 1 | +@if "%DEBUG%" == "" @echo off | |
| 2 | +@rem ########################################################################## | |
| 3 | +@rem | |
| 4 | +@rem Gradle startup script for Windows | |
| 5 | +@rem | |
| 6 | +@rem ########################################################################## | |
| 7 | + | |
| 8 | +@rem Set local scope for the variables with windows NT shell | |
| 9 | +if "%OS%"=="Windows_NT" setlocal | |
| 10 | + | |
| 11 | +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | |
| 12 | +set DEFAULT_JVM_OPTS= | |
| 13 | + | |
| 14 | +set DIRNAME=%~dp0 | |
| 15 | +if "%DIRNAME%" == "" set DIRNAME=. | |
| 16 | +set APP_BASE_NAME=%~n0 | |
| 17 | +set APP_HOME=%DIRNAME% | |
| 18 | + | |
| 19 | +@rem Find java.exe | |
| 20 | +if defined JAVA_HOME goto findJavaFromJavaHome | |
| 21 | + | |
| 22 | +set JAVA_EXE=java.exe | |
| 23 | +%JAVA_EXE% -version >NUL 2>&1 | |
| 24 | +if "%ERRORLEVEL%" == "0" goto init | |
| 25 | + | |
| 26 | +echo. | |
| 27 | +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | |
| 28 | +echo. | |
| 29 | +echo Please set the JAVA_HOME variable in your environment to match the | |
| 30 | +echo location of your Java installation. | |
| 31 | + | |
| 32 | +goto fail | |
| 33 | + | |
| 34 | +:findJavaFromJavaHome | |
| 35 | +set JAVA_HOME=%JAVA_HOME:"=% | |
| 36 | +set JAVA_EXE=%JAVA_HOME%/bin/java.exe | |
| 37 | + | |
| 38 | +if exist "%JAVA_EXE%" goto init | |
| 39 | + | |
| 40 | +echo. | |
| 41 | +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% | |
| 42 | +echo. | |
| 43 | +echo Please set the JAVA_HOME variable in your environment to match the | |
| 44 | +echo location of your Java installation. | |
| 45 | + | |
| 46 | +goto fail | |
| 47 | + | |
| 48 | +:init | |
| 49 | +@rem Get command-line arguments, handling Windowz variants | |
| 50 | + | |
| 51 | +if not "%OS%" == "Windows_NT" goto win9xME_args | |
| 52 | +if "%@eval[2+2]" == "4" goto 4NT_args | |
| 53 | + | |
| 54 | +:win9xME_args | |
| 55 | +@rem Slurp the command line arguments. | |
| 56 | +set CMD_LINE_ARGS= | |
| 57 | +set _SKIP=2 | |
| 58 | + | |
| 59 | +:win9xME_args_slurp | |
| 60 | +if "x%~1" == "x" goto execute | |
| 61 | + | |
| 62 | +set CMD_LINE_ARGS=%* | |
| 63 | +goto execute | |
| 64 | + | |
| 65 | +:4NT_args | |
| 66 | +@rem Get arguments from the 4NT Shell from JP Software | |
| 67 | +set CMD_LINE_ARGS=%$ | |
| 68 | + | |
| 69 | +:execute | |
| 70 | +@rem Setup the command line | |
| 71 | + | |
| 72 | +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar | |
| 73 | + | |
| 74 | +@rem Execute Gradle | |
| 75 | +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% | |
| 76 | + | |
| 77 | +:end | |
| 78 | +@rem End local scope for the variables with windows NT shell | |
| 79 | +if "%ERRORLEVEL%"=="0" goto mainEnd | |
| 80 | + | |
| 81 | +:fail | |
| 82 | +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of | |
| 83 | +rem the _cmd.exe /c_ return code! | |
| 84 | +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 | |
| 85 | +exit /b 1 | |
| 86 | + | |
| 87 | +:mainEnd | |
| 88 | +if "%OS%"=="Windows_NT" endlocal | |
| 89 | + | |
| 90 | +:omega | ... | ... |
settings.gradle
0 → 100644