Search in sources :

Example 1 with FileSortOrder

use of com.owncloud.android.utils.FileSortOrder in project android by nextcloud.

the class OCFileListAdapter method setData.

public void setData(ArrayList<Object> objects, ExtendedListFragment.SearchType searchType, FileDataStorageManager storageManager, OCFile folder) {
    if (storageManager != null && mStorageManager == null) {
        mStorageManager = storageManager;
    }
    mFiles.clear();
    // early exit
    if (objects.size() > 0 && mStorageManager != null) {
        if (searchType.equals(ExtendedListFragment.SearchType.SHARED_FILTER)) {
            parseShares(objects);
        } else {
            parseVirtuals(objects, searchType);
        }
    }
    if (!searchType.equals(ExtendedListFragment.SearchType.PHOTO_SEARCH) && !searchType.equals(ExtendedListFragment.SearchType.PHOTOS_SEARCH_FILTER) && !searchType.equals(ExtendedListFragment.SearchType.RECENTLY_MODIFIED_SEARCH) && !searchType.equals(ExtendedListFragment.SearchType.RECENTLY_MODIFIED_SEARCH_FILTER)) {
        FileSortOrder sortOrder = PreferenceManager.getSortOrder(mContext, folder);
        mFiles = sortOrder.sortCloudFiles(mFiles);
    } else {
        mFiles = FileStorageUtils.sortOcFolderDescDateModified(mFiles);
    }
    mFilesAll.clear();
    mFilesAll.addAll(mFiles);
    new Handler(Looper.getMainLooper()).post(new Runnable() {

        @Override
        public void run() {
            notifyDataSetChanged();
        }
    });
}
Also used : Handler(android.os.Handler) FileSortOrder(com.owncloud.android.utils.FileSortOrder)

Example 2 with FileSortOrder

use of com.owncloud.android.utils.FileSortOrder in project android by nextcloud.

the class OCFileListAdapter method swapDirectory.

/**
 * Change the adapted directory for a new one
 *
 * @param directory             New folder to adapt. Can be NULL, meaning
 *                              "no content to adapt".
 * @param updatedStorageManager Optional updated storage manager; used to replace
 *                              mStorageManager if is different (and not NULL)
 */
public void swapDirectory(OCFile directory, FileDataStorageManager updatedStorageManager, boolean onlyOnDevice) {
    if (updatedStorageManager != null && !updatedStorageManager.equals(mStorageManager)) {
        mStorageManager = updatedStorageManager;
        mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
    }
    if (mStorageManager != null) {
        mFiles = mStorageManager.getFolderContent(directory, onlyOnDevice);
        if (!PreferenceManager.showHiddenFilesEnabled(mContext)) {
            mFiles = filterHiddenFiles(mFiles);
        }
        FileSortOrder sortOrder = PreferenceManager.getSortOrder(mContext, directory);
        mFiles = sortOrder.sortCloudFiles(mFiles);
        mFilesAll.clear();
        mFilesAll.addAll(mFiles);
        currentDirectory = directory;
    } else {
        mFiles.clear();
        mFilesAll.clear();
    }
    notifyDataSetChanged();
}
Also used : FileSortOrder(com.owncloud.android.utils.FileSortOrder)

Example 3 with FileSortOrder

use of com.owncloud.android.utils.FileSortOrder in project android by nextcloud.

the class LocalFileListAdapter method swapDirectory.

/**
 * Change the adapted directory for a new one
 *
 * @param directory New file to adapt. Can be NULL, meaning "no content to adapt".
 */
public void swapDirectory(final File directory) {
    localFileListFragmentInterface.setLoading(true);
    final Handler uiHandler = new Handler(Looper.getMainLooper());
    Executors.newSingleThreadExecutor().execute(() -> {
        List<File> fileList;
        if (directory == null) {
            fileList = new ArrayList<>();
        } else {
            if (mLocalFolderPicker) {
                fileList = getFolders(directory);
            } else {
                fileList = getFiles(directory);
            }
        }
        if (!fileList.isEmpty()) {
            FileSortOrder sortOrder = preferences.getSortOrderByType(FileSortOrder.Type.localFileListView);
            fileList = sortOrder.sortLocalFiles(fileList);
            // Fetch preferences for showing hidden files
            boolean showHiddenFiles = preferences.isShowHiddenFilesEnabled();
            if (!showHiddenFiles) {
                fileList = filterHiddenFiles(fileList);
            }
        }
        final List<File> newFiles = fileList;
        uiHandler.post(() -> {
            mFiles = newFiles;
            mFilesAll = new ArrayList<>();
            mFilesAll.addAll(mFiles);
            notifyDataSetChanged();
            localFileListFragmentInterface.setLoading(false);
        });
    });
}
Also used : Handler(android.os.Handler) FileSortOrder(com.owncloud.android.utils.FileSortOrder) File(java.io.File)

Example 4 with FileSortOrder

use of com.owncloud.android.utils.FileSortOrder in project android by nextcloud.

the class ReceiveExternalFilesActivity method populateDirectoryList.

