mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Add a warning message in save progress dialog
This commit is contained in:
@@ -26,7 +26,7 @@ import com.kunzisoft.keepass.tasks.ActionRunnable
|
|||||||
import com.kunzisoft.keepass.tasks.ProgressTaskDialogFragment
|
import com.kunzisoft.keepass.tasks.ProgressTaskDialogFragment
|
||||||
import com.kunzisoft.keepass.tasks.ProgressTaskUpdater
|
import com.kunzisoft.keepass.tasks.ProgressTaskUpdater
|
||||||
|
|
||||||
open class SaveDatabaseProgressDialogRunnable(var contextDatabase: FragmentActivity,
|
open class SaveDatabaseProgressDialogRunnable(private var contextDatabase: FragmentActivity,
|
||||||
database: Database,
|
database: Database,
|
||||||
private val actionRunnable: ((ProgressTaskUpdater)-> ActionRunnable)?,
|
private val actionRunnable: ((ProgressTaskUpdater)-> ActionRunnable)?,
|
||||||
save: Boolean):
|
save: Boolean):
|
||||||
@@ -36,7 +36,9 @@ open class SaveDatabaseProgressDialogRunnable(var contextDatabase: FragmentActiv
|
|||||||
// Show the dialog
|
// Show the dialog
|
||||||
val progressTaskUpdater : ProgressTaskUpdater = ProgressTaskDialogFragment.start(
|
val progressTaskUpdater : ProgressTaskUpdater = ProgressTaskDialogFragment.start(
|
||||||
contextDatabase.supportFragmentManager,
|
contextDatabase.supportFragmentManager,
|
||||||
R.string.saving_database)
|
R.string.saving_database,
|
||||||
|
null,
|
||||||
|
R.string.do_not_kill_app)
|
||||||
|
|
||||||
// Do the action if defined
|
// Do the action if defined
|
||||||
actionRunnable?.invoke(progressTaskUpdater)?.run()
|
actionRunnable?.invoke(progressTaskUpdater)?.run()
|
||||||
|
|||||||
@@ -40,9 +40,12 @@ open class ProgressTaskDialogFragment : DialogFragment(), ProgressTaskUpdater {
|
|||||||
private var title = UNDEFINED
|
private var title = UNDEFINED
|
||||||
@StringRes
|
@StringRes
|
||||||
private var message = UNDEFINED
|
private var message = UNDEFINED
|
||||||
|
@StringRes
|
||||||
|
private var warning = UNDEFINED
|
||||||
|
|
||||||
private var titleView: TextView? = null
|
private var titleView: TextView? = null
|
||||||
private var messageView: TextView? = null
|
private var messageView: TextView? = null
|
||||||
|
private var warningView: TextView? = null
|
||||||
private var progressView: ProgressBar? = null
|
private var progressView: ProgressBar? = null
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
@@ -60,10 +63,12 @@ open class ProgressTaskDialogFragment : DialogFragment(), ProgressTaskUpdater {
|
|||||||
|
|
||||||
titleView = root.findViewById(R.id.progress_dialog_title)
|
titleView = root.findViewById(R.id.progress_dialog_title)
|
||||||
messageView = root.findViewById(R.id.progress_dialog_message)
|
messageView = root.findViewById(R.id.progress_dialog_message)
|
||||||
|
warningView = root.findViewById(R.id.progress_dialog_warning)
|
||||||
progressView = root.findViewById(R.id.progress_dialog_bar)
|
progressView = root.findViewById(R.id.progress_dialog_bar)
|
||||||
|
|
||||||
updateTitle(title)
|
updateTitle(title)
|
||||||
updateMessage(message)
|
updateMessage(message)
|
||||||
|
updateWarning(warning)
|
||||||
|
|
||||||
isCancelable = false
|
isCancelable = false
|
||||||
Util.lockScreenOrientation(it)
|
Util.lockScreenOrientation(it)
|
||||||
@@ -91,16 +96,21 @@ open class ProgressTaskDialogFragment : DialogFragment(), ProgressTaskUpdater {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateTitle(resId: Int) {
|
fun updateTitle(@StringRes resId: Int) {
|
||||||
this.title = resId
|
this.title = resId
|
||||||
updateView(titleView, title)
|
updateView(titleView, title)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateMessage(resId: Int) {
|
override fun updateMessage(@StringRes resId: Int) {
|
||||||
this.message = resId
|
this.message = resId
|
||||||
updateView(messageView, message)
|
updateView(messageView, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateWarning(@StringRes resId: Int) {
|
||||||
|
this.warning = resId
|
||||||
|
updateView(warningView, warning)
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private const val PROGRESS_TASK_DIALOG_TAG = "progressDialogFragment"
|
private const val PROGRESS_TASK_DIALOG_TAG = "progressDialogFragment"
|
||||||
@@ -109,13 +119,17 @@ open class ProgressTaskDialogFragment : DialogFragment(), ProgressTaskUpdater {
|
|||||||
|
|
||||||
fun start(fragmentManager: FragmentManager,
|
fun start(fragmentManager: FragmentManager,
|
||||||
@StringRes titleId: Int,
|
@StringRes titleId: Int,
|
||||||
@StringRes messageId: Int? = null): ProgressTaskDialogFragment {
|
@StringRes messageId: Int? = null,
|
||||||
|
@StringRes warningId: Int? = null): ProgressTaskDialogFragment {
|
||||||
// Create an instance of the dialog fragment and show it
|
// Create an instance of the dialog fragment and show it
|
||||||
val dialog = ProgressTaskDialogFragment()
|
val dialog = ProgressTaskDialogFragment()
|
||||||
dialog.updateTitle(titleId)
|
dialog.updateTitle(titleId)
|
||||||
messageId?.let {
|
messageId?.let {
|
||||||
dialog.updateMessage(it)
|
dialog.updateMessage(it)
|
||||||
}
|
}
|
||||||
|
warningId?.let {
|
||||||
|
dialog.updateWarning(it)
|
||||||
|
}
|
||||||
dialog.show(fragmentManager, PROGRESS_TASK_DIALOG_TAG)
|
dialog.show(fragmentManager, PROGRESS_TASK_DIALOG_TAG)
|
||||||
return dialog
|
return dialog
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.kunzisoft.keepass.tasks;
|
package com.kunzisoft.keepass.tasks;
|
||||||
|
|
||||||
|
import android.support.annotation.StringRes;
|
||||||
|
|
||||||
public interface ProgressTaskUpdater {
|
public interface ProgressTaskUpdater {
|
||||||
void updateMessage(int resId);
|
void updateMessage(@StringRes int resId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,17 @@
|
|||||||
android:layout_marginEnd="20dp"
|
android:layout_marginEnd="20dp"
|
||||||
style="@style/KeepassDXStyle.TextAppearance.SmallTitle"/>
|
style="@style/KeepassDXStyle.TextAppearance.SmallTitle"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/progress_dialog_warning"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:layout_marginRight="20dp"
|
||||||
|
android:layout_marginStart="20dp"
|
||||||
|
android:layout_marginEnd="20dp"
|
||||||
|
style="@style/KeepassDXStyle.TextAppearance.WarningTextStyle"/>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progress_dialog_bar"
|
android:id="@+id/progress_dialog_bar"
|
||||||
style="?android:attr/progressBarStyleHorizontal"
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
|
|||||||
@@ -174,6 +174,7 @@
|
|||||||
<string name="parallelism">Parallelism</string>
|
<string name="parallelism">Parallelism</string>
|
||||||
<string name="parallelism_explanation">Degree of parallelism (i.e. number of threads) used by the key derivation function.</string>
|
<string name="parallelism_explanation">Degree of parallelism (i.e. number of threads) used by the key derivation function.</string>
|
||||||
<string name="saving_database">Saving database…</string>
|
<string name="saving_database">Saving database…</string>
|
||||||
|
<string name="do_not_kill_app">Do not kill the app…</string>
|
||||||
<string name="space">Space</string>
|
<string name="space">Space</string>
|
||||||
<string name="search_label">Search</string>
|
<string name="search_label">Search</string>
|
||||||
<string name="sort_menu">Sort</string>
|
<string name="sort_menu">Sort</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user