react-native-klarna-inapp-sdk 2.1.13 → 2.2.1

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.
Files changed (104) hide show
  1. package/README.md +100 -270
  2. package/android/build.gradle +84 -106
  3. package/android/gradle.properties +7 -0
  4. package/android/src/main/AndroidManifest.xml +2 -1
  5. package/android/src/main/AndroidManifestNew.xml +4 -0
  6. package/android/src/main/java/com/klarna/mobile/sdk/reactnative/KlarnaMobileSDKPackage.java +33 -0
  7. package/android/src/main/java/com/klarna/mobile/sdk/reactnative/common/ArgumentsUtil.java +62 -0
  8. package/android/src/main/java/com/klarna/mobile/sdk/reactnative/common/WebViewResizeObserver.java +100 -0
  9. package/android/src/main/java/com/klarna/{inapp/sdk → mobile/sdk/reactnative/payments}/KlarnaPaymentEvent.java +9 -19
  10. package/android/src/main/java/com/klarna/mobile/sdk/reactnative/payments/KlarnaPaymentViewManager.java +343 -0
  11. package/android/src/main/java/com/klarna/mobile/sdk/reactnative/payments/PaymentViewWrapper.java +78 -0
  12. package/android/src/main/java/com/klarna/mobile/sdk/reactnative/standalonewebview/KlarnaStandaloneWebViewEvent.java +67 -0
  13. package/android/src/main/java/com/klarna/mobile/sdk/reactnative/standalonewebview/KlarnaStandaloneWebViewEventSender.java +139 -0
  14. package/android/src/main/java/com/klarna/mobile/sdk/reactnative/standalonewebview/KlarnaStandaloneWebViewManager.java +205 -0
  15. package/android/src/newarch/java/com/klarna/mobile/sdk/reactnative/spec/RNKlarnaPaymentViewSpec.java +32 -0
  16. package/android/src/newarch/java/com/klarna/mobile/sdk/reactnative/spec/RNKlarnaStandaloneWebViewSpec.java +33 -0
  17. package/android/src/oldarch/java/com/klarna/mobile/sdk/reactnative/spec/RNKlarnaPaymentViewSpec.java +25 -0
  18. package/android/src/oldarch/java/com/klarna/mobile/sdk/reactnative/spec/RNKlarnaStandaloneWebViewSpec.java +19 -0
  19. package/android/src/test/java/com/klarna/{inapp/sdk/KlarnaPaymentViewPackageTest.java → mobile/sdk/reactnative/KlarnaMobileSDKPackageTest.java} +9 -4
  20. package/android/src/test/java/com/klarna/{inapp/sdk → mobile/sdk/reactnative/payments}/KlarnaPaymentEventTest.java +17 -20
  21. package/android/src/test/java/com/klarna/{inapp/sdk → mobile/sdk/reactnative/payments}/KlarnaPaymentViewManagerTest.java +62 -36
  22. package/ios/{KlarnaInAppSDK.xcodeproj → RNKlarnaMobileSDK.xcodeproj}/project.pbxproj +147 -87
  23. package/ios/{KlarnaInAppSDK.xcodeproj/xcshareddata/xcschemes/KlarnaInAppSDK.xcscheme → RNKlarnaMobileSDK.xcodeproj/xcshareddata/xcschemes/RNKlarnaMobileSDK.xcscheme} +9 -9
  24. package/ios/{KlarnaInAppSDK.xcodeproj/xcshareddata/xcschemes/KlarnaInAppSDKTests.xcscheme → RNKlarnaMobileSDK.xcodeproj/xcshareddata/xcschemes/RNKlarnaMobileSDKTests.xcscheme} +3 -3
  25. package/ios/Sources/KlarnaPaymentViewManager.h +5 -0
  26. package/ios/Sources/{KlarnaPaymentView.m → KlarnaPaymentViewManager.mm} +10 -15
  27. package/ios/Sources/KlarnaStandaloneWebViewManager.h +5 -0
  28. package/ios/Sources/KlarnaStandaloneWebViewManager.mm +77 -0
  29. package/ios/Sources/view/newarch/KlarnaStandaloneWebViewWrapper.h +29 -0
  30. package/ios/Sources/view/newarch/KlarnaStandaloneWebViewWrapper.mm +265 -0
  31. package/ios/Sources/view/newarch/PaymentViewWrapper.h +33 -0
  32. package/ios/Sources/view/newarch/PaymentViewWrapper.mm +240 -0
  33. package/ios/Sources/view/oldarch/KlarnaStandaloneWebViewWrapper.h +42 -0
  34. package/ios/Sources/view/oldarch/KlarnaStandaloneWebViewWrapper.mm +195 -0
  35. package/ios/Sources/view/{PaymentViewWrapper.h → oldarch/PaymentViewWrapper.h} +9 -7
  36. package/ios/Sources/view/{PaymentViewWrapper.m → oldarch/PaymentViewWrapper.mm} +40 -27
  37. package/ios/Tests/PaymentViewWrapperTests.m +8 -10
  38. package/lib/commonjs/KlarnaPaymentView.js +192 -0
  39. package/lib/commonjs/KlarnaPaymentView.js.map +1 -0
  40. package/lib/commonjs/KlarnaStandaloneWebView.js +81 -0
  41. package/lib/commonjs/KlarnaStandaloneWebView.js.map +1 -0
  42. package/lib/commonjs/index.js +28 -0
  43. package/lib/commonjs/index.js.map +1 -0
  44. package/lib/commonjs/specs/KlarnaPaymentViewNativeComponent.js +16 -0
  45. package/lib/commonjs/specs/KlarnaPaymentViewNativeComponent.js.map +1 -0
  46. package/lib/commonjs/specs/KlarnaStandaloneWebViewNativeComponent.js +16 -0
  47. package/lib/commonjs/specs/KlarnaStandaloneWebViewNativeComponent.js.map +1 -0
  48. package/lib/module/KlarnaPaymentView.js +182 -0
  49. package/lib/module/KlarnaPaymentView.js.map +1 -0
  50. package/lib/module/KlarnaStandaloneWebView.js +71 -0
  51. package/lib/module/KlarnaStandaloneWebView.js.map +1 -0
  52. package/lib/module/index.js +3 -0
  53. package/lib/module/index.js.map +1 -0
  54. package/lib/module/specs/KlarnaPaymentViewNativeComponent.js +7 -0
  55. package/lib/module/specs/KlarnaPaymentViewNativeComponent.js.map +1 -0
  56. package/lib/module/specs/KlarnaStandaloneWebViewNativeComponent.js +7 -0
  57. package/lib/module/specs/KlarnaStandaloneWebViewNativeComponent.js.map +1 -0
  58. package/lib/typescript/KlarnaPaymentView.d.ts +51 -0
  59. package/lib/typescript/KlarnaPaymentView.d.ts.map +1 -0
  60. package/lib/typescript/KlarnaStandaloneWebView.d.ts +46 -0
  61. package/lib/typescript/KlarnaStandaloneWebView.d.ts.map +1 -0
  62. package/lib/typescript/index.d.ts +3 -0
  63. package/lib/typescript/index.d.ts.map +1 -0
  64. package/lib/typescript/specs/KlarnaPaymentViewNativeComponent.d.ts +49 -0
  65. package/lib/typescript/specs/KlarnaPaymentViewNativeComponent.d.ts.map +1 -0
  66. package/lib/typescript/specs/KlarnaStandaloneWebViewNativeComponent.d.ts +65 -0
  67. package/lib/typescript/specs/KlarnaStandaloneWebViewNativeComponent.d.ts.map +1 -0
  68. package/package.json +86 -14
  69. package/react-native-klarna-inapp-sdk.podspec +32 -13
  70. package/src/KlarnaPaymentView.tsx +323 -0
  71. package/src/KlarnaStandaloneWebView.tsx +217 -0
  72. package/src/index.tsx +2 -0
  73. package/src/specs/KlarnaPaymentViewNativeComponent.ts +99 -0
  74. package/src/specs/KlarnaStandaloneWebViewNativeComponent.ts +96 -0
  75. package/.gitattributes +0 -3
  76. package/.watchmanconfig +0 -1
  77. package/.yarnrc +0 -5
  78. package/CHANGELOG.md +0 -116
  79. package/android/README.md +0 -14
  80. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  81. package/android/gradle/wrapper/gradle-wrapper.properties +0 -6
  82. package/android/gradlew +0 -172
  83. package/android/gradlew.bat +0 -84
  84. package/android/src/main/java/com/klarna/inapp/sdk/HeightListener.java +0 -159
  85. package/android/src/main/java/com/klarna/inapp/sdk/KlarnaPaymentViewManager.java +0 -282
  86. package/android/src/main/java/com/klarna/inapp/sdk/KlarnaPaymentViewPackage.java +0 -25
  87. package/android/src/main/java/com/klarna/inapp/sdk/Mappable.java +0 -10
  88. package/android/src/main/java/com/klarna/inapp/sdk/MappableKlarnaPaymentsSDKError.java +0 -31
  89. package/android/src/main/java/com/klarna/inapp/sdk/PaymentViewWrapper.java +0 -131
  90. package/android/src/test/java/com/klarna/inapp/sdk/MappableKlarnaPaymentsSDKErrorTest.java +0 -45
  91. package/babel.config.js +0 -3
  92. package/integration-tests/build.gradle +0 -59
  93. package/integration-tests/gradle/wrapper/gradle-wrapper.jar +0 -0
  94. package/integration-tests/gradle/wrapper/gradle-wrapper.properties +0 -6
  95. package/integration-tests/gradlew +0 -172
  96. package/integration-tests/gradlew.bat +0 -84
  97. package/integration-tests/settings.gradle +0 -2
  98. package/integration-tests/src/test/resources/junit-platform.properties +0 -4
  99. package/ios/KlarnaInAppSDK.xcworkspace/contents.xcworkspacedata +0 -10
  100. package/ios/KlarnaInAppSDK.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  101. package/ios/Podfile +0 -73
  102. package/ios/Sources/KlarnaPaymentView.h +0 -5
  103. package/scripts/bootstrap.js +0 -29
  104. package/src/index.js +0 -72
