Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 30 additions & 30 deletions TRANSLATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,34 @@ See [Android Translations Converter](https://github.com/Crustack/android-transla
<!-- translations:start -->
| Language | Coverage |
|----------|----------|
| 🇺🇸 English | 100% (326/326) |
| 🇪🇸 Catalan | 19% (65/326) |
| 🇨🇿 Czech | 96% (313/326) |
| 🇩🇰 Danish | 21% (69/326) |
| 🇩🇪 German | 96% (313/326) |
| 🇬🇷 Greek | 22% (72/326) |
| 🇪🇸 Spanish | 96% (314/326) |
| 🇫🇷 French | 99% (324/326) |
| 🇭🇺 Hungarian | 19% (65/326) |
| 🇮🇩 Indonesian | 23% (75/326) |
| 🇮🇹 Italian | 89% (291/326) |
| 🇯🇵 Japanese | 22% (73/326) |
| 🇲🇲 Burmese | 27% (90/326) |
| 🇳🇴 Norwegian Bokmål | 32% (106/326) |
| 🇳🇱 Dutch | 65% (212/326) |
| 🇳🇴 Norwegian Nynorsk | 32% (106/326) |
| 🇵🇱 Polish | 92% (300/326) |
| 🇧🇷 Portuguese (Brazil) | 95% (312/326) |
| 🇵🇹 Portuguese (Portugal) | 21% (71/326) |
| 🇷🇴 Romanian | 92% (301/326) |
| 🇷🇺 Russian | 93% (305/326) |
| 🇸🇰 Slovak | 19% (65/326) |
| 🇸🇮 Slovenian | 33% (109/326) |
| 🇸🇪 Swedish | 19% (63/326) |
| 🇵🇭 Tagalog | 19% (65/326) |
| 🇹🇷 Turkish | 22% (73/326) |
| 🇺🇦 Ukrainian | 96% (314/326) |
| 🇻🇳 Vietnamese | 32% (107/326) |
| 🇨🇳 Chinese (Simplified) | 96% (313/326) |
| 🇹🇼 Chinese (Traditional) | 90% (294/326) |
| 🇺🇸 English | 100% (328/328) |
| 🇪🇸 Catalan | 19% (65/328) |
| 🇨🇿 Czech | 95% (313/328) |
| 🇩🇰 Danish | 21% (69/328) |
| 🇩🇪 German | 95% (313/328) |
| 🇬🇷 Greek | 21% (72/328) |
| 🇪🇸 Spanish | 95% (314/328) |
| 🇫🇷 French | 98% (324/328) |
| 🇭🇺 Hungarian | 19% (65/328) |
| 🇮🇩 Indonesian | 22% (75/328) |
| 🇮🇹 Italian | 88% (291/328) |
| 🇯🇵 Japanese | 22% (73/328) |
| 🇲🇲 Burmese | 27% (90/328) |
| 🇳🇴 Norwegian Bokmål | 32% (106/328) |
| 🇳🇱 Dutch | 64% (212/328) |
| 🇳🇴 Norwegian Nynorsk | 32% (106/328) |
| 🇵🇱 Polish | 91% (300/328) |
| 🇧🇷 Portuguese (Brazil) | 95% (312/328) |
| 🇵🇹 Portuguese (Portugal) | 21% (71/328) |
| 🇷🇴 Romanian | 91% (301/328) |
| 🇷🇺 Russian | 92% (305/328) |
| 🇸🇰 Slovak | 19% (65/328) |
| 🇸🇮 Slovenian | 33% (109/328) |
| 🇸🇪 Swedish | 19% (63/328) |
| 🇵🇭 Tagalog | 19% (65/328) |
| 🇹🇷 Turkish | 22% (73/328) |
| 🇺🇦 Ukrainian | 95% (314/328) |
| 🇻🇳 Vietnamese | 32% (107/328) |
| 🇨🇳 Chinese (Simplified) | 95% (313/328) |
| 🇹🇼 Chinese (Traditional) | 89% (294/328) |
<!-- translations:end -->
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,9 @@ class MainActivity : LockedActivity<ActivityMainBinding>() {
val pinned = menu.addPinned(MenuItem.SHOW_AS_ACTION_ALWAYS)
menu.addLabels(MenuItem.SHOW_AS_ACTION_ALWAYS)
menu.addDelete(MenuItem.SHOW_AS_ACTION_ALWAYS)
menu.add(R.string.duplicate, R.drawable.content_copy) {
baseModel.duplicateSelectedBaseNotes()
}
menu.add(R.string.archive, R.drawable.archive) { moveNotes(Folder.ARCHIVED) }
menu.addChangeColor()
val share = menu.addShare()
Expand All @@ -645,6 +648,9 @@ class MainActivity : LockedActivity<ActivityMainBinding>() {
moveNotes(Folder.NOTES)
}
menu.addDelete(MenuItem.SHOW_AS_ACTION_ALWAYS)
menu.add(R.string.duplicate, R.drawable.content_copy) {
baseModel.duplicateSelectedBaseNotes()
}
menu.addExportMenu(MenuItem.SHOW_AS_ACTION_ALWAYS)
val pinned = menu.addPinned()
menu.addLabels()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ import com.philkes.notallyx.utils.getUriForFile
import com.philkes.notallyx.utils.log
import com.philkes.notallyx.utils.mergeSkipFirst
import com.philkes.notallyx.utils.observeSkipFirst
import com.philkes.notallyx.utils.openNote
import com.philkes.notallyx.utils.shareNote
import com.philkes.notallyx.utils.showColorSelectDialog
import com.philkes.notallyx.utils.textMaxLengthFilter
Expand Down Expand Up @@ -953,6 +954,14 @@ abstract class EditActivity(private val type: Type) :
}
}

