Skip to content

Commit

Permalink
- add new resources and update UI; (#103)
Browse files Browse the repository at this point in the history
- clean up code;
  • Loading branch information
MykhailoNester authored Aug 30, 2021
1 parent 08a878d commit 8043aee
Show file tree
Hide file tree
Showing 27 changed files with 290 additions and 258 deletions.
16 changes: 0 additions & 16 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions app/src/main/java/dgca/wallet/app/android/LicensesActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,22 @@
* Created by Matthieu De Beule on 11/06/2021, 08:39
*/

package dgca.wallet.app.android;
package dgca.wallet.app.android

import android.graphics.Typeface
import android.os.Bundle
import android.text.util.Linkify
import android.widget.ArrayAdapter
import android.widget.ListView
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import dgca.wallet.app.android.databinding.ActivityLicensesBinding
import dgca.wallet.app.android.databinding.FragmentSettingsBinding
import java.nio.charset.Charset
import java.util.*

//Largely inspired by https://github.com/mozilla-mobile/fenix/pull/13767/
class LicensesActivity : AppCompatActivity() {

private lateinit var binding: ActivityLicensesBinding

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/dgca/wallet/app/android/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)
if (!BuildConfig.DEBUG) {
window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)
}

binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class CertificatesFragment : BindingFragment<FragmentCertificatesBinding>(),
viewModel.certificates.observe(viewLifecycleOwner, { setCertificateCards(it) })
viewModel.inProgress.observe(viewLifecycleOwner, { binding.progressView.isVisible = it })

viewModel.fetchCertificates()
viewModel.fetchCertificates(requireContext().filesDir)

