mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Compare commits
1 Commits
4.1.9
...
feature/Ca
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df33c5feb5 |
@@ -7,6 +7,7 @@ import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.IBinder
|
||||
import android.view.View
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import com.kunzisoft.keepass.app.database.CipherDatabaseEntity
|
||||
import com.kunzisoft.keepass.crypto.keyDerivation.KdfEngine
|
||||
@@ -59,12 +60,16 @@ class ProgressDialogThread(private val activity: FragmentActivity,
|
||||
private val actionTaskListener = object: DatabaseTaskNotificationService.ActionTaskListener {
|
||||
override fun onStartAction(titleId: Int?, messageId: Int?, warningId: Int?) {
|
||||
TimeoutHelper.temporarilyDisableTimeout()
|
||||
startOrUpdateDialog(titleId, messageId, warningId)
|
||||
startOrUpdateDialog(titleId, messageId, warningId, View.OnClickListener {
|
||||
mBinder?.cancelTask()
|
||||
})
|
||||
}
|
||||
|
||||
override fun onUpdateAction(titleId: Int?, messageId: Int?, warningId: Int?) {
|
||||
TimeoutHelper.temporarilyDisableTimeout()
|
||||
startOrUpdateDialog(titleId, messageId, warningId)
|
||||
startOrUpdateDialog(titleId, messageId, warningId, View.OnClickListener {
|
||||
mBinder?.cancelTask()
|
||||
})
|
||||
}
|
||||
|
||||
override fun onStopAction(actionTask: String, result: ActionRunnable.Result) {
|
||||
@@ -75,7 +80,8 @@ class ProgressDialogThread(private val activity: FragmentActivity,
|
||||
}
|
||||
}
|
||||
|
||||
private fun startOrUpdateDialog(titleId: Int?, messageId: Int?, warningId: Int?) {
|
||||
private fun startOrUpdateDialog(titleId: Int?, messageId: Int?, warningId: Int?,
|
||||
cancelableListener: View.OnClickListener?) {
|
||||
var progressTaskDialogFragment = retrieveProgressDialog(activity)
|
||||
if (progressTaskDialogFragment == null) {
|
||||
progressTaskDialogFragment = ProgressTaskDialogFragment.build()
|
||||
@@ -91,6 +97,7 @@ class ProgressDialogThread(private val activity: FragmentActivity,
|
||||
warningId?.let {
|
||||
updateWarning(it)
|
||||
}
|
||||
setCancelButton(cancelableListener)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.os.Binder
|
||||
import android.os.Bundle
|
||||
import android.os.IBinder
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.app.database.CipherDatabaseEntity
|
||||
import com.kunzisoft.keepass.app.database.FileDatabaseHistoryAction
|
||||
@@ -48,6 +49,10 @@ class DatabaseTaskNotificationService : NotificationService(), ProgressTaskUpdat
|
||||
fun removeActionTaskListener(actionTaskListener: ActionTaskListener) {
|
||||
mActionTaskListeners.remove(actionTaskListener)
|
||||
}
|
||||
|
||||
fun cancelTask() {
|
||||
actionRunnableAsyncTask?.cancel(true)
|
||||
}
|
||||
}
|
||||
|
||||
interface ActionTaskListener {
|
||||
|
||||
@@ -27,6 +27,7 @@ import androidx.fragment.app.DialogFragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import com.kunzisoft.keepass.R
|
||||
@@ -44,6 +45,7 @@ open class ProgressTaskDialogFragment : DialogFragment(), ProgressTaskUpdater {
|
||||
private var messageView: TextView? = null
|
||||
private var warningView: TextView? = null
|
||||
private var progressView: ProgressBar? = null
|
||||
private var cancelButton: Button? = null
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
|
||||
@@ -62,6 +64,7 @@ open class ProgressTaskDialogFragment : DialogFragment(), ProgressTaskUpdater {
|
||||
messageView = root.findViewById(R.id.progress_dialog_message)
|
||||
warningView = root.findViewById(R.id.progress_dialog_warning)
|
||||
progressView = root.findViewById(R.id.progress_dialog_bar)
|
||||
cancelButton = root.findViewById(R.id.progress_dialog_cancel_button)
|
||||
|
||||
updateTitle(title)
|
||||
updateMessage(message)
|
||||
@@ -104,6 +107,15 @@ open class ProgressTaskDialogFragment : DialogFragment(), ProgressTaskUpdater {
|
||||
updateView(warningView, warning)
|
||||
}
|
||||
|
||||
fun setCancelButton(onClickListener: View.OnClickListener?) {
|
||||
if (onClickListener == null) {
|
||||
cancelButton?.visibility = View.GONE
|
||||
} else {
|
||||
cancelButton?.setOnClickListener(onClickListener)
|
||||
cancelButton?.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
private const val PROGRESS_TASK_DIALOG_TAG = "progressDialogFragment"
|
||||
|
||||
@@ -46,4 +46,11 @@
|
||||
android:indeterminate="true"
|
||||
android:max="100"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/progress_dialog_cancel_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:text="@android:string/cancel"/>
|
||||
|
||||
</LinearLayout>
|
||||
Reference in New Issue
Block a user