Skip to content

Commit 195200c

Browse files
authored
Merge pull request #476 from mindbox-cloud/release/2.10.1
Release/2.10.1
2 parents 6d01667 + 5c49b26 commit 195200c

23 files changed

+419
-85
lines changed

LICENSE.md

Lines changed: 44 additions & 46 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ Reach out to us for further help and we'll be glad to assist.
5252

5353
## License
5454

55-
The library is available as open source under the terms of the [License](https://github.com/mindbox-cloud/android-sdk/blob/develop/LICENSE.md).
55+
The library is available as open source under the terms of the [License](https://github.com/mindbox-cloud/android-sdk/blob/master/LICENSE.md).
5656

57-
For a better understanding of this content, please familiarize yourself with the Mindbox [Android SDK](https://developers.mindbox.ru/docs/androidhuawei-native-sdk) documentation.
57+
For a better understanding of this content, please familiarize yourself with the Mindbox [Android SDK](https://developers.mindbox.ru/docs/androidhuawei-native-sdk) documentation.

dependencies.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ext {
1717
room_compiler: 'androidx.room:room-compiler:2.5.1',
1818
work_manager: 'androidx.work:work-runtime-ktx:2.7.1',
1919
androidx_lifecycle: 'androidx.lifecycle:lifecycle-process:2.3.1',
20-
hms_push: 'com.huawei.hms:push:6.5.0.300',
20+
hms_push: 'com.huawei.hms:push:6.11.0.300',
2121
hms_ads_identifier: 'com.huawei.hms:ads-identifier:3.4.39.302',
2222
koin: 'io.insert-koin:koin-android:3.2.2',
2323
koin_test: 'io.insert-koin:koin-test:3.2.2',

example/app/build.gradle

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,16 @@ dependencies {
5151
implementation 'com.google.firebase:firebase-messaging-ktx'
5252
implementation 'com.huawei.hms:push:6.11.0.300'
5353

54+
implementation 'com.google.code.gson:gson:2.11.0'
55+
56+
5457
//Mindbox
55-
implementation 'cloud.mindbox:mobile-sdk:2.10.0'
56-
implementation 'cloud.mindbox:mindbox-firebase'
57-
implementation 'cloud.mindbox:mindbox-huawei'
58+
implementation 'cloud.mindbox:mobile-sdk:2.10.1'
59+
implementation 'cloud.mindbox:mindbox-firebase:2.10.1'
60+
implementation 'cloud.mindbox:mindbox-huawei:2.10.1'
5861

5962
//Glade for custom loader
6063
implementation 'com.github.bumptech.glide:glide:4.15.1'
64+
implementation 'androidx.activity:activity-ktx:1.9.0'
6165
annotationProcessor 'com.github.bumptech.glide:compiler:4.15.1'
6266
}
Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
43

54
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
65

6+
<queries>
7+
<intent>
8+
<action android:name="com.huawei.hms.core.aidlservice" />
9+
</intent>
10+
</queries>
11+
712
<application
813
android:name=".ExampleApp"
914
android:allowBackup="true"
1015
android:icon="@mipmap/ic_launcher"
1116
android:networkSecurityConfig="@xml/network_security_config"
12-
android:label="@string/app_name"
1317
android:roundIcon="@mipmap/ic_launcher_round"
1418
android:theme="@style/Theme.MindboxAndroidSdkExample">
15-
<meta-data
16-
android:name="com.huawei.hms.client.channel.androidMarket"
17-
android:value="false" />
19+
20+
<activity
21+
android:name=".NotificationHistoryActivity"
22+
android:exported="false" />
23+
1824
<service
1925
android:name=".MindboxHuaweiMessagingService"
2026
android:enabled="true"
@@ -23,7 +29,6 @@
2329
<action android:name="com.huawei.push.action.MESSAGING_EVENT" />
2430
</intent-filter>
2531
</service>
26-
2732
<service
2833
android:name=".MindboxFirebaseMessagingService"
2934
android:enabled="true"
@@ -36,8 +41,7 @@
3641
<activity
3742
android:name=".ActivityTransitionByPush"
3843
android:exported="false"
39-
android:launchMode="singleTask"/>
40-
44+
android:launchMode="singleTask" />
4145
<activity
4246
android:name=".MainActivity"
4347
android:exported="true"
@@ -50,9 +54,4 @@
5054
</activity>
5155
</application>
5256

53-
<queries>
54-
<intent>
55-
<action android:name="com.huawei.hms.core.aidlservice" />
56-
</intent>
57-
</queries>
5857
</manifest>

example/app/src/main/java/com/mindbox/example/ActivityTransitionByPush.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ActivityTransitionByPush : AppCompatActivity() {
2424
}
2525
}
2626

27-
override fun onNewIntent(intent: Intent?) {
27+
override fun onNewIntent(intent: Intent) {
2828
super.onNewIntent(intent)
2929

3030
//Get data from push after click on push or button in push

example/app/src/main/java/com/mindbox/example/MainActivity.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,13 @@ class MainActivity : AppCompatActivity() {
5050
val intent = Intent(this, ActivityTransitionByPush::class.java)
5151
this.startActivity(intent)
5252
}
53+
54+
binding.btnOpenPushList.setOnClickListener {
55+
startActivity(Intent(this, NotificationHistoryActivity::class.java))
56+
}
5357
}
5458

55-
override fun onNewIntent(intent: Intent?) {
59+
override fun onNewIntent(intent: Intent) {
5660
super.onNewIntent(intent)
5761
processMindboxIntent(intent = intent, context = this)?.let { (url, payload) ->
5862
binding.tvPushUrlResult.text = url
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ class MindboxFirebaseMessagingService : FirebaseMessagingService() {
4141
// Method for getting info from Mindbox push
4242
val mindboxMessage = MindboxFirebase.convertToMindboxRemoteMessage(remoteMessage = message)
4343
Log.d(Utils.TAG, mindboxMessage.toString())
44-
44+
// If you want to save the notification you can call your save function from here.
45+
mindboxMessage?.let {
46+
NotificationStorage.addNotification(it)
47+
}
4548
if (!messageWasHandled) {
4649
// If the push notification was not from Mindbox or it contains incorrect data, you can write a fallback to process it.
4750
Log.d(Utils.TAG, "This push not from Mindbox")

example/app/src/main/java/com/mindbox/example/MindboxHuaweiMessagingService.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ class MindboxHuaweiMessagingService : HmsMessageService() {
5151
// Method for getting info from Mindbox push
5252
val mindboxMessage = MindboxHuawei.convertToMindboxRemoteMessage(remoteMessage = message)
5353
Log.d(Utils.TAG, mindboxMessage.toString())
54-
54+
// If you want to save the notification you can call your save function from here.
55+
mindboxMessage?.let {
56+
NotificationStorage.addNotification(it)
57+
}
5558
if (!messageWasHandled) {
5659
// If the push notification was not from Mindbox or it contains incorrect data, you can write a fallback to process it.
5760
Log.d(Utils.TAG, "This push not from Mindbox")
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.mindbox.example
2+
3+
import android.view.LayoutInflater
4+
import android.view.ViewGroup
5+
import androidx.recyclerview.widget.AsyncListDiffer
6+
import androidx.recyclerview.widget.DiffUtil
7+
import androidx.recyclerview.widget.RecyclerView
8+
import cloud.mindbox.mobile_sdk.pushes.MindboxRemoteMessage
9+
import com.bumptech.glide.Glide
10+
import com.mindbox.example.databinding.ItemNotificationBinding
11+
12+
class NotificationAdapter(private val onItemClick:(MindboxRemoteMessage) -> Unit): RecyclerView.Adapter<NotificationAdapter.NotificationViewHolder>() {
13+
14+
private val differ = AsyncListDiffer(this, MindboxRemoteMessageItemCallback())
15+
16+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NotificationViewHolder {
17+
return NotificationViewHolder(
18+
ItemNotificationBinding.inflate(
19+
LayoutInflater.from(parent.context),
20+
parent,
21+
false
22+
)
23+
)
24+
}
25+
26+
override fun getItemCount(): Int {
27+
return differ.currentList.size
28+
}
29+
30+
override fun onBindViewHolder(holder: NotificationViewHolder, position: Int) {
31+
holder.bind(differ.currentList[position])
32+
}
33+
34+
fun updateNotifications(newList: List<MindboxRemoteMessage>) {
35+
differ.submitList(newList)
36+
}
37+
inner class NotificationViewHolder(private val binding: ItemNotificationBinding) :
38+
RecyclerView.ViewHolder(binding.root) {
39+
40+
fun bind(item: MindboxRemoteMessage) {
41+
binding.root.setOnClickListener {
42+
onItemClick(item)
43+
}
44+
binding.tvTitle.text = item.title
45+
binding.tvDescription.text = item.description
46+
binding.tvPushLink.text = item.pushLink
47+
binding.tvUniqueKey.text = item.uniqueKey
48+
Glide.with(itemView).load(item.imageUrl).into(binding.ivImage)
49+
}
50+
}
51+
52+
class MindboxRemoteMessageItemCallback : DiffUtil.ItemCallback<MindboxRemoteMessage>() {
53+
override fun areItemsTheSame(
54+
oldItem: MindboxRemoteMessage,
55+
newItem: MindboxRemoteMessage
56+
): Boolean {
57+
return oldItem.uniqueKey == newItem.uniqueKey
58+
}
59+
60+
override fun areContentsTheSame(
61+
oldItem: MindboxRemoteMessage,
62+
newItem: MindboxRemoteMessage
63+
): Boolean {
64+
return oldItem == newItem
65+
}
66+
}
67+
68+
}

0 commit comments

Comments
 (0)