6363 */
6464class LeanplumNotificationHelper {
6565
66- private static final int BIGPICTURE_TEXT_TOP_PADDING = -14 ;
67- private static final int BIGPICTURE_TEXT_SIZE = 14 ;
6866 private static final String LEANPLUM_DEFAULT_PUSH_ICON = "leanplum_default_push_icon" ;
69- private static final int MAX_ONE_LINE_TEXT_LENGTH = 37 ;
7067
7168 /**
7269 * If notification channels are supported this method will try to create
@@ -303,8 +300,7 @@ static NotificationCompat.Builder getNotificationCompatBuilder(Context context,
303300 }
304301
305302 /**
306- * Calls setStyle for notificationBuilder and it tries modify notification layout to support two
307- * lines.
303+ * Calls setStyle for notificationBuilder.
308304 *
309305 * @param notificationBuilder current Notification.Builder.
310306 * @param bigPictureStyle current Notification.BigPictureStyle.
@@ -314,30 +310,12 @@ static void setModifiedBigPictureStyle(Notification.Builder notificationBuilder,
314310 if (Build .VERSION .SDK_INT < 16 || notificationBuilder == null || bigPictureStyle == null ) {
315311 return ;
316312 }
317- try {
318- notificationBuilder .setStyle (bigPictureStyle );
319-
320- if (Build .VERSION .SDK_INT >= 24 ) {
321- // By default we cannot reach getStandardView method on API>=24. If we call
322- // createBigContentView, Android will call getStandardView method and we can get
323- // modified RemoteView.
324- try {
325- RemoteViews remoteView = notificationBuilder .createBigContentView ();
326- if (remoteView != null ) {
327- // We need to set received RemoteView as a custom big content view.
328- notificationBuilder .setCustomBigContentView (remoteView );
329- }
330- } catch (Throwable t ) {
331- Log .e ("Cannot modify push notification layout." , t );
332- }
333- }
334- } catch (Throwable t ) {
335- Log .e ("Cannot set BigPicture style for push notification." , t );
336- }
313+
314+ notificationBuilder .setStyle (bigPictureStyle );
337315 }
338316
339317 /**
340- * Gets Notification.BigPictureStyle with 2 lines text .
318+ * Gets Notification.BigPictureStyle with 1 line title and 1 line summary .
341319 *
342320 * @param message Push notification Bundle.
343321 * @param bigPicture Bitmap for BigPictureStyle notification.
@@ -352,34 +330,10 @@ static Notification.BigPictureStyle getBigPictureStyle(Bundle message, Bitmap bi
352330 return null ;
353331 }
354332
355- Notification .BigPictureStyle bigPictureStyle = new Notification .BigPictureStyle () {
356- @ Override
357- protected RemoteViews getStandardView (int layoutId ) {
358- RemoteViews remoteViews = super .getStandardView (layoutId );
359- if (messageText != null && messageText .length () >= MAX_ONE_LINE_TEXT_LENGTH ) {
360- // Modifications of standard push RemoteView.
361- try {
362- int id = Resources .getSystem ().getIdentifier ("text" , "id" , "android" );
363- remoteViews .setBoolean (id , "setSingleLine" , false );
364- remoteViews .setInt (id , "setLines" , 2 );
365- if (Build .VERSION .SDK_INT < 23 ) {
366- // Make text smaller.
367- remoteViews .setViewPadding (id , 0 , BIGPICTURE_TEXT_TOP_PADDING , 0 , 0 );
368- remoteViews .setTextViewTextSize (id , TypedValue .COMPLEX_UNIT_SP , BIGPICTURE_TEXT_SIZE );
369- }
370- } catch (Throwable throwable ) {
371- Log .e ("Cannot modify push notification layout." );
372- }
373- }
374- return remoteViews ;
375- }
376- };
377-
378- bigPictureStyle .bigPicture (bigPicture )
333+ return new Notification .BigPictureStyle ()
334+ .bigPicture (bigPicture )
379335 .setBigContentTitle (title )
380- .setSummaryText (message .getString (Constants .Keys .PUSH_MESSAGE_TEXT ));
381-
382- return bigPictureStyle ;
336+ .setSummaryText (messageText );
383337 }
384338
385339 /**
0 commit comments