mirror of
https://codeberg.org/anoncontributorxmr/mysu.git
synced 2024-11-10 05:03:26 +01:00
Transaction output item now has two paste buttons, one for amount and one for address
This commit is contained in:
parent
511cf1ea0e
commit
69c62ee713
@ -64,7 +64,7 @@ public class SendFragment extends Fragment {
|
||||
private final ActivityResultLauncher<ScanOptions> qrCodeLauncher = registerForActivityResult(new ScanContract(), result -> {
|
||||
if (result.getContents() != null) {
|
||||
if(currentEntryIndex != -1) {
|
||||
pasteAddress(getDestView(currentEntryIndex), result.getContents());
|
||||
pasteAddress(getDestView(currentEntryIndex), result.getContents(), false);
|
||||
currentEntryIndex = -1;
|
||||
}
|
||||
}
|
||||
@ -221,12 +221,21 @@ public class SendFragment extends Fragment {
|
||||
ConstraintLayout entryView = (ConstraintLayout)inflater.inflate(R.layout.transaction_output_item, null);
|
||||
ImageButton removeOutputImageButton = entryView.findViewById(R.id.remove_output_imagebutton);
|
||||
|
||||
entryView.findViewById(R.id.paste_amount_imagebutton).setOnClickListener(view1 -> {
|
||||
Context ctx = getContext();
|
||||
if (ctx != null) {
|
||||
String clipboard = Helper.getClipBoardText(ctx);
|
||||
if (clipboard != null) {
|
||||
pasteAddress(entryView, clipboard, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
entryView.findViewById(R.id.paste_address_imagebutton).setOnClickListener(view1 -> {
|
||||
Context ctx = getContext();
|
||||
if (ctx != null) {
|
||||
String clipboard = Helper.getClipBoardText(ctx);
|
||||
if (clipboard != null) {
|
||||
pasteAddress(entryView, clipboard);
|
||||
pasteAddress(entryView, clipboard, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -312,8 +321,8 @@ public class SendFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
private void pasteAddress(ConstraintLayout entryView, String address) {
|
||||
UriData uriData = UriData.parse(address);
|
||||
private void pasteAddress(ConstraintLayout entryView, String clipboard, boolean pastingAmount) {
|
||||
UriData uriData = UriData.parse(clipboard);
|
||||
if (uriData != null) {
|
||||
EditText addressField = entryView.findViewById(R.id.address_edittext);
|
||||
addressField.setText(uriData.getAddress());
|
||||
@ -323,7 +332,18 @@ public class SendFragment extends Fragment {
|
||||
amountField.setText(uriData.getAmount());
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(getActivity(), getString(R.string.send_address_invalid), Toast.LENGTH_SHORT).show();
|
||||
if(pastingAmount) {
|
||||
try {
|
||||
Double.parseDouble(clipboard);
|
||||
sendMaxButton.setEnabled(false);
|
||||
EditText amountField = entryView.findViewById(R.id.amount_edittext);
|
||||
amountField.setText(clipboard);
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(getActivity(), getString(R.string.send_amount_invalid), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(getActivity(), getString(R.string.send_address_invalid), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
android:inputType="numberDecimal"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/address_edittext"
|
||||
app:layout_constraintEnd_toStartOf="@id/paste_address_imagebutton"
|
||||
app:layout_constraintEnd_toStartOf="@id/paste_amount_imagebutton"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
@ -54,17 +54,31 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:background="@drawable/edittext_bg"
|
||||
android:layout_marginStart="8dp"
|
||||
android:ellipsize="middle"
|
||||
android:hint="@string/address"
|
||||
android:singleLine="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/paste_address_imagebutton"
|
||||
app:layout_constraintStart_toEndOf="@id/to_address_label_textview"
|
||||
app:layout_constraintTop_toBottomOf="@id/amount_edittext"
|
||||
tools:visibility="visible" />
|
||||
<ImageButton
|
||||
android:id="@+id/paste_amount_imagebutton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:minWidth="48dp"
|
||||
android:minHeight="48dp"
|
||||
android:src="@drawable/ic_content_paste_24dp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/amount_edittext"
|
||||
app:layout_constraintEnd_toStartOf="@id/remove_output_imagebutton"
|
||||
app:layout_constraintStart_toEndOf="@id/amount_edittext"
|
||||
app:layout_constraintTop_toTopOf="@id/amount_edittext"
|
||||
tools:ignore="SpeakableTextPresentCheck"
|
||||
tools:visibility="visible" />
|
||||
<ImageButton
|
||||
android:id="@+id/paste_address_imagebutton"
|
||||
android:layout_width="wrap_content"
|
||||
@ -74,13 +88,12 @@
|
||||
android:minWidth="48dp"
|
||||
android:minHeight="48dp"
|
||||
android:src="@drawable/ic_content_paste_24dp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/amount_edittext"
|
||||
app:layout_constraintBottom_toBottomOf="@id/address_edittext"
|
||||
app:layout_constraintEnd_toStartOf="@id/scan_address_imagebutton"
|
||||
app:layout_constraintStart_toEndOf="@id/amount_edittext"
|
||||
app:layout_constraintTop_toTopOf="@id/amount_edittext"
|
||||
app:layout_constraintStart_toEndOf="@id/address_edittext"
|
||||
app:layout_constraintTop_toTopOf="@id/address_edittext"
|
||||
tools:ignore="SpeakableTextPresentCheck"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/scan_address_imagebutton"
|
||||
android:layout_width="wrap_content"
|
||||
@ -88,11 +101,12 @@
|
||||
android:background="@android:color/transparent"
|
||||
android:minWidth="48dp"
|
||||
android:minHeight="48dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:src="@drawable/ic_scan"
|
||||
app:layout_constraintBottom_toBottomOf="@id/amount_edittext"
|
||||
app:layout_constraintEnd_toStartOf="@id/remove_output_imagebutton"
|
||||
app:layout_constraintBottom_toBottomOf="@id/address_edittext"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/paste_address_imagebutton"
|
||||
app:layout_constraintTop_toTopOf="@id/amount_edittext"
|
||||
app:layout_constraintTop_toTopOf="@id/address_edittext"
|
||||
tools:ignore="SpeakableTextPresentCheck"
|
||||
tools:visibility="visible" />
|
||||
<ImageButton
|
||||
@ -106,7 +120,7 @@
|
||||
android:src="@android:drawable/ic_delete"
|
||||
app:layout_constraintBottom_toBottomOf="@id/amount_edittext"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/scan_address_imagebutton"
|
||||
app:layout_constraintStart_toEndOf="@id/paste_amount_imagebutton"
|
||||
app:layout_constraintTop_toTopOf="@id/amount_edittext"
|
||||
tools:ignore="SpeakableTextPresentCheck"
|
||||
tools:visibility="visible" />
|
||||
|
@ -5,6 +5,7 @@
|
||||
<string name="bad_password">Incorrect password!</string>
|
||||
|
||||
<string name="send_address_invalid">Not a valid address</string>
|
||||
<string name="send_amount_invalid">Not a valid amount</string>
|
||||
|
||||
<string name="tx_list_failed_text">failed</string>
|
||||
<string name="tx_list_amount_negative">- %1$s</string>
|
||||
|
Loading…
Reference in New Issue
Block a user