From a69c74eef13c7e7a56c1b9c40861ea481eb8873d Mon Sep 17 00:00:00 2001 From: alperozturk Date: Thu, 6 Jun 2024 10:58:05 +0200 Subject: [PATCH 1/6] Add ActivityExtensions for checking dialog fragments readiness Signed-off-by: alperozturk --- .../utils/extensions/ActivityExtensions.kt | 15 +++++++++++++++ .../android/ui/activity/FileDisplayActivity.java | 1 + .../android/ui/activity/SyncedFoldersActivity.kt | 1 + .../android/ui/activity/UploadFilesActivity.java | 5 +++-- 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/com/nextcloud/utils/extensions/ActivityExtensions.kt diff --git a/app/src/main/java/com/nextcloud/utils/extensions/ActivityExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/ActivityExtensions.kt new file mode 100644 index 0000000000..269585dc4a --- /dev/null +++ b/app/src/main/java/com/nextcloud/utils/extensions/ActivityExtensions.kt @@ -0,0 +1,15 @@ +/* + * Nextcloud - Android Client + * + * SPDX-FileCopyrightText: 2024 Your Name + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +package com.nextcloud.utils.extensions + +import androidx.appcompat.app.AppCompatActivity +import androidx.fragment.app.Fragment + +fun AppCompatActivity.isDialogFragmentReady(fragment: Fragment): Boolean = isActive() && !fragment.isStateSaved() + +fun AppCompatActivity.isActive(): Boolean = !isFinishing && !isDestroyed diff --git a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java index 4e7496dc62..e597cbbc82 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -61,6 +61,7 @@ import com.nextcloud.client.preferences.AppPreferences; import com.nextcloud.client.utils.IntentUtil; import com.nextcloud.model.WorkerState; import com.nextcloud.model.WorkerStateLiveData; +import com.nextcloud.utils.extensions.ActivityExtensionsKt; import com.nextcloud.utils.extensions.BundleExtensionsKt; import com.nextcloud.utils.extensions.IntentExtensionsKt; import com.nextcloud.utils.view.FastScrollUtils; diff --git a/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt index 53fa9c3e60..b466574248 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt @@ -33,6 +33,7 @@ import com.nextcloud.client.jobs.upload.FileUploadWorker import com.nextcloud.client.preferences.AppPreferences import com.nextcloud.client.preferences.SubFolderRule import com.nextcloud.utils.extensions.getParcelableArgument +import com.nextcloud.utils.extensions.isDialogFragmentReady import com.owncloud.android.BuildConfig import com.owncloud.android.MainApp import com.owncloud.android.R diff --git a/app/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java index abfba2982a..9dd891a1f9 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java @@ -32,6 +32,7 @@ import com.nextcloud.client.account.User; import com.nextcloud.client.di.Injectable; import com.nextcloud.client.jobs.upload.FileUploadWorker; import com.nextcloud.client.preferences.AppPreferences; +import com.nextcloud.utils.extensions.ActivityExtensionsKt; import com.owncloud.android.R; import com.owncloud.android.databinding.UploadFilesLayoutBinding; import com.owncloud.android.lib.common.utils.Log_OC; @@ -479,7 +480,7 @@ public class UploadFilesActivity extends DrawerActivity implements LocalFileList */ @Override public void onCheckAvailableSpaceFinish(boolean hasEnoughSpaceAvailable, String... filesToUpload) { - if (mCurrentDialog != null) { + if (mCurrentDialog != null && ActivityExtensionsKt.isDialogFragmentReady(this, mCurrentDialog)) { mCurrentDialog.dismiss(); mCurrentDialog = null; } @@ -524,7 +525,7 @@ public class UploadFilesActivity extends DrawerActivity implements LocalFileList } else { // show a dialog to query the user if wants to move the selected files // to the ownCloud folder instead of copying - String[] args = {getString(R.string.app_name)}; + String[] args = { getString(R.string.app_name) }; ConfirmationDialogFragment dialog = ConfirmationDialogFragment.newInstance( R.string.upload_query_move_foreign_files, args, 0, R.string.common_yes, R.string.common_no, -1); dialog.setOnConfirmationListener(this); From 7b0e86ad6bb3d0d31c7b99e640fb64394335d843 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Thu, 6 Jun 2024 11:02:09 +0200 Subject: [PATCH 2/6] Fix licence header Signed-off-by: alperozturk --- .../java/com/nextcloud/utils/extensions/ActivityExtensions.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/utils/extensions/ActivityExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/ActivityExtensions.kt index 269585dc4a..c60390f34c 100644 --- a/app/src/main/java/com/nextcloud/utils/extensions/ActivityExtensions.kt +++ b/app/src/main/java/com/nextcloud/utils/extensions/ActivityExtensions.kt @@ -1,7 +1,7 @@ /* * Nextcloud - Android Client * - * SPDX-FileCopyrightText: 2024 Your Name + * SPDX-FileCopyrightText: 2024 Alper Ozturk * SPDX-License-Identifier: AGPL-3.0-or-later */ From cd0347deae51c98f82198eabfb560ee258b87687 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Thu, 6 Jun 2024 11:22:36 +0200 Subject: [PATCH 3/6] Fix crash for loading dialog fragment Signed-off-by: alperozturk --- .../com/owncloud/android/ui/activity/FileActivity.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/FileActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/FileActivity.java index ca9a891a6a..8357dccb63 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/FileActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/FileActivity.java @@ -37,6 +37,7 @@ import com.nextcloud.client.jobs.download.FileDownloadWorker; import com.nextcloud.client.jobs.upload.FileUploadHelper; import com.nextcloud.client.network.ConnectivityService; import com.nextcloud.utils.EditorUtils; +import com.nextcloud.utils.extensions.ActivityExtensionsKt; import com.nextcloud.utils.extensions.BundleExtensionsKt; import com.nextcloud.utils.extensions.IntentExtensionsKt; import com.owncloud.android.MainApp; @@ -540,8 +541,11 @@ public abstract class FileActivity extends DrawerActivity Fragment frag = getSupportFragmentManager().findFragmentByTag(DIALOG_WAIT_TAG); if (frag != null) { Log_OC.d(TAG, "dismiss loading dialog"); - LoadingDialog loading = (LoadingDialog) frag; - loading.dismissAllowingStateLoss(); + LoadingDialog loadingDialogFragment = (LoadingDialog) frag; + boolean isFragmentReady = ActivityExtensionsKt.isDialogFragmentReady(this, loadingDialogFragment); + if (isFragmentReady) { + loadingDialogFragment.dismiss(); + } } } From 6ad7152cc9c55c30f82f0025a50fc8523a5e4794 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Thu, 6 Jun 2024 11:26:50 +0200 Subject: [PATCH 4/6] Better variable naming Signed-off-by: alperozturk [skip ci] --- .../java/com/owncloud/android/ui/activity/FileActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/FileActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/FileActivity.java index 8357dccb63..2af5ceea3a 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/FileActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/FileActivity.java @@ -542,8 +542,8 @@ public abstract class FileActivity extends DrawerActivity if (frag != null) { Log_OC.d(TAG, "dismiss loading dialog"); LoadingDialog loadingDialogFragment = (LoadingDialog) frag; - boolean isFragmentReady = ActivityExtensionsKt.isDialogFragmentReady(this, loadingDialogFragment); - if (isFragmentReady) { + boolean isDialogFragmentReady = ActivityExtensionsKt.isDialogFragmentReady(this, loadingDialogFragment); + if (isDialogFragmentReady) { loadingDialogFragment.dismiss(); } } From bbda150572be1bd970da4644fc4ce361cb7f8522 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Thu, 13 Jun 2024 13:57:20 +0200 Subject: [PATCH 5/6] Fix dependency verification Signed-off-by: alperozturk --- gradle/verification-metadata.xml | 36 ++++++++++++++------------------ 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index ef5a88426f..114ea78cac 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -5151,16 +5151,14 @@ - - - - - - - - + + + + + + + + @@ -5169,16 +5167,14 @@ - - - - - - - - + + + + + + + + From d92e7f494d611e2d4edac489b6e2c9aacec7639b Mon Sep 17 00:00:00 2001 From: alperozturk Date: Thu, 13 Jun 2024 14:29:00 +0200 Subject: [PATCH 6/6] Fix code analytics Signed-off-by: alperozturk --- .../com/owncloud/android/ui/activity/SyncedFoldersActivity.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt index b466574248..53fa9c3e60 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt @@ -33,7 +33,6 @@ import com.nextcloud.client.jobs.upload.FileUploadWorker import com.nextcloud.client.preferences.AppPreferences import com.nextcloud.client.preferences.SubFolderRule import com.nextcloud.utils.extensions.getParcelableArgument -import com.nextcloud.utils.extensions.isDialogFragmentReady import com.owncloud.android.BuildConfig import com.owncloud.android.MainApp import com.owncloud.android.R