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

Implemented Showcase view #2070

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
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
8 changes: 5 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ apply from: '../config/quality/quality.gradle'

android {
compileSdkVersion rootProject.ext.compileSdkVersion

defaultConfig {
applicationId "org.mifos.mobile"
minSdkVersion rootProject.ext.minSdkVersion
Expand Down Expand Up @@ -118,7 +118,7 @@ dependencies {
//Dagger dependencies
kapt "com.google.dagger:dagger-compiler:$rootProject.daggerVersion"
implementation "com.google.dagger:dagger:$rootProject.daggerVersion"
compileOnly 'javax.annotation:jsr250-api:1.0'
compileOnly 'javax.annotation:jsr250-api:1.0'
compileOnly 'com.github.pengrad:jdk9-deps:1.0' //Required by Dagger2

//Butter Knife
Expand Down Expand Up @@ -165,9 +165,11 @@ dependencies {
androidTestImplementation "androidx.test.espresso:espresso-core:$rootProject.espressoVersion"
androidTestImplementation "androidx.test:runner:$rootProject.runnerVersion"
androidTestImplementation "androidx.test:rules:$rootProject.rulesVersion"

implementation 'com.github.rahul-gill.mifos-ui-library:uihouse:alpha-2.1'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'

//showcase view
implementation 'com.github.mreram:showcaseview:1.4.1'
}
apply plugin: 'com.google.gms.google-services'
145 changes: 111 additions & 34 deletions app/src/main/java/org/mifos/mobile/ui/fragments/HomeOldFragment.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

package org.mifos.mobile.ui.fragments

import android.animation.LayoutTransition
Expand All @@ -24,6 +23,7 @@ import butterknife.ButterKnife
import butterknife.OnClick
import com.google.android.material.badge.BadgeDrawable
import com.google.android.material.badge.BadgeUtils
import com.google.android.material.card.MaterialCardView
import com.google.android.material.imageview.ShapeableImageView
import kotlinx.android.synthetic.main.fragment_home_old.*
import org.mifos.mobile.R
Expand All @@ -41,6 +41,10 @@ import org.mifos.mobile.ui.fragments.base.BaseFragment
import org.mifos.mobile.ui.getThemeAttributeColor
import org.mifos.mobile.ui.views.HomeOldView
import org.mifos.mobile.utils.*
import smartdevelop.ir.eram.showcaseviewlib.GuideView
import smartdevelop.ir.eram.showcaseviewlib.config.DismissType
import smartdevelop.ir.eram.showcaseviewlib.config.Gravity
import smartdevelop.ir.eram.showcaseviewlib.config.PointerType
import javax.inject.Inject

/**
Expand All @@ -60,7 +64,6 @@ class HomeOldFragment : BaseFragment(), HomeOldView, OnRefreshListener {
var llAccountDetail: LinearLayout? = null



@kotlin.jvm.JvmField
@BindView(R.id.iv_circular_user_image)
var ivCircularUserImage: ShapeableImageView? = null
Expand All @@ -81,6 +84,14 @@ class HomeOldFragment : BaseFragment(), HomeOldView, OnRefreshListener {
@Inject
var presenter: HomeOldPresenter? = null

@kotlin.jvm.JvmField
@BindView(R.id.ll_contact_us)
var llContactUs: LinearLayout? = null

@kotlin.jvm.JvmField
@BindView(R.id.ll_account_overview)
var llAccountOverview: MaterialCardView? = null

@kotlin.jvm.JvmField
@Inject
var preferencesHelper: PreferencesHelper? = null
Expand All @@ -93,26 +104,38 @@ class HomeOldFragment : BaseFragment(), HomeOldView, OnRefreshListener {
private var isDetailVisible: Boolean? = false
private var isReceiverRegistered = false
private var tvNotificationCount: TextView? = null
private var mGuideView: GuideView? = null
private var builder: GuideView.Builder? = null

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
rootView = inflater.inflate(R.layout.fragment_home_old, container, false)
(activity as HomeActivity?)?.activityComponent?.inject(this)
ButterKnife.bind(this, rootView!!)
clientId = preferencesHelper?.clientId
presenter?.attachView(this)
setHasOptionsMenu(true)
slHomeContainer?.setColorSchemeResources(R.color.blue_light, R.color.green_light, R.color.orange_light, R.color.red_light)
slHomeContainer?.setColorSchemeResources(
R.color.blue_light,
R.color.green_light,
R.color.orange_light,
R.color.red_light
)
slHomeContainer?.setOnRefreshListener(this)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
llContainer?.layoutTransition
?.enableTransitionType(LayoutTransition.CHANGING)
?.enableTransitionType(LayoutTransition.CHANGING)
}
if (savedInstanceState == null) {
loadClientData()
}

if (PreferencesHelper(context).getBoolean(Constants.SHOW_CASE, true) == true) {
showcaseView()
PreferencesHelper(context).putBoolean(Constants.SHOW_CASE, false)
}
setToolbarTitle(getString(R.string.home))
showUserInterface()
return rootView
Expand All @@ -130,7 +153,14 @@ class HomeOldFragment : BaseFragment(), HomeOldView, OnRefreshListener {
val count = menuItem.actionView
tvNotificationCount = count.findViewById(R.id.tv_notification_indicator)
presenter?.unreadNotificationsCount
count.setOnClickListener { startActivity(Intent(context, NotificationActivity::class.java)) }
count.setOnClickListener {
startActivity(
Intent(
context,
NotificationActivity::class.java
)
)
}
super.onCreateOptionsMenu(menu, inflater)
}

Expand All @@ -141,15 +171,18 @@ class HomeOldFragment : BaseFragment(), HomeOldView, OnRefreshListener {
}

override fun onPause() {
LocalBroadcastManager.getInstance(requireActivity()).unregisterReceiver(notificationReceiver)
LocalBroadcastManager.getInstance(requireActivity())
.unregisterReceiver(notificationReceiver)
isReceiverRegistered = false
super.onPause()
}

private fun registerReceiver() {
if (!isReceiverRegistered) {
LocalBroadcastManager.getInstance(requireActivity()).registerReceiver(notificationReceiver,
IntentFilter(Constants.NOTIFY_HOME_FRAGMENT))
LocalBroadcastManager.getInstance(requireActivity()).registerReceiver(
notificationReceiver,
IntentFilter(Constants.NOTIFY_HOME_FRAGMENT)
)
isReceiverRegistered = true
}
}
Expand Down Expand Up @@ -192,7 +225,8 @@ class HomeOldFragment : BaseFragment(), HomeOldView, OnRefreshListener {
*/
fun openAccount(accountType: AccountType?) {
(activity as BaseActivity?)?.replaceFragment(
ClientAccountsFragment.newInstance(accountType), true, R.id.container)
ClientAccountsFragment.newInstance(accountType), true, R.id.container
)
}

/**
Expand Down Expand Up @@ -255,15 +289,18 @@ class HomeOldFragment : BaseFragment(), HomeOldView, OnRefreshListener {
ivCircularUserImage?.setImageBitmap(bitmap)
} else {
val userName = preferencesHelper?.clientName.let { savedName ->
if(savedName.isNullOrBlank()) getString(R.string.app_name)
if (savedName.isNullOrBlank()) getString(R.string.app_name)
else savedName
}

val drawable = TextDrawable.builder()
.beginConfig()
.toUpperCase()
.endConfig()
.buildRound(userName.substring(0, 1),requireContext().getThemeAttributeColor(R.attr.colorPrimary))
.beginConfig()
.toUpperCase()
.endConfig()
.buildRound(
userName.substring(0, 1),
requireContext().getThemeAttributeColor(R.attr.colorPrimary)
)
ivCircularUserImage?.setImageDrawable(drawable)
}
}
Expand Down Expand Up @@ -330,31 +367,38 @@ class HomeOldFragment : BaseFragment(), HomeOldView, OnRefreshListener {
*/
@OnClick(R.id.ll_transfer)
fun transferClicked() {
val transferTypes = arrayOf(getString(R.string.transfer), getString(R.string.third_party_transfer))
val transferTypes =
arrayOf(getString(R.string.transfer), getString(R.string.third_party_transfer))
MaterialDialog.Builder().init(activity)
.setTitle(R.string.choose_transfer_type)
.setItems(transferTypes,
DialogInterface.OnClickListener { _, which ->
if (which == 0) {
(activity as HomeActivity?)?.replaceFragment(
SavingsMakeTransferFragment.newInstance(1, ""), true,
R.id.container)
} else {
(activity as HomeActivity?)?.replaceFragment(
ThirdPartyTransferFragment.newInstance(), true, R.id.container)
}
})
.createMaterialDialog()
.show()
.setTitle(R.string.choose_transfer_type)
.setItems(transferTypes,
DialogInterface.OnClickListener { _, which ->
if (which == 0) {
(activity as HomeActivity?)?.replaceFragment(
SavingsMakeTransferFragment.newInstance(1, ""), true,
R.id.container
)
} else {
(activity as HomeActivity?)?.replaceFragment(
ThirdPartyTransferFragment.newInstance(), true, R.id.container
)
}
})
.createMaterialDialog()
.show()
}

/**
* Opens [ClientChargeFragment] to display all Charges associated with client's account
*/
@OnClick(R.id.ll_charges)
fun chargesClicked() {
(activity as HomeActivity?)?.replaceFragment(ClientChargeFragment.newInstance(clientId,
ChargeType.CLIENT), true, R.id.container)
(activity as HomeActivity?)?.replaceFragment(
ClientChargeFragment.newInstance(
clientId,
ChargeType.CLIENT
), true, R.id.container
)
}

/**
Expand All @@ -371,7 +415,11 @@ class HomeOldFragment : BaseFragment(), HomeOldView, OnRefreshListener {
*/
@OnClick(R.id.ll_beneficiaries)
fun beneficiaries() {
(activity as HomeActivity?)?.replaceFragment(BeneficiaryListFragment.newInstance(), true, R.id.container)
(activity as HomeActivity?)?.replaceFragment(
BeneficiaryListFragment.newInstance(),
true,
R.id.container
)
}

@OnClick(R.id.ll_surveys)
Expand Down Expand Up @@ -420,4 +468,33 @@ class HomeOldFragment : BaseFragment(), HomeOldView, OnRefreshListener {
return HomeOldFragment()
}
}

private fun showcaseView() {

builder = GuideView.Builder(requireContext())
.setContentText(getString(R.string.show_case_user_details))
.setGravity(Gravity.center)
.setDismissType(DismissType.anywhere)
.setPointerType(PointerType.circle)
.setTargetView(ivCircularUserImage)
.setGuideListener { view: View ->
when (view.id) {
R.id.iv_circular_user_image -> {
builder!!.setTargetView(llAccountOverview)
.setContentText(getString(R.string.show_case_amount_loan)).build()
}
R.id.ll_account_overview -> {
builder!!.setTargetView(llContactUs)
.setContentText(getString(R.string.show_case_contact_us)).build()
}
R.id.ll_contact_us -> return@setGuideListener
}
mGuideView = builder!!.build()
mGuideView!!.show()
}

mGuideView = builder!!.build()
mGuideView!!.show()

}
}
1 change: 1 addition & 0 deletions app/src/main/java/org/mifos/mobile/utils/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@ object Constants {
const val LOAN_REPAYMENT = "loan_repayment"
const val CURR_PASSWORD = "currentPassword"
const val IS_TO_UPDATE_PASS_CODE = "updatePassCode"
const val SHOW_CASE = "show_case"
}
Loading