gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant-terminal-android] 03/08: Redo payment fragment and upgra


From: gnunet
Subject: [taler-merchant-terminal-android] 03/08: Redo payment fragment and upgrade gradle/kotlin
Date: Tue, 25 Feb 2020 17:07:42 +0100

This is an automated email from the git hooks/post-receive script.

torsten-grote pushed a commit to branch master
in repository merchant-terminal-android.

commit 662f4c237c6d96f8600833976f5adef88139305e
Author: Torsten Grote <address@hidden>
AuthorDate: Tue Feb 25 10:29:41 2020 -0300

    Redo payment fragment and upgrade gradle/kotlin
---
 .idea/codeStyles/Project.xml                       |   3 -
 .idea/gradle.xml                                   |   3 +
 app/build.gradle                                   |   1 -
 app/src/main/java/net/taler/merchantpos/Utils.kt   |  22 ++++
 .../net/taler/merchantpos/order/OrderFragment.kt   |  14 +-
 .../merchantpos/payment/ProcessPaymentFragment.kt  |  27 ++--
 app/src/main/res/layout/fragment_order.xml         |  13 +-
 .../main/res/layout/fragment_process_payment.xml   | 146 ++++++++++++---------
 app/src/main/res/values/colors.xml                 |   4 +-
 app/src/main/res/values/strings.xml                |   3 +
 build.gradle                                       |   8 +-
 gradle/wrapper/gradle-wrapper.properties           |   4 +-
 12 files changed, 143 insertions(+), 105 deletions(-)

diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index a705caf..fad1c60 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -1,8 +1,5 @@
 <component name="ProjectCodeStyleConfiguration">
   <code_scheme name="Project" version="173">
-    <AndroidXmlCodeStyleSettings>
-      <option name="ARRANGEMENT_SETTINGS_MIGRATED_TO_191" value="true" />
-    </AndroidXmlCodeStyleSettings>
     <JetCodeStyleSettings>
       <option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="2147483647" />
       <option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" 
value="2147483647" />
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 7ac24c7..674414f 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -1,8 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
+  <component name="GradleMigrationSettings" migrationVersion="1" />
   <component name="GradleSettings">
     <option name="linkedExternalProjectsSettings">
       <GradleProjectSettings>
+        <option name="delegatedBuild" value="false" />
+        <option name="testRunner" value="PLATFORM" />
         <option name="distributionType" value="DEFAULT_WRAPPED" />
         <option name="externalProjectPath" value="$PROJECT_DIR$" />
         <option name="modules">
diff --git a/app/build.gradle b/app/build.gradle
index 38ddaa9..2a9d620 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -2,7 +2,6 @@ apply plugin: 'com.android.application'
 
 apply plugin: 'kotlin-android'
 apply plugin: 'kotlin-kapt'
