paste receiver address (#592)

This commit is contained in:
m2049r 2019-05-20 17:17:46 +02:00 committed by GitHub
parent 331d88ebba
commit 830d9dadb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 74 additions and 11 deletions

View File

@ -33,7 +33,9 @@ import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import com.m2049r.xmrwallet.R; import com.m2049r.xmrwallet.R;
import com.m2049r.xmrwallet.data.BarcodeData; import com.m2049r.xmrwallet.data.BarcodeData;
@ -92,6 +94,7 @@ public class SendAddressWizardFragment extends SendWizardFragment {
private View llPaymentId; private View llPaymentId;
private TextView tvXmrTo; private TextView tvXmrTo;
private View llXmrTo; private View llXmrTo;
private ImageButton bPasteAddress;
private boolean resolvingOA = false; private boolean resolvingOA = false;
private boolean resolvingPP = 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 = view.findViewById(R.id.etPaymentId);
etPaymentId.getEditText().setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); etPaymentId.getEditText().setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
etPaymentId.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() { etPaymentId.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {

View File

@ -21,6 +21,7 @@ import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.content.ClipData; import android.content.ClipData;
import android.content.ClipDescription;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
@ -281,6 +282,16 @@ public class Helper {
clipboardManager.setPrimaryClip(clip); 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 private Animation ShakeAnimation;
static public Animation getShakeAnimation(Context context) { static public Animation getShakeAnimation(Context context) {

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="@color/gradientOrange"
android:pathData="M19,2h-4.18C14.4,0.84 13.3,0 12,0c-1.3,0 -2.4,0.84 -2.82,2L5,2c-1.1,0 -2,0.9 -2,2v16c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,4c0,-1.1 -0.9,-2 -2,-2zM12,2c0.55,0 1,0.45 1,1s-0.45,1 -1,1 -1,-0.45 -1,-1 0.45,-1 1,-1zM19,20L5,20L5,4h2v3h10L17,4h2v16z" />
</vector>

View File

@ -20,21 +20,46 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" /> android:layout_height="0dp" />
<android.support.design.widget.TextInputLayout <RelativeLayout
android:id="@+id/etAddress" android:id="@+id/llAddress"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:errorEnabled="true"> android:layout_gravity="center"
android:layout_marginBottom="4dp"
android:orientation="horizontal">
<android.support.design.widget.TextInputEditText <android.support.design.widget.TextInputLayout
style="@style/MoneroEdit" android:id="@+id/etAddress"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/send_address_hint" android:layout_alignParentStart="true"
android:imeOptions="actionNext" android:layout_toStartOf="@+id/bPasteAddress"
android:inputType="textMultiLine" app:counterEnabled="true"
android:textAlignment="textStart" /> app:counterMaxLength="16"
</android.support.design.widget.TextInputLayout> app:errorEnabled="true">
<android.support.design.widget.TextInputEditText
style="@style/MoneroEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="10"
android:hint="@string/send_address_hint"
android:imeOptions="actionNext"
android:inputType="textMultiLine"
android:textAlignment="textStart" />
</android.support.design.widget.TextInputLayout>
<ImageButton
android:id="@+id/bPasteAddress"
style="@style/MoneroText.Button.Small"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_alignParentEnd="true"
android:layout_gravity="center"
android:layout_marginStart="8dp"
android:background="?android:selectableItemBackgroundBorderless"
android:src="@drawable/ic_content_paste_orange_24dp" />
</RelativeLayout>
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"