From c0aad101001abb70e2f94822c7dc9248da71cbfb Mon Sep 17 00:00:00 2001 From: Fabian Aggeler Date: Thu, 22 Oct 2020 23:50:42 +0200 Subject: [PATCH 1/3] Move construction of WhatToDoPositiveTestTexts into DPPPTConfigController instead of using static variables --- .../sdk/config/ws/config/WSBaseConfig.java | 89 +- .../ws/controller/DPPPTConfigController.java | 836 ++++++++++-------- .../sdk/config/ws/model/ConfigResponse.java | 6 +- .../sdk/config/ws/BaseControllerTest.java | 49 + .../backend/sdk/config/ws/MessagesTest.java | 61 -- 5 files changed, 519 insertions(+), 522 deletions(-) delete mode 100644 dpppt-config-backend/src/test/java/org/dpppt/switzerland/backend/sdk/config/ws/MessagesTest.java diff --git a/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/config/WSBaseConfig.java b/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/config/WSBaseConfig.java index 3f5acfd..4a4bc99 100644 --- a/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/config/WSBaseConfig.java +++ b/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/config/WSBaseConfig.java @@ -79,8 +79,8 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) { } @Bean - public DPPPTConfigController dppptSDKController() { - return new DPPPTConfigController(); + public DPPPTConfigController dppptSDKController(Messages messages) { + return new DPPPTConfigController(messages); } @Bean @@ -135,7 +135,6 @@ private PublicKey loadPublicKeyFromString() { @Bean public Messages messages(MessageSource messageSource) { Messages messages = new Messages(messageSource); - loadTexts(messages); return messages; } @@ -149,88 +148,4 @@ public MessageSource messageSource() { return messageSource; } - public void loadTexts(Messages messages) { - ConfigResponse.setWhatToDoPositiveTestTexts( - new WhatToDoPositiveTestTextsCollection() { - { - setDe(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("de"))); - setFr(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("fr"))); - setIt(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("it"))); - setEn(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("en"))); - setPt(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("pt"))); - setEs(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("es"))); - setSq(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("sq"))); - setBs(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("bs"))); - setHr(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("hr"))); - setSr(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("sr"))); - setRm(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("rm"))); - setTr(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("tr"))); - setTi(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("ti"))); - } - }); - } - - private WhatToDoPositiveTestTexts getWhatToDoPositiveTestText( - Messages messages, Locale locale) { - return new WhatToDoPositiveTestTexts() { - { - setEnterCovidcodeBoxSupertitle( - messages.getMessage("inform_detail_box_subtitle", locale)); - setEnterCovidcodeBoxTitle(messages.getMessage("inform_detail_box_title", locale)); - setEnterCovidcodeBoxText(messages.getMessage("inform_detail_box_text", locale)); - setEnterCovidcodeBoxButtonTitle( - messages.getMessage("inform_detail_box_button", locale)); - - setInfoBox(null); // no infobox needed at the moment - - setFaqEntries( - Arrays.asList( - new FaqEntry() { - { - setTitle( - messages.getMessage( - "inform_detail_faq1_title", locale)); - setText( - messages.getMessage( - "inform_detail_faq1_text", locale)); - setLinkTitle( - messages.getMessage( - "infoline_coronavirus_number", locale)); - setLinkUrl( - "tel://" - + messages.getMessage( - "infoline_coronavirus_number", - locale) - .replace(" ", "")); - setIconAndroid("ic_verified_user"); - setIconIos("ic-verified-user"); - } - }, - new FaqEntry() { - { - setTitle( - messages.getMessage( - "inform_detail_faq2_title", locale)); - setText( - messages.getMessage( - "inform_detail_faq2_text", locale)); - setIconAndroid("ic_key"); - setIconIos("ic-key"); - } - }, - new FaqEntry() { - { - setTitle( - messages.getMessage( - "inform_detail_faq3_title", locale)); - setText( - messages.getMessage( - "inform_detail_faq3_text", locale)); - setIconAndroid("ic_person"); - setIconIos("ic-user"); - } - })); - } - }; - } } diff --git a/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/controller/DPPPTConfigController.java b/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/controller/DPPPTConfigController.java index afca7ba..2d9ef48 100644 --- a/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/controller/DPPPTConfigController.java +++ b/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/controller/DPPPTConfigController.java @@ -11,16 +11,17 @@ package org.dpppt.switzerland.backend.sdk.config.ws.controller; import java.time.Duration; +import java.util.Arrays; import java.util.List; +import java.util.Locale; import org.dpppt.switzerland.backend.sdk.config.ws.helper.IOS136InfoBoxHelper; -import org.dpppt.switzerland.backend.sdk.config.ws.model.ConfigResponse; -import org.dpppt.switzerland.backend.sdk.config.ws.model.InfoBox; -import org.dpppt.switzerland.backend.sdk.config.ws.model.InfoBoxCollection; -import org.dpppt.switzerland.backend.sdk.config.ws.model.SDKConfig; +import org.dpppt.switzerland.backend.sdk.config.ws.model.*; +import org.dpppt.switzerland.backend.sdk.config.ws.poeditor.Messages; import org.dpppt.switzerland.backend.sdk.config.ws.semver.Version; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Bean; import org.springframework.http.CacheControl; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -33,373 +34,466 @@ @Controller @RequestMapping("/v1") public class DPPPTConfigController { - - private static final String IOS_VERSION_DE_WEEKLY_NOTIFCATION_INFO = "ios13.6"; - private static final List TESTFLIGHT_VERSIONS = List.of("ios-200619.2333.175", - "ios-200612.2347.141", - "ios-200528.2230.100", - "ios-200524.1316.87", - "ios-200521.2320.79"); - private static final String IOS_VERSION_13_7 = "ios13.7"; - private static final String IOS_VERSION_14 = "ios14.0"; - private static final Version APP_VERSION_1_0_9 = new Version("ios-1.0.9"); - - private static final Logger logger = LoggerFactory.getLogger(DPPPTConfigController.class); - - - public DPPPTConfigController() { - } - - @CrossOrigin(origins = { "https://editor.swagger.io" }) - @GetMapping(value = "") - public @ResponseBody String hello() { - return "Hello from DP3T Config WS"; - } - - @CrossOrigin(origins = { "https://editor.swagger.io" }) - @GetMapping(value = "/config") - public @ResponseBody ResponseEntity getConfig(@RequestParam(required = true) String appversion, - @RequestParam(required = true) String osversion, @RequestParam(required = true) String buildnr) { - ConfigResponse config = new ConfigResponse(); - // For iOS 13.6 users show information about weekly notification - if (osversion.startsWith(IOS_VERSION_DE_WEEKLY_NOTIFCATION_INFO)) { - IOS136InfoBoxHelper.setInfoTextForiOS136(config); - } - - // if we have testflight builds suggest to switch to store version - if (TESTFLIGHT_VERSIONS.contains(buildnr)) { - config = testFlightUpdate(); - } - - // Build nr of the initial iOS pilot test app. Contains bug, that factors are - // not used correctly in contact calculations. Set factorHigh to 0.0 for - // improving the calculation. - if (buildnr.equals("ios-200524.1316.87")) { - config.getiOSGaenSdkConfig().setFactorHigh(0.0d); - } - - // Check for old app Versions, iOS only - Version userAppVersion = new Version(appversion); - if (userAppVersion.isIOS() && APP_VERSION_1_0_9.isLargerVersionThan(userAppVersion)) { - config = generalUpdateRelease(true); - } - return ResponseEntity.ok().cacheControl(CacheControl.maxAge(Duration.ofMinutes(5))).body(config); - } - - @CrossOrigin(origins = { "https://editor.swagger.io" }) - @GetMapping(value = "/testinfobox/config") - public @ResponseBody ResponseEntity getGhettoboxConfig( - @RequestParam(required = true) String appversion, @RequestParam(required = true) String osversion, - @RequestParam(required = true) String buildnr) { - ConfigResponse body = mockConfigResponseWithInfoBox(); - return ResponseEntity.ok(body); - } - - private ConfigResponse testFlightUpdate() { - ConfigResponse configResponse = new ConfigResponse(); - String iosURL = "https://apps.apple.com/ch/app/id1509275381"; - InfoBox infoBoxde = new InfoBox(); - infoBoxde.setMsg("Die App wird in Zukunft nicht mehr über Testflight verfügbar sein."); - infoBoxde.setTitle("App-Update im App Store"); - infoBoxde.setUrlTitle("Aktualisieren"); - infoBoxde.setUrl(iosURL); - InfoBox infoBoxfr = new InfoBox(); - infoBoxfr.setMsg("L'application ne sera plus disponible sur TestFlight."); - infoBoxfr.setTitle("Mise à jour dans l'App Store"); - infoBoxfr.setUrlTitle("Mettre à jour"); - infoBoxfr.setUrl(iosURL); - InfoBox infoBoxit = new InfoBox(); - infoBoxit.setMsg("In futuro l'app non sarà più disponibile tramite Testflight."); - infoBoxit.setTitle("Aggiornamento dell'app nell'App Store"); - infoBoxit.setUrlTitle("Aggiorna"); - infoBoxit.setUrl(iosURL); - InfoBox infoBoxen = new InfoBox(); - infoBoxen.setMsg("The app will no longer be available via Testflight."); - infoBoxen.setTitle("App update in the App Store"); - infoBoxen.setUrlTitle("Update"); - infoBoxen.setUrl(iosURL); - InfoBox infoBoxpt = new InfoBox(); - infoBoxpt.setMsg("Futuramente, a app deixará de estar disponível na Testflight."); - infoBoxpt.setTitle("Atualização da app na App Store"); - infoBoxpt.setUrlTitle("Atualizar"); - infoBoxpt.setUrl(iosURL); - InfoBox infoBoxes = new InfoBox(); - infoBoxes.setMsg("En el futuro la aplicación dejará de estar disponible a través de Textflight."); - infoBoxes.setTitle("Actualización de la app en el App Store"); - infoBoxes.setUrlTitle("Actualizar"); - infoBoxes.setUrl(iosURL); - InfoBox infoBoxsq = new InfoBox(); - infoBoxsq.setMsg("Në të ardhmen aplikacioni nuk do të jetë më i disponueshëm përmes Testflight."); - infoBoxsq.setTitle("Update i aplikacionit në App Store"); - infoBoxsq.setUrlTitle("Përditësimi"); - infoBoxsq.setUrl(iosURL); - InfoBox infoBoxbs = new InfoBox(); - infoBoxbs.setMsg("Aplikacija ubuduće više neće biti dostupna preko Testflight-a."); - infoBoxbs.setTitle("Ažuriranje aplikacije u trgovini aplikacijama App Store"); - infoBoxbs.setUrlTitle("Ažuriraj"); - infoBoxbs.setUrl(iosURL); - InfoBox infoBoxhr = new InfoBox(); - infoBoxhr.setMsg("Aplikacija ubuduće više neće biti dostupna preko Testflight-a."); - infoBoxhr.setTitle("Ažuriranje aplikacije u trgovini aplikacijama App Store"); - infoBoxhr.setUrlTitle("Ažuriraj"); - infoBoxhr.setUrl(iosURL); - InfoBox infoBoxrm = new InfoBox(); - infoBoxrm.setMsg("En il futur na vegn l'app betg pli ad esser disponibla via Testflight."); - infoBoxrm.setTitle("Actualisaziun da l'app en l'App Store"); - infoBoxrm.setUrlTitle("Actualisar"); - infoBoxrm.setUrl(iosURL); - InfoBox infoBoxsr = new InfoBox(); - infoBoxsr.setMsg("Aplikacija ubuduće više neće biti dostupna preko Testflight-a."); - infoBoxsr.setTitle("Ažuriranje aplikacije u trgovini aplikacijama App Store"); - infoBoxsr.setUrlTitle("Ažuriraj"); - infoBoxsr.setUrl(iosURL); - - InfoBoxCollection collection = new InfoBoxCollection(); - collection.setDeInfoBox(infoBoxde); - collection.setEnInfoBox(infoBoxen); - collection.setFrInfoBox(infoBoxfr); - collection.setItInfoBox(infoBoxit); - collection.setPtInfoBox(infoBoxpt); - collection.setEsInfoBox(infoBoxes); - collection.setSqInfoBox(infoBoxsq); - collection.setHrInfoBox(infoBoxhr); - collection.setBsInfoBox(infoBoxbs); - collection.setRmInfoBox(infoBoxrm); - collection.setSrInfoBox(infoBoxsr); - configResponse.setInfoBox(collection); - - SDKConfig config = new SDKConfig(); - configResponse.setSdkConfig(config); - return configResponse; - - } - - private ConfigResponse generalUpdateRelease(boolean isIos) { - ConfigResponse configResponse = new ConfigResponse(); - String appstoreUrl = isIos ? "https://apps.apple.com/ch/app/id1509275381" - : "https://play.google.com/store/apps/details?id=ch.admin.bag.dp3t"; - - String store = isIos ? "App Store" : "Play Store"; - String storeFr = isIos ? "l'App Store" : "le Play Store"; + + private static final String IOS_VERSION_DE_WEEKLY_NOTIFCATION_INFO = "ios13.6"; + private static final List TESTFLIGHT_VERSIONS = List.of("ios-200619.2333.175", + "ios-200612.2347.141", + "ios-200528.2230.100", + "ios-200524.1316.87", + "ios-200521.2320.79"); + private static final String IOS_VERSION_13_7 = "ios13.7"; + private static final String IOS_VERSION_14 = "ios14.0"; + private static final Version APP_VERSION_1_0_9 = new Version("ios-1.0.9"); + + private static final Logger logger = LoggerFactory.getLogger(DPPPTConfigController.class); + + private static Messages messages; + + public DPPPTConfigController(Messages messages) { + this.messages = messages; + } + + @CrossOrigin(origins = {"https://editor.swagger.io"}) + @GetMapping(value = "") + public @ResponseBody + String hello() { + return "Hello from DP3T Config WS"; + } + + @CrossOrigin(origins = {"https://editor.swagger.io"}) + @GetMapping(value = "/config") + public @ResponseBody + ResponseEntity getConfig(@RequestParam(required = true) String appversion, + @RequestParam(required = true) String osversion, @RequestParam(required = true) String buildnr) { + ConfigResponse config = new ConfigResponse(); + config.setWhatToDoPositiveTestTexts(whatToDoPositiveTestTexts(messages)); + + // For iOS 13.6 users show information about weekly notification + if (osversion.startsWith(IOS_VERSION_DE_WEEKLY_NOTIFCATION_INFO)) { + IOS136InfoBoxHelper.setInfoTextForiOS136(config); + } + + // if we have testflight builds suggest to switch to store version + if (TESTFLIGHT_VERSIONS.contains(buildnr)) { + config = testFlightUpdate(); + } + + // Build nr of the initial iOS pilot test app. Contains bug, that factors are + // not used correctly in contact calculations. Set factorHigh to 0.0 for + // improving the calculation. + if (buildnr.equals("ios-200524.1316.87")) { + config.getiOSGaenSdkConfig().setFactorHigh(0.0d); + } + + // Check for old app Versions, iOS only + Version userAppVersion = new Version(appversion); + if (userAppVersion.isIOS() && APP_VERSION_1_0_9.isLargerVersionThan(userAppVersion)) { + config = generalUpdateRelease(true); + } + return ResponseEntity.ok().cacheControl(CacheControl.maxAge(Duration.ofMinutes(5))).body(config); + } + + @CrossOrigin(origins = {"https://editor.swagger.io"}) + @GetMapping(value = "/testinfobox/config") + public @ResponseBody + ResponseEntity getGhettoboxConfig( + @RequestParam(required = true) String appversion, @RequestParam(required = true) String osversion, + @RequestParam(required = true) String buildnr) { + ConfigResponse body = mockConfigResponseWithInfoBox(); + return ResponseEntity.ok(body); + } + + private ConfigResponse testFlightUpdate() { + ConfigResponse configResponse = new ConfigResponse(); + String iosURL = "https://apps.apple.com/ch/app/id1509275381"; + InfoBox infoBoxde = new InfoBox(); + infoBoxde.setMsg("Die App wird in Zukunft nicht mehr über Testflight verfügbar sein."); + infoBoxde.setTitle("App-Update im App Store"); + infoBoxde.setUrlTitle("Aktualisieren"); + infoBoxde.setUrl(iosURL); + InfoBox infoBoxfr = new InfoBox(); + infoBoxfr.setMsg("L'application ne sera plus disponible sur TestFlight."); + infoBoxfr.setTitle("Mise à jour dans l'App Store"); + infoBoxfr.setUrlTitle("Mettre à jour"); + infoBoxfr.setUrl(iosURL); + InfoBox infoBoxit = new InfoBox(); + infoBoxit.setMsg("In futuro l'app non sarà più disponibile tramite Testflight."); + infoBoxit.setTitle("Aggiornamento dell'app nell'App Store"); + infoBoxit.setUrlTitle("Aggiorna"); + infoBoxit.setUrl(iosURL); + InfoBox infoBoxen = new InfoBox(); + infoBoxen.setMsg("The app will no longer be available via Testflight."); + infoBoxen.setTitle("App update in the App Store"); + infoBoxen.setUrlTitle("Update"); + infoBoxen.setUrl(iosURL); + InfoBox infoBoxpt = new InfoBox(); + infoBoxpt.setMsg("Futuramente, a app deixará de estar disponível na Testflight."); + infoBoxpt.setTitle("Atualização da app na App Store"); + infoBoxpt.setUrlTitle("Atualizar"); + infoBoxpt.setUrl(iosURL); + InfoBox infoBoxes = new InfoBox(); + infoBoxes.setMsg("En el futuro la aplicación dejará de estar disponible a través de Textflight."); + infoBoxes.setTitle("Actualización de la app en el App Store"); + infoBoxes.setUrlTitle("Actualizar"); + infoBoxes.setUrl(iosURL); + InfoBox infoBoxsq = new InfoBox(); + infoBoxsq.setMsg("Në të ardhmen aplikacioni nuk do të jetë më i disponueshëm përmes Testflight."); + infoBoxsq.setTitle("Update i aplikacionit në App Store"); + infoBoxsq.setUrlTitle("Përditësimi"); + infoBoxsq.setUrl(iosURL); + InfoBox infoBoxbs = new InfoBox(); + infoBoxbs.setMsg("Aplikacija ubuduće više neće biti dostupna preko Testflight-a."); + infoBoxbs.setTitle("Ažuriranje aplikacije u trgovini aplikacijama App Store"); + infoBoxbs.setUrlTitle("Ažuriraj"); + infoBoxbs.setUrl(iosURL); + InfoBox infoBoxhr = new InfoBox(); + infoBoxhr.setMsg("Aplikacija ubuduće više neće biti dostupna preko Testflight-a."); + infoBoxhr.setTitle("Ažuriranje aplikacije u trgovini aplikacijama App Store"); + infoBoxhr.setUrlTitle("Ažuriraj"); + infoBoxhr.setUrl(iosURL); + InfoBox infoBoxrm = new InfoBox(); + infoBoxrm.setMsg("En il futur na vegn l'app betg pli ad esser disponibla via Testflight."); + infoBoxrm.setTitle("Actualisaziun da l'app en l'App Store"); + infoBoxrm.setUrlTitle("Actualisar"); + infoBoxrm.setUrl(iosURL); + InfoBox infoBoxsr = new InfoBox(); + infoBoxsr.setMsg("Aplikacija ubuduće više neće biti dostupna preko Testflight-a."); + infoBoxsr.setTitle("Ažuriranje aplikacije u trgovini aplikacijama App Store"); + infoBoxsr.setUrlTitle("Ažuriraj"); + infoBoxsr.setUrl(iosURL); + + InfoBoxCollection collection = new InfoBoxCollection(); + collection.setDeInfoBox(infoBoxde); + collection.setEnInfoBox(infoBoxen); + collection.setFrInfoBox(infoBoxfr); + collection.setItInfoBox(infoBoxit); + collection.setPtInfoBox(infoBoxpt); + collection.setEsInfoBox(infoBoxes); + collection.setSqInfoBox(infoBoxsq); + collection.setHrInfoBox(infoBoxhr); + collection.setBsInfoBox(infoBoxbs); + collection.setRmInfoBox(infoBoxrm); + collection.setSrInfoBox(infoBoxsr); + configResponse.setInfoBox(collection); + + SDKConfig config = new SDKConfig(); + configResponse.setSdkConfig(config); + return configResponse; + + } + + private ConfigResponse generalUpdateRelease(boolean isIos) { + ConfigResponse configResponse = new ConfigResponse(); + String appstoreUrl = isIos ? "https://apps.apple.com/ch/app/id1509275381" + : "https://play.google.com/store/apps/details?id=ch.admin.bag.dp3t"; + + String store = isIos ? "App Store" : "Play Store"; + String storeFr = isIos ? "l'App Store" : "le Play Store"; String storeRm = isIos ? "da l'App Store" : "dal Play Store"; - InfoBox infoBoxde = new InfoBox(); - infoBoxde.setMsg( - "Es ist eine neuere Version von SwissCovid verfügbar. Um die bestmögliche Funktionsweise der App zu erhalten, laden Sie die neuste Version vom " - + store); - infoBoxde.setTitle("App-Update verfügbar"); - infoBoxde.setUrlTitle("Aktualisieren"); - infoBoxde.setUrl(appstoreUrl); - infoBoxde.setIsDismissible(false); - - InfoBox infoBoxfr = new InfoBox(); - infoBoxfr.setMsg( - "Une nouvelle version de SwissCovid est disponible. Afin que l'application fonctionne au mieux, téléchargez la dernière version sur " - + storeFr); - infoBoxfr.setTitle("Mise à jour disponible"); - infoBoxfr.setUrlTitle("Mettre à jour"); - infoBoxfr.setUrl(appstoreUrl); - infoBoxfr.setIsDismissible(false); - - InfoBox infoBoxit = new InfoBox(); - infoBoxit.setMsg( - "È disponibile una versione più recente di SwissCovid. Per ottimizzare la funzionalità dell'app, scarica l'ultima versione da " - + store); - infoBoxit.setTitle("È disponibile un aggiornamento dell'app"); - infoBoxit.setUrlTitle("Aggiorna"); - infoBoxit.setUrl(appstoreUrl); - infoBoxit.setIsDismissible(false); - - InfoBox infoBoxen = new InfoBox(); - infoBoxen.setMsg( - "An updated version of SwissCovid is available. To guarantee the app works as well as possible, download the latest version from the " - + store); - infoBoxen.setTitle("App update available"); - infoBoxen.setUrlTitle("Update"); - infoBoxen.setUrl(appstoreUrl); - infoBoxen.setIsDismissible(false); - - InfoBox infoBoxpt = new InfoBox(); - infoBoxpt.setMsg( - "Está disponível uma nova versão da SwissCovid. Para que a app trabalhe com toda a eficiência, carregue a versão mais recente a partir da " - + store); - infoBoxpt.setTitle("Atualização da app disponível"); - infoBoxpt.setUrlTitle("Atualizar"); - infoBoxpt.setUrl(appstoreUrl); - infoBoxpt.setIsDismissible(false); - - InfoBox infoBoxes = new InfoBox(); - infoBoxes.setMsg( - "Hay una nueva versión de SwissCovid disponible. Para garantizar el mejor funcionamiento posible, descargue siempre la versión más nueva en el " - + store); - infoBoxes.setTitle("Actualización de la app disponible"); - infoBoxes.setUrlTitle("Actualizar"); - infoBoxes.setUrl(appstoreUrl); - infoBoxes.setIsDismissible(false); - - InfoBox infoBoxsq = new InfoBox(); - infoBoxsq.setMsg( - "Është i disponueshëm një version i ri nga SwissCovid. Për të marrë mënyrën më të mirë të mundshme të funksionit të aplikacionit, ngarkoni versionin më të ri nga " - + store); - infoBoxsq.setTitle("Update i aplikacionit i disponueshëm"); - infoBoxsq.setUrlTitle("Përditësimi"); - infoBoxsq.setUrl(appstoreUrl); - infoBoxsq.setIsDismissible(false); - - InfoBox infoBoxbs = new InfoBox(); - infoBoxbs.setMsg( - "Dostupna je novija verzija aplikacije SwissCovid. Da biste održavali najbolju moguću funkcionalnost aplikacije, preuzmite najnoviju verziju iz trgovine aplikacijama " - + store); - infoBoxbs.setTitle("Dostupno ažuriranje aplikacije"); - infoBoxbs.setUrlTitle("Ažuriraj"); - infoBoxbs.setUrl(appstoreUrl); - infoBoxbs.setIsDismissible(false); - - InfoBox infoBoxhr = new InfoBox(); - infoBoxhr.setMsg( - "Dostupna je novija verzija aplikacije SwissCovid. Da biste održavali najbolju moguću funkcionalnost aplikacije, preuzmite najnoviju verziju iz trgovine aplikacijama " - + store); - infoBoxhr.setTitle("Dostupno ažuriranje aplikacije"); - infoBoxhr.setUrlTitle("Ažuriraj"); - infoBoxhr.setUrl(appstoreUrl); - infoBoxhr.setIsDismissible(false); - - InfoBox infoBoxrm = new InfoBox(); - infoBoxrm.setMsg("Ina versiun pli nova da SwissCovid è disponibla. Chargiai giu l'ultima versiun " + storeRm - + ", per che l'app funcziunia il meglier pussaivel."); - infoBoxrm.setTitle("Actualisaziun da l'app è disponibla"); - infoBoxrm.setUrlTitle("Actualisar"); - infoBoxrm.setUrl(appstoreUrl); - infoBoxrm.setIsDismissible(false); - - InfoBox infoBoxsr = new InfoBox(); - infoBoxsr.setMsg( - "Dostupna je novija verzija aplikacije SwissCovid. Da biste održavali najbolju moguću funkcionalnost aplikacije, preuzmite najnoviju verziju iz trgovine aplikacijama " - + store); - infoBoxsr.setTitle("Dostupno ažuriranje aplikacije"); - infoBoxsr.setUrlTitle("Ažuriraj"); - infoBoxsr.setUrl(appstoreUrl); - infoBoxsr.setIsDismissible(false); - - InfoBox infoBoxtr = new InfoBox(); - infoBoxtr.setMsg( - "SwissCovid uygulamasının yeni sürümü bulunuyor. Uygulamayı en iyi şekilde kullanabilmek için AppStore'dan uygulamanın son sürümünü yükleyin."); - infoBoxtr.setTitle("Güncelleştirme mevcut"); - infoBoxtr.setUrlTitle("Güncelle"); - infoBoxtr.setUrl(appstoreUrl); - infoBoxtr.setIsDismissible(false); - - InfoBox infoBoxti = new InfoBox(); - infoBoxti.setMsg( - "ሓድሽ ቨርዝዮን ናይ SwissCovid ተቐሪቡ። ዝበለጸ ኣሰራርሓ ናይቲ ኤፕ መታን ክወሃበኩም፣ እቲ ሓድሽ ቨርዝዮን ካብ AppStore ብዳውንሎድ ኣምጽኡ ኢኹም።"); - infoBoxti.setTitle("ሓድሽ ኤፕ-ኣፕደይት ኣሎ"); - infoBoxti.setUrlTitle("ምምሕዳስ"); - infoBoxti.setUrl(appstoreUrl); - infoBoxti.setIsDismissible(false); - - InfoBoxCollection collection = new InfoBoxCollection(); - collection.setDeInfoBox(infoBoxde); - collection.setEnInfoBox(infoBoxen); - collection.setFrInfoBox(infoBoxfr); - collection.setItInfoBox(infoBoxit); - collection.setPtInfoBox(infoBoxpt); - collection.setEsInfoBox(infoBoxes); - collection.setSqInfoBox(infoBoxsq); - collection.setHrInfoBox(infoBoxhr); - collection.setBsInfoBox(infoBoxbs); - collection.setRmInfoBox(infoBoxrm); - collection.setSrInfoBox(infoBoxsr); - collection.setTiInfobox(infoBoxti); - collection.setTrInfobox(infoBoxtr); - - configResponse.setInfoBox(collection); - - SDKConfig config = new SDKConfig(); - configResponse.setSdkConfig(config); - return configResponse; - } - - private ConfigResponse mockConfigResponseWithInfoBox() { - ConfigResponse configResponse = new ConfigResponse(); - - InfoBox infoBoxde = new InfoBox(); - infoBoxde.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz DE"); - infoBoxde.setTitle("Hinweis DE"); - infoBoxde.setUrlTitle("Und ein externer Link DE"); - infoBoxde.setUrl("https://www.bag.admin.ch/bag/de/home.html"); - InfoBox infoBoxfr = new InfoBox(); - infoBoxfr.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz FR"); - infoBoxfr.setTitle("Hinweis FR"); - infoBoxfr.setUrlTitle("Und ein externer Link FR"); - infoBoxfr.setUrl("https://www.bag.admin.ch/bag/fr/home.html"); - InfoBox infoBoxit = new InfoBox(); - infoBoxit.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz IT"); - infoBoxit.setTitle("Hinweis IT"); - infoBoxit.setUrlTitle("Und ein externer Link IT"); - infoBoxit.setUrl("https://www.bag.admin.ch/bag/it/home.html"); - InfoBox infoBoxen = new InfoBox(); - infoBoxen.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz EN"); - infoBoxen.setTitle("Hinweis EN"); - infoBoxen.setUrlTitle("Und ein externer Link EN"); - infoBoxen.setUrl("https://www.bag.admin.ch/bag/en/home.html"); - InfoBox infoBoxpt = new InfoBox(); - infoBoxpt.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz PT"); - infoBoxpt.setTitle("Hinweis PT"); - infoBoxpt.setUrlTitle("Und ein externer Link PT"); - infoBoxpt.setUrl("https://www.bag.admin.ch/bag/pt/home.html"); - InfoBox infoBoxes = new InfoBox(); - infoBoxes.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz ES"); - infoBoxes.setTitle("Hinweis ES"); - infoBoxes.setUrlTitle("Und ein externer Link ES"); - infoBoxes.setUrl("https://www.bag.admin.ch/bag/en/home.html"); - InfoBox infoBoxsq = new InfoBox(); - infoBoxsq.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz SQ"); - infoBoxsq.setTitle("Hinweis SQ"); - infoBoxsq.setUrlTitle("Und ein externer Link SQ"); - infoBoxsq.setUrl("https://www.bag.admin.ch/bag/en/home.html"); - InfoBox infoBoxbs = new InfoBox(); - infoBoxbs.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz BS"); - infoBoxbs.setTitle("Hinweis BS"); - infoBoxbs.setUrlTitle("Und ein externer Link BS"); - infoBoxbs.setUrl("https://www.bag.admin.ch/bag/en/home.html"); - InfoBox infoBoxhr = new InfoBox(); - infoBoxhr.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz HR"); - infoBoxhr.setTitle("Hinweis HR"); - infoBoxhr.setUrlTitle("Und ein externer Link HR"); - infoBoxhr.setUrl("https://www.bag.admin.ch/bag/en/home.html"); - InfoBox infoBoxrm = new InfoBox(); - infoBoxrm.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz RM"); - infoBoxrm.setTitle("Hinweis RM"); - infoBoxrm.setUrlTitle("Und ein externer Link RM"); - infoBoxrm.setUrl("https://www.bag.admin.ch/bag/en/home.html"); - InfoBox infoBoxsr = new InfoBox(); - infoBoxsr.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz SR"); - infoBoxsr.setTitle("Hinweis SR"); - infoBoxsr.setUrlTitle("Und ein externer Link SR"); - infoBoxsr.setUrl("https://www.bag.admin.ch/bag/en/home.html"); - - InfoBoxCollection collection = new InfoBoxCollection(); - collection.setDeInfoBox(infoBoxde); - collection.setEnInfoBox(infoBoxen); - collection.setFrInfoBox(infoBoxfr); - collection.setItInfoBox(infoBoxit); - collection.setPtInfoBox(infoBoxpt); - collection.setEsInfoBox(infoBoxes); - collection.setSqInfoBox(infoBoxsq); - collection.setHrInfoBox(infoBoxhr); - collection.setBsInfoBox(infoBoxbs); - collection.setRmInfoBox(infoBoxrm); - collection.setSrInfoBox(infoBoxsr); - configResponse.setInfoBox(collection); - - SDKConfig config = new SDKConfig(); - configResponse.setSdkConfig(config); - return configResponse; - } - - public ConfigResponse mockConfigResponseWithForceUpdate() { - ConfigResponse configResponse = new ConfigResponse(); - configResponse.setForceUpdate(true); - return configResponse; - } + InfoBox infoBoxde = new InfoBox(); + infoBoxde.setMsg( + "Es ist eine neuere Version von SwissCovid verfügbar. Um die bestmögliche Funktionsweise der App zu erhalten, laden Sie die neuste Version vom " + + store); + infoBoxde.setTitle("App-Update verfügbar"); + infoBoxde.setUrlTitle("Aktualisieren"); + infoBoxde.setUrl(appstoreUrl); + infoBoxde.setIsDismissible(false); + + InfoBox infoBoxfr = new InfoBox(); + infoBoxfr.setMsg( + "Une nouvelle version de SwissCovid est disponible. Afin que l'application fonctionne au mieux, téléchargez la dernière version sur " + + storeFr); + infoBoxfr.setTitle("Mise à jour disponible"); + infoBoxfr.setUrlTitle("Mettre à jour"); + infoBoxfr.setUrl(appstoreUrl); + infoBoxfr.setIsDismissible(false); + + InfoBox infoBoxit = new InfoBox(); + infoBoxit.setMsg( + "È disponibile una versione più recente di SwissCovid. Per ottimizzare la funzionalità dell'app, scarica l'ultima versione da " + + store); + infoBoxit.setTitle("È disponibile un aggiornamento dell'app"); + infoBoxit.setUrlTitle("Aggiorna"); + infoBoxit.setUrl(appstoreUrl); + infoBoxit.setIsDismissible(false); + + InfoBox infoBoxen = new InfoBox(); + infoBoxen.setMsg( + "An updated version of SwissCovid is available. To guarantee the app works as well as possible, download the latest version from the " + + store); + infoBoxen.setTitle("App update available"); + infoBoxen.setUrlTitle("Update"); + infoBoxen.setUrl(appstoreUrl); + infoBoxen.setIsDismissible(false); + + InfoBox infoBoxpt = new InfoBox(); + infoBoxpt.setMsg( + "Está disponível uma nova versão da SwissCovid. Para que a app trabalhe com toda a eficiência, carregue a versão mais recente a partir da " + + store); + infoBoxpt.setTitle("Atualização da app disponível"); + infoBoxpt.setUrlTitle("Atualizar"); + infoBoxpt.setUrl(appstoreUrl); + infoBoxpt.setIsDismissible(false); + + InfoBox infoBoxes = new InfoBox(); + infoBoxes.setMsg( + "Hay una nueva versión de SwissCovid disponible. Para garantizar el mejor funcionamiento posible, descargue siempre la versión más nueva en el " + + store); + infoBoxes.setTitle("Actualización de la app disponible"); + infoBoxes.setUrlTitle("Actualizar"); + infoBoxes.setUrl(appstoreUrl); + infoBoxes.setIsDismissible(false); + + InfoBox infoBoxsq = new InfoBox(); + infoBoxsq.setMsg( + "Është i disponueshëm një version i ri nga SwissCovid. Për të marrë mënyrën më të mirë të mundshme të funksionit të aplikacionit, ngarkoni versionin më të ri nga " + + store); + infoBoxsq.setTitle("Update i aplikacionit i disponueshëm"); + infoBoxsq.setUrlTitle("Përditësimi"); + infoBoxsq.setUrl(appstoreUrl); + infoBoxsq.setIsDismissible(false); + + InfoBox infoBoxbs = new InfoBox(); + infoBoxbs.setMsg( + "Dostupna je novija verzija aplikacije SwissCovid. Da biste održavali najbolju moguću funkcionalnost aplikacije, preuzmite najnoviju verziju iz trgovine aplikacijama " + + store); + infoBoxbs.setTitle("Dostupno ažuriranje aplikacije"); + infoBoxbs.setUrlTitle("Ažuriraj"); + infoBoxbs.setUrl(appstoreUrl); + infoBoxbs.setIsDismissible(false); + + InfoBox infoBoxhr = new InfoBox(); + infoBoxhr.setMsg( + "Dostupna je novija verzija aplikacije SwissCovid. Da biste održavali najbolju moguću funkcionalnost aplikacije, preuzmite najnoviju verziju iz trgovine aplikacijama " + + store); + infoBoxhr.setTitle("Dostupno ažuriranje aplikacije"); + infoBoxhr.setUrlTitle("Ažuriraj"); + infoBoxhr.setUrl(appstoreUrl); + infoBoxhr.setIsDismissible(false); + + InfoBox infoBoxrm = new InfoBox(); + infoBoxrm.setMsg("Ina versiun pli nova da SwissCovid è disponibla. Chargiai giu l'ultima versiun " + storeRm + + ", per che l'app funcziunia il meglier pussaivel."); + infoBoxrm.setTitle("Actualisaziun da l'app è disponibla"); + infoBoxrm.setUrlTitle("Actualisar"); + infoBoxrm.setUrl(appstoreUrl); + infoBoxrm.setIsDismissible(false); + + InfoBox infoBoxsr = new InfoBox(); + infoBoxsr.setMsg( + "Dostupna je novija verzija aplikacije SwissCovid. Da biste održavali najbolju moguću funkcionalnost aplikacije, preuzmite najnoviju verziju iz trgovine aplikacijama " + + store); + infoBoxsr.setTitle("Dostupno ažuriranje aplikacije"); + infoBoxsr.setUrlTitle("Ažuriraj"); + infoBoxsr.setUrl(appstoreUrl); + infoBoxsr.setIsDismissible(false); + + InfoBox infoBoxtr = new InfoBox(); + infoBoxtr.setMsg( + "SwissCovid uygulamasının yeni sürümü bulunuyor. Uygulamayı en iyi şekilde kullanabilmek için AppStore'dan uygulamanın son sürümünü yükleyin."); + infoBoxtr.setTitle("Güncelleştirme mevcut"); + infoBoxtr.setUrlTitle("Güncelle"); + infoBoxtr.setUrl(appstoreUrl); + infoBoxtr.setIsDismissible(false); + + InfoBox infoBoxti = new InfoBox(); + infoBoxti.setMsg( + "ሓድሽ ቨርዝዮን ናይ SwissCovid ተቐሪቡ። ዝበለጸ ኣሰራርሓ ናይቲ ኤፕ መታን ክወሃበኩም፣ እቲ ሓድሽ ቨርዝዮን ካብ AppStore ብዳውንሎድ ኣምጽኡ ኢኹም።"); + infoBoxti.setTitle("ሓድሽ ኤፕ-ኣፕደይት ኣሎ"); + infoBoxti.setUrlTitle("ምምሕዳስ"); + infoBoxti.setUrl(appstoreUrl); + infoBoxti.setIsDismissible(false); + + InfoBoxCollection collection = new InfoBoxCollection(); + collection.setDeInfoBox(infoBoxde); + collection.setEnInfoBox(infoBoxen); + collection.setFrInfoBox(infoBoxfr); + collection.setItInfoBox(infoBoxit); + collection.setPtInfoBox(infoBoxpt); + collection.setEsInfoBox(infoBoxes); + collection.setSqInfoBox(infoBoxsq); + collection.setHrInfoBox(infoBoxhr); + collection.setBsInfoBox(infoBoxbs); + collection.setRmInfoBox(infoBoxrm); + collection.setSrInfoBox(infoBoxsr); + collection.setTiInfobox(infoBoxti); + collection.setTrInfobox(infoBoxtr); + + configResponse.setInfoBox(collection); + + SDKConfig config = new SDKConfig(); + configResponse.setSdkConfig(config); + return configResponse; + } + + private ConfigResponse mockConfigResponseWithInfoBox() { + ConfigResponse configResponse = new ConfigResponse(); + + InfoBox infoBoxde = new InfoBox(); + infoBoxde.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz DE"); + infoBoxde.setTitle("Hinweis DE"); + infoBoxde.setUrlTitle("Und ein externer Link DE"); + infoBoxde.setUrl("https://www.bag.admin.ch/bag/de/home.html"); + InfoBox infoBoxfr = new InfoBox(); + infoBoxfr.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz FR"); + infoBoxfr.setTitle("Hinweis FR"); + infoBoxfr.setUrlTitle("Und ein externer Link FR"); + infoBoxfr.setUrl("https://www.bag.admin.ch/bag/fr/home.html"); + InfoBox infoBoxit = new InfoBox(); + infoBoxit.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz IT"); + infoBoxit.setTitle("Hinweis IT"); + infoBoxit.setUrlTitle("Und ein externer Link IT"); + infoBoxit.setUrl("https://www.bag.admin.ch/bag/it/home.html"); + InfoBox infoBoxen = new InfoBox(); + infoBoxen.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz EN"); + infoBoxen.setTitle("Hinweis EN"); + infoBoxen.setUrlTitle("Und ein externer Link EN"); + infoBoxen.setUrl("https://www.bag.admin.ch/bag/en/home.html"); + InfoBox infoBoxpt = new InfoBox(); + infoBoxpt.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz PT"); + infoBoxpt.setTitle("Hinweis PT"); + infoBoxpt.setUrlTitle("Und ein externer Link PT"); + infoBoxpt.setUrl("https://www.bag.admin.ch/bag/pt/home.html"); + InfoBox infoBoxes = new InfoBox(); + infoBoxes.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz ES"); + infoBoxes.setTitle("Hinweis ES"); + infoBoxes.setUrlTitle("Und ein externer Link ES"); + infoBoxes.setUrl("https://www.bag.admin.ch/bag/en/home.html"); + InfoBox infoBoxsq = new InfoBox(); + infoBoxsq.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz SQ"); + infoBoxsq.setTitle("Hinweis SQ"); + infoBoxsq.setUrlTitle("Und ein externer Link SQ"); + infoBoxsq.setUrl("https://www.bag.admin.ch/bag/en/home.html"); + InfoBox infoBoxbs = new InfoBox(); + infoBoxbs.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz BS"); + infoBoxbs.setTitle("Hinweis BS"); + infoBoxbs.setUrlTitle("Und ein externer Link BS"); + infoBoxbs.setUrl("https://www.bag.admin.ch/bag/en/home.html"); + InfoBox infoBoxhr = new InfoBox(); + infoBoxhr.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz HR"); + infoBoxhr.setTitle("Hinweis HR"); + infoBoxhr.setUrlTitle("Und ein externer Link HR"); + infoBoxhr.setUrl("https://www.bag.admin.ch/bag/en/home.html"); + InfoBox infoBoxrm = new InfoBox(); + infoBoxrm.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz RM"); + infoBoxrm.setTitle("Hinweis RM"); + infoBoxrm.setUrlTitle("Und ein externer Link RM"); + infoBoxrm.setUrl("https://www.bag.admin.ch/bag/en/home.html"); + InfoBox infoBoxsr = new InfoBox(); + infoBoxsr.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz SR"); + infoBoxsr.setTitle("Hinweis SR"); + infoBoxsr.setUrlTitle("Und ein externer Link SR"); + infoBoxsr.setUrl("https://www.bag.admin.ch/bag/en/home.html"); + + InfoBoxCollection collection = new InfoBoxCollection(); + collection.setDeInfoBox(infoBoxde); + collection.setEnInfoBox(infoBoxen); + collection.setFrInfoBox(infoBoxfr); + collection.setItInfoBox(infoBoxit); + collection.setPtInfoBox(infoBoxpt); + collection.setEsInfoBox(infoBoxes); + collection.setSqInfoBox(infoBoxsq); + collection.setHrInfoBox(infoBoxhr); + collection.setBsInfoBox(infoBoxbs); + collection.setRmInfoBox(infoBoxrm); + collection.setSrInfoBox(infoBoxsr); + configResponse.setInfoBox(collection); + + SDKConfig config = new SDKConfig(); + configResponse.setSdkConfig(config); + return configResponse; + } + + public ConfigResponse mockConfigResponseWithForceUpdate() { + ConfigResponse configResponse = new ConfigResponse(); + configResponse.setForceUpdate(true); + return configResponse; + } + + + private WhatToDoPositiveTestTextsCollection whatToDoPositiveTestTexts(Messages messages) { + return + new WhatToDoPositiveTestTextsCollection() { + { + setDe(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("de"))); + setFr(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("fr"))); + setIt(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("it"))); + setEn(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("en"))); + setPt(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("pt"))); + setEs(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("es"))); + setSq(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("sq"))); + setBs(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("bs"))); + setHr(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("hr"))); + setSr(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("sr"))); + setRm(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("rm"))); + setTr(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("tr"))); + setTi(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("ti"))); + } + }; + } + + private WhatToDoPositiveTestTexts getWhatToDoPositiveTestText( + Messages messages, Locale locale) { + return new WhatToDoPositiveTestTexts() { + { + setEnterCovidcodeBoxSupertitle( + messages.getMessage("inform_detail_box_subtitle", locale)); + setEnterCovidcodeBoxTitle(messages.getMessage("inform_detail_box_title", locale)); + setEnterCovidcodeBoxText(messages.getMessage("inform_detail_box_text", locale)); + setEnterCovidcodeBoxButtonTitle( + messages.getMessage("inform_detail_box_button", locale)); + + setInfoBox(null); // no infobox needed at the moment + + setFaqEntries( + Arrays.asList( + new FaqEntry() { + { + setTitle( + messages.getMessage( + "inform_detail_faq1_title", locale)); + setText( + messages.getMessage( + "inform_detail_faq1_text", locale)); + setLinkTitle( + messages.getMessage( + "infoline_coronavirus_number", locale)); + setLinkUrl( + "tel://" + + messages.getMessage( + "infoline_coronavirus_number", + locale) + .replace(" ", "")); + setIconAndroid("ic_verified_user"); + setIconIos("ic-verified-user"); + } + }, + new FaqEntry() { + { + setTitle( + messages.getMessage( + "inform_detail_faq2_title", locale)); + setText( + messages.getMessage( + "inform_detail_faq2_text", locale)); + setIconAndroid("ic_key"); + setIconIos("ic-key"); + } + }, + new FaqEntry() { + { + setTitle( + messages.getMessage( + "inform_detail_faq3_title", locale)); + setText( + messages.getMessage( + "inform_detail_faq3_text", locale)); + setIconAndroid("ic_person"); + setIconIos("ic-user"); + } + })); + } + }; + } } diff --git a/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/model/ConfigResponse.java b/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/model/ConfigResponse.java index d3f0a0d..559b64e 100644 --- a/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/model/ConfigResponse.java +++ b/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/model/ConfigResponse.java @@ -19,7 +19,7 @@ public class ConfigResponse { private boolean forceTraceShutdown = false; private InfoBoxCollection infoBox = null; - private static WhatToDoPositiveTestTextsCollection whatToDoPositiveTestTexts; + private WhatToDoPositiveTestTextsCollection whatToDoPositiveTestTexts; private SDKConfig sdkConfig = new SDKConfig(); private GAENSDKConfig iOSGaenSdkConfig = new GAENSDKConfig(); @@ -53,8 +53,8 @@ public WhatToDoPositiveTestTextsCollection getWhatToDoPositiveTestTexts() { return whatToDoPositiveTestTexts; } - public static void setWhatToDoPositiveTestTexts(WhatToDoPositiveTestTextsCollection whatToDoPositiveTestTexts) { - ConfigResponse.whatToDoPositiveTestTexts = whatToDoPositiveTestTexts; + public void setWhatToDoPositiveTestTexts(WhatToDoPositiveTestTextsCollection whatToDoPositiveTestTexts) { + this.whatToDoPositiveTestTexts = whatToDoPositiveTestTexts; } public boolean isForceTraceShutdown() { diff --git a/dpppt-config-backend/src/test/java/org/dpppt/switzerland/backend/sdk/config/ws/BaseControllerTest.java b/dpppt-config-backend/src/test/java/org/dpppt/switzerland/backend/sdk/config/ws/BaseControllerTest.java index ddf977a..3a0655b 100644 --- a/dpppt-config-backend/src/test/java/org/dpppt/switzerland/backend/sdk/config/ws/BaseControllerTest.java +++ b/dpppt-config-backend/src/test/java/org/dpppt/switzerland/backend/sdk/config/ws/BaseControllerTest.java @@ -27,6 +27,7 @@ import org.dpppt.switzerland.backend.sdk.config.ws.filter.ResponseWrapperFilter; import org.dpppt.switzerland.backend.sdk.config.ws.model.ConfigResponse; +import org.dpppt.switzerland.backend.sdk.config.ws.model.WhatToDoPositiveTestTextsCollection; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -214,4 +215,52 @@ public void testThreshold() throws Exception { assertThresholds(result); } + + @Test + public void testWhatToDoPositiveTestTextLanguage() throws Exception { + MockHttpServletResponse result = mockMvc.perform( + get("/v1/config").param("osversion", "ios12").param("appversion", "ios-1.0.9").param("buildnr", "ios-2020.0145asdfa34")) + .andExpect(status().is2xxSuccessful()).andReturn().getResponse(); + + ConfigResponse resp = objectMapper.readValue(result.getContentAsString(Charset.forName("utf-8")), ConfigResponse.class); + + WhatToDoPositiveTestTextsCollection whatToDoPositiveTestTexts = resp.getWhatToDoPositiveTestTexts(); + assertEquals( + "Mit dem Covidcode...", + whatToDoPositiveTestTexts.getDe().getEnterCovidcodeBoxSupertitle()); + assertEquals( + "Avec le code COVID…", + whatToDoPositiveTestTexts.getFr().getEnterCovidcodeBoxSupertitle()); + assertEquals( + "Con il codice Covid...", + whatToDoPositiveTestTexts.getIt().getEnterCovidcodeBoxSupertitle()); + assertEquals( + "With the Covidcode", + whatToDoPositiveTestTexts.getEn().getEnterCovidcodeBoxSupertitle()); + assertEquals( + "Com o código COVID...", + whatToDoPositiveTestTexts.getPt().getEnterCovidcodeBoxSupertitle()); + assertEquals( + "Con el código Covid…", + whatToDoPositiveTestTexts.getEs().getEnterCovidcodeBoxSupertitle()); + assertEquals( + "Me kodin Covid...", + whatToDoPositiveTestTexts.getSq().getEnterCovidcodeBoxSupertitle()); + assertEquals( + "Sa Covid šifrom...", + whatToDoPositiveTestTexts.getBs().getEnterCovidcodeBoxSupertitle()); + assertEquals( + "Sa Covid šifrom...", + whatToDoPositiveTestTexts.getHr().getEnterCovidcodeBoxSupertitle()); + assertEquals( + "Sa Covid šifrom...", + whatToDoPositiveTestTexts.getSr().getEnterCovidcodeBoxSupertitle()); + assertEquals( + "Cun il code covid...", + whatToDoPositiveTestTexts.getRm().getEnterCovidcodeBoxSupertitle()); + assertEquals( + "Kovid kodu ile...", + whatToDoPositiveTestTexts.getTr().getEnterCovidcodeBoxSupertitle()); + assertEquals("ብኮቪድኮድ", whatToDoPositiveTestTexts.getTi().getEnterCovidcodeBoxSupertitle()); + } } diff --git a/dpppt-config-backend/src/test/java/org/dpppt/switzerland/backend/sdk/config/ws/MessagesTest.java b/dpppt-config-backend/src/test/java/org/dpppt/switzerland/backend/sdk/config/ws/MessagesTest.java deleted file mode 100644 index 50780ba..0000000 --- a/dpppt-config-backend/src/test/java/org/dpppt/switzerland/backend/sdk/config/ws/MessagesTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.dpppt.switzerland.backend.sdk.config.ws; - -import static org.junit.Assert.assertEquals; - -import org.dpppt.switzerland.backend.sdk.config.ws.model.ConfigResponse; -import org.dpppt.switzerland.backend.sdk.config.ws.model.WhatToDoPositiveTestTextsCollection; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest -@ActiveProfiles({"cloud-dev"}) -public class MessagesTest { - - @Test - public void testWHatToDoPositiveTestTextLanguage() throws Exception { - ConfigResponse configResponse = new ConfigResponse(); - WhatToDoPositiveTestTextsCollection whatToDoPositiveTestTexts = - configResponse.getWhatToDoPositiveTestTexts(); - assertEquals( - "Mit dem Covidcode...", - whatToDoPositiveTestTexts.getDe().getEnterCovidcodeBoxSupertitle()); - assertEquals( - "Avec le code COVID…", - whatToDoPositiveTestTexts.getFr().getEnterCovidcodeBoxSupertitle()); - assertEquals( - "Con il codice Covid...", - whatToDoPositiveTestTexts.getIt().getEnterCovidcodeBoxSupertitle()); - assertEquals( - "With the Covidcode", - whatToDoPositiveTestTexts.getEn().getEnterCovidcodeBoxSupertitle()); - assertEquals( - "Com o código COVID...", - whatToDoPositiveTestTexts.getPt().getEnterCovidcodeBoxSupertitle()); - assertEquals( - "Con el código Covid…", - whatToDoPositiveTestTexts.getEs().getEnterCovidcodeBoxSupertitle()); - assertEquals( - "Me kodin Covid...", - whatToDoPositiveTestTexts.getSq().getEnterCovidcodeBoxSupertitle()); - assertEquals( - "Sa Covid šifrom...", - whatToDoPositiveTestTexts.getBs().getEnterCovidcodeBoxSupertitle()); - assertEquals( - "Sa Covid šifrom...", - whatToDoPositiveTestTexts.getHr().getEnterCovidcodeBoxSupertitle()); - assertEquals( - "Sa Covid šifrom...", - whatToDoPositiveTestTexts.getSr().getEnterCovidcodeBoxSupertitle()); - assertEquals( - "Cun il code covid...", - whatToDoPositiveTestTexts.getRm().getEnterCovidcodeBoxSupertitle()); - assertEquals( - "Kovid kodu ile...", - whatToDoPositiveTestTexts.getTr().getEnterCovidcodeBoxSupertitle()); - assertEquals("ብኮቪድኮድ", whatToDoPositiveTestTexts.getTi().getEnterCovidcodeBoxSupertitle()); - } -} From 585a07d2d99e30edeb3bc42194364140e22808a4 Mon Sep 17 00:00:00 2001 From: Fabian Aggeler Date: Fri, 23 Oct 2020 00:06:03 +0200 Subject: [PATCH 2/3] Move EnterCovidcodeBoxText to InfoBox if necessary This works around a limitation of SwissCovid 1.1.2 on iOS, which requires an InfoBox to be set. For this specific version, the text above "Enter CovidCode" button is moved below into the InfoBox, if no other InfoBox is present. --- .../ws/controller/DPPPTConfigController.java | 34 +++++++++ .../backend/sdk/config/ws/model/InfoBox.java | 8 +- .../sdk/config/ws/BaseControllerTest.java | 73 +++++++++++++++++-- 3 files changed, 108 insertions(+), 7 deletions(-) diff --git a/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/controller/DPPPTConfigController.java b/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/controller/DPPPTConfigController.java index 2d9ef48..2d6f4cd 100644 --- a/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/controller/DPPPTConfigController.java +++ b/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/controller/DPPPTConfigController.java @@ -44,6 +44,7 @@ public class DPPPTConfigController { private static final String IOS_VERSION_13_7 = "ios13.7"; private static final String IOS_VERSION_14 = "ios14.0"; private static final Version APP_VERSION_1_0_9 = new Version("ios-1.0.9"); + private static final Version IOS_APP_VERSION_1_1_2 = new Version("ios-1.1.2"); private static final Logger logger = LoggerFactory.getLogger(DPPPTConfigController.class); @@ -90,6 +91,26 @@ ResponseEntity getConfig(@RequestParam(required = true) String a if (userAppVersion.isIOS() && APP_VERSION_1_0_9.isLargerVersionThan(userAppVersion)) { config = generalUpdateRelease(true); } + + // Work around a limitation of SwissCovid 1.1.2 on iOS which requires an InfoBox to be set. + // For this specific version, move the text above the "Enter CovidCode" button, below into the + // InfoBox if no other InfoBox is present. + if (userAppVersion.isIOS() && IOS_APP_VERSION_1_1_2.isSameVersionAs(userAppVersion)) { + moveEnterCovidcodeBoxTextToInfoBoxIfNecessary(config.getWhatToDoPositiveTestTexts().getDe()); + moveEnterCovidcodeBoxTextToInfoBoxIfNecessary(config.getWhatToDoPositiveTestTexts().getFr()); + moveEnterCovidcodeBoxTextToInfoBoxIfNecessary(config.getWhatToDoPositiveTestTexts().getIt()); + moveEnterCovidcodeBoxTextToInfoBoxIfNecessary(config.getWhatToDoPositiveTestTexts().getEn()); + moveEnterCovidcodeBoxTextToInfoBoxIfNecessary(config.getWhatToDoPositiveTestTexts().getPt()); + moveEnterCovidcodeBoxTextToInfoBoxIfNecessary(config.getWhatToDoPositiveTestTexts().getEs()); + moveEnterCovidcodeBoxTextToInfoBoxIfNecessary(config.getWhatToDoPositiveTestTexts().getSq()); + moveEnterCovidcodeBoxTextToInfoBoxIfNecessary(config.getWhatToDoPositiveTestTexts().getBs()); + moveEnterCovidcodeBoxTextToInfoBoxIfNecessary(config.getWhatToDoPositiveTestTexts().getHr()); + moveEnterCovidcodeBoxTextToInfoBoxIfNecessary(config.getWhatToDoPositiveTestTexts().getSr()); + moveEnterCovidcodeBoxTextToInfoBoxIfNecessary(config.getWhatToDoPositiveTestTexts().getRm()); + moveEnterCovidcodeBoxTextToInfoBoxIfNecessary(config.getWhatToDoPositiveTestTexts().getTr()); + moveEnterCovidcodeBoxTextToInfoBoxIfNecessary(config.getWhatToDoPositiveTestTexts().getTi()); + } + return ResponseEntity.ok().cacheControl(CacheControl.maxAge(Duration.ofMinutes(5))).body(config); } @@ -411,6 +432,19 @@ public ConfigResponse mockConfigResponseWithForceUpdate() { return configResponse; } + private void moveEnterCovidcodeBoxTextToInfoBoxIfNecessary(WhatToDoPositiveTestTexts texts) { + if (texts.getInfoBox() == null) { + texts.setInfoBox( + new InfoBox() { + { + setTitle(""); + setMsg(texts.getEnterCovidcodeBoxText()); + setIsDismissible(false); + } + }); + texts.setEnterCovidcodeBoxText(""); + } + } private WhatToDoPositiveTestTextsCollection whatToDoPositiveTestTexts(Messages messages) { return diff --git a/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/model/InfoBox.java b/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/model/InfoBox.java index 4fdb2cc..9ddf65f 100644 --- a/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/model/InfoBox.java +++ b/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/model/InfoBox.java @@ -25,8 +25,12 @@ public class InfoBox { private boolean isDismissible = false; public String getInfoId() { - return Integer.toString(getTitle().hashCode() + getMsg().hashCode() + getUrl().hashCode() - + getUrlTitle().hashCode() + Boolean.hashCode(getIsDismissible())); + return Integer.toString( + ((getTitle() != null) ? getTitle().hashCode() : 0) + + ((getMsg() != null) ? getMsg().hashCode() : 0) + + ((getUrl() != null) ? getUrl().hashCode() : 0) + + ((getUrlTitle() != null) ? getUrlTitle().hashCode() : 0) + + (Boolean.hashCode(getIsDismissible()))); } public String getTitle() { diff --git a/dpppt-config-backend/src/test/java/org/dpppt/switzerland/backend/sdk/config/ws/BaseControllerTest.java b/dpppt-config-backend/src/test/java/org/dpppt/switzerland/backend/sdk/config/ws/BaseControllerTest.java index 3a0655b..fbb6e1a 100644 --- a/dpppt-config-backend/src/test/java/org/dpppt/switzerland/backend/sdk/config/ws/BaseControllerTest.java +++ b/dpppt-config-backend/src/test/java/org/dpppt/switzerland/backend/sdk/config/ws/BaseControllerTest.java @@ -10,11 +10,7 @@ package org.dpppt.switzerland.backend.sdk.config.ws; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -94,6 +90,45 @@ private void assertThresholds(MockHttpServletResponse result) throws JsonMapping assertEquals(55, (int) resp.getAndroidGaenSdkConfig().getLowerThreshold()); } + private void assertWhatToDoPositiveTestInfoBox(MockHttpServletResponse result) throws Exception { + ConfigResponse resp = + objectMapper.readValue( + result.getContentAsString(Charset.forName("utf-8")), ConfigResponse.class); + assertNotNull(resp.getWhatToDoPositiveTestTexts().getDe().getInfoBox()); + assertNotNull(resp.getWhatToDoPositiveTestTexts().getFr().getInfoBox()); + assertNotNull(resp.getWhatToDoPositiveTestTexts().getIt().getInfoBox()); + assertNotNull(resp.getWhatToDoPositiveTestTexts().getEn().getInfoBox()); + assertNotNull(resp.getWhatToDoPositiveTestTexts().getPt().getInfoBox()); + assertNotNull(resp.getWhatToDoPositiveTestTexts().getEs().getInfoBox()); + assertNotNull(resp.getWhatToDoPositiveTestTexts().getSq().getInfoBox()); + assertNotNull(resp.getWhatToDoPositiveTestTexts().getBs().getInfoBox()); + assertNotNull(resp.getWhatToDoPositiveTestTexts().getHr().getInfoBox()); + assertNotNull(resp.getWhatToDoPositiveTestTexts().getSr().getInfoBox()); + assertNotNull(resp.getWhatToDoPositiveTestTexts().getRm().getInfoBox()); + assertNotNull(resp.getWhatToDoPositiveTestTexts().getTr().getInfoBox()); + assertNotNull(resp.getWhatToDoPositiveTestTexts().getTi().getInfoBox()); + } + + private void assertEnterCovidcodeBoxText(MockHttpServletResponse result) throws Exception { + ConfigResponse resp = + objectMapper.readValue( + result.getContentAsString(Charset.forName("utf-8")), ConfigResponse.class); + assertNotEquals("", resp.getWhatToDoPositiveTestTexts().getDe().getEnterCovidcodeBoxText()); + assertNotEquals("", resp.getWhatToDoPositiveTestTexts().getFr().getEnterCovidcodeBoxText()); + assertNotEquals("", resp.getWhatToDoPositiveTestTexts().getIt().getEnterCovidcodeBoxText()); + assertNotEquals("", resp.getWhatToDoPositiveTestTexts().getEn().getEnterCovidcodeBoxText()); + assertNotEquals("", resp.getWhatToDoPositiveTestTexts().getPt().getEnterCovidcodeBoxText()); + assertNotEquals("", resp.getWhatToDoPositiveTestTexts().getEs().getEnterCovidcodeBoxText()); + assertNotEquals("", resp.getWhatToDoPositiveTestTexts().getSq().getEnterCovidcodeBoxText()); + assertNotEquals("", resp.getWhatToDoPositiveTestTexts().getBs().getEnterCovidcodeBoxText()); + assertNotEquals("", resp.getWhatToDoPositiveTestTexts().getHr().getEnterCovidcodeBoxText()); + assertNotEquals("", resp.getWhatToDoPositiveTestTexts().getSr().getEnterCovidcodeBoxText()); + assertNotEquals("", resp.getWhatToDoPositiveTestTexts().getRm().getEnterCovidcodeBoxText()); + assertNotEquals("", resp.getWhatToDoPositiveTestTexts().getTr().getEnterCovidcodeBoxText()); + assertNotEquals("", resp.getWhatToDoPositiveTestTexts().getTi().getEnterCovidcodeBoxText()); + } + + @Test public void testHello() throws Exception { final MockHttpServletResponse response = mockMvc.perform(get("/v1")) @@ -263,4 +298,32 @@ public void testWhatToDoPositiveTestTextLanguage() throws Exception { whatToDoPositiveTestTexts.getTr().getEnterCovidcodeBoxSupertitle()); assertEquals("ብኮቪድኮድ", whatToDoPositiveTestTexts.getTi().getEnterCovidcodeBoxSupertitle()); } + + @Test + public void testiOSInfoBoxWorkaround() throws Exception { + MockHttpServletResponse result = + mockMvc + .perform( + get("/v1/config") + .param("osversion", "ios14.0") + .param("appversion", "ios-1.1.2") + .param("buildnr", "ios-2020.0145asdfa34")) + .andExpect(status().is2xxSuccessful()) + .andReturn() + .getResponse(); + assertWhatToDoPositiveTestInfoBox(result); + + result = + mockMvc + .perform( + get("/v1/config") + .param("osversion", "ios13.7") + .param("appversion", "ios-1.1.1") + .param("buildnr", "ios-2020.0145asdfa34")) + .andExpect(status().is2xxSuccessful()) + .andReturn() + .getResponse(); + assertEnterCovidcodeBoxText(result); + } + } From d3486dd92f3ccecf3bad0886bb5be6e4b7230e85 Mon Sep 17 00:00:00 2001 From: Felix Haller Date: Fri, 23 Oct 2020 07:31:33 +0200 Subject: [PATCH 3/3] disable default locale for messagesource to ensure all translations are present --- .../switzerland/backend/sdk/config/ws/config/WSBaseConfig.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/config/WSBaseConfig.java b/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/config/WSBaseConfig.java index 4a4bc99..512a9ad 100644 --- a/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/config/WSBaseConfig.java +++ b/dpppt-config-backend/src/main/java/org/dpppt/switzerland/backend/sdk/config/ws/config/WSBaseConfig.java @@ -145,6 +145,8 @@ public MessageSource messageSource() { messageSource.setBasename("classpath:i18n/messages"); messageSource.setDefaultEncoding("UTF-8"); + messageSource.setFallbackToSystemLocale(false); + messageSource.setDefaultLocale(null); return messageSource; }