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: "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'])

View file

@ -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)
}
}

View file

@ -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")
}
}

View file

@ -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)
}

View file

@ -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() }

View file

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

View file

@ -1,7 +1,8 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.11'
ext.kotlin_version = '1.3.20'
ext.nav_version = '1.0.0-beta01'
repositories {
google()
jcenter()
@ -13,7 +14,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
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 'io.fabric.tools:gradle:1.27.0'