From bb1887c4e6652062c9835648f0db597117b5de03 Mon Sep 17 00:00:00 2001 From: alperozturk96 Date: Mon, 16 Feb 2026 13:51:15 +0100 Subject: [PATCH 1/6] fix(unified-search): opening encrypted folder Signed-off-by: alperozturk96 --- .../ui/fragment/UnifiedSearchFragment.kt | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/UnifiedSearchFragment.kt b/app/src/main/java/com/owncloud/android/ui/fragment/UnifiedSearchFragment.kt index 7c8bd588807f..437e9e410262 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/UnifiedSearchFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/fragment/UnifiedSearchFragment.kt @@ -352,18 +352,13 @@ class UnifiedSearchFragment : } } - private fun showFile(file: OCFile, showFileActions: Boolean) { - activity.let { - if (activity is FileDisplayActivity) { - val fda = activity as FileDisplayActivity - fda.file = file - - if (showFileActions) { - fda.showFileActions(file) - } else { - fda.showFile(file, "") - } + private fun showFile(file: OCFile, showFileActions: Boolean, updateCurrentFile: Boolean = true) { + (activity as? FileDisplayActivity)?.apply { + if (updateCurrentFile) { + this.file = file } + + if (showFileActions) showFileActions(file) else showFile(file, "") } } @@ -407,7 +402,15 @@ class UnifiedSearchFragment : override fun onSearchResultClicked(searchResultEntry: SearchResultEntry) { showMoreActions = false - vm.openResult(searchResultEntry) + + val remotePath = searchResultEntry.remotePath() + OCFile.PATH_SEPARATOR + val file = storageManager.getFileByDecryptedRemotePath(remotePath) + + if (file?.isEncrypted == true) { + showFile(file, showMoreActions, updateCurrentFile = false) + } else { + vm.openResult(searchResultEntry) + } } override fun onLoadMoreClicked(providerID: ProviderID) { From 4eae600f4e11f6745bc4938dbcb33c4fae340fd9 Mon Sep 17 00:00:00 2001 From: alperozturk96 Date: Tue, 17 Feb 2026 13:39:01 +0100 Subject: [PATCH 2/6] fix(unified-search): e2ee folder tap Signed-off-by: alperozturk96 --- .../ui/activity/FileDisplayActivity.kt | 24 ++++---- .../android/ui/adapter/OCFileListAdapter.java | 14 ++++- .../SetupEncryptionDialogFragment.kt | 20 +------ .../ui/fragment/OCFileListFragment.java | 55 +++++++++++-------- 4 files changed, 57 insertions(+), 56 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt index 2b22bdb8f58f..d4ee59f4d27e 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt @@ -3003,24 +3003,20 @@ class FileDisplayActivity : } fun showFile(selectedFile: OCFile?, message: String?) { - dismissLoadingDialog() - getOCFileListFragmentFromFile(object : TransactionInterface { - override fun onOCFileListFragmentComplete(listOfFiles: OCFileListFragment) { - if (TextUtils.isEmpty(message)) { - val temp = file - file = getCurrentDir() - listOfFiles.listDirectory(getCurrentDir(), temp, MainApp.isOnlyOnDevice()) + override fun onOCFileListFragmentComplete(fragment: OCFileListFragment) { + dismissLoadingDialog() + + if (message.isNullOrEmpty()) { + val current = getCurrentDir() + fragment.listDirectory(current, file, MainApp.isOnlyOnDevice()) + file = current updateActionBarTitleAndHomeButton(null) } else { - val view = listOfFiles.view - if (view != null) { - DisplayUtils.showSnackMessage(view, message) - } - } - if (selectedFile != null) { - listOfFiles.onItemClicked(selectedFile) + fragment.view?.let { DisplayUtils.showSnackMessage(it, message) } } + + selectedFile?.let(fragment::onItemClicked) } }) } diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java b/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java index c93624ba352c..716ed87d544a 100644 --- a/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java @@ -335,9 +335,21 @@ public int getItemCount() { @Nullable public OCFile getItem(int position) { + if (mFiles == null || mFiles.isEmpty()) { + return null; + } + + if (position < 0) { + return null; + } + int newPosition = position; - if (shouldShowHeader() && position > 0) { + if (shouldShowHeader()) { + if (position == 0) { + // Header position — no file here + return null; + } newPosition = position - 1; } diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/setupEncryption/SetupEncryptionDialogFragment.kt b/app/src/main/java/com/owncloud/android/ui/dialog/setupEncryption/SetupEncryptionDialogFragment.kt index 427d2c9b75e2..5216b57fc6e1 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/setupEncryption/SetupEncryptionDialogFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/dialog/setupEncryption/SetupEncryptionDialogFragment.kt @@ -9,7 +9,6 @@ package com.owncloud.android.ui.dialog.setupEncryption import android.accounts.AccountManager import android.app.Dialog import android.content.DialogInterface -import android.content.Intent import android.os.Bundle import android.view.View import androidx.annotation.VisibleForTesting @@ -44,7 +43,6 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import java.io.IOException import java.lang.ref.WeakReference -import java.util.Arrays import javax.inject.Inject /* @@ -215,7 +213,7 @@ class SetupEncryptionDialogFragment : ) val secondKey = EncryptionUtils.decodeStringToBase64Bytes(decryptedString) - if (!Arrays.equals(firstKey, secondKey)) { + if (!firstKey.contentEquals(secondKey)) { EncryptionUtils.reportE2eError(arbitraryDataProvider, user) throw Exception("Keys do not match") } @@ -223,7 +221,7 @@ class SetupEncryptionDialogFragment : notifyResult() } catch (e: Exception) { binding.encryptionStatus.setText(R.string.end_to_end_encryption_wrong_password) - Log_OC.d(TAG, "Error while decrypting private key: " + e.message) + Log_OC.e(TAG, "Error while decrypting private key: " + e.message) } } @@ -240,22 +238,9 @@ class SetupEncryptionDialogFragment : } private fun notifyResult() { - val targetFragment = targetFragment - targetFragment?.onActivityResult( - targetRequestCode, - SETUP_ENCRYPTION_RESULT_CODE, - resultIntent - ) parentFragmentManager.setFragmentResult(RESULT_REQUEST_KEY, resultBundle) } - private val resultIntent: Intent - get() { - return Intent().apply { - putExtra(SUCCESS, true) - putExtra(ARG_POSITION, requireArguments().getInt(ARG_POSITION)) - } - } private val resultBundle: Bundle get() { return Bundle().apply { @@ -544,7 +529,6 @@ class SetupEncryptionDialogFragment : companion object { const val SUCCESS = "SUCCESS" const val SETUP_ENCRYPTION_RESULT_CODE = 101 - const val SETUP_ENCRYPTION_REQUEST_CODE = 100 const val SETUP_ENCRYPTION_DIALOG_TAG = "SETUP_ENCRYPTION_DIALOG_TAG" const val ARG_POSITION = "ARG_POSITION" const val RESULT_REQUEST_KEY = "RESULT_REQUEST" diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java index 828aca199a55..67da30db2b31 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -120,6 +120,7 @@ import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; +import org.jetbrains.annotations.NotNull; import java.io.File; import java.util.ArrayList; @@ -148,7 +149,6 @@ import static com.owncloud.android.datamodel.OCFile.ROOT_PATH; import static com.owncloud.android.ui.dialog.setupEncryption.SetupEncryptionDialogFragment.SETUP_ENCRYPTION_DIALOG_TAG; -import static com.owncloud.android.ui.dialog.setupEncryption.SetupEncryptionDialogFragment.SETUP_ENCRYPTION_REQUEST_CODE; import static com.owncloud.android.ui.fragment.SearchType.FAVORITE_SEARCH; import static com.owncloud.android.ui.fragment.SearchType.FILE_SEARCH; import static com.owncloud.android.ui.fragment.SearchType.NO_SEARCH; @@ -254,6 +254,12 @@ public void onCreate(Bundle savedInstanceState) { searchFragment = currentSearchType != null && isSearchEventSet(searchEvent); } + @Override + public void onViewCreated(@NotNull View view, @org.jetbrains.annotations.Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + listenSetupEncryptionDialogResult(); + } + @Override public void onResume() { // Don't handle search events if we're coming back from back stack @@ -1133,7 +1139,6 @@ private void folderOnItemClick(OCFile file, int position) { fileActivity.connectivityService.isNetworkAndServerAvailable(result -> { if (result) { SetupEncryptionDialogFragment dialog = SetupEncryptionDialogFragment.newInstance(user, position); - dialog.setTargetFragment(this, SETUP_ENCRYPTION_REQUEST_CODE); dialog.show(fragmentManager, SETUP_ENCRYPTION_DIALOG_TAG); } else { DisplayUtils.showSnackMessage(fileActivity, R.string.internet_connection_required_for_encrypted_folder_setup); @@ -1255,30 +1260,35 @@ private void browseToFolder(OCFile file, int position) { saveIndexAndTopPosition(position); } - @Override - public void onActivityResult(int requestCode, int resultCode, Intent data) { - if (requestCode == SETUP_ENCRYPTION_REQUEST_CODE && - resultCode == SetupEncryptionDialogFragment.SETUP_ENCRYPTION_RESULT_CODE && - data.getBooleanExtra(SetupEncryptionDialogFragment.SUCCESS, false)) { + private void listenSetupEncryptionDialogResult() { + getParentFragmentManager().setFragmentResultListener( + SetupEncryptionDialogFragment.RESULT_REQUEST_KEY, + this, + (requestKey, bundle) -> { + boolean result = bundle.getBoolean(SetupEncryptionDialogFragment.SUCCESS, false); + if (!result) { + Log_OC.w(TAG, "setup encryption dialog result is not successfully"); + } - int position = data.getIntExtra(SetupEncryptionDialogFragment.ARG_POSITION, -1); - OCFile file = mAdapter.getItem(position); + int position = bundle.getInt(SetupEncryptionDialogFragment.ARG_POSITION, -1); + if (position == -1) { + Log_OC.e(TAG, "invalid position received"); + return; + } + + OCFile file = mAdapter.getItem(position); + if (file == null) { + Log_OC.e(TAG, "file is null cannot toggle encryption"); + return; + } - if (file != null) { mContainerActivity.getFileOperationsHelper().toggleEncryption(file, true); mAdapter.setEncryptionAttributeForItemID(file.getRemoteId(), true); - } - - // update state and view of this fragment - searchFragment = false; - listDirectory(file, MainApp.isOnlyOnDevice()); - // then, notify parent activity to let it update its state and view - mContainerActivity.onBrowsedDownTo(file); - // save index and top position - saveIndexAndTopPosition(position); - } else { - super.onActivityResult(requestCode, resultCode, data); - } + searchFragment = false; + listDirectory(file, MainApp.isOnlyOnDevice()); + mContainerActivity.onBrowsedDownTo(file); + saveIndexAndTopPosition(position); + }); } /** @@ -1933,7 +1943,6 @@ public void onMessageEvent(EncryptionEvent event) { requireActivity().runOnUiThread(() -> { SetupEncryptionDialogFragment dialog = SetupEncryptionDialogFragment.newInstance(user, position); - dialog.setTargetFragment(OCFileListFragment.this, SETUP_ENCRYPTION_REQUEST_CODE); dialog.show(getParentFragmentManager(), SETUP_ENCRYPTION_DIALOG_TAG); }); } else { From eb9bd004c5d85a8f86dd0d9531f9b1478b1a6edf Mon Sep 17 00:00:00 2001 From: alperozturk96 Date: Tue, 17 Feb 2026 13:46:54 +0100 Subject: [PATCH 3/6] fix(unified-search): e2ee folder tap Signed-off-by: alperozturk96 --- .../dialog/setupEncryption/SetupEncryptionDialogFragment.kt | 4 ++++ .../com/owncloud/android/ui/fragment/OCFileListFragment.java | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/setupEncryption/SetupEncryptionDialogFragment.kt b/app/src/main/java/com/owncloud/android/ui/dialog/setupEncryption/SetupEncryptionDialogFragment.kt index 5216b57fc6e1..2967cbe3846d 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/setupEncryption/SetupEncryptionDialogFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/dialog/setupEncryption/SetupEncryptionDialogFragment.kt @@ -531,6 +531,10 @@ class SetupEncryptionDialogFragment : const val SETUP_ENCRYPTION_RESULT_CODE = 101 const val SETUP_ENCRYPTION_DIALOG_TAG = "SETUP_ENCRYPTION_DIALOG_TAG" const val ARG_POSITION = "ARG_POSITION" + + // TODO: ADD file path + const val ARG_FILE = "ARG_FILE" + const val RESULT_REQUEST_KEY = "RESULT_REQUEST" const val RESULT_KEY_CANCELLED = "IS_CANCELLED" private const val NUMBER_OF_WORDS = 12 diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java index 67da30db2b31..953411eb9803 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -1267,7 +1267,8 @@ private void listenSetupEncryptionDialogResult() { (requestKey, bundle) -> { boolean result = bundle.getBoolean(SetupEncryptionDialogFragment.SUCCESS, false); if (!result) { - Log_OC.w(TAG, "setup encryption dialog result is not successfully"); + Log_OC.d(TAG, "setup encryption dialog is dismissed"); + return; } int position = bundle.getInt(SetupEncryptionDialogFragment.ARG_POSITION, -1); From 75ea78b525a952a5dde3c6039342ffe27497532d Mon Sep 17 00:00:00 2001 From: alperozturk96 Date: Wed, 18 Feb 2026 11:27:18 +0100 Subject: [PATCH 4/6] add file path to receive file instead of position Signed-off-by: alperozturk96 --- .../SetupEncryptionDialogFragment.kt | 18 ++++++++++++++---- .../ui/fragment/OCFileListFragment.java | 13 +++++++++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/setupEncryption/SetupEncryptionDialogFragment.kt b/app/src/main/java/com/owncloud/android/ui/dialog/setupEncryption/SetupEncryptionDialogFragment.kt index 2967cbe3846d..532f544cc4a6 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/setupEncryption/SetupEncryptionDialogFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/dialog/setupEncryption/SetupEncryptionDialogFragment.kt @@ -246,6 +246,7 @@ class SetupEncryptionDialogFragment : return Bundle().apply { putBoolean(SUCCESS, true) putInt(ARG_POSITION, requireArguments().getInt(ARG_POSITION)) + putString(ARG_FILE_PATH, requireArguments().getString(ARG_FILE_PATH)) } } @@ -531,10 +532,7 @@ class SetupEncryptionDialogFragment : const val SETUP_ENCRYPTION_RESULT_CODE = 101 const val SETUP_ENCRYPTION_DIALOG_TAG = "SETUP_ENCRYPTION_DIALOG_TAG" const val ARG_POSITION = "ARG_POSITION" - - // TODO: ADD file path - const val ARG_FILE = "ARG_FILE" - + const val ARG_FILE_PATH = "ARG_FILE_PATH" const val RESULT_REQUEST_KEY = "RESULT_REQUEST" const val RESULT_KEY_CANCELLED = "IS_CANCELLED" private const val NUMBER_OF_WORDS = 12 @@ -561,5 +559,17 @@ class SetupEncryptionDialogFragment : arguments = bundle } } + + @JvmStatic + fun newInstance(user: User?, filePath: String): SetupEncryptionDialogFragment { + val bundle = Bundle().apply { + putParcelable(ARG_USER, user) + putString(ARG_FILE_PATH, filePath) + } + + return SetupEncryptionDialogFragment().apply { + arguments = bundle + } + } } } diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java index 953411eb9803..01d40b50aee9 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -1138,7 +1138,7 @@ private void folderOnItemClick(OCFile file, int position) { if (fragmentManager.findFragmentByTag(SETUP_ENCRYPTION_DIALOG_TAG) == null && requireActivity() instanceof FileActivity fileActivity) { fileActivity.connectivityService.isNetworkAndServerAvailable(result -> { if (result) { - SetupEncryptionDialogFragment dialog = SetupEncryptionDialogFragment.newInstance(user, position); + SetupEncryptionDialogFragment dialog = SetupEncryptionDialogFragment.newInstance(user, file.getRemotePath()); dialog.show(fragmentManager, SETUP_ENCRYPTION_DIALOG_TAG); } else { DisplayUtils.showSnackMessage(fileActivity, R.string.internet_connection_required_for_encrypted_folder_setup); @@ -1279,7 +1279,16 @@ private void listenSetupEncryptionDialogResult() { OCFile file = mAdapter.getItem(position); if (file == null) { - Log_OC.e(TAG, "file is null cannot toggle encryption"); + Log_OC.w(TAG, "file is null, checking via remote path"); + } + + if (file == null) { + String fileRemotePath = bundle.getString(SetupEncryptionDialogFragment.ARG_FILE_PATH, null); + file = mContainerActivity.getStorageManager().getFileByDecryptedRemotePath(fileRemotePath); + } + + if (file == null) { + Log_OC.e(TAG,"file is null, cannot toggle encryption"); return; } From 898328b3709825d03c7faaa157a2c24a02c37913 Mon Sep 17 00:00:00 2001 From: alperozturk96 Date: Wed, 18 Feb 2026 11:57:48 +0100 Subject: [PATCH 5/6] use file path instead position Signed-off-by: alperozturk96 --- .../dialog/SetupEncryptionDialogFragmentIT.kt | 4 +-- .../ui/activity/SetupEncryptionActivity.kt | 6 ++--- .../SetupEncryptionDialogFragment.kt | 21 +-------------- .../ui/fragment/OCFileListFragment.java | 27 +++++-------------- 4 files changed, 13 insertions(+), 45 deletions(-) diff --git a/app/src/androidTest/java/com/owncloud/android/ui/dialog/SetupEncryptionDialogFragmentIT.kt b/app/src/androidTest/java/com/owncloud/android/ui/dialog/SetupEncryptionDialogFragmentIT.kt index 7f2717688a76..576b11515063 100644 --- a/app/src/androidTest/java/com/owncloud/android/ui/dialog/SetupEncryptionDialogFragmentIT.kt +++ b/app/src/androidTest/java/com/owncloud/android/ui/dialog/SetupEncryptionDialogFragmentIT.kt @@ -28,7 +28,7 @@ class SetupEncryptionDialogFragmentIT : AbstractIT() { launchActivity().use { scenario -> var sut: SetupEncryptionDialogFragment? = null scenario.onActivity { activity -> - sut = SetupEncryptionDialogFragment.newInstance(user, 0) + sut = SetupEncryptionDialogFragment.newInstance(user, null) sut.show(activity.supportFragmentManager, "1") val keyWords = arrayListOf( "ability", @@ -64,7 +64,7 @@ class SetupEncryptionDialogFragmentIT : AbstractIT() { launchActivity().use { scenario -> var sut: SetupEncryptionDialogFragment? = null scenario.onActivity { activity -> - sut = SetupEncryptionDialogFragment.newInstance(user, 0) + sut = SetupEncryptionDialogFragment.newInstance(user, null) sut.show(activity.supportFragmentManager, "1") sut.errorSavingKeys() } diff --git a/app/src/main/java/com/owncloud/android/ui/activity/SetupEncryptionActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/SetupEncryptionActivity.kt index d5388c0d9995..65f438fa5c56 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/SetupEncryptionActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/SetupEncryptionActivity.kt @@ -27,7 +27,7 @@ class SetupEncryptionActivity : AppCompatActivity() { finish() } - val setupEncryptionDialogFragment = SetupEncryptionDialogFragment.newInstance(user, -1) + val setupEncryptionDialogFragment = SetupEncryptionDialogFragment.newInstance(user, null) supportFragmentManager.setFragmentResultListener( SetupEncryptionDialogFragment.RESULT_REQUEST_KEY, this @@ -52,8 +52,8 @@ class SetupEncryptionActivity : AppCompatActivity() { result.getBoolean(SetupEncryptionDialogFragment.SUCCESS) ) intent.putExtra( - SetupEncryptionDialogFragment.ARG_POSITION, - result.getInt(SetupEncryptionDialogFragment.ARG_POSITION) + SetupEncryptionDialogFragment.ARG_FILE_PATH, + result.getInt(SetupEncryptionDialogFragment.ARG_FILE_PATH) ) return intent } diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/setupEncryption/SetupEncryptionDialogFragment.kt b/app/src/main/java/com/owncloud/android/ui/dialog/setupEncryption/SetupEncryptionDialogFragment.kt index 532f544cc4a6..057873270a5e 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/setupEncryption/SetupEncryptionDialogFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/dialog/setupEncryption/SetupEncryptionDialogFragment.kt @@ -245,7 +245,6 @@ class SetupEncryptionDialogFragment : get() { return Bundle().apply { putBoolean(SUCCESS, true) - putInt(ARG_POSITION, requireArguments().getInt(ARG_POSITION)) putString(ARG_FILE_PATH, requireArguments().getString(ARG_FILE_PATH)) } } @@ -531,7 +530,6 @@ class SetupEncryptionDialogFragment : const val SUCCESS = "SUCCESS" const val SETUP_ENCRYPTION_RESULT_CODE = 101 const val SETUP_ENCRYPTION_DIALOG_TAG = "SETUP_ENCRYPTION_DIALOG_TAG" - const val ARG_POSITION = "ARG_POSITION" const val ARG_FILE_PATH = "ARG_FILE_PATH" const val RESULT_REQUEST_KEY = "RESULT_REQUEST" const val RESULT_KEY_CANCELLED = "IS_CANCELLED" @@ -543,25 +541,8 @@ class SetupEncryptionDialogFragment : private const val KEY_FAILED = "KEY_FAILED" private const val KEY_GENERATE = "KEY_GENERATE" - /** - * Public factory method to create new SetupEncryptionDialogFragment instance - * - * @return Dialog ready to show. - */ @JvmStatic - fun newInstance(user: User?, position: Int): SetupEncryptionDialogFragment { - val bundle = Bundle().apply { - putParcelable(ARG_USER, user) - putInt(ARG_POSITION, position) - } - - return SetupEncryptionDialogFragment().apply { - arguments = bundle - } - } - - @JvmStatic - fun newInstance(user: User?, filePath: String): SetupEncryptionDialogFragment { + fun newInstance(user: User?, filePath: String?): SetupEncryptionDialogFragment { val bundle = Bundle().apply { putParcelable(ARG_USER, user) putString(ARG_FILE_PATH, filePath) diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java index 01d40b50aee9..b2612cf54554 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -1271,22 +1271,13 @@ private void listenSetupEncryptionDialogResult() { return; } - int position = bundle.getInt(SetupEncryptionDialogFragment.ARG_POSITION, -1); - if (position == -1) { - Log_OC.e(TAG, "invalid position received"); + String fileRemotePath = bundle.getString(SetupEncryptionDialogFragment.ARG_FILE_PATH, null); + if (fileRemotePath == null) { + Log_OC.e(TAG, "file path is null"); return; } - OCFile file = mAdapter.getItem(position); - if (file == null) { - Log_OC.w(TAG, "file is null, checking via remote path"); - } - - if (file == null) { - String fileRemotePath = bundle.getString(SetupEncryptionDialogFragment.ARG_FILE_PATH, null); - file = mContainerActivity.getStorageManager().getFileByDecryptedRemotePath(fileRemotePath); - } - + OCFile file = mContainerActivity.getStorageManager().getFileByDecryptedRemotePath(fileRemotePath); if (file == null) { Log_OC.e(TAG,"file is null, cannot toggle encryption"); return; @@ -1297,6 +1288,8 @@ private void listenSetupEncryptionDialogResult() { searchFragment = false; listDirectory(file, MainApp.isOnlyOnDevice()); mContainerActivity.onBrowsedDownTo(file); + + int position = mAdapter.getItemPosition(file); saveIndexAndTopPosition(position); }); } @@ -1944,15 +1937,9 @@ public void onMessageEvent(EncryptionEvent event) { if (publicKey.isEmpty() || privateKey.isEmpty()) { Log_OC.d(TAG, "no public key for " + user.getAccountName()); - int position; - if (file != null) { - position = mAdapter.getItemPosition(file); - } else { - position = -1; - } requireActivity().runOnUiThread(() -> { - SetupEncryptionDialogFragment dialog = SetupEncryptionDialogFragment.newInstance(user, position); + SetupEncryptionDialogFragment dialog = SetupEncryptionDialogFragment.newInstance(user, file.getRemotePath()); dialog.show(getParentFragmentManager(), SETUP_ENCRYPTION_DIALOG_TAG); }); } else { From 3c4b0c93b6b03de3957c6072de538db37dcc0bf4 Mon Sep 17 00:00:00 2001 From: alperozturk96 Date: Wed, 18 Feb 2026 14:27:55 +0100 Subject: [PATCH 6/6] use androidx imports instead of jetbrains Signed-off-by: alperozturk96 --- .../com/owncloud/android/ui/fragment/OCFileListFragment.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java index b2612cf54554..bb5a065114c4 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -120,7 +120,6 @@ import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; -import org.jetbrains.annotations.NotNull; import java.io.File; import java.util.ArrayList; @@ -255,7 +254,7 @@ public void onCreate(Bundle savedInstanceState) { } @Override - public void onViewCreated(@NotNull View view, @org.jetbrains.annotations.Nullable Bundle savedInstanceState) { + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); listenSetupEncryptionDialogResult(); }