diff --git a/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendAddressWizardFragment.java b/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendAddressWizardFragment.java index c8597e1e..11e4fcd2 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendAddressWizardFragment.java +++ b/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendAddressWizardFragment.java @@ -33,7 +33,9 @@ import android.view.ViewGroup; import android.view.inputmethod.EditorInfo; import android.widget.Button; import android.widget.EditText; +import android.widget.ImageButton; import android.widget.TextView; +import android.widget.Toast; import com.m2049r.xmrwallet.R; import com.m2049r.xmrwallet.data.BarcodeData; @@ -92,6 +94,7 @@ public class SendAddressWizardFragment extends SendWizardFragment { private View llPaymentId; private TextView tvXmrTo; private View llXmrTo; + private ImageButton bPasteAddress; private boolean resolvingOA = false; private boolean resolvingPP = false; @@ -197,6 +200,21 @@ public class SendAddressWizardFragment extends SendWizardFragment { } }); + bPasteAddress = view.findViewById(R.id.bPasteAddress); + bPasteAddress.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + final String clip = Helper.getClipBoardText(getActivity()); + if (clip == null) return; + // clean it up + final String address = clip.replaceAll("[^0-9A-Z-a-z]", ""); + if (Wallet.isAddressValid(address) || BitcoinAddressValidator.validate(address)) + etAddress.getEditText().setText(address); + else + Toast.makeText(getActivity(), getString(R.string.send_address_invalid), Toast.LENGTH_SHORT).show(); + } + }); + etPaymentId = view.findViewById(R.id.etPaymentId); etPaymentId.getEditText().setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); etPaymentId.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() { diff --git a/app/src/main/java/com/m2049r/xmrwallet/util/Helper.java b/app/src/main/java/com/m2049r/xmrwallet/util/Helper.java index 968dbe10..21814a54 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/util/Helper.java +++ b/app/src/main/java/com/m2049r/xmrwallet/util/Helper.java @@ -21,6 +21,7 @@ import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.content.ClipData; +import android.content.ClipDescription; import android.content.ClipboardManager; import android.content.Context; import android.content.DialogInterface; @@ -281,6 +282,16 @@ public class Helper { clipboardManager.setPrimaryClip(clip); } + static public String getClipBoardText(Context context) { + final ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); + if (clipboardManager.hasPrimaryClip() + && clipboardManager.getPrimaryClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) { + final ClipData.Item item = clipboardManager.getPrimaryClip().getItemAt(0); + return item.getText().toString(); + } + return null; + } + static private Animation ShakeAnimation; static public Animation getShakeAnimation(Context context) { diff --git a/app/src/main/res/drawable/ic_content_paste_orange_24dp.xml b/app/src/main/res/drawable/ic_content_paste_orange_24dp.xml new file mode 100644 index 00000000..f22f482f --- /dev/null +++ b/app/src/main/res/drawable/ic_content_paste_orange_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/fragment_send_address.xml b/app/src/main/res/layout/fragment_send_address.xml index e1e0f2b6..b874980d 100644 --- a/app/src/main/res/layout/fragment_send_address.xml +++ b/app/src/main/res/layout/fragment_send_address.xml @@ -20,21 +20,46 @@ android:layout_width="0dp" android:layout_height="0dp" /> - + android:layout_gravity="center" + android:layout_marginBottom="4dp" + android:orientation="horizontal"> - - + android:layout_alignParentStart="true" + android:layout_toStartOf="@+id/bPasteAddress" + app:counterEnabled="true" + app:counterMaxLength="16" + app:errorEnabled="true"> + + + + + +