Skip to content

Commit

Permalink
Transfer Screen Implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
garvit984 committed Apr 17, 2020
1 parent ade5d7a commit 49f6eb7
Show file tree
Hide file tree
Showing 65 changed files with 1,635 additions and 115 deletions.
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
Expand All @@ -13,6 +14,7 @@
android:name=".MifosApplication"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:theme="@style/AppTheme">
<activity android:name=".ui.mifos.launcher.LauncherActivity"
android:theme="@style/LauncherTheme">
Expand All @@ -24,6 +26,7 @@
</activity>

<activity android:name=".ui.mifos.DashboardActivity" />
<activity android:name=".ui.mifos.Main" />
<activity android:name=".ui.mifos.login.LoginActivity" />
<activity android:name=".ui.mifos.passcode.PasscodeActivity"/>
<activity android:name=".ui.mifos.loanApplication.loanActivity.LoanApplicationActivity"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package org.mifos.mobile.cn.injection.component
import dagger.Subcomponent
import org.mifos.mobile.cn.injection.PerActivity
import org.mifos.mobile.cn.injection.module.ActivityModule
import org.mifos.mobile.cn.ui.mifos.Account
import org.mifos.mobile.cn.ui.mifos.DashboardActivity
import org.mifos.mobile.cn.ui.mifos.aboutus.AboutUsFragment
import org.mifos.mobile.cn.ui.mifos.accounts.AccountsFragment
Expand Down Expand Up @@ -39,6 +40,8 @@ interface ActivityComponent {

fun inject(passcodeActivity: PasscodeActivity)

fun inject(account :Account)

fun inject(launcherActivity: LauncherActivity)

fun inject(dashboardActivity: DashboardActivity)
Expand Down
194 changes: 194 additions & 0 deletions app/src/main/kotlin/org/mifos/mobile/cn/ui/mifos/Account.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
package org.mifos.mobile.cn.ui.mifos

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import kotlinx.android.synthetic.main.fragment_account.*
import kotlinx.android.synthetic.main.fragment_accounts.*
import org.mifos.mobile.cn.R
import org.mifos.mobile.cn.data.models.CheckboxStatus
import org.mifos.mobile.cn.data.models.accounts.deposit.DepositAccount
import org.mifos.mobile.cn.data.models.accounts.loan.LoanAccount
import org.mifos.mobile.cn.ui.adapter.DepositAccountListAdapter
import org.mifos.mobile.cn.ui.adapter.LoanAccountListAdapter
import org.mifos.mobile.cn.ui.base.MifosBaseActivity
import org.mifos.mobile.cn.ui.base.MifosBaseFragment
import org.mifos.mobile.cn.ui.base.OnItemClickListener
import org.mifos.mobile.cn.ui.mifos.accounts.AccountsContract
import org.mifos.mobile.cn.ui.mifos.accounts.AccountsFragment
import org.mifos.mobile.cn.ui.mifos.accounts.AccountsPresenter
import org.mifos.mobile.cn.ui.mifos.customerDepositDetails.CustomerDepositDetailsFragment
import org.mifos.mobile.cn.ui.mifos.customerLoanDetails.CustomerLoanDetailsFragment
import org.mifos.mobile.cn.ui.utils.ConstantKeys
import javax.inject.Inject

class Account : MifosBaseFragment() , View.OnClickListener, OnItemClickListener, AccountsContract.View {
private lateinit var accountType: String
private lateinit var loanAccounts: List<LoanAccount>
private lateinit var depositAccounts: List<DepositAccount>
var currentFilterList: List<CheckboxStatus>? = null

@Inject
internal lateinit var accountsPresenter: AccountsPresenter

@Inject
lateinit var loanAccountsListAdapter: LoanAccountListAdapter

@Inject
lateinit var depositAccountListAdapter: DepositAccountListAdapter
companion object {
fun newInstance(accountType: String): Account {
val fragment = Account()
val args = Bundle()
args.putString(ConstantKeys.ACCOUNT_TYPE, accountType)
fragment.arguments = args
return fragment
}
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
// Inflate the layout for this fragment
getToolbar().setVisibility(View.GONE);
val rootview: View = inflater.inflate(R.layout.fragment_account,
container, false)
(activity as MifosBaseActivity).activityComponent.inject(this)
accountsPresenter.attachView(this)
return rootview
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
(activity as MifosBaseActivity).activityComponent.inject(this)
loanAccounts = ArrayList()
depositAccounts = ArrayList()
if (arguments != null) {
accountType = arguments!!.getString(ConstantKeys.ACCOUNT_TYPE)
}

}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val layoutManager = LinearLayoutManager(activity)
layoutManager.orientation = LinearLayoutManager.VERTICAL
deposit_r.layoutManager = layoutManager
deposit_r.setHasFixedSize(true)
deposit_r.addItemDecoration(DividerItemDecoration(activity,
layoutManager.orientation))
val layoutManager1 = LinearLayoutManager(activity)
layoutManager1.orientation = LinearLayoutManager.VERTICAL
loan_r.layoutManager = layoutManager1
loan_r.setHasFixedSize(true)
loan_r.addItemDecoration(DividerItemDecoration(activity,
layoutManager.orientation))
btn_deposit.setOnClickListener(this)
btn_loan.setOnClickListener(this)
accountsPresenter.loadLoanAccounts()
accountsPresenter.loadDepositAccounts()
when (accountType) {
ConstantKeys.LOAN_ACCOUNTS -> {
loan_r.adapter = loanAccountsListAdapter
loanAccountsListAdapter.setOnItemClickListener(this)
}
ConstantKeys.DEPOSIT_ACCOUNTS -> {
deposit_r.adapter = depositAccountListAdapter
depositAccountListAdapter.setOnItemClickListener(this)
}
}
}

override fun onClick(view: View) {
when(view.id)
{
R.id.btn_deposit -> {
deposit()
}
R.id.btn_loan -> {
loan()
}
}

}

private fun loan() {
btn_loan.isSelected = true
btn_loan.isFocusable = true
btn_loan.setChipBackgroundColorResource(R.color.white)
btn_deposit.isSelected = false
btn_deposit.setChipBackgroundColorResource(R.color.light_grey)
loan_r.visibility = View.VISIBLE
loan_r.setHasFixedSize(true)
deposit_r.visibility = View.GONE
loan_r.adapter = loanAccountsListAdapter
loanAccountsListAdapter.setOnItemClickListener(this)
accountType="loanAccounts"
}

private fun deposit() {
btn_deposit.isSelected = true
btn_deposit.isFocusable = true
btn_deposit.setChipBackgroundColorResource(R.color.white)
btn_loan.isSelected = false
btn_loan.setChipBackgroundColorResource(R.color.light_grey)
deposit_r.visibility = View.VISIBLE
deposit_r.setHasFixedSize(true)
loan_r.visibility = View.GONE
accountType="deposit_accounts"
}

override fun onItemClick(childView: View, position: Int) {
when (accountType) {
ConstantKeys.LOAN_ACCOUNTS -> {
(activity as MifosBaseActivity).replaceFragment(
CustomerLoanDetailsFragment.newInstance(
loanAccounts[position].productIdentifier!!,
loanAccounts[position].identifier!!), true, R.id.bottom_navigation_fragment_container)
}
ConstantKeys.DEPOSIT_ACCOUNTS -> {
(activity as MifosBaseActivity).replaceFragment(
CustomerDepositDetailsFragment.newInstance(
depositAccounts[position].accountIdentifier!!),true,R.id.bottom_navigation_fragment_container
)
}
}
}

override fun onItemLongPress(childView: View, position: Int) {
TODO("Not yet implemented")
}

override fun showLoanAccounts(loanAccounts: List<LoanAccount>) {
this.loanAccounts = loanAccounts
if (loanAccounts.isNotEmpty()) {
loanAccountsListAdapter.setCustomerLoanAccounts(loanAccounts)
} else {
showEmptyAccounts(getString(R.string.loan))
}
}
override fun showDepositAccounts(depositAccounts: List<DepositAccount>) {
this.depositAccounts = depositAccounts
if (depositAccounts.isNotEmpty()) {
depositAccountListAdapter.setCustomerDepositAccounts(depositAccounts)
} else {
showEmptyAccounts(getString(R.string.deposit))
}

}

override fun showEmptyAccounts(feature: String) {
TODO("Not yet implemented")
}

override fun showError(message: String) {
TODO("Not yet implemented")
}

override fun showProgress() {

}

override fun hideProgress() {
hideProgressBar()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ import org.mifos.mobile.cn.ui.mifos.settings.SettingsFragment
import org.mifos.mobile.cn.ui.utils.CircularImageView
import org.mifos.mobile.cn.ui.utils.Toaster
import android.widget.Toast
import com.mifos.mobile.passcode.utils.PasscodePreferencesHelper
import org.mifos.mobile.cn.ui.mifos.passcode.PasscodeActivity
import org.mifos.mobile.cn.ui.utils.ConstantKeys

class DashboardActivity : MifosBaseActivity(), View.OnClickListener, NavigationView.OnNavigationItemSelectedListener {

@Inject
internal lateinit var preferencesHelper: PreferencesHelper

private var passcodePreferencesHelper: PasscodePreferencesHelper? = null
private lateinit var tvUsername: TextView
private lateinit var ivCircularUserProfilePicture: CircularImageView
private lateinit var ivTextDrawableUserProfilePicture: ImageView
Expand All @@ -52,7 +55,7 @@ class DashboardActivity : MifosBaseActivity(), View.OnClickListener, NavigationV
setupNavigationBar()
setToolbarElevation()

replaceFragment(DashboardFragment.newInstance(), false, R.id.container)
replaceFragment(DashboardFragment.newInstance("customer_identifier"), false, R.id.container)

}

Expand Down Expand Up @@ -95,10 +98,6 @@ class DashboardActivity : MifosBaseActivity(), View.OnClickListener, NavigationV
val actionBarDrawerToggle = object : ActionBarDrawerToggle(this,
drawerLayout, getToolbar(), R.string.open_drawer, R.string.close_drawer) {

override fun onDrawerClosed(drawerView: View) {
super.onDrawerClosed(drawerView)
}

override fun onDrawerOpened(drawerView: View) {
super.onDrawerOpened(drawerView)
hideKeyboard(drawerView)
Expand Down Expand Up @@ -160,7 +159,7 @@ class DashboardActivity : MifosBaseActivity(), View.OnClickListener, NavigationV
when (item.itemId) {
R.id.item_home -> {
hideToolbarElevation()
replaceFragment(DashboardFragment.newInstance(), true, R.id.container)
replaceFragment(DashboardFragment.newInstance("customer_identifier"), true, R.id.container)
}
R.id.item_accounts -> {
replaceFragment(CustomerAccountFragment.newInstance(AccountType.DEPOSIT), true,
Expand All @@ -170,7 +169,17 @@ class DashboardActivity : MifosBaseActivity(), View.OnClickListener, NavigationV
R.id.item_logout -> {
showLogoutDialog()
}

R.id.item_passcode ->{
if (this != null) {
passcodePreferencesHelper = PasscodePreferencesHelper(this)
val currentPass: String = passcodePreferencesHelper!!.getPassCode()
passcodePreferencesHelper!!.savePassCode("")
val intent = Intent(this, PasscodeActivity::class.java)
intent.putExtra(ConstantKeys.CURR_PASSWORD, currentPass)
intent.putExtra(ConstantKeys.UPDATE_PASSWORD_KEY, true)
startActivity(intent)
}
}
R.id.item_product -> {
replaceFragment(ProductFragment.Companion.newInstance(), true,
R.id.container)
Expand Down
21 changes: 21 additions & 0 deletions app/src/main/kotlin/org/mifos/mobile/cn/ui/mifos/Home.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.mifos.mobile.cn.ui.mifos

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import org.mifos.mobile.cn.R
import org.mifos.mobile.cn.ui.Test1
import org.mifos.mobile.cn.ui.base.MifosBaseFragment

class Home : MifosBaseFragment() {
companion object {
fun newInstance(): Home = Home()
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
// Inflate the layout for this fragment
getToolbar().setVisibility(View.GONE);
return inflater.inflate(R.layout.fragment_home, container, false)
}
}
Loading

0 comments on commit 49f6eb7

Please sign in to comment.