tweaking the Delete note dialog a bit

This commit is contained in:
tibbi 2021-11-17 22:02:39 +01:00
parent 1f8b408445
commit 2542f6ea8f
2 changed files with 31 additions and 18 deletions

View File

@ -16,17 +16,20 @@ class DeleteNoteDialog(val activity: SimpleActivity, val note: Note, val callbac
val view = activity.layoutInflater.inflate(R.layout.dialog_delete_note, null).apply {
if (note.path.isNotEmpty()) {
delete_note_checkbox.text = String.format(activity.getString(R.string.delete_file_itself), note.path)
delete_note_checkbox.beVisible()
delete_note_checkbox_holder.beVisible()
delete_note_checkbox_holder.setOnClickListener {
delete_note_checkbox.toggle()
}
}
delete_note_description.text = message
}
AlertDialog.Builder(activity)
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed(view.delete_note_checkbox.isChecked) }
.setNegativeButton(R.string.cancel, null)
.create().apply {
activity.setupDialogStuff(view, this)
}
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed(view.delete_note_checkbox.isChecked) }
.setNegativeButton(R.string.cancel, null)
.create().apply {
activity.setupDialogStuff(view, this)
}
}
private fun dialogConfirmed(deleteFile: Boolean) {

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/delete_note_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -9,21 +10,30 @@
android:id="@+id/delete_note_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/small_margin"
android:layout_marginTop="@dimen/medium_margin"
android:padding="@dimen/activity_margin"
android:textSize="@dimen/bigger_text_size" />
android:textSize="@dimen/bigger_text_size"
tools:text="@string/delete_note_prompt_message" />
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/delete_note_checkbox"
<RelativeLayout
android:id="@+id/delete_note_checkbox_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/activity_margin"
android:layout_marginEnd="@dimen/activity_margin"
android:checked="false"
android:paddingStart="@dimen/activity_margin"
android:paddingTop="@dimen/small_margin"
android:paddingEnd="@dimen/activity_margin"
android:paddingBottom="@dimen/small_margin"
android:text="@string/delete_file_itself"
android:visibility="gone" />
android:background="?attr/selectableItemBackground"
android:padding="@dimen/activity_margin"
android:visibility="gone">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/delete_note_checkbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/small_margin"
android:background="@null"
android:checked="false"
android:clickable="false"
android:layoutDirection="rtl"
android:text="@string/delete_file_itself" />
</RelativeLayout>
</LinearLayout>