setFragmentResultListener(AddNewBottomDialogFragment.REQUEST_KEY) { key, bundle ->
findNavController().navigateUp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,18 @@

package dgca.wallet.app.android.certificate

import android.content.Context
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.qualifiers.ApplicationContext
import dgca.wallet.app.android.data.WalletRepository
import kotlinx.coroutines.launch
import java.io.File
import javax.inject.Inject

@HiltViewModel
class CertificatesViewModel @Inject constructor(
@ApplicationContext private val context: Context,
private val walletRepository: WalletRepository
) : ViewModel() {

Expand All @@ -46,7 +43,7 @@ class CertificatesViewModel @Inject constructor(
private val _inProgress = MutableLiveData<Boolean>()
val inProgress: LiveData<Boolean> = _inProgress

fun fetchCertificates() {
fun fetchCertificates(filesDir: File) {
_inProgress.value = true
viewModelScope.launch {
val certificateCards = walletRepository.getCertificates()
Expand All @@ -56,7 +53,7 @@ class CertificatesViewModel @Inject constructor(
certificatesCards.addAll(certificateCards)
}

val imagesDir = File(context.filesDir, "images")
val imagesDir = File(filesDir, "images")
val imageFileCards = mutableListOf<CertificatesCard.FileCard>()
val pdfFileCards = mutableListOf<CertificatesCard.FileCard>()
imagesDir.listFiles()?.reversed()?.forEach { file ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
package dgca.wallet.app.android.certificate.claim

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import dgca.wallet.app.android.data.TestModel
Expand All @@ -35,7 +34,10 @@ class TestViewHolder(private val binding: ItemTestBinding) : RecyclerView.ViewHo
fun bind(data: TestModel) {
binding.testResultValue.text = data.resultType.value
binding.dateOfCollectionValue.text = data.dateTimeOfCollection.toFormattedDateTime()
(data.dateTimeOfTestResult?.toFormattedDateTime() ?: "").bindText(binding.dateOfTestResultTitle, binding.dateOfTestResultValue)
(data.dateTimeOfTestResult?.toFormattedDateTime() ?: "").bindText(
binding.dateOfTestResultTitle,
binding.dateOfTestResultValue
)

binding.diseaseValue.text = data.disease.value
binding.typeOfTestValue.text = data.typeOfTest.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ import dagger.hilt.android.AndroidEntryPoint
import dgca.wallet.app.android.R
import dgca.wallet.app.android.base.BindingFragment
import dgca.wallet.app.android.certificate.claim.CertListAdapter
import dgca.wallet.app.android.certificate.claim.bindText
import dgca.wallet.app.android.data.CertificateModel
import dgca.wallet.app.android.data.getCertificateListData
import dgca.wallet.app.android.databinding.FragmentCertificateViewBinding
import dgca.wallet.app.android.nfc.DCCApduService
Expand Down Expand Up @@ -101,7 +99,7 @@ class ViewCertificateFragment : BindingFragment<FragmentCertificateViewBinding>(

binding.qrCode.setImageBitmap(it.qrCode)
binding.tan.text = getString(R.string.tan_placeholder, it.certificatesCard.tan)
showUserData(certificate)
binding.personFullName.text = certificate.getFullName()
adapter.update(certificate.getCertificateListData())
})
viewModel.event.observe(viewLifecycleOwner) { event ->
Expand Down Expand Up @@ -129,8 +127,10 @@ class ViewCertificateFragment : BindingFragment<FragmentCertificateViewBinding>(
binding.nfcAction.setOnCheckedChangeListener { _, isChecked ->
if (isChecked) {
initNFCFunction()
binding.nfcSwitchText.text = getString(R.string.nfc_on)
} else {
stopNfcService()
binding.nfcSwitchText.text = getString(R.string.nfc_off)
}
}
}
Expand Down Expand Up @@ -172,21 +172,6 @@ class ViewCertificateFragment : BindingFragment<FragmentCertificateViewBinding>(
Toast.makeText(requireContext(), R.string.file_preparation_error, Toast.LENGTH_SHORT).show()
}

private fun showUserData(certificate: CertificateModel) {
certificate.getFullName().bindText(binding.nameTitle, binding.personFullName)

// val dateOfBirthday = certificate.dateOfBirth.parseFromTo(YEAR_MONTH_DAY, FORMATTED_YEAR_MONTH_DAY)
// if (dateOfBirthday.isNotBlank()) {
// binding.dateOfBirth.text = dateOfBirthday
// View.VISIBLE
// } else {
// View.GONE
// }.apply {
// binding.dateOfBirthTitle.visibility = this
// binding.dateOfBirth.visibility = this
// }
}

private fun onViewModelEvent(event: ViewCertificateViewModel.ViewCertEvent) {
when (event) {
is ViewCertificateViewModel.ViewCertEvent.OnCertDeleted -> findNavController().popBackStack()
Expand All @@ -195,7 +180,7 @@ class ViewCertificateFragment : BindingFragment<FragmentCertificateViewBinding>(

private fun initNFCFunction() {
if (!requireActivity().packageManager.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) {
binding.nfcStatus.text = getString(R.string.no_nfc)
binding.nfcGroup.isVisible = false
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ import androidx.navigation.fragment.navArgs
import dagger.hilt.android.AndroidEntryPoint
import dgca.verifier.app.engine.UTC_ZONE_ID
import dgca.verifier.app.engine.data.source.countries.COUNTRIES_MAP
import dgca.wallet.app.android.certificate.view.certificate.validity.CertificateValidityFragmentArgs
import dgca.wallet.app.android.certificate.view.certificate.validity.CertificateValidityFragmentDirections
import dgca.wallet.app.android.data.local.rules.Converters
import dgca.wallet.app.android.databinding.FragmentValidityCertificateBinding
import java.time.LocalDate
Expand All @@ -51,7 +49,7 @@ class CertificateValidityFragment : Fragment() {

private val viewModel by viewModels<CertificateValidityViewModel>()

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
_binding = FragmentValidityCertificateBinding.inflate(inflater, container, false)
return binding.root
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
import dagger.hilt.android.AndroidEntryPoint
import dgca.verifier.app.engine.Result
import dgca.wallet.app.android.R
import dgca.wallet.app.android.certificate.view.certificate.validity.rules.RulesValidationFragmentArgs
import dgca.wallet.app.android.data.local.rules.Converters
import dgca.wallet.app.android.databinding.FragmentRulesValidatationBinding

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class RulesValidationViewModel @Inject constructor(
private val _validationResults = MutableLiveData<List<ValidationResult>?>()
val validationResults: LiveData<List<ValidationResult>?> = _validationResults

private val _inProgress = MutableLiveData<Boolean>(true)
private val _inProgress = MutableLiveData(true)
val inProgress: LiveData<Boolean> = _inProgress

fun validate(qrCodeText: String, selectedCountry: String, zonedDateTime: ZonedDateTime) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,5 @@ class DCCApduService : HostApduService() {

companion object {
const val NFC_NDEF_KEY = "ndefMessage"
const val NFC_TAG_DCC = "DCC:"
const val NFC_TAG_TAN = "TAN:"
}
}
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/ic_import_image.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M15,1.5L15,1.5L4.125,1.5a0.751,0.751 0,0 0,-0.75 0.75v19.5a0.751,0.751 0,0 0,0.75 0.75L19.875,22.5a0.751,0.751 0,0 0,0.75 -0.75L20.625,7.125ZM15,3.091 L19.033,7.123L15.375,7.123a0.375,0.375 0,0 1,-0.375 -0.375ZM19.5,21.373h-15L4.5,2.627h9.75L14.25,6.75A1.126,1.126 0,0 0,15.375 7.875h4.125Z"
android:fillColor="#262626"/>
<path
android:pathData="M12.846,10.48c0,-0.067 0.008,-0.134 0.008,-0.2a5.263,5.263 0,0 0,-0.871 -2.9,0.16 0.16,0 0,0 -0.272,0 5.246,5.246 0,0 0,-0.906 2.886c0,0.073 0,0.144 0,0.216 -0.045,-0.05 -0.089,-0.1 -0.137,-0.148a5.217,5.217 0,0 0,-2.658 -1.431,0.161 0.161,0 0,0 -0.194,0.191 5.253,5.253 0,0 0,1.394 2.683c0.051,0.052 0.1,0.1 0.157,0.149 -0.067,0 -0.133,-0.007 -0.2,-0.007a5.214,5.214 0,0 0,-2.889 0.873,0.162 0.162,0 0,0 0,0.273 5.221,5.221 0,0 0,2.876 0.909c0.073,0 0.144,0 0.216,-0.005 -0.049,0.045 -0.1,0.088 -0.148,0.137a5.245,5.245 0,0 0,-1.426 2.667,0.161 0.161,0 0,0 0.19,0.194A5.218,5.218 0,0 0,10.659 15.569c0.052,-0.051 0.1,-0.1 0.149,-0.158 0,0.067 -0.007,0.133 -0.007,0.2a5.259,5.259 0,0 0,0.869 2.9,0.16 0.16,0 0,0 0.272,0A5.273,5.273 0,0 0,12.859 15.628c0,-0.074 0,-0.145 -0.006,-0.217 0.044,0.05 0.088,0.1 0.136,0.148a5.219,5.219 0,0 0,2.658 1.431,0.16 0.16,0 0,0 0.192,-0.192 5.27,5.27 0,0 0,-1.391 -2.685c-0.052,-0.052 -0.1,-0.1 -0.156,-0.148 0.065,0 0.132,0.007 0.2,0.008a5.228,5.228 0,0 0,2.891 -0.873,0.16 0.16,0 0,0 0,-0.271 5.235,5.235 0,0 0,-2.878 -0.911c-0.072,0 -0.143,0 -0.215,0 0.049,-0.045 0.1,-0.088 0.148,-0.136A5.257,5.257 0,0 0,15.859 9.121a0.16,0.16 0,0 0,-0.19 -0.193,5.256 5.256,0 0,0 -2.679,1.4C12.941,10.374 12.894,10.428 12.846,10.48ZM12.473,13.328a0.751,0.751 0,1 1,-0.26 -1.03A0.751,0.751 0,0 1,12.473 13.328Z"
android:fillColor="#262626"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_import_pdf.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M15,1.503v0L4.125,1.503a0.751,0.751 0,0 0,-0.75 0.75v19.5a0.751,0.751 0,0 0,0.75 0.75L19.874,22.503a0.751,0.751 0,0 0,0.75 -0.75L20.624,7.125ZM15,3.096 L19.033,7.128L15.374,7.128a0.375,0.375 0,0 1,-0.375 -0.375ZM19.5,21.378h-15L4.5,2.627h9.75L14.25,6.75A1.126,1.126 0,0 0,15.374 7.875h4.125ZM9.2,10.972a2.334,2.334 0,0 0,-0.745 -0.092L7.043,10.88v4.5h0.742v-1.73h0.755a2.28,2.28 0,0 0,0.54 -0.053,1.177 1.177,0 0,0 0.448,-0.231 1.359,1.359 0,0 0,0.458 -1.111,1.518 1.518,0 0,0 -0.162,-0.728A1.117,1.117 0,0 0,9.195 10.968ZM9.034,12.843a0.849,0.849 0,0 1,-0.6 0.168h-0.652v-1.48L8.374,11.531a1.12,1.12 0,0 1,0.57 0.105,0.686 0.686,0 0,1 0.3,0.623A0.782,0.782 0,0 1,9.034 12.843ZM11.96,10.875L10.579,10.875v4.5h1.417a2.794,2.794 0,0 0,0.534 -0.043,1.36 1.36,0 0,0 0.63,-0.31 2.43,2.43 0,0 0,0.709 -1.928,2.454 2.454,0 0,0 -0.547,-1.714A1.752,1.752 0,0 0,11.96 10.876ZM12.748,14.454a0.779,0.779 0,0 1,-0.333 0.235,1.653 1.653,0 0,1 -0.521,0.064h-0.573L11.321,11.496h0.583a1.36,1.36 0,0 1,0.445 0.063,0.985 0.985,0 0,1 0.392,0.26 1.814,1.814 0,0 1,0.385 1.275A2.039,2.039 0,0 1,12.748 14.455ZM14.521,15.373h0.742L15.263,13.403h1.648v-0.636L15.263,12.767L15.263,11.512h1.885v-0.636L14.521,10.876Z"
android:fillColor="#262626"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_nfc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="13.4dp"
android:height="23.4dp"
android:viewportWidth="13.4"
android:viewportHeight="23.4">
<path
android:pathData="M2.4,11.7a4.529,4.529 45,0 0,-2.4 -3.95L1.5,6.3a6.478,6.478 0,0 1,-0 10.8l-1.5,-1.45A4.435,4.435 0,0 0,2.4 11.7ZM6.9,11.7A8.949,8.949 135,0 0,3.35 4.55L4.8,3.15a10.964,10.964 0,0 1,-0 17.1l-1.45,-1.4A8.949,8.949 45,0 0,6.9 11.7ZM11.4,11.7A13.32,13.32 0,0 0,6.6 1.4L8.05,0a15.469,15.469 135,0 1,-0 23.4L6.6,22A13.32,13.32 0,0 0,11.4 11.7Z"
android:fillColor="#262626"/>
</vector>
33 changes: 33 additions & 0 deletions app/src/main/res/drawable/ic_scan.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group>
<clip-path
android:pathData="M1,16.963L7.053,16.963L7.053,23L1,23Z"/>
<path
android:pathData="M2.5,20L2.5,17.713A0.75,0.75 0,0 0,1 17.713L1,20a3,3 0,0 0,3 3L6.3,23a0.75,0.75 0,0 0,0 -1.5L4,21.5a1.5,1.5 0,0 1,-1.5 -1.5"
android:fillColor="#262626"/>
</group>
<group>
<clip-path
android:pathData="M1,1.001L7.053,1.001L7.053,7.037L1,7.037Z"/>
<path
android:pathData="M2.5,6.287L2.5,4.001A1.5,1.5 0,0 1,4 2.501L6.3,2.501A0.75,0.75 0,0 0,6.3 1.001L4,1.001A3,3 0,0 0,1 4.001L1,6.287a0.75,0.75 0,0 0,1.5 0"
android:fillColor="#262626"/>
</group>
<path
android:pathData="M21.5,4L21.5,6.286a0.75,0.75 0,0 0,1.5 0L23,4a3,3 0,0 0,-3 -3L17.729,1a0.75,0.75 0,0 0,0 1.5L20,2.5A1.5,1.5 0,0 1,21.5 4"
android:fillColor="#262626"/>
<group>
<clip-path
android:pathData="M16.979,16.963L23,16.963L23,23L16.979,23Z"/>
<path
android:pathData="M21.5,17.713L21.5,20a1.5,1.5 0,0 1,-1.5 1.5L17.729,21.5a0.75,0.75 0,0 0,0 1.5L20,23a3,3 0,0 0,3 -3L23,17.713a0.75,0.75 0,0 0,-1.5 0"
android:fillColor="#262626"/>
</group>
<path
android:pathData="M16,19.5L8,19.5a3,3 0,0 1,-3 -3L5,4.5L19,4.5L19,16.5A3,3 0,0 1,16 19.5ZM6.5,6L6.5,16.5a1.469,1.469 0,0 0,1.431 1.5h8.1A1.459,1.459 0,0 0,17.5 16.566c0,-0.023 0,-0.045 0,-0.067L17.5,6ZM14.749,14h-5a0.75,0.75 0,1 1,0 -1.5h5a0.75,0.75 0,1 1,0 1.5ZM14.749,11h-5a0.75,0.75 0,1 1,0 -1.5h5a0.75,0.75 0,1 1,0 1.5Z"
android:fillColor="#262626"/>
</vector>
4 changes: 2 additions & 2 deletions app/src/main/res/layout/certificate_card_file.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:ellipsize="end"
android:lines="1"
Expand All @@ -51,7 +51,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="16dp"
android:layout_marginBottom="8dp"
android:ellipsize="end"
android:lines="1"
android:textColor="@color/blue"
Expand Down
11 changes: 6 additions & 5 deletions app/src/main/res/layout/certificate_card_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
-->

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/title"
android:paddingStart="@dimen/default_margin"
android:paddingEnd="@dimen/default_margin"
android:paddingTop="@dimen/default_margin"
android:textSize="24sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:paddingHorizontal="@dimen/default_padding"
android:paddingVertical="4dp"
android:textSize="20sp"
tools:text="Certificates" />
Loading

0 comments on commit 8043aee

Please sign in to comment.