Skip to content

Commit e6f6d2a

Browse files
committed
更新至2.3.9,适配 Android 12
1 parent 48f775d commit e6f6d2a

38 files changed

+132
-119
lines changed

.idea/compiler.xml

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ allprojects {
8282
```groovy
8383
apply plugin: 'com.huawei.agconnect'
8484
android {
85-
compileSdkVersion 29
85+
compileSdkVersion 31
8686
defaultConfig {
8787
...
8888
manifestPlaceholders["VIVO_APP_ID"] = "<VIVO_APP_ID>"
@@ -96,7 +96,7 @@ android {
9696
}
9797
}
9898
dependencies {
99-
def mixpush_version = '2.3.4'
99+
def mixpush_version = '2.3.9'
100100
implementation "io.github.mixpush:mixpush-core:$mixpush_version" // 核心包
101101
implementation "io.github.mixpush:mixpush-mi:$mixpush_version" // 小米推送
102102
implementation "io.github.mixpush:mixpush-meizu:$mixpush_version" // 魅族推送
@@ -225,7 +225,7 @@ MixPushClient.getInstance().getRegisterId(this, new GetRegisterIdCallback() {
225225
<dependency>
226226
<groupId>io.github.mixpush</groupId>
227227
<artifactId>mixpush-sender</artifactId>
228-
<version>2.3.4</version>
228+
<version>2.3.9</version>
229229
</dependency>
230230
</dependencies>
231231
```

build.gradle

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.5.31'
4+
ext.kotlin_version = '1.5.30'
55
repositories {
66
google()
77
mavenCentral()
@@ -21,7 +21,6 @@ allprojects {
2121
repositories {
2222
google()
2323
mavenCentral()
24-
jcenter()
2524
maven {
2625
allowInsecureProtocol = true
2726
url 'http://developer.huawei.com/repo/'

example/build.gradle

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
3-
apply plugin: 'kotlin-android-extensions'
43
apply plugin: 'com.huawei.agconnect'
54

65
android {
7-
compileSdkVersion 29
6+
compileSdkVersion 31
87
defaultConfig {
98
applicationId EXAMPLE_APPLICATION_ID
109
minSdkVersion 14
11-
targetSdkVersion 29
10+
targetSdkVersion 31
1211
versionCode 10
1312
versionName "1.1.0"
1413
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
@@ -47,12 +46,12 @@ android {
4746

4847
dependencies {
4948
implementation fileTree(dir: 'libs', include: ['*.jar'])
50-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
51-
implementation 'androidx.appcompat:appcompat:1.1.0'
52-
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
53-
testImplementation 'junit:junit:4.12'
54-
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
55-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
49+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.30"
50+
implementation 'androidx.appcompat:appcompat:1.4.2'
51+
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
52+
testImplementation 'junit:junit:4.13.2'
53+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
54+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
5655
implementation 'com.alibaba:fastjson:1.1.45.android'
5756

5857
implementation project(path: ':mixpush-core')

example/src/main/AndroidManifest.xml

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
android:supportsRtl="true"
1515
android:theme="@style/AppTheme"
1616
android:usesCleartextTraffic="true">
17-
<activity android:name="com.mixpush.example.UserActivity" />
18-
<activity android:name="com.mixpush.example.WebViewActivity" />
19-
<activity android:name="com.mixpush.example.MainActivity" android:launchMode="singleTop">
17+
<activity android:name="com.mixpush.example.UserActivity" android:exported="false"/>
18+
<activity android:name="com.mixpush.example.WebViewActivity" android:exported="false"/>
19+
<activity android:name="com.mixpush.example.MainActivity" android:launchMode="singleTop"
20+
android:exported="true">
2021

2122
<intent-filter>
2223
<action android:name="android.intent.action.MAIN" />

example/src/main/java/com/mixpush/example/MainActivity.kt

+7-6
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import android.content.Context
66
import android.os.Build
77
import androidx.appcompat.app.AppCompatActivity
88
import android.os.Bundle
9+
import android.view.View
10+
import android.widget.TextView
911
import android.widget.Toast
1012
import com.mixpush.core.GetRegisterIdCallback
1113
import com.mixpush.core.MixPushPlatform
1214
import com.mixpush.core.MixPushClient
13-
import kotlinx.android.synthetic.main.activity_main.*
1415
import java.util.*
1516

1617

@@ -24,14 +25,14 @@ class MainActivity : AppCompatActivity() {
2425
if (!NotificationManagerUtils.isPermissionOpen(this)) {
2526
NotificationManagerUtils.openPermissionSetting(this)
2627
}
27-
copy_reg_id.setOnClickListener {
28+
findViewById<View>(R.id.copy_reg_id).setOnClickListener {
2829
if (notificationMixPushPlatform != null) {
2930
copy(notificationMixPushPlatform!!.regId!!)
3031
} else {
3132
Toast.makeText(this, "注册失败", Toast.LENGTH_SHORT).show()
3233
}
3334
}
34-
copy_pass_through_reg_id.setOnClickListener {
35+
findViewById<View>(R.id.copy_pass_through_reg_id).setOnClickListener {
3536
if (passThroughMixPushPlatform != null) {
3637
copy(passThroughMixPushPlatform!!.regId!!)
3738
} else {
@@ -44,7 +45,7 @@ class MainActivity : AppCompatActivity() {
4445
updateRegId()
4546
}
4647
})
47-
log.text = Date().toString()
48+
findViewById<TextView>(R.id.log).text = Date().toString()
4849

4950
updateRegId()
5051
onRequirePermissions()
@@ -75,10 +76,10 @@ class MainActivity : AppCompatActivity() {
7576
fun updateRegId() {
7677
runOnUiThread {
7778
if (notificationMixPushPlatform != null) {
78-
text_reg_id.text = notificationMixPushPlatform.toString()
79+
findViewById<TextView>(R.id.text_reg_id).text = notificationMixPushPlatform.toString()
7980
}
8081
if (passThroughMixPushPlatform != null) {
81-
text_pass_through_reg_id.text = passThroughMixPushPlatform.toString()
82+
findViewById<TextView>(R.id.text_pass_through_reg_id).text = passThroughMixPushPlatform.toString()
8283
}
8384
}
8485
}

example/src/main/java/com/mixpush/example/UserActivity.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ package com.mixpush.example
22

33
import androidx.appcompat.app.AppCompatActivity
44
import android.os.Bundle
5-
import kotlinx.android.synthetic.main.activity_user.*
5+
import android.widget.TextView
66

77
class UserActivity : AppCompatActivity() {
88
override fun onCreate(savedInstanceState: Bundle?) {
99
super.onCreate(savedInstanceState)
1010
setContentView(R.layout.activity_user)
11-
text_user_id.text = intent.getStringExtra("userId")
11+
findViewById<TextView>(R.id.text_user_id).text = intent.getStringExtra("userId")
1212
}
1313
}
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
package com.mixpush.example
22

3-
import androidx.appcompat.app.AppCompatActivity
43
import android.os.Bundle
54
import android.webkit.WebChromeClient
5+
import android.webkit.WebView
66
import android.webkit.WebViewClient
7-
import kotlinx.android.synthetic.main.activity_web_view.*
7+
import androidx.appcompat.app.AppCompatActivity
88

99
class WebViewActivity : AppCompatActivity() {
10+
private var web_view: WebView? = null
11+
1012
override fun onCreate(savedInstanceState: Bundle?) {
1113
super.onCreate(savedInstanceState)
1214
setContentView(R.layout.activity_web_view)
13-
web_view.loadUrl(intent.getStringExtra("url"))
14-
web_view.settings.javaScriptEnabled = true
15-
web_view.webViewClient = WebViewClient()
16-
web_view.webChromeClient = WebChromeClient()
15+
web_view = findViewById<WebView>(R.id.web_view)
16+
web_view?.loadUrl(intent.getStringExtra("url")!!)
17+
web_view?.settings?.javaScriptEnabled = true
18+
web_view?.webViewClient = WebViewClient()
19+
web_view?.webChromeClient = WebChromeClient()
1720
}
1821

1922
override fun onDestroy() {
20-
web_view.destroy();
23+
web_view?.destroy();
2124
super.onDestroy()
2225
}
2326
}

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip

huaweipush-server-sdk/src/main/java/com/huawei/push/android/AndroidNotification.java

+19-2
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ public class AndroidNotification {
146146
@JSONField(name = "buttons")
147147
private List<Button> buttons;
148148

149+
@JSONField(name = "profile_id")
150+
private String profileId;
151+
149152
private AndroidNotification(Builder builder) {
150153
this.title = builder.title;
151154
this.body = builder.body;
@@ -221,6 +224,8 @@ private AndroidNotification(Builder builder) {
221224
} else {
222225
this.buttons = null;
223226
}
227+
228+
this.profileId = builder.profileId;
224229
}
225230

226231
/**
@@ -258,9 +263,8 @@ public void check(Notification notification) {
258263
if (this.style != null) {
259264
boolean isTrue = this.style == 0 ||
260265
this.style == 1 ||
261-
this.style == 2 ||
262266
this.style == 3;
263-
ValidatorUtils.checkArgument(isTrue, "style should be one of 0:default, 1: big text, 2: big picture");
267+
ValidatorUtils.checkArgument(isTrue, "style should be one of 0:default, 1: big text, 3: Inbox");
264268

265269
if (this.style == 1) {
266270
ValidatorUtils.checkArgument(StringUtils.isNotEmpty(this.bigTitle) && StringUtils.isNotEmpty(this.bigBody), "title and body are required when style = 1");
@@ -325,6 +329,10 @@ public void check(Notification notification) {
325329
button.check();
326330
}
327331
}
332+
333+
if (this.profileId != null) {
334+
ValidatorUtils.checkArgument(this.profileId.length() > 64, "profileId length cannot exceed 64 characters");
335+
}
328336
}
329337

330338
/**
@@ -474,6 +482,8 @@ public List<Button> getButtons() {
474482
return buttons;
475483
}
476484

485+
public String getProfileId() { return profileId; }
486+
477487
/**
478488
* builder
479489
*
@@ -524,6 +534,8 @@ public static class Builder {
524534
private List<String> inboxContent = new ArrayList<>();
525535
private List<Button> buttons = new ArrayList<Button>();
526536

537+
private String profileId;
538+
527539
private Builder() {
528540
}
529541

@@ -731,5 +743,10 @@ public Builder addAllButtons(List<Button> buttons) {
731743
public AndroidNotification build() {
732744
return new AndroidNotification(this);
733745
}
746+
747+
public Builder setProfileId(String profileId) {
748+
this.profileId = profileId;
749+
return this;
750+
}
734751
}
735752
}

huaweipush-server-sdk/src/main/java/com/huawei/push/android/BadgeNotification.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public Integer getSetNum() {
4141
}
4242

4343
public BadgeNotification(Integer addNum, String badgeClass) {
44-
this.addNum = builder().addNum;
44+
this.addNum = addNum;
4545
this.badgeClass = badgeClass;
4646
}
4747

huaweipush-server-sdk/src/main/java/com/huawei/push/apns/Alert.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,12 @@ public Builder setLocKey(String locKey) {
164164
return this;
165165
}
166166

167-
public Builder AddAllLocArgs(List<String> locArgs) {
167+
public Builder addAllLocArgs(List<String> locArgs) {
168168
this.locArgs.addAll(locArgs);
169169
return this;
170170
}
171171

172-
public Builder AddLocArg(String locArg) {
172+
public Builder addLocArg(String locArg) {
173173
this.locArgs.add(locArg);
174174
return this;
175175
}

huaweipush-server-sdk/src/main/java/com/huawei/push/apns/ApnsHmsOptions.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
public class ApnsHmsOptions {
2222
private static final int TEST_USER = 1;
23-
private static final int FORMAL_USER = 1;
24-
private static final int VOIP_USER = 1;
23+
private static final int FORMAL_USER = 2;
24+
private static final int VOIP_USER = 3;
2525

2626
@JSONField(name = "target_user_type")
2727
private Integer targetUserType;

huaweipush-server-sdk/src/main/java/com/huawei/push/message/AndroidConfig.java

+12
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public class AndroidConfig {
4949
@JSONField(name = "notification")
5050
private AndroidNotification notification;
5151

52+
@JSONField(name = "receipt_id")
53+
private String receiptId;
54+
5255
public AndroidConfig(Builder builder) {
5356
this.collapseKey = builder.collapseKey;
5457
this.urgency = builder.urgency;
@@ -64,6 +67,7 @@ public AndroidConfig(Builder builder) {
6467
this.fastAppTargetType = builder.fastAppTargetType;
6568
this.data = builder.data;
6669
this.notification = builder.notification;
70+
this.receiptId = builder.receiptId;
6771
}
6872

6973
/**
@@ -130,6 +134,8 @@ public String getData() {
130134
return data;
131135
}
132136

137+
public String getReceiptId() { return receiptId; }
138+
133139
/**
134140
* builder
135141
*/
@@ -147,6 +153,7 @@ public static class Builder {
147153
private String data;
148154

149155
private AndroidNotification notification;
156+
private String receiptId;
150157

151158
private Builder() {
152159
}
@@ -197,5 +204,10 @@ public Builder setNotification(AndroidNotification notification) {
197204
public AndroidConfig build() {
198205
return new AndroidConfig(this);
199206
}
207+
208+
public Builder setReceiptId(String receiptId) {
209+
this.receiptId = receiptId;
210+
return this;
211+
}
200212
}
201213
}

huaweipush-server-sdk/src/main/java/com/huawei/push/message/Message.java

-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ public void check() {
8484

8585
ValidatorUtils.checkArgument(count == 1, "Exactly one of token, topic or condition must be specified");
8686

87-
boolean isEmptyData = StringUtils.isEmpty(data);
88-
8987
if (this.notification != null) {
9088
this.notification.check();
9189
}

0 commit comments

Comments
 (0)