react-native-security-suite 0.9.5 → 0.9.6
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,13 @@
|
|
|
1
1
|
package com.securitysuite;
|
|
2
2
|
|
|
3
|
-
import android.
|
|
3
|
+
import android.app.Activity;
|
|
4
4
|
import android.graphics.Color;
|
|
5
|
+
import android.view.Window;
|
|
6
|
+
import android.view.WindowManager;
|
|
5
7
|
import android.widget.FrameLayout;
|
|
8
|
+
import android.content.Context;
|
|
6
9
|
|
|
10
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
11
|
import com.facebook.react.bridge.ReadableMap;
|
|
8
12
|
import com.facebook.react.bridge.ReadableType;
|
|
9
13
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
@@ -11,8 +15,11 @@ import com.facebook.react.uimanager.UIManagerModule;
|
|
|
11
15
|
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
12
16
|
|
|
13
17
|
public class SecureView extends FrameLayout {
|
|
14
|
-
|
|
18
|
+
ReactApplicationContext reactContext;
|
|
19
|
+
|
|
20
|
+
public SecureView(Context context, ReactApplicationContext reactContext) {
|
|
15
21
|
super(context);
|
|
22
|
+
this.reactContext = reactContext;
|
|
16
23
|
}
|
|
17
24
|
|
|
18
25
|
@Override
|
|
@@ -21,6 +28,36 @@ public class SecureView extends FrameLayout {
|
|
|
21
28
|
post(measureAndLayout);
|
|
22
29
|
}
|
|
23
30
|
|
|
31
|
+
@Override
|
|
32
|
+
protected void onAttachedToWindow() {
|
|
33
|
+
super.onAttachedToWindow();
|
|
34
|
+
final Activity activity = reactContext.getCurrentActivity();
|
|
35
|
+
if (activity != null) {
|
|
36
|
+
activity.runOnUiThread(new Runnable() {
|
|
37
|
+
@Override
|
|
38
|
+
public void run() {
|
|
39
|
+
Window window = activity.getWindow();
|
|
40
|
+
window.addFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Override
|
|
47
|
+
protected void onDetachedFromWindow() {
|
|
48
|
+
super.onDetachedFromWindow();
|
|
49
|
+
final Activity activity = reactContext.getCurrentActivity();
|
|
50
|
+
if (activity != null) {
|
|
51
|
+
activity.runOnUiThread(new Runnable() {
|
|
52
|
+
@Override
|
|
53
|
+
public void run() {
|
|
54
|
+
Window window = activity.getWindow();
|
|
55
|
+
window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
@@ -66,7 +67,7 @@ public class SecureViewManager extends ViewGroupManager<SecureView> {
|
|
|
66
67
|
}
|
|
67
68
|
setupLayout(parentView);
|
|
68
69
|
|
|
69
|
-
final SecureViewFragment secureViewFragment = new SecureViewFragment();
|
|
70
|
+
final SecureViewFragment secureViewFragment = new SecureViewFragment(reactContext);
|
|
70
71
|
FragmentActivity activity = (FragmentActivity) reactContext.getCurrentActivity();
|
|
71
72
|
if (activity == null) {
|
|
72
73
|
Log.e("SecureViewManager", "Activity is null");
|