Skip to content

Commit 082df4d

Browse files
authored
Support displayCutOutMode Short edges (#89)
Support displayCutOutMode Short edges in poolakey by sending displayCutOutMode flag to bazaar and show in displayCutOutMode Short edges if flag is true
1 parent 7fe866f commit 082df4d

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

poolakey/src/main/java/ir/cafebazaar/poolakey/BillingConnection.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ package ir.cafebazaar.poolakey
22

33
import android.app.Activity
44
import android.content.Context
5+
import android.os.Build
6+
import android.os.Build.VERSION.SDK_INT
7+
import android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
58
import androidx.activity.result.ActivityResult
69
import androidx.activity.result.ActivityResultRegistry
710
import ir.cafebazaar.poolakey.billing.connection.BillingConnectionCommunicator
@@ -82,6 +85,15 @@ internal class BillingConnection(
8285
onActivityResult(it, purchaseCallback)
8386
}.build()
8487

88+
purchaseRequest.cutoutModeIsShortEdges = if (SDK_INT >= Build.VERSION_CODES.P) {
89+
(context as? Activity)
90+
?.window
91+
?.attributes
92+
?.layoutInDisplayCutoutMode == LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
93+
} else {
94+
false
95+
}
96+
8597
runOnCommunicator(TAG_PURCHASE) { billingCommunicator ->
8698
billingCommunicator.purchase(
8799
requireNotNull(paymentLauncher),

poolakey/src/main/java/ir/cafebazaar/poolakey/constant/BazaarIntent.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ internal object BazaarIntent {
1414
const val RESPONSE_CHECK_TRIAL_SUBSCRIPTION_DATA = "CHECK_TRIAL_SUBSCRIPTION_DATA"
1515
const val REQUEST_SKU_DETAILS_LIST = "ITEM_ID_LIST"
1616
const val RESPONSE_DYNAMIC_PRICE_TOKEN = "DYNAMIC_PRICE_TOKEN"
17+
const val RESPONSE_CUTOUT_MODE_IS_SHORT_EDGES = "CUTOUT_MODE_IS_SHORT_EDGES"
1718
}

poolakey/src/main/java/ir/cafebazaar/poolakey/request/PurchaseRequest.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ data class PurchaseRequest(
77
val productId: String,
88
val payload: String? = null,
99
val dynamicPriceToken: String? = null
10-
)
10+
) {
11+
12+
internal var cutoutModeIsShortEdges = false
13+
}
1114

1215
internal fun PurchaseRequest.purchaseExtraData(): Bundle {
1316
return Bundle().apply {
1417
putString(BazaarIntent.RESPONSE_DYNAMIC_PRICE_TOKEN, dynamicPriceToken)
18+
putBoolean(BazaarIntent.RESPONSE_CUTOUT_MODE_IS_SHORT_EDGES, cutoutModeIsShortEdges)
1519
}
1620
}

0 commit comments

Comments
 (0)