Commit 465b122f authored by pokkst's avatar pokkst

DeX UI changes

parent f55a7186
......@@ -164,6 +164,10 @@ class MainActivity : AppCompatActivity() {
}
}
if(!UIManager.isDisplayingDownload) {
this@MainActivity.syncPct.text = ""
}
}
private fun findViews() {
......
......@@ -17,6 +17,7 @@ import app.crescentcash.src.manager.WalletManager
import app.crescentcash.src.ui.RecipientEditText
import app.crescentcash.src.uri.URIHelper
import app.crescentcash.src.utils.Constants
import app.crescentcash.src.utils.DexUtil
import app.crescentcash.src.utils.PrefsUtil
import com.ncorti.slidetoact.SlideToActView
import org.bitcoinj.utils.MonetaryFormat
......@@ -28,7 +29,8 @@ import kotlin.collections.ArrayList
class SendActivity : AppCompatActivity() {
private lateinit var tvRecipientAddress_AM: RecipientEditText
lateinit var amountText: TextView
lateinit var btnSend_AM: SlideToActView
lateinit var btnSendSlider: SlideToActView
lateinit var btnSend: Button
lateinit var setMaxCoins: Button
lateinit var sendTypeSpinner: Spinner
private lateinit var donateBtn: TextView
......@@ -63,7 +65,6 @@ class SendActivity : AppCompatActivity() {
private fun findViews() {
tvRecipientAddress_AM = this.findViewById(R.id.tvRecipientAddress_AM)
amountText = this.findViewById(R.id.etAmount_AM)
btnSend_AM = this.findViewById(R.id.btnSend_AM)
setMaxCoins = this.findViewById(R.id.setMaxCoins)
sendTypeSpinner = this.findViewById(R.id.sendType)
donateBtn = this.findViewById(R.id.donateBtn)
......@@ -73,6 +74,14 @@ class SendActivity : AppCompatActivity() {
opReturnText = this.findViewById(R.id.opReturnText)
opReturnBox = this.findViewById(R.id.opReturnBox)
qrScan = this.findViewById(R.id.qrScan)
if(DexUtil.isDeXEnabled(this)) {
btnSend = this.findViewById(R.id.btnSend)
btnSend.visibility = View.VISIBLE
} else {
btnSendSlider = this.findViewById(R.id.btnSendSlider)
btnSendSlider.visibility = View.VISIBLE
}
}
private fun prepareViews() {
......@@ -123,12 +132,16 @@ class SendActivity : AppCompatActivity() {
}
private fun initListeners() {
val slideBCHListener: SlideToActView.OnSlideCompleteListener = object : SlideToActView.OnSlideCompleteListener {
override fun onSlideComplete(view: SlideToActView) {
WalletManager.send(this@SendActivity)
if(DexUtil.isDeXEnabled(this)) {
this.btnSend.setOnClickListener { WalletManager.send(this@SendActivity) }
} else {
val slideBCHListener: SlideToActView.OnSlideCompleteListener = object : SlideToActView.OnSlideCompleteListener {
override fun onSlideComplete(view: SlideToActView) {
WalletManager.send(this@SendActivity)
}
}
this.btnSendSlider.onSlideCompleteListener = slideBCHListener
}
this.btnSend_AM.onSlideCompleteListener = slideBCHListener
val listener: RecipientTextListener = object : RecipientTextListener {
override fun onUpdate() {
val clipboard = this@SendActivity.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
......@@ -210,9 +223,13 @@ class SendActivity : AppCompatActivity() {
}
fun setSendButtonsActive() {
this.runOnUiThread {
this.btnSend_AM.isEnabled = true
this.btnSend_AM.resetSlider()
if(DexUtil.isDeXEnabled(this)) {
this.runOnUiThread { this.btnSend.isEnabled = true }
} else {
this.runOnUiThread {
this.btnSendSlider.isEnabled = true
this.btnSendSlider.resetSlider()
}
}
}
......
......@@ -3,6 +3,7 @@ package app.crescentcash.src.activity
import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import android.view.View
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
......@@ -12,6 +13,7 @@ import app.crescentcash.src.manager.UIManager
import app.crescentcash.src.manager.WalletManager
import app.crescentcash.src.uri.URIHelper
import app.crescentcash.src.utils.Constants
import app.crescentcash.src.utils.DexUtil
import com.ncorti.slidetoact.SlideToActView
import java.math.BigDecimal
import java.math.RoundingMode
......@@ -21,7 +23,8 @@ class SendSLPActivity : AppCompatActivity() {
lateinit var slpAmount: TextView
lateinit var slpRecipientAddress: TextView
private lateinit var slp_qrScan: ImageView
lateinit var sendSLPBtn: SlideToActView
lateinit var btnSendSLPSlider: SlideToActView
lateinit var btnSendSLP: Button
private lateinit var slpUnit: TextView
override fun onCreate(savedInstanceState: Bundle?) {
......@@ -34,7 +37,13 @@ class SendSLPActivity : AppCompatActivity() {
}
private fun findViews() {
sendSLPBtn = this.findViewById(R.id.sendSLPBtn)
if(DexUtil.isDeXEnabled(this)) {
btnSendSLP = this.findViewById(R.id.sendSLPBtn)
btnSendSLP.visibility = View.VISIBLE
} else {
btnSendSLPSlider = this.findViewById(R.id.sendSLPBtn)
btnSendSLPSlider.visibility = View.VISIBLE
}
setMaxSLP = this.findViewById(R.id.setMaxSLP)
slpUnit = this.findViewById(R.id.slpUnit)
slpAmount = this.findViewById(R.id.slpAmount)
......@@ -60,28 +69,36 @@ class SendSLPActivity : AppCompatActivity() {
slpAmount.text = WalletManager.tokenListInfo[WalletManager.currentTokenPosition].amount.toPlainString()
}
val slideSLPListener: SlideToActView.OnSlideCompleteListener = object : SlideToActView.OnSlideCompleteListener {
override fun onSlideComplete(view: SlideToActView) {
if (!TextUtils.isEmpty(slpRecipientAddress.text) && !TextUtils.isEmpty(slpAmount.text)) {
if (!slpRecipientAddress.text.toString().contains("#")) {
val tokenId = WalletManager.currentTokenId
val tokenPos = WalletManager.currentTokenPosition
val tokenInfo = WalletManager.tokenListInfo[tokenPos]
val amt = BigDecimal(java.lang.Double.parseDouble(slpAmount.text.toString())).setScale(tokenInfo.decimals!!, RoundingMode.HALF_UP)
println(amt.toPlainString())
WalletManager.sendToken(this@SendSLPActivity, tokenId, amt, slpRecipientAddress.text.toString())
} else {
this@SendSLPActivity.runOnUiThread { UIManager.showToastMessage(this@SendSLPActivity, "SLP CashAccts are not supported.") }
}
if(DexUtil.isDeXEnabled(this)) {
this.btnSendSLP.setOnClickListener {
this@SendSLPActivity.send()
}
} else {
val slideSLPListener: SlideToActView.OnSlideCompleteListener = object : SlideToActView.OnSlideCompleteListener {
override fun onSlideComplete(view: SlideToActView) {
this@SendSLPActivity.send()
}
}
this.btnSendSLPSlider.onSlideCompleteListener = slideSLPListener
}
this.sendSLPBtn.onSlideCompleteListener = slideSLPListener
this.slp_qrScan.setOnClickListener { UIManager.clickScanQR(this, Constants.REQUEST_CODE_SCAN_PAY_SLP_TO) }
}
private fun send() {
if (!TextUtils.isEmpty(slpRecipientAddress.text) && !TextUtils.isEmpty(slpAmount.text)) {
if (!slpRecipientAddress.text.toString().contains("#")) {
val tokenId = WalletManager.currentTokenId
val tokenPos = WalletManager.currentTokenPosition
val tokenInfo = WalletManager.tokenListInfo[tokenPos]
val amt = BigDecimal(java.lang.Double.parseDouble(slpAmount.text.toString())).setScale(tokenInfo.decimals!!, RoundingMode.HALF_UP)
println(amt.toPlainString())
WalletManager.sendToken(this@SendSLPActivity, tokenId, amt, slpRecipientAddress.text.toString())
} else {
this@SendSLPActivity.runOnUiThread { UIManager.showToastMessage(this@SendSLPActivity, "SLP CashAccts are not supported.") }
}
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (data != null) {
......
......@@ -18,10 +18,7 @@ import app.crescentcash.src.activity.PaymentReceivedActivity
import app.crescentcash.src.activity.SendActivity
import app.crescentcash.src.activity.SendSLPActivity
import app.crescentcash.src.uri.URIHelper
import app.crescentcash.src.utils.Constants
import app.crescentcash.src.utils.OpPushParser
import app.crescentcash.src.utils.PrefsUtil
import app.crescentcash.src.utils.UtxoUtil
import app.crescentcash.src.utils.*
import com.bitcoin.slpwallet.Network
import com.bitcoin.slpwallet.SLPWallet
import com.bitcoin.slpwallet.SLPWalletConfig
......@@ -491,8 +488,11 @@ class WalletManager {
sendActivity.runOnUiThread { sendActivity.amountText.text = amountFormatted }
if (amountAsFloat <= this@Companion.maximumAutomaticSend) {
sendActivity.runOnUiThread { sendActivity.btnSend_AM.completeSlider() }
send(sendActivity)
if(DexUtil.isDeXEnabled(sendActivity)) {
send(sendActivity)
} else {
sendActivity.runOnUiThread { sendActivity.btnSendSlider.completeSlider() }
}
}
} catch (e: InterruptedException) {
e.printStackTrace()
......@@ -508,7 +508,11 @@ class WalletManager {
fun send(sendActivity: SendActivity) {
if (!UIManager.isDisplayingDownload) {
sendActivity.btnSend_AM.isEnabled = false
if(DexUtil.isDeXEnabled(sendActivity)) {
sendActivity.btnSend.isEnabled = false
} else {
sendActivity.btnSendSlider.isEnabled = false
}
val amount = sendActivity.amount
val amtDblToFrmt: Double
......@@ -796,8 +800,6 @@ class WalletManager {
fun sendToken(sendSlpActivity: SendSLPActivity, tokenId: String, amount: BigDecimal, address: String) {
val formattedAddress = if (!address.startsWith("simpleledger:")) "simpleledger:$address" else address
sendSlpActivity.sendSLPBtn.isEnabled = false
object : Thread() {
override fun run() {
......
......@@ -3,6 +3,7 @@ package app.crescentcash.src.uri
import app.crescentcash.src.activity.SendActivity
import app.crescentcash.src.activity.SendSLPActivity
import app.crescentcash.src.manager.WalletManager
import app.crescentcash.src.utils.DexUtil
import app.crescentcash.src.utils.PrefsUtil
import org.bitcoinj.utils.MonetaryFormat
import java.io.UnsupportedEncodingException
......@@ -160,7 +161,13 @@ class URIHelper() {
val amountAsFloat = amount.toFloat()
println("Amount scanned: $amountAsFloat Maximum amount set: ${WalletManager.maximumAutomaticSend}")
if (amountAsFloat <= WalletManager.maximumAutomaticSend) {
sendActivity?.btnSend_AM?.completeSlider()
if(sendActivity != null) {
if (DexUtil.isDeXEnabled(sendActivity)) {
WalletManager.send(sendActivity)
} else {
sendActivity.btnSendSlider.completeSlider()
}
}
}
}
}
......
......@@ -256,6 +256,24 @@
android:text="Donate to Crescent"
android:textColor="?attr/textColor" />
<Space
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="20dp" />
<Button
android:id="@+id/btnSend"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/bch_wallet_button"
android:gravity="center"
android:singleLine="true"
android:text="@string/send"
android:textAllCaps="false"
android:textColor="?attr/buttonTextOnWhite"
android:visibility="gone" />
</LinearLayout>
<Space
......@@ -270,48 +288,29 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_height="84dp"
android:layout_gravity="bottom"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<Space
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="4" />
<!--<Button
android:id="@+id/btnSend_AM"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/bch_wallet_button"
android:singleLine="true"
android:text="Send"
android:textAllCaps="false"
android:textColor="?attr/buttonTextOnWhite" />-->
<com.ncorti.slidetoact.SlideToActView
android:id="@+id/btnSend_AM"
android:id="@+id/btnSendSlider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
android:elevation="6dp"
android:visibility="gone"
app:area_margin="10dp"
app:border_radius="20dp"
app:inner_color="?attr/buttonTextOnWhite"
app:outer_color="#22cc76"
app:slider_height="75dp"
app:slider_height="64dp"
app:slider_locked="false"
app:text="Slide to Send"
app:text_size="18sp" />
<Space
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="4" />
</LinearLayout>
</FrameLayout>
\ No newline at end of file
......@@ -149,6 +149,19 @@
android:layout_height="wrap_content"
android:minHeight="10dp" />
<Button
android:id="@+id/btnSendSLP"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/bch_wallet_button"
android:gravity="center"
android:singleLine="true"
android:text="@string/send"
android:textAllCaps="false"
android:textColor="?attr/buttonTextOnWhite"
android:visibility="gone" />
</LinearLayout>
......@@ -156,17 +169,12 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_height="84dp"
android:layout_gravity="bottom"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<Space
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="4" />
<!--<Button
android:id="@+id/sendSLPBtn"
android:layout_width="match_parent"
......@@ -182,23 +190,21 @@
android:id="@+id/sendSLPBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
android:layout_weight="0.5"
android:elevation="6dp"
android:paddingBottom="100dp"
android:visibility="gone"
app:area_margin="10dp"
app:border_radius="20dp"
app:inner_color="?attr/buttonTextOnWhite"
app:outer_color="#22cc76"
app:slider_height="75dp"
app:slider_height="64dp"
app:slider_locked="false"
app:text="Slide to Send"
app:text_size="18sp" />
<Space
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="4" />
</LinearLayout>
</FrameLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment