Skip to content

Commit 93c2ec9

Browse files
committed
Clarify dropshadow and gray overlay methods
- separate out overlay color getter into its own method to reduce redundancy - update wording for dropsahdow getter for succinctness - add back constants to companion object
1 parent 3524165 commit 93c2ec9

File tree

1 file changed

+14
-17
lines changed
  • OneSignalSDK/onesignal/in-app-messages/src/main/java/com/onesignal/inAppMessages/internal/display/impl

1 file changed

+14
-17
lines changed

OneSignalSDK/onesignal/in-app-messages/src/main/java/com/onesignal/inAppMessages/internal/display/impl/InAppMessageView.kt

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ internal class InAppMessageView(
385385
cardView.cardElevation =
386386
0f
387387
} else {
388-
if (getInAppMessageHideDropShadow(context)) {
388+
if (getHideDropShadow(context)) {
389389
cardView.cardElevation = 0f
390390
} else {
391391
cardView.cardElevation = ViewUtils.dpToPx(5).toFloat()
@@ -399,7 +399,7 @@ internal class InAppMessageView(
399399
return cardView
400400
}
401401

402-
private fun getInAppMessageHideDropShadow(context: Context): Boolean {
402+
private fun getHideDropShadow(context: Context): Boolean {
403403
return AndroidUtils.getManifestMetaBoolean(context, "com.onesignal.inAppMessageHideDropShadow")
404404
}
405405

@@ -612,19 +612,13 @@ internal class InAppMessageView(
612612
cardViewAnimCallback,
613613
)
614614

615-
var overlayColor = Color.parseColor("#BB000000")
616-
617-
if (hideGrayOverlay) {
618-
overlayColor = Color.TRANSPARENT
619-
}
620-
621615
// Animate background behind the message so it doesn't just show the dark transparency
622616
val backgroundAnimation =
623617
animateBackgroundColor(
624618
backgroundView,
625619
IN_APP_BACKGROUND_ANIMATION_DURATION_MS,
626620
ACTIVITY_BACKGROUND_COLOR_EMPTY,
627-
overlayColor,
621+
getOverlayColor(),
628622
backgroundAnimCallback,
629623
)
630624
messageAnimation.start()
@@ -641,17 +635,11 @@ internal class InAppMessageView(
641635
}
642636
}
643637

644-
var overlayColor = Color.parseColor("#BB000000")
645-
646-
if (hideGrayOverlay) {
647-
overlayColor = Color.TRANSPARENT
648-
}
649-
650638
// Animate background behind the message so it hides before being removed from the view
651639
animateBackgroundColor(
652640
backgroundView,
653641
IN_APP_BACKGROUND_ANIMATION_DURATION_MS,
654-
overlayColor,
642+
getOverlayColor(),
655643
ACTIVITY_BACKGROUND_COLOR_EMPTY,
656644
animCallback,
657645
)
@@ -691,9 +679,18 @@ internal class InAppMessageView(
691679
'}'
692680
}
693681

682+
private fun getOverlayColor(): Int {
683+
return if (hideGrayOverlay) {
684+
ACTIVITY_BACKGROUND_COLOR_EMPTY
685+
} else {
686+
ACTIVITY_BACKGROUND_COLOR_FULL
687+
}
688+
}
689+
694690
companion object {
695691
private const val IN_APP_MESSAGE_CARD_VIEW_TAG = "IN_APP_MESSAGE_CARD_VIEW_TAG"
696-
private val ACTIVITY_BACKGROUND_COLOR_EMPTY = Color.parseColor("#00000000")
692+
private const val ACTIVITY_BACKGROUND_COLOR_EMPTY = Color.TRANSPARENT
693+
private val ACTIVITY_BACKGROUND_COLOR_FULL = Color.parseColor("#BB000000")
697694
private const val IN_APP_BANNER_ANIMATION_DURATION_MS = 1000
698695
private const val IN_APP_CENTER_ANIMATION_DURATION_MS = 1000
699696
private const val IN_APP_BACKGROUND_ANIMATION_DURATION_MS = 400

0 commit comments

Comments
 (0)