From 07109eb50183988a812fe644c9d214768df268e6 Mon Sep 17 00:00:00 2001 From: Patrick Schneider Date: Tue, 22 Oct 2024 10:18:23 +0200 Subject: [PATCH 01/11] [feat] adds txt export for text notes. --- .../ui/notes/BaseNoteActivity.kt | 2 ++ .../ui/notes/TextNoteActivity.kt | 30 ++++++++++++++++++- .../main/res/drawable/baseline_html_24.xml | 5 ++++ app/src/main/res/menu/activity_text.xml | 7 +++++ app/src/main/res/values-de/strings.xml | 2 +- app/src/main/res/values-ja/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 7 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/drawable/baseline_html_24.xml diff --git a/app/src/main/java/org/secuso/privacyfriendlynotes/ui/notes/BaseNoteActivity.kt b/app/src/main/java/org/secuso/privacyfriendlynotes/ui/notes/BaseNoteActivity.kt index 8e9e76ca..ef1626fe 100644 --- a/app/src/main/java/org/secuso/privacyfriendlynotes/ui/notes/BaseNoteActivity.kt +++ b/app/src/main/java/org/secuso/privacyfriendlynotes/ui/notes/BaseNoteActivity.kt @@ -91,6 +91,8 @@ abstract class BaseNoteActivity(noteType: Int) : AppCompatActivity(), View.OnCli } private val etName by lazy { findViewById(R.id.etName) as EditText } + val noteTitle: String + get() = etName.text.toString() private val catSelection by lazy { findViewById(R.id.spinner_category) as AutoCompleteTextView } private lateinit var reminder: MenuItem diff --git a/app/src/main/java/org/secuso/privacyfriendlynotes/ui/notes/TextNoteActivity.kt b/app/src/main/java/org/secuso/privacyfriendlynotes/ui/notes/TextNoteActivity.kt index c27806d1..6af61dec 100644 --- a/app/src/main/java/org/secuso/privacyfriendlynotes/ui/notes/TextNoteActivity.kt +++ b/app/src/main/java/org/secuso/privacyfriendlynotes/ui/notes/TextNoteActivity.kt @@ -13,6 +13,7 @@ */ package org.secuso.privacyfriendlynotes.ui.notes +import android.app.Activity import android.content.Intent import android.content.res.ColorStateList import android.graphics.Color @@ -31,6 +32,8 @@ import android.view.Menu import android.view.MenuItem import android.view.View import android.widget.EditText +import android.widget.Toast +import androidx.activity.result.contract.ActivityResultContracts import androidx.lifecycle.MutableLiveData import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.floatingactionbutton.FloatingActionButton @@ -121,6 +124,13 @@ class TextNoteActivity : BaseNoteActivity(DbContract.NoteEntry.TYPE_TEXT) { .setIcon(android.R.drawable.ic_dialog_alert) .show() } + R.id.action_export_plain -> { + val intent = Intent(Intent.ACTION_CREATE_DOCUMENT) + intent.addCategory(Intent.CATEGORY_OPENABLE) + intent.putExtra(Intent.EXTRA_TITLE, noteTitle + getFileExtension()) + intent.type = getMimeType() + saveToExternalStorageResultLauncher.launch(intent) + } else -> {} } @@ -424,10 +434,28 @@ class TextNoteActivity : BaseNoteActivity(DbContract.NoteEntry.TYPE_TEXT) { override fun getFileExtension() = ".txt" + private val saveToExternalStorageResultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> + if (result.resultCode == Activity.RESULT_OK) { + result.data?.data?.let { uri -> + val fileOutputStream: OutputStream? = contentResolver.openOutputStream(uri) + fileOutputStream?.let { + val out = PrintWriter(it) + out.println(Html.toHtml(etContent.text)) + out.close() + Toast.makeText( + applicationContext, + String.format(getString(R.string.toast_file_exported_to), uri.toString()), + Toast.LENGTH_LONG + ).show() + } + fileOutputStream?.close() + } + } + } override fun onSaveExternalStorage(outputStream: OutputStream) { val out = PrintWriter(outputStream) - out.println(Html.toHtml(etContent.text)) + out.println(Html.fromHtml(Html.toHtml(etContent.text)).toString()) out.close() } } \ No newline at end of file diff --git a/app/src/main/res/drawable/baseline_html_24.xml b/app/src/main/res/drawable/baseline_html_24.xml new file mode 100644 index 00000000..f17a2a06 --- /dev/null +++ b/app/src/main/res/drawable/baseline_html_24.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/menu/activity_text.xml b/app/src/main/res/menu/activity_text.xml index a246712f..9d26cfa1 100644 --- a/app/src/main/res/menu/activity_text.xml +++ b/app/src/main/res/menu/activity_text.xml @@ -1,10 +1,17 @@ + + \ No newline at end of file diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index d52d029a..8a1d459c 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -64,7 +64,6 @@ Notiz aktualisiert Leere Notiz kann nicht gespeichert werden Nur ein Punkt kann gleichzeitig verändert werden. - Notiz gelöscht F @@ -75,6 +74,7 @@ Teilen Bearbeiten Exportieren + Als HTML exportieren Kategorie In Checkliste umwandeln In Textnotiz umwandeln diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index fb515f0d..19903185 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -152,6 +152,7 @@ ノートプレビューを表示する ノートの短いプレビューを表示する 輸出 + HTMLとしてエクスポート カテゴリ フォーマッティング メモが保存されていません diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ab8f3fc8..dde3d939 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -48,6 +48,7 @@ I U Export + Export as HTML Category Undo Redo From 3a96a045b3292d45d3cf88e9a19caada3580ecef Mon Sep 17 00:00:00 2001 From: Patrick Schneider Date: Tue, 22 Oct 2024 10:49:25 +0200 Subject: [PATCH 02/11] [feat] adds option to set title of imported text notes. --- .../backup/BackupRestorer.java | 3 ++- .../ui/notes/TextNoteActivity.kt | 14 +++++++++++--- app/src/main/res/values-de/strings.xml | 2 ++ app/src/main/res/values-ja/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 3 ++- app/src/main/res/xml/pref_settings.xml | 6 ++++++ 6 files changed, 25 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/secuso/privacyfriendlynotes/backup/BackupRestorer.java b/app/src/main/java/org/secuso/privacyfriendlynotes/backup/BackupRestorer.java index d94a3206..a882ba1c 100644 --- a/app/src/main/java/org/secuso/privacyfriendlynotes/backup/BackupRestorer.java +++ b/app/src/main/java/org/secuso/privacyfriendlynotes/backup/BackupRestorer.java @@ -127,7 +127,8 @@ private void readPreferences(@NonNull JsonReader reader, @NonNull Context contex "settings_dialog_on_trashing", "settings_color_category", "notes_reversed_ordering", - "settings_sketch_undo_redo" -> editor.putBoolean(name, reader.nextBoolean()); + "settings_sketch_undo_redo", + "settings_import_text_title_file_first_line" -> editor.putBoolean(name, reader.nextBoolean()); case "settings_font_size", "settings_day_night_theme", "notes_ordering" -> editor.putString(name, reader.nextString()); default -> throw new RuntimeException("Unknown preference " + name); } diff --git a/app/src/main/java/org/secuso/privacyfriendlynotes/ui/notes/TextNoteActivity.kt b/app/src/main/java/org/secuso/privacyfriendlynotes/ui/notes/TextNoteActivity.kt index 6af61dec..05246de5 100644 --- a/app/src/main/java/org/secuso/privacyfriendlynotes/ui/notes/TextNoteActivity.kt +++ b/app/src/main/java/org/secuso/privacyfriendlynotes/ui/notes/TextNoteActivity.kt @@ -20,13 +20,13 @@ import android.graphics.Color import android.graphics.Typeface import android.net.Uri import android.os.Bundle +import android.provider.OpenableColumns import android.text.Html import android.text.Spannable import android.text.SpannableStringBuilder import android.text.Spanned import android.text.style.StyleSpan import android.text.style.UnderlineSpan -import android.util.Log import android.view.ContextThemeWrapper import android.view.Menu import android.view.MenuItem @@ -35,12 +35,14 @@ import android.widget.EditText import android.widget.Toast import androidx.activity.result.contract.ActivityResultContracts import androidx.lifecycle.MutableLiveData +import androidx.preference.PreferenceManager import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.floatingactionbutton.FloatingActionButton import org.secuso.privacyfriendlynotes.R import org.secuso.privacyfriendlynotes.room.DbContract import org.secuso.privacyfriendlynotes.room.model.Note import org.secuso.privacyfriendlynotes.ui.util.ChecklistUtil +import java.io.File import java.io.InputStreamReader import java.io.OutputStream import java.io.PrintWriter @@ -142,8 +144,14 @@ class TextNoteActivity : BaseNoteActivity(DbContract.NoteEntry.TYPE_TEXT) { val uri: Uri? = listOf(intent.data, intent.getParcelableExtra(Intent.EXTRA_STREAM)).firstNotNullOfOrNull { it } if (uri != null) { val text = InputStreamReader(contentResolver.openInputStream(uri)).readLines() - super.setTitle(text[0]) - etContent.setText(Html.fromHtml(text.subList(1, text.size).joinToString("
"))) + if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("settings_import_text_title_file_first_line", false)) { + super.setTitle(text[0]) + etContent.setText(Html.fromHtml(text.subList(1, text.size).joinToString("
"))) + } else { + val title = uri.path?.let { File(it).nameWithoutExtension } ?: "" + super.setTitle(title) + etContent.setText(Html.fromHtml(text.joinToString("
"))) + } } val text = intent.getStringExtra(Intent.EXTRA_TEXT) if (text != null) { diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 8a1d459c..8b5db269 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -167,4 +167,6 @@ Dadurch wird diese Notiz in eine Textnotiz umgewandelt. Möchten Sie fortfahren? Aktiviere die Rückgängig/Wiederherstellen Funktionalität in Skizzen. Diese Funktion kann auf älteren Geräten zu Leistungsproblemen führen. Rückgängig/Wiederherstellen in Skizzen + Erste Zeile als Titel + Wenn diese Option aktiviert ist, entspricht der Titel der importierten Textnotiz der gesamten ersten Zeile des importierten Textes. Andernfalls wird der Name der importierten Datei ausgewählt. \ No newline at end of file diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 19903185..5d6a2efc 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -163,5 +163,7 @@ このメモはテキストメモに変換されます。続けますか? スケッチの元に戻す/やり直し機能を有効にします。このオプションは、古いデバイスでパフォーマンスの問題を引き起こす可能性があります。 スケッチの元に戻す/やり直し + 最初の行をタイトルとして + 有効にすると、インポートされたテキスト ノートのタイトルは、インポートされたテキストの最初の行全体になります。有効にしない場合は、インポートされたファイルの名前が選択されます。 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dde3d939..1491fcdd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -194,5 +194,6 @@ This will convert this note into a text note. Do you want to continue? Enable the undo/redo functionality in sketches. This option may lead to performance issues on older devices. Undo/Redo in sketches - + First line as Title + If enabled, the title of the imported text note will be the whole first line of the imported text. Otherwise the name of the imported file will be selected. diff --git a/app/src/main/res/xml/pref_settings.xml b/app/src/main/res/xml/pref_settings.xml index 363d440a..cd33f4b5 100644 --- a/app/src/main/res/xml/pref_settings.xml +++ b/app/src/main/res/xml/pref_settings.xml @@ -22,6 +22,12 @@ android:title="@string/settings_sketch_undo_redo_title" android:summary="@string/settings_sketch_undo_redo_desc" app:iconSpaceReserved="false" /> + From c99e368f3c09dd1ddbcb16f18ea1571c94dce2e6 Mon Sep 17 00:00:00 2001 From: Patrick Schneider Date: Tue, 22 Oct 2024 10:51:15 +0200 Subject: [PATCH 03/11] [fix] improves export of checklist. --- .../privacyfriendlynotes/ui/notes/ChecklistNoteActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/secuso/privacyfriendlynotes/ui/notes/ChecklistNoteActivity.kt b/app/src/main/java/org/secuso/privacyfriendlynotes/ui/notes/ChecklistNoteActivity.kt index f8366580..0e888c97 100644 --- a/app/src/main/java/org/secuso/privacyfriendlynotes/ui/notes/ChecklistNoteActivity.kt +++ b/app/src/main/java/org/secuso/privacyfriendlynotes/ui/notes/ChecklistNoteActivity.kt @@ -167,7 +167,7 @@ class ChecklistNoteActivity : BaseNoteActivity(DbContract.NoteEntry.TYPE_CHECKLI } private fun getContentString(): String { - return adapter.getItems().joinToString(System.lineSeparator()) { (checked, name) -> "- [${if (checked) "x" else " "}] $name" } + return adapter.getItems().joinToString(System.lineSeparator()) { (checked, name) -> "- [${if (checked) "x" else " "}] $name" } } private fun addItem() { From 9117e0099927d7c5a8f50a530324ec26d8852e50 Mon Sep 17 00:00:00 2001 From: Patrick Schneider Date: Tue, 22 Oct 2024 11:04:00 +0200 Subject: [PATCH 04/11] [feat] allows to color notes always with respect to the category. --- .../backup/BackupRestorer.java | 3 ++- .../privacyfriendlynotes/ui/adapter/NoteAdapter.kt | 14 ++++++++------ app/src/main/res/values-de/strings.xml | 2 ++ app/src/main/res/values-ja/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/pref_settings.xml | 7 +++++++ 6 files changed, 23 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/secuso/privacyfriendlynotes/backup/BackupRestorer.java b/app/src/main/java/org/secuso/privacyfriendlynotes/backup/BackupRestorer.java index a882ba1c..569687ce 100644 --- a/app/src/main/java/org/secuso/privacyfriendlynotes/backup/BackupRestorer.java +++ b/app/src/main/java/org/secuso/privacyfriendlynotes/backup/BackupRestorer.java @@ -128,7 +128,8 @@ private void readPreferences(@NonNull JsonReader reader, @NonNull Context contex "settings_color_category", "notes_reversed_ordering", "settings_sketch_undo_redo", - "settings_import_text_title_file_first_line" -> editor.putBoolean(name, reader.nextBoolean()); + "settings_import_text_title_file_first_line", + "settings_color_category_always_background" -> editor.putBoolean(name, reader.nextBoolean()); case "settings_font_size", "settings_day_night_theme", "notes_ordering" -> editor.putString(name, reader.nextString()); default -> throw new RuntimeException("Unknown preference " + name); } diff --git a/app/src/main/java/org/secuso/privacyfriendlynotes/ui/adapter/NoteAdapter.kt b/app/src/main/java/org/secuso/privacyfriendlynotes/ui/adapter/NoteAdapter.kt index b96fd394..da12ad9a 100644 --- a/app/src/main/java/org/secuso/privacyfriendlynotes/ui/adapter/NoteAdapter.kt +++ b/app/src/main/java/org/secuso/privacyfriendlynotes/ui/adapter/NoteAdapter.kt @@ -80,22 +80,24 @@ class NoteAdapter( if (colorCategory) { mainActivityViewModel.categoryColor(currentNote.category) { + val colorBackground = PreferenceManager.getDefaultSharedPreferences(holder.textViewTitle.context) + .getBoolean("settings_color_category_always_background", false) || !DarkModeUtil.isDarkMode(holder.textViewTitle.context) - if (DarkModeUtil.isDarkMode(holder.textViewTitle.context)) { + if (colorBackground) { val color: Int = it?.let { Color.parseColor(it) } ?: run { val value = TypedValue() - holder.itemView.context.theme.resolveAttribute(R.attr.colorOnBackground, value, true) + holder.itemView.context.theme.resolveAttribute(R.attr.colorSurface, value, true) value.data } - holder.textViewTitle.setTextColor(color) - holder.textViewExtraText.setTextColor(color) + holder.viewNoteItem.setBackgroundColor(color) } else { val color: Int = it?.let { Color.parseColor(it) } ?: run { val value = TypedValue() - holder.itemView.context.theme.resolveAttribute(R.attr.colorSurface, value, true) + holder.itemView.context.theme.resolveAttribute(R.attr.colorOnBackground, value, true) value.data } - holder.viewNoteItem.setBackgroundColor(color) + holder.textViewTitle.setTextColor(color) + holder.textViewExtraText.setTextColor(color) } } } diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 8b5db269..f494239c 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -169,4 +169,6 @@ Rückgängig/Wiederherstellen in Skizzen Erste Zeile als Titel Wenn diese Option aktiviert ist, entspricht der Titel der importierten Textnotiz der gesamten ersten Zeile des importierten Textes. Andernfalls wird der Name der importierten Datei ausgewählt. + Immer den Hintergrund färben + Wenn aktiviert, wird der Hintergrund immer in der Farbe der Kategorie eingefärbt, unabhängig vom ausgewählten Design. \ No newline at end of file diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 5d6a2efc..d56d0cd3 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -165,5 +165,7 @@ スケッチの元に戻す/やり直し 最初の行をタイトルとして 有効にすると、インポートされたテキスト ノートのタイトルは、インポートされたテキストの最初の行全体になります。有効にしない場合は、インポートされたファイルの名前が選択されます。 + 常に背景をカラーにする + 有効にすると、選択したテーマに関係なく、背景は常にカテゴリの色になります。 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1491fcdd..d2fc44f7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -196,4 +196,6 @@ Undo/Redo in sketches First line as Title If enabled, the title of the imported text note will be the whole first line of the imported text. Otherwise the name of the imported file will be selected. + Always color background + If enabled, the background is always colored in the color of the category, regardless of the selected theme. diff --git a/app/src/main/res/xml/pref_settings.xml b/app/src/main/res/xml/pref_settings.xml index cd33f4b5..7f6b3713 100644 --- a/app/src/main/res/xml/pref_settings.xml +++ b/app/src/main/res/xml/pref_settings.xml @@ -46,6 +46,13 @@ android:summary="@string/settings_color_category_summary" android:defaultValue="true" app:iconSpaceReserved="false" /> + Date: Tue, 22 Oct 2024 11:08:57 +0200 Subject: [PATCH 05/11] [fix] deleting checklist item did not change the note. --- .../secuso/privacyfriendlynotes/ui/adapter/ChecklistAdapter.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/org/secuso/privacyfriendlynotes/ui/adapter/ChecklistAdapter.kt b/app/src/main/java/org/secuso/privacyfriendlynotes/ui/adapter/ChecklistAdapter.kt index bacf09b7..41b080ac 100644 --- a/app/src/main/java/org/secuso/privacyfriendlynotes/ui/adapter/ChecklistAdapter.kt +++ b/app/src/main/java/org/secuso/privacyfriendlynotes/ui/adapter/ChecklistAdapter.kt @@ -119,6 +119,7 @@ class ChecklistAdapter( fun removeItem(position: Int) { this.items.removeAt(position) + hasChanged = true notifyItemRemoved(position) } From e38866a513c1e751485764eac7b61f60e28f7efe Mon Sep 17 00:00:00 2001 From: Patrick Schneider Date: Tue, 22 Oct 2024 15:41:35 +0200 Subject: [PATCH 06/11] [fix] imported title is correctly stripped from html. --- .../ui/notes/TextNoteActivity.kt | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/secuso/privacyfriendlynotes/ui/notes/TextNoteActivity.kt b/app/src/main/java/org/secuso/privacyfriendlynotes/ui/notes/TextNoteActivity.kt index 05246de5..94b5387f 100644 --- a/app/src/main/java/org/secuso/privacyfriendlynotes/ui/notes/TextNoteActivity.kt +++ b/app/src/main/java/org/secuso/privacyfriendlynotes/ui/notes/TextNoteActivity.kt @@ -143,19 +143,18 @@ class TextNoteActivity : BaseNoteActivity(DbContract.NoteEntry.TYPE_TEXT) { if (intent != null) { val uri: Uri? = listOf(intent.data, intent.getParcelableExtra(Intent.EXTRA_STREAM)).firstNotNullOfOrNull { it } if (uri != null) { - val text = InputStreamReader(contentResolver.openInputStream(uri)).readLines() - if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("settings_import_text_title_file_first_line", false)) { - super.setTitle(text[0]) - etContent.setText(Html.fromHtml(text.subList(1, text.size).joinToString("
"))) - } else { - val title = uri.path?.let { File(it).nameWithoutExtension } ?: "" - super.setTitle(title) - etContent.setText(Html.fromHtml(text.joinToString("
"))) + val (title: String, text) = InputStreamReader(contentResolver.openInputStream(uri)).readLines().let { + if (PreferenceManager.getDefaultSharedPreferences(this@TextNoteActivity).getBoolean("settings_import_text_title_file_first_line", false)) { + it[0] to it.subList(1, it.size) + } else { + (uri.path?.let { file -> File(file).nameWithoutExtension } ?: "") to it + } } + super.setTitle(Html.fromHtml(title).toString()) + etContent.setText(Html.fromHtml(text.joinToString("
"))) } - val text = intent.getStringExtra(Intent.EXTRA_TEXT) - if (text != null) { - etContent.setText(Html.fromHtml(text)) + intent.getStringExtra(Intent.EXTRA_TEXT)?.let { + etContent.setText(Html.fromHtml(it)) } } } From c0320f9da424c61ab2d49247cfdab37def02f0db Mon Sep 17 00:00:00 2001 From: Patrick Schneider Date: Tue, 22 Oct 2024 15:58:49 +0200 Subject: [PATCH 07/11] [fix] allows multiline entries for checklist items. --- .../privacyfriendlynotes/ui/main/MainActivityViewModel.kt | 3 ++- app/src/main/res/layout/activity_checklist_note.xml | 3 +-- app/src/main/res/layout/item_checklist.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/secuso/privacyfriendlynotes/ui/main/MainActivityViewModel.kt b/app/src/main/java/org/secuso/privacyfriendlynotes/ui/main/MainActivityViewModel.kt index 521780f8..82a1df17 100644 --- a/app/src/main/java/org/secuso/privacyfriendlynotes/ui/main/MainActivityViewModel.kt +++ b/app/src/main/java/org/secuso/privacyfriendlynotes/ui/main/MainActivityViewModel.kt @@ -245,7 +245,8 @@ class MainActivityViewModel(application: Application) : AndroidViewModel(applica throw IllegalArgumentException("Only checklist notes allowed") } return ChecklistUtil.parse(note.content).map { (checked, name) -> - return@map Pair(checked, "[${if (checked) "x" else " "}] $name") + val preview = if (name.length > 30) name.take(30) + "..." else name.take(33) + return@map Pair(checked, "[${if (checked) "x" else " "}] $preview") } } diff --git a/app/src/main/res/layout/activity_checklist_note.xml b/app/src/main/res/layout/activity_checklist_note.xml index bccbcf1b..d2d780bf 100644 --- a/app/src/main/res/layout/activity_checklist_note.xml +++ b/app/src/main/res/layout/activity_checklist_note.xml @@ -21,11 +21,10 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:id="@+id/etNewItem" - android:singleLine="true" android:layout_weight="1" android:hint="@string/hint_new_item" android:textColor="?attr/colorOnBackground" - android:inputType="textCapSentences" /> + android:inputType="textCapSentences|textMultiLine" />