Skip to content

Commit

Permalink
Move local texts to string resource file
Browse files Browse the repository at this point in the history
  • Loading branch information
shubertm committed Nov 29, 2023
1 parent 77c66a8 commit 4eac79d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
4 changes: 1 addition & 3 deletions app/src/main/java/dev/arkbuilders/arkmemo/models/Note.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ import java.time.format.DateTimeFormatter
interface Note {
val title: String
var resource: Resource?
}

val DEFAULT_TITLE = "note ${LocalDate.now().format(DateTimeFormatter.ISO_DATE)}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class NotesListAdapter(private val notes: List<Note>):

override fun onBindViewHolder(holder: NoteViewHolder, position: Int) {
holder.title.text = notes[position].title
holder.date.text = notes[position].resource?.modified?.toString() ?: "Just now"
holder.date.text = notes[position].resource?.modified?.toString() ?:
activity?.getString(R.string.ark_memo_just_now)
}

override fun getItemCount() = notes.size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ import by.kirich1409.viewbindingdelegate.viewBinding
import dagger.hilt.android.AndroidEntryPoint
import dev.arkbuilders.arkmemo.R
import dev.arkbuilders.arkmemo.databinding.FragmentEditNotesBinding
import dev.arkbuilders.arkmemo.models.DEFAULT_TITLE
import dev.arkbuilders.arkmemo.models.GraphicNote
import dev.arkbuilders.arkmemo.ui.activities.MainActivity
import dev.arkbuilders.arkmemo.ui.viewmodels.GraphicNotesViewModel
import dev.arkbuilders.arkmemo.ui.viewmodels.NotesViewModel
import dev.arkbuilders.arkmemo.utils.observeSaveResult
import java.time.LocalDate
import java.time.format.DateTimeFormatter

@AndroidEntryPoint
class EditGraphicNotesFragment: Fragment(R.layout.fragment_edit_notes) {
Expand All @@ -32,7 +33,8 @@ class EditGraphicNotesFragment: Fragment(R.layout.fragment_edit_notes) {
private val graphicNotesViewModel: GraphicNotesViewModel by viewModels()
private val notesViewModel: NotesViewModel by activityViewModels()

private var note = GraphicNote( title = "")
private var note = GraphicNote()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
notesViewModel.init {}
Expand All @@ -52,7 +54,10 @@ class EditGraphicNotesFragment: Fragment(R.layout.fragment_edit_notes) {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val defaultTitle = "Graphic $DEFAULT_TITLE"
val defaultTitle = getString(
R.string.ark_memo_graphic_note,
LocalDate.now().format(DateTimeFormatter.ISO_DATE)
)
var title = note.title
val notesCanvas = binding.notesCanvas
val saveButton = binding.saveNote
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import dagger.hilt.android.AndroidEntryPoint
import dev.arkbuilders.arkmemo.R
import dev.arkbuilders.arkmemo.ui.viewmodels.NotesViewModel
import dev.arkbuilders.arkmemo.databinding.FragmentEditNotesBinding
import dev.arkbuilders.arkmemo.models.DEFAULT_TITLE
import dev.arkbuilders.arkmemo.models.TextNote
import dev.arkbuilders.arkmemo.ui.activities.MainActivity
import dev.arkbuilders.arkmemo.utils.observeSaveResult
import java.time.LocalDate
import java.time.format.DateTimeFormatter

@AndroidEntryPoint
class EditTextNotesFragment: Fragment(R.layout.fragment_edit_notes) {
Expand Down Expand Up @@ -50,7 +51,10 @@ class EditTextNotesFragment: Fragment(R.layout.fragment_edit_notes) {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val defaultTitle = "Text $DEFAULT_TITLE"
val defaultTitle = getString(
R.string.ark_memo_text_note,
LocalDate.now().format(DateTimeFormatter.ISO_DATE)
)
var title = this.note.title
var data = note.text
val editTextListener = object: TextWatcher{
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@
<string name="ark_memo_note_existing">Note already exists</string>
<string name="ark_memo_note_saved">Note saved successfully</string>
<string name="note_title">Title</string>
<string name="ark_memo_just_now">Just now</string>
<string name="ark_memo_graphic_note">Graphic note %1$s</string>
<string name="ark_memo_text_note">Text note %1$s</string>

</resources>

0 comments on commit 4eac79d

Please sign in to comment.