From 78dea00ee6480e523b62b7262bf00d6239562f17 Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Tue, 5 Feb 2019 15:14:10 -0600 Subject: [PATCH] Update Navigation AAC Safe Args library version. Make use of the new Safe Args to pass the Transaction ID fromm the TransactionsActivity to the eReceipt. Update the use of Safe Args to the new way of passing data between HomeFragment and SendTransactionFragment, to decide whether or not to activate the Camera. --- app/build.gradle | 3 +-- .../adapters/TransfersDetailsAdapter.kt | 6 ++++-- .../bitsybitshareswallet/fragments/EReceiptFragment.kt | 8 ++++++++ .../bitsybitshareswallet/fragments/HomeFragment.kt | 3 +-- .../fragments/SendTransactionFragment.kt | 7 +++++-- app/src/main/res/navigation/mobile_navigation.xml | 8 ++++---- build.gradle | 5 +++-- 7 files changed, 26 insertions(+), 14 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 738c163..a46d1f1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,8 +1,8 @@ apply plugin: 'com.android.application' -apply plugin: "androidx.navigation.safeargs" apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' +apply plugin: "androidx.navigation.safeargs.kotlin" apply plugin: 'io.fabric' apply plugin: 'com.google.gms.google-services' @@ -64,7 +64,6 @@ android { dependencies { def lifecycle_version = "2.0.0" def room_version = "2.1.0-alpha04" - def nav_version = "1.0.0-beta01" def rx_bindings_version = "3.0.0-alpha2" implementation fileTree(dir: 'libs', include: ['*.jar']) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/adapters/TransfersDetailsAdapter.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/adapters/TransfersDetailsAdapter.kt index 7a36e07..383d80f 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/adapters/TransfersDetailsAdapter.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/adapters/TransfersDetailsAdapter.kt @@ -130,15 +130,17 @@ class TransfersDetailsAdapter(private val context: Context) : val cryptoAmount = "${df.format(amount)} ${transferDetail.getUIAssetSymbol()}" viewHolder.tvCryptoAmount.text = cryptoAmount + // Fiat equivalent viewHolder.tvFiatEquivalent.text = "-" + // Give the correct direction arrow color depending on the direction of the transaction viewHolder.ivDirectionArrow.setImageDrawable(context.getDrawable( if(transferDetail.direction) R.drawable.ic_arrow_receive else R.drawable.ic_arrow_send )) + // Open the eReceipt when a transaction is tapped viewHolder.rootView.setOnClickListener { v -> - val action = TransactionsFragmentDirections.EReceiptAction() -// action.openCamera = true + val action = TransactionsFragmentDirections.eReceiptAction(transferDetail.id) v.findNavController().navigate(action) } } diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/EReceiptFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/EReceiptFragment.kt index 7670b27..3062a97 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/EReceiptFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/EReceiptFragment.kt @@ -5,10 +5,15 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment +import androidx.navigation.fragment.navArgs + import cy.agorise.bitsybitshareswallet.R +import cy.agorise.bitsybitshareswallet.utils.toast class EReceiptFragment : Fragment() { + private val args: EReceiptFragmentArgs by navArgs() + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { setHasOptionsMenu(true) @@ -17,5 +22,8 @@ class EReceiptFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + + val transferId = args.transferId + context?.toast("Transfer ID: $transferId") } } \ No newline at end of file diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/HomeFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/HomeFragment.kt index de31db2..a0d7b98 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/HomeFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/HomeFragment.kt @@ -99,8 +99,7 @@ class HomeFragment : Fragment() { // Navigate to the Send Transaction Fragment using Navigation's SafeArgs to activate the camera fabSendTransactionCamera.setOnClickListener { - val action = HomeFragmentDirections.sendActionCamera() - action.openCamera = true + val action = HomeFragmentDirections.sendAction(true) findNavController().navigate(action) } diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt index d8e054c..0bcc144 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt @@ -14,6 +14,7 @@ import androidx.core.content.ContextCompat import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProviders import androidx.navigation.fragment.findNavController +import androidx.navigation.fragment.navArgs import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.customview.customView import com.google.common.primitives.UnsignedLong @@ -67,6 +68,9 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand private const val RESPONSE_BROADCAST_TRANSACTION = 4 } + // Navigation AAC Safe Args + private val args: SendTransactionFragmentArgs by navArgs() + /** Variables used in field's validation */ private var isCameraPreviewVisible = false private var isToAccountCorrect = false @@ -130,8 +134,7 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand mUserAccount = UserAccount(userId) // Use Navigation SafeArgs to decide if we should activate or not the camera feed - val safeArgs = SendTransactionFragmentArgs.fromBundle(arguments!!) - if (safeArgs.openCamera) { + if (args.openCamera) { // Delay the camera action to avoid flicker in the fragment transition Handler().postDelayed({ run { verifyCameraPermission() } diff --git a/app/src/main/res/navigation/mobile_navigation.xml b/app/src/main/res/navigation/mobile_navigation.xml index bf4396d..0195c99 100644 --- a/app/src/main/res/navigation/mobile_navigation.xml +++ b/app/src/main/res/navigation/mobile_navigation.xml @@ -69,10 +69,10 @@ android:label="@string/title_e_receipt" tools:layout="@layout/fragment_e_receipt"> - - - - +