Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profile Photo on click opens #158

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)

}

Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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 -> {
Expand All @@ -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
Expand All @@ -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(", ")
Expand Down Expand Up @@ -171,19 +170,21 @@ class CustomerDetailsFragment : MifosBaseFragment(), AppBarLayout.OnOffsetChange
}
showToolbarTitleSubtitle(title, subtitle)
}

override fun showUserInterface() {
if (toolbar_customer != null) {
(activity as AppCompatActivity).setSupportActionBar(toolbar_customer)
(activity as AppCompatActivity).supportActionBar!!
.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)

}

Expand All @@ -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!!
}
Expand All @@ -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()
Expand All @@ -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)
}




}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
garvit984 marked this conversation as resolved.
Show resolved Hide resolved
}
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)
Expand All @@ -69,6 +76,9 @@ class DashboardFragment : MifosBaseFragment(), View.OnClickListener {
R.id.ll_recent_transactions -> {
showRecentTransactions()
}
R.id.iv_user_image -> {
openCustomerProfile()
}
}
}

Expand All @@ -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),
Expand Down