Skip to content

Commit

Permalink
Fix onclick
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 committed Nov 13, 2023
1 parent 0077cfe commit 7a56062
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
* This can be used to upload things to an ownCloud instance.
*/
public class ReceiveExternalFilesActivity extends FileActivity
implements OnItemClickListener, View.OnClickListener, CopyAndUploadContentUrisTask.OnCopyTmpFilesTaskListener,
implements View.OnClickListener, CopyAndUploadContentUrisTask.OnCopyTmpFilesTaskListener,
SortingOrderDialogFragment.OnSortingOrderListener, Injectable, AccountChooserInterface, ReceiveExternalFilesAdapter.OnItemClickListener {

private static final String TAG = ReceiveExternalFilesActivity.class.getSimpleName();
Expand Down Expand Up @@ -300,34 +300,17 @@ public void onSortingOrderChosen(FileSortOrder newSortOrder) {
}

@Override
public void selectFile(int position) {
// click on folder in the list
Log_OC.d(TAG, "on item click");
List<OCFile> tmpFiles = getStorageManager().getFolderContent(mFile, false);
tmpFiles = sortFileList(tmpFiles);

if (tmpFiles.isEmpty()) {
return;
}
// filter on dirtype
Vector<OCFile> files = new Vector<>();
files.addAll(tmpFiles);

if (files.size() < position) {
throw new IndexOutOfBoundsException("Incorrect item selected");
}
OCFile ocFile = files.get(position);
if (ocFile.isFolder()) {
if (ocFile.isEncrypted() &&
public void selectFile(OCFile file) {
if (file.isFolder()) {
if (file.isEncrypted() &&
!FileOperationsHelper.isEndToEndEncryptionSetup(this, getUser().orElseThrow(IllegalAccessError::new))) {
DisplayUtils.showSnackMessage(this, R.string.e2e_not_yet_setup);

return;
}

OCFile folderToEnter = files.get(position);
startSyncFolderOperation(folderToEnter);
mParents.push(folderToEnter.getFileName());
startSyncFolderOperation(file);
mParents.push(file.getFileName());
populateDirectoryList();
}
}
Expand Down Expand Up @@ -670,11 +653,6 @@ public void onBackPressed() {
}
}

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

}

@Override
public void onClick(View v) {
// click on button
Expand Down Expand Up @@ -1041,8 +1019,17 @@ public boolean onCreateOptionsMenu(Menu menu) {
menu.findItem(R.id.action_create_dir).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}

// tint search event
setupSearchView(menu);

MenuItem newFolderMenuItem = menu.findItem(R.id.action_create_dir);
newFolderMenuItem.setEnabled(mFile.canWrite());

return true;
}

private void setupSearchView(Menu menu) {
final MenuItem searchMenuItem = menu.findItem(R.id.action_search);

SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
Expand All @@ -1053,17 +1040,12 @@ public boolean onQueryTextSubmit(String query) {

@Override
public boolean onQueryTextChange(String newText) {
receiveExternalFilesAdapter.filter(newText);
return false;
}
});

MenuItem newFolderMenuItem = menu.findItem(R.id.action_create_dir);
newFolderMenuItem.setEnabled(mFile.canWrite());

// hacky as no default way is provided
viewThemeUtils.androidx.themeToolbarSearchView(searchView);

return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ReceiveExternalFilesAdapter(
private var filteredFiles: List<OCFile> = files

interface OnItemClickListener {
fun selectFile(position: Int)
fun selectFile(file: OCFile)
}

inner class ReceiveExternalViewHolder(val binding: UploaderListItemLayoutBinding) :
Expand All @@ -63,7 +63,7 @@ class ReceiveExternalFilesAdapter(
binding.root.setOnClickListener {
val position = bindingAdapterPosition
if (position != RecyclerView.NO_POSITION) {
onItemClickListener.selectFile(position)
onItemClickListener.selectFile(filteredFiles[position])
}
}
}
Expand Down

0 comments on commit 7a56062

Please sign in to comment.