react-native-security-suite 0.9.5 → 0.9.7

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.
@@ -1,9 +1,14 @@
1
1
  package com.securitysuite;
2
2
 
3
- import android.content.Context;
3
+ import android.app.Activity;
4
4
  import android.graphics.Color;
5
+ import android.view.View;
6
+ import android.view.Window;
7
+ import android.view.WindowManager;
5
8
  import android.widget.FrameLayout;
9
+ import android.content.Context;
6
10
 
11
+ import com.facebook.react.bridge.ReactApplicationContext;
7
12
  import com.facebook.react.bridge.ReadableMap;
8
13
  import com.facebook.react.bridge.ReadableType;
9
14
  import com.facebook.react.uimanager.ThemedReactContext;
@@ -11,8 +16,11 @@ import com.facebook.react.uimanager.UIManagerModule;
11
16
  import com.facebook.react.uimanager.annotations.ReactProp;
12
17
 
13
18
  public class SecureView extends FrameLayout {
14
- public SecureView(Context context) {
19
+ ReactApplicationContext reactContext;
20
+
21
+ public SecureView(Context context, ReactApplicationContext reactContext) {
15
22
  super(context);
23
+ this.reactContext = reactContext;
16
24
  }
17
25
 
18
26
  @Override
@@ -21,6 +29,35 @@ public class SecureView extends FrameLayout {
21
29
  post(measureAndLayout);
22
30
  }
23
31
 
32
+ @Override
33
+ protected void onAttachedToWindow() {
34
+ super.onAttachedToWindow();
35
+ final Activity activity = reactContext.getCurrentActivity();
36
+ if (activity != null) {
37
+ activity.runOnUiThread(() -> {
38
+ Window window = activity.getWindow();
39
+ window.addFlags(WindowManager.LayoutParams.FLAG_SECURE);
40
+ });
41
+ }
42
+ }
43
+
44
+ @Override
45
+ protected void onDetachedFromWindow() {
46
+ super.onDetachedFromWindow();
47
+ final Activity activity = reactContext.getCurrentActivity();
48
+ if (activity != null) {
49
+ activity.runOnUiThread(() -> {
50
+ Window window = activity.getWindow();
51
+ window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
52
+ });
53
+ }
54
+ }
55
+
56
+ @Override
57
+ public void addView(View child, int index) {
58
+ super.addView(child, index);
59
+ }
60
+
24
61
  private final Runnable measureAndLayout = () -> {
25
62
  measure(
26
63
  MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY),
@@ -2,7 +2,6 @@ package com.securitysuite;
2
2
 
3
3
  import android.app.Activity;
4
4
  import android.os.Bundle;
5
- import android.util.Log;
6
5
  import android.view.LayoutInflater;
7
6
  import android.view.View;
8
7
  import android.view.ViewGroup;
@@ -13,11 +12,10 @@ import androidx.annotation.Nullable;
13
12
  import androidx.fragment.app.Fragment;
14
13
 
15
14
  import com.facebook.react.bridge.ReactApplicationContext;
16
- import com.facebook.react.bridge.ReactContext;
17
15
 
18
16
  public class SecureViewFragment extends Fragment {
19
17
  SecureView secureView;
20
- ReactContext reactContext;
18
+ ReactApplicationContext reactContext;
21
19
 
22
20
  public SecureViewFragment(ReactApplicationContext reactContext) {
23
21
  this.reactContext = reactContext;
@@ -26,16 +24,14 @@ public class SecureViewFragment extends Fragment {
26
24
  @Override
27
25
  public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
28
26
  super.onCreateView(inflater, parent, savedInstanceState);
29
- secureView = new SecureView(this.getContext());
27
+ secureView = new SecureView(this.getContext(), this.reactContext);
30
28
  return secureView;
31
29
  }
32
30
 
33
31
  @Override
34
32
  public void onCreate(@Nullable Bundle savedInstanceState) {
35
33
  super.onCreate(savedInstanceState);
36
- Log.d("SecureViewFragment", "onCreate 11111");
37
- final Activity activity = reactContext.getCurrentActivity();
38
- Log.d("SecureViewFragment", String.valueOf(activity));
34
+ final Activity activity = getActivity();
39
35
  if (activity != null) {
40
36
  activity.runOnUiThread(new Runnable() {
41
37
  @Override
@@ -50,9 +46,7 @@ public class SecureViewFragment extends Fragment {
50
46
  @Override
51
47
  public void onDestroy() {
52
48
  super.onDestroy();
53
- Log.d("SecureViewFragment", "onDestroy 11111");
54
-
55
- final Activity activity = reactContext.getCurrentActivity();
49
+ final Activity activity = getActivity();
56
50
  if (activity != null) {
57
51
  activity.runOnUiThread(new Runnable() {
58
52
  @Override
@@ -37,9 +37,10 @@ public class SecureViewManager extends ViewGroupManager<SecureView> {
37
37
  return REACT_CLASS;
38
38
  }
39
39
 
40
+ @NonNull
40
41
  @Override
41
- public SecureView createViewInstance(ThemedReactContext reactContext) {
42
- return new SecureView(reactContext);
42
+ protected SecureView createViewInstance(@NonNull ThemedReactContext themedReactContext) {
43
+ return new SecureView(themedReactContext, reactContext);
43
44
  }
44
45
 
45
46
  @Nullable
@@ -58,6 +59,17 @@ public class SecureViewManager extends ViewGroupManager<SecureView> {
58
59
  }
59
60
  }
60
61
 
62
+ @Override
63
+ public boolean needsCustomLayoutForChildren() {
64
+ return true;
65
+ }
66
+
67
+ @Override
68
+ public void onAfterUpdateTransaction(@NonNull SecureView view) {
69
+ super.onAfterUpdateTransaction(view);
70
+ view.requestLayout();
71
+ }
72
+
61
73
  public void createFragment(FrameLayout root, int reactNativeViewId) {
62
74
  ViewGroup parentView = (ViewGroup) root.findViewById(reactNativeViewId);
63
75
  if (parentView == null) {
@@ -66,7 +78,7 @@ public class SecureViewManager extends ViewGroupManager<SecureView> {
66
78
  }
67
79
  setupLayout(parentView);
68
80
 
69
- final SecureViewFragment secureViewFragment = new SecureViewFragment();
81
+ final SecureViewFragment secureViewFragment = new SecureViewFragment(reactContext);
70
82
  FragmentActivity activity = (FragmentActivity) reactContext.getCurrentActivity();
71
83
  if (activity == null) {
72
84
  Log.e("SecureViewManager", "Activity is null");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-security-suite",
3
- "version": "0.9.5",
3
+ "version": "0.9.7",
4
4
  "description": "Security solution for React Native",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",