1717import com .owncloud .android .lib .resources .shares .OCShare ;
1818
1919import static com .owncloud .android .lib .resources .shares .OCShare .CREATE_PERMISSION_FLAG ;
20- import static com .owncloud .android .lib .resources .shares .OCShare .DELETE_PERMISSION_FLAG ;
2120import static com .owncloud .android .lib .resources .shares .OCShare .MAXIMUM_PERMISSIONS_FOR_FILE ;
2221import static com .owncloud .android .lib .resources .shares .OCShare .MAXIMUM_PERMISSIONS_FOR_FOLDER ;
2322import static com .owncloud .android .lib .resources .shares .OCShare .NO_PERMISSION ;
2423import static com .owncloud .android .lib .resources .shares .OCShare .READ_PERMISSION_FLAG ;
2524import static com .owncloud .android .lib .resources .shares .OCShare .SHARE_PERMISSION_FLAG ;
26- import static com .owncloud .android .lib .resources .shares .OCShare .UPDATE_PERMISSION_FLAG ;
2725
2826/**
2927 * Helper calls for visibility logic of the sharing menu.
3028 */
3129public final class SharingMenuHelper {
3230
31+ private static final SharePermissionManager sharePermissionManager = new SharePermissionManager ();
32+
3333 private SharingMenuHelper () {
3434 // utility class -> private constructor
3535 }
@@ -68,50 +68,21 @@ public static boolean isSecureFileDrop(OCShare share) {
6868 return (share .getPermissions () & ~SHARE_PERMISSION_FLAG ) == CREATE_PERMISSION_FLAG + READ_PERMISSION_FLAG ;
6969 }
7070
71- public static boolean isCreatePermission (OCShare share ) {
72- if (share .getPermissions () == NO_PERMISSION ) {
73- return false ;
74- }
75-
76- return (share .getPermissions () & ~SHARE_PERMISSION_FLAG ) == CREATE_PERMISSION_FLAG ;
77- }
78-
79- public static boolean isUpdatePermission (OCShare share ) {
80- if (share .getPermissions () == NO_PERMISSION ) {
81- return false ;
82- }
83-
84- return (share .getPermissions () & ~SHARE_PERMISSION_FLAG ) == UPDATE_PERMISSION_FLAG ;
85- }
86-
87- public static boolean isDeletePermission (OCShare share ) {
88- if (share .getPermissions () == NO_PERMISSION ) {
89- return false ;
90- }
91-
92- return (share .getPermissions () & ~SHARE_PERMISSION_FLAG ) == DELETE_PERMISSION_FLAG ;
93- }
94-
9571 public static String getPermissionName (Context context , OCShare share ) {
9672 final var res = context .getResources ();
9773
98- if (SharingMenuHelper .isUploadAndEditingAllowed (share )) {
74+ if (sharePermissionManager .isCustomPermission (share )) {
75+ return res .getString (R .string .share_custom_permission );
76+ } else if (SharingMenuHelper .isUploadAndEditingAllowed (share )) {
9977 return res .getString (R .string .share_permission_can_edit );
10078 } else if (SharingMenuHelper .isReadOnly (share )) {
10179 return res .getString (R .string .share_permission_view_only );
10280 } else if (SharingMenuHelper .isSecureFileDrop (share )) {
10381 return res .getString (R .string .share_permission_secure_file_drop );
10482 } else if (SharingMenuHelper .isFileDrop (share )) {
10583 return res .getString (R .string .share_permission_file_drop );
106- } else if (SharingMenuHelper .isCreatePermission (share )) {
107- return res .getString (R .string .share_create_permission );
108- } else if (SharingMenuHelper .isUpdatePermission (share )) {
109- return res .getString (R .string .share_edit_permission );
110- } else if (SharingMenuHelper .isDeletePermission (share )) {
111- return res .getString (R .string .share_delete_permission );
112- } else if (SharingMenuHelper .canReshare (share )) {
113- return res .getString (R .string .share_re_share_permission );
11484 }
85+
11586 return null ;
11687 }
11788
@@ -122,20 +93,14 @@ public static String getPermissionName(Context context, OCShare share) {
12293 public static int getPermissionCheckedItem (Context context , OCShare share , String [] permissionArray ) {
12394 int permissionName ;
12495
125- if (SharingMenuHelper .isUploadAndEditingAllowed (share )) {
96+ if (sharePermissionManager .isCustomPermission (share )) {
97+ permissionName = R .string .share_custom_permission ;
98+ } else if (SharingMenuHelper .isUploadAndEditingAllowed (share )) {
12699 permissionName = share .isFolder () ? R .string .link_share_allow_upload_and_editing : R .string .link_share_editing ;
127100 } else if (SharingMenuHelper .isReadOnly (share )) {
128101 permissionName = R .string .link_share_view_only ;
129102 } else if (SharingMenuHelper .isFileDrop (share )) {
130103 permissionName = R .string .link_share_file_drop ;
131- } else if (SharingMenuHelper .isCreatePermission (share )) {
132- permissionName = R .string .share_create_permission ;
133- } else if (SharingMenuHelper .isUpdatePermission (share )) {
134- permissionName = R .string .share_edit_permission ;
135- } else if (SharingMenuHelper .isDeletePermission (share )) {
136- permissionName = R .string .share_delete_permission ;
137- } else if (SharingMenuHelper .canReshare (share )) {
138- permissionName = R .string .share_re_share_permission ;
139104 } else {
140105 return 0 ;
141106 }
0 commit comments