diff options
36 files changed, 84 insertions, 73 deletions
diff --git a/anastasis-ui/build.gradle b/anastasis-ui/build.gradle index cbb0077..17e9530 100644 --- a/anastasis-ui/build.gradle +++ b/anastasis-ui/build.gradle @@ -24,7 +24,7 @@ android { buildToolsVersion "$build_tools_version" defaultConfig { - minSdkVersion 24 + minSdkVersion 21 targetSdkVersion 29 versionCode 1 versionName "0.1" 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" diff --git a/anastasis-ui/src/main/res/layout/fragment_identity.xml b/anastasis-ui/src/main/res/layout/fragment_identity.xml index bcf6e4d..4a48d32 100644 --- a/anastasis-ui/src/main/res/layout/fragment_identity.xml +++ b/anastasis-ui/src/main/res/layout/fragment_identity.xml @@ -16,6 +16,7 @@ <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true"> @@ -31,7 +32,8 @@ android:layout_margin="16dp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" - app:srcCompat="@drawable/ic_baseline_person" /> + app:srcCompat="@drawable/ic_baseline_person" + tools:ignore="ContentDescription" /> <TextView android:id="@+id/identityIntro" diff --git a/anastasis-ui/src/main/res/layout/fragment_intro.xml b/anastasis-ui/src/main/res/layout/fragment_intro.xml index 32b5b33..04e5d60 100644 --- a/anastasis-ui/src/main/res/layout/fragment_intro.xml +++ b/anastasis-ui/src/main/res/layout/fragment_intro.xml @@ -16,6 +16,7 @@ <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> @@ -33,7 +34,8 @@ app:layout_constraintVertical_bias="1.0" app:layout_constraintVertical_chainStyle="spread" app:srcCompat="@drawable/ic_baseline_cloud_circle" - app:tint="@color/green" /> + app:tint="@color/green" + tools:ignore="ContentDescription" /> <TextView android:id="@+id/textView" diff --git a/anastasis-ui/src/main/res/layout/fragment_security_question.xml b/anastasis-ui/src/main/res/layout/fragment_security_question.xml index 4df4f97..5a7c41f 100644 --- a/anastasis-ui/src/main/res/layout/fragment_security_question.xml +++ b/anastasis-ui/src/main/res/layout/fragment_security_question.xml @@ -16,6 +16,7 @@ <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> @@ -80,11 +81,12 @@ android:layout_height="wrap_content" android:layout_margin="16dp" android:background="?attr/selectableItemBackground" - android:drawableTint="?attr/colorOnPrimarySurface" android:src="@drawable/ic_add_circle" android:text="Save" + app:drawableTint="?attr/colorOnPrimarySurface" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintTop_toBottomOf="@+id/questionCard" /> + app:layout_constraintTop_toBottomOf="@+id/questionCard" + tools:ignore="ContentDescription" /> <Button android:id="@+id/saveQuestionButton" @@ -92,8 +94,8 @@ android:layout_height="wrap_content" android:layout_margin="16dp" android:backgroundTint="@color/green" - android:drawableTint="?attr/colorOnPrimarySurface" android:text="Save" + app:drawableTint="?attr/colorOnPrimarySurface" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" /> diff --git a/anastasis-ui/src/main/res/layout/fragment_sms.xml b/anastasis-ui/src/main/res/layout/fragment_sms.xml index f855d38..c80f892 100644 --- a/anastasis-ui/src/main/res/layout/fragment_sms.xml +++ b/anastasis-ui/src/main/res/layout/fragment_sms.xml @@ -43,8 +43,8 @@ android:layout_height="wrap_content" android:layout_margin="16dp" android:backgroundTint="@color/green" - android:drawableTint="?attr/colorOnPrimarySurface" android:text="Save" + app:drawableTint="?attr/colorOnPrimarySurface" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" /> diff --git a/anastasis-ui/src/main/res/layout/fragment_video.xml b/anastasis-ui/src/main/res/layout/fragment_video.xml index c08e269..ecdd102 100644 --- a/anastasis-ui/src/main/res/layout/fragment_video.xml +++ b/anastasis-ui/src/main/res/layout/fragment_video.xml @@ -47,12 +47,12 @@ android:layout_margin="16dp" android:scaleType="fitCenter" android:visibility="gone" - tools:visibility="visible" app:layout_constraintBottom_toTopOf="@+id/saveVideoButton" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/videoIntro" - tools:srcCompat="@tools:sample/avatars" /> + tools:srcCompat="@tools:sample/avatars" + tools:visibility="visible" /> <Button android:id="@+id/takePhotoButton" @@ -80,9 +80,9 @@ android:layout_height="wrap_content" android:layout_margin="16dp" android:backgroundTint="@color/green" - android:drawableTint="?attr/colorOnPrimarySurface" android:enabled="false" android:text="Save" + app:drawableTint="?attr/colorOnPrimarySurface" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" /> diff --git a/cashier/build.gradle b/cashier/build.gradle index a749353..337a427 100644 --- a/cashier/build.gradle +++ b/cashier/build.gradle @@ -28,7 +28,7 @@ android { defaultConfig { applicationId "net.taler.cashier" - minSdkVersion 24 + minSdkVersion 23 targetSdkVersion 29 versionCode 1 versionName "0.1" @@ -70,7 +70,7 @@ android { dependencies { implementation project(":taler-kotlin-android") implementation "androidx.constraintlayout:constraintlayout:$constraintlayout_version" - implementation 'androidx.security:security-crypto:1.0.0-rc03' + implementation 'androidx.security:security-crypto:1.0.0-rc03' // requires minSdk 23 implementation "com.google.android.material:material:$material_version" implementation "androidx.navigation:navigation-fragment-ktx:$nav_version" diff --git a/cashier/proguard-rules.pro b/cashier/proguard-rules.pro index a1cc1f6..ced7b5c 100644 --- a/cashier/proguard-rules.pro +++ b/cashier/proguard-rules.pro @@ -20,6 +20,7 @@ # hide the original source file name. #-renamesourcefileattribute SourceFile +#noinspection ShrinkerUnresolvedReference -keep class net.taler.cashier.** {*;} # androidx.security:security-crypto diff --git a/cashier/src/main/java/net/taler/cashier/BalanceFragment.kt b/cashier/src/main/java/net/taler/cashier/BalanceFragment.kt index 541bca2..86ace20 100644 --- a/cashier/src/main/java/net/taler/cashier/BalanceFragment.kt +++ b/cashier/src/main/java/net/taler/cashier/BalanceFragment.kt @@ -27,7 +27,6 @@ import android.view.ViewGroup import android.view.inputmethod.EditorInfo import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels -import androidx.lifecycle.Observer import androidx.navigation.fragment.findNavController import net.taler.cashier.BalanceFragmentDirections.Companion.actionBalanceFragmentToTransactionFragment import net.taler.cashier.databinding.FragmentBalanceBinding diff --git a/cashier/src/main/res/layout-w550dp/fragment_balance.xml b/cashier/src/main/res/layout-w550dp/fragment_balance.xml index bcfffc7..5023aba 100644 --- a/cashier/src/main/res/layout-w550dp/fragment_balance.xml +++ b/cashier/src/main/res/layout-w550dp/fragment_balance.xml @@ -208,9 +208,9 @@ android:layout_margin="@dimen/default_margin" android:backgroundTint="@color/green" android:drawableLeft="@drawable/ic_withdraw" - android:drawableTint="?attr/colorOnPrimarySurface" android:text="@string/withdraw_button_confirm" android:visibility="invisible" + app:drawableTint="?attr/colorOnPrimarySurface" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="@+id/guideline" diff --git a/cashier/src/main/res/layout/fragment_balance.xml b/cashier/src/main/res/layout/fragment_balance.xml index 5a11b2a..b8a8012 100644 --- a/cashier/src/main/res/layout/fragment_balance.xml +++ b/cashier/src/main/res/layout/fragment_balance.xml @@ -211,9 +211,9 @@ android:layout_margin="@dimen/default_margin" android:backgroundTint="@color/green" android:drawableLeft="@drawable/ic_withdraw" - android:drawableTint="?attr/colorOnPrimarySurface" android:text="@string/withdraw_button_confirm" android:visibility="invisible" + app:drawableTint="?attr/colorOnPrimarySurface" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.5" diff --git a/cashier/src/main/res/values/strings.xml b/cashier/src/main/res/values/strings.xml index 0400f82..4a8064f 100644 --- a/cashier/src/main/res/values/strings.xml +++ b/cashier/src/main/res/values/strings.xml @@ -1,4 +1,4 @@ -<resources xmlns:tools="http://schemas.android.com/tools"> +<resources> <string name="app_name">Taler Cashier</string> <string name="config_bank_url">Bank API address</string> diff --git a/merchant-terminal/build.gradle b/merchant-terminal/build.gradle index d56dd5c..1f803cb 100644 --- a/merchant-terminal/build.gradle +++ b/merchant-terminal/build.gradle @@ -12,7 +12,7 @@ android { defaultConfig { applicationId "net.taler.merchantpos" - minSdkVersion 24 + minSdkVersion 21 targetSdkVersion 29 versionCode 2 versionName "0.1" @@ -78,5 +78,5 @@ dependencies { implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0" testImplementation 'androidx.test.ext:junit:1.1.2' - testImplementation 'org.robolectric:robolectric:4.3.1' + testImplementation 'org.robolectric:robolectric:4.4' } diff --git a/merchant-terminal/proguard-rules.pro b/merchant-terminal/proguard-rules.pro index 1a50a50..f417733 100644 --- a/merchant-terminal/proguard-rules.pro +++ b/merchant-terminal/proguard-rules.pro @@ -20,4 +20,5 @@ # hide the original source file name. #-renamesourcefileattribute SourceFile +#noinspection ShrinkerUnresolvedReference -keep class net.taler.merchantpos.** {*;} diff --git a/merchant-terminal/src/main/java/net/taler/merchantpos/history/HistoryItemAdapter.kt b/merchant-terminal/src/main/java/net/taler/merchantpos/history/HistoryItemAdapter.kt index 25e94fb..4643cb4 100644 --- a/merchant-terminal/src/main/java/net/taler/merchantpos/history/HistoryItemAdapter.kt +++ b/merchant-terminal/src/main/java/net/taler/merchantpos/history/HistoryItemAdapter.kt @@ -21,6 +21,7 @@ import android.view.View import android.view.ViewGroup import android.widget.ImageButton import android.widget.TextView +import androidx.core.content.ContextCompat.getColor import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView.Adapter import net.taler.common.toRelativeTime @@ -73,7 +74,7 @@ internal class HistoryItemAdapter(private val listener: RefundClickListener) : orderIdView.setTextColor(orderIdColor) } else { orderIdView.text = v.context.getString(R.string.history_unpaid) - orderIdView.setTextColor(v.context.getColor(R.color.red)) + orderIdView.setTextColor(getColor(v.context, R.color.red)) } if (item.refundable) { refundButton.visibility = View.VISIBLE diff --git a/merchant-terminal/src/main/java/net/taler/merchantpos/order/Order.kt b/merchant-terminal/src/main/java/net/taler/merchantpos/order/Order.kt index 4fc2907..0bea20c 100644 --- a/merchant-terminal/src/main/java/net/taler/merchantpos/order/Order.kt +++ b/merchant-terminal/src/main/java/net/taler/merchantpos/order/Order.kt @@ -84,7 +84,7 @@ data class Order(val id: Int, val currency: String, val availableCategories: Map * Returns a map of i18n summaries for each locale present in *all* given [Category]s * or null if there's no locale that fulfills this criteria. */ - val summaryI18n: Map<String, String>? + private val summaryI18n: Map<String, String>? get() { if (products.size == 1) return products[0].descriptionI18n val categoryQuantities = getCategoryQuantities() diff --git a/merchant-terminal/src/main/java/net/taler/merchantpos/refund/RefundFragment.kt b/merchant-terminal/src/main/java/net/taler/merchantpos/refund/RefundFragment.kt index 5306b2f..bb98dbd 100644 --- a/merchant-terminal/src/main/java/net/taler/merchantpos/refund/RefundFragment.kt +++ b/merchant-terminal/src/main/java/net/taler/merchantpos/refund/RefundFragment.kt @@ -24,8 +24,6 @@ import androidx.annotation.StringRes import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.navigation.fragment.findNavController -import com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_LONG -import com.google.android.material.snackbar.Snackbar import net.taler.common.fadeIn import net.taler.common.fadeOut import net.taler.common.navigate diff --git a/taler-kotlin-android/README.md b/taler-kotlin-android/README.md new file mode 100644 index 0000000..c5273de --- /dev/null +++ b/taler-kotlin-android/README.md @@ -0,0 +1,6 @@ +# GNU Taler Kotlin Library for Android + +This library provided basic GNU Taler functionality to Android apps. + +Warning: If you use this library and need bar code scanning, please target at least SDK version 24 + or set `coreLibraryDesugaringEnabled` to `true` in `android.compileOptions`. diff --git a/taler-kotlin-android/build.gradle b/taler-kotlin-android/build.gradle index acd2dc7..d06fde3 100644 --- a/taler-kotlin-android/build.gradle +++ b/taler-kotlin-android/build.gradle @@ -27,7 +27,7 @@ android { buildToolsVersion "$build_tools_version" defaultConfig { - minSdkVersion 24 + minSdkVersion 21 targetSdkVersion 29 versionCode 1 versionName "0.1" @@ -72,7 +72,7 @@ dependencies { implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version" // QR codes - implementation 'com.google.zxing:core:3.4.0' // needs minSdkVersion 24+ + implementation 'com.google.zxing:core:3.4.0' // needs minSdkVersion 24+ or desugar // Logcat viewer implementation('com.github.pedrovgs:lynx:1.1.0') { diff --git a/taler-kotlin-android/src/main/AndroidManifest.xml b/taler-kotlin-android/src/main/AndroidManifest.xml index 902ddc1..f74aae6 100644 --- a/taler-kotlin-android/src/main/AndroidManifest.xml +++ b/taler-kotlin-android/src/main/AndroidManifest.xml @@ -15,8 +15,11 @@ --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" package="net.taler.common"> + <uses-sdk tools:overrideLibrary="com.google.zxing.client.android" /> + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.NFC" /> diff --git a/wallet/build.gradle b/wallet/build.gradle index b5720be..02123ee 100644 --- a/wallet/build.gradle +++ b/wallet/build.gradle @@ -45,7 +45,7 @@ android { defaultConfig { applicationId "net.taler.wallet" - minSdkVersion 24 + minSdkVersion 21 targetSdkVersion 29 versionCode 8 versionName "v0.8.0-rc.3" @@ -82,6 +82,9 @@ android { compileOptions { sourceCompatibility = 1.8 targetCompatibility = 1.8 + + // Flag to enable support for the new language APIs for zxing + coreLibraryDesugaringEnabled true } kotlinOptions { @@ -129,6 +132,8 @@ dependencies { // QR codes implementation 'com.journeyapps:zxing-android-embedded:4.0.2@aar' + // needed to support zxing library in taler-kotlin-android on API < 24 + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.10' // Nicer ProgressBar implementation 'me.zhanghai.android.materialprogressbar:library:1.6.1' diff --git a/wallet/fastlane/Fastfile b/wallet/fastlane/Fastfile index 3c2f8cd..695540c 100644 --- a/wallet/fastlane/Fastfile +++ b/wallet/fastlane/Fastfile @@ -42,7 +42,7 @@ platform :android do skip_upload_images: 'true', skip_upload_screenshots: 'true', skip_upload_apk: 'true', # This is an app bundle, so APK is not possible - validate_only: 'true' + validate_only: 'false' ) end end diff --git a/wallet/proguard-rules.pro b/wallet/proguard-rules.pro index 27f3799..ca6bc15 100644 --- a/wallet/proguard-rules.pro +++ b/wallet/proguard-rules.pro @@ -22,4 +22,5 @@ -keep class akono.AkonoJni {*;} +#noinspection ShrinkerUnresolvedReference -keep class net.taler.wallet.** {*;} diff --git a/wallet/src/main/AndroidManifest.xml b/wallet/src/main/AndroidManifest.xml index e2a79da..b011583 100644 --- a/wallet/src/main/AndroidManifest.xml +++ b/wallet/src/main/AndroidManifest.xml @@ -32,14 +32,15 @@ <application android:allowBackup="true" + android:extractNativeLibs="true" android:fullBackupContent="@xml/backup_descriptor" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme" - android:extractNativeLibs="true" - tools:ignore="GoogleAppIndexingWarning"> + tools:ignore="GoogleAppIndexingWarning" + tools:targetApi="m"> <activity android:name=".MainActivity" diff --git a/wallet/src/main/java/net/taler/wallet/UriInputFragment.kt b/wallet/src/main/java/net/taler/wallet/UriInputFragment.kt index d17977b..f4a5f23 100644 --- a/wallet/src/main/java/net/taler/wallet/UriInputFragment.kt +++ b/wallet/src/main/java/net/taler/wallet/UriInputFragment.kt @@ -26,6 +26,7 @@ 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 net.taler.wallet.databinding.FragmentUriInputBinding @@ -43,10 +44,10 @@ class UriInputFragment : Fragment() { } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - val clipboard = requireContext().getSystemService(ClipboardManager::class.java)!! + val clipboard = requireContext().getSystemService<ClipboardManager>() ui.pasteButton.setOnClickListener { - val item = clipboard.primaryClip?.getItemAt(0) + val item = clipboard?.primaryClip?.getItemAt(0) if (item?.text != null) { ui.uriView.setText(item.text) } else { diff --git a/wallet/src/main/java/net/taler/wallet/Utils.kt b/wallet/src/main/java/net/taler/wallet/Utils.kt index ea01552..388bf61 100644 --- a/wallet/src/main/java/net/taler/wallet/Utils.kt +++ b/wallet/src/main/java/net/taler/wallet/Utils.kt @@ -29,8 +29,8 @@ import android.os.Build.VERSION.SDK_INT import android.widget.Toast import android.widget.Toast.LENGTH_LONG import androidx.annotation.RequiresApi +import androidx.core.content.getSystemService import com.google.zxing.integration.android.IntentIntegrator -import org.json.JSONObject fun scanQrCode(activity: Activity) { IntentIntegrator(activity).apply { @@ -69,7 +69,7 @@ private fun connectToWifi29(context: Context, ssid: String) { @Suppress("DEPRECATION") private fun connectToWifiDeprecated(context: Context, ssid: String) { - context.getSystemService(WifiManager::class.java)?.apply { + context.getSystemService<WifiManager>()?.apply { if (!isWifiEnabled) { val enabledResult = setWifiEnabled(true) while (enabledResult && !isWifiEnabled) Thread.sleep(25) @@ -91,22 +91,6 @@ private fun connectToWifiDeprecated(context: Context, ssid: String) { } } -fun getErrorString(json: JSONObject): String { - return StringBuilder().apply { - append(json.getString("talerErrorCode")) - append(" ") - append(json.getString("message")) - json.optJSONObject("details")?.let { details -> - details.optJSONObject("errorResponse")?.let { errorResponse -> - append("\n\n") - append(errorResponse.optString("code")) - append(" ") - append(errorResponse.optString("hint")) - } - } - }.toString() -} - fun cleanExchange(exchange: String) = exchange.let { if (it.startsWith("https://")) it.substring(8) else it }.trimEnd('/') diff --git a/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt b/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt index 936bbbd..5e492f5 100644 --- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt +++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt @@ -25,6 +25,7 @@ import android.view.View.VISIBLE import android.view.ViewGroup import android.widget.ImageView import android.widget.TextView +import androidx.core.content.ContextCompat.getColor import androidx.recyclerview.selection.ItemDetailsLookup import androidx.recyclerview.selection.ItemKeyProvider import androidx.recyclerview.selection.SelectionTracker @@ -80,13 +81,11 @@ internal class TransactionAdapter( private val amount: TextView = v.findViewById(R.id.amount) private val pendingView: TextView = v.findViewById(R.id.pendingView) - private val selectableForeground = v.foreground private val amountColor = amount.currentTextColor - private val red = context.getColor(R.color.red) - private val green = context.getColor(R.color.green) + private val red = getColor(context, R.color.red) + private val green = getColor(context, R.color.green) fun bind(transaction: Transaction, selected: Boolean) { - v.foreground = selectableForeground v.setOnClickListener { listener.onTransactionClicked(transaction) } v.isActivated = selected if (transaction.error == null) { diff --git a/wallet/src/main/java/net/taler/wallet/withdraw/ManualWithdrawFragment.kt b/wallet/src/main/java/net/taler/wallet/withdraw/ManualWithdrawFragment.kt index 4b56dd0..f368c68 100644 --- a/wallet/src/main/java/net/taler/wallet/withdraw/ManualWithdrawFragment.kt +++ b/wallet/src/main/java/net/taler/wallet/withdraw/ManualWithdrawFragment.kt @@ -53,7 +53,7 @@ class ManualWithdrawFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { ui.qrCodeButton.setOnClickListener { scanQrCode(requireActivity()) } ui.currencyView.text = exchangeItem.currency - val paymentOptions = exchangeItem.paytoUris.mapNotNull {paytoUri -> + val paymentOptions = exchangeItem.paytoUris.mapNotNull { paytoUri -> Uri.parse(paytoUri).authority?.toUpperCase(Locale.getDefault()) }.joinToString(separator = "\n", prefix = "• ") ui.paymentOptionsLabel.text = diff --git a/wallet/src/main/res/layout/fragment_transaction_withdrawal.xml b/wallet/src/main/res/layout/fragment_transaction_withdrawal.xml index 5a1e82f..8fe3247 100644 --- a/wallet/src/main/res/layout/fragment_transaction_withdrawal.xml +++ b/wallet/src/main/res/layout/fragment_transaction_withdrawal.xml @@ -60,8 +60,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:drawableLeft="@drawable/ic_account_balance" - android:drawableTint="?attr/colorOnPrimarySurface" android:text="@string/withdraw_button_confirm_bank" + app:drawableTint="?attr/colorOnPrimarySurface" app:layout_constraintBottom_toTopOf="@+id/chosenAmountLabel" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" diff --git a/wallet/src/main/res/layout/fragment_uri_input.xml b/wallet/src/main/res/layout/fragment_uri_input.xml index 60155e3..1e9934f 100644 --- a/wallet/src/main/res/layout/fragment_uri_input.xml +++ b/wallet/src/main/res/layout/fragment_uri_input.xml @@ -51,8 +51,8 @@ android:layout_marginEnd="16dp" android:layout_weight="1" android:drawableLeft="@drawable/ic_content_paste" - android:drawableTint="?attr/colorOnPrimarySurface" android:text="@string/paste" + app:drawableTint="?attr/colorOnPrimarySurface" app:layout_constraintEnd_toStartOf="@+id/okButton" app:layout_constraintHorizontal_chainStyle="spread_inside" app:layout_constraintStart_toStartOf="parent" diff --git a/wallet/src/main/res/layout/list_item_exchange.xml b/wallet/src/main/res/layout/list_item_exchange.xml index c9d1df4..d81e759 100644 --- a/wallet/src/main/res/layout/list_item_exchange.xml +++ b/wallet/src/main/res/layout/list_item_exchange.xml @@ -19,8 +19,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@drawable/selectable_background" - android:foreground="?attr/selectableItemBackground" + android:background="?attr/selectableItemBackground" android:paddingTop="16dp" android:paddingBottom="16dp"> diff --git a/wallet/src/main/res/layout/list_item_transaction.xml b/wallet/src/main/res/layout/list_item_transaction.xml index 239e656..ed031c3 100644 --- a/wallet/src/main/res/layout/list_item_transaction.xml +++ b/wallet/src/main/res/layout/list_item_transaction.xml @@ -19,8 +19,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@drawable/selectable_background" - android:foreground="?attr/selectableItemBackground" + android:background="?attr/selectableItemBackground" android:paddingStart="16dp" android:paddingTop="8dp" android:paddingEnd="16dp" |