From c502abecc2986c5a9e98b10a19ca5557fa9124cc Mon Sep 17 00:00:00 2001 From: Kyle Corry Date: Sun, 19 Nov 2023 12:10:00 -0500 Subject: [PATCH] Capitalize tool titles --- .../trail_sense/tools/ui/ToolButton.kt | 60 ------------------- .../render/CategoryToolListItemRenderer.kt | 3 +- .../render/HeaderToolListItemRenderer.kt | 3 +- .../render/ToolButtonToolListItemRenderer.kt | 3 +- 4 files changed, 6 insertions(+), 63 deletions(-) delete mode 100644 app/src/main/java/com/kylecorry/trail_sense/tools/ui/ToolButton.kt diff --git a/app/src/main/java/com/kylecorry/trail_sense/tools/ui/ToolButton.kt b/app/src/main/java/com/kylecorry/trail_sense/tools/ui/ToolButton.kt deleted file mode 100644 index e5e374c3f..000000000 --- a/app/src/main/java/com/kylecorry/trail_sense/tools/ui/ToolButton.kt +++ /dev/null @@ -1,60 +0,0 @@ -package com.kylecorry.trail_sense.tools.ui - -import android.content.Context -import android.content.res.ColorStateList -import android.util.AttributeSet -import android.view.Gravity -import android.view.View -import android.widget.FrameLayout -import android.widget.TextView -import com.kylecorry.andromeda.core.system.Resources -import com.kylecorry.andromeda.core.ui.setCompoundDrawables -import com.kylecorry.trail_sense.R -import com.kylecorry.trail_sense.shared.CustomUiUtils - -class ToolButton(context: Context, attrs: AttributeSet? = null) : FrameLayout(context, attrs) { - - private val textView: TextView - - private val iconSize = Resources.dp(context, 24f).toInt() - private val iconPadding = Resources.dp(context, 12f).toInt() - private val iconColor = Resources.androidTextColorPrimary(context) - private val buttonHeight = Resources.dp(context, 64f).toInt() - private val buttonPadding = Resources.dp(context, 16f).toInt() - private val buttonBackgroundColor = - Resources.getAndroidColorAttr(context, android.R.attr.colorBackgroundFloating) - - var text: CharSequence? - get() = textView.text - set(value) { - textView.text = value - } - - fun setIconResource(icon: Int) { - textView.setCompoundDrawables(iconSize, left = icon) - CustomUiUtils.setImageColor(textView, iconColor) - } - - fun setOnClickListener(listener: (View) -> Unit) { - textView.setOnClickListener(listener) - } - - fun setOnLongClickListener(listener: (View) -> Boolean) { - textView.setOnLongClickListener(listener) - } - - init { - textView = TextView(context) - textView.compoundDrawablePadding = iconPadding - textView.elevation = 2f - textView.layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, buttonHeight) - textView.gravity = Gravity.CENTER_VERTICAL - textView.setPadding(buttonPadding, 0, buttonPadding, 0) - - textView.setBackgroundResource(R.drawable.rounded_rectangle) - textView.backgroundTintList = ColorStateList.valueOf(buttonBackgroundColor) - - addView(textView) - } - -} \ No newline at end of file diff --git a/app/src/main/java/com/kylecorry/trail_sense/tools/ui/items/render/CategoryToolListItemRenderer.kt b/app/src/main/java/com/kylecorry/trail_sense/tools/ui/items/render/CategoryToolListItemRenderer.kt index 83108a9f9..47f69e8ed 100644 --- a/app/src/main/java/com/kylecorry/trail_sense/tools/ui/items/render/CategoryToolListItemRenderer.kt +++ b/app/src/main/java/com/kylecorry/trail_sense/tools/ui/items/render/CategoryToolListItemRenderer.kt @@ -3,6 +3,7 @@ package com.kylecorry.trail_sense.tools.ui.items.render import android.view.ViewGroup import androidx.core.view.isVisible import androidx.core.view.setMargins +import com.kylecorry.andromeda.core.capitalizeWords import com.kylecorry.andromeda.core.system.Resources import com.kylecorry.andromeda.core.ui.setCompoundDrawables import com.kylecorry.trail_sense.databinding.ListItemToolBinding @@ -31,7 +32,7 @@ class CategoryToolListItemRenderer : ToolListItemRenderer { ) binding.title.paint.isFakeBoldText = true binding.title.textSize = 14f - binding.title.text = item.title + binding.title.text = item.title?.capitalizeWords() binding.title.isVisible = item.title != null // Click action diff --git a/app/src/main/java/com/kylecorry/trail_sense/tools/ui/items/render/HeaderToolListItemRenderer.kt b/app/src/main/java/com/kylecorry/trail_sense/tools/ui/items/render/HeaderToolListItemRenderer.kt index 8a4b465ee..47d489d40 100644 --- a/app/src/main/java/com/kylecorry/trail_sense/tools/ui/items/render/HeaderToolListItemRenderer.kt +++ b/app/src/main/java/com/kylecorry/trail_sense/tools/ui/items/render/HeaderToolListItemRenderer.kt @@ -3,6 +3,7 @@ package com.kylecorry.trail_sense.tools.ui.items.render import android.view.ViewGroup import androidx.core.view.isVisible import androidx.core.view.setMargins +import com.kylecorry.andromeda.core.capitalizeWords import com.kylecorry.andromeda.core.system.Resources import com.kylecorry.andromeda.core.ui.Colors import com.kylecorry.andromeda.core.ui.setCompoundDrawables @@ -36,7 +37,7 @@ class HeaderToolListItemRenderer : ToolListItemRenderer { binding.title.setTextColor(Resources.androidTextColorPrimary(context)) binding.title.paint.isFakeBoldText = false binding.title.textSize = 24f - binding.title.text = item.title + binding.title.text = item.title?.capitalizeWords() binding.title.isVisible = item.title != null // Remove root click listeners diff --git a/app/src/main/java/com/kylecorry/trail_sense/tools/ui/items/render/ToolButtonToolListItemRenderer.kt b/app/src/main/java/com/kylecorry/trail_sense/tools/ui/items/render/ToolButtonToolListItemRenderer.kt index 680495af9..f2ba2cedd 100644 --- a/app/src/main/java/com/kylecorry/trail_sense/tools/ui/items/render/ToolButtonToolListItemRenderer.kt +++ b/app/src/main/java/com/kylecorry/trail_sense/tools/ui/items/render/ToolButtonToolListItemRenderer.kt @@ -4,6 +4,7 @@ import android.content.res.ColorStateList import android.view.ViewGroup import androidx.core.view.isVisible import androidx.core.view.setMargins +import com.kylecorry.andromeda.core.capitalizeWords import com.kylecorry.andromeda.core.system.Resources import com.kylecorry.andromeda.core.ui.Colors import com.kylecorry.andromeda.core.ui.setCompoundDrawables @@ -39,7 +40,7 @@ class ToolButtonToolListItemRenderer : ToolListItemRenderer { binding.title.setTextColor(Resources.androidTextColorPrimary(context)) binding.title.paint.isFakeBoldText = false binding.title.textSize = 14f - binding.title.text = item.title + binding.title.text = item.title?.capitalizeWords() binding.title.isVisible = item.title != null // Click action