-
 apply plugin: 'kotlin-android-extensions'
 
 android {
diff --git a/app/src/main/java/net/taler/merchantpos/Utils.kt 
b/app/src/main/java/net/taler/merchantpos/Utils.kt
index 9b0075a..6ad459d 100644
--- a/app/src/main/java/net/taler/merchantpos/Utils.kt
+++ b/app/src/main/java/net/taler/merchantpos/Utils.kt
@@ -1,5 +1,8 @@
 package net.taler.merchantpos
 
+import android.view.View
+import android.view.View.INVISIBLE
+import android.view.View.VISIBLE
 import androidx.lifecycle.LiveData
 import androidx.lifecycle.MediatorLiveData
 import androidx.lifecycle.Observer
@@ -40,6 +43,25 @@ object Utils {
 
 }
 
+fun View.fadeIn(endAction: () -> Unit = {}) {
+    if (visibility == VISIBLE) return
+    alpha = 0f
+    visibility = VISIBLE
+    animate().alpha(1f).withEndAction {
+        if (context != null) endAction.invoke()
+    }.start()
+}
+
+fun View.fadeOut(endAction: () -> Unit = {}) {
+    if (visibility == INVISIBLE) return
+    animate().alpha(0f).withEndAction {
+        if (context == null) return@withEndAction
+        visibility = INVISIBLE
+        alpha = 1f
+        endAction.invoke()
+    }.start()
+}
+
 class CombinedLiveData<T, K, S>(
     source1: LiveData<T>,
     source2: LiveData<K>,
diff --git a/app/src/main/java/net/taler/merchantpos/order/OrderFragment.kt 
b/app/src/main/java/net/taler/merchantpos/order/OrderFragment.kt
index 6696afe..90d882f 100644
--- a/app/src/main/java/net/taler/merchantpos/order/OrderFragment.kt
+++ b/app/src/main/java/net/taler/merchantpos/order/OrderFragment.kt
@@ -7,8 +7,6 @@ import android.view.ViewGroup
 import androidx.fragment.app.Fragment
 import androidx.fragment.app.activityViewModels
 import androidx.lifecycle.Observer
-import androidx.navigation.NavController
-import androidx.navigation.Navigation.findNavController
 import androidx.navigation.fragment.findNavController
 import androidx.transition.TransitionManager.beginDelayedTransition
 import kotlinx.android.synthetic.main.fragment_order.*
@@ -55,14 +53,16 @@ class OrderFragment : Fragment() {
 
     override fun onActivityCreated(savedInstanceState: Bundle?) {
         super.onActivityCreated(savedInstanceState)
-        val nav: NavController = findNavController(requireActivity(), 
R.id.nav_host_fragment)
-        reconfigureButton.setOnClickListener { 
nav.navigate(R.id.action_order_to_merchantSettings) }
-        historyButton.setOnClickListener { 
nav.navigate(R.id.action_order_to_merchantHistory) }
-        logoutButton.setOnClickListener { 
nav.navigate(R.id.action_order_to_merchantSettings) }
+        reconfigureButton.setOnClickListener {
+            findNavController().navigate(R.id.action_order_to_merchantSettings)
+        }
+        historyButton.setOnClickListener {
+            findNavController().navigate(R.id.action_order_to_merchantHistory)
+        }
         completeButton.setOnClickListener {
             val order = orderManager.order.value ?: return@setOnClickListener
             paymentManager.createPayment(order)
-            nav.navigate(R.id.action_order_to_processPayment)
+            findNavController().navigate(R.id.action_order_to_processPayment)
         }
     }
 
diff --git 
a/app/src/main/java/net/taler/merchantpos/payment/ProcessPaymentFragment.kt 
b/app/src/main/java/net/taler/merchantpos/payment/ProcessPaymentFragment.kt
index 738ec2f..26234db 100644
--- a/app/src/main/java/net/taler/merchantpos/payment/ProcessPaymentFragment.kt
+++ b/app/src/main/java/net/taler/merchantpos/payment/ProcessPaymentFragment.kt
@@ -9,13 +9,15 @@ import androidx.fragment.app.Fragment
 import androidx.fragment.app.activityViewModels
 import androidx.lifecycle.Observer
 import androidx.navigation.fragment.findNavController
+import com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_LONG
 import com.google.android.material.snackbar.Snackbar
-import com.google.android.material.snackbar.Snackbar.LENGTH_SHORT
 import kotlinx.android.synthetic.main.fragment_process_payment.*
 import net.taler.merchantpos.MainViewModel
 import net.taler.merchantpos.NfcManager.Companion.hasNfc
 import net.taler.merchantpos.QrCodeManager.makeQrCode
 import net.taler.merchantpos.R
+import net.taler.merchantpos.fadeIn
+import net.taler.merchantpos.fadeOut
 
 class ProcessPaymentFragment : Fragment() {
 
@@ -32,18 +34,19 @@ class ProcessPaymentFragment : Fragment() {
     override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
         val introRes =
             if (hasNfc(requireContext())) R.string.payment_intro_nfc else 
R.string.payment_intro
-        textView2.setText(introRes)
+        payIntroView.setText(introRes)
         paymentManager.payment.observe(viewLifecycleOwner, Observer { payment 
->
             onPaymentStateChanged(payment)
         })
-        button_cancel_payment.setOnClickListener {
+        cancelPaymentButton.setOnClickListener {
             onPaymentCancel()
         }
     }
 
     private fun onPaymentStateChanged(payment: Payment) {
         if (payment.error) {
-            Snackbar.make(view!!, "Network Error", LENGTH_SHORT).show()
+            Snackbar.make(view!!, R.string.error_network, LENGTH_LONG).show()
+            findNavController().navigateUp()
             return
         }
         if (payment.paid) {
@@ -51,19 +54,25 @@ class ProcessPaymentFragment : Fragment() {
             model.orderManager.restartOrUndo()
             return
         }
+        payIntroView.fadeIn()
         @SuppressLint("SetTextI18n")
-        text_view_amount.text = "${payment.order.totalAsString} 
${payment.currency}"
-        text_view_order_reference.text = getString(R.string.payment_order_ref, 
payment.orderId)
+        amountView.text = "${payment.order.totalAsString} ${payment.currency}"
+        payment.orderId?.let {
+            orderRefView.text = getString(R.string.payment_order_ref, it)
+            orderRefView.fadeIn()
+        }
         payment.talerPayUri?.let {
             val qrcodeBitmap = makeQrCode(it)
-            qrcode.setImageBitmap(qrcodeBitmap)
+            qrcodeView.setImageBitmap(qrcodeBitmap)
+            qrcodeView.fadeIn()
+            progressBar.fadeOut()
         }
     }
 
     private fun onPaymentCancel() {
         paymentManager.cancelPayment()
-        findNavController().popBackStack()
-        Snackbar.make(view!!, "Payment Canceled", LENGTH_SHORT).show()
+        findNavController().navigateUp()
+        Snackbar.make(view!!, R.string.payment_canceled, LENGTH_LONG).show()
     }
 
 }
diff --git a/app/src/main/res/layout/fragment_order.xml 
b/app/src/main/res/layout/fragment_order.xml
index 136d1e7..67f3fc7 100644
--- a/app/src/main/res/layout/fragment_order.xml
+++ b/app/src/main/res/layout/fragment_order.xml
@@ -104,17 +104,6 @@
             app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintStart_toEndOf="@+id/reconfigureButton" />
 
-    <Button
-            android:id="@+id/logoutButton"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginStart="16dp"
-            android:backgroundTint="@color/logoutButton"
-            android:text="@string/button_logout"
-            android:visibility="gone"
-            app:layout_constraintBottom_toBottomOf="parent"
-            app:layout_constraintStart_toEndOf="@+id/historyButton" />
-
     <Button
             android:id="@+id/completeButton"
             android:layout_width="wrap_content"
@@ -125,6 +114,6 @@
             app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintHorizontal_bias="1.0"
-            app:layout_constraintStart_toEndOf="@+id/logoutButton" />
+            app:layout_constraintStart_toEndOf="@+id/historyButton" />
 
 </androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/app/src/main/res/layout/fragment_process_payment.xml 
b/app/src/main/res/layout/fragment_process_payment.xml
index 879773c..c36090d 100644
--- a/app/src/main/res/layout/fragment_process_payment.xml
+++ b/app/src/main/res/layout/fragment_process_payment.xml
@@ -1,76 +1,94 @@
 <?xml version="1.0" encoding="utf-8"?>
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android";
+<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:id="@+id/frameLayout2"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:layout_margin="15dp"
         tools:context=".payment.ProcessPaymentFragment">
 
-    <androidx.constraintlayout.widget.ConstraintLayout
-            android:id="@+id/constraintLayout"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent">
+    <ImageView
+            android:id="@+id/qrcodeView"
+            android:layout_width="0dp"
+            android:layout_height="0dp"
+            android:layout_margin="32dp"
+            android:visibility="invisible"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toStartOf="@+id/guideline"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent"
+            tools:ignore="ContentDescription"
+            tools:src="@tools:sample/avatars"
+            tools:visibility="visible" />
 
-        <Button
-                android:id="@+id/button_cancel_payment"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="@string/payment_cancel"
-                app:layout_constraintBottom_toBottomOf="parent"
-                app:layout_constraintEnd_toEndOf="parent" />
+    <ProgressBar
+            android:id="@+id/progressBar"
+            style="?android:attr/progressBarStyleLarge"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            app:layout_constraintBottom_toBottomOf="@+id/qrcodeView"
+            app:layout_constraintEnd_toEndOf="@+id/qrcodeView"
+            app:layout_constraintStart_toStartOf="@+id/qrcodeView"
+            app:layout_constraintTop_toTopOf="@+id/qrcodeView" />
 
-        <ImageView
-                android:id="@+id/qrcode"
-                android:layout_width="269dp"
-                android:layout_height="275dp"
-                android:layout_marginTop="32dp"
-                app:layout_constraintEnd_toEndOf="parent"
-                app:layout_constraintStart_toStartOf="parent"
-                app:layout_constraintTop_toTopOf="parent"
-                tools:ignore="ContentDescription"
-                tools:src="@tools:sample/backgrounds/scenic[16]" />
+    <androidx.constraintlayout.widget.Guideline
+            android:id="@+id/guideline"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            app:layout_constraintGuide_percent="0.54" />
 
-        <TextView
-                android:id="@+id/textView2"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginTop="15dp"
-                android:layout_marginBottom="15dp"
-                android:text="@string/payment_intro_nfc"
-                android:textAlignment="center"
-                android:textSize="24sp"
-                app:layout_constraintBottom_toTopOf="@+id/text_view_amount"
-                app:layout_constraintEnd_toEndOf="parent"
-                app:layout_constraintStart_toStartOf="parent"
-                app:layout_constraintTop_toBottomOf="@+id/qrcode" />
+    <TextView
+            android:id="@+id/payIntroView"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_margin="16dp"
+            android:text="@string/payment_intro_nfc"
+            android:textAlignment="center"
+            android:textSize="24sp"
+            android:visibility="invisible"
+            app:layout_constraintBottom_toTopOf="@+id/amountView"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="@+id/guideline"
+            app:layout_constraintTop_toTopOf="parent"
+            app:layout_constraintVertical_chainStyle="spread"
+            tools:visibility="visible" />
 
-        <TextView
-                android:id="@+id/text_view_amount"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginTop="39dp"
-                android:textSize="30sp"
-                
app:layout_constraintBottom_toTopOf="@+id/text_view_order_reference"
-                app:layout_constraintEnd_toEndOf="parent"
-                app:layout_constraintStart_toStartOf="parent"
-                app:layout_constraintTop_toBottomOf="@+id/textView2"
-                tools:text="10.49 Eur" />
+    <TextView
+            android:id="@+id/amountView"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_margin="16dp"
+            android:textAppearance="@style/TextAppearance.AppCompat.Headline"
+            app:layout_constraintBottom_toTopOf="@+id/orderRefView"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="@+id/guideline"
+            app:layout_constraintTop_toBottomOf="@+id/payIntroView"
+            tools:text="10.49 TESTKUDOS" />
 
-        <TextView
-                android:id="@+id/text_view_order_reference"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginStart="8dp"
-                android:layout_marginTop="8dp"
-                android:layout_marginEnd="8dp"
-                android:layout_marginBottom="8dp"
-                android:textAlignment="center"
-                app:layout_constraintBottom_toTopOf="@id/button_cancel_payment"
-                app:layout_constraintEnd_toEndOf="parent"
-                app:layout_constraintStart_toStartOf="parent"
-                app:layout_constraintTop_toBottomOf="@+id/text_view_amount"
-                tools:text="@string/payment_order_ref" />
-    </androidx.constraintlayout.widget.ConstraintLayout>
-</FrameLayout>
\ No newline at end of file
+    <TextView
+            android:id="@+id/orderRefView"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_margin="16dp"
+            android:textAlignment="center"
+            android:visibility="invisible"
+            app:layout_constraintBottom_toTopOf="@id/cancelPaymentButton"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="@+id/guideline"
+            app:layout_constraintTop_toBottomOf="@+id/amountView"
+            tools:text="@string/payment_order_ref"
+            tools:visibility="visible" />
+
+    <Button
+            android:id="@+id/cancelPaymentButton"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_margin="16dp"
+            android:backgroundTint="@color/red"
+            android:text="@string/payment_cancel"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintHorizontal_bias="0.0"
+            app:layout_constraintStart_toStartOf="@+id/guideline" />
+
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/app/src/main/res/values/colors.xml 
b/app/src/main/res/values/colors.xml
index 3ed8874..5a3d60d 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -6,5 +6,7 @@
 
     <color name="selectedBackground">#DADADA</color>
     <color name="bottomButtons">#9E9D24</color>
-    <color name="logoutButton">#C62828</color>
+    <color name="logoutButton">@color/red</color>
+    <color name="red">#C62828</color>
+
 </resources>
diff --git a/app/src/main/res/values/strings.xml 
b/app/src/main/res/values/strings.xml
index fe4a61b..d9f9a1a 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -33,8 +33,11 @@
     <string name="payment_received">Payment Received</string>
     <string name="payment_back_button">Go Back</string>
     <string name="payment_order_ref">Order Reference: %s</string>
+    <string name="payment_canceled">Payment Canceled</string>
 
     <string name="history_received_at">Received at</string>
     <string name="history_ref_no">Ref. No:</string>
 
+    <string name="error_network">Network Error</string>
+
 </resources>
diff --git a/build.gradle b/build.gradle
index dfab280..82723c0 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,17 +1,13 @@
-// Top-level build file where you can add configuration options common to all 
sub-projects/modules.
-
 buildscript {
-    ext.kotlin_version = '1.3.41'
+    ext.kotlin_version = '1.3.61'
     repositories {
         google()
         jcenter()
         
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:3.5.3'
+        classpath 'com.android.tools.build:gradle:3.6.0'
         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
-        // NOTE: Do not place your application dependencies here; they belong
-        // in the individual module build.gradle files
     }
 }
 
diff --git a/gradle/wrapper/gradle-wrapper.properties 
b/gradle/wrapper/gradle-wrapper.properties
index 344e98a..ef25684 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Tue Aug 20 23:27:29 CEST 2019
+#Tue Feb 25 09:57:57 BRT 2020
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]