Skip to content

Commit

Permalink
更新至2.3.9,适配 Android 12
Browse files Browse the repository at this point in the history
  • Loading branch information
taoweiji committed Jul 12, 2022
1 parent 48f775d commit e6f6d2a
Show file tree
Hide file tree
Showing 38 changed files with 132 additions and 119 deletions.
7 changes: 7 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ allprojects {
```groovy
apply plugin: 'com.huawei.agconnect'
android {
compileSdkVersion 29
compileSdkVersion 31
defaultConfig {
...
manifestPlaceholders["VIVO_APP_ID"] = "<VIVO_APP_ID>"
Expand All @@ -96,7 +96,7 @@ android {
}
}
dependencies {
def mixpush_version = '2.3.4'
def mixpush_version = '2.3.9'
implementation "io.github.mixpush:mixpush-core:$mixpush_version" // 核心包
implementation "io.github.mixpush:mixpush-mi:$mixpush_version" // 小米推送
implementation "io.github.mixpush:mixpush-meizu:$mixpush_version" // 魅族推送
Expand Down Expand Up @@ -225,7 +225,7 @@ MixPushClient.getInstance().getRegisterId(this, new GetRegisterIdCallback() {
<dependency>
<groupId>io.github.mixpush</groupId>
<artifactId>mixpush-sender</artifactId>
<version>2.3.4</version>
<version>2.3.9</version>
</dependency>
</dependencies>
```
Expand Down
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.5.31'
ext.kotlin_version = '1.5.30'
repositories {
google()
mavenCentral()
Expand All @@ -21,7 +21,6 @@ allprojects {
repositories {
google()
mavenCentral()
jcenter()
maven {
allowInsecureProtocol = true
url 'http://developer.huawei.com/repo/'
Expand Down
17 changes: 8 additions & 9 deletions example/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.huawei.agconnect'

android {
compileSdkVersion 29
compileSdkVersion 31
defaultConfig {
applicationId EXAMPLE_APPLICATION_ID
minSdkVersion 14
targetSdkVersion 29
targetSdkVersion 31
versionCode 10
versionName "1.1.0"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
Expand Down Expand Up @@ -47,12 +46,12 @@ android {

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

implementation project(path: ':mixpush-core')
Expand Down
7 changes: 4 additions & 3 deletions example/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity android:name="com.mixpush.example.UserActivity" />
<activity android:name="com.mixpush.example.WebViewActivity" />
<activity android:name="com.mixpush.example.MainActivity" android:launchMode="singleTop">
<activity android:name="com.mixpush.example.UserActivity" android:exported="false"/>
<activity android:name="com.mixpush.example.WebViewActivity" android:exported="false"/>
<activity android:name="com.mixpush.example.MainActivity" android:launchMode="singleTop"
android:exported="true">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
13 changes: 7 additions & 6 deletions example/src/main/java/com/mixpush/example/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import android.content.Context
import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.TextView
import android.widget.Toast
import com.mixpush.core.GetRegisterIdCallback
import com.mixpush.core.MixPushPlatform
import com.mixpush.core.MixPushClient
import kotlinx.android.synthetic.main.activity_main.*
import java.util.*


Expand All @@ -24,14 +25,14 @@ class MainActivity : AppCompatActivity() {
if (!NotificationManagerUtils.isPermissionOpen(this)) {
NotificationManagerUtils.openPermissionSetting(this)
}
copy_reg_id.setOnClickListener {
findViewById<View>(R.id.copy_reg_id).setOnClickListener {
if (notificationMixPushPlatform != null) {
copy(notificationMixPushPlatform!!.regId!!)
} else {
Toast.makeText(this, "注册失败", Toast.LENGTH_SHORT).show()
}
}
copy_pass_through_reg_id.setOnClickListener {
findViewById<View>(R.id.copy_pass_through_reg_id).setOnClickListener {
if (passThroughMixPushPlatform != null) {
copy(passThroughMixPushPlatform!!.regId!!)
} else {
Expand All @@ -44,7 +45,7 @@ class MainActivity : AppCompatActivity() {
updateRegId()
}
})
log.text = Date().toString()
findViewById<TextView>(R.id.log).text = Date().toString()

updateRegId()
onRequirePermissions()
Expand Down Expand Up @@ -75,10 +76,10 @@ class MainActivity : AppCompatActivity() {
fun updateRegId() {
runOnUiThread {
if (notificationMixPushPlatform != null) {
text_reg_id.text = notificationMixPushPlatform.toString()
findViewById<TextView>(R.id.text_reg_id).text = notificationMixPushPlatform.toString()
}
if (passThroughMixPushPlatform != null) {
text_pass_through_reg_id.text = passThroughMixPushPlatform.toString()
findViewById<TextView>(R.id.text_pass_through_reg_id).text = passThroughMixPushPlatform.toString()
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions example/src/main/java/com/mixpush/example/UserActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package com.mixpush.example

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_user.*
import android.widget.TextView

class UserActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_user)
text_user_id.text = intent.getStringExtra("userId")
findViewById<TextView>(R.id.text_user_id).text = intent.getStringExtra("userId")
}
}
17 changes: 10 additions & 7 deletions example/src/main/java/com/mixpush/example/WebViewActivity.kt
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
package com.mixpush.example

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.webkit.WebChromeClient
import android.webkit.WebView
import android.webkit.WebViewClient
import kotlinx.android.synthetic.main.activity_web_view.*
import androidx.appcompat.app.AppCompatActivity

class WebViewActivity : AppCompatActivity() {
private var web_view: WebView? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_web_view)
web_view.loadUrl(intent.getStringExtra("url"))
web_view.settings.javaScriptEnabled = true
web_view.webViewClient = WebViewClient()
web_view.webChromeClient = WebChromeClient()
web_view = findViewById<WebView>(R.id.web_view)
web_view?.loadUrl(intent.getStringExtra("url")!!)
web_view?.settings?.javaScriptEnabled = true
web_view?.webViewClient = WebViewClient()
web_view?.webChromeClient = WebChromeClient()
}

override fun onDestroy() {
web_view.destroy();
web_view?.destroy();
super.onDestroy()
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ public class AndroidNotification {
@JSONField(name = "buttons")
private List<Button> buttons;

@JSONField(name = "profile_id")
private String profileId;

private AndroidNotification(Builder builder) {
this.title = builder.title;
this.body = builder.body;
Expand Down Expand Up @@ -221,6 +224,8 @@ private AndroidNotification(Builder builder) {
} else {
this.buttons = null;
}

this.profileId = builder.profileId;
}

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

if (this.style == 1) {
ValidatorUtils.checkArgument(StringUtils.isNotEmpty(this.bigTitle) && StringUtils.isNotEmpty(this.bigBody), "title and body are required when style = 1");
Expand Down Expand Up @@ -325,6 +329,10 @@ public void check(Notification notification) {
button.check();
}
}

if (this.profileId != null) {
ValidatorUtils.checkArgument(this.profileId.length() > 64, "profileId length cannot exceed 64 characters");
}
}

/**
Expand Down Expand Up @@ -474,6 +482,8 @@ public List<Button> getButtons() {
return buttons;
}

public String getProfileId() { return profileId; }

/**
* builder
*
Expand Down Expand Up @@ -524,6 +534,8 @@ public static class Builder {
private List<String> inboxContent = new ArrayList<>();
private List<Button> buttons = new ArrayList<Button>();

private String profileId;

private Builder() {
}

Expand Down Expand Up @@ -731,5 +743,10 @@ public Builder addAllButtons(List<Button> buttons) {
public AndroidNotification build() {
return new AndroidNotification(this);
}

public Builder setProfileId(String profileId) {
this.profileId = profileId;
return this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public Integer getSetNum() {
}

public BadgeNotification(Integer addNum, String badgeClass) {
this.addNum = builder().addNum;
this.addNum = addNum;
this.badgeClass = badgeClass;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@ public Builder setLocKey(String locKey) {
return this;
}

public Builder AddAllLocArgs(List<String> locArgs) {
public Builder addAllLocArgs(List<String> locArgs) {
this.locArgs.addAll(locArgs);
return this;
}

public Builder AddLocArg(String locArg) {
public Builder addLocArg(String locArg) {
this.locArgs.add(locArg);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

public class ApnsHmsOptions {
private static final int TEST_USER = 1;
private static final int FORMAL_USER = 1;
private static final int VOIP_USER = 1;
private static final int FORMAL_USER = 2;
private static final int VOIP_USER = 3;

@JSONField(name = "target_user_type")
private Integer targetUserType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public class AndroidConfig {
@JSONField(name = "notification")
private AndroidNotification notification;

@JSONField(name = "receipt_id")
private String receiptId;

public AndroidConfig(Builder builder) {
this.collapseKey = builder.collapseKey;
this.urgency = builder.urgency;
Expand All @@ -64,6 +67,7 @@ public AndroidConfig(Builder builder) {
this.fastAppTargetType = builder.fastAppTargetType;
this.data = builder.data;
this.notification = builder.notification;
this.receiptId = builder.receiptId;
}

/**
Expand Down Expand Up @@ -130,6 +134,8 @@ public String getData() {
return data;
}

public String getReceiptId() { return receiptId; }

/**
* builder
*/
Expand All @@ -147,6 +153,7 @@ public static class Builder {
private String data;

private AndroidNotification notification;
private String receiptId;

private Builder() {
}
Expand Down Expand Up @@ -197,5 +204,10 @@ public Builder setNotification(AndroidNotification notification) {
public AndroidConfig build() {
return new AndroidConfig(this);
}

public Builder setReceiptId(String receiptId) {
this.receiptId = receiptId;
return this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ public void check() {

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

boolean isEmptyData = StringUtils.isEmpty(data);

if (this.notification != null) {
this.notification.check();
}
Expand Down
Loading

0 comments on commit e6f6d2a

Please sign in to comment.