Skip to content

Commit

Permalink
Merge tag 'v2.02.01' into develop
Browse files Browse the repository at this point in the history
v2.01.01 v2.02.01
  • Loading branch information
Ishwor-Shrestha committed Oct 5, 2021
2 parents b4dd2fc + 2a663ae commit cbc1842
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 46 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

### 2.01.01
- Cleared form data on back pressed
- Cleared form data on successful payment

### 2.01.00
- Dropped android sdk support below 21
- Migrated to maven from jcenter for deployment
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
release {
minifyEnabled true
shrinkResources true
debuggable false
debuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Expand All @@ -35,6 +35,6 @@ dependencies {
/*ButterKnife*/
implementation "com.jakewharton:butterknife:${butterKnifeVersion}"
annotationProcessor "com.jakewharton:butterknife-compiler:${butterKnifeVersion}"
implementation "com.khalti:khalti-android:2.01.00"
implementation "com.khalti:khalti-android:2.01.01"
// implementation project(':khalti-android')
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class CheckOutActivity : AppCompatActivity(), CheckOutContract.View, BaseComm {

private val searchViewMap = HashMap<String, SearchView>()
private val searchViewMapInitSignal = Signal<Any>()
private val backPressSignal:Signal<Any> = Signal<Any>()

companion object {
var isActive: Boolean = false
Expand Down Expand Up @@ -174,9 +175,7 @@ class CheckOutActivity : AppCompatActivity(), CheckOutContract.View, BaseComm {
window.decorView.systemUiVisibility = flags
window.statusBarColor = ResourceUtil.getColor(this, R.color.bg)
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && Build.VERSION.SDK_INT < 23) {
window.statusBarColor = ResourceUtil.getColor(this, R.color.khaltiPrimaryDark)
}
window.statusBarColor = ResourceUtil.getColor(this, R.color.khaltiPrimaryDark)
}
}

Expand Down Expand Up @@ -237,8 +236,13 @@ class CheckOutActivity : AppCompatActivity(), CheckOutContract.View, BaseComm {
}
}

override fun getBackPressedSignal(): Signal<Any> {
return backPressSignal;
}

override fun onBackPressed() {
presenter.onBackPressed()
backPressSignal.emit(true);
super.onBackPressed()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.khalti.checkout.helper.CheckoutEventListener
import com.khalti.checkout.helper.Config
import com.khalti.checkout.helper.PaymentPreference
import com.khalti.signal.CompositeSignal
import com.khalti.signal.Signal
import com.khalti.utils.EmptyUtil
import com.khalti.utils.GuavaUtil
import com.khalti.utils.HandlerUtil
Expand Down Expand Up @@ -84,7 +85,6 @@ class CheckOutPresenter(view: CheckOutContract.View) : CheckOutContract.Presente

override fun onTabSelected(preferences: List<PaymentPreference>, it: Map<String, Any>) {
currentPage = it.getValue("position") as Int
// view.toggleTab(currentPage, it.getValue("selected") as Boolean, it.getValue("id") as String)
view.toggleSearch(preferences[currentPage].value, searchList.contains(preferences[currentPage].value))
}

Expand Down
39 changes: 35 additions & 4 deletions khalti-android/src/main/java/com/khalti/checkout/form/Form.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ class Form : Fragment(), FormContract.View {
}

if (show) {
val pair = UserInterfaceUtil.runProgressDialog(fragmentActivity, message, ResourceUtil.getString(fragmentActivity, R.string.please_wait))
val pair = UserInterfaceUtil.runProgressDialog(
fragmentActivity,
message,
ResourceUtil.getString(fragmentActivity, R.string.please_wait)
)
progressDialog = pair.first
signal = pair.second
} else {
Expand All @@ -90,7 +94,10 @@ class Form : Fragment(), FormContract.View {
}

override fun toggleConfirmationLayout(show: Boolean) {
val buttonText = if (show) ResourceUtil.getString(fragmentActivity, R.string.confirm_payment) else "Pay Rs ${NumberUtil.convertToRupees(Store.getConfig().amount)}"
val buttonText = if (show) ResourceUtil.getString(
fragmentActivity,
R.string.confirm_payment
) else "Pay Rs ${NumberUtil.convertToRupees(Store.getConfig().amount)}"
binding.btnPay.text = buttonText
binding.etCode.setText("")
binding.elConfirmation.toggleExpansion()
Expand Down Expand Up @@ -209,12 +216,26 @@ class Form : Fragment(), FormContract.View {
}

override fun showNetworkError() {
UserInterfaceUtil.showSnackBar(fragmentActivity, baseComm.getCoordinator(), ResourceUtil.getString(fragmentActivity, R.string.network_error_body), null, Snackbar.LENGTH_LONG)
UserInterfaceUtil.showSnackBar(
fragmentActivity,
baseComm.getCoordinator(),
ResourceUtil.getString(fragmentActivity, R.string.network_error_body),
null,
Snackbar.LENGTH_LONG
)
}

override fun showMessageDialog(title: String, message: String, actionListener: Boolean): Signal<Boolean> {
val cancelText = if (actionListener) ResourceUtil.getString(fragmentActivity, R.string.cancel) else null
return UserInterfaceUtil.showInfoDialog(fragmentActivity, title, message, autoDismiss = true, cancelable = true, positiveText = ResourceUtil.getString(fragmentActivity, R.string.ok), negativeText = cancelText)
return UserInterfaceUtil.showInfoDialog(
fragmentActivity,
title,
message,
autoDismiss = true,
cancelable = true,
positiveText = ResourceUtil.getString(fragmentActivity, R.string.ok),
negativeText = cancelText
)
}

override fun showSlogan() {
Expand Down Expand Up @@ -316,6 +337,16 @@ class Form : Fragment(), FormContract.View {
}
}

override fun clearForm() {
binding.etMobile.setText("")
binding.etCode.setText("")
binding.etPIN.setText("")
}

override fun getBackPressedSignal(): Signal<Any> {
return baseComm.getBackPressedSignal()
}

override fun setPresenter(presenter: FormContract.Presenter) {
this.presenter = presenter
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package com.khalti.checkout.form


import com.khalti.base.LifeCycle

import com.khalti.checkout.api.Result
import com.khalti.checkout.form.helper.WalletConfirmPojo
import com.khalti.checkout.form.helper.WalletInitPojo
import com.khalti.checkout.api.Result
import com.khalti.checkout.helper.Config
import com.khalti.signal.Signal

Expand Down Expand Up @@ -72,6 +71,10 @@ interface FormContract {

fun doesPackageExist(): Boolean

fun clearForm()

fun getBackPressedSignal(): Signal<Any>

fun setPresenter(presenter: Presenter)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.khalti.checkout.form

import com.khalti.checkout.api.ErrorAction
import com.khalti.checkout.api.Result
import com.khalti.checkout.helper.Config
import com.khalti.checkout.form.helper.WalletInitPojo
import com.khalti.checkout.helper.Config
import com.khalti.checkout.helper.PaymentPreference
import com.khalti.signal.CompositeSignal
import com.khalti.utils.*
Expand Down Expand Up @@ -108,44 +108,48 @@ class FormPresenter(view: FormContract.View) : FormContract.Presenter {

if (EmptyUtil.isNotNull(clickMap["pin"])) {
compositeSignal.add(clickMap.getValue("pin")
.connect {
if (view.doesPackageExist()) {
view.openKhaltiSettings()
} else {
view.openLinkInBrowser(Constant.url + transactionPINUrl)
}
})
.connect {
if (view.doesPackageExist()) {
view.openKhaltiSettings()
} else {
view.openLinkInBrowser(Constant.url + transactionPINUrl)
}
})
}

val watcherMap = view.setEditTextListener()
if (EmptyUtil.isNotNull(watcherMap["mobile"])) {
compositeSignal.add(watcherMap.getValue("mobile")
.connect {
view.setEditTextError("mobile", null)
if (view.payButtonText.lowercase(Locale.getDefault()).contains("confirm")) {
view.toggleConfirmationLayout(false)
}
})
.connect {
view.setEditTextError("mobile", null)
if (view.payButtonText.lowercase(Locale.getDefault()).contains("confirm")) {
view.toggleConfirmationLayout(false)
}
})
}

if (EmptyUtil.isNotNull(watcherMap["pin"])) {
compositeSignal.add(watcherMap.getValue("pin")
.connect {
view.setEditTextError("pin", null)
if (view.payButtonText.lowercase(Locale.getDefault()).contains("confirm")) {
view.toggleConfirmationLayout(false)
}
})
.connect {
view.setEditTextError("pin", null)
if (view.payButtonText.lowercase(Locale.getDefault()).contains("confirm")) {
view.toggleConfirmationLayout(false)
}
})
}

if (EmptyUtil.isNotNull(watcherMap["code"])) {
compositeSignal.add(watcherMap.getValue("code")
.connect {
view.setEditTextError("code", null)
view.setConfirmationLayoutHeight()
})
.connect {
view.setEditTextError("code", null)
view.setConfirmationLayoutHeight()
})
}
}

compositeSignal.add(view.getBackPressedSignal().connect {
view.clearForm()
})
}

override fun onDestroy() {
Expand Down Expand Up @@ -218,15 +222,15 @@ class FormPresenter(view: FormContract.View) : FormContract.Presenter {

if (errorMap.containsKey("error_key") && errorMap.getValue("error_key") == "third_party_transaction_locked") {
compositeSignal.add(view.showMessageDialog("Error", view.getMessage("pin_error"), true)
.connect {
if (it) {
if (view.doesPackageExist()) {
view.openKhaltiSettings()
} else {
view.openLinkInBrowser(Constant.url + transactionPINUrl)
}
.connect {
if (it) {
if (view.doesPackageExist()) {
view.openKhaltiSettings()
} else {
view.openLinkInBrowser(Constant.url + transactionPINUrl)
}
})
}
})
} else if (errorMap.containsKey("detail")) {
view.showMessageDialog("Error", errorMap.getValue("detail"))
} else if (errorMap.containsKey("error_key") && errorMap.getValue("error_key") == "validation_error") {
Expand Down Expand Up @@ -279,11 +283,15 @@ class FormPresenter(view: FormContract.View) : FormContract.Presenter {
if (EmptyUtil.isNotNull(walletConfirmPojo.mobile)) {
data["mobile"] = walletConfirmPojo.mobile!!
}
if (EmptyUtil.isNotNull(walletConfirmPojo.idx)) {
data["idx"] = walletConfirmPojo.idx!!
}
if (EmptyUtil.isNotNull(config.additionalData) && EmptyUtil.isNotEmpty(config.additionalData)) {
data.putAll(config.additionalData!!)
}

config.onCheckOutListener.onSuccess(data)
view.clearForm()
view.closeWidget()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import com.google.gson.annotations.Expose
import com.google.gson.annotations.SerializedName

class WalletConfirmPojo {
@SerializedName("idx")
@Expose
val idx: String? = null
@SerializedName("product_identity")
@Expose
val productIdentity: String? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.khalti.checkout.helper

import androidx.appcompat.widget.SearchView
import androidx.coordinatorlayout.widget.CoordinatorLayout
import com.khalti.signal.Signal

interface BaseComm {

Expand All @@ -10,4 +11,6 @@ interface BaseComm {
fun addSearchView(paymentType: String, searchView: SearchView)

fun toggleSearchView(paymentType: String, show: Boolean)

fun getBackPressedSignal(): Signal<Any>
}
4 changes: 2 additions & 2 deletions metadata.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ ext {
appVersionCode = 10000
appVersionName = "1.0.0"

khaltiVersionCode = 2001000
khaltiVersionName = "2.01.00"
khaltiVersionCode = 2001001
khaltiVersionName = "2.01.01"

compileSdk = 29
buildToolVersion = '29.0.0'
Expand Down

0 comments on commit cbc1842

Please sign in to comment.