android sdk更新

适配targetSdkVersion 33
This commit is contained in:
远方夕阳 2023-02-15 11:15:43 +08:00
parent 97fe0a2721
commit 046bfd8ade
10 changed files with 79 additions and 57 deletions

29
.gitignore vendored
View File

@ -1,2 +1,27 @@
target/ # Compiled class file
app/build/ *.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
/target/
/.idea/
*.class
*/local.properties

View File

@ -181,7 +181,7 @@ https://www.yuque.com/yuanfangxiyang/ma4ytb/vvy3iz/edit#nnzKN
<dependency> <dependency>
<groupId>com.farsunset</groupId> <groupId>com.farsunset</groupId>
<artifactId>cim-server-sdk-netty</artifactId> <artifactId>cim-server-sdk-netty</artifactId>
<version>4.2.5</version> <version>4.2.6</version>
</dependency> </dependency>
``` ```
@ -189,5 +189,5 @@ https://www.yuque.com/yuanfangxiyang/ma4ytb/vvy3iz/edit#nnzKN
android端sdk引用 android端sdk引用
``` ```
implementation "com.farsunset:cim-android-sdk:4.2.8" implementation "com.farsunset:cim-android-sdk:4.2.10"
``` ```

View File

@ -6,7 +6,7 @@
<groupId>com.farsunset</groupId> <groupId>com.farsunset</groupId>
<artifactId>cim-android-sdk</artifactId> <artifactId>cim-android-sdk</artifactId>
<version>4.2.9</version> <version>4.2.10</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>${project.groupId}:${project.artifactId}</name> <name>${project.groupId}:${project.artifactId}</name>

View File

