From 67000bafa0a5b937f263d666b5d3b3647284452d Mon Sep 17 00:00:00 2001 From: pokkst Date: Tue, 4 Oct 2022 03:40:20 -0500 Subject: [PATCH] Add basic churning feature with warning not tested yet --- .../dialog/SendBottomSheetDialog.java | 7 ++- .../wallet/fragment/utxos/UtxosFragment.java | 12 ++++++ app/src/main/res/layout/fragment_home.xml | 4 +- app/src/main/res/layout/fragment_utxos.xml | 43 +++++++++++++++---- app/src/main/res/values/strings.xml | 2 + 5 files changed, 56 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/net/mynero/wallet/fragment/dialog/SendBottomSheetDialog.java b/app/src/main/java/net/mynero/wallet/fragment/dialog/SendBottomSheetDialog.java index ccaa130..50b8c90 100644 --- a/app/src/main/java/net/mynero/wallet/fragment/dialog/SendBottomSheetDialog.java +++ b/app/src/main/java/net/mynero/wallet/fragment/dialog/SendBottomSheetDialog.java @@ -55,6 +55,7 @@ public class SendBottomSheetDialog extends BottomSheetDialogFragment { }); public LiveData pendingTransaction = _pendingTransaction; public UriData uriData = null; + public boolean isChurning = false; public PendingTransaction.Priority priority; private EditText addressEditText; private EditText amountEditText; @@ -118,7 +119,11 @@ public class SendBottomSheetDialog extends BottomSheetDialogFragment { String valueString = Wallet.getDisplayAmount(selectedValue); selectedUtxosValueTextView.setVisibility(View.VISIBLE); - selectedUtxosValueTextView.setText(getResources().getString(R.string.selected_utxos_value, valueString)); + if(isChurning) { + selectedUtxosValueTextView.setText(getResources().getString(R.string.selected_utxos_value_churning, valueString)); + } else { + selectedUtxosValueTextView.setText(getResources().getString(R.string.selected_utxos_value, valueString)); + } } else { selectedUtxosValueTextView.setVisibility(View.GONE); } diff --git a/app/src/main/java/net/mynero/wallet/fragment/utxos/UtxosFragment.java b/app/src/main/java/net/mynero/wallet/fragment/utxos/UtxosFragment.java index 4e6de83..d549c6c 100644 --- a/app/src/main/java/net/mynero/wallet/fragment/utxos/UtxosFragment.java +++ b/app/src/main/java/net/mynero/wallet/fragment/utxos/UtxosFragment.java @@ -17,7 +17,9 @@ import net.mynero.wallet.R; import net.mynero.wallet.adapter.CoinsInfoAdapter; import net.mynero.wallet.fragment.dialog.SendBottomSheetDialog; import net.mynero.wallet.model.CoinsInfo; +import net.mynero.wallet.service.AddressService; import net.mynero.wallet.service.UTXOService; +import net.mynero.wallet.util.UriData; import java.util.ArrayList; import java.util.Collections; @@ -28,6 +30,7 @@ public class UtxosFragment extends Fragment implements CoinsInfoAdapter.CoinsInf private final ArrayList selectedUtxos = new ArrayList<>(); private final CoinsInfoAdapter adapter = new CoinsInfoAdapter(this); private Button sendUtxosButton; + private Button churnUtxosButton; @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @@ -45,12 +48,21 @@ public class UtxosFragment extends Fragment implements CoinsInfoAdapter.CoinsInf private void bindListeners(View view) { sendUtxosButton = view.findViewById(R.id.send_utxos_button); + churnUtxosButton = view.findViewById(R.id.churn_utxos_button); sendUtxosButton.setVisibility(View.GONE); + churnUtxosButton.setVisibility(View.GONE); sendUtxosButton.setOnClickListener(view1 -> { SendBottomSheetDialog sendDialog = new SendBottomSheetDialog(); sendDialog.selectedUtxos = selectedUtxos; sendDialog.show(getActivity().getSupportFragmentManager(), null); }); + churnUtxosButton.setOnClickListener(view1 -> { + SendBottomSheetDialog sendDialog = new SendBottomSheetDialog(); + sendDialog.isChurning = true; + sendDialog.uriData = UriData.parse(AddressService.getInstance().getLatestSubaddress().getAddress()); + sendDialog.selectedUtxos = selectedUtxos; + sendDialog.show(getActivity().getSupportFragmentManager(), null); + }); } private void bindObservers(View view) { diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 6c6ce3f..4291787 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -110,7 +110,7 @@ android:layout_height="wrap_content" android:background="@drawable/button_bg_left" android:text="@string/receive" - android:layout_marginBottom="16dp" + android:layout_marginBottom="24dp" android:layout_marginStart="24dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@id/send_button" @@ -122,7 +122,7 @@ android:layout_height="wrap_content" android:background="@drawable/button_bg_right" android:text="@string/send" - android:layout_marginBottom="16dp" + android:layout_marginBottom="24dp" android:layout_marginEnd="24dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" diff --git a/app/src/main/res/layout/fragment_utxos.xml b/app/src/main/res/layout/fragment_utxos.xml index 43c9a90..dbc3664 100644 --- a/app/src/main/res/layout/fragment_utxos.xml +++ b/app/src/main/res/layout/fragment_utxos.xml @@ -4,7 +4,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:padding="24dp" tools:context="net.mynero.wallet.fragment.home.HomeFragment"> @@ -25,20 +27,43 @@ android:layout_marginTop="16dp" android:clipToPadding="false" android:paddingBottom="128dp" + android:layout_marginStart="24dp" + android:layout_marginEnd="24dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/view_utxos_textview" app:layout_constraintVertical_bias="0.0" /> -