@sodyo/react-native-sodyo-sdk 3.12.0 → 4.0.0
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/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
[SodyoSDK for iOS](https://github.com/sodyo-ltd/SodyoSDKPod) v3.64.02
|
|
5
5
|
|
|
6
|
-
[SodyoSDK for Android](https://search.maven.org/search?q=a:sodyo-android-sdk) 3.
|
|
6
|
+
[SodyoSDK for Android](https://search.maven.org/search?q=a:sodyo-android-sdk) 3.65.18
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
## Install
|
package/android/build.gradle
CHANGED
|
@@ -55,7 +55,7 @@ repositories {
|
|
|
55
55
|
|
|
56
56
|
dependencies {
|
|
57
57
|
implementation ('com.facebook.react:react-native:+')
|
|
58
|
-
implementation ('com.sodyo:sodyo-android-sdk:3.
|
|
58
|
+
implementation ('com.sodyo:sodyo-android-sdk:3.65.20') {
|
|
59
59
|
transitive = true
|
|
60
60
|
exclude group: 'com.parse.bolts', module: 'bolts-android'
|
|
61
61
|
}
|
|
@@ -1,113 +1,110 @@
|
|
|
1
|
-
|
|
2
1
|
package com.sodyo.RNSodyoSDK;
|
|
3
2
|
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
import androidx.fragment.app.Fragment;
|
|
6
|
+
import androidx.fragment.app.FragmentActivity;
|
|
7
|
+
import androidx.fragment.app.FragmentManager;
|
|
8
|
+
import androidx.fragment.app.FragmentTransaction;
|
|
9
|
+
|
|
10
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
4
11
|
import com.facebook.react.uimanager.SimpleViewManager;
|
|
5
12
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
6
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
13
|
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
8
14
|
|
|
9
15
|
import android.util.Log;
|
|
10
16
|
import android.widget.FrameLayout;
|
|
11
|
-
import android.app.Fragment;
|
|
12
|
-
import android.app.FragmentManager;
|
|
13
|
-
import android.app.FragmentTransaction;
|
|
14
|
-
import android.app.Activity;
|
|
15
|
-
|
|
16
|
-
import javax.annotation.Nullable;
|
|
17
17
|
|
|
18
18
|
import com.sodyo.sdk.SodyoScannerFragment;
|
|
19
19
|
|
|
20
20
|
public class RNSodyoSdkView extends SimpleViewManager<FrameLayout> {
|
|
21
|
-
static final String TAG = "RNSodyoSdkView";
|
|
22
|
-
|
|
23
|
-
static final String TAG_FRAGMENT = "SODYO_SCANNER";
|
|
24
|
-
|
|
21
|
+
private static final String TAG = "RNSodyoSdkView";
|
|
22
|
+
private static final String TAG_FRAGMENT = "SODYO_SCANNER";
|
|
25
23
|
public static final String REACT_CLASS = "RNSodyoSdkView";
|
|
26
24
|
|
|
27
25
|
private final @Nullable ReactApplicationContext mCallerContext;
|
|
28
|
-
|
|
29
26
|
private @Nullable SodyoScannerFragment sodyoFragment;
|
|
30
|
-
|
|
31
27
|
private boolean isCameraEnabled = true;
|
|
32
28
|
|
|
29
|
+
public RNSodyoSdkView(ReactApplicationContext callerContext) {
|
|
30
|
+
mCallerContext = callerContext;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@NonNull
|
|
33
34
|
@Override
|
|
34
35
|
public String getName() {
|
|
35
36
|
return REACT_CLASS;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
mCallerContext = callerContext;
|
|
40
|
-
}
|
|
41
|
-
|
|
39
|
+
@NonNull
|
|
42
40
|
@Override
|
|
43
|
-
public FrameLayout createViewInstance(ThemedReactContext context) {
|
|
44
|
-
Log.i(TAG,"createViewInstance");
|
|
41
|
+
public FrameLayout createViewInstance(@NonNull ThemedReactContext context) {
|
|
42
|
+
Log.i(TAG, "createViewInstance");
|
|
45
43
|
|
|
46
44
|
final FrameLayout view = new FrameLayout(context);
|
|
47
45
|
|
|
48
|
-
|
|
49
|
-
Activity currentActivity = mCallerContext.getCurrentActivity();
|
|
46
|
+
FragmentActivity currentActivity = (FragmentActivity) mCallerContext.getCurrentActivity();
|
|
50
47
|
if (currentActivity == null) {
|
|
51
|
-
// Handle the situation when the activity is null
|
|
52
48
|
Log.e(TAG, "Current activity is null, cannot initialize SodyoScannerFragment");
|
|
53
|
-
// Consider providing user feedback or a fallback mechanism
|
|
54
49
|
return view;
|
|
55
50
|
}
|
|
56
51
|
|
|
57
|
-
// Proceed with initialization as the activity is not null
|
|
58
52
|
if (sodyoFragment == null) {
|
|
59
|
-
Log.i(TAG,"init SodyoScannerFragment");
|
|
53
|
+
Log.i(TAG, "init SodyoScannerFragment");
|
|
60
54
|
sodyoFragment = new SodyoScannerFragment();
|
|
61
55
|
}
|
|
62
56
|
|
|
63
|
-
|
|
64
|
-
FragmentManager fragmentManager = currentActivity.getFragmentManager();
|
|
57
|
+
FragmentManager fragmentManager = currentActivity.getSupportFragmentManager();
|
|
65
58
|
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
|
66
59
|
|
|
67
60
|
fragmentTransaction.add(sodyoFragment, TAG_FRAGMENT).commitAllowingStateLoss();
|
|
68
61
|
fragmentManager.executePendingTransactions();
|
|
69
62
|
|
|
70
|
-
view.addView(sodyoFragment.getView(),
|
|
63
|
+
view.addView(sodyoFragment.getView(), new FrameLayout.LayoutParams(
|
|
64
|
+
FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
|
|
71
65
|
return view;
|
|
72
66
|
}
|
|
73
67
|
|
|
74
68
|
@Override
|
|
75
|
-
public void onDropViewInstance(FrameLayout view) {
|
|
69
|
+
public void onDropViewInstance(@NonNull FrameLayout view) {
|
|
76
70
|
super.onDropViewInstance(view);
|
|
77
71
|
|
|
78
|
-
Log.i(TAG,"onDropViewInstance");
|
|
72
|
+
Log.i(TAG, "onDropViewInstance");
|
|
79
73
|
|
|
80
74
|
sodyoFragment = null;
|
|
81
75
|
isCameraEnabled = true;
|
|
82
76
|
|
|
83
77
|
try {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
78
|
+
FragmentActivity currentActivity = (FragmentActivity) mCallerContext.getCurrentActivity();
|
|
79
|
+
if (currentActivity != null) {
|
|
80
|
+
FragmentManager fragmentManager = currentActivity.getSupportFragmentManager();
|
|
81
|
+
Fragment fragment = fragmentManager.findFragmentByTag(TAG_FRAGMENT);
|
|
82
|
+
|
|
83
|
+
if (fragment != null) {
|
|
84
|
+
fragmentManager.beginTransaction().remove(fragment).commitAllowingStateLoss();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
90
87
|
} catch (Exception e) {
|
|
91
|
-
|
|
88
|
+
Log.e(TAG, "Error dropping view instance", e);
|
|
92
89
|
}
|
|
93
90
|
}
|
|
94
91
|
|
|
95
|
-
@ReactProp(name = "isEnabled", defaultBoolean=true)
|
|
92
|
+
@ReactProp(name = "isEnabled", defaultBoolean = true)
|
|
96
93
|
public void setIsEnabled(FrameLayout view, boolean isEnabled) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
if (sodyoFragment == null) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
100
97
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
98
|
+
if (isEnabled && !isCameraEnabled) {
|
|
99
|
+
Log.i(TAG, "start camera");
|
|
100
|
+
isCameraEnabled = true;
|
|
101
|
+
sodyoFragment.startCamera();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (!isEnabled && isCameraEnabled) {
|
|
105
|
+
Log.i(TAG, "stop camera");
|
|
106
|
+
isCameraEnabled = false;
|
|
107
|
+
sodyoFragment.stopCamera();
|
|
108
|
+
}
|
|
112
109
|
}
|
|
113
110
|
}
|