diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ReceiveTransactionFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ReceiveTransactionFragment.kt index 53345b5..340c06f 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ReceiveTransactionFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ReceiveTransactionFragment.kt @@ -22,7 +22,7 @@ import cy.agorise.bitsybitshareswallet.utils.Constants import cy.agorise.bitsybitshareswallet.viewmodels.UserAccountViewModel import cy.agorise.graphenej.* import kotlinx.android.synthetic.main.fragment_receive_transaction.* -import java.util.HashMap +import java.util.* class ReceiveTransactionFragment : Fragment() { private val TAG = this.javaClass.simpleName @@ -62,7 +62,7 @@ class ReceiveTransactionFragment : Fragment() { try { val bitmap = encodeAsBitmap(Invoice.toQrCode(invoice), "#139657") // PalmPay green ivQR.setImageBitmap(bitmap) - //updateAmountAddressUI(total, mUserAccount!!.getName()) +// updateAmountAddressUI(total, mUserAccount!!.getName()) } catch (e: WriterException) { Log.e(TAG, "WriterException. Msg: " + e.message) } @@ -113,4 +113,27 @@ class ReceiveTransactionFragment : Fragment() { bitmap.setPixels(pixels, 0, w, 0, 0, w, h) return bitmap } + +// /** +// * Updates the UI to show amount and address to send the payment +// * +// * @param amount Amount in crypto to be paid +// * @param address Address to pay amount +// */ +// private fun updateAmountAddressUI(amount: Double, account: String) { +// // Trick to format correctly really small floating point numbers +// val df = DecimalFormat("0", DecimalFormatSymbols.getInstance(Locale.ENGLISH)) +// df.maximumFractionDigits = 340 +// +// val cryptoAmount = Helper.getCryptoAmountLocaleFormatted( +// locale, amount, +// inputCoinType.toLowerCase(), this +// ) +// +// val txtAmount = getString(R.string.please_pay_s_s, cryptoAmount, inputCoinType.toUpperCase()) +// val txtAddress = getString(R.string.to_s, account) +// +// tvTotalCryptoAmount.setText(txtAmount) +// tvReceivingAddress.setText(txtAddress) +// } } \ No newline at end of file diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/views/MyTextInputAutoCompleteTextView.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/views/MyTextInputAutoCompleteTextView.kt new file mode 100644 index 0000000..d37b60d --- /dev/null +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/views/MyTextInputAutoCompleteTextView.kt @@ -0,0 +1,45 @@ +package cy.agorise.bitsybitshareswallet.views + +import android.content.Context +import android.util.AttributeSet +import com.google.android.material.textfield.TextInputLayout +import android.view.inputmethod.InputConnection +import android.view.inputmethod.EditorInfo +import androidx.appcompat.widget.AppCompatAutoCompleteTextView + +/** + * Custom AutoCompleteTextView to be used inside a TextInputLayout, so that they can share their hint + * From https://stackoverflow.com/a/41864063/5428997 + */ +class MyTextInputAutoCompleteTextView : AppCompatAutoCompleteTextView { + + constructor(context: Context) : super(context) + + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) + + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) + + override fun onCreateInputConnection(outAttrs: EditorInfo): InputConnection? { + val ic = super.onCreateInputConnection(outAttrs) + if (ic != null && outAttrs.hintText == null) { + // If we don't have a hint and our parent is a TextInputLayout, use it's hint for the + // EditorInfo. This allows us to display a hint in 'extract mode'. + val parent = parent + if (parent is TextInputLayout) { + outAttrs.hintText = parent.hint + } + } + // An EditText that lets you use actions ("Done", "Go", etc.) on multi-line edits. + val imeActions = outAttrs.imeOptions and EditorInfo.IME_MASK_ACTION + if (imeActions and EditorInfo.IME_ACTION_DONE != 0) { + // clear the existing action + outAttrs.imeOptions = outAttrs.imeOptions xor imeActions + // set the DONE action + outAttrs.imeOptions = outAttrs.imeOptions or EditorInfo.IME_ACTION_DONE + } + if (outAttrs.imeOptions and EditorInfo.IME_FLAG_NO_ENTER_ACTION != 0) { + outAttrs.imeOptions = outAttrs.imeOptions and EditorInfo.IME_FLAG_NO_ENTER_ACTION.inv() + } + return ic + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_receive_transaction.xml b/app/src/main/res/layout/fragment_receive_transaction.xml index 388d936..61bb58d 100644 --- a/app/src/main/res/layout/fragment_receive_transaction.xml +++ b/app/src/main/res/layout/fragment_receive_transaction.xml @@ -38,30 +38,28 @@ - - - + android:hint="@string/text__asset" + app:layout_constraintTop_toTopOf="@id/tilAmount" + app:layout_constraintBottom_toBottomOf="@id/tilAmount" + app:layout_constraintStart_toEndOf="@id/centeredVerticalGuideline" + app:layout_constraintEnd_toEndOf="parent"> - + + + Transactions - + To + Amount + Memo + Scan QR + Asset Settings Night mode - Amount - Memo - Scan QR