marinofaggiana 6 年之前
父节点
当前提交
3014dcfd50
共有 2 个文件被更改,包括 45 次插入3 次删除
  1. 44 3
      iOSClient/Share/CCShareOC.m
  2. 1 0
      iOSClient/Supporting Files/en.lproj/Localizable.strings

+ 44 - 3
iOSClient/Share/CCShareOC.m

@@ -28,6 +28,7 @@
 @interface CCShareOC ()
 {
     AppDelegate *appDelegate;
+    tableCapabilities *capabilities;
 }
 @end
 
@@ -73,7 +74,7 @@
     [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
     [section addFormRow:row];
  
-    tableCapabilities *capabilities = [[NCManageDatabase sharedInstance] getCapabilitesWithAccount:appDelegate.activeAccount];
+    capabilities = [[NCManageDatabase sharedInstance] getCapabilitesWithAccount:appDelegate.activeAccount];
     if (capabilities != nil && capabilities.versionMajor >= k_nextcloud_version_15_0) {
         row = [XLFormRowDescriptor formRowDescriptorWithTag:@"hideDownload" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_share_link_hide_download_", nil)];
         [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
@@ -388,8 +389,37 @@
         
         if ([[rowDescriptor.value valueData] boolValue] == YES) {
             
-            [self.delegate share:self.metadata serverUrl:self.serverUrl password:@"" permission:1 hideDownload:false];
-            [self disableForm];
+            if (capabilities.isFilesSharingPublicPasswordEnforced == YES) {
+                
+                UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_enforce_password_protection_",nil) message:nil preferredStyle:UIAlertControllerStyleAlert];
+                [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
+                    textField.secureTextEntry = true;
+                    [textField addTarget:self action:@selector(minCharTextFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
+                }];
+
+                UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_",nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+                    NSLog(@"[LOG] Cancel action");
+                }];
+                UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+                    NSString *password = alertController.textFields.firstObject.text;
+                    XLFormRowDescriptor *rowPassword = [self.form formRowWithTag:@"password"];
+                    rowPassword.value = password;
+                    [self.delegate share:self.metadata serverUrl:self.serverUrl password:password permission:1 hideDownload:false];
+                    [self disableForm];
+                }];
+                
+                okAction.enabled = NO;
+                
+                [alertController addAction:cancelAction];
+                [alertController addAction:okAction];
+                
+                [self presentViewController:alertController animated:YES completion:nil];
+                
+            } else {
+                
+                [self.delegate share:self.metadata serverUrl:self.serverUrl password:@"" permission:1 hideDownload:false];
+                [self disableForm];
+            }
             
         } else {
             
@@ -542,6 +572,17 @@
 #pragma mark ===== Utility =====
 #pragma --------------------------------------------------------------------------------------------
 
+- (void)minCharTextFieldDidChange:(UITextField *)sender
+{
+    UIAlertController *alertController = (UIAlertController *)self.presentedViewController;
+    
+    if (alertController) {
+        UITextField *password = alertController.textFields.firstObject;
+        UIAlertAction *okAction = alertController.actions.lastObject;
+        okAction.enabled = password.text.length > 0;
+    }
+}
+
 -(void)disableForm
 {
     self.form.disabled = YES;

+ 1 - 0
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -439,6 +439,7 @@
 "_share_type_user_"             = "User";
 "_share_type_group_"            = "Group";
 "_share_type_remote_"           = "Remote";
+"_enforce_password_protection_" = "Enforce password protection";
 
 // Share Permission