override fun duplicate() {
lifecycleScope.launch {
saveNote(true)
val duplicateId = baseModel.duplicateNote(notallyModel.getBaseNote())
openNote(duplicateId, notallyModel.type, clearBackStack = true)
}
}

override fun changeReminders() {
val intent = Intent(this, RemindersActivity::class.java)
intent.putExtra(RemindersActivity.NOTE_ID, notallyModel.id)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.philkes.notallyx.presentation.activity.note

import android.app.Activity
import android.content.Intent
import android.graphics.Typeface
import android.net.Uri
Expand Down Expand Up @@ -53,6 +52,7 @@ import com.philkes.notallyx.presentation.view.note.action.AddNoteBottomSheet
import com.philkes.notallyx.utils.LinkMovementMethod
import com.philkes.notallyx.utils.copyToClipBoard
import com.philkes.notallyx.utils.findAllOccurrences
import com.philkes.notallyx.utils.openNote
import com.philkes.notallyx.utils.wrapWithChooser

class EditNoteActivity : EditActivity(Type.NOTE), AddNoteActions {
Expand Down Expand Up @@ -486,18 +486,7 @@ class EditNoteActivity : EditActivity(Type.NOTE), AddNoteActions {
}

private fun URLSpan.navigateToNote() {
val noteId = url.getNoteIdFromUrl()
val noteType = url.getNoteTypeFromUrl()
when (noteType) {
Type.NOTE -> goToActivity(EditNoteActivity::class.java, noteId)
Type.LIST -> goToActivity(EditListActivity::class.java, noteId)
}
}

private fun goToActivity(activity: Class<out Activity>, noteId: Long) {
val intent = Intent(this, activity)
intent.putExtra(EXTRA_SELECTED_BASE_NOTE, noteId)
startActivity(intent)
openNote(this.url.getNoteIdFromUrl(), this.url.getNoteTypeFromUrl())
}

private fun Intent?.getPickedNoteData(): Triple<String, String, Boolean> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ class MoreNoteBottomSheet(
}
false
},
Action(R.string.duplicate, R.drawable.content_copy) { _ ->
callbacks.duplicate()
true
},
Action(R.string.change_color, R.drawable.change_color) { _ ->
callbacks.changeColor()
true
Expand All @@ -60,6 +64,8 @@ interface MoreActions {

fun changeColor()

fun duplicate()

fun changeReminders()

fun changeLabels()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import com.philkes.notallyx.data.model.Header
import com.philkes.notallyx.data.model.Item
import com.philkes.notallyx.data.model.Label
import com.philkes.notallyx.data.model.SearchResult
import com.philkes.notallyx.data.model.deepCopy
import com.philkes.notallyx.data.model.toNoteIdReminders
import com.philkes.notallyx.presentation.activity.main.fragment.settings.SettingsFragment.Companion.EXTRA_SHOW_IMPORT_BACKUPS_FOLDER
import com.philkes.notallyx.presentation.getQuantityString
Expand Down Expand Up @@ -93,7 +94,6 @@ import com.philkes.notallyx.utils.viewFile
import java.io.File
import java.util.concurrent.atomic.AtomicInteger
import javax.crypto.Cipher
import kotlin.collections.map
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -701,6 +701,37 @@ class BaseNoteModel(private val app: Application) : AndroidViewModel(app) {
}
}

suspend fun duplicateNote(note: BaseNote) = duplicateNotes(listOf(note)).first()

suspend fun duplicateNotes(notes: Collection<BaseNote>): List<Long> {
val now = System.currentTimeMillis()
val copies: List<BaseNote> =
notes.map { original ->
original
.deepCopy()
.copy(
id = 0L,
title =
if (original.title.isNotEmpty())
"${original.title} (${app.getString(R.string.copy)})"
else app.getString(R.string.copy),
timestamp = now,
modifiedTimestamp = now,
)
}
return withContext(Dispatchers.IO) { baseNoteDao.insert(copies) }
}

fun duplicateSelectedBaseNotes() {
if (actionMode.isEmpty()) return
val selected = actionMode.selectedNotes.values.toList()
viewModelScope.launch {
duplicateNotes(selected)
actionMode.close(true)
app.showToast(app.getQuantityString(R.plurals.duplicated_notes, selected.size))
}
}

suspend fun getAllLabels() = withContext(Dispatchers.IO) { labelDao.getArrayOfAll() }

fun deleteLabel(value: String) {
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/com/philkes/notallyx/utils/AndroidExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,20 @@ fun Fragment.showErrorDialog(
.show()
}

fun Activity.openNote(noteId: Long, noteType: Type, clearBackStack: Boolean = false) {
val activity =
when (noteType) {
Type.NOTE -> EditNoteActivity::class.java
Type.LIST -> EditListActivity::class.java
}
val intent = Intent(this, activity)
if (clearBackStack) {
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
}
intent.putExtra(EXTRA_SELECTED_BASE_NOTE, noteId)
startActivity(intent)
}

fun Activity.showErrorDialog(
throwable: Throwable,
titleResId: Int,
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@
<string name="documentation">Documentation</string>
<string name="donate">Make a Donation</string>
<string name="drag_handle">Drag Handle</string>
<string name="duplicate">Duplicate</string>
<plurals name="duplicated_notes">
<item quantity="one">Duplicated %1$d note</item>
<item quantity="other">Duplicated %1$d notes</item>
</plurals>
<string name="edit">Edit</string>
<string name="edit_color">Edit Color</string>
<string name="edit_label">Edit label</string>
Expand Down
Binary file modified app/translations.xlsx
Binary file not shown.