Skip to content

Commit c88908d

Browse files
committed
use separate margin sizes for height and width
1 parent 740b39c commit c88908d

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/InAppMessageView.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class InAppMessageView {
5555

5656
private static final int ACTIVITY_FINISH_AFTER_DISMISS_DELAY_MS = 600;
5757
private static final int ACTIVITY_INIT_DELAY = 200;
58-
private static final int MARGIN_PX_SIZE = dpToPx(24);
5958
private static final int DRAG_THRESHOLD_PX_SIZE = dpToPx(4);
6059
private PopupWindow popupWindow;
6160

@@ -69,6 +68,8 @@ interface InAppMessageViewListener {
6968
private final Handler handler = new Handler();
7069
private int pageWidth;
7170
private int pageHeight;
71+
private int marginPxSizeWidth = dpToPx(24);
72+
private int marginPxSizeHeight = dpToPx(24);
7273
private double dismissDuration;
7374
private boolean hasBackground;
7475
private boolean shouldDismissWhenActive = false;
@@ -194,22 +195,22 @@ private LinearLayout.LayoutParams createParentLinearLayoutParams() {
194195

195196
private DraggableRelativeLayout.Params createDraggableLayoutParams(int pageHeight, WebViewManager.Position displayLocation, boolean disableDragging) {
196197
DraggableRelativeLayout.Params draggableParams = new DraggableRelativeLayout.Params();
197-
draggableParams.maxXPos = MARGIN_PX_SIZE;
198-
draggableParams.maxYPos = MARGIN_PX_SIZE;
198+
draggableParams.maxXPos = marginPxSizeWidth;
199+
draggableParams.maxYPos = marginPxSizeHeight;
199200
draggableParams.draggingDisabled = disableDragging;
200201
draggableParams.messageHeight = pageHeight;
201202
draggableParams.height = getDisplayYSize();
202203

203204
switch (displayLocation) {
204205
case TOP_BANNER:
205-
draggableParams.dragThresholdY = MARGIN_PX_SIZE - DRAG_THRESHOLD_PX_SIZE;
206+
draggableParams.dragThresholdY = marginPxSizeHeight - DRAG_THRESHOLD_PX_SIZE;
206207
break;
207208
case BOTTOM_BANNER:
208209
draggableParams.posY = getDisplayYSize() - pageHeight;
209-
draggableParams.dragThresholdY = MARGIN_PX_SIZE + DRAG_THRESHOLD_PX_SIZE;
210+
draggableParams.dragThresholdY = marginPxSizeHeight + DRAG_THRESHOLD_PX_SIZE;
210211
break;
211212
case FULL_SCREEN:
212-
draggableParams.messageHeight = pageHeight = getDisplayYSize() - (MARGIN_PX_SIZE * 2);
213+
draggableParams.messageHeight = pageHeight = getDisplayYSize() - (marginPxSizeHeight * 2);
213214
// fall through for FULL_SCREEN since it shares similar params to CENTER_MODAL
214215
case CENTER_MODAL:
215216
int y = (getDisplayYSize() / 2) - (pageHeight / 2);
@@ -335,7 +336,7 @@ public void onDragEnd() {
335336
cardView.setTag(IN_APP_MESSAGE_CARD_VIEW_TAG);
336337
cardView.addView(webView);
337338

338-
draggableRelativeLayout.setPadding(MARGIN_PX_SIZE, MARGIN_PX_SIZE, MARGIN_PX_SIZE, MARGIN_PX_SIZE);
339+
draggableRelativeLayout.setPadding(marginPxSizeWidth, marginPxSizeHeight, marginPxSizeWidth, marginPxSizeHeight);
339340
draggableRelativeLayout.setClipChildren(false);
340341
draggableRelativeLayout.setClipToPadding(false);
341342
draggableRelativeLayout.addView(cardView);
@@ -543,7 +544,7 @@ private void animateTop(View messageView, int height, Animation.AnimationListene
543544
// Animate the message view from above the screen downward to the top
544545
OneSignalAnimate.animateViewByTranslation(
545546
messageView,
546-
-height - MARGIN_PX_SIZE,
547+
-height - marginPxSizeHeight,
547548
0f,
548549
IN_APP_BANNER_ANIMATION_DURATION_MS,
549550
new OneSignalBounceInterpolator(0.1, 8.0),
@@ -555,7 +556,7 @@ private void animateBottom(View messageView, int height, Animation.AnimationList
555556
// Animate the message view from under the screen upward to the bottom
556557
OneSignalAnimate.animateViewByTranslation(
557558
messageView,
558-
height + MARGIN_PX_SIZE,
559+
height + marginPxSizeHeight,
559560
0f,
560561
IN_APP_BANNER_ANIMATION_DURATION_MS,
561562
new OneSignalBounceInterpolator(0.1, 8.0),

0 commit comments

Comments
 (0)