@@ -0,0 +1,96 @@
1
+ import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
2
+ import type { HostComponent } from 'react-native';
3
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
4
+ import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
5
+ import type { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
6
+ import React from 'react';
7
+ import type { Double, Int32 } from 'react-native/Libraries/Types/CodegenTypes';
8
+
9
+ export interface RNKlarnaStandaloneWebViewProps extends ViewProps {
10
+ returnUrl: string;
11
+ onLoadStart: DirectEventHandler<KlarnaWebViewNavigationEvent>;
12
+ onLoadEnd: DirectEventHandler<KlarnaWebViewNavigationEvent>;
13
+ onError: DirectEventHandler<KlarnaWebViewError>;
14
+ onLoadProgress: DirectEventHandler<KlarnaWebViewProgressEvent>;
15
+ onKlarnaMessage: DirectEventHandler<KlarnaWebViewKlarnaMessageEvent>;
16
+ /* Android only */
17
+ onRenderProcessGone: DirectEventHandler<KlarnaWebViewRenderProcessGoneEvent>;
18
+ /* End of Android only */
19
+ }
20
+
21
+ export type KlarnaWebViewNavigationEvent = Readonly<{
22
+ navigationEvent: Readonly<{
23
+ url: string;
24
+ loading: boolean;
25
+ title: string;
26
+ canGoBack: boolean;
27
+ canGoForward: boolean;
28
+ }>;
29
+ }>;
30
+
31
+ type KlarnaWebViewError = Readonly<{
32
+ error: Readonly<{
33
+ url: string;
34
+ loading: boolean;
35
+ title: string;
36
+ canGoBack: boolean;
37
+ canGoForward: boolean;
38
+ code: Int32;
39
+ description: string;
40
+ }>;
41
+ }>;
42
+
43
+ type KlarnaWebViewProgressEvent = Readonly<{
44
+ progressEvent: Readonly<{
45
+ url: string;
46
+ loading: boolean;
47
+ title: string;
48
+ canGoBack: boolean;
49
+ canGoForward: boolean;
50
+ progress: Double;
51
+ }>;
52
+ }>;
53
+
54
+ type KlarnaWebViewKlarnaMessageEvent = Readonly<{
55
+ klarnaMessageEvent: Readonly<{
56
+ action: string;
57
+ // Dictionary is not supported for events
58
+ // params: { [key: string]: any };
59
+ // TODO What is a KlarnaWebViewComponent?
60
+ // component: KlarnaWebViewComponent;
61
+ }>;
62
+ }>;
63
+
64
+ type KlarnaWebViewRenderProcessGoneEvent = Readonly<{
65
+ renderProcessGoneEvent: Readonly<{
66
+ didCrash: boolean;
67
+ }>;
68
+ }>;
69
+
70
+ type KlarnaStandaloneWebViewNativeComponentType =
71
+ HostComponent<RNKlarnaStandaloneWebViewProps>;
72
+
73
+ interface RNKlarnaStandaloneWebViewNativeCommands {
74
+ load: (
75
+ viewRef: React.ElementRef<KlarnaStandaloneWebViewNativeComponentType>,
76
+ url: string
77
+ ) => void;
78
+ goBack: (
79
+ viewRef: React.ElementRef<KlarnaStandaloneWebViewNativeComponentType>
80
+ ) => void;
81
+ goForward: (
82
+ viewRef: React.ElementRef<KlarnaStandaloneWebViewNativeComponentType>
83
+ ) => void;
84
+ reload: (
85
+ viewRef: React.ElementRef<KlarnaStandaloneWebViewNativeComponentType>
86
+ ) => void;
87
+ }
88
+
89
+ export const RNKlarnaStandaloneWebViewCommands: RNKlarnaStandaloneWebViewNativeCommands =
90
+ codegenNativeCommands<RNKlarnaStandaloneWebViewNativeCommands>({
91
+ supportedCommands: ['load', 'goBack', 'goForward', 'reload'],
92
+ });
93
+
94
+ export default codegenNativeComponent<RNKlarnaStandaloneWebViewProps>(
95
+ 'RNKlarnaStandaloneWebView'
96
+ ) as KlarnaStandaloneWebViewNativeComponentType;
package/.gitattributes DELETED
@@ -1,3 +0,0 @@
1
- *.pbxproj -text
2
- # specific for windows script files
3
- *.bat text eol=crlf
package/.watchmanconfig DELETED
@@ -1 +0,0 @@
1
- {}
package/.yarnrc DELETED
@@ -1,5 +0,0 @@
1
- # Override Yarn command so we can automatically setup the repo on running `yarn`
2
-
3
- yarn-path "scripts/bootstrap.js"
4
-
5
- registry "https://registry.yarnpkg.com"
package/CHANGELOG.md DELETED
@@ -1,116 +0,0 @@
1
- # Changelog
2
- All notable changes to React Native Klarna In-App SDK will be documented in this file.
3
-
4
- ### [2.1.13] - 2023-09-19
5
- - Update Android native SDK version to 2.6.8
6
- - Update iOS native SDK version to 2.6.10
7
- - Applied dependabot version updates
8
-
9
- ### [2.1.12] - 2023-05-11
10
- - Update Android native SDK version to 2.6.2
11
- - Applied dependabot version updates
12
-
13
- ### [2.1.11] - 2023-05-09
14
- - Update iOS native SDK version to 2.6.4
15
-
16
- ### [2.1.10] - 2022-12-14
17
- - Update Android native SDK version to 2.4.1
18
- - Update iOS native SDK version to 2.4.1
19
-
20
- ### [2.1.9] - 2022-10-04
21
- - Update Android native SDK version to the latest (2.3.1)
22
-
23
- ### [2.1.8] - 2022-09-20
24
- - Fix react peer dependency (>=16.5.0)
25
- - Add Gradle 7 compatibility
26
-
27
- ### [2.1.7] - 2022-09-12
28
- - Update iOS native SDK version to the latest (2.2.2)
29
- - Update Android native SDK version to the latest (2.2.1)
30
-
31
- ### [2.1.6] - 2022-03-25
32
- - Update Android Gradle plugin version (4.2.0)
33
-
34
- ### [2.1.5] - 2022-03-25
35
- - Update Android Gradle version to the latest (7.4.1)
36
-
37
- ### [2.1.4] - 2022-03-24
38
- - Update iOS SDK version to the latest (2.1.5)
39
-
40
- ### [2.1.3] - 2022-02-10
41
- - Updated Android SDK (2.1.4) & iOS SDK (2.1.4)
42
-
43
- ### [2.1.0] - 2021-11-16
44
- - Update Android SDK & iOS SDK version to the latest (2.1.0)
45
-
46
- ### [2.0.18] - 2021-05-31
47
- - Update Android SDK version to the latest (2.0.39)
48
-
49
- ### [2.0.17] - 2021-03-23
50
- - Update iOS SDK version to the latest (2.0.36)
51
-
52
- ### [2.0.16] - 2020-12-09
53
-
54
- ### [2.0.15] - 2020-12-01
55
- - Added arm64 in EXCLUDED_ARCHS for iOS.
56
-
57
- ### [2.0.14] - 2020-10-30
58
- - Update iOS SDK version to the latest (2.0.28)
59
-
60
- ### [2.0.13] - 2020-10-21
61
- - Update Android SDK version to the latest (2.0.28)
62
-
63
- ### [2.0.12] - 2020-10-21
64
- - Change Android SDK version to 2.0.26
65
-
66
- ### [2.0.11] - 2020-10-08
67
- - Update iOS SDK version to the latest (2.0.24)
68
-
69
- ### [2.0.10] - 2020-09-10
70
- - Update iOS SDK version to the latest (2.0.21)
71
-
72
- ### [2.0.9] - 2020-07-14
73
- - Updated web view height calculation on Android.
74
-
75
- ### [2.0.8] - 2020-06-29
76
- - Fixed a resizing issue on Android when the web view's height was not properly updated.
77
-
78
- ### [2.0.7] - 2020-06-12
79
- - Updated the iOS SDK version to the latest (2.0.17)
80
-
81
- ### [2.0.6] - 2020-06-08
82
- - Updated the parameters of reauthorize and finalize methods.
83
-
84
- ### [2.0.5] - 2020-05-27
85
- - Fixed a resizing issue on Android when the web view's scroll height value was returned null.
86
-
87
- ### [2.0.4] - 2020-05-06
88
- - Updated the iOS SDK version to the latest (2.0.13)
89
-
90
- ### [2.0.3] - 2020-04-27
91
- - Fixed a rendering issue while loading the payment view in Android SDK
92
-
93
- ### [2.0.2] - 2020-04-20
94
- - Updated the iOS SDK version to the latest (2.0.12)
95
- - Updated the Android SDK version to the latest (2.0.16)
96
- - Updated the README file with a note about androidx annotations package
97
- - Update dependencies
98
-
99
- ### [2.0.1] - 2020-03-31
100
- - Update the iOS SDK version to support Swift 5.2
101
-
102
- ### [2.0.0] - 2020-03-06
103
-
104
- ### [1.0.10] - 2020-03-04
105
- - Fixed `No such property: username for class: java.lang.String` build issue for Android.
106
- - Migrate to AndroidX.
107
-
108
- ### [1.0.9] - 2020-02-27
109
- - Updated the iOS SDK version to the latest (2.0.10)
110
-
111
- ### [1.0.8] - 2020-01-14
112
- - Updated the Android SDK version to the latest (2.0.10)
113
-
114
- ### [1.0.7] - 2020-01-08
115
- - Updated the Android SDK package name.
116
- - Updated the Android SDK version to the latest (2.0.9)
package/android/README.md DELETED
@@ -1,14 +0,0 @@
1
- README
2
- ======
3
-
4
- If you want to publish the lib as a maven dependency, follow these steps before publishing a new version to npm:
5
-
6
- 1. Be sure to have the Android [SDK](https://developer.android.com/studio/index.html) and [NDK](https://developer.android.com/ndk/guides/index.html) installed
7
- 2. Be sure to have a `local.properties` file in this folder that points to the Android SDK and NDK
8
- ```
9
- ndk.dir=/Users/{username}/Library/Android/sdk/ndk-bundle
10
- sdk.dir=/Users/{username}/Library/Android/sdk
11
- ```
12
- 3. Delete the `maven` folder
13
- 4. Run `sudo ./gradlew installArchives`
14
- 5. Verify that latest set of generated files is in the maven folder with the correct version number
@@ -1,6 +0,0 @@
1
- #Tue Apr 14 16:23:22 CEST 2020
2
- distributionBase=GRADLE_USER_HOME
3
- distributionPath=wrapper/dists
4
- zipStoreBase=GRADLE_USER_HOME
5
- zipStorePath=wrapper/dists
6
- distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-all.zip
package/android/gradlew DELETED
@@ -1,172 +0,0 @@
1
- #!/usr/bin/env sh
2
-
3
- ##############################################################################
4
- ##
5
- ## Gradle start up script for UN*X
6
- ##
7
- ##############################################################################
8
-
9
- # Attempt to set APP_HOME
10
- # Resolve links: $0 may be a link
11
- PRG="$0"
12
- # Need this for relative symlinks.
13
- while [ -h "$PRG" ] ; do
14
- ls=`ls -ld "$PRG"`
15
- link=`expr "$ls" : '.*-> \(.*\)$'`
16
- if expr "$link" : '/.*' > /dev/null; then
17
- PRG="$link"
18
- else
19
- PRG=`dirname "$PRG"`"/$link"
20
- fi
21
- done
22
- SAVED="`pwd`"
23
- cd "`dirname \"$PRG\"`/" >/dev/null
24
- APP_HOME="`pwd -P`"
25
- cd "$SAVED" >/dev/null
26
-
27
- APP_NAME="Gradle"
28
- APP_BASE_NAME=`basename "$0"`
29
-
30
- # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31
- DEFAULT_JVM_OPTS=""
32
-
33
- # Use the maximum available, or set MAX_FD != -1 to use that value.
34
- MAX_FD="maximum"
35
-
36
- warn () {
37
- echo "$*"
38
- }
39
-
40
- die () {
41
- echo
42
- echo "$*"
43
- echo
44
- exit 1
45
- }
46
-
47
- # OS specific support (must be 'true' or 'false').
48
- cygwin=false
49
- msys=false
50
- darwin=false
51
- nonstop=false
52
- case "`uname`" in
53
- CYGWIN* )
54
- cygwin=true
55
- ;;
56
- Darwin* )
57
- darwin=true
58
- ;;
59
- MINGW* )
60
- msys=true
61
- ;;
62
- NONSTOP* )
63
- nonstop=true
64
- ;;
65
- esac
66
-
67
- CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68
-
69
- # Determine the Java command to use to start the JVM.
70
- if [ -n "$JAVA_HOME" ] ; then
71
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72
- # IBM's JDK on AIX uses strange locations for the executables
73
- JAVACMD="$JAVA_HOME/jre/sh/java"
74
- else
75
- JAVACMD="$JAVA_HOME/bin/java"
76
- fi
77
- if [ ! -x "$JAVACMD" ] ; then
78
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79
-
80
- Please set the JAVA_HOME variable in your environment to match the
81
- location of your Java installation."
82
- fi
83
- else
84
- JAVACMD="java"
85
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86
-
87
- Please set the JAVA_HOME variable in your environment to match the
88
- location of your Java installation."
89
- fi
90
-
91
- # Increase the maximum file descriptors if we can.
92
- if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93
- MAX_FD_LIMIT=`ulimit -H -n`
94
- if [ $? -eq 0 ] ; then
95
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96
- MAX_FD="$MAX_FD_LIMIT"
97
- fi
98
- ulimit -n $MAX_FD
99
- if [ $? -ne 0 ] ; then
100
- warn "Could not set maximum file descriptor limit: $MAX_FD"
101
- fi
102
- else
103
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104
- fi
105
- fi
106
-
107
- # For Darwin, add options to specify how the application appears in the dock
108
- if $darwin; then
109
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110
- fi
111
-
112
- # For Cygwin, switch paths to Windows format before running java
113
- if $cygwin ; then
114
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116
- JAVACMD=`cygpath --unix "$JAVACMD"`
117
-
118
- # We build the pattern for arguments to be converted via cygpath
119
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120
- SEP=""
121
- for dir in $ROOTDIRSRAW ; do
122
- ROOTDIRS="$ROOTDIRS$SEP$dir"
123
- SEP="|"
124
- done
125
- OURCYGPATTERN="(^($ROOTDIRS))"
126
- # Add a user-defined pattern to the cygpath arguments
127
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129
- fi
130
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
131
- i=0
132
- for arg in "$@" ; do
133
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135
-
136
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138
- else
139
- eval `echo args$i`="\"$arg\""
140
- fi
141
- i=$((i+1))
142
- done
143
- case $i in
144
- (0) set -- ;;
145
- (1) set -- "$args0" ;;
146
- (2) set -- "$args0" "$args1" ;;
147
- (3) set -- "$args0" "$args1" "$args2" ;;
148
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154
- esac
155
- fi
156
-
157
- # Escape application args
158
- save () {
159
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160
- echo " "
161
- }
162
- APP_ARGS=$(save "$@")
163
-
164
- # Collect all arguments for the java command, following the shell quoting and substitution rules
165
- eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166
-
167
- # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168
- if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169
- cd "$(dirname "$0")"
170
- fi
171
-
172
- exec "$JAVACMD" "$@"
@@ -1,84 +0,0 @@
1
- @if "%DEBUG%" == "" @echo off
2
- @rem ##########################################################################
3
- @rem
4
- @rem Gradle startup script for Windows
5
- @rem
6
- @rem ##########################################################################
7
-
8
- @rem Set local scope for the variables with windows NT shell
9
- if "%OS%"=="Windows_NT" setlocal
10
-
11
- set DIRNAME=%~dp0
12
- if "%DIRNAME%" == "" set DIRNAME=.
13
- set APP_BASE_NAME=%~n0
14
- set APP_HOME=%DIRNAME%
15
-
16
- @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17
- set DEFAULT_JVM_OPTS=
18
-
19
- @rem Find java.exe
20
- if defined JAVA_HOME goto findJavaFromJavaHome
21
-
22
- set JAVA_EXE=java.exe
23
- %JAVA_EXE% -version >NUL 2>&1
24
- if "%ERRORLEVEL%" == "0" goto init
25
-
26
- echo.
27
- echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28
- echo.
29
- echo Please set the JAVA_HOME variable in your environment to match the
30
- echo location of your Java installation.
31
-
32
- goto fail
33
-
34
- :findJavaFromJavaHome
35
- set JAVA_HOME=%JAVA_HOME:"=%
36
- set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37
-
38
- if exist "%JAVA_EXE%" goto init
39
-
40
- echo.
41
- echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42
- echo.
43
- echo Please set the JAVA_HOME variable in your environment to match the
44
- echo location of your Java installation.
45
-
46
- goto fail
47
-
48
- :init
49
- @rem Get command-line arguments, handling Windows variants
50
-
51
- if not "%OS%" == "Windows_NT" goto win9xME_args
52
-
53
- :win9xME_args
54
- @rem Slurp the command line arguments.
55
- set CMD_LINE_ARGS=
56
- set _SKIP=2
57
-
58
- :win9xME_args_slurp
59
- if "x%~1" == "x" goto execute
60
-
61
- set CMD_LINE_ARGS=%*
62
-
63
- :execute
64
- @rem Setup the command line
65
-
66
- set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67
-
68
- @rem Execute Gradle
69
- "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70
-
71
- :end
72
- @rem End local scope for the variables with windows NT shell
73
- if "%ERRORLEVEL%"=="0" goto mainEnd
74
-
75
- :fail
76
- rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77
- rem the _cmd.exe /c_ return code!
78
- if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79
- exit /b 1
80
-
81
- :mainEnd
82
- if "%OS%"=="Windows_NT" endlocal
83
-
84
- :omega
@@ -1,159 +0,0 @@
1
- package com.klarna.inapp.sdk;
2
-
3
- import android.os.Build;
4
- import android.webkit.JavascriptInterface;
5
- import android.webkit.ValueCallback;
6
- import android.webkit.WebView;
7
-
8
- import java.lang.ref.WeakReference;
9
- import java.util.concurrent.atomic.AtomicBoolean;
10
-
11
- /**
12
- * Used by the PaymentViewWrapper class to inject JS and listen to height changes inside the WebView
13
- */
14
- public class HeightListener {
15
- private final String heightScript = "getAndroidHeight()";
16
- private final AtomicBoolean attachedEventObserver = new AtomicBoolean(false);
17
- private WeakReference<HeightListenerCallback> callback;
18
-
19
- HeightListener(WebView webView, HeightListenerCallback callback) {
20
- this.callback = new WeakReference<>(callback);
21
- webView.addJavascriptInterface(this, "AndroidEventObserver");
22
- }
23
-
24
- /**
25
- * Injects the script that fetches the height value
26
- *
27
- * @param webView The web view instance to inject the script into
28
- */
29
- void injectListener(WebView webView) {
30
- injectScript(webView, getHeightFuncScript());
31
- }
32
-
33
- /**
34
- * Calls the height function which was injected to the web view and
35
- * send the value back to the wrapper
36
- *
37
- * @param webView The web view to fetch its height value
38
- */
39
- void fetchHeight(final WebView webView) {
40
- if (webView == null) {
41
- return;
42
- }
43
- webView.evaluateJavascript(heightScript, new ValueCallback<String>() {
44
- @Override
45
- public void onReceiveValue(String value) {
46
- if (!attachedEventObserver.get()) {
47
- attachEventObserver(webView);
48
- }
49
- sendHeightValue(value);
50
- }
51
- });
52
- }
53
-
54
- /**
55
- * Attaches 'resize' event listener to the web view's window object and
56
- * calls the height function when there is a resize event, then send the height value
57
- * back to the wrapper
58
- *
59
- * @param webView The web view to attach the 'resize' listener to
60
- */
61
- private void attachEventObserver(WebView webView) {
62
- String eventListenerScript =
63
- "try{" +
64
- "window.addEventListener('resize', function() { AndroidEventObserver.onResized(" + heightScript + "); });" +
65
- "}catch(error){" +
66
- "console.log('Failed to attach AndroidEventObserver: ' + error);" +
67
- "}";
68
- evaluateJSCompat(webView, eventListenerScript);
69
- }
70
-
71
- /**
72
- * Injects the given script into the given web view object
73
- *
74
- * @param webView The web view to inject the script into
75
- * @param script The script to inject into the web view
76
- */
77
- private void injectScript(WebView webView, String script) {
78
- try {
79
- evaluateJSCompat(webView, "(function() {" +
80
- "var parent = document.getElementsByTagName('head').item(0);" +
81
- "var script = document.createElement('script');" +
82
- "script.type = 'text/javascript';" +
83
- "script.innerHTML = " + script + ";" +
84
- "parent.appendChild(script)" +
85
- "})()");
86
- } catch (Throwable t) {
87
- }
88
- }
89
-
90
- /**
91
- * The javascript interface method that is called when there's a
92
- * 'resize' event
93
- *
94
- * @param value The height value which is sent from the 'resize' listener
95
- */
96
- @JavascriptInterface
97
- public void onResized(final String value) {
98
- attachedEventObserver.set(true);
99
- sendHeightValue(value);
100
- }
101
-
102
- /**
103
- * Unwraps and null checks the callback object and sends
104
- * the height value to wrapper through this callback
105
- *
106
- * @param value The updated height value to send to wrapper
107
- */
108
- private void sendHeightValue(String value) {
109
- if (callback != null) {
110
- HeightListenerCallback callbackInstance = callback.get();
111
- if (callbackInstance != null) {
112
- callbackInstance.onNewHeight(value);
113
- }
114
- }
115
- }
116
-
117
- /**
118
- * Returns the height function to be injected as a script into the web view
119
- *
120
- * @return The height function in JS
121
- */
122
- private String getHeightFuncScript() {
123
- return
124
- "function getAndroidHeight(){\n" +
125
- " var heights = new Array();\n" +
126
- " var bodyHeight = document.body.scrollHeight;\n" +
127
- " bodyHeight > 0 && heights.push(bodyHeight);\n" +
128
- " var docHeight = document.documentElement.scrollHeight;\n" +
129
- " docHeight > 0 && heights.push(docHeight);\n" +
130
- " try{\n" +
131
- " var containerHeight = document.getElementById('payment-container').scrollHeight;\n" +
132
- " containerHeight > 0 && heights.push(containerHeight);\n" +
133
- " } catch(error){}\n" +
134
- " return heights.length > 0 ? Math.min.apply(Math,heights) : 0;\n" +
135
- "}";
136
- }
137
-
138
- /**
139
- * Evaluates a script inside a web view in a backward-compatible manner
140
- *
141
- * @param webView The web view to evaluate the script
142
- * @param script The script to be evaluated
143
- */
144
- private void evaluateJSCompat(WebView webView, String script) {
145
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
146
- webView.evaluateJavascript(script, null);
147
- } else {
148
- webView.loadUrl("javascript:" + script);
149
- }
150
- }
151
-
152
- /**
153
- * The interface between the wrapper and listener class
154
- * to send the updated height values
155
- */
156
- public interface HeightListenerCallback {
157
- void onNewHeight(String value);
158
- }
159
- }