Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,83 +1,64 @@
/*
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2023 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-FileCopyrightText: 2026 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-FileCopyrightText: 2015 David A. Velasco <dvelasco@solidgear.es>
* 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

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<ProgressBar>(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)
}
}
}
}
17 changes: 0 additions & 17 deletions app/src/main/res/drawable/process_dialog_background.xml

This file was deleted.

1 change: 0 additions & 1 deletion app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
<color name="task_container">#F4F4F4</color>
<color name="icon_on_nc_grey">#000000</color>
<color name="foreground_highlight">#1D1B1E</color>
<color name="process_dialog_background">#ffffff</color>
<color name="indicator_dot_selected">#ffffff</color>
<color name="drawer_shadow">#000000</color>
<color name="online">#2D7B41</color>
Expand Down
8 changes: 0 additions & 8 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,6 @@
<item name="textInputStyle">@style/Widget.App.TextInputLayout</item>
</style>

<style name="ProgressDialogTheme" parent="ownCloud.Dialog">
<item name="colorAccent">@color/color_accent</item>
<item name="android:textColor">@color/login_text_color</item>
<item name="android:windowFrame">@color/transparent</item>
<item name="android:windowBackground">@color/transparent</item>
<item name="android:windowTitleBackgroundStyle">@drawable/process_dialog_background</item>
</style>

<style name="ownCloud.SearchView" parent="Widget.AppCompat.SearchView">
<!-- Close button icon -->
<item name="closeIcon">@drawable/ic_close</item>
Expand Down
Loading