@@ -71,7 +71,7 @@ interface InAppMessageViewListener {
71
71
private int marginPxSizeRight = dpToPx (24 );
72
72
private int marginPxSizeTop = dpToPx (24 );
73
73
private int marginPxSizeBottom = dpToPx (24 );
74
- private double dismissDuration ;
74
+ private double displayDuration ;
75
75
private boolean hasBackground ;
76
76
private boolean shouldDismissWhenActive = false ;
77
77
private boolean isDragging = false ;
@@ -88,9 +88,30 @@ interface InAppMessageViewListener {
88
88
this .displayLocation = content .getDisplayLocation ();
89
89
this .pageHeight = content .getPageHeight ();
90
90
this .pageWidth = ViewGroup .LayoutParams .MATCH_PARENT ;
91
- this .dismissDuration = content .getDismissDuration () == null ? 0 : dismissDuration ;
91
+ this .displayDuration = content .getDisplayDuration () == null ? 0 : content . getDisplayDuration () ;
92
92
this .hasBackground = !displayLocation .isBanner ();
93
93
this .disableDragDismiss = disableDragDismiss ;
94
+ setMarginsFromContent (content );
95
+ }
96
+
97
+ /**
98
+ * For now we only support default margin or no margin.
99
+ * Any non-zero value will be treated as default margin
100
+ * @param content in app message content and style
101
+ */
102
+ private void setMarginsFromContent (OSInAppMessageContent content ) {
103
+ if (content .getTopMargin () != null && content .getTopMargin () == 0 ) {
104
+ this .marginPxSizeTop = content .getTopMargin ();
105
+ }
106
+ if (content .getBottomMargin () != null && content .getBottomMargin () == 0 ) {
107
+ this .marginPxSizeBottom = content .getBottomMargin ();
108
+ }
109
+ if (content .getLeftMargin () != null && content .getLeftMargin () == 0 ) {
110
+ this .marginPxSizeLeft = content .getLeftMargin ();
111
+ }
112
+ if (content .getRightMargin () != null && content .getRightMargin () == 0 ) {
113
+ this .marginPxSizeRight = content .getRightMargin ();
114
+ }
94
115
}
95
116
96
117
void setWebView (WebView webView ) {
@@ -299,9 +320,7 @@ private void createPopupWindow(@NonNull RelativeLayout parentRelativeLayout) {
299
320
0
300
321
);
301
322
}
302
- /*
303
323
304
- */
305
324
private void setUpParentRelativeLayout (Context context ) {
306
325
parentRelativeLayout = new RelativeLayout (context );
307
326
parentRelativeLayout .setBackgroundDrawable (new ColorDrawable (Color .TRANSPARENT ));
@@ -394,7 +413,7 @@ private CardView createCardView(Context context) {
394
413
* Schedule dismiss behavior, if IAM has a dismiss after X number of seconds timer.
395
414
*/
396
415
private void startDismissTimerIfNeeded () {
397
- if (dismissDuration <= 0 )
416
+ if (displayDuration <= 0 )
398
417
return ;
399
418
400
419
if (scheduleDismissRunnable != null )
@@ -414,7 +433,7 @@ public void run() {
414
433
}
415
434
}
416
435
};
417
- handler .postDelayed (scheduleDismissRunnable , (long ) dismissDuration * 1_000 );
436
+ handler .postDelayed (scheduleDismissRunnable , (long ) displayDuration * 1_000 );
418
437
}
419
438
420
439
// Do not add view until activity is ready
@@ -627,7 +646,7 @@ public String toString() {
627
646
"currentActivity=" + currentActivity +
628
647
", pageWidth=" + pageWidth +
629
648
", pageHeight=" + pageHeight +
630
- ", dismissDuration =" + dismissDuration +
649
+ ", displayDuration =" + displayDuration +
631
650
", hasBackground=" + hasBackground +
632
651
", shouldDismissWhenActive=" + shouldDismissWhenActive +
633
652
", isDragging=" + isDragging +
0 commit comments