Skip to content

Commit

Permalink
Filter oc file list adapter according to selected menu item
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 committed Sep 23, 2024
1 parent f04ebeb commit 8ccee61
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/src/main/java/com/owncloud/android/datamodel/OCFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,10 @@ public boolean isSharedViaLink() {
return this.sharedViaLink;
}

public boolean isShared() {
return isSharedViaLink() || isSharedWithSharee() || isSharedWithMe();
}

public String getPermissions() {
return this.permissions;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import com.owncloud.android.operations.RefreshFolderOperation;
import com.owncloud.android.operations.RemoteOperationFailedException;
import com.owncloud.android.ui.activity.ComponentsGetter;
import com.owncloud.android.ui.activity.DrawerActivity;
import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.ui.fragment.SearchType;
import com.owncloud.android.ui.interfaces.OCFileListFragmentInterface;
Expand Down Expand Up @@ -733,6 +734,30 @@ public boolean shouldShowHeader() {
return !TextUtils.isEmpty(currentDirectory.getRichWorkspace().trim());
}

private List<OCFile> filterSharedFiles(Iterable<OCFile> files) {
List<OCFile> ret = new ArrayList<>();

for (OCFile file : files) {
if (file.isShared()) {
ret.add(file);
}
}

return ret;
}

private List<OCFile> filterFavoriteFiles(Iterable<OCFile> files) {
List<OCFile> ret = new ArrayList<>();

for (OCFile file : files) {
if (file.isFavorite()) {
ret.add(file);
}
}

return ret;
}

/**
* Change the adapted directory for a new one
*
Expand Down Expand Up @@ -765,6 +790,13 @@ public void swapDirectory(
if (OCFile.ROOT_PATH.equals(directory.getRemotePath()) && MainApp.isOnlyPersonFiles()) {
mFiles = limitToPersonalFiles(mFiles);
}
if (DrawerActivity.menuItemId == R.id.nav_shared && currentDirectory.isRootDirectory()) {
mFiles = filterSharedFiles(mFiles);
}
if (DrawerActivity.menuItemId == R.id.nav_favorites && currentDirectory.isRootDirectory()) {
mFiles = filterFavoriteFiles(mFiles);
}

sortOrder = preferences.getSortOrderByFolder(directory);
mFiles = sortOrder.sortCloudFiles(mFiles);
prepareListOfHiddenFiles();
Expand Down

0 comments on commit 8ccee61

Please sign in to comment.