tobiasKaminsky 8 years ago
parent
commit
923d4b6293
1 changed files with 33 additions and 9 deletions
  1. 33 9
      src/com/owncloud/android/ui/fragment/ShareFileFragment.java

+ 33 - 9
src/com/owncloud/android/ui/fragment/ShareFileFragment.java

@@ -247,6 +247,10 @@ public class ShareFileFragment extends Fragment
         // Set listener for user actions on edit permission
         initEditPermissionListener(view);
 
+        // Set listener for hide file listing
+        // TODO only if "allow editing" is true
+        initHideFileListingListener(view);
+
         // Hide share features sections that are not enabled
         hideNotEnabledShareSections(view);
 
@@ -479,6 +483,21 @@ public class ShareFileFragment extends Fragment
 
     }
 
+    /**
+     * Binds listener for user actions that start any update the hide file listing permissions
+     * for the public link to the views receiving the user events.
+     *
+     * @param shareView Root view in the fragment.
+     */
+    private void initHideFileListingListener(View shareView) {
+        mOnHideFileListingPermissionInteractionListener =
+                new OnHideFileListingPermissionInteractionListener();
+
+        ((SwitchCompat) shareView.findViewById(R.id.shareViaLinkHideListPermissionSwitch)).
+                setOnCheckedChangeListener(mOnHideFileListingPermissionInteractionListener);
+
+    }
+
     /**
      * Listener for user actions that start any update on the edit permissions for the public link.
      */
@@ -799,15 +818,20 @@ public class ShareFileFragment extends Fragment
 
             // set null listener before setChecked() to prevent infinite loop of calls
             hideFileListingPermissionSwitch.setOnCheckedChangeListener(null);
-            if (mPublicShare.getPermissions() > OCShare.READ_PERMISSION_FLAG) {
-                if (!hideFileListingPermissionSwitch.isChecked()) {
-                    hideFileListingPermissionSwitch.toggle();
-                }
-            } else {
-                if (hideFileListingPermissionSwitch.isChecked()) {
-                    hideFileListingPermissionSwitch.toggle();
-                }
-            }
+
+            boolean readOnly = (mPublicShare.getPermissions() & OCShare.READ_PERMISSION_FLAG) != 0;
+            hideFileListingPermissionSwitch.setChecked(!readOnly);
+
+//            if ((mPublicShare.getPermissions() & OCShare.READ_PERMISSION_FLAG) != 0) {
+//                if (!hideFileListingPermissionSwitch.isChecked()) {
+//
+//                }
+//            } else {
+//                if (hideFileListingPermissionSwitch.isChecked()) {
+//                    hideFileListingPermissionSwitch.toggle();
+//                }
+//            }
+
             // recover listener
             hideFileListingPermissionSwitch.setOnCheckedChangeListener(
                     mOnHideFileListingPermissionInteractionListener