-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add endpoint; - add UI for claim certificate screen; - add viewmodel with QR decoder; - add new resources icons, strings etc; - add user permissions; - add new data models; - add progressview on cert list fragment; - handle navigation from claim cert to cert list; - update fragment animation; - add rsa support;
- Loading branch information
1 parent
a2110b3
commit 9de9878
Showing
30 changed files
with
723 additions
and
81 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package dgca.wallet.app.android | ||
|
||
/** | ||
* Used as a wrapper for data that is exposed via a LiveData that represents an event. | ||
*/ | ||
open class Event<out T>(private val content: T) { | ||
|
||
var hasBeenHandled = false | ||
private set // Allow external read but not write | ||
|
||
/** | ||
* Returns the content and prevents its use again. | ||
*/ | ||
fun getContentIfNotHandled(): T? { | ||
return if (hasBeenHandled) { | ||
null | ||
} else { | ||
hasBeenHandled = true | ||
content | ||
} | ||
} | ||
|
||
/** | ||
* Returns the content, even if it's already been handled. | ||
*/ | ||
fun peekContent(): T = content | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
app/src/main/java/dgca/wallet/app/android/certificate/claim/ClaimCertificateFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* ---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 | ||
* | ||
* Created by mykhailo.nester on 5/12/21 12:27 AM | ||
*/ | ||
|
||
package dgca.wallet.app.android.certificate.claim | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.Toast | ||
import androidx.core.view.isVisible | ||
import androidx.fragment.app.Fragment | ||
import androidx.fragment.app.viewModels | ||
import androidx.navigation.fragment.findNavController | ||
import androidx.navigation.fragment.navArgs | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import dgca.wallet.app.android.databinding.FragmentCertificateClaimBinding | ||
|
||
@AndroidEntryPoint | ||
class ClaimCertificateFragment : Fragment() { | ||
|
||
private val args by navArgs<ClaimCertificateFragmentArgs>() | ||
private val viewModel by viewModels<ClaimCertificateViewModel>() | ||
private var _binding: FragmentCertificateClaimBinding? = null | ||
private val binding get() = _binding!! | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { | ||
_binding = FragmentCertificateClaimBinding.inflate(inflater, container, false) | ||
return binding.root | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
binding.backBtn.setOnClickListener { | ||
findNavController().popBackStack() | ||
} | ||
binding.saveBtn.setOnClickListener { | ||
viewModel.save(args.qrCodeText, binding.tanTextField.editText?.text.toString()) | ||
} | ||
|
||
viewModel.inProgress.observe(viewLifecycleOwner, { | ||
binding.progressView.isVisible = it | ||
}) | ||
viewModel.event.observe(viewLifecycleOwner) { event -> | ||
event.getContentIfNotHandled()?.let { | ||
onViewModelEvent(it) | ||
} | ||
} | ||
} | ||
|
||
override fun onDestroyView() { | ||
super.onDestroyView() | ||
_binding = null | ||
} | ||
|
||
private fun onViewModelEvent(event: ClaimCertificateViewModel.ClaimCertEvent) { | ||
when (event) { | ||
is ClaimCertificateViewModel.ClaimCertEvent.OnCertClaimed -> { | ||
if (event.result) { | ||
Toast.makeText(requireContext(), "Certificate claimed", Toast.LENGTH_SHORT).show() | ||
val action = ClaimCertificateFragmentDirections.actionClaimCertificateFragmentToCertificatesFragment() | ||
findNavController().navigate(action) | ||
} else { | ||
Toast.makeText(requireContext(), "Certificate not claimed", Toast.LENGTH_SHORT).show() | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.