Commit e02b12ba authored by stopcovid@lunabee.com's avatar stopcovid@lunabee.com
Browse files

Update to 3.1.4

- New deeplink format
parent 6122b3db
......@@ -43,8 +43,8 @@ android {
applicationId "fr.gouv.android.stopcovid"
minSdkVersion 21
targetSdkVersion 30
versionCode 242
versionName "3.1.3"
versionCode 244
versionName "3.1.4"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
......
......@@ -35,8 +35,8 @@ import com.lunabeestudio.stopcovid.databinding.ActivityMainBinding
import com.lunabeestudio.stopcovid.extension.alertRiskLevelChanged
import com.lunabeestudio.stopcovid.extension.robertManager
import com.lunabeestudio.stopcovid.extension.showAlertRiskLevelChanged
import com.lunabeestudio.stopcovid.manager.DeeplinkManager
import com.lunabeestudio.stopcovid.manager.RisksLevelManager
import com.lunabeestudio.stopcovid.manager.VenuesManager
class MainActivity : BaseActivity() {
......@@ -115,9 +115,9 @@ class MainActivity : BaseActivity() {
}
private fun fixIntentData(intent: Intent) {
// since we use '#' to separate the venue base64 code, we replace it to pass a clean URL to the nav_graph deeplink handle
// since we use '#' to separate the code, we replace it to pass a clean URL to the nav_graph deeplink handle
val uri = intent.data?.let {
VenuesManager.cleanVenueUri(it.toString())
DeeplinkManager.transformAnchorParam(it)
}
val uriBuilder = uri?.buildUpon()
?.path(intent.data?.path?.takeIf { it != "/" })
......
......@@ -745,17 +745,17 @@ class ProximityFragment : TimeMainFragment() {
KeyFiguresManager.featuredFigures?.let { keyFigures ->
franceData = NumbersCardItem.Data(
strings["common.country.france"],
generateFromKeyFigure(keyFigures[0]),
generateFromKeyFigure(keyFigures[1]),
generateFromKeyFigure(keyFigures[2])
generateFromKeyFigure(keyFigures.getOrNull(0)),
generateFromKeyFigure(keyFigures.getOrNull(1)),
generateFromKeyFigure(keyFigures.getOrNull(2))
)
localData = if (sharedPrefs.hasChosenPostalCode) {
NumbersCardItem.Data(
keyFigures.getDepartmentLabel(sharedPrefs.chosenPostalCode),
generateFromKeyFigure(keyFigures[0], true),
generateFromKeyFigure(keyFigures[1], true),
generateFromKeyFigure(keyFigures[2], true)
generateFromKeyFigure(keyFigures.getOrNull(0), true),
generateFromKeyFigure(keyFigures.getOrNull(1), true),
generateFromKeyFigure(keyFigures.getOrNull(2), true)
)
} else {
null
......@@ -805,18 +805,20 @@ class ProximityFragment : TimeMainFragment() {
return items
}
private fun generateFromKeyFigure(keyFigure: KeyFigure, fromDepartment: Boolean = false): NumbersCardItem.DataFigure {
return NumbersCardItem.DataFigure(
strings[keyFigure.labelShortStringKey],
if (fromDepartment) {
keyFigure.getKeyFigureForPostalCode(sharedPrefs.chosenPostalCode)?.valueToDisplay?.formatNumberIfNeeded(numberFormat)
} else {
keyFigure.valueGlobalToDisplay.formatNumberIfNeeded(numberFormat)
},
strings[keyFigure.colorStringKey(requireContext().isNightMode())]?.let {
Color.parseColor(it)
}
)
private fun generateFromKeyFigure(keyFigure: KeyFigure?, fromDepartment: Boolean = false): NumbersCardItem.DataFigure? {
return keyFigure?.let {
NumbersCardItem.DataFigure(
strings[keyFigure.labelShortStringKey],
if (fromDepartment) {
keyFigure.getKeyFigureForPostalCode(sharedPrefs.chosenPostalCode)?.valueToDisplay?.formatNumberIfNeeded(numberFormat)
} else {
keyFigure.valueGlobalToDisplay.formatNumberIfNeeded(numberFormat)
},
strings[keyFigure.colorStringKey(requireContext().isNightMode())]?.let {
Color.parseColor(it)
}
)
}
}
private fun addAttestationItems(items: ArrayList<GenericItem>) {
......
......@@ -17,6 +17,7 @@ import com.lunabeestudio.stopcovid.coreui.extension.callPhone
import com.lunabeestudio.stopcovid.coreui.extension.findNavControllerOrNull
import com.lunabeestudio.stopcovid.coreui.fastitem.captionItem
import com.lunabeestudio.stopcovid.coreui.fastitem.spaceItem
import com.lunabeestudio.stopcovid.extension.safeNavigate
import com.lunabeestudio.stopcovid.fastitem.addCertificateCardItem
import com.lunabeestudio.stopcovid.fastitem.phoneSupportItem
import com.mikepenz.fastadapter.GenericItem
......@@ -37,7 +38,7 @@ class WalletAddCertificateFragment : MainFragment() {
fallbackRes = R.drawable.test_certificate
mainAction = {
findNavControllerOrNull()
?.navigate(
?.safeNavigate(
WalletAddCertificateFragmentDirections.actionWalletAddCertificateFragmentToWalletQRFragment(
WalletCertificateType.SANITARY
)
......@@ -45,7 +46,7 @@ class WalletAddCertificateFragment : MainFragment() {
}
thumbnailAction = {
findNavControllerOrNull()
?.navigate(WalletAddCertificateFragmentDirections.actionWalletAddCertificateFragmentToTestDocumentExplanationFragment())
?.safeNavigate(WalletAddCertificateFragmentDirections.actionWalletAddCertificateFragmentToTestDocumentExplanationFragment())
}
identifier = title.hashCode().toLong()
}
......@@ -57,7 +58,7 @@ class WalletAddCertificateFragment : MainFragment() {
fallbackRes = R.drawable.vaccin_certificate
mainAction = {
findNavControllerOrNull()
?.navigate(
?.safeNavigate(
WalletAddCertificateFragmentDirections.actionWalletAddCertificateFragmentToWalletQRFragment(
WalletCertificateType.VACCINATION
)
......@@ -65,7 +66,7 @@ class WalletAddCertificateFragment : MainFragment() {
}
thumbnailAction = {
findNavControllerOrNull()
?.navigate(WalletAddCertificateFragmentDirections.actionWalletAddCertificateFragmentToVaccinDocumentExplanationFragment())
?.safeNavigate(WalletAddCertificateFragmentDirections.actionWalletAddCertificateFragmentToVaccinDocumentExplanationFragment())
}
identifier = title.hashCode().toLong()
}
......
......@@ -60,7 +60,7 @@ class WalletContainerFragment : BaseFragment() {
confirmationAsked = savedInstanceState?.getBoolean(CONFIRMATION_ASKED_KEY) == true
val certificateCode = args.certificateCode
val certificateCode = args.code
if (certificateCode != null && !confirmationAsked) {
if (checkCodeValue(certificateCode)) {
findNavControllerOrNull()?.safeNavigate(
......@@ -92,7 +92,7 @@ class WalletContainerFragment : BaseFragment() {
binding = FragmentWalletContainerBinding.inflate(inflater, container, false)
binding.walletBottomSheetButton.setOnClickListener {
findNavControllerOrNull()
?.navigate(WalletContainerFragmentDirections.actionWalletContainerFragmentToWalletAddCertificateFragment())
?.safeNavigate(WalletContainerFragmentDirections.actionWalletContainerFragmentToWalletAddCertificateFragment())
}
return binding.root
}
......@@ -147,7 +147,7 @@ class WalletContainerFragment : BaseFragment() {
private fun handleCertificateError(error: Exception, certificateType: WalletCertificateType): Boolean {
val certificateError = error.walletCertificateError()
if (certificateError != null) {
findNavControllerOrNull()?.navigate(
findNavControllerOrNull()?.safeNavigate(
WalletContainerFragmentDirections.actionWalletQRCodeFragmentToWalletCertificateErrorFragment(
certificateType,
certificateError,
......
......@@ -62,7 +62,7 @@ class WalletInfoFragment : MainFragment() {
if (it.isNullOrEmpty() || parentFragment is WalletPagerFragment) {
refreshScreen()
} else {
findNavControllerOrNull()?.navigate(WalletInfoFragmentDirections.actionWalletInfoFragmentToWalletPagerFragment())
findNavControllerOrNull()?.safeNavigate(WalletInfoFragmentDirections.actionWalletInfoFragmentToWalletPagerFragment())
}
}
}
......
......@@ -29,6 +29,7 @@ import com.lunabeestudio.stopcovid.coreui.extension.findParentFragmentByType
import com.lunabeestudio.stopcovid.coreui.extension.refreshLift
import com.lunabeestudio.stopcovid.coreui.fragment.BaseFragment
import com.lunabeestudio.stopcovid.extension.robertManager
import com.lunabeestudio.stopcovid.extension.safeNavigate
import com.lunabeestudio.stopcovid.extension.secureKeystoreDataSource
import com.lunabeestudio.stopcovid.model.UnknownException
import com.lunabeestudio.stopcovid.viewmodel.WalletViewModel
......@@ -69,7 +70,7 @@ class WalletPagerFragment : BaseFragment() {
setupViewPager()
viewModel.certificatesCount.observe(viewLifecycleOwner) { certificateCount ->
if (certificateCount == 0) {
findNavControllerOrNull()?.navigate(WalletPagerFragmentDirections.actionWalletPagerFragmentToWalletInfoFragment())
findNavControllerOrNull()?.safeNavigate(WalletPagerFragmentDirections.actionWalletPagerFragmentToWalletInfoFragment())
} else {
(activity as? MainActivity)?.binding?.tabLayout?.getTabAt(WALLET_CERTIFICATE_FRAGMENT_POSITION)?.text =
stringsFormat("walletController.mode.myCertificates", certificateCount)
......
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* Authors
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Created by Lunabee Studio / Date - 2021/1/6 - for the TOUS-ANTI-COVID project
*/
package com.lunabeestudio.stopcovid.manager
import android.net.Uri
object DeeplinkManager {
fun transformAnchorParam(uri: Uri): Uri = Uri.parse(transformAnchorParam(uri.toString()))
fun transformAnchorParam(uri: String): String = if (uri.contains('?')) {
uri.replace("#", "&code=")
} else {
uri.replace("#", "?code=")
}
}
\ No newline at end of file
package com.lunabeestudio.stopcovid.manager
import android.content.SharedPreferences
import android.net.Uri
import android.net.UrlQuerySanitizer
import android.util.Base64
import com.lunabeestudio.domain.extension.ntpTimeSToUnixTimeMs
......@@ -24,10 +23,6 @@ import kotlin.time.days
object VenuesManager {
fun cleanVenueUri(stringUri: String): Uri = Uri.parse(cleanVenueUriString(stringUri))
private fun cleanVenueUriString(stringUri: String): String = stringUri.replace("#", "&code=")
fun processVenueUrl(
robertManager: RobertManager,
secureKeystoreDataSource: SecureKeystoreDataSource,
......@@ -38,7 +33,7 @@ object VenuesManager {
sanitizer.registerParameters(arrayOf("code", "v", "t")) {
it // Do nothing since there are plenty of non legal characters in this value
}
sanitizer.parseUrl(cleanVenueUriString(stringUrl))
sanitizer.parseUrl(DeeplinkManager.transformAnchorParam(stringUrl))
val base64URLCode: String = sanitizer.getValue("code") ?: throw VenueInvalidFormatException()
val version: Int = sanitizer.getValue("v")?.toInt() ?: throw VenueInvalidFormatException()
......
......@@ -708,10 +708,14 @@
android:name="com.lunabeestudio.stopcovid.fragment.WalletContainerFragment">
<deepLink
android:autoVerify="true"
app:uri="https://bonjour.tousanticovid.gouv.fr/app/wallet?v={certificateCode}"
app:uri="https://bonjour.tousanticovid.gouv.fr/app/wallet?v={code}"
tools:targetApi="m" />
<deepLink
android:autoVerify="true"
app:uri="https://bonjour.tousanticovid.gouv.fr/app/wallet2d?code={code}"
tools:targetApi="m" />
<argument
android:name="certificateCode"
android:name="code"
android:defaultValue="@null"
app:argType="string"
app:nullable="true" />
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment