From fc33953b1a0c0609b40ce1c370ecc6008e5e0d60 Mon Sep 17 00:00:00 2001 From: Fernando Garcia Date: Tue, 7 Jan 2025 14:12:28 +0100 Subject: [PATCH] ANDROID-14792 Fix. Lint errors --- .../ui/classic/components/SteppersCatalogFragment.kt | 4 +++- .../mistica/catalog/ui/compose/components/Tabs.kt | 4 ++-- .../mistica/compose/carousel/CarouselPagerIndicator.kt | 3 ++- .../com/telefonica/mistica/compose/input/TextAreaInput.kt | 4 ++-- .../main/java/com/telefonica/mistica/compose/tabs/Tabs.kt | 6 +++++- .../compose/theme/values/MisticaRadiusAutogenerated.kt | 4 ++-- .../java/com/telefonica/mistica/feedback/SnackbarBuilder.kt | 4 +++- .../main/java/com/telefonica/mistica/stepper/StepView.kt | 2 ++ 8 files changed, 21 insertions(+), 10 deletions(-) diff --git a/catalog/src/main/java/com/telefonica/mistica/catalog/ui/classic/components/SteppersCatalogFragment.kt b/catalog/src/main/java/com/telefonica/mistica/catalog/ui/classic/components/SteppersCatalogFragment.kt index 8453ce225..983623606 100644 --- a/catalog/src/main/java/com/telefonica/mistica/catalog/ui/classic/components/SteppersCatalogFragment.kt +++ b/catalog/src/main/java/com/telefonica/mistica/catalog/ui/classic/components/SteppersCatalogFragment.kt @@ -1,5 +1,6 @@ package com.telefonica.mistica.catalog.ui.classic.components +import android.annotation.SuppressLint import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -21,6 +22,7 @@ class SteppersCatalogFragment : Fragment() { return layoutInflater.inflate(R.layout.screen_steppers_catalog, container, false) } + @SuppressLint("SetTextI18n") override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -42,7 +44,7 @@ class SteppersCatalogFragment : Fragment() { numberOfSteps.map { it.toString() } ) ) - setText(2.toString()) + setText(maxSteps.toString()) setOnItemClickListener { _, _, position, _ -> maxSteps = numberOfSteps[position] currentStep = 1 diff --git a/catalog/src/main/java/com/telefonica/mistica/catalog/ui/compose/components/Tabs.kt b/catalog/src/main/java/com/telefonica/mistica/catalog/ui/compose/components/Tabs.kt index 57afca1d8..defdd7d76 100644 --- a/catalog/src/main/java/com/telefonica/mistica/catalog/ui/compose/components/Tabs.kt +++ b/catalog/src/main/java/com/telefonica/mistica/catalog/ui/compose/components/Tabs.kt @@ -115,8 +115,8 @@ fun TabsCatalog() { text = "Remove last tab", onClickListener = { if (tabs.size > 1) { - tabs = tabs.toMutableList().also { - it.removeLast() + tabs = tabs.toMutableList().apply { + removeAt(lastIndex) } if (currentIndex >= tabs.size) { currentIndex = tabs.size - 1 diff --git a/library/src/main/java/com/telefonica/mistica/compose/carousel/CarouselPagerIndicator.kt b/library/src/main/java/com/telefonica/mistica/compose/carousel/CarouselPagerIndicator.kt index a58a4b737..e03c86bcc 100644 --- a/library/src/main/java/com/telefonica/mistica/compose/carousel/CarouselPagerIndicator.kt +++ b/library/src/main/java/com/telefonica/mistica/compose/carousel/CarouselPagerIndicator.kt @@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.CircleShape import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue @@ -78,7 +79,7 @@ fun CarouselPagerIndicator( } }) } - var currentlySelected by remember { mutableStateOf(0) } + var currentlySelected by remember { mutableIntStateOf(0) } var shouldAnimate by remember { mutableStateOf(true) } val indicatorUnselectedModifier = remember { diff --git a/library/src/main/java/com/telefonica/mistica/compose/input/TextAreaInput.kt b/library/src/main/java/com/telefonica/mistica/compose/input/TextAreaInput.kt index dfde10d75..6313fe365 100644 --- a/library/src/main/java/com/telefonica/mistica/compose/input/TextAreaInput.kt +++ b/library/src/main/java/com/telefonica/mistica/compose/input/TextAreaInput.kt @@ -2,7 +2,7 @@ package com.telefonica.mistica.compose.input import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier @@ -30,7 +30,7 @@ fun TextAreaInput( keyboardOptions: KeyboardOptions = KeyboardOptions.Default, ) { var currentChars by remember { - mutableStateOf(0) + mutableIntStateOf(0) } TextInputImpl( diff --git a/library/src/main/java/com/telefonica/mistica/compose/tabs/Tabs.kt b/library/src/main/java/com/telefonica/mistica/compose/tabs/Tabs.kt index 4c7ff7732..8fc53f6d5 100644 --- a/library/src/main/java/com/telefonica/mistica/compose/tabs/Tabs.kt +++ b/library/src/main/java/com/telefonica/mistica/compose/tabs/Tabs.kt @@ -45,6 +45,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Constraints import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.dp import com.telefonica.mistica.compose.theme.MisticaTheme import com.telefonica.mistica.compose.theme.brand.MovistarBrand @@ -331,9 +332,12 @@ private fun Modifier.misticaTabIndicatorOffset( targetValue = currentTabPosition.left, animationSpec = tween(durationMillis = 300, easing = FastOutSlowInEasing) ) + fillMaxWidth() .wrapContentSize(Alignment.BottomStart) - .offset(x = indicatorOffset) + .offset { + IntOffset(x = indicatorOffset.roundToPx(), y = 0) + } .width(currentTabWidth) } diff --git a/library/src/main/java/com/telefonica/mistica/compose/theme/values/MisticaRadiusAutogenerated.kt b/library/src/main/java/com/telefonica/mistica/compose/theme/values/MisticaRadiusAutogenerated.kt index 5b0ecf623..73e544f62 100644 --- a/library/src/main/java/com/telefonica/mistica/compose/theme/values/MisticaRadiusAutogenerated.kt +++ b/library/src/main/java/com/telefonica/mistica/compose/theme/values/MisticaRadiusAutogenerated.kt @@ -3,6 +3,7 @@ package com.telefonica.mistica.compose.theme.values import androidx.compose.runtime.ProvidableCompositionLocal import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import androidx.compose.runtime.staticCompositionLocalOf @@ -23,8 +24,7 @@ public class MisticaRadius( sheetBorderRadius: Dp = Dp.Unspecified, mediaSmallBorderRadius: Dp = Dp.Unspecified, ) { - public var avatarBorderRadius: Int by mutableStateOf(avatarBorderRadius, - structuralEqualityPolicy()) + public var avatarBorderRadius: Int by mutableIntStateOf(avatarBorderRadius) internal set public var barBorderRadius: Dp by mutableStateOf(barBorderRadius, structuralEqualityPolicy()) diff --git a/library/src/main/java/com/telefonica/mistica/feedback/SnackbarBuilder.kt b/library/src/main/java/com/telefonica/mistica/feedback/SnackbarBuilder.kt index 19f651f02..13aff26d4 100644 --- a/library/src/main/java/com/telefonica/mistica/feedback/SnackbarBuilder.kt +++ b/library/src/main/java/com/telefonica/mistica/feedback/SnackbarBuilder.kt @@ -9,6 +9,7 @@ import android.text.style.ForegroundColorSpan import android.view.LayoutInflater import android.view.View import android.view.accessibility.AccessibilityManager +import android.widget.FrameLayout import androidx.annotation.AttrRes import androidx.annotation.StringRes import com.google.android.material.snackbar.BaseTransientBottomBar.BaseCallback @@ -141,7 +142,8 @@ open class SnackbarBuilder(view: View?, text: String) { // Since we are inflating a custom layout, we pass a dummy text and apply // the expected one later on to our custom TextView val snackbar = Snackbar.make(view, "", duration) - val snackbarLayout = snackbar.view as Snackbar.SnackbarLayout + + val snackbarLayout = snackbar.view as FrameLayout snackbarLayout.removeAllViews() val customLayout = LayoutInflater.from(snackbarLayout.context).inflate(R.layout.snackbar_layout, snackbarLayout, false) diff --git a/library/src/main/java/com/telefonica/mistica/stepper/StepView.kt b/library/src/main/java/com/telefonica/mistica/stepper/StepView.kt index 42452b2d0..931bef31c 100644 --- a/library/src/main/java/com/telefonica/mistica/stepper/StepView.kt +++ b/library/src/main/java/com/telefonica/mistica/stepper/StepView.kt @@ -1,5 +1,6 @@ package com.telefonica.mistica.stepper +import android.annotation.SuppressLint import android.content.Context import android.graphics.PorterDuff import android.graphics.PorterDuffColorFilter @@ -84,6 +85,7 @@ internal class StepView @JvmOverloads constructor( } } + @SuppressLint("SetTextI18n") fun setStep(step: Int, isSelected: Boolean = false) { selectedStepTextView.text = step.toString() unselectedStepTextView.text = step.toString()