diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/IndeterminateProgressDialog.kt b/app/src/main/java/com/owncloud/android/ui/dialog/IndeterminateProgressDialog.kt index 5b4a996e8c7c..97af3f793580 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/IndeterminateProgressDialog.kt +++ b/app/src/main/java/com/owncloud/android/ui/dialog/IndeterminateProgressDialog.kt @@ -1,24 +1,21 @@ /* * Nextcloud - Android Client * - * SPDX-FileCopyrightText: 2023 Alper Ozturk + * SPDX-FileCopyrightText: 2026 Alper Ozturk * SPDX-FileCopyrightText: 2015 David A. Velasco * SPDX-FileCopyrightText: 2015 ownCloud Inc. * SPDX-License-Identifier: GPL-2.0-only AND (AGPL-3.0-or-later OR GPL-2.0-only) */ -@file:Suppress("DEPRECATION") package com.owncloud.android.ui.dialog import android.app.Dialog -import android.app.ProgressDialog -import android.content.DialogInterface import android.os.Bundle -import android.view.KeyEvent -import android.widget.ProgressBar import androidx.fragment.app.DialogFragment +import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.nextcloud.client.di.Injectable import com.owncloud.android.R +import com.owncloud.android.databinding.LoadingDialogBinding import com.owncloud.android.utils.theme.ViewThemeUtils import javax.inject.Inject @@ -26,58 +23,42 @@ class IndeterminateProgressDialog : DialogFragment(), Injectable { - @JvmField @Inject - var viewThemeUtils: ViewThemeUtils? = null + lateinit var viewThemeUtils: ViewThemeUtils - /** - * {@inheritDoc} - */ override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { - // / create indeterminate progress dialog - val progressDialog = ProgressDialog(requireActivity(), R.style.ProgressDialogTheme) - progressDialog.isIndeterminate = true - progressDialog.setOnShowListener { - val v = progressDialog.findViewById(android.R.id.progress) - viewThemeUtils?.platform?.tintDrawable(requireContext(), v.indeterminateDrawable) - } + val cancelable = requireArguments().getBoolean(ARG_CANCELABLE, false) + isCancelable = cancelable - // / set message val messageId = requireArguments().getInt(ARG_MESSAGE_ID, R.string.placeholder_sentence) - progressDialog.setMessage(getString(messageId)) - // / set cancellation behavior - val cancelable = requireArguments().getBoolean(ARG_CANCELABLE, false) - if (!cancelable) { - progressDialog.setCancelable(false) - // disable the back button - val keyListener = - DialogInterface.OnKeyListener { _, keyCode, _ -> keyCode == KeyEvent.KEYCODE_BACK } - progressDialog.setOnKeyListener(keyListener) + val binding = LoadingDialogBinding.inflate(layoutInflater).apply { + loadingText.setText(messageId) + loadingBar.indeterminateDrawable?.let { drawable -> + viewThemeUtils.platform.tintDrawable(requireContext(), drawable) + } } - return progressDialog + + val builder = MaterialAlertDialogBuilder(requireContext()) + .setView(binding.root) + .setCancelable(cancelable) + + viewThemeUtils.dialog.colorMaterialAlertDialogBackground(requireContext(), builder) + + return builder.create() } companion object { - private val ARG_MESSAGE_ID = IndeterminateProgressDialog::class.java.canonicalName?.plus(".ARG_MESSAGE_ID") - private val ARG_CANCELABLE = IndeterminateProgressDialog::class.java.canonicalName?.plus(".ARG_CANCELABLE") + private const val ARG_MESSAGE_ID = "message_id" + private const val ARG_CANCELABLE = "cancelable" - /** - * Public factory method to get dialog instances. - * - * @param messageId Resource id for a message to show in the dialog. - * @param cancelable If 'true', the dialog can be cancelled by the user input (BACK button, touch outside...) - * @return New dialog instance, ready to show. - */ @JvmStatic - fun newInstance(messageId: Int, cancelable: Boolean): IndeterminateProgressDialog { - val fragment = IndeterminateProgressDialog() - fragment.setStyle(STYLE_NO_FRAME, R.style.ownCloud_AlertDialog) - val args = Bundle() - args.putInt(ARG_MESSAGE_ID, messageId) - args.putBoolean(ARG_CANCELABLE, cancelable) - fragment.arguments = args - return fragment - } + fun newInstance(messageId: Int, cancelable: Boolean): IndeterminateProgressDialog = + IndeterminateProgressDialog().apply { + arguments = Bundle().apply { + putInt(ARG_MESSAGE_ID, messageId) + putBoolean(ARG_CANCELABLE, cancelable) + } + } } } diff --git a/app/src/main/res/drawable/process_dialog_background.xml b/app/src/main/res/drawable/process_dialog_background.xml deleted file mode 100644 index 56a0d0fa670b..000000000000 --- a/app/src/main/res/drawable/process_dialog_background.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index aded2c0b3577..35de9f1d6ed2 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -61,7 +61,6 @@ #F4F4F4 #000000 #1D1B1E - #ffffff #ffffff #000000 #2D7B41 diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 51a22e01a523..7e1c9e8608c7 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -151,14 +151,6 @@ @style/Widget.App.TextInputLayout - -