Skip to content

Commit b3d6d65

Browse files
authored
Add default list note view mode setting (#926)
1 parent 2a3c38a commit b3d6d65

8 files changed

Lines changed: 79 additions & 30 deletions

File tree

TRANSLATIONS.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,34 @@ See [Android Translations Converter](https://github.com/Crustack/android-transla
1919
<!-- translations:start -->
2020
| Language | Coverage |
2121
|----------|----------|
22-
| 🇺🇸 English | 100% (345/345) |
23-
| 🇪🇸 Catalan | 18% (65/345) |
24-
| 🇨🇿 Czech | 91% (314/345) |
25-
| 🇩🇰 Danish | 20% (69/345) |
26-
| 🇩🇪 German | 97% (336/345) |
27-
| 🇬🇷 Greek | 20% (72/345) |
28-
| 🇪🇸 Spanish | 91% (315/345) |
29-
| 🇫🇷 French | 95% (328/345) |
30-
| 🇭🇺 Hungarian | 18% (65/345) |
31-
| 🇮🇩 Indonesian | 21% (75/345) |
32-
| 🇮🇹 Italian | 84% (292/345) |
33-
| 🇯🇵 Japanese | 21% (73/345) |
34-
| 🇲🇲 Burmese | 26% (91/345) |
35-
| 🇳🇴 Norwegian Bokmål | 31% (107/345) |
36-
| 🇳🇱 Dutch | 61% (213/345) |
37-
| 🇳🇴 Norwegian Nynorsk | 31% (107/345) |
38-
| 🇵🇱 Polish | 87% (301/345) |
39-
| 🇧🇷 Portuguese (Brazil) | 90% (313/345) |
40-
| 🇵🇹 Portuguese (Portugal) | 20% (71/345) |
41-
| 🇷🇴 Romanian | 87% (302/345) |
42-
| 🇷🇺 Russian | 88% (306/345) |
43-
| 🇸🇰 Slovak | 18% (65/345) |
44-
| 🇸🇮 Slovenian | 31% (110/345) |
45-
| 🇸🇪 Swedish | 18% (63/345) |
46-
| 🇵🇭 Tagalog | 18% (65/345) |
47-
| 🇹🇷 Turkish | 21% (73/345) |
48-
| 🇺🇦 Ukrainian | 96% (332/345) |
49-
| 🇻🇳 Vietnamese | 31% (108/345) |
50-
| 🇨🇳 Chinese (Simplified) | 95% (329/345) |
51-
| 🇹🇼 Chinese (Traditional) | 85% (295/345) |
22+
| 🇺🇸 English | 100% (347/347) |
23+
| 🇪🇸 Catalan | 18% (65/347) |
24+
| 🇨🇿 Czech | 90% (314/347) |
25+
| 🇩🇰 Danish | 19% (69/347) |
26+
| 🇩🇪 German | 96% (336/347) |
27+
| 🇬🇷 Greek | 20% (72/347) |
28+
| 🇪🇸 Spanish | 90% (315/347) |
29+
| 🇫🇷 French | 94% (328/347) |
30+
| 🇭🇺 Hungarian | 18% (65/347) |
31+
| 🇮🇩 Indonesian | 21% (75/347) |
32+
| 🇮🇹 Italian | 84% (292/347) |
33+
| 🇯🇵 Japanese | 21% (73/347) |
34+
| 🇲🇲 Burmese | 26% (91/347) |
35+
| 🇳🇴 Norwegian Bokmål | 30% (107/347) |
36+
| 🇳🇱 Dutch | 61% (213/347) |
37+
| 🇳🇴 Norwegian Nynorsk | 30% (107/347) |
38+
| 🇵🇱 Polish | 86% (301/347) |
39+
| 🇧🇷 Portuguese (Brazil) | 90% (313/347) |
40+
| 🇵🇹 Portuguese (Portugal) | 20% (71/347) |
41+
| 🇷🇴 Romanian | 87% (302/347) |
42+
| 🇷🇺 Russian | 88% (306/347) |
43+
| 🇸🇰 Slovak | 18% (65/347) |
44+
| 🇸🇮 Slovenian | 31% (110/347) |
45+
| 🇸🇪 Swedish | 18% (63/347) |
46+
| 🇵🇭 Tagalog | 18% (65/347) |
47+
| 🇹🇷 Turkish | 21% (73/347) |
48+
| 🇺🇦 Ukrainian | 95% (332/347) |
49+
| 🇻🇳 Vietnamese | 31% (108/347) |
50+
| 🇨🇳 Chinese (Simplified) | 94% (329/347) |
51+
| 🇹🇼 Chinese (Traditional) | 85% (295/347) |
5252
<!-- translations:end -->

app/src/main/java/com/philkes/notallyx/presentation/activity/main/fragment/settings/SettingsFragment.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,16 @@ class SettingsFragment : Fragment() {
353353
}
354354
}
355355

356+
defaultListNoteViewMode.observe(viewLifecycleOwner) { value ->
357+
binding.DefaultListNoteViewMode.setup(
358+
defaultListNoteViewMode,
359+
value,
360+
requireContext(),
361+
) { newValue ->
362+
model.savePreference(defaultListNoteViewMode, newValue)
363+
}
364+
}
365+
356366
autoRemoveDeletedNotesAfterDays.observe(viewLifecycleOwner) { value ->
357367
binding.AutoEmptyBin.setupAutoEmptyBin(
358368
autoRemoveDeletedNotesAfterDays,

app/src/main/java/com/philkes/notallyx/presentation/activity/note/EditActivity.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,16 @@ abstract class EditActivity(private val type: Type) : LockedActivity<ActivityEdi
196196
setupListeners()
197197
setStateFromModel(savedInstanceState)
198198

199+
if (
200+
!notallyModel.isNewNote &&
201+
notallyModel.type == Type.LIST &&
202+
savedInstanceState == null
203+
) {
204+
val lastUsedViewMode = notallyModel.viewMode.value
205+
notallyModel.viewMode.value =
206+
preferences.defaultListNoteViewMode.value.toNoteViewMode(lastUsedViewMode)
207+
}
208+
199209
configureUI()
200210
binding.ScrollView.visibility = VISIBLE
201211
setupEditNoteReminderChip()

app/src/main/java/com/philkes/notallyx/presentation/viewmodel/preference/NotallyXPreferences.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ class NotallyXPreferences private constructor(private val context: Context) {
5959
R.string.list_item_auto_sort,
6060
)
6161

62+
val defaultListNoteViewMode =
63+
createEnumPreference(
64+
preferences,
65+
"defaultListNoteViewMode",
66+
DefaultListNoteViewMode.LAST_USED,
67+
R.string.default_list_note_view_mode,
68+
)
69+
6270
val maxItems =
6371
IntPreference(
6472
"maxItemsToDisplayInList.v1",
@@ -313,6 +321,7 @@ class NotallyXPreferences private constructor(private val context: Context) {
313321
editNoteActivityTopActions,
314322
editNoteActivityBottomAction,
315323
defaultNoteColor,
324+
defaultListNoteViewMode,
316325
)
317326
.forEach { it.refresh() }
318327
}

app/src/main/java/com/philkes/notallyx/presentation/viewmodel/preference/Preference.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,20 @@ fun ListItemSort.callback(adapterChecked: CheckedListItemAdapter) =
404404
else -> ListItemParentSortCallback(adapterChecked)
405405
}
406406

407+
enum class DefaultListNoteViewMode(override val textResId: Int) : StaticTextProvider {
408+
READ_ONLY(R.string.read_only),
409+
EDIT(R.string.edit),
410+
LAST_USED(R.string.last_used);
411+
412+
fun toNoteViewMode(lastUsed: NoteViewMode): NoteViewMode {
413+
return when (this) {
414+
READ_ONLY -> NoteViewMode.READ_ONLY
415+
EDIT -> NoteViewMode.EDIT
416+
LAST_USED -> lastUsed
417+
}
418+
}
419+
}
420+
407421
enum class BiometricLock(override val textResId: Int) : StaticTextProvider {
408422
ENABLED(R.string.enabled),
409423
DISABLED(R.string.disabled);

app/src/main/res/layout/fragment_settings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@
6161
android:id="@+id/StartView"
6262
layout="@layout/preference" />
6363

64+
<include
65+
android:id="@+id/DefaultListNoteViewMode"
66+
layout="@layout/preference" />
67+
6468
<include
6569
android:id="@+id/AutoSaveAfterIdle"
6670
layout="@layout/preference_seekbar" />

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
<string name="day">Day</string>
114114
<string name="days">Days</string>
115115
<string name="default_color_hint">This is the default color for new notes. To change it, make another color the default</string>
116+
<string name="default_list_note_view_mode">Default List-Note View Mode</string>
116117
<string name="delete">Delete</string>
117118
<string name="delete_all">Delete all</string>
118119
<string name="delete_all_notes">Delete all notes\?</string>
@@ -228,6 +229,7 @@
228229
<string name="labels_hidden_in_overview">By enabling this, the notes’ labels will be hidden in the overview</string>
229230
<string name="labels_hidden_in_overview_title">Hide Labels in Overview</string>
230231
<string name="large">Large</string>
232+
<string name="last_used">Last Used</string>
231233
<string name="libraries">Libraries</string>
232234
<string name="light">Light</string>
233235
<string name="link">Link</string>

app/translations.xlsx

236 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)