Skip to content

Commit

Permalink
feat: new UI design
Browse files Browse the repository at this point in the history
Co-authored-by: Nicola MC <[email protected]>
Co-authored-by: Kaizen <[email protected]>
  • Loading branch information
3 people authored Feb 23, 2022
1 parent 59daf92 commit 8f53d13
Show file tree
Hide file tree
Showing 17 changed files with 486 additions and 293 deletions.
6 changes: 4 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ android {
applicationId "it.ministerodellasalute.verificaC19"
minSdkVersion Config.minSdk
targetSdkVersion Config.targetSdk
versionCode 651
versionName "1.2.5"
versionCode 655
versionName "1.2.6"
testInstrumentationRunner Config.androidTestInstrumentation

buildConfigField "String", "BASE_LINK_URL", "\"https://www.dgc.gov.it\""
}

buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import it.ministerodellasalute.verificaC19.databinding.ActivityFirstBinding
import it.ministerodellasalute.verificaC19.ui.base.doOnDebug
import it.ministerodellasalute.verificaC19.ui.extensions.hide
import it.ministerodellasalute.verificaC19.ui.extensions.show
import it.ministerodellasalute.verificaC19.ui.main.ExternalLink
import it.ministerodellasalute.verificaC19.ui.main.Extras
import it.ministerodellasalute.verificaC19.ui.main.MainActivity
import it.ministerodellasalute.verificaC19sdk.data.local.prefs.PrefKeys
Expand Down Expand Up @@ -167,8 +168,7 @@ class FirstActivity : AppCompatActivity(), View.OnClickListener,
private fun setupUI() {
val string = getString(R.string.version, BuildConfig.VERSION_NAME)
val spannableString = SpannableString(string).also {
it.setSpan(UnderlineSpan(), 0, it.length, 0)
it.setSpan(StyleSpan(Typeface.BOLD), 0, it.length, 0)
it.setSpan(StyleSpan(Typeface.NORMAL), 0, it.length, 0)
}
binding.versionText.text = spannableString
binding.dateLastSyncText.text = getString(R.string.loading)
Expand Down Expand Up @@ -207,12 +207,12 @@ class FirstActivity : AppCompatActivity(), View.OnClickListener,
binding.scanModeButton.setOnClickListener(this)
binding.privacyPolicyCard.setOnClickListener {
val browserIntent =
Intent(Intent.ACTION_VIEW, Uri.parse("https://www.dgc.gov.it/web/pn.html"))
Intent(Intent.ACTION_VIEW, Uri.parse(ExternalLink.PRIVACY_POLICY_URL))
startActivity(browserIntent)
}
binding.faqCard.setOnClickListener {
val browserIntent =
Intent(Intent.ACTION_VIEW, Uri.parse("https://www.dgc.gov.it/web/faq.html"))
Intent(Intent.ACTION_VIEW, Uri.parse(ExternalLink.FAQ_URL))
startActivity(browserIntent)
}
binding.initDownload.setOnClickListener {
Expand Down Expand Up @@ -241,6 +241,7 @@ class FirstActivity : AppCompatActivity(), View.OnClickListener,
createCheckConnectionAlertDialog()
}
}
binding.circleInfoContainer.setOnClickListener(this)
}

private fun setScanModeButtonText(currentScanMode: ScanMode) {
Expand All @@ -251,12 +252,12 @@ class FirstActivity : AppCompatActivity(), View.OnClickListener,
} else {
var chosenScanMode =
when (currentScanMode) {
ScanMode.STANDARD -> getString(R.string.scan_mode_3G_header).substringAfter(' ').toUpperCase(Locale.ROOT)
ScanMode.STRENGTHENED -> getString(R.string.scan_mode_2G_header).substringAfter(' ').toUpperCase(Locale.ROOT)
ScanMode.BOOSTER -> getString(R.string.scan_mode_booster_header).substringAfter(' ').toUpperCase(Locale.ROOT)
ScanMode.WORK -> getString(R.string.scan_mode_work_header).substringAfter(' ').toUpperCase(Locale.ROOT)
ScanMode.ENTRY_ITALY -> getString(R.string.scan_mode_entry_italy_header).substringAfter(' ').toUpperCase(Locale.ROOT)
ScanMode.SCHOOL -> getString(R.string.scan_mode_school_header).substringAfter(' ').toUpperCase(Locale.ROOT)
ScanMode.STANDARD -> getString(R.string.scan_mode_3G_header)
ScanMode.STRENGTHENED -> getString(R.string.scan_mode_2G_header)
ScanMode.BOOSTER -> getString(R.string.scan_mode_booster_header)
ScanMode.WORK -> getString(R.string.scan_mode_work_header)
ScanMode.ENTRY_ITALY -> getString(R.string.scan_mode_entry_italy_header)
ScanMode.SCHOOL -> getString(R.string.scan_mode_school_header)
else -> getString(R.string.scan_mode_3G_header)
}
chosenScanMode += "\n"
Expand Down Expand Up @@ -423,7 +424,6 @@ class FirstActivity : AppCompatActivity(), View.OnClickListener,
}

