@@ -68,8 +68,10 @@ interface InAppMessageViewListener {
68
68
private final Handler handler = new Handler ();
69
69
private int pageWidth ;
70
70
private int pageHeight ;
71
- private int marginPxSizeWidth = dpToPx (24 );
72
- private int marginPxSizeHeight = dpToPx (24 );
71
+ private int marginPxSizeLeft = dpToPx (24 );
72
+ private int marginPxSizeRight = dpToPx (24 );
73
+ private int marginPxSizeTop = dpToPx (24 );
74
+ private int marginPxSizeBottom = dpToPx (24 );
73
75
private double dismissDuration ;
74
76
private boolean hasBackground ;
75
77
private boolean shouldDismissWhenActive = false ;
@@ -116,6 +118,16 @@ void checkIfShouldDismiss() {
116
118
}
117
119
}
118
120
121
+ void useHeightMargins (boolean shouldUseMargin ) {
122
+ marginPxSizeBottom = shouldUseMargin ? MARGIN_PX_SIZE : 0 ;
123
+ marginPxSizeTop = shouldUseMargin ? MARGIN_PX_SIZE : 0 ;
124
+ }
125
+
126
+ void useWidthMargins (boolean shouldUseMargin ) {
127
+ marginPxSizeLeft = shouldUseMargin ? MARGIN_PX_SIZE : 0 ;
128
+ marginPxSizeRight = shouldUseMargin ? MARGIN_PX_SIZE : 0 ;
129
+ }
130
+
119
131
/**
120
132
* This will fired when the device is rotated for example with a new provided height for the WebView
121
133
* Called to shrink or grow the WebView when it receives a JS resize event with a new height.
@@ -196,22 +208,22 @@ private RelativeLayout.LayoutParams createParentRelativeLayoutParams() {
196
208
197
209
private DraggableRelativeLayout .Params createDraggableLayoutParams (int pageHeight , WebViewManager .Position displayLocation , boolean disableDragging ) {
198
210
DraggableRelativeLayout .Params draggableParams = new DraggableRelativeLayout .Params ();
199
- draggableParams .maxXPos = marginPxSizeWidth ;
200
- draggableParams .maxYPos = marginPxSizeHeight ;
211
+ draggableParams .maxXPos = marginPxSizeRight ;
212
+ draggableParams .maxYPos = marginPxSizeTop ;
201
213
draggableParams .draggingDisabled = disableDragging ;
202
214
draggableParams .messageHeight = pageHeight ;
203
215
draggableParams .height = getDisplayYSize ();
204
216
205
217
switch (displayLocation ) {
206
218
case TOP_BANNER :
207
- draggableParams .dragThresholdY = marginPxSizeHeight - DRAG_THRESHOLD_PX_SIZE ;
219
+ draggableParams .dragThresholdY = marginPxSizeTop - DRAG_THRESHOLD_PX_SIZE ;
208
220
break ;
209
221
case BOTTOM_BANNER :
210
222
draggableParams .posY = getDisplayYSize () - pageHeight ;
211
- draggableParams .dragThresholdY = marginPxSizeHeight + DRAG_THRESHOLD_PX_SIZE ;
223
+ draggableParams .dragThresholdY = marginPxSizeBottom + DRAG_THRESHOLD_PX_SIZE ;
212
224
break ;
213
225
case FULL_SCREEN :
214
- draggableParams .messageHeight = pageHeight = getDisplayYSize () - (marginPxSizeHeight * 2 );
226
+ draggableParams .messageHeight = pageHeight = getDisplayYSize () - (marginPxSizeBottom + marginPxSizeTop );
215
227
// fall through for FULL_SCREEN since it shares similar params to CENTER_MODAL
216
228
case CENTER_MODAL :
217
229
int y = (getDisplayYSize () / 2 ) - (pageHeight / 2 );
@@ -343,7 +355,7 @@ public void onDragEnd() {
343
355
cardView .setTag (IN_APP_MESSAGE_CARD_VIEW_TAG );
344
356
cardView .addView (webView );
345
357
346
- draggableRelativeLayout .setPadding (marginPxSizeWidth , marginPxSizeHeight , marginPxSizeWidth , marginPxSizeHeight );
358
+ draggableRelativeLayout .setPadding (marginPxSizeLeft , marginPxSizeTop , marginPxSizeRight , marginPxSizeBottom );
347
359
draggableRelativeLayout .setClipChildren (false );
348
360
draggableRelativeLayout .setClipToPadding (false );
349
361
draggableRelativeLayout .addView (cardView );
@@ -551,7 +563,7 @@ private void animateTop(View messageView, int height, Animation.AnimationListene
551
563
// Animate the message view from above the screen downward to the top
552
564
OneSignalAnimate .animateViewByTranslation (
553
565
messageView ,
554
- -height - marginPxSizeHeight ,
566
+ -height - marginPxSizeTop ,
555
567
0f ,
556
568
IN_APP_BANNER_ANIMATION_DURATION_MS ,
557
569
new OneSignalBounceInterpolator (0.1 , 8.0 ),
@@ -563,7 +575,7 @@ private void animateBottom(View messageView, int height, Animation.AnimationList
563
575
// Animate the message view from under the screen upward to the bottom
564
576
OneSignalAnimate .animateViewByTranslation (
565
577
messageView ,
566
- height + marginPxSizeHeight ,
578
+ height + marginPxSizeBottom ,
567
579
0f ,
568
580
IN_APP_BANNER_ANIMATION_DURATION_MS ,
569
581
new OneSignalBounceInterpolator (0.1 , 8.0 ),
0 commit comments