This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 497
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ramp Down Notice (EXPOSUREAPP-14422) (#5802)
* Ramp Down Notice * Update comment * Rename * Tests * Update RampDownDataProviderTest.kt * Rampdown notice UI (EXPOSUREAPP-14571) (#5803) * add RampDownNoticeCard * add RampdownNoticeFragment * finish rampdown notice * remove StatusTabNotice * change naming * change naming * update navigation add night icon * add screenshot test * Tweaking * Keep instance for subsequent cals Co-authored-by: Mohamed <[email protected]> * remove screenshot test * Test Co-authored-by: Nikolaus Schauersberger <[email protected]>
- Loading branch information
1 parent
02a414d
commit 167ce2b
Showing
25 changed files
with
857 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...rn-App/src/main/java/de/rki/coronawarnapp/ccl/rampdown/calculation/RampDownCalculation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package de.rki.coronawarnapp.ccl.rampdown.calculation | ||
|
||
import androidx.annotation.VisibleForTesting | ||
import com.fasterxml.jackson.databind.JsonNode | ||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import de.rki.coronawarnapp.ccl.configuration.model.CclInputParameters | ||
import de.rki.coronawarnapp.ccl.configuration.model.getDefaultInputParameters | ||
import de.rki.coronawarnapp.ccl.dccwalletinfo.calculation.CclJsonFunctions | ||
import de.rki.coronawarnapp.ccl.dccwalletinfo.model.SystemTime | ||
import de.rki.coronawarnapp.ccl.rampdown.model.RampDownInput | ||
import de.rki.coronawarnapp.ccl.rampdown.model.RampDownOutput | ||
import de.rki.coronawarnapp.util.coroutine.DispatcherProvider | ||
import de.rki.coronawarnapp.util.serialization.BaseJackson | ||
import kotlinx.coroutines.withContext | ||
import java.time.ZonedDateTime | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class RampDownCalculation @Inject constructor( | ||
@BaseJackson private val mapper: ObjectMapper, | ||
private val cclJsonFunctions: CclJsonFunctions, | ||
private val dispatcherProvider: DispatcherProvider | ||
) { | ||
|
||
suspend fun getStatusTabNotice( | ||
dateTime: ZonedDateTime = ZonedDateTime.now(), | ||
): RampDownOutput = withContext(dispatcherProvider.IO) { | ||
val output = cclJsonFunctions.evaluateFunction( | ||
"getStatusTabNotice", | ||
getDefaultInputParameters(dateTime).toInput(mapper) | ||
) | ||
mapper.treeToValue(output, RampDownOutput::class.java) | ||
} | ||
} | ||
|
||
@VisibleForTesting | ||
internal fun CclInputParameters.toInput(mapper: ObjectMapper) = mapper.valueToTree<JsonNode>( | ||
RampDownInput( | ||
os = os, | ||
language = language, | ||
now = SystemTime( | ||
timestamp = now.timestamp, | ||
localDate = now.localDate, | ||
localDateTime = now.localDateTime, | ||
localDateTimeMidnight = now.localDateTimeMidnight, | ||
utcDate = now.utcDate, | ||
utcDateTime = now.utcDateTime, | ||
utcDateTimeMidnight = now.utcDateTimeMidnight, | ||
) | ||
) | ||
) |
15 changes: 15 additions & 0 deletions
15
Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ccl/rampdown/model/RampDownInput.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package de.rki.coronawarnapp.ccl.rampdown.model | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty | ||
import de.rki.coronawarnapp.ccl.dccwalletinfo.model.SystemTime | ||
|
||
data class RampDownInput( | ||
@JsonProperty("os") | ||
val os: String, | ||
|
||
@JsonProperty("language") | ||
val language: String, | ||
|
||
@JsonProperty("now") | ||
val now: SystemTime, | ||
) |
21 changes: 21 additions & 0 deletions
21
Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ccl/rampdown/model/RampDownOutput.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package de.rki.coronawarnapp.ccl.rampdown.model | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty | ||
import de.rki.coronawarnapp.ccl.dccwalletinfo.model.CclText | ||
|
||
data class RampDownOutput( | ||
@JsonProperty("visible") | ||
val visible: Boolean, | ||
|
||
@JsonProperty("titleText") | ||
val titleText: CclText?, | ||
|
||
@JsonProperty("subtitleText") | ||
val subtitleText: CclText?, | ||
|
||
@JsonProperty("longText") | ||
val longText: CclText?, | ||
|
||
@JsonProperty("faqAnchor") | ||
val faqAnchor: String?, | ||
) |
39 changes: 39 additions & 0 deletions
39
Corona-Warn-App/src/main/java/de/rki/coronawarnapp/rampdown/ui/RampDownNoticeCard.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package de.rki.coronawarnapp.rampdown.ui | ||
|
||
import android.view.ViewGroup | ||
import de.rki.coronawarnapp.R | ||
import de.rki.coronawarnapp.databinding.HomeRampDownNoticeCardBinding | ||
import de.rki.coronawarnapp.ui.main.home.HomeAdapter | ||
import de.rki.coronawarnapp.ui.main.home.items.HomeItem | ||
import de.rki.coronawarnapp.ui.main.home.rampdown.RampDownNotice | ||
import de.rki.coronawarnapp.util.lists.diffutil.HasPayloadDiffer | ||
|
||
class RampDownNoticeCard( | ||
parent: ViewGroup | ||
) : HomeAdapter.HomeItemVH<RampDownNoticeCard.Item, HomeRampDownNoticeCardBinding>( | ||
R.layout.home_card_container_layout, | ||
parent | ||
) { | ||
|
||
override val viewBinding = lazy { | ||
HomeRampDownNoticeCardBinding | ||
.inflate(layoutInflater, itemView.findViewById(R.id.card_container), true) | ||
} | ||
|
||
override val onBindData: HomeRampDownNoticeCardBinding.( | ||
item: Item, | ||
payloads: List<Any> | ||
) -> Unit = { item, payloads -> | ||
val curItem = payloads.filterIsInstance<Item>().lastOrNull() ?: item | ||
itemView.setOnClickListener { curItem.onClickAction(item) } | ||
rampdownCardHeaderHeadline.text = curItem.rampDownNotice.title | ||
rampdownCardContentBody.text = curItem.rampDownNotice.subtitle | ||
} | ||
|
||
data class Item( | ||
val onClickAction: (Item) -> Unit, | ||
val rampDownNotice: RampDownNotice | ||
) : HomeItem, HasPayloadDiffer { | ||
override val stableId = Item::class.hashCode().toLong() | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
Corona-Warn-App/src/main/java/de/rki/coronawarnapp/rampdown/ui/RampDownNoticeFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package de.rki.coronawarnapp.rampdown.ui | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.core.view.isVisible | ||
import androidx.fragment.app.Fragment | ||
import androidx.navigation.fragment.navArgs | ||
import de.rki.coronawarnapp.R | ||
import de.rki.coronawarnapp.databinding.FragmentRampdownNoticeBinding | ||
import de.rki.coronawarnapp.util.convertToHyperlink | ||
import de.rki.coronawarnapp.util.ui.popBackStack | ||
import de.rki.coronawarnapp.util.ui.viewBinding | ||
|
||
class RampDownNoticeFragment : Fragment(R.layout.fragment_rampdown_notice) { | ||
|
||
private val binding: FragmentRampdownNoticeBinding by viewBinding() | ||
private val navArgs by navArgs<RampDownNoticeFragmentArgs>() | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
val data = navArgs.rampDownNotice | ||
|
||
binding.apply { | ||
toolbar.title = data.title | ||
toolbar.setNavigationOnClickListener { popBackStack() } | ||
rampDownNoticeSubtitle.text = data.subtitle | ||
rampDownNoticeLongtext.text = data.description | ||
data.faqUrl?.let { | ||
rampDownNoticeFaqAnchor.convertToHyperlink(it) | ||
rampDownNoticeFaqAnchor.isVisible = true | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.