зеркало из https://github.com/nextcloud/android.git
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:
Коммит
0e9204d731
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче