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% (339/339) |
| 🇪🇸 Catalan | 19% (65/339) |
| 🇨🇿 Czech | 92% (314/339) |
| 🇩🇰 Danish | 20% (69/339) |
| 🇩🇪 German | 99% (336/339) |
| 🇬🇷 Greek | 21% (72/339) |
| 🇪🇸 Spanish | 92% (315/339) |
| 🇫🇷 French | 96% (328/339) |
| 🇭🇺 Hungarian | 19% (65/339) |
| 🇮🇩 Indonesian | 22% (75/339) |
| 🇮🇹 Italian | 86% (292/339) |
| 🇯🇵 Japanese | 21% (73/339) |
| 🇲🇲 Burmese | 26% (91/339) |
| 🇳🇴 Norwegian Bokmål | 31% (107/339) |
| 🇳🇱 Dutch | 62% (213/339) |
| 🇳🇴 Norwegian Nynorsk | 31% (107/339) |
| 🇵🇱 Polish | 88% (301/339) |
| 🇧🇷 Portuguese (Brazil) | 92% (313/339) |
| 🇵🇹 Portuguese (Portugal) | 20% (71/339) |
| 🇷🇴 Romanian | 89% (302/339) |
| 🇷🇺 Russian | 90% (306/339) |
| 🇸🇰 Slovak | 19% (65/339) |
| 🇸🇮 Slovenian | 32% (110/339) |
| 🇸🇪 Swedish | 18% (63/339) |
| 🇵🇭 Tagalog | 19% (65/339) |
| 🇹🇷 Turkish | 21% (73/339) |
| 🇺🇦 Ukrainian | 97% (332/339) |
| 🇻🇳 Vietnamese | 31% (108/339) |
| 🇨🇳 Chinese (Simplified) | 97% (329/339) |
| 🇹🇼 Chinese (Traditional) | 87% (295/339) |
| 🇺🇸 English | 100% (344/344) |
| 🇪🇸 Catalan | 18% (65/344) |
| 🇨🇿 Czech | 91% (314/344) |
| 🇩🇰 Danish | 20% (69/344) |
| 🇩🇪 German | 97% (336/344) |
| 🇬🇷 Greek | 20% (72/344) |
| 🇪🇸 Spanish | 91% (315/344) |
| 🇫🇷 French | 95% (328/344) |
| 🇭🇺 Hungarian | 18% (65/344) |
| 🇮🇩 Indonesian | 21% (75/344) |
| 🇮🇹 Italian | 84% (292/344) |
| 🇯🇵 Japanese | 21% (73/344) |
| 🇲🇲 Burmese | 26% (91/344) |
| 🇳🇴 Norwegian Bokmål | 31% (107/344) |
| 🇳🇱 Dutch | 61% (213/344) |
| 🇳🇴 Norwegian Nynorsk | 31% (107/344) |
| 🇵🇱 Polish | 87% (301/344) |
| 🇧🇷 Portuguese (Brazil) | 90% (313/344) |
| 🇵🇹 Portuguese (Portugal) | 20% (71/344) |
| 🇷🇴 Romanian | 87% (302/344) |
| 🇷🇺 Russian | 88% (306/344) |
| 🇸🇰 Slovak | 18% (65/344) |
| 🇸🇮 Slovenian | 31% (110/344) |
| 🇸🇪 Swedish | 18% (63/344) |
| 🇵🇭 Tagalog | 18% (65/344) |
| 🇹🇷 Turkish | 21% (73/344) |
| 🇺🇦 Ukrainian | 96% (332/344) |
| 🇻🇳 Vietnamese | 31% (108/344) |
| 🇨🇳 Chinese (Simplified) | 95% (329/344) |
| 🇹🇼 Chinese (Traditional) | 85% (295/344) |
<!-- translations:end -->
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ interface BaseNoteDao {
)
suspend fun move(ids: LongArray, folder: Folder, timestamp: Long)

@Query("SELECT DISTINCT color FROM BaseNote") fun getAllColorsAsync(): LiveData<List<String>>

@Query("SELECT DISTINCT color FROM BaseNote") suspend fun getAllColors(): List<String>

