diff --git a/app/src/main/java/org/secuso/privacyfriendlynotes/ui/adapter/CategoryAdapter.kt b/app/src/main/java/org/secuso/privacyfriendlynotes/ui/adapter/CategoryAdapter.kt
index 9c957a38..90421bba 100644
--- a/app/src/main/java/org/secuso/privacyfriendlynotes/ui/adapter/CategoryAdapter.kt
+++ b/app/src/main/java/org/secuso/privacyfriendlynotes/ui/adapter/CategoryAdapter.kt
@@ -14,6 +14,7 @@
package org.secuso.privacyfriendlynotes.ui.adapter
import android.graphics.Color
+import android.graphics.drawable.Drawable
import android.preference.PreferenceManager
import android.util.TypedValue
import android.view.LayoutInflater
@@ -53,20 +54,37 @@ class CategoryAdapter(
override fun onBindViewHolder(holder: CategoryHolder, position: Int) {
val (_, name, color) = categories[position]
holder.textViewCategoryName.text = name
- val backgroundColor = if (color != null) Color.parseColor(color) else {
+
+ if (color == null) {
val value = TypedValue()
holder.itemView.context.theme.resolveAttribute(R.attr.colorOnSurface, value, true)
- value.data
- }
- if (PreferenceManager.getDefaultSharedPreferences(holder.itemView.context).getBoolean("settings_color_category", true)) {
- if (isDarkMode(holder.textViewCategoryName.context)) {
- holder.textViewCategoryName.setTextColor(backgroundColor)
- holder.btnColorSelector.setBackgroundColor(backgroundColor)
+ val defaultColor = value.data
+
+ if (PreferenceManager.getDefaultSharedPreferences(holder.itemView.context).getBoolean("settings_color_category", true)) {
+ holder.btnColorSelector.setIconResource(R.drawable.transparent_checker)
+ holder.btnColorSelector.setBackgroundColor(holder.btnColorSelector.resources.getColor(R.color.transparent))
+ if (isDarkMode(holder.textViewCategoryName.context)) {
+ holder.textViewCategoryName.setTextColor(defaultColor)
+ } else {
+ holder.itemView.setBackgroundColor(defaultColor)
+ }
} else {
- holder.itemView.setBackgroundColor(backgroundColor)
+ holder.btnExpandMenu.visibility = View.GONE
}
} else {
- holder.btnExpandMenu.visibility = View.GONE
+ val backgroundColor = Color.parseColor(color)
+ if (PreferenceManager.getDefaultSharedPreferences(holder.itemView.context).getBoolean("settings_color_category", true)) {
+ holder.btnColorSelector.icon = null
+ holder.btnColorSelector.setBackgroundColor(backgroundColor)
+ if (isDarkMode(holder.textViewCategoryName.context)) {
+ holder.textViewCategoryName.setTextColor(backgroundColor)
+ } else {
+ holder.itemView.setBackgroundColor(backgroundColor)
+ }
+ } else {
+ holder.btnExpandMenu.visibility = View.GONE
+ }
+
}
}
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 ea9ea749..83299179 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
@@ -74,15 +74,21 @@ class NoteAdapter(
if (colorCategory) {
mainActivityViewModel.categoryColor(currentNote.category) {
- val color: Int = it?.let { Color.parseColor(it) } ?: run {
- val value = TypedValue()
- holder.itemView.context.theme.resolveAttribute(R.attr.colorOnSurface, value, true)
- value.data
- }
+
if (DarkModeUtil.isDarkMode(holder.textViewTitle.context)) {
+ val color: Int = it?.let { Color.parseColor(it) } ?: run {
+ val value = TypedValue()
+ holder.itemView.context.theme.resolveAttribute(R.attr.colorOnBackground, value, true)
+ value.data
+ }
holder.textViewTitle.setTextColor(color)
holder.textViewExtraText.setTextColor(color)
} else {
+ val color: Int = it?.let { Color.parseColor(it) } ?: run {
+ val value = TypedValue()
+ holder.itemView.context.theme.resolveAttribute(R.attr.colorSurface, value, true)
+ value.data
+ }
holder.viewNoteItem.setBackgroundColor(color)
}
}
diff --git a/app/src/main/java/org/secuso/privacyfriendlynotes/ui/manageCategories/ManageCategoriesActivity.kt b/app/src/main/java/org/secuso/privacyfriendlynotes/ui/manageCategories/ManageCategoriesActivity.kt
index 9057bb0e..2aefc986 100644
--- a/app/src/main/java/org/secuso/privacyfriendlynotes/ui/manageCategories/ManageCategoriesActivity.kt
+++ b/app/src/main/java/org/secuso/privacyfriendlynotes/ui/manageCategories/ManageCategoriesActivity.kt
@@ -16,6 +16,7 @@ package org.secuso.privacyfriendlynotes.ui.manageCategories
import android.content.DialogInterface
import android.os.Bundle
import android.preference.PreferenceManager
+import android.util.Log
import android.util.TypedValue
import android.view.View
import android.widget.EditText
@@ -23,6 +24,7 @@ import android.widget.ImageButton
import android.widget.LinearLayout
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
+import androidx.core.graphics.toColorInt
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.ItemTouchHelper
@@ -46,7 +48,6 @@ class ManageCategoriesActivity : AppCompatActivity(), View.OnClickListener, OnDi
private val manageCategoriesViewModel: ManageCategoriesViewModel by lazy { ViewModelProvider(this)[ManageCategoriesViewModel::class.java] }
private val etName: EditText by lazy { findViewById(R.id.etName) }
private val recyclerList: RecyclerView by lazy { findViewById(R.id.recyclerview_category) }
- private val btnResetColor: ImageButton by lazy { findViewById(R.id.category_menu_color_reset) }
private val btnColorSelector: MaterialButton by lazy { findViewById(R.id.btn_color_selector) }
private val btnExpandMenu: ImageButton by lazy { findViewById(R.id.category_expand_menu_button) }
private val expandMenu: LinearLayout by lazy { findViewById(R.id.category_expand_menu) }
@@ -94,11 +95,6 @@ class ManageCategoriesActivity : AppCompatActivity(), View.OnClickListener, OnDi
theme.resolveAttribute(R.attr.colorOnSurface, value, true)
btnColorSelector.setBackgroundColor(value.data)
btnExpandMenu.setOnClickListener { expandMenu.visibility = if (expandMenu.visibility == View.GONE) { View.VISIBLE } else { View.GONE } }
- btnResetColor.setOnClickListener {
- btnColorSelector.setBackgroundColor(resources.getColor(R.color.transparent))
- manageCategoriesViewModel
- catColor = null
- }
btnColorSelector.setOnClickListener { displayColorDialog() }
} else {
btnExpandMenu.visibility = View.GONE
@@ -124,7 +120,7 @@ class ManageCategoriesActivity : AppCompatActivity(), View.OnClickListener, OnDi
if (sp.getBoolean(SettingsActivity.PREF_DEL_NOTES, false)) {
lifecycleScope.launch {
manageCategoriesViewModel.notes.collect {
- notes -> notes.filter { it.category == cat._id }.forEach { manageCategoriesViewModel.delete(it) }
+ notes -> notes.filter { it.category == cat._id }.forEach { manageCategoriesViewModel.delete(it) }
}
}
}
@@ -138,21 +134,29 @@ class ManageCategoriesActivity : AppCompatActivity(), View.OnClickListener, OnDi
.cancelable(true) //allows close by tapping outside of dialog
.colors(this, R.array.mdcolor_500)
.choiceMode(SimpleColorDialog.SINGLE_CHOICE_DIRECT) //auto-close on selection
+ .neut(R.string.default_color)
.extra(bundle)
.show(this, TAG_COLORDIALOG)
}
override fun onResult(dialogTag: String, which: Int, extras: Bundle): Boolean {
- if (dialogTag == TAG_COLORDIALOG && which == DialogInterface.BUTTON_POSITIVE) {
- val color = extras.getInt(SimpleColorDialog.COLOR)
+ // 0 is dismiss
+ if (dialogTag == TAG_COLORDIALOG && which != DialogInterface.BUTTON_NEGATIVE && which != 0) {
+ val color = if (which == DialogInterface.BUTTON_POSITIVE) "#${Integer.toHexString(extras.getInt(SimpleColorDialog.COLOR))}" else null;
val position = extras.getInt(CATEGORY_COLOR, -1)
// Check if the user changes a category color
if (position != -1) {
- manageCategoriesViewModel.update(adapter.categories[position], "#${Integer.toHexString(color)}")
+ manageCategoriesViewModel.update(adapter.categories[position], color)
} else {
- btnColorSelector.setBackgroundColor(color)
- catColor = "#${Integer.toHexString(color)}"
+ if (color == null) {
+ btnColorSelector.setIconResource(R.drawable.transparent_checker)
+ btnColorSelector.setBackgroundColor(resources.getColor(R.color.transparent))
+ } else {
+ btnColorSelector.icon = null
+ btnColorSelector.setBackgroundColor(color.toColorInt())
+ }
+ catColor = color
}
return true
}
diff --git a/app/src/main/res/drawable/transparent_checker.xml b/app/src/main/res/drawable/transparent_checker.xml
new file mode 100644
index 00000000..4be169e3
--- /dev/null
+++ b/app/src/main/res/drawable/transparent_checker.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_manage_categories.xml b/app/src/main/res/layout/activity_manage_categories.xml
index 8293cb2a..d0e8e88a 100644
--- a/app/src/main/res/layout/activity_manage_categories.xml
+++ b/app/src/main/res/layout/activity_manage_categories.xml
@@ -62,24 +62,26 @@
android:layout_height="match_parent"
android:layout_weight="0.55"/>
-
-
-
+ android:layout_height="30dp"
+ app:cardCornerRadius="5dp"
+ >
+
+
diff --git a/app/src/main/res/layout/item_category.xml b/app/src/main/res/layout/item_category.xml
index 12b13d1d..edbb8850 100644
--- a/app/src/main/res/layout/item_category.xml
+++ b/app/src/main/res/layout/item_category.xml
@@ -73,16 +73,26 @@
android:backgroundTint="?attr/colorIconFill"
android:background="@drawable/ic_baseline_format_color_reset_icon_24dp" />
-
+ android:layout_height="30dp"
+ app:cardCornerRadius="5dp"
+ >
+
+
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 3df26c02..86535984 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -12,6 +12,7 @@
Privacy Friendly Notizen
Speichern
Standard
+ Standard
Wollen Sie %1s endgültig löschen?
%1s löschen?
Sie müssen mindestens eine Kategorie erstellen. Möchten Sie dies jetzt tun?
diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml
index 62d7da73..4184e3c7 100644
--- a/app/src/main/res/values-ja/strings.xml
+++ b/app/src/main/res/values-ja/strings.xml
@@ -2,6 +2,7 @@
Notes
Privacy Friendly Notes
デフォルト
+ デフォルト
カテゴリー
テキスト メモ
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 03596a63..31065a30 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -2,6 +2,7 @@
Notes
Privacy Friendly Notes
Default
+ Default
Categories
Text Note