@ -22,21 +22,21 @@
package com.farsunset.cim.sdk.android; package com.farsunset.cim.sdk.android;
import android.net.NetworkInfo; import android.net.NetworkInfo;
import android.util.Log;
import com.farsunset.cim.sdk.android.model.Message; import com.farsunset.cim.sdk.android.model.Message;
import com.farsunset.cim.sdk.android.model.ReplyBody; import com.farsunset.cim.sdk.android.model.ReplyBody;
import com.farsunset.cim.sdk.android.model.SentBody; import com.farsunset.cim.sdk.android.model.SentBody;
import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
/** /**
* CIM 消息监听器管理 * CIM 消息监听器管理
*/ */
public class CIMListenerManager { public class CIMListenerManager {
private static final List<CIMEventListener> cimListeners = new CopyOnWriteArrayList<>(); private static final List<CIMEventListener> cimListeners = new LinkedList<>();
private static final ReceiveComparator comparator = new ReceiveComparator(); private static final ReceiveComparator comparator = new ReceiveComparator();
private CIMListenerManager() { private CIMListenerManager() {
@ -47,7 +47,7 @@ public class CIMListenerManager {
if (!cimListeners.contains(listener)) { if (!cimListeners.contains(listener)) {
cimListeners.add(listener); cimListeners.add(listener);
cimListeners.sort(comparator); Collections.sort(cimListeners,comparator);
} }
} }
@ -56,32 +56,32 @@ public class CIMListenerManager {
} }
public static void notifyOnNetworkChanged(NetworkInfo info) { public static void notifyOnNetworkChanged(NetworkInfo info) {
for (CIMEventListener cimListener : cimListeners) { for (CIMEventListener cimListener : getListeners()) {
cimListener.onNetworkChanged(info); cimListener.onNetworkChanged(info);
} }
} }
public static void notifyOnConnectFinished(boolean hasAutoBind) { public static void notifyOnConnectFinished(boolean hasAutoBind) {
for (CIMEventListener cimListener : cimListeners) { for (CIMEventListener cimListener : getListeners()) {
cimListener.onConnectFinished(hasAutoBind); cimListener.onConnectFinished(hasAutoBind);
} }
} }
public static void notifyOnMessageReceived(Message message) { public static void notifyOnMessageReceived(Message message) {
for (CIMEventListener cimListener : cimListeners) { for (CIMEventListener cimListener : getListeners()) {
cimListener.onMessageReceived(message); cimListener.onMessageReceived(message);
} }
} }
public static void notifyOnConnectionClosed() { public static void notifyOnConnectionClosed() {
for (CIMEventListener cimListener : cimListeners) { for (CIMEventListener cimListener : getListeners()) {
cimListener.onConnectionClosed(); cimListener.onConnectionClosed();
} }
} }
public static void notifyOnConnectFailed() { public static void notifyOnConnectFailed() {
for (CIMEventListener cimListener : cimListeners) { for (CIMEventListener cimListener : getListeners()) {
cimListener.onConnectFailed(); cimListener.onConnectFailed();
} }
@ -89,14 +89,14 @@ public class CIMListenerManager {
public static void notifyOnReplyReceived(ReplyBody body) { public static void notifyOnReplyReceived(ReplyBody body) {
for (CIMEventListener cimListener : cimListeners) { for (CIMEventListener cimListener : getListeners()) {
cimListener.onReplyReceived(body); cimListener.onReplyReceived(body);
} }
} }
public static void notifyOnSendFinished(SentBody body) { public static void notifyOnSendFinished(SentBody body) {
for (CIMEventListener cimListener : cimListeners) { for (CIMEventListener cimListener : getListeners()) {
cimListener.onSendFinished(body); cimListener.onSendFinished(body);
} }
} }
@ -105,10 +105,8 @@ public class CIMListenerManager {
cimListeners.clear(); cimListeners.clear();
} }
public static void logListenersName() { public static List<CIMEventListener> getListeners() {
for (CIMEventListener cimListener : cimListeners) { return new LinkedList<>(cimListeners);
Log.i(CIMEventListener.class.getSimpleName(), "#######" + cimListener.getClass().getName() + "#######");
}
} }
/** /**

View File

@ -271,13 +271,11 @@ public class CIMPushService extends Service {
channel.enableVibration(false); channel.enableVibration(false);
channel.setSound(null, null); channel.setSound(null, null);
notificationManager.createNotificationChannel(channel); notificationManager.createNotificationChannel(channel);
Notification notification = makeNotification(TRANSIENT_NTC_CHANNEL_ID,0,CIMPushService.class.getSimpleName(),null);
startForeground(NOTIFICATION_ID, notification);
} }
Notification notification = makeNotification(TRANSIENT_NTC_CHANNEL_ID,0,CIMPushService.class.getSimpleName(),null);
startForeground(NOTIFICATION_ID, notification);
} }

View File

@ -1,23 +1,21 @@
plugins { apply plugin: 'com.android.application'
id 'com.android.application'
}
android { android {
compileSdkVersion 29 compileSdkVersion 33
buildToolsVersion "29.0.3" buildToolsVersion '33.0.0'
defaultConfig { defaultConfig {
applicationId "com.farsunset.cim" applicationId "com.farsunset.cim"
minSdkVersion 23 minSdkVersion 23
targetSdkVersion 29 targetSdkVersion 33
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
/* /*
CIM服务器 CIM服务器
*/ */
buildConfigField("String", "CIM_API_URL", '"http://192.168.31.245:8080"') buildConfigField("String", "CIM_API_URL", '"http://192.168.31.175:8080"')
buildConfigField("String", "CIM_SERVER_HOST", '"192.168.31.245"') buildConfigField("String", "CIM_SERVER_HOST", '"192.168.31.175"')
buildConfigField("Integer", "CIM_SERVER_PORT", '23456') buildConfigField("Integer", "CIM_SERVER_PORT", '23456')
} }
@ -28,17 +26,17 @@ android {
} }
} }
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility = '1.8'
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility = '1.8'
} }
} }
dependencies { dependencies {
implementation "com.farsunset:cim-android-sdk:4.2.8" implementation "com.farsunset:cim-android-sdk:4.2.10"
implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.appcompat:appcompat:1.6.0'
implementation 'com.google.android.material:material:1.2.1' implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.annotation:annotation:1.1.0' implementation 'androidx.annotation:annotation:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.protobuf:protobuf-lite:3.0.1' implementation 'com.google.protobuf:protobuf-lite:3.0.1'
implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0'

View File

@ -17,7 +17,7 @@
android:networkSecurityConfig="@xml/network_security_config" android:networkSecurityConfig="@xml/network_security_config"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity <activity
android:name="com.farsunset.cim.activity.LoginActivity"> android:name="com.farsunset.cim.activity.LoginActivity" android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
@ -32,7 +32,6 @@
<!-- ****************************************CIM推送配置 begin*************************************** --> <!-- ****************************************CIM推送配置 begin*************************************** -->
<service <service
android:name="com.farsunset.cim.sdk.android.CIMPushService" android:name="com.farsunset.cim.sdk.android.CIMPushService"
android:process=":cimpush"
android:exported="false" android:exported="false"
/> />
@ -44,7 +43,7 @@
<!--消息接受广播注册--> <!--消息接受广播注册-->
<receiver android:name="com.farsunset.cim.reveiver.CIMPushMessageReceiver"> <receiver android:name="com.farsunset.cim.reveiver.CIMPushMessageReceiver" android:exported="false">
<intent-filter android:priority="0x7fffffff"> <intent-filter android:priority="0x7fffffff">
<!-- 网络变事件action targetVersion 24之前 --> <!-- 网络变事件action targetVersion 24之前 -->
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />

View File

@ -1,24 +1,27 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
repositories { repositories {
google() google()
jcenter() jcenter()
mavenCentral()
maven{ url'https://maven.aliyun.com/repository/central' }
maven{ url'https://maven.aliyun.com/repository/google' }
maven{ url'https://maven.aliyun.com/repository/public' }
maven{ url'https://maven.aliyun.com/repository/gradle-plugin' }
maven { url "https://jitpack.io" }
} }
dependencies { dependencies {
classpath "com.android.tools.build:gradle:4.1.2" classpath 'com.android.tools.build:gradle:7.4.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
} }
} }
allprojects { allprojects {
repositories { repositories {
google() google()
jcenter() jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
maven{ url'https://maven.aliyun.com/repository/central' }
maven{ url'https://maven.aliyun.com/repository/google' }
maven{ url'https://maven.aliyun.com/repository/public' }
maven{ url'https://maven.aliyun.com/repository/gradle-plugin' }
} }
} }
task clean(type: Delete) {
delete rootProject.buildDir
}

View File

@ -16,4 +16,5 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# https://developer.android.com/topic/libraries/support-library/androidx-rn # https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX # Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true android.enableJetifier=true
android.injected.testOnly=false

View File

@ -1,6 +1,6 @@
#Mon Apr 26 20:11:13 CST 2021 #Wed Feb 15 10:18:48 CST 2023
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip zipStoreBase=GRADLE_USER_HOME