From 44ddf26ffc0647db3da55bdcedcc6c312d68b34a Mon Sep 17 00:00:00 2001 From: dreacot Date: Sun, 20 Jun 2021 21:55:11 +0100 Subject: [PATCH] add coin control ui --- app/src/main/AndroidManifest.xml | 4 + .../coincontrol/CoinControlActivity.kt | 52 ++++ .../com/dcrandroid/dialog/send/SendDialog.kt | 26 ++ .../main/res/layout/activity_coin_control.xml | 247 ++++++++++++++++++ .../layout/coin_control_input_list_row.xml | 108 ++++++++ app/src/main/res/layout/coin_control_row.xml | 98 +++++++ app/src/main/res/layout/send_page_sheet.xml | 18 ++ app/src/main/res/values/strings.xml | 2 + 8 files changed, 555 insertions(+) create mode 100644 app/src/main/java/com/dcrandroid/activities/coincontrol/CoinControlActivity.kt create mode 100644 app/src/main/res/layout/activity_coin_control.xml create mode 100644 app/src/main/res/layout/coin_control_input_list_row.xml create mode 100644 app/src/main/res/layout/coin_control_row.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f1481607..5d23a9b2 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -201,6 +201,10 @@ android:name=".activities.privacy.ManualMixerSetup" android:launchMode="singleTask" /> + + = arrayOf( + PopupItem(R.string.clear_fields) + ) + + PopupUtil.showPopup(it, items) { window, _ -> + window.dismiss() + clearFields() + } + } + + go_back.setOnClickListener { finish() } + } + + override fun onResume() { + super.onResume() + } + + override fun onPause() { + super.onPause() + } + + private fun clearFields() { + checkBox.isChecked = false + } +} \ No newline at end of file diff --git a/app/src/main/java/com/dcrandroid/dialog/send/SendDialog.kt b/app/src/main/java/com/dcrandroid/dialog/send/SendDialog.kt index 3152687c..c9ea7cf6 100644 --- a/app/src/main/java/com/dcrandroid/dialog/send/SendDialog.kt +++ b/app/src/main/java/com/dcrandroid/dialog/send/SendDialog.kt @@ -19,6 +19,7 @@ import android.view.ViewTreeObserver import androidx.core.text.HtmlCompat import androidx.fragment.app.FragmentActivity import com.dcrandroid.R +import com.dcrandroid.activities.coincontrol.CoinControlActivity import com.dcrandroid.adapter.PopupItem import com.dcrandroid.adapter.PopupUtil import com.dcrandroid.data.Account @@ -34,10 +35,12 @@ import com.dcrandroid.util.CurrencyUtil import com.dcrandroid.util.SnackBar import com.dcrandroid.util.Utils import com.dcrandroid.view.util.AccountCustomSpinner +import com.dcrandroid.view.util.InputHelper import com.dcrandroid.view.util.SCAN_QR_REQUEST_CODE import dcrlibwallet.Dcrlibwallet import dcrlibwallet.TxAuthor import dcrlibwallet.TxFeeAndSize +import kotlinx.android.synthetic.main.coin_control_row.* import kotlinx.android.synthetic.main.fee_layout.* import kotlinx.android.synthetic.main.send_page_amount_card.* import kotlinx.android.synthetic.main.send_page_sheet.* @@ -47,6 +50,7 @@ import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import java.util.* + class SendDialog(val fragmentActivity: FragmentActivity, dismissListener: DialogInterface.OnDismissListener) : FullScreenBottomSheetDialog(dismissListener), ViewTreeObserver.OnScrollChangedListener { @@ -93,6 +97,15 @@ class SendDialog(val fragmentActivity: FragmentActivity, dismissListener: Dialog amountChanged = this@SendDialog.amountChanged } + val customAddressChangeInput = InputHelper(requireContext(), custom_address_change_input) { + true + }.apply { + hideQrScanner() + setHint(R.string.custom_change_address) + + editText.isSingleLine = true + } + destinationAddressCard = DestinationAddressCard(context!!, dest_address_card, validateAddress).apply { addressChanged = destAddressChanged addressInputHelper.textChanged = destAddressChanged @@ -124,6 +137,19 @@ class SendDialog(val fragmentActivity: FragmentActivity, dismissListener: Dialog } sourceAccountSpinner.pickerTitle = R.string.source_account_picker_title + coin_control_switch.setOnCheckedChangeListener { _, isChecked -> + if (isChecked) { + coin_control_enabled_section.show() + } else { + coin_control_enabled_section.hide() + } + } + + coin_control_input_button.setOnClickListener { + val intent = Intent(context, CoinControlActivity::class.java) + startActivity(intent) + } + send_scroll_view.viewTreeObserver.addOnScrollChangedListener(this) iv_send_max.setOnClickListener { diff --git a/app/src/main/res/layout/activity_coin_control.xml b/app/src/main/res/layout/activity_coin_control.xml new file mode 100644 index 00000000..cc9cd6cf --- /dev/null +++ b/app/src/main/res/layout/activity_coin_control.xml @@ -0,0 +1,247 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/coin_control_input_list_row.xml b/app/src/main/res/layout/coin_control_input_list_row.xml new file mode 100644 index 00000000..1585b7ad --- /dev/null +++ b/app/src/main/res/layout/coin_control_input_list_row.xml @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/coin_control_row.xml b/app/src/main/res/layout/coin_control_row.xml new file mode 100644 index 00000000..3ef90a65 --- /dev/null +++ b/app/src/main/res/layout/coin_control_row.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/send_page_sheet.xml b/app/src/main/res/layout/send_page_sheet.xml index 58f8829e..51bdfe07 100644 --- a/app/src/main/res/layout/send_page_sheet.xml +++ b/app/src/main/res/layout/send_page_sheet.xml @@ -121,6 +121,24 @@ + + + + + + Input or scan the destination wallet address and the amount in DCR to send funds. + Select the Inputs you want to use for your transaction Type Loading DCR @@ -660,6 +661,7 @@ No: %1$d (%2$.2f%%) Yes: %1$d (%2$.2f%%) No: %3$d (%4$.2f%%) %1$s by %2$s + Custom Change Address