Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,19 @@ public OCFile findDuplicatedFile(OCFile parentFolder, ServerFileInterface newFil
return duplicatedFile;
}

public String getFileNameBasedOnEncryptionStatus(OCFile file) {
FileEntity entity = fileDao.getFileById(file.getFileId());
if (entity == null) {
return file.getFileName();
}

if (file.isEncrypted()) {
return entity.getEncryptedName();
} else {
return entity.getName();
}
}

public List<OCFile> getFolderImages(OCFile folder, boolean onlyOnDevice) {
List<OCFile> imageList = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private Activity getActivity() {
public void onAccountChosen(@NonNull User user) {
setAccount(user.toPlatformAccount(), false);
initTargetFolder();
populateDirectoryList();
populateDirectoryList(null);
}

@Override
Expand All @@ -258,7 +258,7 @@ private void browseToFolderIfItExists() {
final OCFile fileByPath = getStorageManager().getFileByPath(full_path);
if (fileByPath != null) {
startSyncFolderOperation(fileByPath);
populateDirectoryList();
populateDirectoryList(null);
} else {
browseToRoot();
preferences.setLastUploadPath(OCFile.ROOT_PATH);
Expand Down Expand Up @@ -290,7 +290,7 @@ protected void onDestroy() {
public void onSortingOrderChosen(FileSortOrder newSortOrder) {
preferences.setSortOrder(mFile, newSortOrder);
sortButton.setText(DisplayUtils.getSortOrderStringId(newSortOrder));
populateDirectoryList();
populateDirectoryList(null);
}

@Override
Expand All @@ -310,8 +310,10 @@ public void selectFile(OCFile file) {
}

startSyncFolderOperation(file);
mParents.push(file.getFileName());
populateDirectoryList();

String filename = fileDataStorageManager.getFileNameBasedOnEncryptionStatus(file);
mParents.push(filename);
populateDirectoryList(file);
}
}

Expand Down Expand Up @@ -712,7 +714,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// account at this point
// since account setup can set only one account at time
setAccount(accounts[0], false);
populateDirectoryList();
populateDirectoryList(null);
}
}
}
Expand All @@ -727,7 +729,7 @@ private void setupActionBarSubtitle() {
}
}

private void populateDirectoryList() {
private void populateDirectoryList(OCFile file) {
setupEmptyList();
setupToolbar();
ActionBar actionBar = getSupportActionBar();
Expand All @@ -743,7 +745,11 @@ private void populateDirectoryList() {
if (TextUtils.isEmpty(current_dir)) {
viewThemeUtils.files.themeActionBar(this, actionBar, R.string.uploader_top_message);
} else {
viewThemeUtils.files.themeActionBar(this, actionBar, current_dir);
if (file != null) {
viewThemeUtils.files.themeActionBar(this, actionBar, file.getFileName());
} else {
viewThemeUtils.files.themeActionBar(this, actionBar, current_dir);
}
}

actionBar.setDisplayHomeAsUpEnabled(notRoot);
Expand All @@ -754,37 +760,44 @@ private void populateDirectoryList() {

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 (file != null) {
mFile = file;
} else {
mFile = getStorageManager().getFileByPath(full_path);
}

if (files.isEmpty()) {
setMessageForEmptyList(R.string.file_list_empty_headline, R.string.empty,
R.drawable.uploads);
mEmptyListContainer.setVisibility(View.VISIBLE);
binding.list.setVisibility(View.GONE);
} else {
mEmptyListContainer.setVisibility(View.GONE);
files = sortFileList(files);
setupReceiveExternalFilesAdapter(files);
}
if (mFile == null) {
return;
}

MaterialButton btnChooseFolder = binding.uploaderChooseFolder;
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(btnChooseFolder);
btnChooseFolder.setOnClickListener(this);
List<OCFile> files = getStorageManager().getFolderContent(mFile, false);

btnChooseFolder.setEnabled(mFile.canWrite());
if (files.isEmpty()) {
setMessageForEmptyList(R.string.file_list_empty_headline, R.string.empty,
R.drawable.uploads);
mEmptyListContainer.setVisibility(View.VISIBLE);
binding.list.setVisibility(View.GONE);
} else {
mEmptyListContainer.setVisibility(View.GONE);
files = sortFileList(files);
setupReceiveExternalFilesAdapter(files);
}

viewThemeUtils.platform.themeStatusBar(this);
MaterialButton btnChooseFolder = binding.uploaderChooseFolder;
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(btnChooseFolder);
btnChooseFolder.setOnClickListener(this);

viewThemeUtils.material.colorMaterialButtonPrimaryOutlined(binding.uploaderCancel);
binding.uploaderCancel.setOnClickListener(this);
btnChooseFolder.setEnabled(mFile.canWrite());

sortButton = binding.toolbarLayout.sortButton;
FileSortOrder sortOrder = preferences.getSortOrderByFolder(mFile);
sortButton.setText(DisplayUtils.getSortOrderStringId(sortOrder));
sortButton.setOnClickListener(l -> openSortingOrderDialogFragment(getSupportFragmentManager(), sortOrder));
}
viewThemeUtils.platform.themeStatusBar(this);

viewThemeUtils.material.colorMaterialButtonPrimaryOutlined(binding.uploaderCancel);
binding.uploaderCancel.setOnClickListener(this);

sortButton = binding.toolbarLayout.sortButton;
FileSortOrder sortOrder = preferences.getSortOrderByFolder(mFile);
sortButton.setText(DisplayUtils.getSortOrderStringId(sortOrder));
sortButton.setOnClickListener(l -> openSortingOrderDialogFragment(getSupportFragmentManager(), sortOrder));
}

private void setupReceiveExternalFilesAdapter(List<OCFile> files) {
Expand Down Expand Up @@ -979,19 +992,15 @@ public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationRe
* @param operation Creation operation performed.
* @param result Result of the creation.
*/
private void onCreateFolderOperationFinish(CreateFolderOperation operation,
RemoteOperationResult result) {
private void onCreateFolderOperationFinish(CreateFolderOperation operation, RemoteOperationResult result) {
if (result.isSuccess()) {
String remotePath = operation.getRemotePath().substring(0, operation.getRemotePath().length() - 1);
String newFolder = remotePath.substring(remotePath.lastIndexOf('/') + 1);
mParents.push(newFolder);
populateDirectoryList();
populateDirectoryList(null);
} else {
try {
DisplayUtils.showSnackMessage(
this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources())
);

DisplayUtils.showSnackMessage(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()));
} catch (NotFoundException e) {
Log_OC.e(TAG, "Error while trying to show fail message ", e);
}
Expand Down Expand Up @@ -1043,8 +1052,10 @@ public boolean onCreateOptionsMenu(Menu menu) {

setupSearchView(menu);

MenuItem newFolderMenuItem = menu.findItem(R.id.action_create_dir);
newFolderMenuItem.setEnabled(mFile.canWrite());
if (mFile != null) {
MenuItem newFolderMenuItem = menu.findItem(R.id.action_create_dir);
newFolderMenuItem.setEnabled(mFile.canWrite());
}

return true;
}
Expand Down Expand Up @@ -1155,9 +1166,8 @@ public void onReceive(Context context, Intent intent) {
}

if (currentDir.getRemotePath().equals(syncFolderRemotePath)) {
populateDirectoryList();
populateDirectoryList(currentFile);
}
mFile = currentFile;
}

mSyncInProgress = !FileSyncAdapter.EVENT_FULL_SYNC_END.equals(event) &&
Expand Down
Loading