From 2619541e166ec60cf282c240121fbbbac8f30f68 Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Thu, 13 Dec 2018 08:20:17 -0600 Subject: [PATCH] - Create and add the new Transactions, Merchants and Settings icons and use them in the Balances toolbar. - Remove the transactions section from the Balances fragment. - Create a new TransactionsFragment which hosts the list of trasactions. - Add the transactions destination to the navigation graph so that the Navigation component automatically handles the transition when the transactions icon is selected in Balances. --- .../fragments/BalancesFragment.kt | 12 ----- .../fragments/TransactionsFragment.kt | 53 +++++++++++++++++++ app/src/main/res/drawable/ic_merchants.xml | 17 +++--- app/src/main/res/drawable/ic_settings.xml | 2 +- app/src/main/res/drawable/ic_transactions.xml | 9 ++++ app/src/main/res/layout/fragment_balances.xml | 14 ----- .../main/res/layout/fragment_transactions.xml | 15 ++++++ app/src/main/res/menu/menu_balances.xml | 8 ++- .../main/res/navigation/mobile_navigation.xml | 15 ++++-- 9 files changed, 107 insertions(+), 38 deletions(-) create mode 100644 app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/TransactionsFragment.kt create mode 100644 app/src/main/res/drawable/ic_transactions.xml create mode 100644 app/src/main/res/layout/fragment_transactions.xml diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/BalancesFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/BalancesFragment.kt index 290fd58..0bbc505 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/BalancesFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/BalancesFragment.kt @@ -25,7 +25,6 @@ class BalancesFragment : Fragment() { private lateinit var mUserAccountViewModel: UserAccountViewModel private lateinit var mBalanceDetailViewModel: BalanceDetailViewModel - private lateinit var mTransferDetailViewModel: TransferDetailViewModel override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -59,17 +58,6 @@ class BalancesFragment : Fragment() { mBalanceDetailViewModel.getAll().observe(this, Observer> { balancesDetails -> balancesAdapter.replaceAll(balancesDetails) }) - - // Configure TransferDetailViewModel to show the transaction history - mTransferDetailViewModel = ViewModelProviders.of(this).get(TransferDetailViewModel::class.java) - - val transfersDetailsAdapter = TransfersDetailsAdapter(context!!) - rvTransactions.adapter = transfersDetailsAdapter - rvTransactions.layoutManager = LinearLayoutManager(context) - - mTransferDetailViewModel.getAll(userId).observe(this, Observer> { transfersDetails -> - transfersDetailsAdapter.replaceAll(transfersDetails) - }) } override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/TransactionsFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/TransactionsFragment.kt new file mode 100644 index 0000000..bcbe7da --- /dev/null +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/TransactionsFragment.kt @@ -0,0 +1,53 @@ +package cy.agorise.bitsybitshareswallet.fragments + +import android.os.Bundle +import android.preference.PreferenceManager +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import androidx.lifecycle.Observer +import androidx.lifecycle.ViewModelProviders +import androidx.recyclerview.widget.LinearLayoutManager +import cy.agorise.bitsybitshareswallet.R +import cy.agorise.bitsybitshareswallet.adapters.TransfersDetailsAdapter +import cy.agorise.bitsybitshareswallet.database.joins.TransferDetail +import cy.agorise.bitsybitshareswallet.utils.Constants +import cy.agorise.bitsybitshareswallet.viewmodels.TransferDetailViewModel +import kotlinx.android.synthetic.main.fragment_transactions.* + +class TransactionsFragment : Fragment() { + + private lateinit var mTransferDetailViewModel: TransferDetailViewModel + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { +// setHasOptionsMenu(true) + + return inflater.inflate(R.layout.fragment_transactions, container, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + val userId = PreferenceManager.getDefaultSharedPreferences(context) + .getString(Constants.KEY_CURRENT_ACCOUNT_ID, "") ?: "" + + // Configure TransferDetailViewModel to show the transaction history + mTransferDetailViewModel = ViewModelProviders.of(this).get(TransferDetailViewModel::class.java) + + val transfersDetailsAdapter = TransfersDetailsAdapter(context!!) + rvTransactions.adapter = transfersDetailsAdapter + rvTransactions.layoutManager = LinearLayoutManager(context) + + mTransferDetailViewModel.getAll(userId).observe(this, Observer> { transfersDetails -> + transfersDetailsAdapter.replaceAll(transfersDetails) + }) + } + +// override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { +// inflater.inflate(R.menu.menu_balances, menu) +// } +} diff --git a/app/src/main/res/drawable/ic_merchants.xml b/app/src/main/res/drawable/ic_merchants.xml index 806e675..094456f 100644 --- a/app/src/main/res/drawable/ic_merchants.xml +++ b/app/src/main/res/drawable/ic_merchants.xml @@ -1,9 +1,12 @@ - + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + + diff --git a/app/src/main/res/drawable/ic_settings.xml b/app/src/main/res/drawable/ic_settings.xml index ace746c..a219c09 100644 --- a/app/src/main/res/drawable/ic_settings.xml +++ b/app/src/main/res/drawable/ic_settings.xml @@ -4,6 +4,6 @@ android:viewportWidth="24.0" android:viewportHeight="24.0"> diff --git a/app/src/main/res/drawable/ic_transactions.xml b/app/src/main/res/drawable/ic_transactions.xml new file mode 100644 index 0000000..060c0e5 --- /dev/null +++ b/app/src/main/res/drawable/ic_transactions.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/fragment_balances.xml b/app/src/main/res/layout/fragment_balances.xml index 364b34c..f41c657 100644 --- a/app/src/main/res/layout/fragment_balances.xml +++ b/app/src/main/res/layout/fragment_balances.xml @@ -35,20 +35,6 @@ tools:listitem="@layout/item_balance" tools:itemCount="3"/> - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_transactions.xml b/app/src/main/res/layout/fragment_transactions.xml new file mode 100644 index 0000000..d80ebb6 --- /dev/null +++ b/app/src/main/res/layout/fragment_transactions.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/menu_balances.xml b/app/src/main/res/menu/menu_balances.xml index f1094e0..f9d5c72 100644 --- a/app/src/main/res/menu/menu_balances.xml +++ b/app/src/main/res/menu/menu_balances.xml @@ -2,6 +2,12 @@ + + diff --git a/app/src/main/res/navigation/mobile_navigation.xml b/app/src/main/res/navigation/mobile_navigation.xml index 966e57e..73c210a 100644 --- a/app/src/main/res/navigation/mobile_navigation.xml +++ b/app/src/main/res/navigation/mobile_navigation.xml @@ -12,7 +12,16 @@ android:label="@string/app_name" tools:layout="@layout/fragment_balances"> - + + + + \ No newline at end of file