diff options
author | Torsten Grote <t@grobox.de> | 2020-09-08 16:49:28 -0300 |
---|---|---|
committer | Torsten Grote <t@grobox.de> | 2020-09-08 16:49:28 -0300 |
commit | d351f89cce722485033711f90edaf5a0f28e81ae (patch) | |
tree | 50746414671125d5c35b3da8ae6799b8bc62c3c1 | |
parent | 310775d1cb7a177641c704efb1a98a7ccaac67b3 (diff) | |
download | taler-android-d351f89cce722485033711f90edaf5a0f28e81ae.tar.gz taler-android-d351f89cce722485033711f90edaf5a0f28e81ae.tar.bz2 taler-android-d351f89cce722485033711f90edaf5a0f28e81ae.zip |
Fix minor lint warnings
18 files changed, 42 insertions, 67 deletions
diff --git a/anastasis-ui/build.gradle b/anastasis-ui/build.gradle index 0f86815..cbb0077 100644 --- a/anastasis-ui/build.gradle +++ b/anastasis-ui/build.gradle @@ -57,8 +57,8 @@ android { dependencies { implementation project(":taler-kotlin-android") - implementation 'com.google.android.material:material:1.2.0-beta01' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation "com.google.android.material:material:$material_version" + implementation "androidx.constraintlayout:constraintlayout:$constraintlayout_version" // Navigation Library implementation "androidx.navigation:navigation-fragment-ktx:$nav_version" @@ -69,6 +69,6 @@ dependencies { testImplementation 'junit:junit:4.13' - androidTestImplementation 'androidx.test.ext:junit:1.1.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' } 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 c4b8e73..1e5a8d1 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 @@ -27,8 +27,6 @@ import kotlinx.android.synthetic.main.fragment_intro.* class IntroFragment : Fragment() { - private val model: MainViewModel by activityViewModels() - override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? diff --git a/anastasis-ui/src/main/java/org/gnu/anastasis/ui/MainViewModel.kt b/anastasis-ui/src/main/java/org/gnu/anastasis/ui/MainViewModel.kt index 3b97578..e2bf0c8 100644 --- a/anastasis-ui/src/main/java/org/gnu/anastasis/ui/MainViewModel.kt +++ b/anastasis-ui/src/main/java/org/gnu/anastasis/ui/MainViewModel.kt @@ -21,7 +21,7 @@ import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.MutableLiveData import org.gnu.anastasis.ui.identity.LOCATIONS -class MainViewModel(private val app: Application) : AndroidViewModel(app) { +class MainViewModel(app: Application) : AndroidViewModel(app) { val currentCountry = MutableLiveData(LOCATIONS[0]) 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 fd770cb..5f7ab2e 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 @@ -79,17 +79,17 @@ class AuthenticationFragment : Fragment() { ) } - viewModel.securityQuestionChecked.observe(viewLifecycleOwner, Observer { checked -> + viewModel.securityQuestionChecked.observe(viewLifecycleOwner, { checked -> passwordCard.isChecked = checked updatePrice(checked, Amount.fromJSONString("KUDOS:0.5")) updateNextButtonState() }) - viewModel.smsChecked.observe(viewLifecycleOwner, Observer { checked -> + viewModel.smsChecked.observe(viewLifecycleOwner, { checked -> smsCard.isChecked = checked updatePrice(checked, Amount.fromJSONString("KUDOS:1.0")) updateNextButtonState() }) - viewModel.videoChecked.observe(viewLifecycleOwner, Observer { checked -> + viewModel.videoChecked.observe(viewLifecycleOwner, { checked -> videoCard.isChecked = checked updatePrice(checked, Amount.fromJSONString("KUDOS:2.25")) updateNextButtonState() 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 f20fba5..2daf14a 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 @@ -97,8 +97,8 @@ class SmsFragment : Fragment() { private fun fillPhoneNumber() { val telephonyService = requireContext().getSystemService(TelephonyManager::class.java) telephonyService?.line1Number?.let { phoneNumber -> - smsView?.editText?.setText(phoneNumber) - smsView?.editText?.setSelection(phoneNumber.length) + 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 40fa477..bcfbf24 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 @@ -52,7 +52,7 @@ class AnastasisIdentityFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - model.currentCountry.observe(viewLifecycleOwner, Observer { country -> + model.currentCountry.observe(viewLifecycleOwner, { country -> countryView.text = country.name if (stub != null) { stub.layoutResource = country.layoutRes diff --git a/anastasis-ui/src/main/res/drawable/ic_add_circle.xml b/anastasis-ui/src/main/res/drawable/ic_add_circle.xml new file mode 100644 index 0000000..76e1fcb --- /dev/null +++ b/anastasis-ui/src/main/res/drawable/ic_add_circle.xml @@ -0,0 +1,10 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:tint="?attr/colorControlNormal" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:fillColor="@android:color/white" + android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM17,13h-4v4h-2v-4L7,13v-2h4L11,7h2v4h4v2z" /> +</vector> diff --git a/anastasis-ui/src/main/res/layout/fragment_identity.xml b/anastasis-ui/src/main/res/layout/fragment_identity.xml index 072414d..bcf6e4d 100644 --- a/anastasis-ui/src/main/res/layout/fragment_identity.xml +++ b/anastasis-ui/src/main/res/layout/fragment_identity.xml @@ -68,7 +68,7 @@ android:layout_height="wrap_content" android:layout_marginStart="8dp" android:text="Change" - android:textColor="@color/colorAccent" + android:textColor="?attr/colorAccent" app:layout_constraintBaseline_toBaselineOf="@+id/countryView" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.0" @@ -144,9 +144,9 @@ android:layout_height="wrap_content" android:layout_margin="16dp" android:backgroundTint="@color/green" - android:drawableLeft="@drawable/ic_baseline_lock" - android:drawableTint="?attr/colorOnPrimarySurface" + android:drawableStart="@drawable/ic_baseline_lock" android:text="Encrypt Identity" + app:drawableTint="?attr/colorOnPrimarySurface" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" /> diff --git a/cashier/src/main/java/net/taler/cashier/BalanceFragment.kt b/cashier/src/main/java/net/taler/cashier/BalanceFragment.kt index 1114080..541bca2 100644 --- a/cashier/src/main/java/net/taler/cashier/BalanceFragment.kt +++ b/cashier/src/main/java/net/taler/cashier/BalanceFragment.kt @@ -62,10 +62,10 @@ class BalanceFragment : Fragment() { } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - withdrawManager.lastTransaction.observe(viewLifecycleOwner, Observer { lastTransaction -> + withdrawManager.lastTransaction.observe(viewLifecycleOwner, { lastTransaction -> onLastTransaction(lastTransaction) }) - viewModel.balance.observe(viewLifecycleOwner, Observer { result -> + viewModel.balance.observe(viewLifecycleOwner, { result -> onBalanceUpdated(result) }) ui.button5.setOnClickListener { onAmountButtonPressed(5) } @@ -82,7 +82,7 @@ class BalanceFragment : Fragment() { true } else false } - configManager.currency.observe(viewLifecycleOwner, Observer { currency -> + configManager.currency.observe(viewLifecycleOwner, { currency -> ui.currencyView.text = currency }) ui.confirmWithdrawalButton.setOnClickListener { onAmountConfirmed(getAmountFromView()) } diff --git a/cashier/src/main/java/net/taler/cashier/MainViewModel.kt b/cashier/src/main/java/net/taler/cashier/MainViewModel.kt index 2cce8cd..253c7d5 100644 --- a/cashier/src/main/java/net/taler/cashier/MainViewModel.kt +++ b/cashier/src/main/java/net/taler/cashier/MainViewModel.kt @@ -69,7 +69,7 @@ class MainViewModel(private val app: Application) : AndroidViewModel(app) { val result = when (val response = makeJsonGetRequest(url, config)) { is HttpJsonResult.Success -> { try { - val balanceObj = response.json.getJSONObject("balance"); + val balanceObj = response.json.getJSONObject("balance") val balanceAmount = balanceObj.getString("amount") val positive = when (val creditDebitIndicator = balanceObj.getString("credit_debit_indicator")) { diff --git a/cashier/src/main/res/layout-w550dp/fragment_balance.xml b/cashier/src/main/res/layout-w550dp/fragment_balance.xml index 40fa6af..bcfffc7 100644 --- a/cashier/src/main/res/layout-w550dp/fragment_balance.xml +++ b/cashier/src/main/res/layout-w550dp/fragment_balance.xml @@ -27,13 +27,13 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:background="?attr/colorPrimaryDark" - android:drawableStart="@drawable/ic_check_circle" android:drawablePadding="8dp" - android:drawableTint="?attr/colorOnPrimarySurface" android:gravity="center_vertical" android:padding="8dp" android:textColor="?attr/colorOnPrimarySurface" android:visibility="gone" + app:drawableStartCompat="@drawable/ic_check_circle" + app:drawableTint="?attr/colorOnPrimarySurface" app:layout_constraintEnd_toStartOf="@+id/guideline" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" diff --git a/cashier/src/main/res/layout/fragment_balance.xml b/cashier/src/main/res/layout/fragment_balance.xml index fcd0e0a..5a11b2a 100644 --- a/cashier/src/main/res/layout/fragment_balance.xml +++ b/cashier/src/main/res/layout/fragment_balance.xml @@ -27,13 +27,13 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:background="?attr/colorPrimaryDark" - android:drawableStart="@drawable/ic_check_circle" android:drawablePadding="8dp" - android:drawableTint="?attr/colorOnPrimarySurface" android:gravity="center_vertical" android:padding="8dp" android:textColor="?attr/colorOnPrimarySurface" android:visibility="gone" + app:drawableStartCompat="@drawable/ic_check_circle" + app:drawableTint="?attr/colorOnPrimarySurface" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" diff --git a/merchant-terminal/src/main/java/net/taler/merchantpos/history/HistoryFragment.kt b/merchant-terminal/src/main/java/net/taler/merchantpos/history/HistoryFragment.kt index 3ef48e1..c7cd8ba 100644 --- a/merchant-terminal/src/main/java/net/taler/merchantpos/history/HistoryFragment.kt +++ b/merchant-terminal/src/main/java/net/taler/merchantpos/history/HistoryFragment.kt @@ -26,10 +26,9 @@ import androidx.fragment.app.activityViewModels import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.DividerItemDecoration.VERTICAL import androidx.recyclerview.widget.LinearLayoutManager -import com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_LONG -import com.google.android.material.snackbar.Snackbar import net.taler.common.exhaustive import net.taler.common.navigate +import net.taler.common.showError import net.taler.merchantlib.OrderHistoryEntry import net.taler.merchantpos.MainViewModel import net.taler.merchantpos.databinding.FragmentMerchantHistoryBinding @@ -81,7 +80,7 @@ class HistoryFragment : Fragment(), RefundClickListener { }) historyManager.items.observe(viewLifecycleOwner, { result -> when (result) { - is HistoryResult.Error -> onError(result.msg) + is HistoryResult.Error -> requireActivity().showError(result.msg) is HistoryResult.Success -> historyListAdapter.setData(result.items) }.exhaustive }) @@ -96,10 +95,6 @@ class HistoryFragment : Fragment(), RefundClickListener { } } - private fun onError(msg: String) { - Snackbar.make(requireView(), msg, LENGTH_LONG).show() - } - override fun onRefundClicked(item: OrderHistoryEntry) { refundManager.startRefund(item) navigate(actionNavHistoryToRefundFragment()) 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 91e68e6..5306b2f 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 @@ -20,6 +20,7 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.annotation.StringRes import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.navigation.fragment.findNavController @@ -28,6 +29,7 @@ import com.google.android.material.snackbar.Snackbar import net.taler.common.fadeIn import net.taler.common.fadeOut import net.taler.common.navigate +import net.taler.common.showError import net.taler.lib.common.Amount import net.taler.lib.common.AmountParserException import net.taler.merchantlib.OrderHistoryEntry @@ -89,9 +91,9 @@ class RefundFragment : Fragment() { } private fun onRefundResultChanged(result: RefundResult?): Any = when (result) { - is Error -> onError(result.msg) - PastDeadline -> onError(getString(R.string.refund_error_deadline)) - AlreadyRefunded -> onError(getString(R.string.refund_error_already_refunded)) + is Error -> onError(R.string.refund_error_backend, result.msg) + PastDeadline -> onError(R.string.refund_error_deadline) + AlreadyRefunded -> onError(R.string.refund_error_already_refunded) is Success -> { ui.progressBar.fadeOut() ui.refundButton.fadeIn() @@ -101,8 +103,8 @@ class RefundFragment : Fragment() { } } - private fun onError(msg: String) { - Snackbar.make(requireView(), msg, LENGTH_LONG).show() + private fun onError(@StringRes main: Int, details: String = "") { + requireActivity().showError(main, details) ui.progressBar.fadeOut() ui.refundButton.fadeIn() } diff --git a/wallet/build.gradle b/wallet/build.gradle index 0ca1636..cc0e411 100644 --- a/wallet/build.gradle +++ b/wallet/build.gradle @@ -117,7 +117,7 @@ dependencies { // Lists and Selection implementation "androidx.recyclerview:recyclerview:1.1.0" - implementation "androidx.recyclerview:recyclerview-selection:1.1.0-rc01" + implementation "androidx.recyclerview:recyclerview-selection:1.1.0-rc02" // Navigation Library implementation "androidx.navigation:navigation-fragment-ktx:$nav_version" diff --git a/wallet/src/main/res/drawable/ic_add_circle.xml b/wallet/src/main/res/drawable/ic_add_circle.xml deleted file mode 100644 index 4144735..0000000 --- a/wallet/src/main/res/drawable/ic_add_circle.xml +++ /dev/null @@ -1,26 +0,0 @@ -<!-- - ~ This file is part of GNU Taler - ~ (C) 2020 Taler Systems S.A. - ~ - ~ GNU Taler is free software; you can redistribute it and/or modify it under the - ~ terms of the GNU General Public License as published by the Free Software - ~ Foundation; either version 3, or (at your option) any later version. - ~ - ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details. - ~ - ~ You should have received a copy of the GNU General Public License along with - ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - --> - -<vector xmlns:android="http://schemas.android.com/apk/res/android" - android:width="24dp" - android:height="24dp" - android:tint="?attr/colorControlNormal" - android:viewportWidth="24.0" - android:viewportHeight="24.0"> - <path - android:fillColor="#FF000000" - android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM17,13h-4v4h-2v-4L7,13v-2h4L11,7h2v4h4v2z" /> -</vector> diff --git a/wallet/src/main/res/values-fr/strings.xml b/wallet/src/main/res/values-fr/strings.xml index 3a54659..e13a912 100644 --- a/wallet/src/main/res/values-fr/strings.xml +++ b/wallet/src/main/res/values-fr/strings.xml @@ -50,7 +50,6 @@ <string name="button_back">Retour</string> <string name="payment_label_order_summary">Achat</string> <string name="payment_balance_insufficient">Solde insuffisant !</string> - <string name="payment_hide_details">Masquer les détails</string> <string name="payment_already_paid_title">Déjà payé</string> <string name="payment_already_paid">Vous avez déjà payé cet achat.</string> <string name="withdraw_total">Retrait</string> @@ -84,6 +83,5 @@ <string name="payment_error">Erreur : %s</string> <string name="google_play_full_desc" tools:keep="@string/google_play_full_desc">Cette application est un portefeuille pour GNU Taler. Elle est très expérimentale et n\'est pas encore prête à être utilisée en production. GNU Taler est un système de paiement préservant la vie privée. Les clients peuvent rester anonymes, mais les commerçants ne peuvent pas cacher leurs revenus par des paiements avec GNU Taler. Cela permet d\'éviter l\'évasion fiscale et le blanchiment d\'argent. Le principal cas d\'utilisation de GNU Taler est celui des paiements ; il ne s\'agit pas d\'une réserve de valeur. Les paiements sont toujours garantis par une devise existante. Les paiements sont effectués après avoir échangé l\'argent existant en monnaie électronique avec l\'aide d\'un service d\'échange, c\'est-à-dire un fournisseur de services de paiement pour le Taler. Pour effectuer un paiement, les clients n\'ont besoin que d\'un portefeuille chargé. Un commerçant peut accepter des paiements sans que ses clients ne s\'inscrivent sur son site web. GNU Taler est immunisé contre de nombreux types de fraude, tels que l\'hameçonnage des informations relatives aux cartes de crédit ou la fraude par rétrofacturation. En cas de perte ou de vol, seule la quantité limitée d\'argent restant dans le portefeuille peut disparaître.</string> <string name="payment_label_amount_total">Montant total :</string> - <string name="payment_show_details">Afficher les détails</string> <string name="exchange_fee_coin_expiration_label">Expiration de la pièce au plus tôt :</string> </resources>
\ No newline at end of file diff --git a/wallet/src/main/res/values/strings.xml b/wallet/src/main/res/values/strings.xml index 9844cfa..24db2b0 100644 --- a/wallet/src/main/res/values/strings.xml +++ b/wallet/src/main/res/values/strings.xml @@ -97,8 +97,6 @@ GNU Taler is immune against many types of fraud, such as phishing of credit card <string name="payment_label_order_summary">Purchase</string> <string name="payment_error">Error: %s</string> <string name="payment_balance_insufficient">Balance insufficient!</string> - <string name="payment_show_details">Show Details</string> - <string name="payment_hide_details">Hide Details</string> <string name="payment_aborted">Aborted</string> <string name="payment_failed">Failed</string> <string name="payment_initiated">Payment initiated</string> |