add copy button to receive popup

This commit is contained in:
pokkst 2022-09-10 17:17:12 -05:00
parent 67ab38d91f
commit 21a81a271a
No known key found for this signature in database
GPG Key ID: 90C2ED85E67A50FF
2 changed files with 21 additions and 4 deletions

View File

@ -5,6 +5,7 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
@ -21,6 +22,7 @@ import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.m2049r.xmrwallet.R;
import com.m2049r.xmrwallet.data.Subaddress;
import com.m2049r.xmrwallet.service.AddressService;
import com.m2049r.xmrwallet.util.Helper;
import java.util.HashMap;
import java.util.Map;
@ -39,10 +41,12 @@ public class ReceiveBottomSheetDialog extends BottomSheetDialogFragment {
super.onViewCreated(view, savedInstanceState);
ImageView addressImageView = view.findViewById(R.id.monero_qr_imageview);
TextView addressTextView = view.findViewById(R.id.address_textview);
ImageButton copyAddressImageButton = view.findViewById(R.id.copy_address_imagebutton);
Subaddress addr = AddressService.getInstance().getLatestSubaddress();
addressTextView.setText(addr.getAddress());
addressImageView.setImageBitmap(generate(addr.getAddress(), 256, 256));
copyAddressImageButton.setOnClickListener(view1 -> Helper.clipBoardCopy(getContext(), "address", addr.getAddress()));
}
public Bitmap generate(String text, int width, int height) {

View File

@ -35,17 +35,30 @@
<TextView
android:id="@+id/address_textview"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:layout_marginEnd="8dp"
android:textAlignment="center"
android:textSize="16sp"
android:textStyle="bold"
tools:text="ADDRESS"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@id/copy_address_imagebutton"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/monero_qr_imageview" />
<ImageButton
android:id="@+id/copy_address_imagebutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:padding="8dp"
android:layout_marginEnd="24dp"
android:src="@drawable/ic_content_copy_24dp"
app:layout_constraintTop_toTopOf="@id/address_textview"
app:layout_constraintBottom_toBottomOf="@id/address_textview"
app:layout_constraintStart_toEndOf="@id/address_textview"
app:layout_constraintEnd_toEndOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>