aboutsummaryrefslogtreecommitdiff
path: root/anastasis-ui
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-05-16 16:46:12 +0200
committerFlorian Dold <florian@dold.me>2022-05-16 16:46:12 +0200
commite6e58ecebe107deeb4a050652fc53c899beab3a6 (patch)
treef2047b0435fca5f45b3577a4a71f8e75f82ae22a /anastasis-ui
parent22e5e8034d2891f04568e724baa8b5c95660b897 (diff)
downloadtaler-android-e6e58ecebe107deeb4a050652fc53c899beab3a6.tar.gz
taler-android-e6e58ecebe107deeb4a050652fc53c899beab3a6.tar.bz2
taler-android-e6e58ecebe107deeb4a050652fc53c899beab3a6.zip
-migrate away from deprecated library (Kotlin synthetics)
Diffstat (limited to 'anastasis-ui')
-rw-r--r--anastasis-ui/build.gradle10
-rw-r--r--anastasis-ui/src/main/java/org/gnu/anastasis/ui/IntroFragment.kt19
-rw-r--r--anastasis-ui/src/main/java/org/gnu/anastasis/ui/MainActivity.kt8
-rw-r--r--anastasis-ui/src/main/java/org/gnu/anastasis/ui/identity/IdentityFragment.kt35
4 files changed, 52 insertions, 20 deletions
diff --git a/anastasis-ui/build.gradle b/anastasis-ui/build.gradle
index 62b226d..2275496 100644
--- a/anastasis-ui/build.gradle
+++ b/anastasis-ui/build.gradle
@@ -16,16 +16,15 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
-apply plugin: 'kotlin-android-extensions'
android {
- compileSdkVersion 30
+ compileSdkVersion 32
//noinspection GradleDependency
buildToolsVersion "$build_tools_version"
defaultConfig {
minSdkVersion 21
- targetSdkVersion 30
+ targetSdkVersion 32
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
@@ -50,6 +49,11 @@ android {
kotlinOptions {
jvmTarget = "1.8"
}
+
+ buildFeatures {
+ viewBinding true
+ }
+
namespace 'org.gnu.anastasis.ui'
}
diff --git a/anastasis-ui/src/main/java/org/gnu/anastasis/ui/IntroFragment.kt b/anastasis-ui/src/main/java/org/gnu/anastasis/ui/IntroFragment.kt
index d8f0185..ef2e190 100644
--- a/anastasis-ui/src/main/java/org/gnu/anastasis/ui/IntroFragment.kt
+++ b/anastasis-ui/src/main/java/org/gnu/anastasis/ui/IntroFragment.kt
@@ -22,21 +22,34 @@ import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
-import kotlinx.android.synthetic.main.fragment_intro.*
+import org.gnu.anastasis.ui.databinding.FragmentIntroBinding
class IntroFragment : Fragment() {
+ private var _binding: FragmentIntroBinding? = 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? {
- return inflater.inflate(R.layout.fragment_intro, container, false)
+ _binding = FragmentIntroBinding.inflate(inflater, container, false)
+ val view = binding.root
+ return view
+ }
+
+ override fun onDestroyView() {
+ super.onDestroyView()
+ _binding = null
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- button.setOnClickListener {
+ binding.button.setOnClickListener {
findNavController().navigate(R.id.action_nav_anastasis_intro_to_nav_anastasis_identity)
}
}
diff --git a/anastasis-ui/src/main/java/org/gnu/anastasis/ui/MainActivity.kt b/anastasis-ui/src/main/java/org/gnu/anastasis/ui/MainActivity.kt
index ac355c1..d7870cb 100644
--- a/anastasis-ui/src/main/java/org/gnu/anastasis/ui/MainActivity.kt
+++ b/anastasis-ui/src/main/java/org/gnu/anastasis/ui/MainActivity.kt
@@ -22,7 +22,7 @@ import androidx.navigation.NavController
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.setupWithNavController
-import kotlinx.android.synthetic.main.activity.*
+import org.gnu.anastasis.ui.databinding.ActivityBinding
internal const val PERMISSION_REQUEST_CODE = 1
@@ -30,6 +30,8 @@ class MainActivity : AppCompatActivity() {
private lateinit var nav: NavController
+ private lateinit var binding: ActivityBinding
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity)
@@ -38,11 +40,11 @@ class MainActivity : AppCompatActivity() {
supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment
nav = navHostFragment.navController
- setSupportActionBar(toolbar)
+ setSupportActionBar(binding.toolbar)
val appBarConfiguration = AppBarConfiguration(
emptySet()
)
- toolbar.setupWithNavController(nav, appBarConfiguration)
+ binding.toolbar.setupWithNavController(nav, appBarConfiguration)
}
}
diff --git a/anastasis-ui/src/main/java/org/gnu/anastasis/ui/identity/IdentityFragment.kt b/anastasis-ui/src/main/java/org/gnu/anastasis/ui/identity/IdentityFragment.kt
index ad97ab6..73ae629 100644
--- a/anastasis-ui/src/main/java/org/gnu/anastasis/ui/identity/IdentityFragment.kt
+++ b/anastasis-ui/src/main/java/org/gnu/anastasis/ui/identity/IdentityFragment.kt
@@ -31,9 +31,9 @@ import androidx.core.content.getSystemService
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
-import kotlinx.android.synthetic.main.fragment_identity.*
import org.gnu.anastasis.ui.MainViewModel
import org.gnu.anastasis.ui.R
+import org.gnu.anastasis.ui.databinding.FragmentIdentityBinding
import java.util.Calendar
import java.util.Date
import java.util.Locale
@@ -45,27 +45,40 @@ class AnastasisIdentityFragment : Fragment() {
private val model: MainViewModel by activityViewModels()
+ private var _binding: FragmentIdentityBinding? = null
+
+ // This property is only valid between onCreateView and
+ // onDestroyView.
+ private val binding get() = _binding!!
+
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
- savedInstanceState: Bundle?
+ savedInstanceState: Bundle?,
): View? {
- return inflater.inflate(R.layout.fragment_identity, container, false)
+ _binding = FragmentIdentityBinding.inflate(inflater, container, false)
+ val view = binding.root
+ return view
+ }
+
+ override fun onDestroyView() {
+ super.onDestroyView()
+ _binding = null
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
model.currentCountry.observe(viewLifecycleOwner, { country ->
- countryView.text = country.name
- if (stub != null) {
- stub.layoutResource = country.layoutRes
- stub.inflate()
+ binding.countryView.text = country.name
+ if (binding.stub != null) {
+ binding.stub.layoutResource = country.layoutRes
+ binding.stub.inflate()
}
})
- changeCountryView.setOnClickListener {
+ binding.changeCountryView.setOnClickListener {
findNavController().navigate(R.id.action_nav_anastasis_identity_to_nav_change_location)
}
- birthDateInput.editText?.setOnClickListener {
+ binding.birthDateInput.editText?.setOnClickListener {
if (SDK_INT >= 24) {
val picker = DatePickerDialog(requireContext())
picker.datePicker.maxDate =
@@ -76,14 +89,14 @@ class AnastasisIdentityFragment : Fragment() {
}
val date = Date(calender.timeInMillis)
val dateStr = getDateFormat(requireContext()).format(date)
- birthDateInput.editText?.setText(dateStr)
+ binding.birthDateInput.editText?.setText(dateStr)
}
picker.show()
} else {
Toast.makeText(requireContext(), "Needs newer phone", LENGTH_LONG).show()
}
}
- createIdentifierButton.setOnClickListener {
+ binding.createIdentifierButton.setOnClickListener {
findNavController().navigate(R.id.action_nav_anastasis_intro_to_nav_anastasis_authentication)
}
}