@amrshbib/react-native-pushbib 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -11,6 +11,8 @@ import android.graphics.BitmapFactory
|
|
|
11
11
|
import android.graphics.Color
|
|
12
12
|
import android.media.RingtoneManager
|
|
13
13
|
import android.os.Build
|
|
14
|
+
import android.view.View
|
|
15
|
+
import android.widget.RemoteViews
|
|
14
16
|
import androidx.core.app.NotificationCompat
|
|
15
17
|
import androidx.core.app.NotificationManagerCompat
|
|
16
18
|
import org.json.JSONObject
|
|
@@ -73,9 +75,13 @@ object NotificationRenderer {
|
|
|
73
75
|
|
|
74
76
|
fetchBitmap(p.largeIcon)?.let { builder.setLargeIcon(it) }
|
|
75
77
|
fetchBitmap(p.imageUrl)?.let { image ->
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
// BigPictureStyle cuts the body to two lines, so the expanded view is our own:
|
|
79
|
+
// the whole body above the picture. Android 12+ wraps it in the app header by
|
|
80
|
+
// itself, full width, but drops the buttons there; a push with buttons, and older
|
|
81
|
+
// versions, get DecoratedCustomViewStyle instead.
|
|
82
|
+
val bare = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && p.buttons.isEmpty()
|
|
83
|
+
builder.setStyle(if (bare) null else NotificationCompat.DecoratedCustomViewStyle())
|
|
84
|
+
builder.setCustomBigContentView(bigPictureView(context, p, image))
|
|
79
85
|
if (p.largeIcon == null) builder.setLargeIcon(image)
|
|
80
86
|
}
|
|
81
87
|
|
|
@@ -91,6 +97,14 @@ object NotificationRenderer {
|
|
|
91
97
|
}
|
|
92
98
|
}
|
|
93
99
|
|
|
100
|
+
private fun bigPictureView(context: Context, p: NotificationPayload, image: Bitmap) =
|
|
101
|
+
RemoteViews(context.packageName, R.layout.pushbib_notification_big_picture).apply {
|
|
102
|
+
setTextViewText(R.id.pushbib_title, p.title ?: appName(context))
|
|
103
|
+
setTextViewText(R.id.pushbib_body, p.body)
|
|
104
|
+
setViewVisibility(R.id.pushbib_body, if (p.body == null) View.GONE else View.VISIBLE)
|
|
105
|
+
setImageViewBitmap(R.id.pushbib_image, image)
|
|
106
|
+
}
|
|
107
|
+
|
|
94
108
|
private fun clickIntent(context: Context, p: NotificationPayload, actionId: String?, requestCode: Int): PendingIntent {
|
|
95
109
|
val launch = context.packageManager.getLaunchIntentForPackage(context.packageName)
|
|
96
110
|
?: Intent().setPackage(context.packageName)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- The expanded view of a push with a picture: the whole body, then the picture
|
|
3
|
+
scaled into the height that is left, so neither is cut. -->
|
|
4
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
5
|
+
android:layout_width="match_parent"
|
|
6
|
+
android:layout_height="wrap_content"
|
|
7
|
+
android:orientation="vertical">
|
|
8
|
+
|
|
9
|
+
<TextView
|
|
10
|
+
android:id="@+id/pushbib_title"
|
|
11
|
+
style="@style/TextAppearance.Compat.Notification.Title"
|
|
12
|
+
android:layout_width="match_parent"
|
|
13
|
+
android:layout_height="wrap_content"
|
|
14
|
+
android:ellipsize="end"
|
|
15
|
+
android:maxLines="2" />
|
|
16
|
+
|
|
17
|
+
<TextView
|
|
18
|
+
android:id="@+id/pushbib_body"
|
|
19
|
+
style="@style/TextAppearance.Compat.Notification"
|
|
20
|
+
android:layout_width="match_parent"
|
|
21
|
+
android:layout_height="wrap_content" />
|
|
22
|
+
|
|
23
|
+
<ImageView
|
|
24
|
+
android:id="@+id/pushbib_image"
|
|
25
|
+
android:layout_width="match_parent"
|
|
26
|
+
android:layout_height="wrap_content"
|
|
27
|
+
android:layout_marginTop="8dp"
|
|
28
|
+
android:adjustViewBounds="true"
|
|
29
|
+
android:scaleType="fitCenter" />
|
|
30
|
+
</LinearLayout>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amrshbib/react-native-pushbib",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Self-hosted push notification SDK for React Native. Pushbib-style API (login, tags, click events) with zero Firebase setup in the app \u2014 no google-services.json, no GoogleService-Info.plist.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "index.d.ts",
|
package/src/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const SDK_VERSION = '0.4.
|
|
1
|
+
export const SDK_VERSION = '0.4.1';
|
|
2
2
|
export const SDK_NAME = `pushbib-rn/${SDK_VERSION}`;
|