-
Notifications
You must be signed in to change notification settings - Fork 16
Restore dual architecture support for 3.9 #487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
11e442a
67519dc
4ad8d08
7d08692
868c1be
e2c5166
4aa378b
b137016
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,21 +27,26 @@ of this software and associated documentation files (the "Software"), to deal | |
| import android.content.Context; | ||
| import androidx.activity.ComponentActivity; | ||
| import androidx.annotation.NonNull; | ||
| import com.facebook.react.bridge.Promise; | ||
| import com.facebook.react.bridge.ReactApplicationContext; | ||
| import com.facebook.react.bridge.ReactContextBaseJavaModule; | ||
| import com.facebook.react.bridge.ReactMethod; | ||
| import com.facebook.react.bridge.Arguments; | ||
| import com.facebook.react.bridge.Promise; | ||
| import com.facebook.react.bridge.ReadableArray; | ||
| import com.facebook.react.bridge.ReadableMap; | ||
| import com.facebook.react.bridge.WritableMap; | ||
| import com.shopify.checkoutsheetkit.NativeShopifyCheckoutSheetKitSpec; | ||
| import com.facebook.react.module.annotations.ReactModule; | ||
| import com.facebook.react.turbomodule.core.interfaces.TurboModule; | ||
| import com.shopify.checkoutsheetkit.*; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.Objects; | ||
|
|
||
| public class ShopifyCheckoutSheetKitModule extends NativeShopifyCheckoutSheetKitSpec { | ||
| @ReactModule(name = ShopifyCheckoutSheetKitModule.NAME) | ||
| public class ShopifyCheckoutSheetKitModule extends ReactContextBaseJavaModule implements TurboModule { | ||
|
|
||
| public static final String NAME = "ShopifyCheckoutSheetKit"; | ||
|
|
||
| public static Configuration checkoutConfig = new Configuration(); | ||
|
|
||
|
|
@@ -62,8 +67,14 @@ public ShopifyCheckoutSheetKitModule(ReactApplicationContext reactContext) { | |
| }); | ||
| } | ||
|
|
||
| @NonNull | ||
| @Override | ||
| public String getName() { | ||
| return NAME; | ||
| } | ||
|
|
||
| @Override | ||
| protected Map<String, Object> getTypedExportedConstants() { | ||
| public Map<String, Object> getConstants() { | ||
| final Map<String, Object> constants = new HashMap<>(); | ||
| constants.put("version", ShopifyCheckoutSheetKit.version); | ||
| return constants; | ||
|
|
@@ -81,7 +92,7 @@ public void removeListeners(double count) { | |
|
|
||
| @ReactMethod | ||
| public void present(String checkoutURL) { | ||
| Activity currentActivity = getCurrentActivity(); | ||
| Activity currentActivity = getReactApplicationContext().getCurrentActivity(); | ||
| if (currentActivity instanceof ComponentActivity) { | ||
| checkoutEventProcessor = new CustomCheckoutEventProcessor(currentActivity, this.reactContext); | ||
| currentActivity.runOnUiThread(() -> { | ||
|
|
@@ -101,7 +112,7 @@ public void dismiss() { | |
|
|
||
| @ReactMethod | ||
| public void preload(String checkoutURL) { | ||
| Activity currentActivity = getCurrentActivity(); | ||
| Activity currentActivity = getReactApplicationContext().getCurrentActivity(); | ||
|
|
||
| if (currentActivity instanceof ComponentActivity) { | ||
| ShopifyCheckoutSheetKit.preload(checkoutURL, (ComponentActivity) currentActivity); | ||
|
|
@@ -113,15 +124,15 @@ public void invalidateCache() { | |
| ShopifyCheckoutSheetKit.invalidate(); | ||
| } | ||
|
|
||
| @ReactMethod(isBlockingSynchronousMethod = true) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI These all exist as turbo module plumbing - the typescript spec includes them |
||
| public WritableMap getConfig() { | ||
| @ReactMethod | ||
| public void getConfig(Promise promise) { | ||
| WritableMap resultConfig = Arguments.createMap(); | ||
|
|
||
| resultConfig.putBoolean("preloading", checkoutConfig.getPreloading().getEnabled()); | ||
| resultConfig.putString("colorScheme", colorSchemeToString(checkoutConfig.getColorScheme())); | ||
| resultConfig.putString("logLevel", logLevelToString(checkoutConfig.getLogLevel())); | ||
|
|
||
| return resultConfig; | ||
| promise.resolve(resultConfig); | ||
| } | ||
|
|
||
| @ReactMethod | ||
|
|
@@ -165,30 +176,31 @@ public void setConfig(ReadableMap config) { | |
| }); | ||
| } | ||
|
|
||
| @ReactMethod(isBlockingSynchronousMethod = true) | ||
| public boolean configureAcceleratedCheckouts( | ||
| @ReactMethod | ||
| public void configureAcceleratedCheckouts( | ||
| String storefrontDomain, | ||
| String storefrontAccessToken, | ||
| String customerEmail, | ||
| String customerPhoneNumber, | ||
| String customerAccessToken, | ||
| String applePayMerchantIdentifier, | ||
| ReadableArray applyPayContactFields, | ||
| ReadableArray supportedShippingCountries) { | ||
| ReadableArray supportedShippingCountries, | ||
| Promise promise) { | ||
| // Accelerated checkouts not supported on Android | ||
| return false; | ||
| promise.resolve(false); | ||
| } | ||
|
|
||
| @ReactMethod(isBlockingSynchronousMethod = true) | ||
| public boolean isAcceleratedCheckoutAvailable() { | ||
| @ReactMethod | ||
| public void isAcceleratedCheckoutAvailable(Promise promise) { | ||
| // Accelerated checkouts not supported on Android | ||
| return false; | ||
| promise.resolve(false); | ||
| } | ||
|
|
||
| @ReactMethod(isBlockingSynchronousMethod = true) | ||
| public boolean isApplePayAvailable() { | ||
| @ReactMethod | ||
| public void isApplePayAvailable(Promise promise) { | ||
| // Apple Pay not available on Android | ||
| return false; | ||
| promise.resolve(false); | ||
| } | ||
|
|
||
| @ReactMethod | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| { | ||
| "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", | ||
| "projectFolder": ".", | ||
| "mainEntryPointFilePath": "<projectFolder>/lib/typescript/src/index.d.ts", | ||
| "compiler": { | ||
| "tsconfigFilePath": "<projectFolder>/tsconfig.build.json" | ||
| }, | ||
| "newlineKind": "lf", | ||
| "apiReport": { | ||
| "enabled": true, | ||
| "reportFolder": "<projectFolder>/api/", | ||
| "reportFileName": "checkout-sheet-kit.api.md" | ||
| }, | ||
| "docModel": { | ||
| "enabled": false | ||
| }, | ||
| "dtsRollup": { | ||
| "enabled": false | ||
| }, | ||
| "tsdocMetadata": { | ||
| "enabled": false | ||
| }, | ||
| "messages": { | ||
| "compilerMessageReporting": { | ||
| "default": { | ||
| "logLevel": "warning" | ||
| } | ||
| }, | ||
| "extractorMessageReporting": { | ||
| "default": { | ||
| "logLevel": "warning" | ||
| }, | ||
| "ae-missing-release-tag": { | ||
| "logLevel": "none" | ||
| }, | ||
| "ae-forgotten-export": { | ||
| "logLevel": "none", | ||
| "addToApiReportFile": false | ||
| } | ||
| }, | ||
| "tsdocMessageReporting": { | ||
| "default": { | ||
| "logLevel": "none" | ||
| } | ||
| } | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.