Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 committed Jan 7, 2025
1 parent adc4b86 commit 1908e2d
Showing 1 changed file with 54 additions and 44 deletions.
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 @@ -706,7 +708,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 @@ -721,7 +723,7 @@ private void setupActionBarSubtitle() {
}
}

private void populateDirectoryList() {
private void populateDirectoryList(OCFile file) {
setupEmptyList();
setupToolbar();
ActionBar actionBar = getSupportActionBar();
Expand All @@ -737,7 +739,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 @@ -748,37 +754,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 @@ -969,19 +982,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 @@ -1033,8 +1042,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 @@ -1145,9 +1156,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

0 comments on commit 1908e2d

Please sign in to comment.