Merge pull request #13100 from nextcloud/backport/13075/stable-3.29

[stable-3.29] Bugfix Add ActivityExtensions for Checking Dialog Fragments
This commit is contained in:
Tobias Kaminsky 2024-06-14 13:35:31 +02:00 коммит произвёл GitHub
Родитель 8203387853 d92e7f494d
Коммит 0e9204d731
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
4 изменённых файлов: 25 добавлений и 4 удалений

Просмотреть файл

@ -0,0 +1,15 @@
/*
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2024 Alper Ozturk <alper.ozturk@nextcloud.com>
* 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

Просмотреть файл

@ -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 isDialogFragmentReady = ActivityExtensionsKt.isDialogFragmentReady(this, loadingDialogFragment);
if (isDialogFragmentReady) {
loadingDialogFragment.dismiss();
}
}
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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);