diff options
author | Torsten Grote <t@grobox.de> | 2020-09-16 10:21:33 -0300 |
---|---|---|
committer | Torsten Grote <t@grobox.de> | 2020-09-16 10:37:37 -0300 |
commit | c0a8673e9f97fbeb565000fe85d2f1ce55f6e8c2 (patch) | |
tree | afeef27bf7da0683560fb61f887c87e0be410dbc /anastasis-ui/src/main/java | |
parent | 85c2be5713eac244ffbe7a024ed2aa08b9816388 (diff) | |
download | taler-android-c0a8673e9f97fbeb565000fe85d2f1ce55f6e8c2.tar.gz taler-android-c0a8673e9f97fbeb565000fe85d2f1ce55f6e8c2.tar.bz2 taler-android-c0a8673e9f97fbeb565000fe85d2f1ce55f6e8c2.zip |
Make apps work on API 21+ (except cashier that needs 23+)
Diffstat (limited to 'anastasis-ui/src/main/java')
4 files changed, 21 insertions, 14 deletions
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 1e5a8d1..d8f0185 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 @@ -21,7 +21,6 @@ import android.view.LayoutInflater import android.view.View 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_intro.* 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 5f7ab2e..59d0410 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 @@ -26,7 +26,6 @@ import android.widget.Toast.LENGTH_SHORT import androidx.annotation.IdRes import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels -import androidx.lifecycle.Observer import androidx.navigation.fragment.FragmentNavigatorExtras import androidx.navigation.fragment.findNavController import com.google.android.material.card.MaterialCardView 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 2daf14a..a5d872d 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 @@ -26,6 +26,7 @@ import android.view.View import android.view.ViewGroup import androidx.annotation.RequiresPermission import androidx.core.content.ContextCompat +import androidx.core.content.getSystemService import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.navigation.fragment.findNavController @@ -95,7 +96,7 @@ class SmsFragment : Fragment() { @SuppressLint("HardwareIds") @RequiresPermission(PERMISSION) private fun fillPhoneNumber() { - val telephonyService = requireContext().getSystemService(TelephonyManager::class.java) + val telephonyService = requireContext().getSystemService<TelephonyManager>() telephonyService?.line1Number?.let { phoneNumber -> smsView.editText?.setText(phoneNumber) smsView.editText?.setSelection(phoneNumber.length) 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 bcfbf24..ad97ab6 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 @@ -18,15 +18,18 @@ package org.gnu.anastasis.ui.identity import android.annotation.SuppressLint import android.app.DatePickerDialog +import android.os.Build.VERSION.SDK_INT import android.os.Bundle import android.telephony.TelephonyManager import android.text.format.DateFormat.getDateFormat import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.Toast +import android.widget.Toast.LENGTH_LONG +import androidx.core.content.getSystemService import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels -import androidx.lifecycle.Observer import androidx.navigation.fragment.findNavController import kotlinx.android.synthetic.main.fragment_identity.* import org.gnu.anastasis.ui.MainViewModel @@ -63,17 +66,22 @@ class AnastasisIdentityFragment : Fragment() { findNavController().navigate(R.id.action_nav_anastasis_identity_to_nav_change_location) } birthDateInput.editText?.setOnClickListener { - val picker = DatePickerDialog(requireContext()) - picker.datePicker.maxDate = System.currentTimeMillis() - DAYS.toMillis(365) * MIN_AGE - picker.setOnDateSetListener { _, year, month, dayOfMonth -> - val calender = Calendar.getInstance().apply { - set(year, month, dayOfMonth) + if (SDK_INT >= 24) { + val picker = DatePickerDialog(requireContext()) + picker.datePicker.maxDate = + System.currentTimeMillis() - DAYS.toMillis(365) * MIN_AGE + picker.setOnDateSetListener { _, year, month, dayOfMonth -> + val calender = Calendar.getInstance().apply { + set(year, month, dayOfMonth) + } + val date = Date(calender.timeInMillis) + val dateStr = getDateFormat(requireContext()).format(date) + birthDateInput.editText?.setText(dateStr) } - val date = Date(calender.timeInMillis) - val dateStr = getDateFormat(requireContext()).format(date) - birthDateInput.editText?.setText(dateStr) + picker.show() + } else { + Toast.makeText(requireContext(), "Needs newer phone", LENGTH_LONG).show() } - picker.show() } createIdentifierButton.setOnClickListener { findNavController().navigate(R.id.action_nav_anastasis_intro_to_nav_anastasis_authentication) @@ -82,7 +90,7 @@ class AnastasisIdentityFragment : Fragment() { @Suppress("unused") private fun getCountryName(): String { - val tm = requireContext().getSystemService(TelephonyManager::class.java)!! + val tm = requireContext().getSystemService<TelephonyManager>()!! val countryIso = if (tm.networkCountryIso.isNullOrEmpty()) { if (tm.simCountryIso.isNullOrEmpty()) { if (Locale.getDefault().country.isNullOrEmpty()) "unknown" |