override fun onClick(v: View?) {

if (v?.id == R.id.qrButton) {
viewModel.getDateLastSync().let {
if (!viewModel.getScanModeFlag() && v.id != R.id.scan_mode_button) {
Expand Down Expand Up @@ -451,6 +451,7 @@ class FirstActivity : AppCompatActivity(), View.OnClickListener,
R.id.qrButton -> checkCameraPermission()
R.id.settings -> openSettings()
R.id.scan_mode_button -> showScanModeChoiceAlertDialog()
R.id.circle_info_container -> createScanModeInfoAlert()
}
}

Expand All @@ -468,44 +469,32 @@ class FirstActivity : AppCompatActivity(), View.OnClickListener,
val scanModeChoices = arrayOf(
getString(
R.string.label_alert_dialog_option,
getString(R.string.scan_mode_3G_header).substringAfter(' ').toUpperCase(
Locale.ROOT
),
getString(R.string.scan_mode_3G_header),
getString(R.string.label_scan_mode_3G)
),
getString(
R.string.label_alert_dialog_option,
getString(R.string.scan_mode_2G_header).substringAfter(
' '
).toUpperCase(Locale.ROOT),
getString(R.string.scan_mode_2G_header),
getString(R.string.label_scan_mode_2G)
),
getString(
R.string.label_alert_dialog_option,
getString(R.string.scan_mode_booster_header).substringAfter(' ').toUpperCase(
Locale.ROOT
),
getString(R.string.scan_mode_booster_header),
getString(R.string.label_scan_mode_booster)
),
getString(
R.string.label_alert_dialog_option,
getString(R.string.scan_mode_work_header).substringAfter(' ').toUpperCase(
Locale.ROOT
),
getString(R.string.scan_mode_work_header),
getString(R.string.label_scan_mode_work)
),
getString(
R.string.label_alert_dialog_option,
getString(R.string.scan_mode_entry_italy_header).substringAfter(' ').toUpperCase(
Locale.ROOT
),
getString(R.string.scan_mode_entry_italy_header),
getString(R.string.label_scan_mode_entry_italy)
),
getString(
R.string.label_alert_dialog_option,
getString(R.string.scan_mode_school_header).substringAfter(' ').toUpperCase(
Locale.ROOT
),
getString(R.string.scan_mode_school_header),
getString(R.string.label_scan_mode_school)
),
)
Expand All @@ -531,7 +520,22 @@ class FirstActivity : AppCompatActivity(), View.OnClickListener,
private fun createNoScanModeChosenAlert() {
val builder = AlertDialog.Builder(this)
builder.setTitle(getString(R.string.noKeyAlertTitle))
val string = SpannableString(getString(R.string.label_no_scan_mode_chosen)).also {
val string = SpannableString(getText(R.string.label_no_scan_mode_chosen)).also {
Linkify.addLinks(it, Linkify.ALL)
}
builder.setMessage(string)
builder.setPositiveButton(getString(R.string.ok)) { _, _ ->
}
val dialog = builder.create()
dialog.show()
val alertMessage = dialog.findViewById<TextView>(android.R.id.message) as TextView
alertMessage.movementMethod = LinkMovementMethod.getInstance()
}

private fun createScanModeInfoAlert() {
val builder = AlertDialog.Builder(this)
builder.setTitle(getString(R.string.label_scan_mode_types))
val string = SpannableString(getText(R.string.label_scan_mode_types_description)).also {
Linkify.addLinks(it, Linkify.ALL)
}
builder.setMessage(string)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ import android.view.View
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import dagger.hilt.android.AndroidEntryPoint
import it.ministerodellasalute.verificaC19.BuildConfig
import it.ministerodellasalute.verificaC19.R
import it.ministerodellasalute.verificaC19.databinding.ActivitySettingsBinding
import it.ministerodellasalute.verificaC19.ui.main.ExternalLink
import it.ministerodellasalute.verificaC19sdk.model.VerificationViewModel

@AndroidEntryPoint
Expand Down Expand Up @@ -67,11 +69,11 @@ class SettingsActivity : AppCompatActivity(), View.OnClickListener {
viewModel.setTotemMode(binding.totemSwitch.isChecked)
} else if (v?.id == R.id.faq_card) {
val browserIntent =
Intent(Intent.ACTION_VIEW, Uri.parse("https://www.dgc.gov.it/web/faq.html"))
Intent(Intent.ACTION_VIEW, Uri.parse(ExternalLink.FAQ_URL))
startActivity(browserIntent)
} else if (v?.id == R.id.privacy_policy_card) {
val browserIntent =
Intent(Intent.ACTION_VIEW, Uri.parse("https://www.dgc.gov.it/web/pn.html"))
Intent(Intent.ACTION_VIEW, Uri.parse(ExternalLink.PRIVACY_POLICY_URL))
startActivity(browserIntent)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* ---license-start
* eu-digital-green-certificates / dgca-verifier-app-android
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ---license-end
*
*/

package it.ministerodellasalute.verificaC19.ui.main

import it.ministerodellasalute.verificaC19.BuildConfig


object ExternalLink {
const val FAQ_URL = "${BuildConfig.BASE_LINK_URL}/web/app.html"
const val PRIVACY_POLICY_URL = "${BuildConfig.BASE_LINK_URL}/web/pn.html"
const val VERIFICATION_FAQ_URL = "${BuildConfig.BASE_LINK_URL}/web/faq.html#verifica19"
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import com.journeyapps.barcodescanner.camera.CameraSettings
import dagger.hilt.android.AndroidEntryPoint
import it.ministerodellasalute.verificaC19.R
import it.ministerodellasalute.verificaC19.databinding.FragmentCodeReaderBinding
import it.ministerodellasalute.verificaC19sdk.model.ScanMode
import it.ministerodellasalute.verificaC19sdk.model.VerificationViewModel

@AndroidEntryPoint
Expand Down Expand Up @@ -104,6 +105,17 @@ class CodeReaderFragment : Fragment(), NavController.OnDestinationChangedListene
binding.barcodeScanner.barcodeView.decoderFactory = DefaultDecoderFactory(formats, hintsMap, null, 0)
binding.barcodeScanner.cameraSettings.isAutoFocusEnabled = true

val chosenScanMode = when (viewModel.getScanMode()) {
ScanMode.STANDARD -> getString(R.string.scan_mode_3G_header)
ScanMode.STRENGTHENED -> getString(R.string.scan_mode_2G_header)
ScanMode.BOOSTER -> getString(R.string.scan_mode_booster_header)
ScanMode.SCHOOL -> getString(R.string.scan_mode_school_header)
ScanMode.WORK -> getString(R.string.scan_mode_work_header)
ScanMode.ENTRY_ITALY -> getString(R.string.scan_mode_entry_italy_header)
}
binding.scanModeText.text = chosenScanMode
binding.closeButton.setOnClickListener(this)

if (viewModel.getFrontCameraStatus()) {
binding.barcodeScanner.barcodeView.cameraSettings.focusMode =
CameraSettings.FocusMode.INFINITY
Expand Down Expand Up @@ -131,8 +143,6 @@ class CodeReaderFragment : Fragment(), NavController.OnDestinationChangedListene
binding.barcodeScanner.statusView.text = ""
beepManager = BeepManager(requireActivity())

binding.backImage.setOnClickListener(this)
binding.backText.setOnClickListener(this)
binding.flipCamera.setOnClickListener(this)
}

Expand Down Expand Up @@ -201,6 +211,7 @@ class CodeReaderFragment : Fragment(), NavController.OnDestinationChangedListene
binding.barcodeScanner.setTorchOn()
}
}
R.id.close_button -> activity?.onBackPressed()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import dagger.hilt.android.AndroidEntryPoint
import it.ministerodellasalute.verificaC19.BuildConfig
import it.ministerodellasalute.verificaC19.R
import it.ministerodellasalute.verificaC19.databinding.FragmentVerificationBinding
import it.ministerodellasalute.verificaC19.ui.base.isDebug
import it.ministerodellasalute.verificaC19.ui.compounds.QuestionCompound
import it.ministerodellasalute.verificaC19.ui.main.ExternalLink
import it.ministerodellasalute.verificaC19sdk.VerificaDownloadInProgressException
import it.ministerodellasalute.verificaC19sdk.VerificaMinSDKVersionException
import it.ministerodellasalute.verificaC19sdk.VerificaMinVersionException
Expand Down Expand Up @@ -75,6 +77,8 @@ class VerificationFragment : Fragment(), View.OnClickListener {
setPersonData(it.person, it.dateOfBirth)
setupCertStatusView(it)
setupTimeStamp(it)
binding.closeButton.visibility = View.VISIBLE
binding.validationDate.visibility = View.VISIBLE
if (
viewModel.getTotemMode() &&
(certificate.certificateStatus == CertificateStatus.VALID)
Expand Down Expand Up @@ -117,22 +121,14 @@ class VerificationFragment : Fragment(), View.OnClickListener {

private fun setScanModeText() {
val chosenScanMode = when (viewModel.getScanMode()) {
ScanMode.STANDARD -> getString(R.string.scan_mode_3G_header).substringAfter(' ')
.toUpperCase(Locale.ROOT)
ScanMode.STRENGTHENED -> getString(R.string.scan_mode_2G_header).substringAfter(' ')
.toUpperCase(Locale.ROOT)
ScanMode.BOOSTER -> getString(R.string.scan_mode_booster_header).substringAfter(' ')
.toUpperCase(Locale.ROOT)
ScanMode.SCHOOL -> getString(R.string.scan_mode_school_header).substringAfter(' ')
.toUpperCase(Locale.ROOT)
ScanMode.WORK -> getString(R.string.scan_mode_work_header).substringAfter(' ')
.toUpperCase(Locale.ROOT)
ScanMode.ENTRY_ITALY -> getString(R.string.scan_mode_entry_italy_header).substringAfter(' ')
.toUpperCase(Locale.ROOT)
ScanMode.STANDARD -> getString(R.string.scan_mode_3G_header)
ScanMode.STRENGTHENED -> getString(R.string.scan_mode_2G_header)
ScanMode.BOOSTER -> getString(R.string.scan_mode_booster_header)
ScanMode.SCHOOL -> getString(R.string.scan_mode_school_header)
ScanMode.WORK -> getString(R.string.scan_mode_work_header)
ScanMode.ENTRY_ITALY -> getString(R.string.scan_mode_entry_italy_header)
}
val scanModeLabel = getString(R.string.label_scan_mode_ver)
binding.scanModeText.text =
getString(R.string.label_verification_scan_mode, scanModeLabel, chosenScanMode)
binding.scanModeText.text = chosenScanMode
}

private fun setupTimeStamp(cert: CertificateViewBean) {
Expand All @@ -147,14 +143,15 @@ class VerificationFragment : Fragment(), View.OnClickListener {
private fun setLinkViews(certStatus: CertificateStatus) {
binding.questionContainer.removeAllViews()
val questionMap: Map<String, String> = when (certStatus) {
CertificateStatus.VALID -> mapOf(getString(R.string.label_what_can_be_done) to "https://www.dgc.gov.it/web/faq.html#verifica19")
CertificateStatus.NOT_VALID_YET -> mapOf(getString(R.string.label_when_qr_valid) to "https://www.dgc.gov.it/web/faq.html#verifica19")
CertificateStatus.NOT_VALID, CertificateStatus.EXPIRED, CertificateStatus.TEST_NEEDED, CertificateStatus.REVOKED -> mapOf(
getString(R.string.label_why_qr_not_valid) to "https://www.dgc.gov.it/web/faq.html#verifica19"
CertificateStatus.VALID -> mapOf(getString(R.string.label_what_can_be_done) to ExternalLink.VERIFICATION_FAQ_URL)
CertificateStatus.NOT_VALID_YET -> mapOf(getString(R.string.label_when_qr_valid) to ExternalLink.VERIFICATION_FAQ_URL)
CertificateStatus.NOT_VALID, CertificateStatus.EXPIRED, CertificateStatus.REVOKED -> mapOf(
getString(R.string.label_why_qr_not_valid) to ExternalLink.VERIFICATION_FAQ_URL
)
CertificateStatus.NOT_EU_DCC -> mapOf(getString(R.string.label_which_qr_scan) to "https://www.dgc.gov.it/web/faq.html#verifica19")
CertificateStatus.TEST_NEEDED -> mapOf(getString(R.string.label_why_is_test_needed) to ExternalLink.VERIFICATION_FAQ_URL)
CertificateStatus.NOT_EU_DCC -> mapOf(getString(R.string.label_which_qr_scan) to ExternalLink.VERIFICATION_FAQ_URL)
}
questionMap.map {
questionMap.forEach {
val compound = QuestionCompound(context)
compound.setupWithLabels(it.key, it.value)
binding.questionContainer.addView(compound)
Expand Down Expand Up @@ -207,7 +204,7 @@ class VerificationFragment : Fragment(), View.OnClickListener {

private fun setPersonDetailsVisibility(certStatus: CertificateStatus) {
binding.containerPersonDetails.visibility = when (certStatus) {
CertificateStatus.VALID, CertificateStatus.REVOKED, CertificateStatus.TEST_NEEDED, CertificateStatus.NOT_VALID, CertificateStatus.EXPIRED, CertificateStatus.NOT_VALID_YET -> View.VISIBLE
CertificateStatus.VALID, CertificateStatus.REVOKED, CertificateStatus.TEST_NEEDED, CertificateStatus.NOT_VALID, CertificateStatus.EXPIRED, CertificateStatus.NOT_VALID_YET -> View.VISIBLE
else -> View.GONE
}
}
Expand Down
Loading

0 comments on commit 8f53d13

Please sign in to comment.