-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #409 from SwissCovid/develop
Version 2.2.0
- Loading branch information
Showing
30 changed files
with
2,187 additions
and
9 deletions.
There are no files selected for viewing
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
16 changes: 16 additions & 0 deletions
16
...src/main/java/ch/admin/bag/dp3t/networking/models/VaccinationBookingCantonCollection.java
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,16 @@ | ||
/* | ||
* Copyright (c) 2021 Ubique Innovation AG <https://www.ubique.ch> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package ch.admin.bag.dp3t.networking.models; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
public class VaccinationBookingCantonCollection extends HashMap<String, List<VaccinationBookingCantonModel>> { | ||
} |
16 changes: 16 additions & 0 deletions
16
app/src/main/java/ch/admin/bag/dp3t/networking/models/VaccinationBookingCantonModel.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,16 @@ | ||
/* | ||
* Copyright (c) 2021 Ubique Innovation AG <https://www.ubique.ch> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
package ch.admin.bag.dp3t.networking.models | ||
|
||
data class VaccinationBookingCantonModel( | ||
val name: String, | ||
val linkUrl: String | ||
) |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/ch/admin/bag/dp3t/networking/models/VaccinationBookingInfoCollection.java
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,15 @@ | ||
/* | ||
* Copyright (c) 2021 Ubique Innovation AG <https://www.ubique.ch> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package ch.admin.bag.dp3t.networking.models; | ||
|
||
import java.util.HashMap; | ||
|
||
public class VaccinationBookingInfoCollection extends HashMap<String, VaccinationBookingInfoModel> { | ||
} |
17 changes: 17 additions & 0 deletions
17
app/src/main/java/ch/admin/bag/dp3t/networking/models/VaccinationBookingInfoModel.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,17 @@ | ||
/* | ||
* Copyright (c) 2021 Ubique Innovation AG <https://www.ubique.ch> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
package ch.admin.bag.dp3t.networking.models | ||
|
||
data class VaccinationBookingInfoModel( | ||
val title: String, | ||
val text: String, | ||
val info: String | ||
) |
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
41 changes: 41 additions & 0 deletions
41
app/src/main/java/ch/admin/bag/dp3t/vaccination/VaccinationAppointmentCantonAdapter.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,41 @@ | ||
/* | ||
* Copyright (c) 2021 Ubique Innovation AG <https://www.ubique.ch> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
package ch.admin.bag.dp3t.vaccination | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import ch.admin.bag.dp3t.networking.models.VaccinationBookingCantonModel | ||
import ch.admin.bag.dp3t.databinding.ItemVaccinationAppointmentCantonBinding | ||
|
||
class VaccinationAppointmentCantonAdapter( | ||
private val onCantonClicked: (VaccinationBookingCantonModel) -> Unit | ||
) : RecyclerView.Adapter<VaccinationAppointmentCantonViewHolder>() { | ||
|
||
private val items = mutableListOf<VaccinationBookingCantonModel>() | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VaccinationAppointmentCantonViewHolder { | ||
val binding = ItemVaccinationAppointmentCantonBinding.inflate(LayoutInflater.from(parent.context), parent, false) | ||
return VaccinationAppointmentCantonViewHolder(binding) | ||
} | ||
|
||
override fun onBindViewHolder(holder: VaccinationAppointmentCantonViewHolder, position: Int) { | ||
holder.bind(items[position], onCantonClicked) | ||
} | ||
|
||
override fun getItemCount() = items.size | ||
|
||
fun setItems(newItems: List<VaccinationBookingCantonModel>) { | ||
items.clear() | ||
items.addAll(newItems) | ||
notifyDataSetChanged() | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
app/src/main/java/ch/admin/bag/dp3t/vaccination/VaccinationAppointmentCantonViewHolder.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,26 @@ | ||
/* | ||
* Copyright (c) 2021 Ubique Innovation AG <https://www.ubique.ch> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
package ch.admin.bag.dp3t.vaccination | ||
|
||
import androidx.recyclerview.widget.RecyclerView | ||
import ch.admin.bag.dp3t.networking.models.VaccinationBookingCantonModel | ||
import ch.admin.bag.dp3t.databinding.ItemVaccinationAppointmentCantonBinding | ||
|
||
class VaccinationAppointmentCantonViewHolder( | ||
private val binding: ItemVaccinationAppointmentCantonBinding | ||
) : RecyclerView.ViewHolder(binding.root) { | ||
|
||
fun bind(canton: VaccinationBookingCantonModel, onCantonClicked: (VaccinationBookingCantonModel) -> Unit) { | ||
binding.root.setOnClickListener { onCantonClicked.invoke(canton) } | ||
binding.cantonName.text = canton.name | ||
} | ||
|
||
} |
84 changes: 84 additions & 0 deletions
84
app/src/main/java/ch/admin/bag/dp3t/vaccination/VaccinationAppointmentFragment.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,84 @@ | ||
/* | ||
* Copyright (c) 2021 Ubique Innovation AG <https://www.ubique.ch> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
package ch.admin.bag.dp3t.vaccination | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import ch.admin.bag.dp3t.networking.models.VaccinationBookingCantonModel | ||
import ch.admin.bag.dp3t.networking.models.VaccinationBookingInfoModel | ||
import ch.admin.bag.dp3t.R | ||
import ch.admin.bag.dp3t.databinding.FragmentVaccinationAppointmentBinding | ||
import ch.admin.bag.dp3t.storage.SecureStorage | ||
import ch.admin.bag.dp3t.util.UrlUtil | ||
|
||
class VaccinationAppointmentFragment : Fragment() { | ||
|
||
companion object { | ||
@JvmStatic | ||
fun newInstance() = VaccinationAppointmentFragment() | ||
} | ||
|
||
private var _binding: FragmentVaccinationAppointmentBinding? = null | ||
private val binding get() = _binding!! | ||
|
||
private val adapter = VaccinationAppointmentCantonAdapter(this::onCantonClicked) | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { | ||
_binding = FragmentVaccinationAppointmentBinding.inflate(inflater, container, false) | ||
return binding.root | ||
} | ||
|
||
override fun onDestroyView() { | ||
super.onDestroyView() | ||
_binding = null | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
binding.toolbar.setNavigationOnClickListener { parentFragmentManager.popBackStack() } | ||
setupCantonList() | ||
setupMoreInformationButton() | ||
|
||
val secureStorage = SecureStorage.getInstance(context) | ||
secureStorage.getVaccinationBookingInfo(requireContext().getString(R.string.language_key))?.let { | ||
setupVaccinationBookingInfo(it) | ||
} | ||
adapter.setItems( | ||
secureStorage.getVaccinationBookingCantons(requireContext().getString(R.string.language_key)) ?: emptyList() | ||
) | ||
|
||
} | ||
|
||
private fun setupCantonList() { | ||
binding.vaccinationAppointmentCantonList.adapter = adapter | ||
} | ||
|
||
private fun setupVaccinationBookingInfo(vaccinationBookingInfo: VaccinationBookingInfoModel) { | ||
binding.vaccinationBookingTitle.text = vaccinationBookingInfo.title | ||
binding.vaccinationBookingText.text = vaccinationBookingInfo.text | ||
binding.vaccinationBookingInfo.text = vaccinationBookingInfo.info | ||
} | ||
|
||
private fun setupMoreInformationButton() { | ||
binding.vaccinationMoreInfoButton.setOnClickListener { | ||
val url = getString(R.string.vaccination_booking_info_url) | ||
UrlUtil.openUrl(requireContext(), url) | ||
} | ||
} | ||
|
||
private fun onCantonClicked(canton: VaccinationBookingCantonModel) { | ||
UrlUtil.openUrl(requireContext(), canton.linkUrl) | ||
} | ||
|
||
} |
Oops, something went wrong.