adding a placeholder at empty checklists

This commit is contained in:
tibbi 2018-12-09 10:40:50 +01:00
parent 57450ac5f7
commit 334056852a
24 changed files with 91 additions and 15 deletions

View File

@ -42,6 +42,7 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
val checklistItemType = object : TypeToken<List<ChecklistItem>>() {}.type
items = Gson().fromJson<ArrayList<ChecklistItem>>(note!!.value, checklistItemType) ?: ArrayList(1)
context!!.updateTextColors(view.checklist_holder)
setupFragment()
}
}
@ -56,22 +57,42 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
private fun setupFragment() {
val plusIcon = resources.getColoredDrawableWithColor(R.drawable.ic_plus, if (context!!.isBlackAndWhiteTheme()) Color.BLACK else Color.WHITE)
view.checklist_fab.apply {
setImageDrawable(plusIcon)
background.applyColorFilter(context!!.getAdjustedPrimaryColor())
setOnClickListener {
NewChecklistItemDialog(activity as SimpleActivity) {
val currentMaxId = items.maxBy { it.id }?.id ?: 0
val checklistItem = ChecklistItem(currentMaxId + 1, it, false)
items.add(checklistItem)
saveNote()
view.apply {
checklist_fab.apply {
setImageDrawable(plusIcon)
background.applyColorFilter(context!!.getAdjustedPrimaryColor())
setOnClickListener {
showNewItemDialog()
}
}
fragment_placeholder_2.apply {
setTextColor(context!!.getAdjustedPrimaryColor())
underlineText()
setOnClickListener {
showNewItemDialog()
}
}
}
setupAdapter()
}
private fun showNewItemDialog() {
NewChecklistItemDialog(activity as SimpleActivity) {
val currentMaxId = items.maxBy { it.id }?.id ?: 0
val checklistItem = ChecklistItem(currentMaxId + 1, it, false)
items.add(checklistItem)
saveNote()
}
}
private fun setupAdapter() {
view.apply {
fragment_placeholder.beVisibleIf(items.isEmpty())
fragment_placeholder_2.beVisibleIf(items.isEmpty())
checklist_list.beVisibleIf(items.isNotEmpty())
}
ChecklistAdapter(activity as SimpleActivity, items, this, view.checklist_list) {
val clickedNote = it as ChecklistItem
clickedNote.isDone = !clickedNote.isDone
@ -101,5 +122,6 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
}
override fun refreshItems() {
setupAdapter()
}
}

View File

@ -6,13 +6,45 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.simplemobiletools.commons.views.MyRecyclerView
android:id="@+id/checklist_list"
<RelativeLayout
android:id="@+id/checklist_items_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:overScrollMode="never"
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager"/>
android:layout_height="match_parent">
<com.simplemobiletools.commons.views.MyRecyclerView
android:id="@+id/checklist_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:overScrollMode="never"
android:visibility="gone"
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/fragment_placeholder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_margin"
android:gravity="center"
android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin"
android:text="@string/checklist_is_empty"
android:textSize="@dimen/bigger_text_size"
android:visibility="gone"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/fragment_placeholder_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/fragment_placeholder"
android:layout_centerHorizontal="true"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:padding="@dimen/activity_margin"
android:text="@string/add_new_checklist_item"
android:textSize="@dimen/bigger_text_size"
android:visibility="gone"/>
</RelativeLayout>
<com.simplemobiletools.commons.views.MyFloatingActionButton
android:id="@+id/checklist_fab"

View File

@ -51,6 +51,7 @@
<!-- Checklists -->
<string name="checklist">Checklist</string>
<string name="add_new_checklist_item">Add a new checklist item</string>
<string name="checklist_is_empty">The checklist is empty</string>
<!-- Import / Export -->
<string name="export_all_notes">Bütün qeydləri fayl şəklində çıxar</string>

View File

@ -51,6 +51,7 @@
<!-- Checklists -->
<string name="checklist">Checklist</string>
<string name="add_new_checklist_item">Add a new checklist item</string>
<string name="checklist_is_empty">The checklist is empty</string>
<!-- Import / Export -->
<string name="export_all_notes">Eksporter alle noter som filer</string>

View File

@ -51,6 +51,7 @@
<!-- Checklists -->
<string name="checklist">Checklist</string>
<string name="add_new_checklist_item">Add a new checklist item</string>
<string name="checklist_is_empty">The checklist is empty</string>
<!-- Import / Export -->
<string name="export_all_notes">Alle Notizen als Dateien exportieren</string>

View File

@ -51,6 +51,7 @@
<!-- Checklists -->
<string name="checklist">Checklist</string>
<string name="add_new_checklist_item">Add a new checklist item</string>
<string name="checklist_is_empty">The checklist is empty</string>
<!-- Import / Export -->
<string name="export_all_notes">Exportar todas las notas como archivos</string>

View File

@ -51,6 +51,7 @@
<!-- Checklists -->
<string name="checklist">Checklist</string>
<string name="add_new_checklist_item">Add a new checklist item</string>
<string name="checklist_is_empty">The checklist is empty</string>
<!-- Import / Export -->
<string name="export_all_notes">Exporter toutes les notes en tant que fichiers</string>

View File

@ -53,6 +53,7 @@
<!-- Checklists -->
<string name="checklist">Checklist</string>
<string name="add_new_checklist_item">Add a new checklist item</string>
<string name="checklist_is_empty">The checklist is empty</string>
<!-- Import / Export -->
<string name="export_all_notes">Exportar todas as notas como ficheiros</string>

View File

@ -51,6 +51,7 @@
<!-- Checklists -->
<string name="checklist">Checklist</string>
<string name="add_new_checklist_item">Add a new checklist item</string>
<string name="checklist_is_empty">The checklist is empty</string>
<!-- Import / Export -->
<string name="export_all_notes">Izvezi sve bilješke kao datoteke</string>

View File

@ -51,6 +51,7 @@
<!-- Checklists -->
<string name="checklist">Checklist</string>
<string name="add_new_checklist_item">Add a new checklist item</string>
<string name="checklist_is_empty">The checklist is empty</string>
<!-- Import / Export -->
<string name="export_all_notes">Export all notes as files</string>

View File

@ -51,6 +51,7 @@
<!-- Checklists -->
<string name="checklist">Checklist</string>
<string name="add_new_checklist_item">Add a new checklist item</string>
<string name="checklist_is_empty">The checklist is empty</string>
<!-- Import / Export -->
<string name="export_all_notes">Esporta le note come file</string>

View File

@ -51,6 +51,7 @@
<!-- Checklists -->
<string name="checklist">Checklist</string>
<string name="add_new_checklist_item">Add a new checklist item</string>
<string name="checklist_is_empty">The checklist is empty</string>
<!-- Import / Export -->
<string name="export_all_notes">Export all notes as files</string>

View File

@ -51,6 +51,7 @@
<!-- Checklists -->
<string name="checklist">Checklist</string>
<string name="add_new_checklist_item">Add a new checklist item</string>
<string name="checklist_is_empty">The checklist is empty</string>
<!-- Import / Export -->
<string name="export_all_notes">Eksportuoti visus užrašus kaip bylas</string>

View File

@ -51,6 +51,7 @@
<!-- Checklists -->
<string name="checklist">Checklist</string>
<string name="add_new_checklist_item">Add a new checklist item</string>
<string name="checklist_is_empty">The checklist is empty</string>
<!-- Import / Export -->
<string name="export_all_notes">Export all notes as files</string>

View File

@ -51,6 +51,7 @@
<!-- Checklists -->
<string name="checklist">Checklist</string>
<string name="add_new_checklist_item">Add a new checklist item</string>
<string name="checklist_is_empty">The checklist is empty</string>
<!-- Import / Export -->
<string name="export_all_notes">Eksportuj wszystkie notatki jako pliki</string>

View File

@ -51,6 +51,7 @@
<!-- Checklists -->
<string name="checklist">Checklist</string>
<string name="add_new_checklist_item">Add a new checklist item</string>
<string name="checklist_is_empty">The checklist is empty</string>
<!-- Import / Export -->
<string name="export_all_notes">Exportar todas as notas como arquivo</string>

View File

@ -51,6 +51,7 @@
<!-- Checklists -->
<string name="checklist">Checklist</string>
<string name="add_new_checklist_item">Add a new checklist item</string>
<string name="checklist_is_empty">The checklist is empty</string>
<!-- Import / Export -->
<string name="export_all_notes">Exportar todas as notas como ficheiros</string>

View File

@ -51,6 +51,7 @@
<!-- Checklists -->
<string name="checklist">Checklist</string>
<string name="add_new_checklist_item">Add a new checklist item</string>
<string name="checklist_is_empty">The checklist is empty</string>
<!-- Import / Export -->
<string name="export_all_notes">Экспортировать все заметки в файлы</string>

View File

@ -51,6 +51,7 @@
<!-- Checklists -->
<string name="checklist">Zoznam položiek</string>
<string name="add_new_checklist_item">Pridať do zoznamu novú položku</string>
<string name="checklist_is_empty">Zoznam položiek je prázdny</string>
<!-- Import / Export -->
<string name="export_all_notes">Exportovať všetky poznámky ako súbory</string>

View File

@ -51,6 +51,7 @@
<!-- Checklists -->
<string name="checklist">Checklist</string>
<string name="add_new_checklist_item">Add a new checklist item</string>
<string name="checklist_is_empty">The checklist is empty</string>
<!-- Import / Export -->
<string name="export_all_notes">Exportera alla anteckningar som filer</string>

View File

@ -51,6 +51,7 @@
<!-- Checklists -->
<string name="checklist">Checklist</string>
<string name="add_new_checklist_item">Add a new checklist item</string>
<string name="checklist_is_empty">The checklist is empty</string>
<!-- Import / Export -->
<string name="export_all_notes">Tüm notları dosya olarak dışa aktar</string>

View File

@ -51,6 +51,7 @@
<!-- Checklists -->
<string name="checklist">Checklist</string>
<string name="add_new_checklist_item">Add a new checklist item</string>
<string name="checklist_is_empty">The checklist is empty</string>
<!-- Import / Export -->
<string name="export_all_notes">Export all notes as files</string>

View File

@ -51,6 +51,7 @@
<!-- Checklists -->
<string name="checklist">核對清單</string>
<string name="add_new_checklist_item">新增新的核對清單項目</string>
<string name="checklist_is_empty">The checklist is empty</string>
<!-- Import / Export -->
<string name="export_all_notes">將全部筆記匯出成檔案</string>

View File

@ -51,6 +51,7 @@
<!-- Checklists -->
<string name="checklist">Checklist</string>
<string name="add_new_checklist_item">Add a new checklist item</string>
<string name="checklist_is_empty">The checklist is empty</string>
<!-- Import / Export -->
<string name="export_all_notes">Export all notes as files</string>