mirror of
https://codeberg.org/r4v3r23/mysu.git
synced 2024-11-10 05:03:44 +01:00
Parse URIs for amount and address
This commit is contained in:
parent
81c6cb6074
commit
f17bd07d67
@ -29,8 +29,10 @@ import com.m2049r.xmrwallet.model.PendingTransaction;
|
|||||||
import com.m2049r.xmrwallet.model.Wallet;
|
import com.m2049r.xmrwallet.model.Wallet;
|
||||||
import com.m2049r.xmrwallet.service.BalanceService;
|
import com.m2049r.xmrwallet.service.BalanceService;
|
||||||
import com.m2049r.xmrwallet.service.TxService;
|
import com.m2049r.xmrwallet.service.TxService;
|
||||||
|
import com.m2049r.xmrwallet.util.Constants;
|
||||||
import com.m2049r.xmrwallet.util.Helper;
|
import com.m2049r.xmrwallet.util.Helper;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SendBottomSheetDialog extends BottomSheetDialogFragment {
|
public class SendBottomSheetDialog extends BottomSheetDialogFragment {
|
||||||
@ -234,14 +236,30 @@ public class SendBottomSheetDialog extends BottomSheetDialogFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void pasteAddress(String address) {
|
private void pasteAddress(String address) {
|
||||||
String modifiedAddress = address.replace("monero:", "").split("\\?")[0];
|
HashMap<String, String> params = new HashMap<>();
|
||||||
boolean isValid = Wallet.isAddressValid(modifiedAddress);
|
String[] uriParts = address.replace(Constants.URI_PREFIX, "").split("\\?");
|
||||||
|
String finalAddress = uriParts[0];
|
||||||
|
String queryParams = "";
|
||||||
|
if(uriParts.length > 1) {
|
||||||
|
queryParams = uriParts[1];
|
||||||
|
String[] queryParts = queryParams.split("&");
|
||||||
|
for (String param : queryParts) {
|
||||||
|
String[] paramParts = param.split("=");
|
||||||
|
String variable = paramParts[0];
|
||||||
|
String value = paramParts[1];
|
||||||
|
params.put(variable, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
boolean isValid = Wallet.isAddressValid(finalAddress);
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
addressEditText.setText(modifiedAddress);
|
addressEditText.setText(finalAddress);
|
||||||
|
if(!params.isEmpty()) {
|
||||||
|
if(params.containsKey(Constants.URI_ARG_AMOUNT)) {
|
||||||
|
amountEditText.setText(params.get(Constants.URI_ARG_AMOUNT));
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(getActivity(), getString(R.string.send_address_invalid), Toast.LENGTH_SHORT).show();
|
Toast.makeText(getActivity(), getString(R.string.send_address_invalid), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -7,4 +7,7 @@ public class Constants {
|
|||||||
public static final String PREF_USES_TOR = "pref_uses_tor";
|
public static final String PREF_USES_TOR = "pref_uses_tor";
|
||||||
public static final String PREF_NIGHT_MODE = "pref_night_mode";
|
public static final String PREF_NIGHT_MODE = "pref_night_mode";
|
||||||
public static final String PREF_PROXY = "pref_proxy";
|
public static final String PREF_PROXY = "pref_proxy";
|
||||||
|
|
||||||
|
public static final String URI_PREFIX = "monero:";
|
||||||
|
public static final String URI_ARG_AMOUNT = "tx_amount";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user