tobiaskaminsky 7 лет назад
Родитель
Сommit
4aa189954a

+ 9 - 8
src/main/java/com/owncloud/android/datamodel/OCFile.java

@@ -1,4 +1,4 @@
-/**
+/*
  *   ownCloud Android client application
  *
  *   @author Bartek Przybylski
@@ -104,7 +104,7 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
 
     /**
      * Exportable URI to the local path of the file contents, if stored in the device.
-     *
+     * <p>
      * Cached after first call, until changed.
      */
     private Uri mExposedFileUri;
@@ -112,7 +112,7 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
 
     /**
      * Create new {@link OCFile} with given path.
-     * <p/>
+     * <p>
      * The path received must be URL-decoded. Path separator must be OCFile.PATH_SEPARATOR, and it must be the first character in 'path'.
      *
      * @param path The remote path of the file.
@@ -286,15 +286,15 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
             if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
                 // TODO - use FileProvider with any Android version, with deeper testing -> 2.2.0
                 mExposedFileUri = Uri.parse(
-                    ContentResolver.SCHEME_FILE + "://" + WebdavUtils.encodePath(mLocalPath)
+                        ContentResolver.SCHEME_FILE + "://" + WebdavUtils.encodePath(mLocalPath)
                 );
             } else {
                 // Use the FileProvider to get a content URI
                 try {
                     mExposedFileUri = FileProvider.getUriForFile(
-                        context,
-                        context.getString(R.string.file_provider_authority),
-                        new File(mLocalPath)
+                            context,
+                            context.getString(R.string.file_provider_authority),
+                            new File(mLocalPath)
                     );
                 } catch (IllegalArgumentException e) {
                     Log_OC.e(TAG, "File can't be exported");
@@ -503,6 +503,7 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
 
     /**
      * get remote path of parent file
+     *
      * @return remote path
      */
     public String getParentRemotePath() {
@@ -688,7 +689,7 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
         return (permissions != null && permissions.contains(PERMISSION_SHARED_WITH_ME));
     }
 
-    public boolean canReshare(){
+    public boolean canReshare() {
         String permissions = getPermissions();
         return permissions != null && permissions.contains(PERMISSION_CAN_RESHARE);
     }

+ 28 - 28
src/main/java/com/owncloud/android/ui/fragment/EditShareFragment.java

@@ -1,22 +1,21 @@
-/**
- *   ownCloud Android client application
+/*
+ * ownCloud Android client application
  *
- *   @author masensio
- *   @author David A. Velasco
- *   Copyright (C) 2015 ownCloud Inc.
+ * @author masensio
+ * @author David A. Velasco
+ * Copyright (C) 2015 ownCloud Inc.
  *
- *   This program is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2,
- *   as published by the Free Software Foundation.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
  *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 package com.owncloud.android.ui.fragment;
@@ -83,7 +82,7 @@ public class EditShareFragment extends Fragment {
 
     /** Listener for changes on privilege checkboxes */
     private CompoundButton.OnCheckedChangeListener mOnPrivilegeChangeListener;
-    
+
     /**
      * Public factory method to create new EditShareFragment instances.
      *
@@ -116,7 +115,8 @@ public class EditShareFragment extends Fragment {
             mAccount = getArguments().getParcelable(ARG_ACCOUNT);
         }
 
-        refreshCapabilitiesFromDB();
+        FileDataStorageManager storageManager = new FileDataStorageManager(mAccount, getContext().getContentResolver());
+        mCapabilities = storageManager.getCapability(mAccount.name);
     }
 
 
@@ -140,7 +140,7 @@ public class EditShareFragment extends Fragment {
         // Inflate the layout for this fragment
         View view = inflater.inflate(R.layout.edit_share_layout, container, false);
 
-        ((TextView)view.findViewById(R.id.editShareTitle)).setText(
+        ((TextView) view.findViewById(R.id.editShareTitle)).setText(
                 getResources().getString(R.string.share_with_edit_title, mShare.getSharedWithDisplayName()));
 
         View headerDivider = view.findViewById(R.id.share_header_divider);
@@ -159,9 +159,9 @@ public class EditShareFragment extends Fragment {
      * instance ready to use. If not ready, does nothing.
      */
     public void refreshCapabilitiesFromDB() {
-        if(getActivity() instanceof FileActivity){
-            FileActivity fileActivity = ((FileActivity)getActivity());
-            if(fileActivity.getStorageManager() != null){
+        if (getActivity() instanceof FileActivity) {
+            FileActivity fileActivity = ((FileActivity) getActivity());
+            if (fileActivity.getStorageManager() != null) {
                 mCapabilities = fileActivity.getStorageManager().getCapability(mAccount.name);
             }
         }
@@ -189,7 +189,7 @@ public class EditShareFragment extends Fragment {
 
             if (isFederated) {
                 shareSwitch.setVisibility(View.INVISIBLE);
-            } else if(mCapabilities != null && mCapabilities.getFilesSharingResharing().isFalse()){
+            } else if (mCapabilities != null && mCapabilities.getFilesSharingResharing().isFalse()) {
                 shareSwitch.setVisibility(View.GONE);
             }
 
@@ -285,7 +285,7 @@ public class EditShareFragment extends Fragment {
             /// else, getView() cannot be NULL
 
             CompoundButton subordinate;
-            switch(compound.getId()) {
+            switch (compound.getId()) {
                 case R.id.canShareSwitch:
                     Log_OC.v(TAG, "canShareCheckBox toggled to " + isChecked);
                     updatePermissionsToShare();
@@ -304,7 +304,7 @@ public class EditShareFragment extends Fragment {
                                     subordinate = (CompoundButton) getView().findViewById(sSubordinateCheckBoxIds[i]);
                                     subordinate.setVisibility(View.VISIBLE);
                                     if (!subordinate.isChecked() &&
-                                        !mFile.isSharedWithMe()) {          // see (1)
+                                            !mFile.isSharedWithMe()) {          // see (1)
                                         toggleDisablingListener(subordinate);
                                     }
                                 }
@@ -329,8 +329,8 @@ public class EditShareFragment extends Fragment {
                         }
                     }
 
-                    if(!(mFile.isFolder() && isChecked && mFile.isSharedWithMe())       // see (1)
-                        || isFederated ) {
+                    if (!(mFile.isFolder() && isChecked && mFile.isSharedWithMe())       // see (1)
+                            || isFederated) {
                         updatePermissionsToShare();
                     }
 
@@ -381,7 +381,7 @@ public class EditShareFragment extends Fragment {
                 }
             } else {
                 boolean allDisabled = true;
-                for (int i=0; allDisabled && i<sSubordinateCheckBoxIds.length; i++) {
+                for (int i = 0; allDisabled && i < sSubordinateCheckBoxIds.length; i++) {
                     allDisabled &=
                             sSubordinateCheckBoxIds[i] == subordinateCheckBoxView.getId() ||
                                     !((CheckBox) getView().findViewById(sSubordinateCheckBoxIds[i])).isChecked()
@@ -389,7 +389,7 @@ public class EditShareFragment extends Fragment {
                 }
                 if (canEditCompound.isChecked() && allDisabled) {
                     toggleDisablingListener(canEditCompound);
-                    for (int i=0; i<sSubordinateCheckBoxIds.length; i++) {
+                    for (int i = 0; i < sSubordinateCheckBoxIds.length; i++) {
                         getView().findViewById(sSubordinateCheckBoxIds[i]).setVisibility(View.GONE);
                     }
                 }