44import com .facebook .react .bridge .ReadableMap ;
55import com .facebook .react .bridge .WritableArray ;
66import com .facebook .react .bridge .WritableMap ;
7+ import com .facebook .react .bridge .ReadableNativeArray ;
8+
79
810import java .util .ArrayList ;
911import java .util .Map ;
1012import java .util .Iterator ;
1113
12- import com .facebook .react .bridge .WritableNativeMap ;
1314import com .google .gson .Gson ;
1415
1516public class NotificationAttributes {
@@ -51,6 +52,8 @@ public class NotificationAttributes {
5152 public String bigStyleImageBase64 ;
5253 public String subText ;
5354 public Integer progress ;
55+ public Integer lifetime ;
56+ public Integer progressEnd ;
5457 public String color ;
5558 public Integer number ;
5659 public String category ;
@@ -61,6 +64,8 @@ public class NotificationAttributes {
6164 public String inboxStyleSummaryText ;
6265 public ArrayList <String > inboxStyleLines ;
6366
67+ public String group ;
68+
6469 public void loadFromMap (Map map ) {
6570 WritableMap writableMap = (WritableMap ) new WritableNativeMap ();
6671
@@ -83,6 +88,34 @@ public void loadFromMap(Map map) {
8388
8489 } else if (value .getClass ().equals (Boolean .class )) {
8590 writableMap .putBoolean (key , (Boolean ) value );
91+
92+
93+ } else if ("inboxStyle" .equals (key )) {
94+ inboxStyle = true ;
95+ WritableMap inboxStyleMap = new WritableNativeMap ();
96+
97+ Map inboxMap = (Map ) value ;
98+ if (inboxMap .containsKey ("bigContentTitle" )) {
99+ inboxStyleBigContentTitle = (String ) inboxMap .get ("bigContentTitle" );
100+ inboxStyleMap .putString ("bigContentTitle" , inboxStyleBigContentTitle );
101+ }
102+
103+ if (inboxMap .containsKey ("summaryText" )) {
104+ inboxStyleSummaryText = (String ) inboxMap .get ("summaryText" );
105+ inboxStyleMap .putString ("summaryText" , inboxStyleSummaryText );
106+ }
107+
108+ if (inboxMap .containsKey ("lines" )) {
109+ WritableArray inboxLines = new com .facebook .react .bridge .WritableNativeArray ();
110+ org .mozilla .javascript .NativeArray inboxStyleLines = (org .mozilla .javascript .NativeArray ) inboxMap .get ("lines" );
111+
112+ for (int i =0 ; i < inboxStyleLines .size (); i ++){
113+ inboxLines .pushString ((String ) inboxStyleLines .get (i ));
114+ }
115+ inboxStyleMap .putArray ("lines" , inboxLines );
116+ }
117+
118+ writableMap .putMap ("inboxStyle" , inboxStyleMap );
86119
87120 } else {
88121 Gson gson = new Gson ();
@@ -134,22 +167,28 @@ public void loadFromReadableMap(ReadableMap readableMap) {
134167 if (readableMap .hasKey ("bigStyleImageBase64" )) bigStyleImageBase64 = readableMap .getString ("bigStyleImageBase64" );
135168 if (readableMap .hasKey ("subText" )) subText = readableMap .getString ("subText" );
136169 if (readableMap .hasKey ("progress" )) progress = readableMap .getInt ("progress" );
170+ if (readableMap .hasKey ("progressEnd" )) progressEnd = readableMap .getInt ("progressEnd" );
171+ if (readableMap .hasKey ("lifetime" )) lifetime = readableMap .getInt ("lifetime" );
172+
137173 if (readableMap .hasKey ("color" )) color = readableMap .getString ("color" );
138174 if (readableMap .hasKey ("number" )) number = readableMap .getInt ("number" );
139175 if (readableMap .hasKey ("category" )) category = readableMap .getString ("category" );
140176 if (readableMap .hasKey ("localOnly" )) localOnly = readableMap .getBoolean ("localOnly" );
177+ if (readableMap .hasKey ("group" )) group = readableMap .getString ("group" );
141178
142179 if (readableMap .hasKey ("inboxStyle" )){
143180 inboxStyle = true ;
144- ReadableMap inboxStyle = readableMap .getMap ("inboxStyle" );
181+ ReadableMap inboxStyleMap = readableMap .getMap ("inboxStyle" );
145182
146- inboxStyleBigContentTitle = inboxStyle .getString ("bigContentTitle" );
147- inboxStyleSummaryText = inboxStyle .getString ("summaryText" );
183+ inboxStyleBigContentTitle = inboxStyleMap .getString ("bigContentTitle" );
184+ inboxStyleSummaryText = inboxStyleMap .getString ("summaryText" );
148185
149- ReadableArray inboxLines = inboxStyle .getArray ("lines" );
150- inboxStyleLines = new ArrayList <>();
151- for (int i =0 ; i < inboxLines .size (); i ++){
152- inboxStyleLines .add (inboxLines .getString (i ));
186+ ReadableArray inboxLines = inboxStyleMap .getArray ("lines" );
187+ if (inboxLines != null ) {
188+ inboxStyleLines = new ArrayList <>();
189+ for (int i =0 ; i < inboxLines .size (); i ++){
190+ inboxStyleLines .add (inboxLines .getString (i ));
191+ }
153192 }
154193 }else {
155194 inboxStyle = false ;
@@ -202,10 +241,14 @@ public ReadableMap asReadableMap() {
202241 if (number != null ) writableMap .putInt ("number" , number );
203242 if (category != null ) writableMap .putString ("category" , category );
204243 if (localOnly != null ) writableMap .putBoolean ("localOnly" , localOnly );
244+ if (group != null ) writableMap .putString ("group" , group );
245+
246+ if (progressEnd != null ) writableMap .putInt ("progressEnd" , progressEnd );
247+ if (lifetime != null ) writableMap .putInt ("lifetime" , lifetime );
205248
206249 if (inboxStyle ){
207250
208- WritableMap inboxStyle = new com . facebook . react . bridge . WritableNativeMap ();
251+ WritableMap inboxStyle = new WritableNativeMap ();
209252
210253 if (inboxStyleBigContentTitle != null ) inboxStyle .putString ("bigContentTitle" , inboxStyleBigContentTitle );
211254 if (inboxStyleSummaryText != null ) inboxStyle .putString ("summaryText" , inboxStyleSummaryText );
0 commit comments