change the way new note types are determined, to a radio button

This commit is contained in:
tibbi 2018-12-09 10:00:06 +01:00
parent 60671c7774
commit 57450ac5f7
3 changed files with 37 additions and 13 deletions

View File

@ -31,7 +31,7 @@ class NewNoteDialog(val activity: Activity, callback: (note: Note) -> Unit) {
title.isEmpty() -> activity.toast(R.string.no_title)
activity.notesDB.getNoteIdWithTitle(title) != null -> activity.toast(R.string.title_taken)
else -> {
val type = if (view.note_checklist.isChecked) TYPE_CHECKLIST else TYPE_TEXT
val type = if (view.new_note_type.checkedRadioButtonId == view.type_checklist.id) TYPE_CHECKLIST else TYPE_TEXT
val newNote = Note(null, title, "", type)
callback(newNote)
dismiss()

View File

@ -1,13 +1,14 @@
<?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/open_file_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin">
android:paddingTop="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/open_file_filename_label"
@ -20,10 +21,11 @@
android:id="@+id/open_file_filename"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_margin"
android:layout_marginLeft="@dimen/activity_margin"
android:layout_marginBottom="@dimen/activity_margin"
android:paddingTop="@dimen/small_margin"
android:paddingRight="@dimen/small_margin"
android:paddingTop="@dimen/small_margin"/>
tools:text="myfile.txt"/>
<RadioGroup
android:id="@+id/open_file_type"
@ -35,16 +37,16 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="true"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingBottom="@dimen/activity_margin"
android:text="@string/update_file_at_note"/>
<com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/open_file_content_only"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingBottom="@dimen/activity_margin"
android:text="@string/only_import_file_content"/>
</RadioGroup>

View File

@ -18,13 +18,35 @@
android:textCursorDrawable="@null"
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/note_checklist"
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/new_note_type_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/small_margin"
android:paddingRight="@dimen/small_margin"
android:text="@string/new_note_type"/>
<RadioGroup
android:id="@+id/new_note_type"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/type_text_note"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="true"
android:paddingTop="@dimen/activity_margin"
android:paddingBottom="@dimen/activity_margin"
android:text="@string/text_note"/>
<com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/type_checklist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin"
android:paddingBottom="@dimen/activity_margin"
android:text="@string/checklist"/>
</RadioGroup>
</LinearLayout>