From 742ccd0a5d0b3bc147dbef1db12d076cbf63bf19 Mon Sep 17 00:00:00 2001 From: garvit984 Date: Fri, 13 Mar 2020 16:15:29 +0530 Subject: [PATCH 1/2] FIX-152 --- .../CustomerDetailsFragment.kt | 91 ++++++++++--------- .../main/res/layout/fragment_dashboard.xml | 2 +- 2 files changed, 47 insertions(+), 46 deletions(-) diff --git a/app/src/main/kotlin/org/mifos/mobile/cn/ui/mifos/customerDetails/CustomerDetailsFragment.kt b/app/src/main/kotlin/org/mifos/mobile/cn/ui/mifos/customerDetails/CustomerDetailsFragment.kt index 507d1ac1..d8cf978c 100644 --- a/app/src/main/kotlin/org/mifos/mobile/cn/ui/mifos/customerDetails/CustomerDetailsFragment.kt +++ b/app/src/main/kotlin/org/mifos/mobile/cn/ui/mifos/customerDetails/CustomerDetailsFragment.kt @@ -28,44 +28,43 @@ import org.mifos.mobile.cn.ui.views.HeaderView import javax.inject.Inject -class CustomerDetailsFragment : MifosBaseFragment(), AppBarLayout.OnOffsetChangedListener,CustomerDetailsContract.View, View.OnClickListener{ - +class CustomerDetailsFragment : MifosBaseFragment(), AppBarLayout.OnOffsetChangedListener, CustomerDetailsContract.View, View.OnClickListener { @Inject lateinit var customerDetailsPresenter: CustomerDetailsPresenter - private lateinit var rootView : View - private lateinit var customerIdentification : String - private var isHideToolbarView: Boolean = false - private lateinit var collapsingToolbarLayout : CollapsingToolbarLayout - private lateinit var customer : Customer - private lateinit var toolbarHeaderView : HeaderView - private lateinit var floatHeaderView : HeaderView - - companion object { - fun newInstance(identifier: String): CustomerDetailsFragment { - val fragment = CustomerDetailsFragment() - val args = Bundle() - args.putString(ConstantKeys.CUSTOMER_IDENTIFIER,identifier) - fragment.arguments = args - return fragment - - } - } + private lateinit var rootView: View + private lateinit var customerIdentification: String + private var isHideToolbarView: Boolean = false + private lateinit var collapsingToolbarLayout: CollapsingToolbarLayout + private lateinit var customer: Customer + private lateinit var toolbarHeaderView: HeaderView + private lateinit var floatHeaderView: HeaderView + + companion object { + fun newInstance(identifier: String): CustomerDetailsFragment { + val fragment = CustomerDetailsFragment() + val args = Bundle() + args.putString(ConstantKeys.CUSTOMER_IDENTIFIER, identifier) + fragment.arguments = args + return fragment + } + } - override fun onCreate(savedInstanceState: Bundle?){ + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setToolbarTitle(getString(R.string.account_overview)) - if(arguments != null){1 + if (arguments != null) { + 1 customerIdentification = arguments!!.getString(ConstantKeys.CUSTOMER_IDENTIFIER) } } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - rootView = inflater.inflate(R.layout.fragment_customer_details,container,false) + rootView = inflater.inflate(R.layout.fragment_customer_details, container, false) (activity as MifosBaseActivity).activityComponent.inject(this) customerDetailsPresenter.attachView(this) @@ -88,12 +87,13 @@ class CustomerDetailsFragment : MifosBaseFragment(), AppBarLayout.OnOffsetChange } + override fun onClick(view: View) { - when(view.id){ + when (view.id) { R.id.ll_deposit_accounts -> { openDepositAccount() } - R.id.ll_loan_accounts-> { + R.id.ll_loan_accounts -> { openLoanAccount() } R.id.ll_activities -> { @@ -117,13 +117,12 @@ class CustomerDetailsFragment : MifosBaseFragment(), AppBarLayout.OnOffsetChange override fun onResume() { super.onResume() - cl_customer_details.visibility = View.GONE - collapsingToolbarLayout.title= " " + cl_customer_details.visibility = View.GONE + collapsingToolbarLayout.title = " " customerDetailsPresenter.loadCustomerDetails(customerIdentification) } - override fun showCustomerDetails(customer: Customer) { this.customer = customer cl_customer_details.visibility = View.VISIBLE @@ -132,10 +131,10 @@ class CustomerDetailsFragment : MifosBaseFragment(), AppBarLayout.OnOffsetChange loadCustomerPortrait() tv_current_status.text = customer.currentState!!.name - StatusUtils.setCustomerStatusIcon(customer.currentState!!,iv_current_status,context) + StatusUtils.setCustomerStatusIcon(customer.currentState!!, iv_current_status, context) - val address : Address = customer.address!! + val address: Address = customer.address!! val addressBuilder = StringBuilder() addressBuilder .append(address.street).append(", ") @@ -171,6 +170,7 @@ class CustomerDetailsFragment : MifosBaseFragment(), AppBarLayout.OnOffsetChange } showToolbarTitleSubtitle(title, subtitle) } + override fun showUserInterface() { if (toolbar_customer != null) { (activity as AppCompatActivity).setSupportActionBar(toolbar_customer) @@ -178,12 +178,13 @@ class CustomerDetailsFragment : MifosBaseFragment(), AppBarLayout.OnOffsetChange .setDisplayHomeAsUpEnabled(true) } - collapsingToolbarLayout.title= " " + collapsingToolbarLayout.title = " " app_bar_layout.addOnOffsetChangedListener(this) } + override fun showToolbarTitleSubtitle(title: String, subtitle: String) { - toolbarHeaderView.bindTo(title,subtitle) - floatHeaderView.bindTo(title,subtitle) + toolbarHeaderView.bindTo(title, subtitle) + floatHeaderView.bindTo(title, subtitle) } @@ -206,25 +207,22 @@ class CustomerDetailsFragment : MifosBaseFragment(), AppBarLayout.OnOffsetChange } - override fun loadCustomerPortrait() { val imageLoaderUtils = ImageLoaderUtils(this.context!!) - imageLoaderUtils.loadImage(imageLoaderUtils.buildCustomerPortraitImageUrl(customer.identifier),iv_customer_profile,R.drawable.mifos_logo_new) + imageLoaderUtils.loadImage(imageLoaderUtils.buildCustomerPortraitImageUrl(customer.identifier), iv_customer_profile, R.drawable.mifos_logo_new) } override fun showProgressbar() { - showProgressBar() + showProgressBar() } override fun hideProgressbar() { - hideProgressBar() + hideProgressBar() } - - override fun getCustomerStatus(): Customer.State { return customer.currentState!! } @@ -241,6 +239,7 @@ class CustomerDetailsFragment : MifosBaseFragment(), AppBarLayout.OnOffsetChange hideProgressDialog() customerDetailsPresenter.detachView() } + override fun onOffsetChanged(appBarLayout: AppBarLayout?, verticalOffset: Int) { val maxScroll = appBarLayout!!.totalScrollRange val percentage = Math.abs(verticalOffset).toFloat() / maxScroll.toFloat() @@ -254,28 +253,30 @@ class CustomerDetailsFragment : MifosBaseFragment(), AppBarLayout.OnOffsetChange } } + private fun openDepositAccount() { (activity as MifosBaseActivity) .replaceFragment(CustomerAccountFragment.newInstance(AccountType.DEPOSIT), true, R.id.container) } + private fun openLoanAccount() { (activity as MifosBaseActivity) .replaceFragment(CustomerAccountFragment.newInstance(AccountType.LOAN), true, R.id.container) } + private fun openCustomerActivities() { - val intent = Intent(activity,CustomerActivitiesActivity::class.java) - intent.putExtra(ConstantKeys.CUSTOMER_IDENTIFIER,"customer_identifier") + val intent = Intent(activity, CustomerActivitiesActivity::class.java) + intent.putExtra(ConstantKeys.CUSTOMER_IDENTIFIER, "customer_identifier") startActivity(intent) } + private fun openIdentificationCards() { - val intent = Intent(activity,IdentificationsActivity::class.java) - intent.putExtra(ConstantKeys.CUSTOMER_IDENTIFIER,"customer_identifier") + val intent = Intent(activity, IdentificationsActivity::class.java) + intent.putExtra(ConstantKeys.CUSTOMER_IDENTIFIER, "customer_identifier") startActivity(intent) } - - } \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_dashboard.xml b/app/src/main/res/layout/fragment_dashboard.xml index f3fd880e..7e2d8adc 100644 --- a/app/src/main/res/layout/fragment_dashboard.xml +++ b/app/src/main/res/layout/fragment_dashboard.xml @@ -40,7 +40,7 @@ android:layout_width="65dp" android:visibility="visible" android:background="?selectableItemBackgroundBorderless" - android:clickable="true" + android:clickable="false" app:srcCompat="@drawable/ic_person_black_24dp"/> Date: Sat, 14 Mar 2020 15:41:18 +0530 Subject: [PATCH 2/2] Profile photo problem solved --- .../mobile/cn/ui/mifos/DashboardActivity.kt | 4 ++-- .../CustomerProfileActivity.kt | 2 -- .../ui/mifos/dashboard/DashboardFragment.kt | 20 ++++++++++++++++--- .../main/res/layout/fragment_dashboard.xml | 2 +- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/org/mifos/mobile/cn/ui/mifos/DashboardActivity.kt b/app/src/main/kotlin/org/mifos/mobile/cn/ui/mifos/DashboardActivity.kt index 6895b8e2..c303a3a4 100644 --- a/app/src/main/kotlin/org/mifos/mobile/cn/ui/mifos/DashboardActivity.kt +++ b/app/src/main/kotlin/org/mifos/mobile/cn/ui/mifos/DashboardActivity.kt @@ -52,7 +52,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) } @@ -160,7 +160,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, diff --git a/app/src/main/kotlin/org/mifos/mobile/cn/ui/mifos/customerProfile/CustomerProfileActivity.kt b/app/src/main/kotlin/org/mifos/mobile/cn/ui/mifos/customerProfile/CustomerProfileActivity.kt index 27cf1165..d68aa176 100644 --- a/app/src/main/kotlin/org/mifos/mobile/cn/ui/mifos/customerProfile/CustomerProfileActivity.kt +++ b/app/src/main/kotlin/org/mifos/mobile/cn/ui/mifos/customerProfile/CustomerProfileActivity.kt @@ -12,13 +12,11 @@ import android.provider.MediaStore import android.view.Menu import android.view.MenuItem import android.widget.ImageView -import com.github.therajanmaurya.sweeterror.SweetUIErrorHandler import kotlinx.android.synthetic.main.activity_customer_profile.* import org.mifos.mobile.cn.R import org.mifos.mobile.cn.ui.base.MifosBaseActivity import org.mifos.mobile.cn.ui.utils.* import java.io.ByteArrayOutputStream -import java.util.jar.Manifest class CustomerProfileActivity: MifosBaseActivity(),CustomerProfileContract.View { diff --git a/app/src/main/kotlin/org/mifos/mobile/cn/ui/mifos/dashboard/DashboardFragment.kt b/app/src/main/kotlin/org/mifos/mobile/cn/ui/mifos/dashboard/DashboardFragment.kt index 977343ff..0c3d1554 100644 --- a/app/src/main/kotlin/org/mifos/mobile/cn/ui/mifos/dashboard/DashboardFragment.kt +++ b/app/src/main/kotlin/org/mifos/mobile/cn/ui/mifos/dashboard/DashboardFragment.kt @@ -13,20 +13,22 @@ import org.mifos.mobile.cn.ui.base.MifosBaseActivity import org.mifos.mobile.cn.ui.base.MifosBaseFragment import org.mifos.mobile.cn.ui.mifos.customerAccounts.CustomerAccountFragment import org.mifos.mobile.cn.ui.mifos.customerDetails.CustomerDetailsActivity +import org.mifos.mobile.cn.ui.mifos.customerProfile.CustomerProfileActivity import org.mifos.mobile.cn.ui.mifos.loanApplication.loanActivity.LoanApplicationActivity import org.mifos.mobile.cn.ui.mifos.recentTransactions.RecentTransactionsFragment import org.mifos.mobile.cn.ui.utils.ConstantKeys class DashboardFragment : MifosBaseFragment(), View.OnClickListener { - + private lateinit var customerIdentification: String private lateinit var rootView: View private lateinit var customer: Customer companion object { - fun newInstance(): DashboardFragment { + fun newInstance(identifier: String): DashboardFragment { val fragment = DashboardFragment() val args = Bundle() + args.putString(ConstantKeys.CUSTOMER_IDENTIFIER, identifier) fragment.arguments = args return fragment } @@ -38,12 +40,17 @@ class DashboardFragment : MifosBaseFragment(), View.OnClickListener { rootView = inflater.inflate(R.layout.fragment_dashboard, container, false) setHasOptionsMenu(true) setToolbarTitle(getString(R.string.home)) + if (arguments != null) { + 1 + customerIdentification = arguments!!.getString(ConstantKeys.CUSTOMER_IDENTIFIER) + } return rootView } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) ll_apply_for_loan.setOnClickListener(this) + iv_user_image.setOnClickListener(this) ll_accounts.setOnClickListener(this) ll_account_overview.setOnClickListener(this) ll_recent_transactions.setOnClickListener(this) @@ -69,6 +76,9 @@ class DashboardFragment : MifosBaseFragment(), View.OnClickListener { R.id.ll_recent_transactions -> { showRecentTransactions() } + R.id.iv_user_image -> { + openCustomerProfile() + } } } @@ -77,7 +87,11 @@ class DashboardFragment : MifosBaseFragment(), View.OnClickListener { intent.putExtra(ConstantKeys.CUSTOMER_IDENTIFIER, "customer_identifier") startActivity(intent) } - + private fun openCustomerProfile() { + val intent = Intent(activity, CustomerProfileActivity::class.java) + intent.putExtra(ConstantKeys.CUSTOMER_IDENTIFIER, customerIdentification) + startActivity(intent) + } private fun openAccount() { (activity as MifosBaseActivity) .replaceFragment(CustomerAccountFragment.newInstance(AccountType.DEPOSIT), diff --git a/app/src/main/res/layout/fragment_dashboard.xml b/app/src/main/res/layout/fragment_dashboard.xml index 7e2d8adc..f3fd880e 100644 --- a/app/src/main/res/layout/fragment_dashboard.xml +++ b/app/src/main/res/layout/fragment_dashboard.xml @@ -40,7 +40,7 @@ android:layout_width="65dp" android:visibility="visible" android:background="?selectableItemBackgroundBorderless" - android:clickable="false" + android:clickable="true" app:srcCompat="@drawable/ic_person_black_24dp"/>