Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Moving registration package to submission package #21

Merged
merged 3 commits into from
May 30, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.rki.coronawarnapp.ui.register
package de.rki.coronawarnapp.ui.submission

enum class ApiRequestState {
IDLE, STARTED, FAILED, SUCCESS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.rki.coronawarnapp.ui.register
package de.rki.coronawarnapp.ui.submission

enum class ScanStatus {
STARTED, INVALID, SUCCESS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ class SubmissionDispatcherFragment : BaseFragment() {
private fun setButtonOnClickListener() {
binding.submissionDispatcherQr.dispatcherCard.setOnClickListener {
doNavigate(
SubmissionDispatcherFragmentDirections.actionSubmissionDispatcherFragmentToRegisterQRCodeFragment()
SubmissionDispatcherFragmentDirections
.actionSubmissionDispatcherFragmentToSubmissionQRCodeScanFragment()
)
}
binding.submissionDispatcherTanCode.dispatcherCard.setOnClickListener {
doNavigate(
SubmissionDispatcherFragmentDirections.actionSubmissionDispatcherFragmentToSubmissionTanFragment()
SubmissionDispatcherFragmentDirections
.actionSubmissionDispatcherFragmentToSubmissionTanFragment()
)
}
binding.submissionDispatcherTanTele.dispatcherCard.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.rki.coronawarnapp.ui.register
package de.rki.coronawarnapp.ui.submission

import android.Manifest
import android.content.pm.PackageManager
Expand All @@ -13,30 +13,30 @@ import com.google.zxing.BarcodeFormat
import com.journeyapps.barcodescanner.BarcodeResult
import com.journeyapps.barcodescanner.DefaultDecoderFactory
import de.rki.coronawarnapp.R
import de.rki.coronawarnapp.databinding.FragmentRegisterQrCodeScanBinding
import de.rki.coronawarnapp.databinding.FragmentSubmissionQrCodeScanBinding
import de.rki.coronawarnapp.ui.BaseFragment
import de.rki.coronawarnapp.ui.viewmodel.SubmissionViewModel
import de.rki.coronawarnapp.util.CameraPermissionHelper

/**
* A simple [BaseFragment] subclass.
*/
class RegisterQRCodeScanFragment : BaseFragment() {
class SubmissionQRCodeScanFragment : BaseFragment() {

companion object {
private val TAG: String? = RegisterQRCodeScanFragment::class.simpleName
private val TAG: String? = SubmissionQRCodeScanFragment::class.simpleName
private const val REQUEST_CAMERA_PERMISSION_CODE = 1
}

private val viewModel: SubmissionViewModel by viewModels()
private lateinit var binding: FragmentRegisterQrCodeScanBinding
private lateinit var binding: FragmentSubmissionQrCodeScanBinding

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentRegisterQrCodeScanBinding.inflate(inflater)
binding = FragmentSubmissionQrCodeScanBinding.inflate(inflater)
binding.lifecycleOwner = this
return binding.root
}
Expand All @@ -46,29 +46,27 @@ class RegisterQRCodeScanFragment : BaseFragment() {
}

private fun startDecode() {
binding.registerQrCodeScanPreview.decodeSingle { decodeCallback(it) }
binding.submissionQrCodeScanPreview.decodeSingle { decodeCallback(it) }
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

checkForCameraPermission()

binding.registerQrCodeScanTorch.setOnCheckedChangeListener { _, isChecked ->
binding.registerQrCodeScanPreview.setTorch(
binding.submissionQrCodeScanTorch.setOnCheckedChangeListener { _, isChecked ->
binding.submissionQrCodeScanPreview.setTorch(
isChecked
)
}

binding.registerQrCodeScanClose.buttonIcon.setOnClickListener {
doNavigate(
RegisterQRCodeScanFragmentDirections.actionRegisterQRCodeFragmentToSubmissionDispatcherFragment()
)
binding.submissionQrCodeScanClose.buttonIcon.setOnClickListener {
navigateToDispatchScreen()
}

binding.registerQrCodeScanPreview.decoderFactory =
binding.submissionQrCodeScanPreview.decoderFactory =
DefaultDecoderFactory(listOf(BarcodeFormat.QR_CODE))
binding.registerQrCodeScanViewfinderView.setCameraPreview(binding.registerQrCodeScanPreview)
binding.submissionQrCodeScanViewfinderView.setCameraPreview(binding.submissionQrCodeScanPreview)

viewModel.scanStatus.observe(viewLifecycleOwner, Observer {
if (ScanStatus.SUCCESS == it) {
Expand All @@ -85,24 +83,25 @@ class RegisterQRCodeScanFragment : BaseFragment() {

private fun navigateToDispatchScreen() =
doNavigate(
RegisterQRCodeScanFragmentDirections.actionRegisterQRCodeFragmentToSubmissionDispatcherFragment()
SubmissionQRCodeScanFragmentDirections.actionSubmissionQRCodeScanFragmentToSubmissionDispatcherFragment()
)

private fun showSuccessfulScanDialog() {
val alertDialog: AlertDialog = requireActivity().let {
val builder = AlertDialog.Builder(it)
builder.apply {
setTitle(R.string.register_qr_code_scan_successful_dialog_headline)
setMessage(R.string.register_qr_code_scan_successful_dialog_body)
setTitle(R.string.submission_qr_code_scan_successful_dialog_headline)
setMessage(R.string.submission_qr_code_scan_successful_dialog_body)
setPositiveButton(
R.string.register_qr_code_scan_successful_dialog_button_positive
R.string.submission_qr_code_scan_successful_dialog_button_positive
) { _, _ ->
doNavigate(
RegisterQRCodeScanFragmentDirections.actionRegisterQRCodeFragmentToDeviceRegistrationFragment()
SubmissionQRCodeScanFragmentDirections
.actionSubmissionQRCodeScanFragmentToSubmissionRegisterDeviceFragment()
)
}
setNegativeButton(
R.string.register_qr_code_scan_successful_dialog_button_negative
R.string.submission_qr_code_scan_successful_dialog_button_negative
) { _, _ ->
viewModel.deleteTestGUID()
navigateToDispatchScreen()
Expand All @@ -117,15 +116,15 @@ class RegisterQRCodeScanFragment : BaseFragment() {
val alertDialog: AlertDialog = requireActivity().let {
val builder = AlertDialog.Builder(it)
builder.apply {
setTitle(R.string.register_qr_code_scan_invalid_dialog_headline)
setMessage(R.string.register_qr_code_scan_invalid_dialog_body)
setTitle(R.string.submission_qr_code_scan_invalid_dialog_headline)
setMessage(R.string.submission_qr_code_scan_invalid_dialog_body)
setPositiveButton(
R.string.register_qr_code_scan_invalid_dialog_button_positive
R.string.submission_qr_code_scan_invalid_dialog_button_positive
) { _, _ ->
startDecode()
}
setNegativeButton(
R.string.register_qr_code_scan_invalid_dialog_button_negative
R.string.submission_qr_code_scan_invalid_dialog_button_negative
) { _, _ ->
navigateToDispatchScreen()
}
Expand All @@ -151,7 +150,7 @@ class RegisterQRCodeScanFragment : BaseFragment() {
}

private fun cameraPermissionIsGranted() {
binding.registerQrCodeScanPreview.resume()
binding.submissionQrCodeScanPreview.resume()
startDecode()
}

Expand All @@ -172,18 +171,18 @@ class RegisterQRCodeScanFragment : BaseFragment() {
val alertDialog: AlertDialog = requireActivity().let {
val builder = AlertDialog.Builder(it)
builder.apply {
setTitle(R.string.register_qr_code_scan_permission_rationale_dialog_headline)
setMessage(R.string.register_qr_code_scan_permission_rationale_dialog_body)
setTitle(R.string.submission_qr_code_scan_permission_rationale_dialog_headline)
setMessage(R.string.submission_qr_code_scan_permission_rationale_dialog_body)
setPositiveButton(
R.string.register_qr_code_scan_permission_rationale_dialog_button_positive
R.string.submission_qr_code_scan_permission_rationale_dialog_button_positive
) { _, _ ->
requestPermissions(
arrayOf(Manifest.permission.CAMERA),
REQUEST_CAMERA_PERMISSION_CODE
)
}
setNegativeButton(
R.string.register_qr_code_scan_permission_rationale_dialog_button_negative
R.string.submission_qr_code_scan_permission_rationale_dialog_button_negative
) { _, _ ->
navigateToDispatchScreen()
}
Expand All @@ -197,10 +196,10 @@ class RegisterQRCodeScanFragment : BaseFragment() {
val alertDialog: AlertDialog = requireActivity().let {
val builder = AlertDialog.Builder(it)
builder.apply {
setTitle(R.string.register_qr_code_scan_permission_denied_dialog_headline)
setMessage(R.string.register_qr_code_scan_permission_denied_dialog_body)
setTitle(R.string.submission_qr_code_scan_permission_denied_dialog_headline)
setMessage(R.string.submission_qr_code_scan_permission_denied_dialog_body)
setPositiveButton(
R.string.register_qr_code_scan_permission_denied_dialog_button_positive
R.string.submission_qr_code_scan_permission_denied_dialog_button_positive
) { _, _ ->
navigateToDispatchScreen()
}
Expand All @@ -212,11 +211,11 @@ class RegisterQRCodeScanFragment : BaseFragment() {

override fun onResume() {
super.onResume()
binding.registerQrCodeScanPreview.resume()
binding.submissionQrCodeScanPreview.resume()
}

override fun onPause() {
super.onPause()
binding.registerQrCodeScanPreview.pause()
binding.submissionQrCodeScanPreview.pause()
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
package de.rki.coronawarnapp.ui.register
package de.rki.coronawarnapp.ui.submission

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.Observer
import de.rki.coronawarnapp.databinding.FragmentRegisterDeviceBinding
import de.rki.coronawarnapp.databinding.FragmentSubmissionRegisterDeviceBinding
import de.rki.coronawarnapp.ui.BaseFragment
import de.rki.coronawarnapp.ui.viewmodel.SubmissionViewModel

class RegisterDeviceFragment : BaseFragment() {
class SubmissionRegisterDeviceFragment : BaseFragment() {
private val viewModel: SubmissionViewModel by activityViewModels()
private lateinit var binding: FragmentRegisterDeviceBinding
private lateinit var binding: FragmentSubmissionRegisterDeviceBinding

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentRegisterDeviceBinding.inflate(inflater)
binding = FragmentSubmissionRegisterDeviceBinding.inflate(inflater)
binding.lifecycleOwner = this
return binding.root
}
Expand All @@ -30,7 +30,8 @@ class RegisterDeviceFragment : BaseFragment() {
viewModel.registrationState.observe(viewLifecycleOwner, Observer {
if (ApiRequestState.SUCCESS == it) {
doNavigate(
RegisterDeviceFragmentDirections.actionDeviceRegistrationFragmentToSubmissionResultFragment()
SubmissionRegisterDeviceFragmentDirections
.actionSubmissionRegisterDeviceFragmentToSubmissionResultFragment()
)
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ class SubmissionTanFragment : BaseFragment() {
// store locally
viewModel.storeTeletan()

doNavigate(SubmissionTanFragmentDirections.actionSubmissionTanFragmentToDeviceRegistrationFragment())
doNavigate(SubmissionTanFragmentDirections.actionSubmissionTanFragmentToSubmissionRegisterDeviceFragment())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import de.rki.coronawarnapp.exception.report
import de.rki.coronawarnapp.service.submission.SubmissionService
import de.rki.coronawarnapp.storage.LocalData
import de.rki.coronawarnapp.storage.SubmissionRepository
import de.rki.coronawarnapp.ui.register.ApiRequestState
import de.rki.coronawarnapp.ui.register.ScanStatus
import de.rki.coronawarnapp.ui.submission.ApiRequestState
import de.rki.coronawarnapp.ui.submission.ScanStatus
import de.rki.coronawarnapp.util.formatter.TestResult
import kotlinx.coroutines.launch
import java.util.Date
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import android.graphics.drawable.Drawable
import android.view.View
import de.rki.coronawarnapp.CoronaWarnApplication
import de.rki.coronawarnapp.R
import de.rki.coronawarnapp.ui.register.ApiRequestState
import de.rki.coronawarnapp.ui.submission.ApiRequestState
import de.rki.coronawarnapp.ui.submission.TestResultStatus
import de.rki.coronawarnapp.util.formatter.TestResult.INVALID
import de.rki.coronawarnapp.util.formatter.TestResult.NEGATIVE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
app:illustration="@{@drawable/ic_submission_illustration_qr_code_card}"
app:layout_constraintEnd_toStartOf="@+id/submission_guideline_end"
app:layout_constraintStart_toStartOf="@+id/submission_guideline_start"
android:focusable="true"
app:layout_constraintTop_toBottomOf="@+id/submission_dispatcher_subtitle" />

<include
Expand Down Expand Up @@ -99,7 +100,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_end="@dimen/sm_guideline_button" />
app:layout_constraintGuide_end="@dimen/submission_guideline_button" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/submission_guideline_top"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_end="@dimen/sm_guideline_button" />
app:layout_constraintGuide_end="@dimen/submission_guideline_button" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/submission_guideline_top"
Expand Down
Loading