aboutsummaryrefslogtreecommitdiff
path: root/anastasis-ui
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-05-16 19:58:31 +0200
committerFlorian Dold <florian@dold.me>2022-05-19 11:05:18 +0200
commit023ea96d26a65d29d408ef78c9405411bb842afd (patch)
tree658717478320443c4dd3cb6c5c906cfa443d2cad /anastasis-ui
parent29e19d02b7befa0c8e18b9c73ac912bb256aa7ee (diff)
downloadtaler-android-023ea96d26a65d29d408ef78c9405411bb842afd.tar.gz
taler-android-023ea96d26a65d29d408ef78c9405411bb842afd.tar.bz2
taler-android-023ea96d26a65d29d408ef78c9405411bb842afd.zip
-remove multiplatform dependency, library upgrade WIP
Diffstat (limited to 'anastasis-ui')
-rw-r--r--anastasis-ui/src/main/java/org/gnu/anastasis/ui/authentication/AuthenticationFragment.kt44
-rw-r--r--anastasis-ui/src/main/java/org/gnu/anastasis/ui/authentication/SecurityQuestionFragment.kt27
-rw-r--r--anastasis-ui/src/main/java/org/gnu/anastasis/ui/authentication/SmsFragment.kt23
-rw-r--r--anastasis-ui/src/main/java/org/gnu/anastasis/ui/authentication/VideoFragment.kt34
-rw-r--r--anastasis-ui/src/main/java/org/gnu/anastasis/ui/identity/ChangeLocationFragment.kt16
5 files changed, 94 insertions, 50 deletions
diff --git a/anastasis-ui/src/main/java/org/gnu/anastasis/ui/authentication/AuthenticationFragment.kt b/anastasis-ui/src/main/java/org/gnu/anastasis/ui/authentication/AuthenticationFragment.kt
index 59d0410..da947b0 100644
--- a/anastasis-ui/src/main/java/org/gnu/anastasis/ui/authentication/AuthenticationFragment.kt
+++ b/anastasis-ui/src/main/java/org/gnu/anastasis/ui/authentication/AuthenticationFragment.kt
@@ -29,10 +29,10 @@ import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.FragmentNavigatorExtras
import androidx.navigation.fragment.findNavController
import com.google.android.material.card.MaterialCardView
-import kotlinx.android.synthetic.main.fragment_authentication.*
-import net.taler.lib.common.Amount
+import net.taler.common.Amount
import org.gnu.anastasis.ui.MainViewModel
import org.gnu.anastasis.ui.R
+import org.gnu.anastasis.ui.databinding.FragmentAuthenticationBinding
class AuthenticationFragment : Fragment() {
@@ -40,6 +40,12 @@ class AuthenticationFragment : Fragment() {
private var price: Amount = Amount.zero("KUDOS")
+ private var _binding: FragmentAuthenticationBinding? = null
+
+ // This property is only valid between onCreateView and
+ // onDestroyView.
+ private val binding get() = _binding!!
+
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
@@ -50,46 +56,46 @@ class AuthenticationFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- passwordCard.setOnClickListener {
+ binding.passwordCard.setOnClickListener {
showDialog(
R.id.action_nav_anastasis_authentication_to_securityQuestionFragment,
- passwordCard,
+ binding.passwordCard,
"question_card"
)
}
- postidentCard.setOnClickListener {
+ binding.postidentCard.setOnClickListener {
toggleCard(
- postidentCard,
+ binding.postidentCard,
Amount.fromJSONString("KUDOS:3.5")
)
}
- smsCard.setOnClickListener {
+ binding.smsCard.setOnClickListener {
showDialog(
R.id.action_nav_anastasis_authentication_to_smsFragment,
- smsCard,
+ binding.smsCard,
"sms_card"
)
}
- videoCard.setOnClickListener {
+ binding.videoCard.setOnClickListener {
showDialog(
R.id.action_nav_anastasis_authentication_to_videoFragment,
- videoCard,
+ binding.videoCard,
"video_card"
)
}
viewModel.securityQuestionChecked.observe(viewLifecycleOwner, { checked ->
- passwordCard.isChecked = checked
+ binding.passwordCard.isChecked = checked
updatePrice(checked, Amount.fromJSONString("KUDOS:0.5"))
updateNextButtonState()
})
viewModel.smsChecked.observe(viewLifecycleOwner, { checked ->
- smsCard.isChecked = checked
+ binding.smsCard.isChecked = checked
updatePrice(checked, Amount.fromJSONString("KUDOS:1.0"))
updateNextButtonState()
})
viewModel.videoChecked.observe(viewLifecycleOwner, { checked ->
- videoCard.isChecked = checked
+ binding.videoCard.isChecked = checked
updatePrice(checked, Amount.fromJSONString("KUDOS:2.25"))
updateNextButtonState()
})
@@ -113,16 +119,16 @@ class AuthenticationFragment : Fragment() {
private fun updatePrice(add: Boolean, amount: Amount) {
if (add) price += amount
else price -= amount
- recoveryCostView.text = "Recovery cost: $price"
+ binding.recoveryCostView.text = "Recovery cost: $price"
}
private fun updateNextButtonState() {
var numChecked = 0
- numChecked += if (passwordCard.isChecked) 1 else 0
- numChecked += if (postidentCard.isChecked) 1 else 0
- numChecked += if (smsCard.isChecked) 1 else 0
- numChecked += if (videoCard.isChecked) 1 else 0
- nextAuthButton.isEnabled = numChecked >= 2
+ numChecked += if (binding.passwordCard.isChecked) 1 else 0
+ numChecked += if (binding.postidentCard.isChecked) 1 else 0
+ numChecked += if (binding.smsCard.isChecked) 1 else 0
+ numChecked += if (binding.videoCard.isChecked) 1 else 0
+ binding.nextAuthButton.isEnabled = numChecked >= 2
}
}
diff --git a/anastasis-ui/src/main/java/org/gnu/anastasis/ui/authentication/SecurityQuestionFragment.kt b/anastasis-ui/src/main/java/org/gnu/anastasis/ui/authentication/SecurityQuestionFragment.kt
index 7353174..0796610 100644
--- a/anastasis-ui/src/main/java/org/gnu/anastasis/ui/authentication/SecurityQuestionFragment.kt
+++ b/anastasis-ui/src/main/java/org/gnu/anastasis/ui/authentication/SecurityQuestionFragment.kt
@@ -23,30 +23,35 @@ import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
-import com.google.android.material.transition.MaterialContainerTransform
-import com.google.android.material.transition.MaterialContainerTransform.FADE_MODE_CROSS
-import kotlinx.android.synthetic.main.fragment_security_question.*
import org.gnu.anastasis.ui.MainViewModel
-import org.gnu.anastasis.ui.R
+import org.gnu.anastasis.ui.databinding.FragmentSecurityQuestionBinding
class SecurityQuestionFragment : Fragment() {
private val viewModel: MainViewModel by activityViewModels()
+ private var _binding: FragmentSecurityQuestionBinding? = null
+
+ // This property is only valid between onCreateView and
+ // onDestroyView.
+ private val binding get() = _binding!!
+
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
- sharedElementEnterTransition = MaterialContainerTransform().apply {
- fadeMode = FADE_MODE_CROSS
- }
- return inflater.inflate(R.layout.fragment_security_question, container, false).apply {
- transitionName = "question_card"
- }
+ _binding = FragmentSecurityQuestionBinding.inflate(inflater, container, false)
+ val view = binding.root
+ return view
+ }
+
+ override fun onDestroyView() {
+ super.onDestroyView()
+ _binding = null
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- saveQuestionButton.setOnClickListener {
+ binding.saveQuestionButton.setOnClickListener {
viewModel.securityQuestionChecked.value = true
findNavController().popBackStack()
}
diff --git a/anastasis-ui/src/main/java/org/gnu/anastasis/ui/authentication/SmsFragment.kt b/anastasis-ui/src/main/java/org/gnu/anastasis/ui/authentication/SmsFragment.kt
index a5d872d..413f472 100644
--- a/anastasis-ui/src/main/java/org/gnu/anastasis/ui/authentication/SmsFragment.kt
+++ b/anastasis-ui/src/main/java/org/gnu/anastasis/ui/authentication/SmsFragment.kt
@@ -32,10 +32,11 @@ import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
import com.google.android.material.transition.MaterialContainerTransform
import com.google.android.material.transition.MaterialContainerTransform.FADE_MODE_CROSS
-import kotlinx.android.synthetic.main.fragment_sms.*
import org.gnu.anastasis.ui.MainViewModel
import org.gnu.anastasis.ui.PERMISSION_REQUEST_CODE
import org.gnu.anastasis.ui.R
+import org.gnu.anastasis.ui.databinding.FragmentSecurityQuestionBinding
+import org.gnu.anastasis.ui.databinding.FragmentSmsBinding
private const val PERMISSION = Manifest.permission.READ_PHONE_STATE
@@ -43,10 +44,17 @@ class SmsFragment : Fragment() {
private val viewModel: MainViewModel by activityViewModels()
+ private var _binding: FragmentSmsBinding? = null
+
+ // This property is only valid between onCreateView and
+ // onDestroyView.
+ private val binding get() = _binding!!
+
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
+ _binding = FragmentSmsBinding.inflate(inflater, container, false)
sharedElementEnterTransition = MaterialContainerTransform().apply {
fadeMode = FADE_MODE_CROSS
}
@@ -55,11 +63,16 @@ class SmsFragment : Fragment() {
}
}
+ override fun onDestroyView() {
+ super.onDestroyView()
+ _binding = null
+ }
+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- smsView.editText?.setOnFocusChangeListener { _, hasFocus ->
+ binding.smsView.editText?.setOnFocusChangeListener { _, hasFocus ->
if (hasFocus) checkPerm()
}
- saveSmsButton.setOnClickListener {
+ binding.saveSmsButton.setOnClickListener {
viewModel.smsChecked.value = true
findNavController().popBackStack()
}
@@ -98,8 +111,8 @@ class SmsFragment : Fragment() {
private fun fillPhoneNumber() {
val telephonyService = requireContext().getSystemService<TelephonyManager>()
telephonyService?.line1Number?.let { phoneNumber ->
- smsView.editText?.setText(phoneNumber)
- smsView.editText?.setSelection(phoneNumber.length)
+ binding.smsView.editText?.setText(phoneNumber)
+ binding.smsView.editText?.setSelection(phoneNumber.length)
}
}
diff --git a/anastasis-ui/src/main/java/org/gnu/anastasis/ui/authentication/VideoFragment.kt b/anastasis-ui/src/main/java/org/gnu/anastasis/ui/authentication/VideoFragment.kt
index 6cd80ce..6716f8a 100644
--- a/anastasis-ui/src/main/java/org/gnu/anastasis/ui/authentication/VideoFragment.kt
+++ b/anastasis-ui/src/main/java/org/gnu/anastasis/ui/authentication/VideoFragment.kt
@@ -35,9 +35,9 @@ import androidx.navigation.fragment.findNavController
import androidx.transition.TransitionManager.beginDelayedTransition
import com.google.android.material.transition.MaterialContainerTransform
import com.google.android.material.transition.MaterialContainerTransform.FADE_MODE_CROSS
-import kotlinx.android.synthetic.main.fragment_video.*
import org.gnu.anastasis.ui.MainViewModel
import org.gnu.anastasis.ui.R
+import org.gnu.anastasis.ui.databinding.FragmentVideoBinding
import java.io.FileDescriptor
private const val REQUEST_IMAGE_CAPTURE = 1
@@ -47,10 +47,17 @@ class VideoFragment : Fragment() {
private val viewModel: MainViewModel by activityViewModels()
+ private var _binding: FragmentVideoBinding? = null
+
+ // This property is only valid between onCreateView and
+ // onDestroyView.
+ private val binding get() = _binding!!
+
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
+ _binding = FragmentVideoBinding.inflate(inflater, container, false)
sharedElementEnterTransition = MaterialContainerTransform().apply {
fadeMode = FADE_MODE_CROSS
}
@@ -59,8 +66,13 @@ class VideoFragment : Fragment() {
}
}
+ override fun onDestroyView() {
+ super.onDestroyView()
+ _binding = null
+ }
+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- takePhotoButton.setOnClickListener {
+ binding.takePhotoButton.setOnClickListener {
val pm = requireContext().packageManager
Intent(MediaStore.ACTION_IMAGE_CAPTURE).also { takePictureIntent ->
takePictureIntent.resolveActivity(pm)?.also {
@@ -70,7 +82,7 @@ class VideoFragment : Fragment() {
}
}
}
- choosePhotoButton.setOnClickListener {
+ binding.choosePhotoButton.setOnClickListener {
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
type = "image/*"
@@ -80,7 +92,7 @@ class VideoFragment : Fragment() {
)
}
- saveVideoButton.setOnClickListener {
+ binding.saveVideoButton.setOnClickListener {
viewModel.videoChecked.value = true
findNavController().popBackStack()
}
@@ -99,12 +111,14 @@ class VideoFragment : Fragment() {
}
private fun showImage(bitmap: Bitmap) {
- photoView.setImageBitmap(bitmap)
- beginDelayedTransition(view as ViewGroup)
- photoView.visibility = VISIBLE
- takePhotoButton.visibility = GONE
- choosePhotoButton.visibility = GONE
- saveVideoButton.isEnabled = true
+ with (binding) {
+ photoView.setImageBitmap(bitmap)
+ beginDelayedTransition(view as ViewGroup)
+ photoView.visibility = VISIBLE
+ takePhotoButton.visibility = GONE
+ choosePhotoButton.visibility = GONE
+ saveVideoButton.isEnabled = true
+ }
}
private fun getBitmapFromUri(uri: Uri): Bitmap {
diff --git a/anastasis-ui/src/main/java/org/gnu/anastasis/ui/identity/ChangeLocationFragment.kt b/anastasis-ui/src/main/java/org/gnu/anastasis/ui/identity/ChangeLocationFragment.kt
index 5b68d36..00eec11 100644
--- a/anastasis-ui/src/main/java/org/gnu/anastasis/ui/identity/ChangeLocationFragment.kt
+++ b/anastasis-ui/src/main/java/org/gnu/anastasis/ui/identity/ChangeLocationFragment.kt
@@ -23,14 +23,20 @@ import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
-import kotlinx.android.synthetic.main.fragment_change_location.*
import org.gnu.anastasis.ui.MainViewModel
import org.gnu.anastasis.ui.R
+import org.gnu.anastasis.ui.databinding.FragmentChangeLocationBinding
class ChangeLocationFragment : Fragment() {
private val viewModel: MainViewModel by activityViewModels()
+ private var _binding: FragmentChangeLocationBinding? = null
+
+ // This property is only valid between onCreateView and
+ // onDestroyView.
+ private val binding get() = _binding!!
+
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
@@ -40,16 +46,16 @@ class ChangeLocationFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- switzerlandView.setOnClickListener {
+ binding.switzerlandView.setOnClickListener {
changeCountry(LOCATIONS[0])
}
- germanyView.setOnClickListener {
+ binding.germanyView.setOnClickListener {
changeCountry(LOCATIONS[1])
}
- usaView.setOnClickListener {
+ binding.usaView.setOnClickListener {
changeCountry(LOCATIONS[2])
}
- indiaView.setOnClickListener {
+ binding.indiaView.setOnClickListener {
changeCountry(LOCATIONS[3])
}
}