Added bottom bar to ask user if she likes to fetch all transactions
This commit is contained in:
parent
5b054dcb52
commit
e7d665f588
|
@ -14,14 +14,17 @@ import androidx.recyclerview.widget.DividerItemDecoration
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kotlinx.android.synthetic.main.fragment_home.*
|
||||
import kotlinx.android.synthetic.main.fragment_home.view.*
|
||||
import net.dankito.banking.ui.android.R
|
||||
import net.dankito.banking.ui.android.di.BankingComponent
|
||||
import net.dankito.banking.ui.android.adapter.AccountTransactionAdapter
|
||||
import net.dankito.banking.ui.android.di.BankingComponent
|
||||
import net.dankito.banking.ui.android.extensions.showAmount
|
||||
import net.dankito.banking.ui.model.TypedBankAccount
|
||||
import net.dankito.banking.ui.model.parameters.TransferMoneyData
|
||||
import net.dankito.banking.ui.model.responses.GetTransactionsResponse
|
||||
import net.dankito.banking.ui.presenter.BankingPresenter
|
||||
import net.dankito.utils.android.extensions.asActivity
|
||||
import net.dankito.utils.android.extensions.getDimension
|
||||
import net.dankito.utils.multiplatform.sum
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -37,6 +40,11 @@ class HomeFragment : Fragment() {
|
|||
private lateinit var mnitmUpdateTransactions: MenuItem
|
||||
|
||||
|
||||
private var accountsForWhichNotAllTransactionsHaveBeenFetched = listOf<TypedBankAccount>()
|
||||
|
||||
private var doNotShowFetchAllTransactionsOverlay = false
|
||||
|
||||
|
||||
private val transactionAdapter: AccountTransactionAdapter
|
||||
|
||||
protected var appliedTransactionsFilter = ""
|
||||
|
@ -61,21 +69,31 @@ class HomeFragment : Fragment() {
|
|||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
homeViewModel = ViewModelProviders.of(this).get(HomeViewModel::class.java)
|
||||
val root = inflater.inflate(R.layout.fragment_home, container, false)
|
||||
val rootView = inflater.inflate(R.layout.fragment_home, container, false)
|
||||
// val textView: TextView = root.findViewById(R.id.text_home)
|
||||
// homeViewModel.text.observe(this, Observer {
|
||||
// textView.text = it
|
||||
// })
|
||||
|
||||
|
||||
val rcyvwAccountTransactions: RecyclerView = root.findViewById(R.id.rcyvwAccountTransactions)
|
||||
val rcyvwAccountTransactions: RecyclerView = rootView.findViewById(R.id.rcyvwAccountTransactions)
|
||||
rcyvwAccountTransactions.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
|
||||
rcyvwAccountTransactions.adapter = transactionAdapter
|
||||
rcyvwAccountTransactions.addItemDecoration(DividerItemDecoration(context, DividerItemDecoration.VERTICAL))
|
||||
rcyvwAccountTransactions.isNestedScrollingEnabled = false
|
||||
|
||||
registerForContextMenu(rcyvwAccountTransactions) // this is actually bad, splits code as context menu is created in AccountTransactionAdapter
|
||||
|
||||
return root
|
||||
rootView.btnFetchAllTransactions.setOnClickListener {
|
||||
fetchAllTransactions()
|
||||
}
|
||||
|
||||
rootView.btnHideFetchAllTransactionsOverlay.setOnClickListener {
|
||||
doNotShowFetchAllTransactionsOverlay = true
|
||||
setFetchAllTransactionsView()
|
||||
}
|
||||
|
||||
return rootView
|
||||
}
|
||||
|
||||
|
||||
|
@ -222,6 +240,36 @@ class HomeFragment : Fragment() {
|
|||
val sumOfDisplayedTransactions = if (appliedTransactionsFilter.isBlank()) presenter.balanceOfSelectedBankAccounts
|
||||
else transactionAdapter.items.map { it.amount }.sum()
|
||||
txtTransactionsBalance.showAmount(presenter, sumOfDisplayedTransactions)
|
||||
|
||||
setFetchAllTransactionsView()
|
||||
}
|
||||
|
||||
private fun setFetchAllTransactionsView() {
|
||||
accountsForWhichNotAllTransactionsHaveBeenFetched = presenter.selectedBankAccountsForWhichNotAllTransactionsHaveBeenFetched
|
||||
|
||||
var floatingActionMenuBottomMarginResourceId = R.dimen.fab_margin_bottom_without_toolbar
|
||||
|
||||
if (doNotShowFetchAllTransactionsOverlay || accountsForWhichNotAllTransactionsHaveBeenFetched.isEmpty()) {
|
||||
lytFetchAllTransactionsOverlay.visibility = View.GONE
|
||||
}
|
||||
else {
|
||||
lytFetchAllTransactionsOverlay.visibility = View.VISIBLE
|
||||
floatingActionMenuBottomMarginResourceId = R.dimen.fab_margin_bottom_with_fetch_all_transactions_overlay
|
||||
}
|
||||
|
||||
(requireActivity().findViewById<View>(R.id.floatingActionMenu).layoutParams as? ViewGroup.MarginLayoutParams)?.let { params ->
|
||||
params.bottomMargin = requireContext().getDimension(floatingActionMenuBottomMarginResourceId)
|
||||
}
|
||||
}
|
||||
|
||||
private fun fetchAllTransactions() {
|
||||
accountsForWhichNotAllTransactionsHaveBeenFetched.forEach { account ->
|
||||
presenter.fetchAllAccountTransactionsAsync(account) {
|
||||
requireActivity().runOnUiThread {
|
||||
updateAccountsTransactions()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -25,6 +25,7 @@
|
|||
<include layout="@layout/content_main" />
|
||||
|
||||
<include
|
||||
android:id="@+id/floatingActionMenu"
|
||||
layout="@layout/view_floating_action_button_main"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -7,13 +7,21 @@
|
|||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="@dimen/fragment_account_transaction_margin_start_and_end"
|
||||
android:layout_marginEnd="@dimen/fragment_account_transaction_margin_start_and_end"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/fragment_account_transaction_margin_start_and_end"
|
||||
android:layout_marginEnd="@dimen/fragment_account_transaction_margin_start_and_end"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_above="@+id/lytFetchAllTransactionsOverlay"
|
||||
>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/lytTransactionsSummary"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -51,15 +59,58 @@
|
|||
android:id="@+id/rcyvwAccountTransactions"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/lytTransactionsSummary"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/lytFetchAllTransactionsOverlay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/fragment_account_transaction_fetch_all_transactions_overlay_height"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
android:gravity="center_vertical"
|
||||
android:background="@color/snackbarBackground"
|
||||
android:visibility="gone"
|
||||
>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnFetchAllTransactions"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_toLeftOf="@+id/btnHideFetchAllTransactionsOverlay"
|
||||
android:layout_toStartOf="@+id/btnHideFetchAllTransactionsOverlay"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:gravity="center"
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:textColor="@color/linkColor"
|
||||
android:text="@string/fragment_home_fetch_all_account_transactions"
|
||||
/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnHideFetchAllTransactionsOverlay"
|
||||
android:layout_width="@dimen/fragment_account_transaction_button_close_fetch_all_transactions_overlay_size"
|
||||
android:layout_height="@dimen/fragment_account_transaction_button_close_fetch_all_transactions_overlay_size"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginRight="@dimen/fragment_account_transaction_button_close_fetch_all_transactions_overlay_margin_end"
|
||||
android:layout_marginEnd="@dimen/fragment_account_transaction_button_close_fetch_all_transactions_overlay_margin_end"
|
||||
android:background="@null"
|
||||
android:tint="#FFFFFF"
|
||||
app:srcCompat="@drawable/ic_baseline_close_24"
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -40,6 +40,7 @@
|
|||
<string name="fragment_home_could_not_retrieve_account_transactions">Kontoumsätze für \'%1$s\' konnten nicht empfangen werden.\n\nFehlermeldung Ihrer Bank:\n\n%2$s</string>
|
||||
<string name="fragment_home_transfer_money_to">Neue Überweisung an %s</string>
|
||||
<string name="fragment_home_transfer_money_with_same_data">Neue Überweisung mit gleichen Daten</string>
|
||||
<string name="fragment_home_fetch_all_account_transactions">Ältere Umsätze laden (erfordert TAN)</string>
|
||||
|
||||
<string name="dialog_add_account_enter_bank">Bank (Suche auch mittels Bankleitzahl oder Ort):</string>
|
||||
<string name="dialog_add_account_add">Hinzufügen</string>
|
||||
|
|
|
@ -25,7 +25,9 @@
|
|||
<color name="list_item_bank_info_bank_supported">@color/colorAccent</color>
|
||||
<color name="list_item_bank_info_bank_not_supported">@color/negativeAmount</color>
|
||||
|
||||
<color name="info_icon_color">#007aff</color>
|
||||
<color name="infoIconColor">#007aff</color>
|
||||
|
||||
<color name="linkColor">#007aff</color>
|
||||
|
||||
<!-- darker_gray: #aaa -->
|
||||
<color name="formSectionDivideColor">#e0e0e0</color>
|
||||
|
@ -33,6 +35,8 @@
|
|||
<!-- colorError = #B00020 -->
|
||||
<color name="destructiveColor">#ff3b30</color>
|
||||
|
||||
<color name="snackbarBackground">#323232</color>
|
||||
|
||||
|
||||
<color name="fabTextColor">#FFFFFF</color>
|
||||
<!-- <color name="fabLabelBackgroundColor">@color/black_semi_transparent</color>-->
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
<dimen name="fab_margin">16dp</dimen>
|
||||
<dimen name="fab_margin_bottom_without_toolbar">16dp</dimen>
|
||||
<dimen name="fab_margin_bottom_with_toolbar">42dp</dimen>
|
||||
<dimen name="fab_margin_bottom_with_fetch_all_transactions_overlay">64dp</dimen>
|
||||
|
||||
<dimen name="form_padding">12dp</dimen>
|
||||
<dimen name="form_section_height">60dp</dimen>
|
||||
|
@ -24,6 +25,9 @@
|
|||
|
||||
<dimen name="fragment_account_transaction_margin_start_and_end">4dp</dimen>
|
||||
<dimen name="fragment_account_transaction_transactions_summary_height">24dp</dimen>
|
||||
<dimen name="fragment_account_transaction_fetch_all_transactions_overlay_height">48dp</dimen>
|
||||
<dimen name="fragment_account_transaction_button_close_fetch_all_transactions_overlay_size">20dp</dimen>
|
||||
<dimen name="fragment_account_transaction_button_close_fetch_all_transactions_overlay_margin_end">6dp</dimen>
|
||||
|
||||
<dimen name="list_item_account_transaction_height">74dp</dimen>
|
||||
<dimen name="list_item_account_transaction_padding">0dp</dimen>
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
<string name="fragment_home_could_not_retrieve_account_transactions">Could not retrieve account transactions for \'%1$s\'.\n\nError message from your bank:\n\n%2$s</string>
|
||||
<string name="fragment_home_transfer_money_to">Transfer money to %s</string>
|
||||
<string name="fragment_home_transfer_money_with_same_data">New transfer with same data</string>
|
||||
<string name="fragment_home_fetch_all_account_transactions">Fetch earlier transactions (requires TAN)</string>
|
||||
|
||||
<string name="dialog_add_account_enter_bank">Bank (find also by bank code or city):</string>
|
||||
<string name="dialog_add_account_add">Add</string>
|
||||
|
|
|
@ -579,6 +579,9 @@ open class BankingPresenter constructor(
|
|||
open val balanceOfSelectedBankAccounts: BigDecimal
|
||||
get() = sumBalance(selectedBankAccounts.map { it.balance })
|
||||
|
||||
open val selectedBankAccountsForWhichNotAllTransactionsHaveBeenFetched: List<TypedBankAccount>
|
||||
get() = selectedBankAccounts.filter { it.haveAllTransactionsBeenFetched == false }
|
||||
|
||||
|
||||
open val areAllAccountSelected: Boolean
|
||||
get() = selectedAccountType == SelectedAccountType.AllAccounts
|
||||
|
|
Loading…
Reference in New Issue