Browse Source

show files during copy, move, remote folder select on synced folder

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 7 years ago
parent
commit
228a69a38f

+ 1 - 1
src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java

@@ -180,7 +180,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
     private void createFragments() {
         OCFileListFragment listOfFiles = new OCFileListFragment();
         Bundle args = new Bundle();
-        args.putBoolean(OCFileListFragment.ARG_JUST_FOLDERS, true);
+        args.putBoolean(OCFileListFragment.ARG_ONLY_FOLDERS_CLICKABLE, true);
         args.putBoolean(OCFileListFragment.ARG_HIDE_FAB, true);
         args.putBoolean(OCFileListFragment.ARG_HIDE_ITEM_OPTIONS, true);
         args.putBoolean(OCFileListFragment.ARG_SEARCH_ONLY_FOLDER, mSearchOnlyFolders);

+ 1 - 2
src/main/java/com/owncloud/android/ui/adapter/FileListListAdapter.java

@@ -99,11 +99,10 @@ public class FileListListAdapter extends BaseAdapter {
 
     private ArrayList<ThumbnailsCacheManager.ThumbnailGenerationTask> asyncTasks = new ArrayList<>();
 
-    public FileListListAdapter(boolean justFolders, Context context, ComponentsGetter transferServiceGetter,
+    public FileListListAdapter(Context context, ComponentsGetter transferServiceGetter,
                                OCFileListFragmentInterface OCFileListFragmentInterface, boolean argHideItemOptions) {
 
         this.OCFileListFragmentInterface = OCFileListFragmentInterface;
-        mJustFolders = justFolders;
         mContext = context;
         mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
         mHideItemOptions = argHideItemOptions;

+ 29 - 41
src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java

@@ -129,7 +129,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
     private static final String MY_PACKAGE = OCFileListFragment.class.getPackage() != null ?
             OCFileListFragment.class.getPackage().getName() : "com.owncloud.android.ui.fragment";
 
-    public final static String ARG_JUST_FOLDERS = MY_PACKAGE + ".JUST_FOLDERS";
+    public final static String ARG_ONLY_FOLDERS_CLICKABLE = MY_PACKAGE + ".ONLY_FOLDERS_CLICKABLE";
     public final static String ARG_ALLOW_CONTEXTUAL_ACTIONS = MY_PACKAGE + ".ALLOW_CONTEXTUAL";
     public final static String ARG_HIDE_FAB = MY_PACKAGE + ".HIDE_FAB";
     public final static String ARG_HIDE_ITEM_OPTIONS = MY_PACKAGE + ".HIDE_ITEM_OPTIONS";
@@ -155,7 +155,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
 
     private OCFile mFile = null;
     private FileListListAdapter mAdapter;
-    private boolean mJustFolders;
+    private boolean mOnlyFoldersClickable;
 
     private int mSystemBarActionModeColor;
     private int mSystemBarColor;
@@ -313,17 +313,13 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
             mFile = savedInstanceState.getParcelable(KEY_FILE);
         }
 
-        if (mJustFolders) {
-            setFooterEnabled(false);
-        } else {
-            setFooterEnabled(true);
-        }
+        setFooterEnabled(true);
 
         Bundle args = getArguments();
-        mJustFolders = (args != null) && args.getBoolean(ARG_JUST_FOLDERS, false);
+        mOnlyFoldersClickable = (args != null) && args.getBoolean(ARG_ONLY_FOLDERS_CLICKABLE, false);
         boolean hideItemOptions = (args != null) && args.getBoolean(ARG_HIDE_ITEM_OPTIONS, false);
 
-        mAdapter = new FileListListAdapter(mJustFolders, getActivity(), mContainerActivity, this, hideItemOptions);
+        mAdapter = new FileListListAdapter(getActivity(), mContainerActivity, this, hideItemOptions);
         setListAdapter(mAdapter);
 
         mHideFab = (args != null) && args.getBoolean(ARG_HIDE_FAB, false);
@@ -934,8 +930,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
                     // save index and top position
                     saveIndexAndTopPosition(position);
                 }
-
-            } else { /// Click on a file
+            } else if (!mOnlyFoldersClickable) { // Click on a file
                 if (PreviewImageFragment.canBePreviewed(file)) {
                     // preview image - it handles the download, if needed
                     if (searchFragment) {
@@ -967,18 +962,14 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
                     } else {
                         mContainerActivity.getFileOperationsHelper().openFile(file);
                     }
-
                 } else {
                     // automatic download, preview on finish
                     ((FileDisplayActivity) mContainerActivity).startDownloadForPreview(file);
                 }
-
             }
-
         } else {
             Log_OC.d(TAG, "Null object in ListAdapter!!");
         }
-
     }
 
     @Override
@@ -1200,39 +1191,36 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
     }
 
     private void updateFooter() {
-        if (!mJustFolders) {
-            int filesCount = 0;
-            int foldersCount = 0;
-            int count = mAdapter.getCount();
-            OCFile file;
-            for (int i = 0; i < count; i++) {
-                file = (OCFile) mAdapter.getItem(i);
-                if (file.isFolder()) {
-                    foldersCount++;
-                } else {
-                    if (!file.isHidden()) {
-                        filesCount++;
-                    }
+        int filesCount = 0;
+        int foldersCount = 0;
+        int count = mAdapter.getCount();
+        OCFile file;
+        for (int i = 0; i < count; i++) {
+            file = (OCFile) mAdapter.getItem(i);
+            if (file.isFolder()) {
+                foldersCount++;
+            } else {
+                if (!file.isHidden()) {
+                    filesCount++;
                 }
             }
-            // set footer text
-            setFooterText(generateFooterText(filesCount, foldersCount));
         }
+        // set footer text
+        setFooterText(generateFooterText(filesCount, foldersCount));
     }
 
     private void updateLayout() {
-        if (!mJustFolders) {
-            updateFooter();
-            // decide grid vs list view
-            OwnCloudVersion version = AccountUtils.getServerVersion(
-                    ((FileActivity) mContainerActivity).getAccount());
-            if (version != null && version.supportsRemoteThumbnails() &&
-                    isGridViewPreferred(mFile)) {
-                switchToGridView();
-            } else {
-                switchToListView();
-            }
+        updateFooter();
+        // decide grid vs list view
+        OwnCloudVersion version = AccountUtils.getServerVersion(
+                ((FileActivity) mContainerActivity).getAccount());
+        if (version != null && version.supportsRemoteThumbnails() &&
+                isGridViewPreferred(mFile)) {
+            switchToGridView();
+        } else {
+            switchToListView();
         }
+
         invalidateActionMode();
     }