@24i/smartapps-bigscreen-rnv-build-engine 0.17.27-alpha.2816 → 0.17.27-alpha.2818
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/sdks/sdk-androidtv/sdkAndroidtv.js +38 -0
- package/dist/templates/platforms/androidtv/project/amazoniap/src/main/kotlin/com/twentyfouri/bridgetv/amazoniap/AmazonIapService.kt +6 -4
- package/dist/templates/platforms/androidtv/project/app/build.gradle +1 -0
- package/dist/templates/platforms/androidtv/project/app/src/bigscreenAppstage/java/com/twentyfouri/tvbridge/Flavor.kt +6 -1
- package/dist/templates/platforms/androidtv/project/app/src/main/java/com/twentyfouri/tvbridge/bridge/BridgeFromJavaScript.kt +12 -3
- package/dist/templates/platforms/androidtv/project/app/src/main/java/com/twentyfouri/tvbridge/bridge/BridgeToJavaScript.kt +4 -3
- package/dist/templates/platforms/androidtv/project/app/src/main/java/com/twentyfouri/tvbridge/webview/viewmodel/WebViewModel.kt +2 -3
- package/dist/templates/platforms/androidtv/project/common/src/main/java/com/twentyfouri/tvbridge/common/IapService.kt +4 -3
- package/package.json +1 -1
|
@@ -216,6 +216,43 @@ const configureEntryUrl = (c) => {
|
|
|
216
216
|
rnv_1.Common.addSystemInjects(c, injects);
|
|
217
217
|
rnv_1.FileUtils.writeCleanFile(buildGradleFilePath, buildGradleFilePath, injects, null, c);
|
|
218
218
|
};
|
|
219
|
+
const configureIap = (c) => {
|
|
220
|
+
rnv_1.Logger.logTask('configureIap');
|
|
221
|
+
const projectDir = rnv_1.Common.getPlatformProjectDir(c);
|
|
222
|
+
const buildGradleFilePath = path.join(projectDir, 'app', buildGradleFileName);
|
|
223
|
+
const flavorFilePath = path.join(projectDir, `app/src/${flavourName}/java/com/twentyfouri/tvbridge/Flavor.kt`);
|
|
224
|
+
const enableIap = rnv_1.Common.getConfigProp(c, c.platform, 'enableIap', false);
|
|
225
|
+
let iapDependencies = [];
|
|
226
|
+
let flavorImports = [];
|
|
227
|
+
let flavorIapFactories = [];
|
|
228
|
+
if (enableIap) {
|
|
229
|
+
switch (c.platform) {
|
|
230
|
+
case 'firetv':
|
|
231
|
+
iapDependencies.push('implementation project(\':amazoniap\')');
|
|
232
|
+
flavorImports.push('import com.twentyfouri.bridgetv.amazoniap.AmazonIapServiceFactory');
|
|
233
|
+
flavorIapFactories.push('AmazonIapServiceFactory');
|
|
234
|
+
break;
|
|
235
|
+
case 'androidtv':
|
|
236
|
+
iapDependencies.push('implementation project(\':googleiap\')');
|
|
237
|
+
flavorImports.push('import com.twentyfouri.bridgetv.googleiap.GoogleIapServiceFactory');
|
|
238
|
+
flavorIapFactories.push('GoogleIapServiceFactory');
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const injects = [{
|
|
243
|
+
pattern: '{{IAP_DEPENDENCIES}}',
|
|
244
|
+
override: iapDependencies.join('\n'),
|
|
245
|
+
}, {
|
|
246
|
+
pattern: '{{FLAVOR_IMPORTS}}',
|
|
247
|
+
override: flavorImports.join('\n'),
|
|
248
|
+
}, {
|
|
249
|
+
pattern: '{{FLAVOR_IAP_FACTORIES}}',
|
|
250
|
+
override: flavorIapFactories.join(', '),
|
|
251
|
+
}];
|
|
252
|
+
rnv_1.Common.addSystemInjects(c, injects);
|
|
253
|
+
rnv_1.FileUtils.writeCleanFile(buildGradleFilePath, buildGradleFilePath, injects, null, c);
|
|
254
|
+
rnv_1.FileUtils.writeCleanFile(flavorFilePath, flavorFilePath, injects, null, c);
|
|
255
|
+
};
|
|
219
256
|
const configureAndroidProperties = async (c) => {
|
|
220
257
|
rnv_1.Logger.logTask('configureAndroidProperties');
|
|
221
258
|
let sdkDir = c.buildConfig?.sdks?.ANDROID_SDK || '';
|
|
@@ -240,6 +277,7 @@ const configureAndroidTVProject = async (c) => {
|
|
|
240
277
|
await configureAndroidProperties(c);
|
|
241
278
|
configureProject(c);
|
|
242
279
|
configureEntryUrl(c);
|
|
280
|
+
configureIap(c);
|
|
243
281
|
configureSigning(c);
|
|
244
282
|
const gradlew = path.join(rnv_1.Common.getPlatformProjectDir(c), 'gradlew');
|
|
245
283
|
fs.chmodSync(gradlew, '755');
|
|
@@ -14,6 +14,7 @@ import com.twentyfouri.tvbridge.common.IapException
|
|
|
14
14
|
import com.twentyfouri.tvbridge.common.IapProduct
|
|
15
15
|
import com.twentyfouri.tvbridge.common.IapPurchase
|
|
16
16
|
import com.twentyfouri.tvbridge.common.IapService
|
|
17
|
+
import org.json.JSONObject
|
|
17
18
|
|
|
18
19
|
class AmazonIapService(private val context: Context) : IapService, PurchasingListener {
|
|
19
20
|
private var callback: IapCallback? = null
|
|
@@ -38,7 +39,7 @@ class AmazonIapService(private val context: Context) : IapService, PurchasingLis
|
|
|
38
39
|
if (result.requestStatus == PurchaseUpdatesResponse.RequestStatus.SUCCESSFUL) {
|
|
39
40
|
callback?.checkNewPurchasesFinished(
|
|
40
41
|
result.receipts.map { receipt ->
|
|
41
|
-
IapPurchase(receipt.sku, result.userData.userId, receipt.
|
|
42
|
+
IapPurchase(receipt.sku, result.userData.userId, receipt.toJSON())
|
|
42
43
|
}
|
|
43
44
|
)
|
|
44
45
|
} else {
|
|
@@ -53,7 +54,7 @@ class AmazonIapService(private val context: Context) : IapService, PurchasingLis
|
|
|
53
54
|
override fun onPurchaseResponse(result: PurchaseResponse) {
|
|
54
55
|
if (result.requestStatus == PurchaseResponse.RequestStatus.SUCCESSFUL) {
|
|
55
56
|
callback?.purchaseFinished(
|
|
56
|
-
IapPurchase(result.receipt.sku, result.userData.userId, result.receipt.
|
|
57
|
+
IapPurchase(result.receipt.sku, result.userData.userId, result.receipt.toJSON())
|
|
57
58
|
)
|
|
58
59
|
} else {
|
|
59
60
|
callback?.purchaseFinished(IapException(result.requestStatus.name))
|
|
@@ -84,7 +85,8 @@ class AmazonIapService(private val context: Context) : IapService, PurchasingLis
|
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
|
|
87
|
-
override fun acknowledgeReceipt(receipt:
|
|
88
|
-
|
|
88
|
+
override fun acknowledgeReceipt(receipt: JSONObject) {
|
|
89
|
+
val receiptId = receipt.getString("receiptId")
|
|
90
|
+
PurchasingService.notifyFulfillment(receiptId, FulfillmentResult.FULFILLED)
|
|
89
91
|
}
|
|
90
92
|
}
|
|
@@ -94,6 +94,7 @@ dependencies {
|
|
|
94
94
|
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'
|
|
95
95
|
|
|
96
96
|
implementation project(':common')
|
|
97
|
+
{{IAP_DEPENDENCIES}}
|
|
97
98
|
|
|
98
99
|
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
|
99
100
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2"
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
package com.twentyfouri.tvbridge
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import com.twentyfouri.tvbridge.common.IapServiceFactory
|
|
4
|
+
{{FLAVOR_IMPORTS}}
|
|
4
5
|
|
|
6
|
+
class Flavor: FlavorBase() {
|
|
7
|
+
override fun getIapServiceFactories(): List<IapServiceFactory> {
|
|
8
|
+
return listOf({{FLAVOR_IAP_FACTORIES}})
|
|
9
|
+
}
|
|
5
10
|
}
|
|
@@ -14,6 +14,7 @@ import com.twentyfouri.tvbridge.webview.parser.TrackJsonModelParser.audioFromJso
|
|
|
14
14
|
import com.twentyfouri.tvbridge.webview.parser.TrackJsonModelParser.textFromJson
|
|
15
15
|
import com.twentyfouri.tvbridge.webview.parser.TrackJsonModelParser.toJson
|
|
16
16
|
import com.twentyfouri.tvbridge.webview.viewmodel.WebViewModel
|
|
17
|
+
import org.json.JSONObject
|
|
17
18
|
import java.text.SimpleDateFormat
|
|
18
19
|
import java.util.Arrays
|
|
19
20
|
import java.util.concurrent.CountDownLatch
|
|
@@ -359,9 +360,17 @@ class BridgeFromJavaScript(
|
|
|
359
360
|
}
|
|
360
361
|
|
|
361
362
|
@JavascriptInterface
|
|
362
|
-
fun bridgeReceiptIAPValidated(
|
|
363
|
-
Log.d(LOG_TAG, "bridgeReceiptIAPValidated
|
|
364
|
-
|
|
363
|
+
fun bridgeReceiptIAPValidated(receipt: String?) {
|
|
364
|
+
Log.d(LOG_TAG, "bridgeReceiptIAPValidated receipt=$receipt")
|
|
365
|
+
val json = when {
|
|
366
|
+
receipt == null -> JSONObject()
|
|
367
|
+
receipt.startsWith('{') -> JSONObject(receipt)
|
|
368
|
+
else -> JSONObject().also {
|
|
369
|
+
it.put("receiptId", receipt) // Amazon
|
|
370
|
+
it.put("purchaseToken", receipt) // Google
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
viewModel.acknowledgeIapReceipt(json)
|
|
365
374
|
}
|
|
366
375
|
|
|
367
376
|
/***
|
|
@@ -11,6 +11,7 @@ import com.twentyfouri.tvbridge.bridge.BridgeFromJavaScript.Companion.LOG_TAG
|
|
|
11
11
|
import com.twentyfouri.tvbridge.configuration.BridgeConfig
|
|
12
12
|
import com.twentyfouri.tvbridge.webview.parser.TrackJsonModelParser.toJson
|
|
13
13
|
import org.json.JSONArray
|
|
14
|
+
import org.json.JSONObject
|
|
14
15
|
|
|
15
16
|
class BridgeToJavaScript(
|
|
16
17
|
config: BridgeConfig,
|
|
@@ -98,14 +99,14 @@ class BridgeToJavaScript(
|
|
|
98
99
|
|
|
99
100
|
fun bridgeAndroidToJavaScript_IAPValidationSuccess(
|
|
100
101
|
userId: String,
|
|
101
|
-
|
|
102
|
+
receipt: JSONObject,
|
|
102
103
|
sku: String
|
|
103
104
|
) {
|
|
104
105
|
Log.d(
|
|
105
106
|
LOG_TAG,
|
|
106
|
-
"bridgeAndroidToJavaScript_IAPValidationSuccess sku=$sku
|
|
107
|
+
"bridgeAndroidToJavaScript_IAPValidationSuccess sku=$sku receipt=$receipt"
|
|
107
108
|
)
|
|
108
|
-
executeJavaScript("javascript:((function dispatchEvent(){var evt = document.createEvent('Events');evt.initEvent('${iapEventPrefix}iapSuccess',true,true);evt.userId='$userId';evt.
|
|
109
|
+
executeJavaScript("javascript:((function dispatchEvent(){var evt = document.createEvent('Events');evt.initEvent('${iapEventPrefix}iapSuccess',true,true);evt.userId='$userId';evt.receipt='$receipt';evt.sku='$sku';document.dispatchEvent(evt);})())")
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
fun bridgeIAPGetProductDataSuccess(okSkus: String, badSkus: String) {
|
|
@@ -14,7 +14,6 @@ import android.webkit.CookieManager
|
|
|
14
14
|
import android.webkit.WebChromeClient
|
|
15
15
|
import android.webkit.WebView
|
|
16
16
|
import com.google.android.gms.ads.identifier.AdvertisingIdClient
|
|
17
|
-
import com.google.android.gms.common.GooglePlayServicesNotAvailableException
|
|
18
17
|
import com.google.gson.JsonArray
|
|
19
18
|
import com.google.gson.JsonObject
|
|
20
19
|
import com.twentyfouri.player.base.*
|
|
@@ -492,9 +491,9 @@ class WebViewModel @Inject constructor(
|
|
|
492
491
|
iapService.getProducts(skus)
|
|
493
492
|
}
|
|
494
493
|
|
|
495
|
-
fun acknowledgeIapReceipt(
|
|
494
|
+
fun acknowledgeIapReceipt(receipt: JSONObject) {
|
|
496
495
|
iapService.setCallback(iapCallback)
|
|
497
|
-
iapService.acknowledgeReceipt(
|
|
496
|
+
iapService.acknowledgeReceipt(receipt)
|
|
498
497
|
}
|
|
499
498
|
|
|
500
499
|
private fun dispatchKeyEvent(event: KeyEvent): Boolean {
|
|
@@ -2,6 +2,7 @@ package com.twentyfouri.tvbridge.common
|
|
|
2
2
|
|
|
3
3
|
import android.app.Activity
|
|
4
4
|
import android.content.Context
|
|
5
|
+
import org.json.JSONObject
|
|
5
6
|
|
|
6
7
|
interface IapServiceFactory {
|
|
7
8
|
fun detectSupport(context: Context): Boolean
|
|
@@ -23,7 +24,7 @@ interface IapService {
|
|
|
23
24
|
fun checkNewPurchases()
|
|
24
25
|
fun getProducts(skus: List<String>)
|
|
25
26
|
fun purchase(activity: Activity, sku: String)
|
|
26
|
-
fun acknowledgeReceipt(receipt:
|
|
27
|
+
fun acknowledgeReceipt(receipt: JSONObject)
|
|
27
28
|
fun setCallback(callback: IapCallback?)
|
|
28
29
|
}
|
|
29
30
|
|
|
@@ -55,7 +56,7 @@ open class IapProduct(
|
|
|
55
56
|
open class IapPurchase(
|
|
56
57
|
val sku: String,
|
|
57
58
|
val userId: String,
|
|
58
|
-
val receipt:
|
|
59
|
+
val receipt: JSONObject
|
|
59
60
|
)
|
|
60
61
|
|
|
61
62
|
open class IapException(
|
|
@@ -104,7 +105,7 @@ open class NullIapService : IapService {
|
|
|
104
105
|
callback?.purchaseFinished(UnsupportedOperationException())
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
override fun acknowledgeReceipt(receipt:
|
|
108
|
+
override fun acknowledgeReceipt(receipt: JSONObject) {
|
|
108
109
|
callback?.acknowledgeReceiptFinished(UnsupportedOperationException())
|
|
109
110
|
}
|
|
110
111
|
|
package/package.json
CHANGED