diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c5f255e83..f6caa9c46 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -25,8 +25,8 @@ android { minSdk = Versions.MinSdk targetSdk = Versions.TargetSdk multiDexEnabled = true - versionCode = 250 - versionName = "24.10.01" + versionCode = 252 + versionName = "24.10.02" ndk { moduleName = "suplaclient" diff --git a/app/src/main/java/org/supla/android/data/formatting/DateFormatter.kt b/app/src/main/java/org/supla/android/data/formatting/DateFormatter.kt index c6e0fd8b6..058b3c294 100644 --- a/app/src/main/java/org/supla/android/data/formatting/DateFormatter.kt +++ b/app/src/main/java/org/supla/android/data/formatting/DateFormatter.kt @@ -22,69 +22,48 @@ import androidx.compose.runtime.compositionLocalOf import java.text.SimpleDateFormat import java.util.Date +@SuppressLint("SimpleDateFormat") class DateFormatter { - @SuppressLint("SimpleDateFormat") + private val hourFormatter = SimpleDateFormat("HH:mm") + private val monthFormatter = SimpleDateFormat("dd MMM") + private val dateFormatter = SimpleDateFormat("dd.MM.yyyy") + private val shortDateFormatter = SimpleDateFormat("dd.MM.yy") + private val fullDateFormatter = SimpleDateFormat("dd.MM.yyyy HH:mm") + private val dayHourFormatter = SimpleDateFormat("EEEE HH:mm") + private val dayAndHourFormatter = SimpleDateFormat("dd MMM HH:mm") + private val dayAndHourShortFormatter = SimpleDateFormat("dd.MM HH:mm") + private val monthAndYearFormatter = SimpleDateFormat("LLLL yyyy") + private val yearFormatter = SimpleDateFormat("yyyy") + fun getHourString(date: Date?): String? = - date?.let { - val formatter = SimpleDateFormat("HH:mm") - formatter.format(it) - } + date?.let { hourFormatter.format(it) } - @SuppressLint("SimpleDateFormat") fun getMonthString(date: Date?): String? = - date?.let { - val formatter = SimpleDateFormat("dd MMM") - formatter.format(it) - } + date?.let { monthFormatter.format(it) } - @SuppressLint("SimpleDateFormat") fun getDateString(date: Date?): String? = - date?.let { - val formatter = SimpleDateFormat("dd.MM.yyyy") - formatter.format(it) - } + date?.let { dateFormatter.format(it) } - @SuppressLint("SimpleDateFormat") fun getShortDateString(date: Date?): String? = - date?.let { - val formatter = SimpleDateFormat("dd.MM.yy") - formatter.format(it) - } + date?.let { shortDateFormatter.format(it) } - @SuppressLint("SimpleDateFormat") fun getFullDateString(date: Date?): String? = - date?.let { - val formatter = SimpleDateFormat("dd.MM.yyyy HH:mm") - formatter.format(it) - } + date?.let { fullDateFormatter.format(it) } - @SuppressLint("SimpleDateFormat") fun getDayHourDateString(date: Date?): String? = - date?.let { - val formatter = SimpleDateFormat("EEEE HH:mm") - formatter.format(it) - } + date?.let { dayHourFormatter.format(it) } - @SuppressLint("SimpleDateFormat") fun getDayAndHourDateString(date: Date?): String? = - date?.let { - val formatter = SimpleDateFormat("dd MMM HH:mm") - formatter.format(it) - } + date?.let { dayAndHourFormatter.format(it) } + + fun getDayAndHourShortDateString(date: Date?): String? = + date?.let { dayAndHourShortFormatter.format(it) } - @SuppressLint("SimpleDateFormat") fun getMonthAndYearString(date: Date?): String? = - date?.let { - val formatter = SimpleDateFormat("LLLL yyyy") - formatter.format(it) - } + date?.let { monthAndYearFormatter.format(it) } - @SuppressLint("SimpleDateFormat") fun getYearString(date: Date?): String? = - date?.let { - val formatter = SimpleDateFormat("yyyy") - formatter.format(it) - } + date?.let { yearFormatter.format(it) } } val LocalDateFormatter = compositionLocalOf { DateFormatter() } diff --git a/app/src/main/java/org/supla/android/data/source/local/entity/measurements/ElectricityMeterLogEntity.kt b/app/src/main/java/org/supla/android/data/source/local/entity/measurements/ElectricityMeterLogEntity.kt index d54195659..e9d05e9a1 100644 --- a/app/src/main/java/org/supla/android/data/source/local/entity/measurements/ElectricityMeterLogEntity.kt +++ b/app/src/main/java/org/supla/android/data/source/local/entity/measurements/ElectricityMeterLogEntity.kt @@ -261,4 +261,4 @@ private interface SetWithResetDetection { } } -fun Long.toKWh(): Float = this.div(100000.00f) +fun Long.toKWh(): Float = this.div(100_000.00f) diff --git a/app/src/main/java/org/supla/android/data/source/remote/SuplaDeviceConfig.kt b/app/src/main/java/org/supla/android/data/source/remote/SuplaDeviceConfig.kt index cc7f40e08..acb01268d 100644 --- a/app/src/main/java/org/supla/android/data/source/remote/SuplaDeviceConfig.kt +++ b/app/src/main/java/org/supla/android/data/source/remote/SuplaDeviceConfig.kt @@ -86,7 +86,8 @@ enum class HomeScreenContent(val value: Int) { TIME(1 shl 3), TIME_DATE(1 shl 4), TEMPERATURE_TIME(1 shl 5), - MAIN_AND_AUX_TEMPERATURE(1 shl 6) + MAIN_AND_AUX_TEMPERATURE(1 shl 6), + MODE_OR_TEMPERATURE(1 shl 7) } data class HomeScreenContentField( diff --git a/app/src/main/java/org/supla/android/data/source/remote/channel/SuplaElectricityMeasurementType.kt b/app/src/main/java/org/supla/android/data/source/remote/channel/SuplaElectricityMeasurementType.kt index d5a43dd61..7d7478a3f 100644 --- a/app/src/main/java/org/supla/android/data/source/remote/channel/SuplaElectricityMeasurementType.kt +++ b/app/src/main/java/org/supla/android/data/source/remote/channel/SuplaElectricityMeasurementType.kt @@ -103,8 +103,6 @@ enum class SuplaElectricityMeasurementType(val rawValue: Int, val ordering: Int, FORWARD_REACTIVE_ENERGY, REVERSE_REACTIVE_ENERGY -> "kvarh" - - else -> "" } val precision: Int @@ -126,17 +124,45 @@ enum class SuplaElectricityMeasurementType(val rawValue: Int, val ordering: Int, else -> 0 } - fun merge(values: List): Float? = + val showEnergyLabel: Boolean + get() = when (this) { + FORWARD_ACTIVE_ENERGY, + REVERSE_ACTIVE_ENERGY, + FORWARD_REACTIVE_ENERGY, + REVERSE_REACTIVE_ENERGY -> true + + else -> false + } + + val shortLabel: Int + get() = when (this) { + FREQUENCY -> R.string.details_em_frequency + VOLTAGE -> R.string.details_em_voltage + CURRENT, CURRENT_OVER_65A -> R.string.details_em_current + POWER_ACTIVE, POWER_ACTIVE_KW -> R.string.details_em_power_active + POWER_REACTIVE, POWER_REACTIVE_KVAR -> R.string.details_em_power_reactive + POWER_APPARENT, POWER_APPARENT_KVA -> R.string.details_em_power_apparent + POWER_FACTOR -> R.string.details_em_power_factor + PHASE_ANGLE -> R.string.details_em_phase_angle + FORWARD_ACTIVE_ENERGY -> R.string.details_em_forward_active_energy_short + REVERSE_ACTIVE_ENERGY -> R.string.details_em_reverse_active_energy_short + FORWARD_ACTIVE_ENERGY_BALANCED -> R.string.details_em_forward_active_energy_short + REVERSE_ACTIVE_ENERGY_BALANCED -> R.string.details_em_reverse_active_energy_short + FORWARD_REACTIVE_ENERGY -> R.string.details_em_forward_reactive_energy_short + REVERSE_REACTIVE_ENERGY -> R.string.details_em_reverse_reactive_energy_short + } + + fun merge(values: List): Value? = when (this) { - FREQUENCY -> values.first() - VOLTAGE -> values.average().toFloat() + FREQUENCY -> Value.Single(values.first()) + VOLTAGE -> Value.Double(values.min(), values.max()) POWER_ACTIVE, POWER_REACTIVE, POWER_APPARENT, FORWARD_ACTIVE_ENERGY, REVERSE_ACTIVE_ENERGY, FORWARD_REACTIVE_ENERGY, - REVERSE_REACTIVE_ENERGY -> values.sum() + REVERSE_REACTIVE_ENERGY -> Value.Single(values.sum()) else -> null } @@ -163,6 +189,11 @@ enum class SuplaElectricityMeasurementType(val rawValue: Int, val ordering: Int, } } } + + sealed interface Value { + data class Single(val value: Float) : Value + data class Double(val first: Float, val second: Float) : Value + } } val Int.suplaElectricityMeterMeasuredTypes: List diff --git a/app/src/main/java/org/supla/android/features/details/detailbase/electricitymeter/ElectricityMeterGeneralStateHandler.kt b/app/src/main/java/org/supla/android/features/details/detailbase/electricitymeter/ElectricityMeterGeneralStateHandler.kt index dc7d4f55a..e1a615803 100644 --- a/app/src/main/java/org/supla/android/features/details/detailbase/electricitymeter/ElectricityMeterGeneralStateHandler.kt +++ b/app/src/main/java/org/supla/android/features/details/detailbase/electricitymeter/ElectricityMeterGeneralStateHandler.kt @@ -109,7 +109,14 @@ private fun PhaseWithMeasurements.Companion.allPhases( .filterValues { it.isNotEmpty() } .mapValues { it.key.merge(it.value) } .filterValues { it != null } - .mapValues { formatter.custom(it.value!!, it.key.precision) } + .mapValues { + when (val value = it.value!!) { + is SuplaElectricityMeasurementType.Value.Single -> + formatter.custom(value.value, it.key.precision) + is SuplaElectricityMeasurementType.Value.Double -> + "${formatter.custom(value.first, 0)}- ${formatter.custom(value.second, 0)}" + } + } return PhaseWithMeasurements(R.string.em_chart_all_phases, values) } diff --git a/app/src/main/java/org/supla/android/features/details/detailbase/electricitymeter/ElectricityMeterMetricsView.kt b/app/src/main/java/org/supla/android/features/details/detailbase/electricitymeter/ElectricityMeterMetricsView.kt index e4bb356b9..57ece3bab 100644 --- a/app/src/main/java/org/supla/android/features/details/detailbase/electricitymeter/ElectricityMeterMetricsView.kt +++ b/app/src/main/java/org/supla/android/features/details/detailbase/electricitymeter/ElectricityMeterMetricsView.kt @@ -157,7 +157,11 @@ private fun PhasesData(measurementTypes: List, } @Composable -private fun PhaseDataLabels(measurementTypes: List, withHeader: Boolean = true) = +private fun PhaseDataLabels( + measurementTypes: List, + withHeader: Boolean = true, + withLabel: Boolean = true +) = Column( modifier = Modifier .width(IntrinsicSize.Max) @@ -167,8 +171,13 @@ private fun PhaseDataLabels(measurementTypes: List, - showPhaseName: Boolean + showPhaseName: Boolean, + withLabel: Boolean = true ) = Column( modifier = Modifier @@ -192,7 +202,12 @@ private fun PhaseDataSinglePhase( modifier = Modifier.width(IntrinsicSize.Max), horizontalAlignment = Alignment.CenterHorizontally ) { + var energyShown = false types.forEach { + if (!energyShown && it.showEnergyLabel && withLabel) { + EnergyLabel() + energyShown = true + } PhaseValue(phase.values[it] ?: ValuesFormatter.NO_VALUE_TEXT) } } @@ -200,7 +215,12 @@ private fun PhaseDataSinglePhase( modifier = Modifier.width(IntrinsicSize.Max), horizontalAlignment = Alignment.CenterHorizontally ) { + var energyShown = false types.forEach { + if (!energyShown && it.showEnergyLabel && withLabel) { + EnergyLabel() + energyShown = true + } PhaseValueUnit(if (phase.values.contains(it) && phase.values[it] != null) it.unit else "") } } @@ -241,6 +261,19 @@ private fun PhaseHeader(text: String = "", alignment: TextAlign = TextAlign.Star .wrapContentHeight(align = Alignment.CenterVertically) ) +@Composable +private fun EnergyLabel(text: String = "") = + Text( + text = text, + style = MaterialTheme.typography.labelMedium, + color = MaterialTheme.colorScheme.onBackground, + modifier = Modifier + .fillMaxWidth() + .background(MaterialTheme.colorScheme.surface) + .padding(top = Distance.small, bottom = Distance.tiny) + .wrapContentHeight(align = Alignment.CenterVertically) + ) + @Composable private fun TypeLabel(text: String = "") = Text( @@ -252,7 +285,6 @@ private fun TypeLabel(text: String = "") = .height(35.dp) .fillMaxWidth() .background(MaterialTheme.colorScheme.surface) - .padding(end = Distance.small) .wrapContentHeight(align = Alignment.CenterVertically) ) @@ -361,7 +393,8 @@ private fun Preview() { phaseMeasurementTypes = listOf( SuplaElectricityMeasurementType.FREQUENCY, SuplaElectricityMeasurementType.CURRENT, - SuplaElectricityMeasurementType.VOLTAGE + SuplaElectricityMeasurementType.VOLTAGE, + SuplaElectricityMeasurementType.FORWARD_ACTIVE_ENERGY ), phaseMeasurementValues = listOf( PhaseWithMeasurements( @@ -369,7 +402,8 @@ private fun Preview() { mapOf( SuplaElectricityMeasurementType.FREQUENCY to "50", SuplaElectricityMeasurementType.CURRENT to "5", - SuplaElectricityMeasurementType.VOLTAGE to "245" + SuplaElectricityMeasurementType.VOLTAGE to "245", + SuplaElectricityMeasurementType.FORWARD_ACTIVE_ENERGY to "245" ) ), PhaseWithMeasurements( @@ -377,7 +411,8 @@ private fun Preview() { mapOf( SuplaElectricityMeasurementType.FREQUENCY to "50", SuplaElectricityMeasurementType.CURRENT to "3", - SuplaElectricityMeasurementType.VOLTAGE to "243" + SuplaElectricityMeasurementType.VOLTAGE to "243", + SuplaElectricityMeasurementType.FORWARD_ACTIVE_ENERGY to "245" ) ), PhaseWithMeasurements( @@ -385,7 +420,8 @@ private fun Preview() { mapOf( SuplaElectricityMeasurementType.FREQUENCY to "50", SuplaElectricityMeasurementType.CURRENT to "4", - SuplaElectricityMeasurementType.VOLTAGE to "248" + SuplaElectricityMeasurementType.VOLTAGE to "248", + SuplaElectricityMeasurementType.FORWARD_ACTIVE_ENERGY to "245" ) ) ), diff --git a/app/src/main/java/org/supla/android/features/details/detailbase/electricitymeter/EnergyData.kt b/app/src/main/java/org/supla/android/features/details/detailbase/electricitymeter/EnergyData.kt index 385767d56..f0d46725e 100644 --- a/app/src/main/java/org/supla/android/features/details/detailbase/electricitymeter/EnergyData.kt +++ b/app/src/main/java/org/supla/android/features/details/detailbase/electricitymeter/EnergyData.kt @@ -19,7 +19,7 @@ package org.supla.android.features.details.detailbase.electricitymeter import org.supla.android.extensions.ifNotZero import org.supla.android.usecases.channel.valueformatter.ChannelValueFormatter -import java.util.Locale +import java.text.DecimalFormat data class EnergyData( val energy: String, @@ -29,7 +29,13 @@ data class EnergyData( operator fun invoke(formatter: ChannelValueFormatter, energy: Double, pricePerUnit: Double, currency: String): EnergyData = EnergyData( energy = formatter.format(energy), - price = pricePerUnit.ifNotZero { String.format(Locale.getDefault(), "%.2f %s", it.times(energy), currency) } + price = pricePerUnit.ifNotZero { + val decimalFormatter = DecimalFormat() + decimalFormatter.minimumFractionDigits = 2 + decimalFormatter.maximumFractionDigits = 2 + + "${decimalFormatter.format(it.times(energy))} $currency" + } ) } } diff --git a/app/src/main/java/org/supla/android/features/details/detailbase/history/BaseHistoryDetailViewModel.kt b/app/src/main/java/org/supla/android/features/details/detailbase/history/BaseHistoryDetailViewModel.kt index f6701887f..cb0935c98 100644 --- a/app/src/main/java/org/supla/android/features/details/detailbase/history/BaseHistoryDetailViewModel.kt +++ b/app/src/main/java/org/supla/android/features/details/detailbase/history/BaseHistoryDetailViewModel.kt @@ -635,18 +635,6 @@ data class HistoryDetailViewState( } } - val showBottomBar: Boolean - get() = when (filters.selectedRange) { - ChartRange.DAY, - ChartRange.WEEK, - ChartRange.MONTH, - ChartRange.QUARTER, - ChartRange.YEAR, - ChartRange.ALL_HISTORY -> true - - else -> false - } - val allowNavigation: Boolean get() = when (filters.selectedRange) { ChartRange.DAY, diff --git a/app/src/main/java/org/supla/android/ui/views/charts/CombinedChart.kt b/app/src/main/java/org/supla/android/ui/views/charts/CombinedChart.kt index b6901625d..0ea5c0ebc 100644 --- a/app/src/main/java/org/supla/android/ui/views/charts/CombinedChart.kt +++ b/app/src/main/java/org/supla/android/ui/views/charts/CombinedChart.kt @@ -33,9 +33,11 @@ import com.github.mikephil.charting.charts.CombinedChart import com.github.mikephil.charting.components.AxisBase import com.github.mikephil.charting.components.XAxis import com.github.mikephil.charting.components.YAxis +import com.github.mikephil.charting.components.YAxis.AxisDependency import com.github.mikephil.charting.formatter.ValueFormatter import com.github.mikephil.charting.listener.ChartTouchListener import com.github.mikephil.charting.listener.OnChartGestureListener +import com.github.mikephil.charting.utils.ViewPortHandler import org.supla.android.R import org.supla.android.data.formatting.DateFormatter import org.supla.android.data.formatting.LocalDateFormatter @@ -92,8 +94,10 @@ fun CombinedChart( it.xAxis.setDrawGridLines(false) it.xAxis.setDrawAxisLine(false) it.xAxis.position = XAxis.XAxisPosition.BOTTOM + xAxisFormatter.chart = it + xAxisFormatter.handler = it.viewPortHandler it.xAxis.valueFormatter = xAxisFormatter - it.xAxis.labelCount = 6 + it.xAxis.labelCount = 5 it.xAxis.textColor = onBackgroundColor // Others it.data = combinedData @@ -201,11 +205,20 @@ private class CombinedChartAxisXFormatter( ) : ValueFormatter() { lateinit var converter: ChartData + lateinit var chart: CombinedChart + lateinit var handler: ViewPortHandler override fun getAxisLabel(value: Float, axis: AxisBase?): String { + val left = chart.getValuesByTouchPoint(handler.contentLeft(), handler.contentTop(), AxisDependency.LEFT) + val right = chart.getValuesByTouchPoint(handler.contentRight(), handler.contentTop(), AxisDependency.LEFT) + + val distanceInDaysFromChart = (converter.fromCoordinate(right.x.toFloat()) - converter.fromCoordinate(left.x.toFloat())) / 3600 / 24 val distanceInDays = converter.distanceInDays ?: 1 return when { - distanceInDays <= 1 -> + distanceInDays > 1 && distanceInDaysFromChart <= 2 -> + dateFormatter.getDayAndHourShortDateString(Date(converter.fromCoordinate(value).times(1000).toLong())) ?: "" + + distanceInDaysFromChart <= 1 -> dateFormatter.getHourString(Date(converter.fromCoordinate(value).times(1000).toLong())) ?: "" else -> { diff --git a/app/src/main/java/org/supla/android/usecases/channel/measurementsprovider/ElectricityConsumptionMeasurementsProvider.kt b/app/src/main/java/org/supla/android/usecases/channel/measurementsprovider/ElectricityConsumptionMeasurementsProvider.kt index 91496d610..2f3c25ef7 100644 --- a/app/src/main/java/org/supla/android/usecases/channel/measurementsprovider/ElectricityConsumptionMeasurementsProvider.kt +++ b/app/src/main/java/org/supla/android/usecases/channel/measurementsprovider/ElectricityConsumptionMeasurementsProvider.kt @@ -262,7 +262,7 @@ class ElectricityConsumptionMeasurementsProvider @Inject constructor( spec: ChartDataSpec, formatter: ChartDataAggregation.Formatter ): List = - balanceHourly(measurements, formatter) + measurements.balanceHourly(formatter) .groupBy { item -> spec.aggregation.aggregator(item.date, formatter) } .filter { group -> group.value.isNotEmpty() } .map { group -> @@ -273,24 +273,6 @@ class ElectricityConsumptionMeasurementsProvider @Inject constructor( } .toList() - private fun balanceHourly(measurements: List, formatter: ChartDataAggregation.Formatter) = - measurements - .groupBy { item -> ChartDataAggregation.HOURS.aggregator(item.date, formatter) } - .asSequence() - .filter { group -> group.value.isNotEmpty() } - .map { group -> - val consumption = - group.value.map { it.phase1Fae ?: 0f }.sum() + - group.value.map { it.phase2Fae ?: 0f }.sum() + - group.value.map { it.phase3Fae ?: 0f }.sum() - val production = - group.value.map { it.phase1Rae ?: 0f }.sum() + - group.value.map { it.phase2Rae ?: 0f }.sum() + - group.value.map { it.phase3Rae ?: 0f }.sum() - val result = consumption - production - BalancedValue(group.value.firstOrNull()!!.date, if (result > 0) result else 0f, if (result < 0) -result else 0f) - } - private fun aggregatedPhases( spec: ChartDataSpec, group: Map.Entry> diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index d9c14c8ca..5e136867c 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -631,6 +631,11 @@ Batteriefachdeckel offen %1$d Uhr Datentyp + Wirk- aufgenommen + Wirk- zurückgegeben + Blind- aufgenommen + Blind- zurückgegeben + Energie eingeschaltet eingeschaltet diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index dba93884d..207beda06 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -706,6 +706,11 @@ Otwarta pokrywa baterii Godzina %1$d Typ danych + Czynna pobrana + Czynna zwrócona + Indukcyjna + Pojemnościowa + Energia włączone diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c799aa618..fe2550f91 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -728,6 +728,11 @@ Battery cover open %1$d o\'clock Data type + Forward active + Reverse active + Forward reactive + Reverse reactive + Energy on diff --git a/app/src/main/res/xml/backup_descriptor.xml b/app/src/main/res/xml/backup_descriptor.xml index 14b6565d8..1fea58d88 100644 --- a/app/src/main/res/xml/backup_descriptor.xml +++ b/app/src/main/res/xml/backup_descriptor.xml @@ -1,10 +1,13 @@ - - - + + + + diff --git a/app/src/test/java/org/supla/android/features/details/detailbase/electricitymeter/ElectricityMeterGeneralStateHandlerTest.kt b/app/src/test/java/org/supla/android/features/details/detailbase/electricitymeter/ElectricityMeterGeneralStateHandlerTest.kt index 32231a0d5..d8ceff6a2 100644 --- a/app/src/test/java/org/supla/android/features/details/detailbase/electricitymeter/ElectricityMeterGeneralStateHandlerTest.kt +++ b/app/src/test/java/org/supla/android/features/details/detailbase/electricitymeter/ElectricityMeterGeneralStateHandlerTest.kt @@ -72,7 +72,7 @@ class ElectricityMeterGeneralStateHandlerTest { every { summary } returns mockk { every { totalForwardActiveEnergy } returns 100.0 } - every { pricePerUnit } returns 10.0 + every { pricePerUnit } returns 2.0 every { currency } returns "PLN" every { getMeasurement(1, 0) } returns mockMeasurement(1) every { getMeasurement(2, 0) } returns mockMeasurement(2) @@ -97,7 +97,7 @@ class ElectricityMeterGeneralStateHandlerTest { assertThat(result).isEqualTo( state.copy( online = true, - totalForwardActiveEnergy = EnergyData("100.0 kWh", "1000.00 PLN"), + totalForwardActiveEnergy = EnergyData("100.0 kWh", "200.00 PLN"), phaseMeasurementTypes = listOf( SuplaElectricityMeasurementType.FREQUENCY, SuplaElectricityMeasurementType.VOLTAGE, @@ -105,7 +105,7 @@ class ElectricityMeterGeneralStateHandlerTest { SuplaElectricityMeasurementType.FORWARD_ACTIVE_ENERGY ), phaseMeasurementValues = listOf( - phaseWithMeasurements(R.string.em_chart_all_phases, "10.00 ", "21.00 ", forwardActiveEnergy = "600.00000 "), + phaseWithMeasurements(R.string.em_chart_all_phases, "10.00 ", "11 - 31 ", forwardActiveEnergy = "600.00000 "), phaseWithMeasurements(R.string.details_em_phase1, "10.00 ", "11.00 ", "12.00 ", "100.00000 "), phaseWithMeasurements(R.string.details_em_phase2, "20.00 ", "21.00 ", "22.00 ", "200.00000 "), phaseWithMeasurements(R.string.details_em_phase3, "30.00 ", "31.00 ", "32.00 ", "300.00000 ") diff --git a/app/src/test/java/org/supla/android/features/details/detailbase/electricitymeter/EnergyDataTest.kt b/app/src/test/java/org/supla/android/features/details/detailbase/electricitymeter/EnergyDataTest.kt index 3a44d26d4..ea5955f27 100644 --- a/app/src/test/java/org/supla/android/features/details/detailbase/electricitymeter/EnergyDataTest.kt +++ b/app/src/test/java/org/supla/android/features/details/detailbase/electricitymeter/EnergyDataTest.kt @@ -43,7 +43,7 @@ class EnergyDataTest { // then Assertions.assertThat(result) .extracting({ it.energy }, { it.price }) - .containsExactly(energyString, "1234.50 PLN") + .containsExactly(energyString, "1,234.50 PLN") } @Test