Commit 9c738408 authored by pokkst's avatar pokkst

All green buttons now have proper black or white text depending on light/dark...

All green buttons now have proper black or white text depending on light/dark mode. Sweeping tx now broadcasts to rest servers. Clicking QR codes now copies address.
parent 27e0bbc1
......@@ -91,18 +91,22 @@ class ReceiveActivity : AppCompatActivity() {
UIManager.showToastMessage(this, "Copied")
}
this.copyBtcAddr.setOnClickListener {
val clip: ClipData = ClipData.newPlainText("My BCH address", WalletManager.parameters.cashAddrPrefix + ":" + btcAddress.text.toString())
val clipboard = this.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
clipboard.setPrimaryClip(clip)
UIManager.showToastMessage(this, "Copied")
}
val copyListener = View.OnClickListener { copyAddr() }
this.copyBtcAddr.setOnClickListener(copyListener)
this.findViewById<ImageView>(R.id.btcQR).setOnClickListener(copyListener)
val filter = IntentFilter()
filter.addAction(Constants.ACTION_UPDATE_CASH_ACCOUNT_LABEL)
LocalBroadcastManager.getInstance(this).registerReceiver(receiver, filter)
}
private fun copyAddr() {
val clip: ClipData = ClipData.newPlainText("My BCH address", WalletManager.parameters.cashAddrPrefix + ":" + btcAddress.text.toString())
val clipboard = this.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
clipboard.setPrimaryClip(clip)
UIManager.showToastMessage(this, "Copied")
}
private fun displayEmoji() {
val cashEmoji = PrefsUtil.prefs.getString("cashEmoji", "")
myEmoji.text = cashEmoji
......
......@@ -48,19 +48,22 @@ class ReceiveSLPActivity : AppCompatActivity() {
}
private fun initListeners() {
this.copySlpAddr.setOnClickListener {
val clip: ClipData = if (currentAddrView) ClipData.newPlainText("My SLP address", "simpleledger:" + slpAddress.text.toString()) else ClipData.newPlainText("My BCH SLP address", "bitcoincash:" + slpAddress.text.toString())
val clipboard = this.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
clipboard.setPrimaryClip(clip)
Toast.makeText(this, "Copied", Toast.LENGTH_SHORT).show()
}
val copyListener = View.OnClickListener { copyAddr() }
this.copySlpAddr.setOnClickListener(copyListener)
this.findViewById<ImageView>(R.id.slpQR).setOnClickListener(copyListener)
this.toggleAddr.setOnClickListener {
this.currentAddrView = !this.currentAddrView
this.displayReceiveSLP()
}
}
private fun copyAddr() {
val clip: ClipData = if (currentAddrView) ClipData.newPlainText("My SLP address", "simpleledger:" + slpAddress.text.toString()) else ClipData.newPlainText("My BCH SLP address", "bitcoincash:" + slpAddress.text.toString())
val clipboard = this.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
clipboard.setPrimaryClip(clip)
Toast.makeText(this, "Copied", Toast.LENGTH_SHORT).show()
}
private fun generateQR(textToConvert: String, viewID: Int, slp: Boolean) {
try {
val encoder = BarcodeEncoder()
......
......@@ -413,7 +413,7 @@ class NetManager {
return "-1"
}
fun broadcastTransaction(sendActivity: SendActivity, hex: String, baseUrl: String) {
fun broadcastTransaction(sendActivity: SendActivity?, hex: String, baseUrl: String) {
object : Thread() {
override fun run() {
try {
......@@ -438,12 +438,16 @@ class NetManager {
println(sb.toString())
}
} catch (e: Exception) {
WalletManager.throwSendError(sendActivity, "Failed to broadcast transaction.")
if(sendActivity != null)
WalletManager.throwSendError(sendActivity, "Failed to broadcast transaction.")
e.printStackTrace()
}
}
} catch (e: FileNotFoundException) {
WalletManager.throwSendError(sendActivity, "Failed to broadcast transaction.")
if(sendActivity != null)
WalletManager.throwSendError(sendActivity, "Failed to broadcast transaction.")
e.printStackTrace()
}
}
......
......@@ -18,6 +18,7 @@ import java.io.InputStream
import java.io.InputStreamReader
import java.net.URL
import java.nio.charset.Charset
import java.nio.charset.StandardCharsets
class UtxoUtil {
......@@ -65,7 +66,15 @@ class UtxoUtil {
req.ensureMinRequiredFee = false
req.feePerKb = Coin.valueOf(java.lang.Long.parseLong(1.toString() + "") * 1000L)
val tx = walletToSweep.sendCoinsOffline(req)
val txHexBytes = Hex.encode(tx.bitcoinSerialize())
val txHex = String(txHexBytes, StandardCharsets.UTF_8)
WalletManager.broadcastTxToPeers(tx)
if (!WalletManager.useTor) {
NetManager.broadcastTransaction(null, txHex, "https://rest.bitcoin.com/v2/rawtransactions/sendRawTransaction")
}
NetManager.broadcastTransaction(null, txHex, "https://rest.imaginary.cash/v2/rawtransactions/sendRawTransaction")
}
private fun getUtxos(url: String): JSONObject? {
......
......@@ -174,7 +174,7 @@
android:text="Bitcoin Cash Wallet"
android:textAlignment="textStart"
android:textAllCaps="false"
android:textColor="#fff"
android:textColor="?attr/buttonTextOnWhite"
android:textSize="18sp" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
......@@ -182,7 +182,7 @@
android:layout_width="55dp"
android:layout_height="55dp"
android:backgroundTint="#22cc76"
android:tint="#fff"
android:tint="?attr/buttonTextOnWhite"
app:fabCustomSize="55dp"
app:srcCompat="@drawable/send" />
......@@ -196,7 +196,7 @@
android:layout_width="55dp"
android:layout_height="55dp"
android:backgroundTint="#22cc76"
android:tint="#fff"
android:tint="?attr/buttonTextOnWhite"
app:fabCustomSize="55dp"
app:srcCompat="@drawable/receive" />
......@@ -223,7 +223,7 @@
android:text="Simple Ledger Wallet"
android:textAlignment="textStart"
android:textAllCaps="false"
android:textColor="#fff"
android:textColor="?attr/buttonTextOnWhite"
android:textSize="18sp" />
<Space
......
......@@ -162,7 +162,7 @@
android:text="Bitcoin Cash Wallet"
android:textAlignment="textStart"
android:textAllCaps="false"
android:textColor="#fff"
android:textColor="?attr/buttonTextOnWhite"
android:textSize="18sp" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
......@@ -170,7 +170,7 @@
android:layout_width="55dp"
android:layout_height="55dp"
android:backgroundTint="#22cc76"
android:tint="#fff"
android:tint="?attr/buttonTextOnWhite"
app:fabCustomSize="55dp"
app:srcCompat="@drawable/send" />
......@@ -184,7 +184,7 @@
android:layout_width="55dp"
android:layout_height="55dp"
android:backgroundTint="#22cc76"
android:tint="#fff"
android:tint="?attr/buttonTextOnWhite"
app:fabCustomSize="55dp"
app:srcCompat="@drawable/receive" />
......@@ -211,7 +211,7 @@
android:text="Simple Ledger Wallet"
android:textAlignment="textStart"
android:textAllCaps="false"
android:textColor="#fff"
android:textColor="?attr/buttonTextOnWhite"
android:textSize="18sp" />
<Space
......
......@@ -173,7 +173,7 @@
android:text="Bitcoin Cash Wallet"
android:textAlignment="textStart"
android:textAllCaps="false"
android:textColor="#fff"
android:textColor="?attr/buttonTextOnWhite"
android:textSize="18sp" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
......@@ -181,7 +181,7 @@
android:layout_width="55dp"
android:layout_height="55dp"
android:backgroundTint="#22cc76"
android:tint="#fff"
android:tint="?attr/buttonTextOnWhite"
app:fabCustomSize="55dp"
app:srcCompat="@drawable/send" />
......@@ -195,7 +195,7 @@
android:layout_width="55dp"
android:layout_height="55dp"
android:backgroundTint="#22cc76"
android:tint="#fff"
android:tint="?attr/buttonTextOnWhite"
app:fabCustomSize="55dp"
app:srcCompat="@drawable/receive" />
......@@ -222,7 +222,7 @@
android:text="Simple Ledger Wallet"
android:textAlignment="textStart"
android:textAllCaps="false"
android:textColor="#fff"
android:textColor="?attr/buttonTextOnWhite"
android:textSize="18sp" />
<Space
......
......@@ -62,7 +62,7 @@
android:background="@drawable/bch_wallet_button"
android:text="@string/create"
android:textAllCaps="false"
android:textColor="#fff"
android:textColor="?attr/buttonTextOnWhite"
android:textSize="18sp" />
<Space
......
......@@ -33,7 +33,7 @@
android:background="@drawable/bch_wallet_button"
android:text="@string/newwallet"
android:textAllCaps="false"
android:textColor="#fff"
android:textColor="?attr/buttonTextOnWhite"
android:textSize="18sp" />
<Space
......@@ -48,7 +48,7 @@
android:background="@drawable/bch_wallet_button"
android:text="@string/restorewallet"
android:textAllCaps="false"
android:textColor="#fff"
android:textColor="?attr/buttonTextOnWhite"
android:textSize="18sp" />
<Space
......
......@@ -55,7 +55,7 @@
android:singleLine="true"
android:text="Close"
android:textAllCaps="false"
android:textColor="#fff" />
android:textColor="?attr/buttonTextOnWhite" />
<Space
android:layout_width="match_parent"
......
......@@ -88,7 +88,7 @@
android:background="@drawable/bch_wallet_button"
android:text="@string/restore"
android:textAllCaps="false"
android:textColor="#fff"
android:textColor="?attr/buttonTextOnWhite"
android:textSize="18sp" />
<Space
......
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