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.

This commit is contained in:
Severiano Jaramillo 2019-02-05 15:14:10 -06:00
parent d8f1ad7216
commit 78dea00ee6
7 changed files with 26 additions and 14 deletions

View file

@ -1,8 +1,8 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
apply plugin: "androidx.navigation.safeargs"
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: "androidx.navigation.safeargs.kotlin"
apply plugin: 'io.fabric' apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'
@ -64,7 +64,6 @@ android {
dependencies { dependencies {
def lifecycle_version = "2.0.0" def lifecycle_version = "2.0.0"
def room_version = "2.1.0-alpha04" def room_version = "2.1.0-alpha04"
def nav_version = "1.0.0-beta01"
def rx_bindings_version = "3.0.0-alpha2" def rx_bindings_version = "3.0.0-alpha2"
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])

View file

@ -130,15 +130,17 @@ class TransfersDetailsAdapter(private val context: Context) :
val cryptoAmount = "${df.format(amount)} ${transferDetail.getUIAssetSymbol()}" val cryptoAmount = "${df.format(amount)} ${transferDetail.getUIAssetSymbol()}"
viewHolder.tvCryptoAmount.text = cryptoAmount viewHolder.tvCryptoAmount.text = cryptoAmount
// Fiat equivalent
viewHolder.tvFiatEquivalent.text = "-" viewHolder.tvFiatEquivalent.text = "-"
// Give the correct direction arrow color depending on the direction of the transaction
viewHolder.ivDirectionArrow.setImageDrawable(context.getDrawable( viewHolder.ivDirectionArrow.setImageDrawable(context.getDrawable(
if(transferDetail.direction) R.drawable.ic_arrow_receive else R.drawable.ic_arrow_send 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 -> viewHolder.rootView.setOnClickListener { v ->
val action = TransactionsFragmentDirections.EReceiptAction() val action = TransactionsFragmentDirections.eReceiptAction(transferDetail.id)
// action.openCamera = true
v.findNavController().navigate(action) v.findNavController().navigate(action)
} }
} }

View file

@ -5,10 +5,15 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.navigation.fragment.navArgs
import cy.agorise.bitsybitshareswallet.R import cy.agorise.bitsybitshareswallet.R
import cy.agorise.bitsybitshareswallet.utils.toast
class EReceiptFragment : Fragment() { class EReceiptFragment : Fragment() {
private val args: EReceiptFragmentArgs by navArgs()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
setHasOptionsMenu(true) setHasOptionsMenu(true)
@ -17,5 +22,8 @@ class EReceiptFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
val transferId = args.transferId
context?.toast("Transfer ID: $transferId")
} }
} }

View file

@ -99,8 +99,7 @@ class HomeFragment : Fragment() {
// Navigate to the Send Transaction Fragment using Navigation's SafeArgs to activate the camera // Navigate to the Send Transaction Fragment using Navigation's SafeArgs to activate the camera
fabSendTransactionCamera.setOnClickListener { fabSendTransactionCamera.setOnClickListener {
val action = HomeFragmentDirections.sendActionCamera() val action = HomeFragmentDirections.sendAction(true)
action.openCamera = true
findNavController().navigate(action) findNavController().navigate(action)
} }

View file

@ -14,6 +14,7 @@ import androidx.core.content.ContextCompat
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders import androidx.lifecycle.ViewModelProviders
import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.customview.customView import com.afollestad.materialdialogs.customview.customView
import com.google.common.primitives.UnsignedLong import com.google.common.primitives.UnsignedLong
@ -67,6 +68,9 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand
private const val RESPONSE_BROADCAST_TRANSACTION = 4 private const val RESPONSE_BROADCAST_TRANSACTION = 4
} }
// Navigation AAC Safe Args
private val args: SendTransactionFragmentArgs by navArgs()
/** Variables used in field's validation */ /** Variables used in field's validation */
private var isCameraPreviewVisible = false private var isCameraPreviewVisible = false
private var isToAccountCorrect = false private var isToAccountCorrect = false
@ -130,8 +134,7 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand
mUserAccount = UserAccount(userId) mUserAccount = UserAccount(userId)
// Use Navigation SafeArgs to decide if we should activate or not the camera feed // Use Navigation SafeArgs to decide if we should activate or not the camera feed
val safeArgs = SendTransactionFragmentArgs.fromBundle(arguments!!) if (args.openCamera) {
if (safeArgs.openCamera) {
// Delay the camera action to avoid flicker in the fragment transition // Delay the camera action to avoid flicker in the fragment transition
Handler().postDelayed({ Handler().postDelayed({
run { verifyCameraPermission() } run { verifyCameraPermission() }

View file

@ -69,10 +69,10 @@
android:label="@string/title_e_receipt" android:label="@string/title_e_receipt"
tools:layout="@layout/fragment_e_receipt"> tools:layout="@layout/fragment_e_receipt">
<!--<argument--> <argument
<!--android:name="openCamera"--> android:name="transferId"
<!--app:argType="boolean"--> app:argType="string"
<!--android:defaultValue="false" />--> android:defaultValue="0" />
</fragment> </fragment>
<fragment <fragment

View file

@ -1,7 +1,8 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.3.11' ext.kotlin_version = '1.3.20'
ext.nav_version = '1.0.0-beta01'
repositories { repositories {
google() google()
jcenter() jcenter()
@ -13,7 +14,7 @@ buildscript {
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.3.0' classpath 'com.android.tools.build:gradle:3.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha09" classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:$nav_version"
classpath 'com.google.gms:google-services:4.2.0' classpath 'com.google.gms:google-services:4.2.0'
classpath 'io.fabric.tools:gradle:1.27.0' classpath 'io.fabric.tools:gradle:1.27.0'