Browse Source

增加录屏截屏事件控制

Pq 2 years ago
parent
commit
08909bd979

+ 2 - 0
BaseLibrary/src/main/java/com/cooleshow/base/common/WebApi.java

@@ -10,5 +10,7 @@ public class WebApi {
     public static final String OPEN_PAGE_SUCCESS = "openPageSuccess";
     //事件埋点
     public static final String SET_EVENT_TRACKING = "setEventTracking";
+    //屏幕录屏限制开关
+    public static final String LIMIT_SCREEN_RECORD = "limitScreenRecord";
     public static final String WITHDRAW_TAG = "WITHDRAW";
 }

+ 15 - 0
student/src/main/java/com/cooleshow/student/widgets/helper/JsInterfaceAccomPanyUtils.java

@@ -325,6 +325,21 @@ public class JsInterfaceAccomPanyUtils extends Object {
                     }
                     return;
                 }
+
+                if (TextUtils.equals(WebApi.LIMIT_SCREEN_RECORD, api)) {
+                    //录屏截屏事件控制
+                    JSONObject content = jsonObject.getJSONObject("content");
+                    String type = content.optString("type");
+                    if (activity == null) {
+                        return;
+                    }
+                    if (TextUtils.equals(type, "1")) {
+                        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
+                    } else {
+                        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
+                    }
+                    return;
+                }
             } catch (Exception e) {
 
             }

+ 19 - 2
student/src/main/java/com/cooleshow/student/widgets/helper/JsInterfaceUtils.java

@@ -6,6 +6,7 @@ import android.app.Activity;
 import android.content.Intent;
 import android.net.Uri;
 import android.text.TextUtils;
+import android.util.Log;
 import android.view.Window;
 import android.view.WindowManager;
 import android.webkit.JavascriptInterface;
@@ -239,7 +240,7 @@ public class JsInterfaceUtils extends Object {
                     JSONObject content = jsonObject.getJSONObject("content");
 
                     if (onListener != null) {
-                        onListener.savePicture(content.getString("base64"),content.getString("uuid"));
+                        onListener.savePicture(content.getString("base64"), content.getString("uuid"));
                     }
                 }
 
@@ -252,6 +253,21 @@ public class JsInterfaceUtils extends Object {
                     }
                     return;
                 }
+
+                if (TextUtils.equals(WebApi.LIMIT_SCREEN_RECORD, api)) {
+                    //录屏截屏事件控制
+                    JSONObject content = jsonObject.getJSONObject("content");
+                    String type = content.optString("type");
+                    if (activity == null) {
+                        return;
+                    }
+                    if (TextUtils.equals(type, "1")) {
+                        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
+                    } else {
+                        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
+                    }
+                    return;
+                }
             } catch (Exception e) {
             }
         });
@@ -349,9 +365,10 @@ public class JsInterfaceUtils extends Object {
 
         /**
          * 保存图片
+         *
          * @param base64
          */
-        void savePicture(String base64,String uuid);
+        void savePicture(String base64, String uuid);
     }
 
 }

+ 15 - 0
teacher/src/main/java/com/cooleshow/teacher/widgets/helper/JsInterfaceAccomPanyUtils.java

@@ -322,6 +322,21 @@ public class JsInterfaceAccomPanyUtils extends Object {
                     }
                     return;
                 }
+
+                if (TextUtils.equals(WebApi.LIMIT_SCREEN_RECORD, api)) {
+                    //录屏截屏事件控制
+                    JSONObject content = jsonObject.getJSONObject("content");
+                    String type = content.optString("type");
+                    if (activity == null) {
+                        return;
+                    }
+                    if (TextUtils.equals(type, "1")) {
+                        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
+                    } else {
+                        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
+                    }
+                    return;
+                }
             } catch (Exception e) {
 
             }

+ 15 - 0
teacher/src/main/java/com/cooleshow/teacher/widgets/helper/JsInterfaceUtils.java

@@ -300,6 +300,21 @@ public class JsInterfaceUtils extends Object {
                     }
                     return;
                 }
+
+                if (TextUtils.equals(WebApi.LIMIT_SCREEN_RECORD, api)) {
+                    //录屏截屏事件控制
+                    JSONObject content = jsonObject.getJSONObject("content");
+                    String type = content.optString("type");
+                    if (activity == null) {
+                        return;
+                    }
+                    if (TextUtils.equals(type, "1")) {
+                        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
+                    } else {
+                        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
+                    }
+                    return;
+                }
             } catch (Exception e) {
             }
         });