Add basic churning feature with warning

not tested yet
This commit is contained in:
pokkst 2022-10-04 03:40:20 -05:00
parent 7268b07c6c
commit 67000bafa0
No known key found for this signature in database
GPG Key ID: 90C2ED85E67A50FF
5 changed files with 56 additions and 12 deletions

View File

@ -55,6 +55,7 @@ public class SendBottomSheetDialog extends BottomSheetDialogFragment {
});
public LiveData<PendingTransaction> 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);
}

View File

@ -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<String> 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) {

View File

@ -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"

View File

@ -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">
<TextView
@ -14,6 +13,9 @@
android:text="@string/view_utxos"
android:textSize="32sp"
android:textStyle="bold"
android:layout_marginTop="24dp"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@ -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" />
<Button
android:id="@+id/send_utxos_button"
android:layout_width="0dp"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/utxos_options_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/button_bg"
android:visibility="gone"
android:text="@string/send"
tools:visibility="visible"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:layout_marginBottom="24dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<Button
android:id="@+id/churn_utxos_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/button_bg_left"
android:text="@string/churn"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/send_utxos_button"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/send_utxos_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/button_bg_right"
android:text="@string/send"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/churn_utxos_button" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -94,7 +94,9 @@
<string name="high">High</string>
<string name="view_utxos">View UTXOs</string>
<string name="selected_utxos_value">Selected value: %1$s XMR</string>
<string name="selected_utxos_value_churning">Selected value: %1$s XMR\n\nThe anonymity benefits of churning are still being researched. Only proceed if you know what you are doing.</string>
<string name="global_index_text">Global Idx: %1$d</string>
<string name="outpoint_text">Outpoint: %1$s</string>
<string name="create_wallet_failed">Create wallet failed: %1$s</string>
<string name="churn">Churn</string>
</resources>