mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-03-21 02:50:07 +01:00
fix #358, allow creating a new note from the Open Note dialog
This commit is contained in:
parent
4610bd4127
commit
50281671e4
@ -914,8 +914,12 @@ class MainActivity : SimpleActivity() {
|
||||
}
|
||||
|
||||
private fun displayOpenNoteDialog() {
|
||||
OpenNoteDialog(this) {
|
||||
updateSelectedNote(it)
|
||||
OpenNoteDialog(this) { noteId, newNote ->
|
||||
if (newNote == null) {
|
||||
updateSelectedNote(noteId)
|
||||
} else {
|
||||
addNewNote(newNote)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ import com.simplemobiletools.notes.pro.models.Note
|
||||
import kotlinx.android.synthetic.main.dialog_open_note.view.*
|
||||
import kotlinx.android.synthetic.main.open_note_item.view.*
|
||||
|
||||
class OpenNoteDialog(val activity: Activity, val callback: (checkedId: Long) -> Unit) {
|
||||
class OpenNoteDialog(val activity: Activity, val callback: (checkedId: Long, newNote: Note?) -> Unit) {
|
||||
private var dialog: AlertDialog? = null
|
||||
|
||||
init {
|
||||
@ -24,6 +24,14 @@ class OpenNoteDialog(val activity: Activity, val callback: (checkedId: Long) ->
|
||||
NotesHelper(activity).getNotes {
|
||||
initDialog(it, view)
|
||||
}
|
||||
|
||||
view.dialog_open_note_new_radio.setOnClickListener {
|
||||
view.dialog_open_note_new_radio.isChecked = false
|
||||
NewNoteDialog(activity) {
|
||||
callback(0, it)
|
||||
dialog?.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initDialog(notes: ArrayList<Note>, view: View) {
|
||||
@ -37,7 +45,7 @@ class OpenNoteDialog(val activity: Activity, val callback: (checkedId: Long) ->
|
||||
id = note.id!!.toInt()
|
||||
|
||||
setOnClickListener {
|
||||
callback(note.id!!)
|
||||
callback(note.id!!, null)
|
||||
dialog?.dismiss()
|
||||
}
|
||||
}
|
||||
@ -53,8 +61,8 @@ class OpenNoteDialog(val activity: Activity, val callback: (checkedId: Long) ->
|
||||
}
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.open_note)
|
||||
}
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.open_note)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,41 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/dialog_open_note_linear"
|
||||
<RelativeLayout
|
||||
android:id="@+id/dialog_open_note_wrapper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:orientation="vertical" />
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/dialog_open_note_linear"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:orientation="vertical" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dialog_open_note_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:layout_below="@+id/dialog_open_note_linear"
|
||||
android:background="@color/divider_grey"
|
||||
android:importantForAccessibility="no" />
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/dialog_open_note_create_new"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/dialog_open_note_divider"
|
||||
android:padding="@dimen/normal_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||
android:id="@+id/dialog_open_note_new_radio"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/normal_margin"
|
||||
android:paddingBottom="@dimen/normal_margin"
|
||||
android:text="@string/create_new_note" />
|
||||
|
||||
</RadioGroup>
|
||||
</RelativeLayout>
|
||||
</ScrollView>
|
||||
|
Loading…
x
Reference in New Issue
Block a user