Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add coin control ui #569

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@
android:name=".activities.privacy.ManualMixerSetup"
android:launchMode="singleTask" />

<activity
android:name=".activities.coincontrol.CoinControlActivity"
android:launchMode="singleTask" />

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.dcrandroid.activities.coincontrol

import android.os.Bundle
import android.view.View
import com.dcrandroid.R
import com.dcrandroid.activities.BaseActivity
import com.dcrandroid.adapter.PopupItem
import com.dcrandroid.adapter.PopupUtil
import com.dcrandroid.dialog.InfoDialog
import kotlinx.android.synthetic.main.activity_coin_control.*
import kotlinx.android.synthetic.main.coin_control_input_list_row.*

class CoinControlActivity : BaseActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_coin_control)

iv_info.setOnClickListener {
InfoDialog(this)
.setDialogTitle("Select Inputs")
.setMessage(getString(R.string.coin_control_info))
.setPositiveButton(getString(R.string.got_it), null)
.show()
}

iv_options.setOnClickListener {
val items: Array<Any> = 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
}
}
26 changes: 26 additions & 0 deletions app/src/main/java/com/dcrandroid/dialog/send/SendDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.*
Expand All @@ -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 {

Expand Down Expand Up @@ -93,6 +97,15 @@ class SendDialog(val fragmentActivity: FragmentActivity, dismissListener: Dialog
amountChanged = [email protected]
}

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
Expand Down Expand Up @@ -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 {
Expand Down
247 changes: 247 additions & 0 deletions app/src/main/res/layout/activity_coin_control.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2018-2021 The Decred developers
~ Use of this source code is governed by an ISC
~ license that can be found in the LICENSE file.
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:background="@color/colorBackground"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:id="@+id/app_bar"
app:elevation="0dp"
android:background="@color/colorBackground"
android:theme="@style/AppTheme.AppBarOverlay">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="0dp"
android:paddingLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetLeft="0dp"
android:paddingEnd="0dp"
android:paddingRight="0dp"
app:contentInsetEnd="0dp"
app:contentInsetRight="0dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="@dimen/margin_padding_size_8"
android:paddingEnd="0dp"
android:orientation="horizontal"
android:gravity="center_vertical">

<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="@dimen/margin_padding_size_8"
android:background="@drawable/bg_primary_ripple"
android:focusable="true"
android:clickable="true"
android:id="@+id/go_back"
app:srcCompat="@drawable/ic_back" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/app_bar_title"
android:text="Coin Control"
android:layout_marginStart="@dimen/margin_padding_size_8"
android:textSize="@dimen/edit_text_size_20"
android:textColor="@color/darkBlueTextColor"
android:includeFontPadding="false"
app:fontFamily="@font/source_sans_pro" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end">

<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/iv_info"
android:padding="@dimen/margin_padding_size_8"
android:layout_marginEnd="@dimen/margin_padding_size_8"
app:srcCompat="@drawable/ic_info"
android:focusable="true"
android:clickable="true"
android:background="@drawable/bg_primary_ripple" />

<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/iv_options"
android:padding="@dimen/margin_padding_size_8"
app:srcCompat="@drawable/ic_options"
android:focusable="true"
android:clickable="true"
android:background="@drawable/bg_primary_ripple" />

</LinearLayout>

</LinearLayout>

</androidx.appcompat.widget.Toolbar>

</com.google.android.material.appbar.AppBarLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/card_bg"
android:orientation="vertical"
android:elevation="@dimen/margin_padding_size_4"
android:layout_marginStart="@dimen/margin_padding_size_8"
android:layout_marginEnd="@dimen/margin_padding_size_8"
android:layout_marginTop="@dimen/margin_padding_size_4"
android:layout_marginBottom="@dimen/margin_padding_size_4"
android:padding="@dimen/margin_padding_size_16">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1"
android:orientation="horizontal"
android:layout_gravity="center_vertical"
android:layout_marginTop="@dimen/margin_padding_size_6">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/coin_control_quantity"
android:layout_weight="0.5"
android:text="Selected: 5"
android:textSize="@dimen/edit_text_size_16"
android:includeFontPadding="false"
app:fontFamily="@font/source_sans_pro" />

<TextView
android:id="@+id/coin_control_amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:gravity="end"
android:includeFontPadding="false"
android:text="Amount: 118.19008368 DCR"
android:textSize="@dimen/edit_text_size_16"
app:fontFamily="@font/source_sans_pro" />

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1"
android:orientation="horizontal"
android:layout_gravity="center_vertical"
android:layout_marginTop="@dimen/margin_padding_size_6">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/coin_control_fee"
android:layout_weight="0.5"
android:text="Fee: 0.0000881 DCR"
android:textSize="@dimen/edit_text_size_16"
android:includeFontPadding="false"
app:fontFamily="@font/source_sans_pro"/>

<TextView
android:id="@+id/coin_control_after_fee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:gravity="end"
android:includeFontPadding="false"
android:text="After Fee: 118.18999558 DCR"
android:textSize="@dimen/edit_text_size_16"
app:fontFamily="@font/source_sans_pro" />

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1"
android:orientation="horizontal"
android:layout_gravity="center_vertical"
android:layout_marginTop="@dimen/margin_padding_size_6">

</LinearLayout>

</LinearLayout>

<!-- <androidx.recyclerview.widget.RecyclerView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:id="@+id/recycler_view"-->
<!-- android:background="@drawable/card_bg"-->
<!-- android:elevation="@dimen/margin_padding_size_4"-->
<!-- android:layout_marginTop="@dimen/margin_padding_size_4"-->
<!-- android:layout_marginStart="@dimen/margin_padding_size_8"-->
<!-- android:layout_marginEnd="@dimen/margin_padding_size_8"-->
<!-- android:layout_marginBottom="@dimen/margin_padding_size_8" />-->

<LinearLayout
android:id="@+id/recycler_view_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="visible">

<include
layout="@layout/coin_control_input_list_row"
android:visibility="visible"
android:id="@+id/destination_account_spinner" />

<include
layout="@layout/coin_control_input_list_row"
android:visibility="visible"
android:id="@+id/destination_account_spinner" />

<include
layout="@layout/coin_control_input_list_row"
android:visibility="visible"
android:id="@+id/destination_account_spinner" />

<include
layout="@layout/coin_control_input_list_row"
android:visibility="visible"
android:id="@+id/destination_account_spinner" />

<include
layout="@layout/coin_control_input_list_row"
android:visibility="visible"
android:id="@+id/destination_account_spinner" />

<!-- <androidx.recyclerview.widget.RecyclerView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:id="@+id/recycler_view"-->
<!-- android:layout_marginTop="@dimen/margin_padding_size_4" />-->

</LinearLayout>

<!-- <TextView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:gravity="center"-->
<!-- android:textSize="@dimen/edit_text_size_16"-->
<!-- android:layout_marginBottom="@dimen/margin_padding_size_18"-->
<!-- android:textColor="@color/lightGrayTextColor"-->
<!-- app:fontFamily="@font/source_sans_pro"-->
<!-- android:text="No inputs available" />-->

</LinearLayout>
Loading