Ver código fonte

【2025】【Protect】 Redact,点击应用后没有提示修复

lizhe 1 mês atrás
pai
commit
b7302236be

+ 26 - 0
PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift

@@ -729,6 +729,8 @@ struct KMNMWCFlags {
                 //密文
                 listView.annotationType = .redact
                 listView.toolMode = .CRedactToolMode
+                
+                self.enterRedactAlert()
             } else if subToolMode == .Digital_Sign {
                 //数字签名
                 listView.annotationType = .digitalSign
@@ -7363,6 +7365,30 @@ extension KMMainViewController {
         }
     }
     
+    func enterRedactAlert() {
+        if UserDefaults.standard.object(forKey: "kRedact") != nil {
+            return
+        }
+        let alert = NSAlert()
+        alert.alertStyle = .informational
+        alert.informativeText = KMLocalizedString("Redaction allows you to permanently mask and remove sensitive content.")
+        alert.messageText = KMLocalizedString("""
+                                              Redaction requires two steps:
+                                              1. Mark for Redaction
+                                              2. Apply Redactions
+
+                                              Note: Redactions are not applied permanently until you select Apply Redactions.
+                                              """)
+        alert.addButton(withTitle: KMLocalizedString("OK"))
+        alert.showsSuppressionButton = true
+        let response = alert.runModal()
+        if response.rawValue == 1000 {
+            if alert.suppressionButton?.state == .on {
+                UserDefaults.standard.set("YES", forKey: "kRedact")
+                UserDefaults.standard.synchronize()
+            }
+        }
+    }
     
     // MARK: - 保存文档
     internal func needSaveDocument() -> Bool {

+ 69 - 6
PDF Office/PDF Master/KMClass/KMPDFViewController/Toolbar/KMPDFToolbarController.swift

@@ -1286,14 +1286,17 @@ extension KMPDFToolbarController: KMRedactToolbarControllerDelegate {
             delegate?.kmPDFToolbarControllerDidToolbarItemClicked?(self, KMPDFToolbar_protect_redact_Property_Identifier)
             
         } else if buttonIndex == 2 {
-            viewManager?.subToolMode = .None
-            cancelSelectedSecondToolbarItems(.Protect)
-            delegate?.kmPDFToolbarControllerDidToolbarItemClicked?(self, KMPDFToolbar_protect_redact_Apply_Identifier)
+            self.applyRedactAlert()
+            
+//            viewManager?.subToolMode = .None
+//            cancelSelectedSecondToolbarItems(.Protect)
+//            delegate?.kmPDFToolbarControllerDidToolbarItemClicked?(self, KMPDFToolbar_protect_redact_Apply_Identifier)
             
         } else if buttonIndex == 3 {
-            viewManager?.subToolMode = .None
-            cancelSelectedSecondToolbarItems(.Protect)
-            delegate?.kmPDFToolbarControllerDidToolbarItemClicked?(self, KMPDFToolbar_protect_redact_Exit_Identifier)
+            self.exitRedactAlert()
+//            viewManager?.subToolMode = .None
+//            cancelSelectedSecondToolbarItems(.Protect)
+//            delegate?.kmPDFToolbarControllerDidToolbarItemClicked?(self, KMPDFToolbar_protect_redact_Exit_Identifier)
             
         }
         
@@ -1301,4 +1304,64 @@ extension KMPDFToolbarController: KMRedactToolbarControllerDelegate {
         
         
     }
+    
+    func exitRedactAlert() {
+        if UserDefaults.standard.object(forKey: "kExitRedactAlert") != nil {
+            return
+        }
+        let alert = NSAlert()
+        alert.alertStyle = .informational
+//        alert.informativeText = KMLocalizedString("Redaction allows you to permanently mask and remove sensitive content.")
+        alert.messageText = KMLocalizedString("""
+                                              There are unapplied redactions in this file. Any content associated with them will not be redacted until applied.
+                                              """)
+        alert.addButton(withTitle: KMLocalizedString("Exit"))
+        alert.addButton(withTitle: KMLocalizedString("Cancel"))
+        alert.showsSuppressionButton = true
+        let response = alert.runModal()
+        if response.rawValue == 1000 {
+            if alert.suppressionButton?.state == .on {
+                UserDefaults.standard.set("YES", forKey: "kExitRedactAlert")
+                UserDefaults.standard.synchronize()
+            }
+            
+            //退出
+            viewManager?.subToolMode = .None
+            cancelSelectedSecondToolbarItems(.Protect)
+            delegate?.kmPDFToolbarControllerDidToolbarItemClicked?(self, KMPDFToolbar_protect_redact_Exit_Identifier)
+        } else if response.rawValue == 1001 {
+            //取消
+            
+        }
+    }
+    
+    func applyRedactAlert() {
+        if UserDefaults.standard.object(forKey: "kApplyRedactAlert") != nil {
+            return
+        }
+        let alert = NSAlert()
+        alert.alertStyle = .informational
+        alert.messageText = KMLocalizedString("This action will permanently remove the redacted information from this document.")
+        alert.informativeText = KMLocalizedString("""
+                                              After you save this document, you will not be able to retrieve the redacted information.
+                                              """)
+        alert.addButton(withTitle: KMLocalizedString("Apply"))
+        alert.addButton(withTitle: KMLocalizedString("Cancel"))
+        alert.showsSuppressionButton = true
+        let response = alert.runModal()
+        if response.rawValue == 1000 {
+            if alert.suppressionButton?.state == .on {
+                UserDefaults.standard.set("YES", forKey: "kApplyRedactAlert")
+                UserDefaults.standard.synchronize()
+            }
+            
+            //应用
+            viewManager?.subToolMode = .None
+            cancelSelectedSecondToolbarItems(.Protect)
+            delegate?.kmPDFToolbarControllerDidToolbarItemClicked?(self, KMPDFToolbar_protect_redact_Apply_Identifier)
+        } else if response.rawValue == 1001 {
+            //取消
+            
+        }
+    }
 }