Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

handle exception when setting secure mode

ammarahm-ed7b5e33c7baa3
diff --git a/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/RCTNNativeModule.java b/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/RCTNNativeModule.java
index 5ad5234e2..43df807c2 100644
--- a/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/RCTNNativeModule.java
+++ b/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/RCTNNativeModule.java
@@ -7,6 +7,7 @@ import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactMethod;
+;
public class RCTNNativeModule extends ReactContextBaseJavaModule {
@@ -16,7 +17,6 @@ public class RCTNNativeModule extends ReactContextBaseJavaModule {
public RCTNNativeModule(ReactApplicationContext reactContext) {
super(reactContext);
mContext = reactContext;
-
}
@Override
@@ -24,21 +24,25 @@ public class RCTNNativeModule extends ReactContextBaseJavaModule {
return "NNativeModule";
}
+
@ReactMethod
public void setSecureMode(final boolean mode) {
- mContext.getCurrentActivity().runOnUiThread(new Runnable() {
- @Override
- public void run() {
- if (mode) {
- mContext.getCurrentActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
- } else {
- mContext.getCurrentActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
- }
- }
- });
+ try {
+ getCurrentActivity().runOnUiThread(() -> {
+
+ try {
+ if (mode)
+ getCurrentActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
+ else
+ getCurrentActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
+ } catch (Exception e) {
+ }
+ });
+ } catch (Exception e) {
+ }
}