@Query("UPDATE BaseNote SET color = :color WHERE id IN (:ids)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ abstract class LockedActivity<T : ViewBinding> : AppCompatActivity() {
ActivityResultLauncher<Intent>

internal lateinit var binding: T
protected lateinit var preferences: NotallyXPreferences
internal lateinit var preferences: NotallyXPreferences
val baseModel: BaseNoteModel by viewModels()

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ class MainActivity : LockedActivity<ActivityMainBinding>() {
.value
.getBaseNoteDao()
.getAllColors()
.toSet()
}
// Show color as selected only if all selected notes have the same color
val currentColor =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.philkes.notallyx.R
import com.philkes.notallyx.data.NotallyDatabase
import com.philkes.notallyx.data.model.Audio
import com.philkes.notallyx.data.model.ColorString
import com.philkes.notallyx.data.model.FileAttachment
import com.philkes.notallyx.data.model.Folder
import com.philkes.notallyx.data.model.NoteViewMode
Expand Down Expand Up @@ -269,14 +270,15 @@ class NoteActionHandler(

private fun changeColor() {
activity.lifecycleScope.launch {
val colors =
val colors: MutableSet<ColorString> =
withContext(Dispatchers.IO) {
NotallyDatabase.getDatabase(activity, observePreferences = false)
.value
.getBaseNoteDao()
.getAllColors()
.toMutableSet()
}
.toMutableList()
.toMutableSet()
if (colors.none { it == notallyModel.color }) {
colors.add(notallyModel.color)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ package com.philkes.notallyx.presentation.view.main
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.philkes.notallyx.data.model.ColorString
import com.philkes.notallyx.databinding.RecyclerColorBinding
import com.philkes.notallyx.presentation.view.misc.ItemListener

class ColorAdapter(
private val colors: List<String>,
private val selectedColor: String?,
private val colors: List<ColorString>,
private val selectedColor: ColorString?,
var defaultColor: ColorString?,
private val listener: ItemListener,
) : RecyclerView.Adapter<ColorVH>() {

override fun getItemCount() = colors.size

override fun onBindViewHolder(holder: ColorVH, position: Int) {
val color = colors[position]
holder.bind(color, color == selectedColor)
holder.bind(color, color == selectedColor, color == defaultColor)
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ColorVH {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import com.philkes.notallyx.R
import com.philkes.notallyx.data.model.BaseNote
import com.philkes.notallyx.data.model.ColorString
import com.philkes.notallyx.databinding.RecyclerColorBinding
import com.philkes.notallyx.presentation.dp
import com.philkes.notallyx.presentation.extractColor
Expand All @@ -23,7 +24,7 @@ class ColorVH(private val binding: RecyclerColorBinding, listener: ItemListener)
}
}

fun bind(color: String, isSelected: Boolean) {
fun bind(color: ColorString, isSelected: Boolean, isNoteDefault: Boolean = false) {
val showAddIcon = color == BaseNote.COLOR_NEW
val context = binding.root.context
val value =
Expand All @@ -32,8 +33,11 @@ class ColorVH(private val binding: RecyclerColorBinding, listener: ItemListener)
val controlsColor = context.getContrastFontColor(value)
binding.apply {
CardView.apply {
setCardBackgroundColor(value)
contentDescription = color
setCardBackgroundColor(value)
if (color == BaseNote.COLOR_DEFAULT) {
setBackgroundResource(R.drawable.dashed_background)
}
if (isSelected) {
strokeWidth = 4.dp
strokeColor = controlsColor
Expand All @@ -51,6 +55,10 @@ class ColorVH(private val binding: RecyclerColorBinding, listener: ItemListener)
imageTintList = ColorStateList.valueOf(controlsColor)
isVisible = showAddIcon || isSelected
}
DefaultColorIcon.apply {
isVisible = isNoteDefault
imageTintList = ColorStateList.valueOf(controlsColor)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,10 @@ class BaseNoteModel(private val app: Application) : AndroidViewModel(app) {
}

fun changeColor(oldColor: String, newColor: String) {
val defaultColor = preferences.defaultNoteColor.value
if (oldColor == defaultColor) {
preferences.defaultNoteColor.save(newColor)
}
viewModelScope.launch(Dispatchers.IO) { baseNoteDao.updateColor(oldColor, newColor) }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class NotallyModel(private val app: Application) : AndroidViewModel(app) {

var id = 0L
var folder = Folder.NOTES
var color = BaseNote.COLOR_DEFAULT
var color = preferences.defaultNoteColor.value

var title = String()
var pinned = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.preference.PreferenceManager
import androidx.security.crypto.EncryptedSharedPreferences
import androidx.security.crypto.MasterKey
import com.philkes.notallyx.R
import com.philkes.notallyx.data.model.BaseNote
import com.philkes.notallyx.data.model.Type
import com.philkes.notallyx.presentation.viewmodel.preference.Constants.PASSWORD_EMPTY
import com.philkes.notallyx.utils.backup.importPreferences
Expand Down Expand Up @@ -204,6 +205,8 @@ class NotallyXPreferences private constructor(private val context: Context) {
*/
val dataSchemaId = IntPreference("dataSchemaId", preferences, 0, 0, Integer.MAX_VALUE)

val defaultNoteColor = StringPreference("defaultNoteColor", preferences, BaseNote.COLOR_DEFAULT)

fun setDataSchemaId(value: Int) {
preferences.edit(true) { putInt(dataSchemaId.key, value) }
dataSchemaId.refresh()
Expand Down Expand Up @@ -309,6 +312,7 @@ class NotallyXPreferences private constructor(private val context: Context) {
autoRemoveDeletedNotesAfterDays,
editNoteActivityTopActions,
editNoteActivityBottomAction,
defaultNoteColor,
)
.forEach { it.refresh() }
}
Expand Down
Loading