private void populateDirectoryList() {
    setContentView(R.layout.receive_external_files);
    setupEmptyList();
    setupToolbar();
    ActionBar actionBar = getSupportActionBar();
    setupActionBarSubtitle();
    ListView mListView = findViewById(android.R.id.list);
    findViewById(R.id.sort_list_button_group).setVisibility(View.VISIBLE);
    findViewById(R.id.switch_grid_view_button).setVisibility(View.GONE);
    String current_dir = mParents.peek();
    boolean notRoot = mParents.size() > 1;
    if (actionBar != null) {
        if (TextUtils.isEmpty(current_dir)) {
            ThemeToolbarUtils.setColoredTitle(actionBar, R.string.uploader_top_message, this);
        } else {
            ThemeToolbarUtils.setColoredTitle(actionBar, current_dir, this);
        }
        actionBar.setDisplayHomeAsUpEnabled(notRoot);
        actionBar.setHomeButtonEnabled(notRoot);
    }
    String full_path = generatePath(mParents);
    Log_OC.d(TAG, "Populating view with content of : " + full_path);
    mFile = getStorageManager().getFileByPath(full_path);
    if (mFile != null) {
        List<OCFile> files = getStorageManager().getFolderContent(mFile, false);
        if (files.isEmpty()) {
            setMessageForEmptyList(R.string.file_list_empty_headline, R.string.empty, R.drawable.uploads);
        } else {
            mEmptyListContainer.setVisibility(View.GONE);
            files = sortFileList(files);
            List<Map<String, Object>> data = new LinkedList<>();
            for (OCFile f : files) {
                Map<String, Object> h = new HashMap<>();
                h.put("dirname", f);
                data.add(h);
            }
            UploaderAdapter sa = new UploaderAdapter(this, data, R.layout.uploader_list_item_layout, new String[] { "dirname" }, new int[] { R.id.filename }, getStorageManager(), getUser().get());
            mListView.setAdapter(sa);
        }
        MaterialButton btnChooseFolder = findViewById(R.id.uploader_choose_folder);
        ThemeButtonUtils.colorPrimaryButton(btnChooseFolder, this);
        btnChooseFolder.setOnClickListener(this);
        if (mFile.canWrite()) {
            btnChooseFolder.setEnabled(true);
            ThemeButtonUtils.colorPrimaryButton(btnChooseFolder, this);
        } else {
            btnChooseFolder.setEnabled(false);
            btnChooseFolder.setBackgroundColor(Color.GRAY);
        }
        ThemeToolbarUtils.colorStatusBar(this);
        ThemeToolbarUtils.tintBackButton(actionBar, this);
        Button btnNewFolder = findViewById(R.id.uploader_cancel);
        btnNewFolder.setTextColor(ThemeColorUtils.primaryColor(this, true));
        btnNewFolder.setOnClickListener(this);
        mListView.setOnItemClickListener(this);
        sortButton = findViewById(R.id.sort_button);
        FileSortOrder sortOrder = preferences.getSortOrderByFolder(mFile);
        sortButton.setText(DisplayUtils.getSortOrderStringId(sortOrder));
        sortButton.setOnClickListener(l -> openSortingOrderDialogFragment(getSupportFragmentManager(), sortOrder));
    }
}
Also used : HashMap(java.util.HashMap) FileSortOrder(com.owncloud.android.utils.FileSortOrder) MaterialButton(com.google.android.material.button.MaterialButton) LinkedList(java.util.LinkedList) OCFile(com.owncloud.android.datamodel.OCFile) ListView(android.widget.ListView) UploaderAdapter(com.owncloud.android.ui.adapter.UploaderAdapter) Button(android.widget.Button) MaterialButton(com.google.android.material.button.MaterialButton) Map(java.util.Map) HashMap(java.util.HashMap) ActionBar(androidx.appcompat.app.ActionBar)

Example 5 with FileSortOrder

use of com.owncloud.android.utils.FileSortOrder in project android by nextcloud.

the class OCFileListAdapter method swapDirectory.

/**
 * Change the adapted directory for a new one
 *
 * @param directory             New folder to adapt. Can be NULL, meaning "no content to adapt".
 * @param updatedStorageManager Optional updated storage manager; used to replace
 * @param limitToMimeType       show only files of this mimeType
 */
public void swapDirectory(User account, OCFile directory, FileDataStorageManager updatedStorageManager, boolean onlyOnDevice, String limitToMimeType) {
    this.onlyOnDevice = onlyOnDevice;
    if (updatedStorageManager != null && !updatedStorageManager.equals(mStorageManager)) {
        mStorageManager = updatedStorageManager;
        showShareAvatar = mStorageManager.getCapability(account.getAccountName()).getVersion().isShareesOnDavSupported();
        this.user = account;
    }
    if (mStorageManager != null) {
        mFiles = mStorageManager.getFolderContent(directory, onlyOnDevice);
        if (!preferences.isShowHiddenFilesEnabled()) {
            mFiles = filterHiddenFiles(mFiles);
        }
        if (!limitToMimeType.isEmpty()) {
            mFiles = filterByMimeType(mFiles, limitToMimeType);
        }
        FileSortOrder sortOrder = preferences.getSortOrderByFolder(directory);
        mFiles = sortOrder.sortCloudFiles(mFiles);
        mFilesAll.clear();
        mFilesAll.addAll(mFiles);
        currentDirectory = directory;
    } else {
        mFiles.clear();
        mFilesAll.clear();
    }
    notifyDataSetChanged();
}
Also used : FileSortOrder(com.owncloud.android.utils.FileSortOrder)

Aggregations

FileSortOrder (com.owncloud.android.utils.FileSortOrder)9 Handler (android.os.Handler)4 OCFile (com.owncloud.android.datamodel.OCFile)2 View (android.view.View)1 Button (android.widget.Button)1 ImageButton (android.widget.ImageButton)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 ActionBar (androidx.appcompat.app.ActionBar)1 MaterialButton (com.google.android.material.button.MaterialButton)1 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)1 VirtualFolderType (com.owncloud.android.datamodel.VirtualFolderType)1 LocalFileListAdapter (com.owncloud.android.ui.adapter.LocalFileListAdapter)1 UploaderAdapter (com.owncloud.android.ui.adapter.UploaderAdapter)1 File (java.io.File)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1