Fix displaying recipe ingredient note twice (#197)
* Update README.md * Bump version to 35 * Cleanup dependencies * Bump versions of dependencies * Save isFood/disableAmount flags to db * Fix displaying ingredient note twice * Remove whitespace after note is extracted
This commit is contained in:
@@ -7,7 +7,6 @@ import java.util.Properties
|
||||
plugins {
|
||||
id("gq.kirmanak.mealient.application")
|
||||
id("kotlin-kapt")
|
||||
id("androidx.navigation.safeargs.kotlin")
|
||||
id("dagger.hilt.android.plugin")
|
||||
alias(libs.plugins.ksp)
|
||||
alias(libs.plugins.appsweep)
|
||||
@@ -17,8 +16,8 @@ plugins {
|
||||
android {
|
||||
defaultConfig {
|
||||
applicationId = "gq.kirmanak.mealient"
|
||||
versionCode = 34
|
||||
versionName = "0.4.5"
|
||||
versionCode = 35
|
||||
versionName = "0.4.6"
|
||||
testInstrumentationRunner = "gq.kirmanak.mealient.MealientTestRunner"
|
||||
testInstrumentationRunnerArguments += mapOf("clearPackageData" to "true")
|
||||
resourceConfigurations += listOf("en", "es", "ru", "fr", "nl", "pt", "de")
|
||||
@@ -75,6 +74,9 @@ android {
|
||||
}
|
||||
}
|
||||
}
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
}
|
||||
}
|
||||
|
||||
ksp {
|
||||
@@ -98,20 +100,11 @@ dependencies {
|
||||
|
||||
implementation(libs.android.material.material)
|
||||
|
||||
implementation(libs.androidx.navigation.fragmentKtx)
|
||||
implementation(libs.androidx.navigation.runtimeKtx)
|
||||
implementation(libs.androidx.navigation.uiKtx)
|
||||
|
||||
implementation(libs.androidx.coreKtx)
|
||||
implementation(libs.androidx.splashScreen)
|
||||
|
||||
implementation(libs.androidx.appcompat)
|
||||
|
||||
implementation(libs.androidx.constraintLayout)
|
||||
|
||||
implementation(libs.androidx.swipeRefreshLayout)
|
||||
|
||||
implementation(libs.androidx.lifecycle.livedataKtx)
|
||||
implementation(libs.androidx.lifecycle.viewmodelKtx)
|
||||
|
||||
implementation(libs.androidx.shareTarget)
|
||||
@@ -131,8 +124,6 @@ dependencies {
|
||||
|
||||
implementation(libs.jetbrains.kotlinx.datetime)
|
||||
|
||||
implementation(libs.kirich1409.viewBinding)
|
||||
|
||||
implementation(libs.androidx.datastore.preferences)
|
||||
|
||||
implementation(libs.coil)
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
package gq.kirmanak.mealient.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.annotation.IdRes
|
||||
import androidx.annotation.LayoutRes
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.WindowInsetsControllerCompat
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import by.kirich1409.viewbindingdelegate.viewBinding
|
||||
import gq.kirmanak.mealient.extensions.isDarkThemeOn
|
||||
import gq.kirmanak.mealient.logging.Logger
|
||||
import javax.inject.Inject
|
||||
|
||||
abstract class BaseActivity<T : ViewBinding>(
|
||||
binder: (View) -> T,
|
||||
@IdRes containerId: Int,
|
||||
@LayoutRes layoutRes: Int,
|
||||
) : AppCompatActivity(layoutRes) {
|
||||
|
||||
protected val binding by viewBinding(binder, containerId)
|
||||
|
||||
@Inject
|
||||
lateinit var logger: Logger
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
logger.v { "onCreate() called with: savedInstanceState = $savedInstanceState" }
|
||||
setContentView(binding.root)
|
||||
with(WindowInsetsControllerCompat(window, window.decorView)) {
|
||||
val isAppearanceLightBars = !isDarkThemeOn()
|
||||
isAppearanceLightNavigationBars = isAppearanceLightBars
|
||||
isAppearanceLightStatusBars = isAppearanceLightBars
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,13 +86,14 @@ private fun IngredientListItem(
|
||||
onCheckedChange = { isChecked = it },
|
||||
)
|
||||
|
||||
val (text, note) = item.textAndNote
|
||||
Column {
|
||||
Text(
|
||||
text = item.display,
|
||||
text = text,
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
)
|
||||
|
||||
if (item.note.isNotBlank()) {
|
||||
if (note.isNotBlank()) {
|
||||
Text(
|
||||
text = item.note,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
@@ -100,4 +101,21 @@ private fun IngredientListItem(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val RecipeIngredientEntity.textAndNote: Pair<String, String>
|
||||
get() = when {
|
||||
disableAmount -> note to ""
|
||||
|
||||
note.isBlank() -> display to ""
|
||||
|
||||
else -> {
|
||||
val text = if (display.endsWith(note)) {
|
||||
display.dropLast(note.length).trimEnd()
|
||||
} else {
|
||||
display
|
||||
}
|
||||
|
||||
text to note
|
||||
}
|
||||
}
|
||||
@@ -12,9 +12,11 @@ internal val INGREDIENT_TWO = RecipeIngredientEntity(
|
||||
note = "Recipe ingredient note",
|
||||
food = "Recipe ingredient food",
|
||||
unit = "Recipe ingredient unit",
|
||||
display = "Recipe ingredient display that is very long and should be wrapped",
|
||||
quantity = 1.0,
|
||||
display = "Recipe ingredient display that is very long and should be wrapped",
|
||||
title = null,
|
||||
isFood = false,
|
||||
disableAmount = true,
|
||||
)
|
||||
|
||||
internal val SUMMARY_ENTITY = RecipeSummaryEntity(
|
||||
@@ -34,9 +36,11 @@ internal val INGREDIENT_ONE = RecipeIngredientEntity(
|
||||
note = "Recipe ingredient note",
|
||||
food = "Recipe ingredient food",
|
||||
unit = "Recipe ingredient unit",
|
||||
display = "Recipe ingredient display that is very long and should be wrapped",
|
||||
quantity = 1.0,
|
||||
display = "Recipe ingredient display that is very long and should be wrapped",
|
||||
title = "Recipe ingredient section title",
|
||||
isFood = false,
|
||||
disableAmount = true,
|
||||
)
|
||||
|
||||
internal val INSTRUCTION_ONE = RecipeInstructionEntity(
|
||||
|
||||
Reference in New Issue
Block a user