Skip to content

Commit 67b3f92

Browse files
committed
using height/width margin booleans instead of top/bottom/left/right double
1 parent 4bd2209 commit 67b3f92

File tree

2 files changed

+10
-24
lines changed

2 files changed

+10
-24
lines changed

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,10 @@ interface InAppMessageViewListener {
100100
* @param content in app message content and style
101101
*/
102102
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-
}
103+
this.marginPxSizeTop = content.getUseHeightMargin() ? dpToPx(24) : 0;
104+
this.marginPxSizeBottom = content.getUseHeightMargin() ? dpToPx(24) : 0;
105+
this.marginPxSizeLeft = content.getUseWidthMargin() ? dpToPx(24) : 0;
106+
this.marginPxSizeRight = content.getUseWidthMargin() ? dpToPx(24) : 0;
115107
}
116108

117109
void setWebView(WebView webView) {

OneSignalSDK/onesignal/src/main/java/com/onesignal/OSInAppMessageContent.kt

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,13 @@ import org.json.JSONObject
55
const val HTML = "html"
66
const val STYLES = "styles"
77
const val DISPLAY_DURATION = "display_duration"
8-
const val TOP_MARGIN = "top_margin"
9-
const val BOTTOM_MARGIN = "bottom_margin"
10-
const val LEFT_MARGIN = "left_margin"
11-
const val RIGHT_MARGIN = "right_margin"
8+
const val REMOVE_HEIGHT_MARGIN = "remove_height_margin"
9+
const val REMOVE_WIDTH_MARGIN = "remove_width_margin"
1210

1311
internal open class OSInAppMessageContent constructor(jsonObject: JSONObject) {
1412
var contentHtml: String? = null
15-
var topMargin: Int? = 1
16-
var bottomMargin: Int? = 1
17-
var leftMargin: Int? = 1
18-
var rightMargin: Int? = 1
13+
var useHeightMargin: Boolean = true
14+
var useWidthMargin: Boolean = true
1915
// The following properties are populated from Javascript events
2016
var displayLocation: WebViewManager.Position? = null
2117
var displayDuration: Double? = null
@@ -25,9 +21,7 @@ internal open class OSInAppMessageContent constructor(jsonObject: JSONObject) {
2521
contentHtml = jsonObject.optString(HTML)
2622
displayDuration = jsonObject.optDouble(DISPLAY_DURATION)
2723
var styles: JSONObject? = jsonObject.optJSONObject(STYLES)
28-
topMargin = styles?.optInt(TOP_MARGIN, 1)
29-
bottomMargin = styles?.optInt(BOTTOM_MARGIN, 1)
30-
leftMargin = styles?.optInt(LEFT_MARGIN, 1)
31-
rightMargin = styles?.optInt(RIGHT_MARGIN,1)
24+
useHeightMargin = !(styles?.optBoolean(REMOVE_HEIGHT_MARGIN, false) ?: false)
25+
useWidthMargin = !(styles?.optBoolean(REMOVE_WIDTH_MARGIN, false) ?: false)
3226
}
3327
}

0 commit comments

Comments
 (0)