diff --git a/app/src/main/java/com/kylecorry/trail_sense/shared/views/MaterialSpinnerView.kt b/app/src/main/java/com/kylecorry/trail_sense/shared/views/MaterialSpinnerView.kt index d3feea1cc..f5c1c9fac 100644 --- a/app/src/main/java/com/kylecorry/trail_sense/shared/views/MaterialSpinnerView.kt +++ b/app/src/main/java/com/kylecorry/trail_sense/shared/views/MaterialSpinnerView.kt @@ -3,6 +3,9 @@ package com.kylecorry.trail_sense.shared.views import android.content.Context import android.util.AttributeSet import android.widget.FrameLayout +import androidx.core.text.bold +import androidx.core.text.buildSpannedString +import androidx.core.text.scale import com.google.android.material.textfield.TextInputEditText import com.google.android.material.textfield.TextInputLayout import com.kylecorry.andromeda.pickers.Pickers @@ -14,6 +17,7 @@ class MaterialSpinnerView(context: Context, attrs: AttributeSet?) : FrameLayout( private val holder: TextInputLayout private var listener: ((Int?) -> Unit)? = null private var items: List = listOf() + private var descriptions: List = listOf() var selectedItemPosition: Int = 0 private set @@ -27,7 +31,32 @@ class MaterialSpinnerView(context: Context, attrs: AttributeSet?) : FrameLayout( holder = findViewById(R.id.material_spinner_holder) edittext.setOnClickListener { - Pickers.item(context, holder.hint ?: "", items, selectedItemPosition) { + val pickerItems = items.mapIndexed { index, item -> + buildSpannedString { + val hasDescription = descriptions.getOrNull(index)?.isNotBlank() == true + if (hasDescription) { + bold { + append(item) + } + } else { + append(item) + } + if (hasDescription) { + append("\n") + scale(0.2f) { + append("\n") + } + scale(0.65f) { + append(descriptions[index]) + } + scale(0.2f) { + append("\n") + } + } + } + } + + Pickers.item(context, holder.hint ?: "", pickerItems, selectedItemPosition) { it ?: return@item setSelection(it) } @@ -38,6 +67,10 @@ class MaterialSpinnerView(context: Context, attrs: AttributeSet?) : FrameLayout( this.items = items } + fun setDescriptions(descriptions: List) { + this.descriptions = descriptions + } + fun setSelection(position: Int) { selectedItemPosition = position listener?.invoke(position) diff --git a/app/src/main/java/com/kylecorry/trail_sense/tools/tides/ui/CreateTideFragment.kt b/app/src/main/java/com/kylecorry/trail_sense/tools/tides/ui/CreateTideFragment.kt index 5cf3ab781..c02779dbb 100644 --- a/app/src/main/java/com/kylecorry/trail_sense/tools/tides/ui/CreateTideFragment.kt +++ b/app/src/main/java/com/kylecorry/trail_sense/tools/tides/ui/CreateTideFragment.kt @@ -65,7 +65,18 @@ class CreateTideFragment : BoundFragment() { EstimateType.LunitidalIntervalManualLocal to getString(R.string.lunitidal_interval_local), EstimateType.LunitidalIntervalManualUTC to getString(R.string.lunitidal_interval_utc), EstimateType.TideModel to getString(R.string.tide_model_auto), - EstimateType.Harmonic to getString(R.string.harmonic) + " (!! NEED TO MANUALLY INSERT INTO DB !!)" + EstimateType.Harmonic to getString(R.string.harmonic) + ) + } + + private val estimateTypeDescriptionMap by lazy { + mapOf( + EstimateType.Clock to getString(R.string.tide_estimation_description_tide_clock), + EstimateType.LunitidalIntervalAuto to getString(R.string.tide_estimation_description_lunitidal_interval_auto), + EstimateType.LunitidalIntervalManualLocal to getString(R.string.tide_estimation_description_lunitidal_interval_local), + EstimateType.LunitidalIntervalManualUTC to getString(R.string.tide_estimation_description_lunitidal_interval_utc), + EstimateType.TideModel to getString(R.string.tide_estimation_description_tide_model), + EstimateType.Harmonic to "!! NEED TO MANUALLY INSERT INTO DB !!" ) } @@ -117,6 +128,9 @@ class CreateTideFragment : BoundFragment() { binding.estimateAlgorithmSpinner.setItems( estimateTypes.map { estimateTypeNameMap[it] ?: "" }, ) + binding.estimateAlgorithmSpinner.setDescriptions( + estimateTypes.map { estimateTypeDescriptionMap[it] ?: "" } + ) binding.estimateAlgorithmSpinner.setSelection(0) binding.estimateAlgorithmSpinner.setOnItemSelectedListener { position -> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0702f6e76..e4347597f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1514,4 +1514,9 @@ Nearby beacons pref_tide_model_enabled Tide model (auto) + Uses the clock to estimate tides. Requires at least one known tide. + Uses the moon\'s position to estimate tides. Requires at least one known tide. + Uses the moon\'s position to estimate tides. Requires the local lunitidal interval and the location. + Uses the moon\'s position to estimate tides. Requires the UTC lunitidal interval. + Uses a built-in tide model to estimate tides for the entered location or your location if none is entered. \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9dbb35fe6..1eb3434bf 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,7 +5,7 @@ androidXTestRunner = "1.6.2" androidXTestUiAutomator = "2.3.0" androidXArchCore = "2.2.0" androidXCoreRemoteViews = "1.1.0" -andromedaVersion = "11.2.0" +andromedaVersion = "11.3.0" cameraxVersion = "1.4.0" coreKtx = "1.15.0" appcompat = "1.7.0"