From 7e17847ba5a959930a2898865753fb8fa7f472cf Mon Sep 17 00:00:00 2001 From: miplodder Date: Fri, 2 Aug 2019 01:29:49 +0530 Subject: [PATCH] :View Ledger feature added --- app/src/main/AndroidManifest.xml | 2 + .../fineract/ui/adapters/LedgerAdapter.kt | 18 +- .../accountdetails/AccountDetailActivity.kt | 2 +- .../ledgerdetails/LedgerDetailActivity.kt | 46 +++ .../{ => ledgerlist}/LedgerContract.kt | 0 .../{ => ledgerlist}/LedgerFragment.kt | 18 +- .../{ => ledgerlist}/LedgerPresenter.kt | 0 .../apache/fineract/utils/ConstantKeys.java | 1 + .../res/layout/activity_account_detail.xml | 15 - .../res/layout/activity_ledger_detail.xml | 290 ++++++++++++++++++ app/src/main/res/values/strings.xml | 6 + 11 files changed, 380 insertions(+), 18 deletions(-) create mode 100644 app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/ledgerdetails/LedgerDetailActivity.kt rename app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/{ => ledgerlist}/LedgerContract.kt (100%) rename app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/{ => ledgerlist}/LedgerFragment.kt (88%) rename app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/{ => ledgerlist}/LedgerPresenter.kt (100%) create mode 100644 app/src/main/res/layout/activity_ledger_detail.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6ff46135..2330d742 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -88,6 +88,8 @@ + + diff --git a/app/src/main/java/org/apache/fineract/ui/adapters/LedgerAdapter.kt b/app/src/main/java/org/apache/fineract/ui/adapters/LedgerAdapter.kt index 9f369538..78876f01 100644 --- a/app/src/main/java/org/apache/fineract/ui/adapters/LedgerAdapter.kt +++ b/app/src/main/java/org/apache/fineract/ui/adapters/LedgerAdapter.kt @@ -11,6 +11,7 @@ import kotlinx.android.synthetic.main.item_ledger.view.* import org.apache.fineract.R import org.apache.fineract.data.models.accounts.Ledger import org.apache.fineract.injection.ApplicationContext +import org.apache.fineract.ui.base.OnItemClickListener import org.apache.fineract.utils.DateUtils import org.apache.fineract.utils.StatusUtils import javax.inject.Inject @@ -19,6 +20,7 @@ class LedgerAdapter @Inject constructor(@ApplicationContext val context: Context : RecyclerView.Adapter() { private var ledgers: List = ArrayList() + private lateinit var onItemClickListener: OnItemClickListener override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { @@ -54,12 +56,26 @@ class LedgerAdapter @Inject constructor(@ApplicationContext val context: Context notifyDataSetChanged() } - class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + fun setItemClickListener(onItemClickListener: OnItemClickListener) { + this.onItemClickListener = onItemClickListener + } + + inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), View.OnClickListener { val tvLedgerIdentifier: TextView = itemView.tv_ledger_identifier val tvModifiedBy: TextView = itemView.tv_modified_by val tvModifiedOn: TextView = itemView.tv_modified_on val tvTotalValue: TextView = itemView.tv_total_value val ivAccountTypeIndicator: AppCompatImageView = itemView.iv_type_indicator + + init { + itemView.ll_ledger.setOnClickListener(this) + } + + override fun onClick(v: View?) { + if (onItemClickListener != null) { + onItemClickListener.onItemClick(v, adapterPosition) + } + } } } \ No newline at end of file diff --git a/app/src/main/java/org/apache/fineract/ui/online/accounting/accounts/accountdetails/AccountDetailActivity.kt b/app/src/main/java/org/apache/fineract/ui/online/accounting/accounts/accountdetails/AccountDetailActivity.kt index 133e14e9..997c9bb2 100644 --- a/app/src/main/java/org/apache/fineract/ui/online/accounting/accounts/accountdetails/AccountDetailActivity.kt +++ b/app/src/main/java/org/apache/fineract/ui/online/accounting/accounts/accountdetails/AccountDetailActivity.kt @@ -21,7 +21,7 @@ class AccountDetailActivity : FineractBaseActivity() { populateUserInterface() } - fun populateUserInterface() { + private fun populateUserInterface() { tvType.text = account.type.toString() tvIdentifier.text = account.identifier tvName.text = account.name diff --git a/app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/ledgerdetails/LedgerDetailActivity.kt b/app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/ledgerdetails/LedgerDetailActivity.kt new file mode 100644 index 00000000..6222e43e --- /dev/null +++ b/app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/ledgerdetails/LedgerDetailActivity.kt @@ -0,0 +1,46 @@ +package org.apache.fineract.ui.online.accounting.ledgers.ledgerdetails + +import android.os.Bundle +import android.widget.Toast +import kotlinx.android.synthetic.main.activity_ledger_detail.* +import org.apache.fineract.R +import org.apache.fineract.data.models.accounts.Ledger +import org.apache.fineract.ui.base.FineractBaseActivity +import org.apache.fineract.utils.ConstantKeys + +class LedgerDetailActivity : FineractBaseActivity() { + + lateinit var ledger: Ledger + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_ledger_detail) + + ledger = intent.getParcelableExtra(ConstantKeys.LEDGER) + setToolbarTitle(getString(R.string.ledger_details)) + showBackButton() + populateUserInterface() + } + + private fun populateUserInterface() { + tvType.text = ledger.type.toString() + tvIdentifier.text = ledger.identifier + tvName.text = ledger.name + tvParentLedgerIdentifier.text = ledger.parentLedgerIdentifier + tvDescription.text = ledger.description + tvTotalValue.text = "$ ${ledger.totalValue}" + tvSubLedger.text = "\n" + if (ledger.subLedgers!!.size > 0) { + var ledgerIterator = ledger.subLedgers?.iterator() + while (ledgerIterator!!.hasNext()) + tvSubLedger.append("${ledgerIterator.next()}\n") + } else { + tvSubLedger.text = getString(R.string.no_sub_ledger_available) + } + tvShowAccountInChart.text = ledger.showAccountsInChart.toString() + tvCreateOn.text = ledger.createdOn + tvCreatedBy.text = ledger.createdBy + tvLastModifiedOn.text = ledger.lastModifiedOn + tvLastModifiedBy.text = ledger.lastModifiedBy + } +} \ No newline at end of file diff --git a/app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/LedgerContract.kt b/app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/ledgerlist/LedgerContract.kt similarity index 100% rename from app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/LedgerContract.kt rename to app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/ledgerlist/LedgerContract.kt diff --git a/app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/LedgerFragment.kt b/app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/ledgerlist/LedgerFragment.kt similarity index 88% rename from app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/LedgerFragment.kt rename to app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/ledgerlist/LedgerFragment.kt index 75c50be5..6a8888f3 100644 --- a/app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/LedgerFragment.kt +++ b/app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/ledgerlist/LedgerFragment.kt @@ -3,12 +3,14 @@ package org.apache.fineract.ui.online.accounting.ledgers import android.app.SearchManager import android.content.Context +import android.content.Intent import android.os.Bundle import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import androidx.recyclerview.widget.LinearLayoutManager import androidx.appcompat.widget.SearchView import android.text.TextUtils import android.view.* +import android.widget.Toast import androidx.recyclerview.widget.RecyclerView import kotlinx.android.synthetic.main.fragment_ledger.* import kotlinx.android.synthetic.main.layout_exception_handler.* @@ -17,13 +19,16 @@ import org.apache.fineract.data.models.accounts.Ledger import org.apache.fineract.ui.adapters.LedgerAdapter import org.apache.fineract.ui.base.FineractBaseActivity import org.apache.fineract.ui.base.FineractBaseFragment +import org.apache.fineract.ui.base.OnItemClickListener import org.apache.fineract.ui.online.accounting.accounts.LedgerContract +import org.apache.fineract.ui.online.accounting.ledgers.ledgerdetails.LedgerDetailActivity +import org.apache.fineract.utils.ConstantKeys import javax.inject.Inject import kotlin.collections.ArrayList class LedgerFragment : FineractBaseFragment(), LedgerContract.View, - SwipeRefreshLayout.OnRefreshListener { + SwipeRefreshLayout.OnRefreshListener, OnItemClickListener { @Inject lateinit var ledgerAdapter: LedgerAdapter @@ -75,6 +80,7 @@ class LedgerFragment : FineractBaseFragment(), LedgerContract.View, rvLedger.setHasFixedSize(true) rvLedger.adapter = ledgerAdapter + ledgerAdapter.setItemClickListener(this) swipeContainer.setColorSchemeColors(*activity!! .resources.getIntArray(R.array.swipeRefreshColors)) @@ -161,6 +167,16 @@ class LedgerFragment : FineractBaseFragment(), LedgerContract.View, showFineractErrorUI(getString(R.string.ledger)) } + override fun onItemClick(childView: View?, position: Int) { + var intent = Intent(context, LedgerDetailActivity::class.java) + intent.putExtra(ConstantKeys.LEDGER, ledgerList[position]) + startActivity(intent) + } + + override fun onItemLongPress(childView: View?, position: Int) { + + } + override fun onDestroyView() { super.onDestroyView() ledgerPresenter.detachView() diff --git a/app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/LedgerPresenter.kt b/app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/ledgerlist/LedgerPresenter.kt similarity index 100% rename from app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/LedgerPresenter.kt rename to app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/ledgerlist/LedgerPresenter.kt diff --git a/app/src/main/java/org/apache/fineract/utils/ConstantKeys.java b/app/src/main/java/org/apache/fineract/utils/ConstantKeys.java index 2eaec1a7..e473535a 100644 --- a/app/src/main/java/org/apache/fineract/utils/ConstantKeys.java +++ b/app/src/main/java/org/apache/fineract/utils/ConstantKeys.java @@ -41,4 +41,5 @@ public class ConstantKeys { public static final String PERMISSIONS_READ_EXTERNAL_STORAGE_STATUS = "read_status"; public static final String ACCOUNT = "account"; + public static final String LEDGER = "ledger"; } diff --git a/app/src/main/res/layout/activity_account_detail.xml b/app/src/main/res/layout/activity_account_detail.xml index 4edb3318..b0268beb 100644 --- a/app/src/main/res/layout/activity_account_detail.xml +++ b/app/src/main/res/layout/activity_account_detail.xml @@ -125,11 +125,6 @@ android:layout_marginStart="@dimen/start_margin" android:textStyle="bold" /> - - @@ -199,11 +194,6 @@ android:layout_marginStart="@dimen/start_margin" android:textStyle="bold" /> - - @@ -348,11 +338,6 @@ android:layout_marginStart="@dimen/start_margin" android:textStyle="bold" /> - - diff --git a/app/src/main/res/layout/activity_ledger_detail.xml b/app/src/main/res/layout/activity_ledger_detail.xml new file mode 100644 index 00000000..ecc09091 --- /dev/null +++ b/app/src/main/res/layout/activity_ledger_detail.xml @@ -0,0 +1,290 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index acfaa779..0477c30f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -218,6 +218,12 @@ Account Details No Holder Found No Signature Authorities Found + Parent Ledger Identifier + Total Value + Sub Ledger + Show Account in Chart + Ledger Details + No Sub-ledger available Account*