mirror of
https://codeberg.org/anoncontributorxmr/mysu.git
synced 2024-11-22 07:22:26 +00:00
auto-reformat code
This commit is contained in:
parent
316fb994da
commit
58e4954084
28 changed files with 158 additions and 144 deletions
|
@ -60,7 +60,7 @@ public class MainActivity extends AppCompatActivity implements MoneroHandlerThre
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
Uri uri = intent.getData();
|
Uri uri = intent.getData();
|
||||||
if(uri != null) {
|
if (uri != null) {
|
||||||
uriData = UriData.parse(uri.toString());
|
uriData = UriData.parse(uri.toString());
|
||||||
if (uriData != null) {
|
if (uriData != null) {
|
||||||
proceedToSend = true;
|
proceedToSend = true;
|
||||||
|
@ -122,7 +122,7 @@ public class MainActivity extends AppCompatActivity implements MoneroHandlerThre
|
||||||
init(walletFile, password);
|
init(walletFile, password);
|
||||||
restartEvents.call();
|
restartEvents.call();
|
||||||
|
|
||||||
if(proceedToSend) {
|
if (proceedToSend) {
|
||||||
SendBottomSheetDialog sendDialog = new SendBottomSheetDialog();
|
SendBottomSheetDialog sendDialog = new SendBottomSheetDialog();
|
||||||
sendDialog.uriData = uriData;
|
sendDialog.uriData = uriData;
|
||||||
sendDialog.show(getSupportFragmentManager(), null);
|
sendDialog.show(getSupportFragmentManager(), null);
|
||||||
|
|
|
@ -106,19 +106,19 @@ public class CoinsInfoAdapter extends RecyclerView.Adapter<CoinsInfoAdapter.View
|
||||||
amountTextView.setText(itemView.getResources().getString(R.string.tx_amount_no_prefix, Wallet.getDisplayAmount(coinsInfo.getAmount())));
|
amountTextView.setText(itemView.getResources().getString(R.string.tx_amount_no_prefix, Wallet.getDisplayAmount(coinsInfo.getAmount())));
|
||||||
pubKeyTextView.setText(coinsInfo.getPubKey());
|
pubKeyTextView.setText(coinsInfo.getPubKey());
|
||||||
globalIdxTextView.setText(itemView.getResources().getString(R.string.global_index_text, coinsInfo.getGlobalOutputIndex()));
|
globalIdxTextView.setText(itemView.getResources().getString(R.string.global_index_text, coinsInfo.getGlobalOutputIndex()));
|
||||||
outpointTextView.setText(itemView.getResources().getString(R.string.outpoint_text, coinsInfo.getHash()+":"+coinsInfo.getLocalOutputIndex()));
|
outpointTextView.setText(itemView.getResources().getString(R.string.outpoint_text, coinsInfo.getHash() + ":" + coinsInfo.getLocalOutputIndex()));
|
||||||
|
|
||||||
itemView.setOnLongClickListener(view -> {
|
itemView.setOnLongClickListener(view -> {
|
||||||
boolean unlocked = coinsInfo.isUnlocked();
|
boolean unlocked = coinsInfo.isUnlocked();
|
||||||
if(unlocked) {
|
if (unlocked) {
|
||||||
listener.onUtxoSelected(coinsInfo);
|
listener.onUtxoSelected(coinsInfo);
|
||||||
}
|
}
|
||||||
return unlocked;
|
return unlocked;
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!coinsInfo.isUnlocked()) {
|
if (!coinsInfo.isUnlocked()) {
|
||||||
itemView.setBackgroundColor(ContextCompat.getColor(itemView.getContext(), R.color.oled_locked_utxo));
|
itemView.setBackgroundColor(ContextCompat.getColor(itemView.getContext(), R.color.oled_locked_utxo));
|
||||||
} else if(selected) {
|
} else if (selected) {
|
||||||
itemView.setBackgroundColor(ContextCompat.getColor(itemView.getContext(), R.color.oled_negativeColor));
|
itemView.setBackgroundColor(ContextCompat.getColor(itemView.getContext(), R.color.oled_negativeColor));
|
||||||
} else {
|
} else {
|
||||||
itemView.setBackgroundColor(ContextCompat.getColor(itemView.getContext(), android.R.color.transparent));
|
itemView.setBackgroundColor(ContextCompat.getColor(itemView.getContext(), android.R.color.transparent));
|
||||||
|
|
|
@ -87,6 +87,7 @@ public class NodeSelectionAdapter extends RecyclerView.Adapter<NodeSelectionAdap
|
||||||
*/
|
*/
|
||||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
private final NodeSelectionAdapterListener listener;
|
private final NodeSelectionAdapterListener listener;
|
||||||
|
|
||||||
public ViewHolder(NodeSelectionAdapterListener listener, View view) {
|
public ViewHolder(NodeSelectionAdapterListener listener, View view) {
|
||||||
super(view);
|
super(view);
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
|
@ -96,7 +97,7 @@ public class NodeSelectionAdapter extends RecyclerView.Adapter<NodeSelectionAdap
|
||||||
String currentNodeString = PrefService.getInstance().getString(Constants.PREF_NODE, DefaultNodes.XMRTW.getAddress());
|
String currentNodeString = PrefService.getInstance().getString(Constants.PREF_NODE, DefaultNodes.XMRTW.getAddress());
|
||||||
Node currentNode = Node.fromString(currentNodeString);
|
Node currentNode = Node.fromString(currentNodeString);
|
||||||
boolean match = node.equals(currentNode);
|
boolean match = node.equals(currentNode);
|
||||||
if(match) {
|
if (match) {
|
||||||
itemView.setBackgroundColor(itemView.getResources().getColor(R.color.oled_colorSecondary));
|
itemView.setBackgroundColor(itemView.getResources().getColor(R.color.oled_colorSecondary));
|
||||||
} else {
|
} else {
|
||||||
itemView.setBackgroundColor(itemView.getResources().getColor(android.R.color.transparent));
|
itemView.setBackgroundColor(itemView.getResources().getColor(android.R.color.transparent));
|
||||||
|
|
|
@ -113,14 +113,14 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfo
|
||||||
public void bind(TransactionInfo txInfo) {
|
public void bind(TransactionInfo txInfo) {
|
||||||
String displayAmount = Helper.getDisplayAmount(txInfo.amount, Helper.DISPLAY_DIGITS_INFO);
|
String displayAmount = Helper.getDisplayAmount(txInfo.amount, Helper.DISPLAY_DIGITS_INFO);
|
||||||
|
|
||||||
TextView confirmationsTextView = ((TextView) itemView.findViewById(R.id.tvConfirmations));
|
TextView confirmationsTextView = itemView.findViewById(R.id.tvConfirmations);
|
||||||
CircularProgressIndicator confirmationsProgressBar = ((CircularProgressIndicator) itemView.findViewById(R.id.pbConfirmations));
|
CircularProgressIndicator confirmationsProgressBar = itemView.findViewById(R.id.pbConfirmations);
|
||||||
confirmationsProgressBar.setMax(TransactionInfo.CONFIRMATION);
|
confirmationsProgressBar.setMax(TransactionInfo.CONFIRMATION);
|
||||||
this.amountTextView = ((TextView) itemView.findViewById(R.id.tx_amount));
|
this.amountTextView = itemView.findViewById(R.id.tx_amount);
|
||||||
((TextView) itemView.findViewById(R.id.tx_failed)).setVisibility(View.GONE);
|
itemView.findViewById(R.id.tx_failed).setVisibility(View.GONE);
|
||||||
if (txInfo.isFailed) {
|
if (txInfo.isFailed) {
|
||||||
((TextView) itemView.findViewById(R.id.tx_amount)).setText(itemView.getContext().getString(R.string.tx_list_amount_negative, displayAmount));
|
((TextView) itemView.findViewById(R.id.tx_amount)).setText(itemView.getContext().getString(R.string.tx_list_amount_negative, displayAmount));
|
||||||
((TextView) itemView.findViewById(R.id.tx_failed)).setVisibility(View.VISIBLE);
|
itemView.findViewById(R.id.tx_failed).setVisibility(View.VISIBLE);
|
||||||
setTxColour(failedColour);
|
setTxColour(failedColour);
|
||||||
confirmationsTextView.setVisibility(View.GONE);
|
confirmationsTextView.setVisibility(View.GONE);
|
||||||
confirmationsProgressBar.setVisibility(View.GONE);
|
confirmationsProgressBar.setVisibility(View.GONE);
|
||||||
|
@ -158,7 +158,7 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfo
|
||||||
((TextView) itemView.findViewById(R.id.tx_amount)).setText(itemView.getContext().getString(R.string.tx_list_amount_positive, displayAmount));
|
((TextView) itemView.findViewById(R.id.tx_amount)).setText(itemView.getContext().getString(R.string.tx_list_amount_positive, displayAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
TextView paymentIdTextView = ((TextView) itemView.findViewById(R.id.tx_paymentid));
|
TextView paymentIdTextView = itemView.findViewById(R.id.tx_paymentid);
|
||||||
String tag = null;
|
String tag = null;
|
||||||
String info = "";
|
String info = "";
|
||||||
UserNotes userNotes = new UserNotes(txInfo.notes);
|
UserNotes userNotes = new UserNotes(txInfo.notes);
|
||||||
|
|
|
@ -30,6 +30,7 @@ public enum DefaultNodes {
|
||||||
boldsuck("6dsdenp6vjkvqzy4wzsnzn6wixkdzihx3khiumyzieauxuxslmcaeiad.onion:18081/mainnet/boldsuck.onion");
|
boldsuck("6dsdenp6vjkvqzy4wzsnzn6wixkdzihx3khiumyzieauxuxslmcaeiad.onion:18081/mainnet/boldsuck.onion");
|
||||||
|
|
||||||
private final String uri;
|
private final String uri;
|
||||||
|
|
||||||
DefaultNodes(String uri) {
|
DefaultNodes(String uri) {
|
||||||
this.uri = uri;
|
this.uri = uri;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ import net.mynero.wallet.model.Wallet;
|
||||||
import net.mynero.wallet.util.Helper;
|
import net.mynero.wallet.util.Helper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
// https://stackoverflow.com/questions/2139134/how-to-send-an-object-from-one-android-activity-to-another-using-intents
|
// https://stackoverflow.com/questions/2139134/how-to-send-an-object-from-one-android-activity-to-another-using-intents
|
||||||
public class TxData implements Parcelable {
|
public class TxData implements Parcelable {
|
||||||
|
|
|
@ -14,6 +14,7 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||||
|
|
||||||
import net.mynero.wallet.R;
|
import net.mynero.wallet.R;
|
||||||
import net.mynero.wallet.service.PrefService;
|
import net.mynero.wallet.service.PrefService;
|
||||||
import net.mynero.wallet.util.Constants;
|
import net.mynero.wallet.util.Constants;
|
||||||
|
@ -39,42 +40,42 @@ public class AddNodeBottomSheetDialog extends BottomSheetDialogFragment {
|
||||||
ImageButton pasteAddressImageButton = view.findViewById(R.id.paste_address_imagebutton);
|
ImageButton pasteAddressImageButton = view.findViewById(R.id.paste_address_imagebutton);
|
||||||
pasteAddressImageButton.setOnClickListener(view1 -> {
|
pasteAddressImageButton.setOnClickListener(view1 -> {
|
||||||
Context ctx = getContext();
|
Context ctx = getContext();
|
||||||
if(ctx != null) {
|
if (ctx != null) {
|
||||||
addressEditText.setText(Helper.getClipBoardText(ctx));
|
addressEditText.setText(Helper.getClipBoardText(ctx));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
addNodeButton.setOnClickListener(view1 -> {
|
addNodeButton.setOnClickListener(view1 -> {
|
||||||
String node = addressEditText.getText().toString();
|
String node = addressEditText.getText().toString();
|
||||||
String name = nodeNameEditText.getText().toString();
|
String name = nodeNameEditText.getText().toString();
|
||||||
if(node.contains(":") && !name.isEmpty()) {
|
if (node.contains(":") && !name.isEmpty()) {
|
||||||
String[] nodeParts = node.split(":");
|
String[] nodeParts = node.split(":");
|
||||||
if(nodeParts.length == 2) {
|
if (nodeParts.length == 2) {
|
||||||
try {
|
try {
|
||||||
String address = nodeParts[0];
|
String address = nodeParts[0];
|
||||||
int port = Integer.parseInt(nodeParts[1]);
|
int port = Integer.parseInt(nodeParts[1]);
|
||||||
String newNodeString = address + ":" + port + "/mainnet/" + name;
|
String newNodeString = address + ":" + port + "/mainnet/" + name;
|
||||||
boolean validAddress = Patterns.IP_ADDRESS.matcher(address).matches() || Patterns.DOMAIN_NAME.matcher(address).matches();
|
boolean validAddress = Patterns.IP_ADDRESS.matcher(address).matches() || Patterns.DOMAIN_NAME.matcher(address).matches();
|
||||||
if(validAddress) {
|
if (validAddress) {
|
||||||
String nodesArray = PrefService.getInstance().getString(Constants.PREF_CUSTOM_NODES, "[]");
|
String nodesArray = PrefService.getInstance().getString(Constants.PREF_CUSTOM_NODES, "[]");
|
||||||
JSONArray jsonArray = new JSONArray(nodesArray);
|
JSONArray jsonArray = new JSONArray(nodesArray);
|
||||||
boolean exists = false;
|
boolean exists = false;
|
||||||
for(int i = 0; i < jsonArray.length(); i++) {
|
for (int i = 0; i < jsonArray.length(); i++) {
|
||||||
String nodeString = jsonArray.getString(i);
|
String nodeString = jsonArray.getString(i);
|
||||||
if(nodeString.equals(newNodeString))
|
if (nodeString.equals(newNodeString))
|
||||||
exists = true;
|
exists = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!exists) {
|
if (!exists) {
|
||||||
jsonArray.put(newNodeString);
|
jsonArray.put(newNodeString);
|
||||||
}
|
}
|
||||||
|
|
||||||
PrefService.getInstance().edit().putString(Constants.PREF_CUSTOM_NODES, jsonArray.toString()).apply();
|
PrefService.getInstance().edit().putString(Constants.PREF_CUSTOM_NODES, jsonArray.toString()).apply();
|
||||||
if(listener != null) {
|
if (listener != null) {
|
||||||
listener.onNodeAdded();
|
listener.onNodeAdded();
|
||||||
}
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
} catch(NumberFormatException | JSONException e) {
|
} catch (NumberFormatException | JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||||
|
|
||||||
import net.mynero.wallet.R;
|
import net.mynero.wallet.R;
|
||||||
import net.mynero.wallet.util.Helper;
|
import net.mynero.wallet.util.Helper;
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||||
|
|
||||||
import net.mynero.wallet.R;
|
import net.mynero.wallet.R;
|
||||||
import net.mynero.wallet.adapter.NodeSelectionAdapter;
|
import net.mynero.wallet.adapter.NodeSelectionAdapter;
|
||||||
import net.mynero.wallet.data.DefaultNodes;
|
import net.mynero.wallet.data.DefaultNodes;
|
||||||
|
@ -28,8 +29,8 @@ import org.json.JSONException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class NodeSelectionBottomSheetDialog extends BottomSheetDialogFragment implements NodeSelectionAdapter.NodeSelectionAdapterListener {
|
public class NodeSelectionBottomSheetDialog extends BottomSheetDialogFragment implements NodeSelectionAdapter.NodeSelectionAdapterListener {
|
||||||
private NodeSelectionAdapter adapter = null;
|
|
||||||
public NodeSelectionDialogListener listener = null;
|
public NodeSelectionDialogListener listener = null;
|
||||||
|
private NodeSelectionAdapter adapter = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
@ -48,7 +49,7 @@ public class NodeSelectionBottomSheetDialog extends BottomSheetDialogFragment im
|
||||||
|
|
||||||
Button addNodeButton = view.findViewById(R.id.add_node_button);
|
Button addNodeButton = view.findViewById(R.id.add_node_button);
|
||||||
addNodeButton.setOnClickListener(view1 -> {
|
addNodeButton.setOnClickListener(view1 -> {
|
||||||
if(listener != null) {
|
if (listener != null) {
|
||||||
listener.onClickedAddNode();
|
listener.onClickedAddNode();
|
||||||
}
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
|
@ -57,10 +58,10 @@ public class NodeSelectionBottomSheetDialog extends BottomSheetDialogFragment im
|
||||||
try {
|
try {
|
||||||
String nodesArray = PrefService.getInstance().getString(Constants.PREF_CUSTOM_NODES, "[]");
|
String nodesArray = PrefService.getInstance().getString(Constants.PREF_CUSTOM_NODES, "[]");
|
||||||
JSONArray jsonArray = new JSONArray(nodesArray);
|
JSONArray jsonArray = new JSONArray(nodesArray);
|
||||||
for(int i = 0; i < jsonArray.length(); i++) {
|
for (int i = 0; i < jsonArray.length(); i++) {
|
||||||
String nodeString = jsonArray.getString(i);
|
String nodeString = jsonArray.getString(i);
|
||||||
Node node = Node.fromString(nodeString);
|
Node node = Node.fromString(nodeString);
|
||||||
if(node != null) {
|
if (node != null) {
|
||||||
nodes.add(node);
|
nodes.add(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +69,7 @@ public class NodeSelectionBottomSheetDialog extends BottomSheetDialogFragment im
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(DefaultNodes defaultNode : DefaultNodes.values()) {
|
for (DefaultNodes defaultNode : DefaultNodes.values()) {
|
||||||
nodes.add(Node.fromString(defaultNode.getUri()));
|
nodes.add(Node.fromString(defaultNode.getUri()));
|
||||||
}
|
}
|
||||||
adapter.submitList(nodes);
|
adapter.submitList(nodes);
|
||||||
|
@ -77,7 +78,7 @@ public class NodeSelectionBottomSheetDialog extends BottomSheetDialogFragment im
|
||||||
@Override
|
@Override
|
||||||
public void onSelectNode(Node node) {
|
public void onSelectNode(Node node) {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if(activity != null) {
|
if (activity != null) {
|
||||||
activity.runOnUiThread(() -> {
|
activity.runOnUiThread(() -> {
|
||||||
Toast.makeText(activity, getString(R.string.node_selected), Toast.LENGTH_SHORT).show();
|
Toast.makeText(activity, getString(R.string.node_selected), Toast.LENGTH_SHORT).show();
|
||||||
});
|
});
|
||||||
|
@ -90,6 +91,7 @@ public class NodeSelectionBottomSheetDialog extends BottomSheetDialogFragment im
|
||||||
|
|
||||||
public interface NodeSelectionDialogListener {
|
public interface NodeSelectionDialogListener {
|
||||||
void onNodeSelected();
|
void onNodeSelected();
|
||||||
|
|
||||||
void onClickedAddNode();
|
void onClickedAddNode();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,6 +12,7 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||||
|
|
||||||
import net.mynero.wallet.R;
|
import net.mynero.wallet.R;
|
||||||
import net.mynero.wallet.model.WalletManager;
|
import net.mynero.wallet.model.WalletManager;
|
||||||
import net.mynero.wallet.util.Constants;
|
import net.mynero.wallet.util.Constants;
|
||||||
|
|
|
@ -19,17 +19,15 @@ import com.google.zxing.WriterException;
|
||||||
import com.google.zxing.common.BitMatrix;
|
import com.google.zxing.common.BitMatrix;
|
||||||
import com.google.zxing.qrcode.QRCodeWriter;
|
import com.google.zxing.qrcode.QRCodeWriter;
|
||||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||||
|
|
||||||
import net.mynero.wallet.R;
|
import net.mynero.wallet.R;
|
||||||
import net.mynero.wallet.data.Subaddress;
|
import net.mynero.wallet.data.Subaddress;
|
||||||
import net.mynero.wallet.model.CoinsInfo;
|
|
||||||
import net.mynero.wallet.model.WalletManager;
|
|
||||||
import net.mynero.wallet.service.AddressService;
|
import net.mynero.wallet.service.AddressService;
|
||||||
import net.mynero.wallet.util.DayNightMode;
|
import net.mynero.wallet.util.DayNightMode;
|
||||||
import net.mynero.wallet.util.Helper;
|
import net.mynero.wallet.util.Helper;
|
||||||
import net.mynero.wallet.util.NightmodeHelper;
|
import net.mynero.wallet.util.NightmodeHelper;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
|
@ -4,7 +4,6 @@ import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Pair;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -21,17 +20,16 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
import androidx.lifecycle.MutableLiveData;
|
import androidx.lifecycle.MutableLiveData;
|
||||||
import androidx.lifecycle.Observer;
|
|
||||||
|
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||||
import com.google.zxing.client.android.Intents;
|
import com.google.zxing.client.android.Intents;
|
||||||
import com.journeyapps.barcodescanner.ScanContract;
|
import com.journeyapps.barcodescanner.ScanContract;
|
||||||
import com.journeyapps.barcodescanner.ScanOptions;
|
import com.journeyapps.barcodescanner.ScanOptions;
|
||||||
|
|
||||||
import net.mynero.wallet.R;
|
import net.mynero.wallet.R;
|
||||||
import net.mynero.wallet.model.CoinsInfo;
|
import net.mynero.wallet.model.CoinsInfo;
|
||||||
import net.mynero.wallet.model.PendingTransaction;
|
import net.mynero.wallet.model.PendingTransaction;
|
||||||
import net.mynero.wallet.model.Wallet;
|
import net.mynero.wallet.model.Wallet;
|
||||||
import net.mynero.wallet.model.WalletManager;
|
|
||||||
import net.mynero.wallet.service.BalanceService;
|
import net.mynero.wallet.service.BalanceService;
|
||||||
import net.mynero.wallet.service.TxService;
|
import net.mynero.wallet.service.TxService;
|
||||||
import net.mynero.wallet.service.UTXOService;
|
import net.mynero.wallet.service.UTXOService;
|
||||||
|
@ -42,8 +40,9 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SendBottomSheetDialog extends BottomSheetDialogFragment {
|
public class SendBottomSheetDialog extends BottomSheetDialogFragment {
|
||||||
public ArrayList<String> selectedUtxos = new ArrayList<>();
|
|
||||||
private final MutableLiveData<Boolean> _sendingMax = new MutableLiveData<>(false);
|
private final MutableLiveData<Boolean> _sendingMax = new MutableLiveData<>(false);
|
||||||
|
private final MutableLiveData<PendingTransaction> _pendingTransaction = new MutableLiveData<>(null);
|
||||||
|
public ArrayList<String> selectedUtxos = new ArrayList<>();
|
||||||
public LiveData<Boolean> sendingMax = _sendingMax; private final ActivityResultLauncher<String> cameraPermissionsLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(),
|
public LiveData<Boolean> sendingMax = _sendingMax; private final ActivityResultLauncher<String> cameraPermissionsLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(),
|
||||||
granted -> {
|
granted -> {
|
||||||
if (granted) {
|
if (granted) {
|
||||||
|
@ -52,16 +51,17 @@ public class SendBottomSheetDialog extends BottomSheetDialogFragment {
|
||||||
Toast.makeText(getActivity(), getString(R.string.no_camera_permission), Toast.LENGTH_SHORT).show();
|
Toast.makeText(getActivity(), getString(R.string.no_camera_permission), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
private final MutableLiveData<PendingTransaction> _pendingTransaction = new MutableLiveData<>(null);
|
|
||||||
public LiveData<PendingTransaction> pendingTransaction = _pendingTransaction;
|
public LiveData<PendingTransaction> pendingTransaction = _pendingTransaction;
|
||||||
|
public UriData uriData = null;
|
||||||
|
public PendingTransaction.Priority priority;
|
||||||
private EditText addressEditText;
|
private EditText addressEditText;
|
||||||
|
private EditText amountEditText;
|
||||||
private final ActivityResultLauncher<ScanOptions> barcodeLauncher = registerForActivityResult(new ScanContract(),
|
private final ActivityResultLauncher<ScanOptions> barcodeLauncher = registerForActivityResult(new ScanContract(),
|
||||||
result -> {
|
result -> {
|
||||||
if (result.getContents() != null) {
|
if (result.getContents() != null) {
|
||||||
pasteAddress(result.getContents());
|
pasteAddress(result.getContents());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
private EditText amountEditText;
|
|
||||||
private TextView sendAllTextView;
|
private TextView sendAllTextView;
|
||||||
private TextView feeTextView;
|
private TextView feeTextView;
|
||||||
private TextView addressTextView;
|
private TextView addressTextView;
|
||||||
|
@ -75,9 +75,6 @@ public class SendBottomSheetDialog extends BottomSheetDialogFragment {
|
||||||
private ImageButton scanAddressImageButton;
|
private ImageButton scanAddressImageButton;
|
||||||
private RadioGroup feeRadioGroup;
|
private RadioGroup feeRadioGroup;
|
||||||
|
|
||||||
public UriData uriData = null;
|
|
||||||
public PendingTransaction.Priority priority;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
return inflater.inflate(R.layout.send_bottom_sheet_dialog, null);
|
return inflater.inflate(R.layout.send_bottom_sheet_dialog, null);
|
||||||
|
@ -103,16 +100,16 @@ public class SendBottomSheetDialog extends BottomSheetDialogFragment {
|
||||||
|
|
||||||
if (uriData != null) {
|
if (uriData != null) {
|
||||||
addressEditText.setText(uriData.getAddress());
|
addressEditText.setText(uriData.getAddress());
|
||||||
if(uriData.hasAmount()) {
|
if (uriData.hasAmount()) {
|
||||||
amountEditText.setText(uriData.getAmount());
|
amountEditText.setText(uriData.getAmount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!selectedUtxos.isEmpty()) {
|
if (!selectedUtxos.isEmpty()) {
|
||||||
long selectedValue = 0;
|
long selectedValue = 0;
|
||||||
|
|
||||||
for(CoinsInfo coinsInfo : UTXOService.getInstance().getUtxos()) {
|
for (CoinsInfo coinsInfo : UTXOService.getInstance().getUtxos()) {
|
||||||
if(selectedUtxos.contains(coinsInfo.getKeyImage())) {
|
if (selectedUtxos.contains(coinsInfo.getKeyImage())) {
|
||||||
selectedValue += coinsInfo.getAmount();
|
selectedValue += coinsInfo.getAmount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,11 +162,11 @@ public class SendBottomSheetDialog extends BottomSheetDialogFragment {
|
||||||
feeRadioGroup.check(R.id.low_fee_radiobutton);
|
feeRadioGroup.check(R.id.low_fee_radiobutton);
|
||||||
priority = PendingTransaction.Priority.Priority_Low;
|
priority = PendingTransaction.Priority.Priority_Low;
|
||||||
feeRadioGroup.setOnCheckedChangeListener((radioGroup, i) -> {
|
feeRadioGroup.setOnCheckedChangeListener((radioGroup, i) -> {
|
||||||
if(i == R.id.low_fee_radiobutton) {
|
if (i == R.id.low_fee_radiobutton) {
|
||||||
priority = PendingTransaction.Priority.Priority_Low;
|
priority = PendingTransaction.Priority.Priority_Low;
|
||||||
} else if(i == R.id.med_fee_radiobutton) {
|
} else if (i == R.id.med_fee_radiobutton) {
|
||||||
priority = PendingTransaction.Priority.Priority_Medium;
|
priority = PendingTransaction.Priority.Priority_Medium;
|
||||||
} else if(i == R.id.high_fee_radiobutton) {
|
} else if (i == R.id.high_fee_radiobutton) {
|
||||||
priority = PendingTransaction.Priority.Priority_High;
|
priority = PendingTransaction.Priority.Priority_High;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -309,7 +306,7 @@ public class SendBottomSheetDialog extends BottomSheetDialogFragment {
|
||||||
feeTextView.setVisibility(View.GONE);
|
feeTextView.setVisibility(View.GONE);
|
||||||
addressTextView.setVisibility(View.GONE);
|
addressTextView.setVisibility(View.GONE);
|
||||||
amountTextView.setVisibility(View.GONE);
|
amountTextView.setVisibility(View.GONE);
|
||||||
if(!selectedUtxos.isEmpty()) {
|
if (!selectedUtxos.isEmpty()) {
|
||||||
selectedUtxosValueTextView.setVisibility(View.VISIBLE);
|
selectedUtxosValueTextView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
feeRadioGroup.setVisibility(View.VISIBLE);
|
feeRadioGroup.setVisibility(View.VISIBLE);
|
||||||
|
@ -321,11 +318,13 @@ public class SendBottomSheetDialog extends BottomSheetDialogFragment {
|
||||||
UriData uriData = UriData.parse(address);
|
UriData uriData = UriData.parse(address);
|
||||||
if (uriData != null) {
|
if (uriData != null) {
|
||||||
addressEditText.setText(uriData.getAddress());
|
addressEditText.setText(uriData.getAddress());
|
||||||
if(uriData.hasAmount()) {
|
if (uriData.hasAmount()) {
|
||||||
amountEditText.setText(uriData.getAmount());
|
amountEditText.setText(uriData.getAmount());
|
||||||
}
|
}
|
||||||
} 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -16,10 +16,7 @@ import android.widget.Toast;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
|
||||||
import androidx.fragment.app.FragmentManager;
|
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.navigation.fragment.NavHostFragment;
|
|
||||||
|
|
||||||
import net.mynero.wallet.MainActivity;
|
import net.mynero.wallet.MainActivity;
|
||||||
import net.mynero.wallet.R;
|
import net.mynero.wallet.R;
|
||||||
|
@ -98,7 +95,7 @@ public class OnboardingFragment extends Fragment {
|
||||||
|
|
||||||
private void createOrImportWallet(String walletPassword, String walletSeed, String restoreHeightText) {
|
private void createOrImportWallet(String walletPassword, String walletSeed, String restoreHeightText) {
|
||||||
MainActivity mainActivity = (MainActivity) getActivity();
|
MainActivity mainActivity = (MainActivity) getActivity();
|
||||||
if(mainActivity != null) {
|
if (mainActivity != null) {
|
||||||
if (!walletPassword.isEmpty()) {
|
if (!walletPassword.isEmpty()) {
|
||||||
PrefService.getInstance().edit().putBoolean(Constants.PREF_USES_PASSWORD, true).apply();
|
PrefService.getInstance().edit().putBoolean(Constants.PREF_USES_PASSWORD, true).apply();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.navigation.NavDirections;
|
|
||||||
import androidx.navigation.fragment.NavHostFragment;
|
import androidx.navigation.fragment.NavHostFragment;
|
||||||
|
|
||||||
import net.mynero.wallet.R;
|
import net.mynero.wallet.R;
|
||||||
|
@ -43,20 +42,34 @@ public class SettingsFragment extends Fragment implements PasswordBottomSheetDia
|
||||||
|
|
||||||
private SettingsViewModel mViewModel;
|
private SettingsViewModel mViewModel;
|
||||||
TextWatcher proxyAddressListener = new TextWatcher() {
|
TextWatcher proxyAddressListener = new TextWatcher() {
|
||||||
@Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
@Override
|
||||||
@Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||||
@Override public void afterTextChanged(Editable editable) {
|
}
|
||||||
if(mViewModel != null) {
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable editable) {
|
||||||
|
if (mViewModel != null) {
|
||||||
mViewModel.setProxyAddress(editable.toString());
|
mViewModel.setProxyAddress(editable.toString());
|
||||||
mViewModel.updateProxy();
|
mViewModel.updateProxy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
TextWatcher proxyPortListener = new TextWatcher() {
|
TextWatcher proxyPortListener = new TextWatcher() {
|
||||||
@Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
@Override
|
||||||
@Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||||
@Override public void afterTextChanged(Editable editable) {
|
}
|
||||||
if(mViewModel != null) {
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable editable) {
|
||||||
|
if (mViewModel != null) {
|
||||||
mViewModel.setProxyPort(editable.toString());
|
mViewModel.setProxyPort(editable.toString());
|
||||||
mViewModel.updateProxy();
|
mViewModel.updateProxy();
|
||||||
}
|
}
|
||||||
|
@ -97,13 +110,13 @@ public class SettingsFragment extends Fragment implements PasswordBottomSheetDia
|
||||||
|
|
||||||
boolean usesProxy = PrefService.getInstance().getBoolean(Constants.PREF_USES_TOR, false);
|
boolean usesProxy = PrefService.getInstance().getBoolean(Constants.PREF_USES_TOR, false);
|
||||||
String proxy = PrefService.getInstance().getString(Constants.PREF_PROXY, "");
|
String proxy = PrefService.getInstance().getString(Constants.PREF_PROXY, "");
|
||||||
if(proxy.contains(":")) {
|
if (proxy.contains(":")) {
|
||||||
String proxyAddress = proxy.split(":")[0];
|
String proxyAddress = proxy.split(":")[0];
|
||||||
String proxyPort = proxy.split(":")[1];
|
String proxyPort = proxy.split(":")[1];
|
||||||
initProxyStuff(proxyAddress, proxyPort);
|
initProxyStuff(proxyAddress, proxyPort);
|
||||||
}
|
}
|
||||||
torSwitch.setChecked(usesProxy);
|
torSwitch.setChecked(usesProxy);
|
||||||
if(usesProxy) {
|
if (usesProxy) {
|
||||||
proxySettingsLayout.setVisibility(View.VISIBLE);
|
proxySettingsLayout.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
proxySettingsLayout.setVisibility(View.GONE);
|
proxySettingsLayout.setVisibility(View.GONE);
|
||||||
|
@ -113,9 +126,9 @@ public class SettingsFragment extends Fragment implements PasswordBottomSheetDia
|
||||||
|
|
||||||
torSwitch.setOnCheckedChangeListener((compoundButton, b) -> {
|
torSwitch.setOnCheckedChangeListener((compoundButton, b) -> {
|
||||||
PrefService.getInstance().edit().putBoolean(Constants.PREF_USES_TOR, b).apply();
|
PrefService.getInstance().edit().putBoolean(Constants.PREF_USES_TOR, b).apply();
|
||||||
if(b) {
|
if (b) {
|
||||||
String proxyString = PrefService.getInstance().getString(Constants.PREF_PROXY, "");
|
String proxyString = PrefService.getInstance().getString(Constants.PREF_PROXY, "");
|
||||||
if(proxyString.contains(":")) {
|
if (proxyString.contains(":")) {
|
||||||
removeProxyTextListeners();
|
removeProxyTextListeners();
|
||||||
|
|
||||||
String proxyAddress = proxyString.split(":")[0];
|
String proxyAddress = proxyString.split(":")[0];
|
||||||
|
@ -150,11 +163,11 @@ public class SettingsFragment extends Fragment implements PasswordBottomSheetDia
|
||||||
|
|
||||||
TextView statusTextView = view.findViewById(R.id.status_textview);
|
TextView statusTextView = view.findViewById(R.id.status_textview);
|
||||||
BlockchainService.getInstance().connectionStatus.observe(getViewLifecycleOwner(), connectionStatus -> {
|
BlockchainService.getInstance().connectionStatus.observe(getViewLifecycleOwner(), connectionStatus -> {
|
||||||
if(connectionStatus == Wallet.ConnectionStatus.ConnectionStatus_Connected) {
|
if (connectionStatus == Wallet.ConnectionStatus.ConnectionStatus_Connected) {
|
||||||
statusTextView.setText(getResources().getText(R.string.connected));
|
statusTextView.setText(getResources().getText(R.string.connected));
|
||||||
} else if(connectionStatus == Wallet.ConnectionStatus.ConnectionStatus_Disconnected) {
|
} else if (connectionStatus == Wallet.ConnectionStatus.ConnectionStatus_Disconnected) {
|
||||||
statusTextView.setText(getResources().getText(R.string.disconnected));
|
statusTextView.setText(getResources().getText(R.string.disconnected));
|
||||||
} else if(connectionStatus == Wallet.ConnectionStatus.ConnectionStatus_WrongVersion) {
|
} else if (connectionStatus == Wallet.ConnectionStatus.ConnectionStatus_WrongVersion) {
|
||||||
statusTextView.setText(getResources().getText(R.string.version_mismatch));
|
statusTextView.setText(getResources().getText(R.string.version_mismatch));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -186,7 +199,7 @@ public class SettingsFragment extends Fragment implements PasswordBottomSheetDia
|
||||||
|
|
||||||
private void initProxyStuff(String proxyAddress, String proxyPort) {
|
private void initProxyStuff(String proxyAddress, String proxyPort) {
|
||||||
boolean validIpAddress = Patterns.IP_ADDRESS.matcher(proxyAddress).matches();
|
boolean validIpAddress = Patterns.IP_ADDRESS.matcher(proxyAddress).matches();
|
||||||
if(validIpAddress) {
|
if (validIpAddress) {
|
||||||
mViewModel.setProxyAddress(proxyAddress);
|
mViewModel.setProxyAddress(proxyAddress);
|
||||||
mViewModel.setProxyPort(proxyPort);
|
mViewModel.setProxyPort(proxyPort);
|
||||||
walletProxyAddressEditText.setText(proxyAddress);
|
walletProxyAddressEditText.setText(proxyAddress);
|
||||||
|
|
|
@ -14,23 +14,24 @@ public class SettingsViewModel extends ViewModel {
|
||||||
|
|
||||||
private String proxyAddress = "";
|
private String proxyAddress = "";
|
||||||
private String proxyPort = "";
|
private String proxyPort = "";
|
||||||
|
|
||||||
public void updateProxy() {
|
public void updateProxy() {
|
||||||
AsyncTask.execute(() -> {
|
AsyncTask.execute(() -> {
|
||||||
boolean usesProxy = PrefService.getInstance().getBoolean(Constants.PREF_USES_TOR, false);
|
boolean usesProxy = PrefService.getInstance().getBoolean(Constants.PREF_USES_TOR, false);
|
||||||
String currentNodeString = PrefService.getInstance().getString(Constants.PREF_NODE, DefaultNodes.XMRTW.getAddress());
|
String currentNodeString = PrefService.getInstance().getString(Constants.PREF_NODE, DefaultNodes.XMRTW.getAddress());
|
||||||
boolean isNodeLocalIp = currentNodeString.startsWith("10.") || currentNodeString.startsWith("192.168.") || currentNodeString.equals("localhost") || currentNodeString.equals("127.0.0.1");
|
boolean isNodeLocalIp = currentNodeString.startsWith("10.") || currentNodeString.startsWith("192.168.") || currentNodeString.equals("localhost") || currentNodeString.equals("127.0.0.1");
|
||||||
|
|
||||||
if(!usesProxy || isNodeLocalIp) {
|
if (!usesProxy || isNodeLocalIp) {
|
||||||
WalletManager.getInstance().setProxy("");
|
WalletManager.getInstance().setProxy("");
|
||||||
WalletManager.getInstance().getWallet().setProxy("");
|
WalletManager.getInstance().getWallet().setProxy("");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(proxyAddress.isEmpty()) proxyAddress = "127.0.0.1";
|
if (proxyAddress.isEmpty()) proxyAddress = "127.0.0.1";
|
||||||
if(proxyPort.isEmpty()) proxyPort = "9050";
|
if (proxyPort.isEmpty()) proxyPort = "9050";
|
||||||
boolean validIpAddress = Patterns.IP_ADDRESS.matcher(proxyAddress).matches();
|
boolean validIpAddress = Patterns.IP_ADDRESS.matcher(proxyAddress).matches();
|
||||||
|
|
||||||
if(validIpAddress) {
|
if (validIpAddress) {
|
||||||
String proxy = proxyAddress + ":" + proxyPort;
|
String proxy = proxyAddress + ":" + proxyPort;
|
||||||
PrefService.getInstance().edit().putString(Constants.PREF_PROXY, proxy).apply();
|
PrefService.getInstance().edit().putString(Constants.PREF_PROXY, proxy).apply();
|
||||||
WalletManager.getInstance().setProxy(proxy);
|
WalletManager.getInstance().setProxy(proxy);
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class TransactionFragment extends Fragment {
|
||||||
|
|
||||||
mViewModel = new ViewModelProvider(this).get(TransactionViewModel.class);
|
mViewModel = new ViewModelProvider(this).get(TransactionViewModel.class);
|
||||||
Bundle args = getArguments();
|
Bundle args = getArguments();
|
||||||
if(args != null) {
|
if (args != null) {
|
||||||
TransactionInfo txInfo = getArguments().getParcelable(Constants.NAV_ARG_TXINFO);
|
TransactionInfo txInfo = getArguments().getParcelable(Constants.NAV_ARG_TXINFO);
|
||||||
mViewModel.init(txInfo);
|
mViewModel.init(txInfo);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ public class TransactionFragment extends Fragment {
|
||||||
ImageButton copyTxHashImageButton = view.findViewById(R.id.copy_txhash_imagebutton);
|
ImageButton copyTxHashImageButton = view.findViewById(R.id.copy_txhash_imagebutton);
|
||||||
copyTxHashImageButton.setOnClickListener(view1 -> {
|
copyTxHashImageButton.setOnClickListener(view1 -> {
|
||||||
TransactionInfo txInfo = mViewModel.transaction.getValue();
|
TransactionInfo txInfo = mViewModel.transaction.getValue();
|
||||||
if(txInfo != null) {
|
if (txInfo != null) {
|
||||||
Helper.clipBoardCopy(getContext(), "transaction_hash", txInfo.hash);
|
Helper.clipBoardCopy(getContext(), "transaction_hash", txInfo.hash);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -64,9 +64,9 @@ public class TransactionFragment extends Fragment {
|
||||||
ImageButton copyTxAddressImageButton = view.findViewById(R.id.copy_txaddress_imagebutton);
|
ImageButton copyTxAddressImageButton = view.findViewById(R.id.copy_txaddress_imagebutton);
|
||||||
copyTxAddressImageButton.setOnClickListener(view1 -> {
|
copyTxAddressImageButton.setOnClickListener(view1 -> {
|
||||||
TransactionInfo txInfo = mViewModel.transaction.getValue();
|
TransactionInfo txInfo = mViewModel.transaction.getValue();
|
||||||
if(txInfo != null) {
|
if (txInfo != null) {
|
||||||
String destination = mViewModel.destination.getValue();
|
String destination = mViewModel.destination.getValue();
|
||||||
if(destination != null) {
|
if (destination != null) {
|
||||||
Helper.clipBoardCopy(getContext(), "transaction_address", destination);
|
Helper.clipBoardCopy(getContext(), "transaction_address", destination);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,14 +83,14 @@ public class TransactionFragment extends Fragment {
|
||||||
|
|
||||||
mViewModel.transaction.observe(getViewLifecycleOwner(), transactionInfo -> {
|
mViewModel.transaction.observe(getViewLifecycleOwner(), transactionInfo -> {
|
||||||
txHashTextView.setText(transactionInfo.hash);
|
txHashTextView.setText(transactionInfo.hash);
|
||||||
txConfTextView.setText(""+transactionInfo.confirmations);
|
txConfTextView.setText("" + transactionInfo.confirmations);
|
||||||
txDateTextView.setText(getDateTime(transactionInfo.timestamp));
|
txDateTextView.setText(getDateTime(transactionInfo.timestamp));
|
||||||
txAmountTextView.setText(getResources().getString(R.string.tx_amount_no_prefix, Helper.getDisplayAmount(transactionInfo.amount)));
|
txAmountTextView.setText(getResources().getString(R.string.tx_amount_no_prefix, Helper.getDisplayAmount(transactionInfo.amount)));
|
||||||
});
|
});
|
||||||
|
|
||||||
mViewModel.destination.observe(getViewLifecycleOwner(), s -> {
|
mViewModel.destination.observe(getViewLifecycleOwner(), s -> {
|
||||||
txAddressTextView.setText(Objects.requireNonNullElse(s, "-"));
|
txAddressTextView.setText(Objects.requireNonNullElse(s, "-"));
|
||||||
if(s == null) {
|
if (s == null) {
|
||||||
copyTxAddressImageButton.setVisibility(View.INVISIBLE);
|
copyTxAddressImageButton.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,21 +10,21 @@ import net.mynero.wallet.model.WalletManager;
|
||||||
|
|
||||||
public class TransactionViewModel extends ViewModel {
|
public class TransactionViewModel extends ViewModel {
|
||||||
private final MutableLiveData<TransactionInfo> _transaction = new MutableLiveData<>(null);
|
private final MutableLiveData<TransactionInfo> _transaction = new MutableLiveData<>(null);
|
||||||
public LiveData<TransactionInfo> transaction = _transaction;
|
|
||||||
private final MutableLiveData<String> _destination = new MutableLiveData<>(null);
|
private final MutableLiveData<String> _destination = new MutableLiveData<>(null);
|
||||||
|
public LiveData<TransactionInfo> transaction = _transaction;
|
||||||
public LiveData<String> destination = _destination;
|
public LiveData<String> destination = _destination;
|
||||||
|
|
||||||
public void init(TransactionInfo info) {
|
public void init(TransactionInfo info) {
|
||||||
Wallet wallet = WalletManager.getInstance().getWallet();
|
Wallet wallet = WalletManager.getInstance().getWallet();
|
||||||
if(info.txKey == null) {
|
if (info.txKey == null) {
|
||||||
info.txKey = wallet.getTxKey(info.hash);
|
info.txKey = wallet.getTxKey(info.hash);
|
||||||
}
|
}
|
||||||
if(info.address == null && info.direction == TransactionInfo.Direction.Direction_In) {
|
if (info.address == null && info.direction == TransactionInfo.Direction.Direction_In) {
|
||||||
_destination.setValue(wallet.getSubaddress(info.accountIndex, info.addressIndex));
|
_destination.setValue(wallet.getSubaddress(info.accountIndex, info.addressIndex));
|
||||||
} else if(info.address != null && info.direction == TransactionInfo.Direction.Direction_In) {
|
} else if (info.address != null && info.direction == TransactionInfo.Direction.Direction_In) {
|
||||||
_destination.setValue(info.address);
|
_destination.setValue(info.address);
|
||||||
} else if(info.transfers != null && info.direction == TransactionInfo.Direction.Direction_Out) {
|
} else if (info.transfers != null && info.direction == TransactionInfo.Direction.Direction_Out) {
|
||||||
if(info.transfers.size() == 1) {
|
if (info.transfers.size() == 1) {
|
||||||
_destination.setValue(info.transfers.get(0).address);
|
_destination.setValue(info.transfers.get(0).address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import androidx.fragment.app.Fragment;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import net.mynero.wallet.R;
|
import net.mynero.wallet.R;
|
||||||
import net.mynero.wallet.adapter.CoinsInfoAdapter;
|
import net.mynero.wallet.adapter.CoinsInfoAdapter;
|
||||||
import net.mynero.wallet.fragment.dialog.SendBottomSheetDialog;
|
import net.mynero.wallet.fragment.dialog.SendBottomSheetDialog;
|
||||||
|
@ -24,8 +25,8 @@ import java.util.Collections;
|
||||||
public class UtxosFragment extends Fragment implements CoinsInfoAdapter.CoinsInfoAdapterListener {
|
public class UtxosFragment extends Fragment implements CoinsInfoAdapter.CoinsInfoAdapterListener {
|
||||||
|
|
||||||
private UtxosViewModel mViewModel;
|
private UtxosViewModel mViewModel;
|
||||||
private ArrayList<String> selectedUtxos = new ArrayList<>();
|
private final ArrayList<String> selectedUtxos = new ArrayList<>();
|
||||||
private CoinsInfoAdapter adapter = new CoinsInfoAdapter(this);
|
private final CoinsInfoAdapter adapter = new CoinsInfoAdapter(this);
|
||||||
private Button sendUtxosButton;
|
private Button sendUtxosButton;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -60,8 +61,8 @@ public class UtxosFragment extends Fragment implements CoinsInfoAdapter.CoinsInf
|
||||||
if (utxoService != null) {
|
if (utxoService != null) {
|
||||||
utxoService.utxos.observe(getViewLifecycleOwner(), utxos -> {
|
utxoService.utxos.observe(getViewLifecycleOwner(), utxos -> {
|
||||||
ArrayList<CoinsInfo> filteredUtxos = new ArrayList<>();
|
ArrayList<CoinsInfo> filteredUtxos = new ArrayList<>();
|
||||||
for(CoinsInfo coinsInfo : utxos) {
|
for (CoinsInfo coinsInfo : utxos) {
|
||||||
if(!coinsInfo.isSpent()) {
|
if (!coinsInfo.isSpent()) {
|
||||||
filteredUtxos.add(coinsInfo);
|
filteredUtxos.add(coinsInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,13 +80,13 @@ public class UtxosFragment extends Fragment implements CoinsInfoAdapter.CoinsInf
|
||||||
@Override
|
@Override
|
||||||
public void onUtxoSelected(CoinsInfo coinsInfo) {
|
public void onUtxoSelected(CoinsInfo coinsInfo) {
|
||||||
boolean selected = selectedUtxos.contains(coinsInfo.getKeyImage());
|
boolean selected = selectedUtxos.contains(coinsInfo.getKeyImage());
|
||||||
if(selected) {
|
if (selected) {
|
||||||
selectedUtxos.remove(coinsInfo.getKeyImage());
|
selectedUtxos.remove(coinsInfo.getKeyImage());
|
||||||
} else {
|
} else {
|
||||||
selectedUtxos.add(coinsInfo.getKeyImage());
|
selectedUtxos.add(coinsInfo.getKeyImage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(selectedUtxos.isEmpty()) {
|
if (selectedUtxos.isEmpty()) {
|
||||||
sendUtxosButton.setVisibility(View.GONE);
|
sendUtxosButton.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
sendUtxosButton.setVisibility(View.VISIBLE);
|
sendUtxosButton.setVisibility(View.VISIBLE);
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package net.mynero.wallet.model;
|
package net.mynero.wallet.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
|
@ -21,10 +21,19 @@ import android.os.Parcelable;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
public class CoinsInfo implements Parcelable, Comparable<CoinsInfo> {
|
||||||
import java.util.List;
|
public static final Creator<CoinsInfo> CREATOR = new Creator<CoinsInfo>() {
|
||||||
|
@Override
|
||||||
|
public CoinsInfo createFromParcel(Parcel in) {
|
||||||
|
return new CoinsInfo(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CoinsInfo[] newArray(int size) {
|
||||||
|
return new CoinsInfo[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public class CoinsInfo implements Parcelable, Comparable<CoinsInfo> {
|
|
||||||
static {
|
static {
|
||||||
System.loadLibrary("monerujo");
|
System.loadLibrary("monerujo");
|
||||||
}
|
}
|
||||||
|
@ -53,18 +62,6 @@ public class CoinsInfo implements Parcelable, Comparable<CoinsInfo> {
|
||||||
globalOutputIndex = in.readLong();
|
globalOutputIndex = in.readLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<CoinsInfo> CREATOR = new Creator<CoinsInfo>() {
|
|
||||||
@Override
|
|
||||||
public CoinsInfo createFromParcel(Parcel in) {
|
|
||||||
return new CoinsInfo(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CoinsInfo[] newArray(int size) {
|
|
||||||
return new CoinsInfo[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public long getGlobalOutputIndex() {
|
public long getGlobalOutputIndex() {
|
||||||
return globalOutputIndex;
|
return globalOutputIndex;
|
||||||
}
|
}
|
||||||
|
|
|
@ -341,6 +341,7 @@ public class Wallet {
|
||||||
}
|
}
|
||||||
return coins;
|
return coins;
|
||||||
}
|
}
|
||||||
|
|
||||||
private native long getCoinsJ();
|
private native long getCoinsJ();
|
||||||
|
|
||||||
//virtual bool exportKeyImages(const std::string &filename) = 0;
|
//virtual bool exportKeyImages(const std::string &filename) = 0;
|
||||||
|
@ -354,7 +355,7 @@ public class Wallet {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshCoins() {
|
public void refreshCoins() {
|
||||||
if(this.isSynchronized()) {
|
if (this.isSynchronized()) {
|
||||||
getCoins().refresh();
|
getCoins().refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -486,6 +487,7 @@ public class Wallet {
|
||||||
final private String errorString;
|
final private String errorString;
|
||||||
@Nullable
|
@Nullable
|
||||||
private ConnectionStatus connectionStatus; // optional
|
private ConnectionStatus connectionStatus; // optional
|
||||||
|
|
||||||
Status(int status, String errorString) {
|
Status(int status, String errorString) {
|
||||||
this.status = StatusEnum.values()[status];
|
this.status = StatusEnum.values()[status];
|
||||||
this.errorString = errorString;
|
this.errorString = errorString;
|
||||||
|
|
|
@ -6,7 +6,6 @@ import net.mynero.wallet.model.Wallet;
|
||||||
import net.mynero.wallet.model.WalletManager;
|
import net.mynero.wallet.model.WalletManager;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class AddressService extends ServiceBase {
|
public class AddressService extends ServiceBase {
|
||||||
|
|
|
@ -11,6 +11,7 @@ public class BalanceService extends ServiceBase {
|
||||||
private final MutableLiveData<Long> _lockedBalance = new MutableLiveData<>(0L);
|
private final MutableLiveData<Long> _lockedBalance = new MutableLiveData<>(0L);
|
||||||
public LiveData<Long> balance = _balance;
|
public LiveData<Long> balance = _balance;
|
||||||
public LiveData<Long> lockedBalance = _lockedBalance;
|
public LiveData<Long> lockedBalance = _lockedBalance;
|
||||||
|
|
||||||
public BalanceService(MoneroHandlerThread thread) {
|
public BalanceService(MoneroHandlerThread thread) {
|
||||||
super(thread);
|
super(thread);
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
|
@ -9,11 +9,12 @@ import net.mynero.wallet.model.WalletManager;
|
||||||
public class BlockchainService extends ServiceBase {
|
public class BlockchainService extends ServiceBase {
|
||||||
public static BlockchainService instance = null;
|
public static BlockchainService instance = null;
|
||||||
private final MutableLiveData<Long> _currentHeight = new MutableLiveData<>(0L);
|
private final MutableLiveData<Long> _currentHeight = new MutableLiveData<>(0L);
|
||||||
public LiveData<Long> height = _currentHeight;
|
|
||||||
private final MutableLiveData<Wallet.ConnectionStatus> _connectionStatus = new MutableLiveData<>(Wallet.ConnectionStatus.ConnectionStatus_Disconnected);
|
private final MutableLiveData<Wallet.ConnectionStatus> _connectionStatus = new MutableLiveData<>(Wallet.ConnectionStatus.ConnectionStatus_Disconnected);
|
||||||
|
public LiveData<Long> height = _currentHeight;
|
||||||
public LiveData<Wallet.ConnectionStatus> connectionStatus = _connectionStatus;
|
public LiveData<Wallet.ConnectionStatus> connectionStatus = _connectionStatus;
|
||||||
private long daemonHeight = 0;
|
private long daemonHeight = 0;
|
||||||
private long lastDaemonHeightUpdateTimeMs = 0;
|
private long lastDaemonHeightUpdateTimeMs = 0;
|
||||||
|
|
||||||
public BlockchainService(MoneroHandlerThread thread) {
|
public BlockchainService(MoneroHandlerThread thread) {
|
||||||
super(thread);
|
super(thread);
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
|
@ -12,6 +12,7 @@ public class HistoryService extends ServiceBase {
|
||||||
public static HistoryService instance = null;
|
public static HistoryService instance = null;
|
||||||
private final MutableLiveData<List<TransactionInfo>> _history = new MutableLiveData<>();
|
private final MutableLiveData<List<TransactionInfo>> _history = new MutableLiveData<>();
|
||||||
public LiveData<List<TransactionInfo>> history = _history;
|
public LiveData<List<TransactionInfo>> history = _history;
|
||||||
|
|
||||||
public HistoryService(MoneroHandlerThread thread) {
|
public HistoryService(MoneroHandlerThread thread) {
|
||||||
super(thread);
|
super(thread);
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
|
@ -28,7 +28,6 @@ import net.mynero.wallet.model.WalletManager;
|
||||||
import net.mynero.wallet.util.Constants;
|
import net.mynero.wallet.util.Constants;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,9 +38,9 @@ import java.util.List;
|
||||||
public class MoneroHandlerThread extends Thread implements WalletListener {
|
public class MoneroHandlerThread extends Thread implements WalletListener {
|
||||||
// from src/cryptonote_config.h
|
// from src/cryptonote_config.h
|
||||||
static public final long THREAD_STACK_SIZE = 5 * 1024 * 1024;
|
static public final long THREAD_STACK_SIZE = 5 * 1024 * 1024;
|
||||||
|
private final Wallet wallet;
|
||||||
int triesLeft = 5;
|
int triesLeft = 5;
|
||||||
private Listener listener = null;
|
private Listener listener = null;
|
||||||
private final Wallet wallet;
|
|
||||||
|
|
||||||
public MoneroHandlerThread(String name, Listener listener, Wallet wallet) {
|
public MoneroHandlerThread(String name, Listener listener, Wallet wallet) {
|
||||||
super(null, null, name, THREAD_STACK_SIZE);
|
super(null, null, name, THREAD_STACK_SIZE);
|
||||||
|
@ -117,7 +116,7 @@ public class MoneroHandlerThread extends Thread implements WalletListener {
|
||||||
|
|
||||||
private void refresh(boolean refreshCoins) {
|
private void refresh(boolean refreshCoins) {
|
||||||
wallet.refreshHistory();
|
wallet.refreshHistory();
|
||||||
if(refreshCoins) {
|
if (refreshCoins) {
|
||||||
wallet.refreshCoins();
|
wallet.refreshCoins();
|
||||||
}
|
}
|
||||||
listener.onRefresh();
|
listener.onRefresh();
|
||||||
|
@ -126,7 +125,7 @@ public class MoneroHandlerThread extends Thread implements WalletListener {
|
||||||
public PendingTransaction createTx(String address, String amountStr, boolean sendAll, PendingTransaction.Priority feePriority, ArrayList<String> selectedUtxos) throws Exception {
|
public PendingTransaction createTx(String address, String amountStr, boolean sendAll, PendingTransaction.Priority feePriority, ArrayList<String> selectedUtxos) throws Exception {
|
||||||
long amount = sendAll ? Wallet.SWEEP_ALL : Wallet.getAmountFromString(amountStr);
|
long amount = sendAll ? Wallet.SWEEP_ALL : Wallet.getAmountFromString(amountStr);
|
||||||
ArrayList<String> preferredInputs;
|
ArrayList<String> preferredInputs;
|
||||||
if(selectedUtxos.isEmpty()) {
|
if (selectedUtxos.isEmpty()) {
|
||||||
// no inputs manually selected, we are sending from home screen most likely, or user somehow broke the app
|
// no inputs manually selected, we are sending from home screen most likely, or user somehow broke the app
|
||||||
preferredInputs = UTXOService.getInstance().selectUtxos(amount, sendAll);
|
preferredInputs = UTXOService.getInstance().selectUtxos(amount, sendAll);
|
||||||
} else {
|
} else {
|
||||||
|
@ -137,15 +136,15 @@ public class MoneroHandlerThread extends Thread implements WalletListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkSelectedAmounts(ArrayList<String> selectedUtxos, long amount, boolean sendAll) throws Exception {
|
private void checkSelectedAmounts(ArrayList<String> selectedUtxos, long amount, boolean sendAll) throws Exception {
|
||||||
if(!sendAll) {
|
if (!sendAll) {
|
||||||
long amountSelected = 0;
|
long amountSelected = 0;
|
||||||
for(CoinsInfo coinsInfo : UTXOService.getInstance().getUtxos()) {
|
for (CoinsInfo coinsInfo : UTXOService.getInstance().getUtxos()) {
|
||||||
if(selectedUtxos.contains(coinsInfo.getKeyImage())) {
|
if (selectedUtxos.contains(coinsInfo.getKeyImage())) {
|
||||||
amountSelected += coinsInfo.getAmount();
|
amountSelected += coinsInfo.getAmount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(amountSelected <= amount) {
|
if (amountSelected <= amount) {
|
||||||
throw new Exception("insufficient wallet balance");
|
throw new Exception("insufficient wallet balance");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
import net.mynero.wallet.model.CoinsInfo;
|
import net.mynero.wallet.model.CoinsInfo;
|
||||||
import net.mynero.wallet.model.PendingTransaction;
|
import net.mynero.wallet.model.PendingTransaction;
|
||||||
import net.mynero.wallet.model.TransactionInfo;
|
|
||||||
import net.mynero.wallet.model.Wallet;
|
import net.mynero.wallet.model.Wallet;
|
||||||
import net.mynero.wallet.model.WalletManager;
|
import net.mynero.wallet.model.WalletManager;
|
||||||
|
|
||||||
|
@ -19,6 +18,7 @@ public class UTXOService extends ServiceBase {
|
||||||
public static UTXOService instance = null;
|
public static UTXOService instance = null;
|
||||||
private final MutableLiveData<List<CoinsInfo>> _utxos = new MutableLiveData<>();
|
private final MutableLiveData<List<CoinsInfo>> _utxos = new MutableLiveData<>();
|
||||||
public LiveData<List<CoinsInfo>> utxos = _utxos;
|
public LiveData<List<CoinsInfo>> utxos = _utxos;
|
||||||
|
|
||||||
public UTXOService(MoneroHandlerThread thread) {
|
public UTXOService(MoneroHandlerThread thread) {
|
||||||
super(thread);
|
super(thread);
|
||||||
instance = this;
|
instance = this;
|
||||||
|
@ -46,7 +46,7 @@ public class UTXOService extends ServiceBase {
|
||||||
Collections.sort(utxos);
|
Collections.sort(utxos);
|
||||||
//loop through each utxo
|
//loop through each utxo
|
||||||
for (CoinsInfo coinsInfo : utxos) {
|
for (CoinsInfo coinsInfo : utxos) {
|
||||||
if(!coinsInfo.isSpent() && coinsInfo.isUnlocked()) { //filter out spent and locked outputs
|
if (!coinsInfo.isSpent() && coinsInfo.isUnlocked()) { //filter out spent and locked outputs
|
||||||
if (sendAll) {
|
if (sendAll) {
|
||||||
// if send all, add all utxos and set amount to send all
|
// if send all, add all utxos and set amount to send all
|
||||||
selectedUtxos.add(coinsInfo.getKeyImage());
|
selectedUtxos.add(coinsInfo.getKeyImage());
|
||||||
|
|
|
@ -13,32 +13,12 @@ public class UriData {
|
||||||
this.params = params;
|
this.params = params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, String> getParams() {
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAddress() {
|
|
||||||
return address;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAmount() {
|
|
||||||
String txAmount = params.get(Constants.URI_ARG_AMOUNT);
|
|
||||||
if(txAmount == null) {
|
|
||||||
return params.get(Constants.URI_ARG_AMOUNT2);
|
|
||||||
}
|
|
||||||
return txAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasAmount() {
|
|
||||||
return params.containsKey(Constants.URI_ARG_AMOUNT) || params.containsKey(Constants.URI_ARG_AMOUNT2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static UriData parse(String uri) {
|
public static UriData parse(String uri) {
|
||||||
HashMap<String, String> params = new HashMap<>();
|
HashMap<String, String> params = new HashMap<>();
|
||||||
String[] uriParts = uri.replace(Constants.URI_PREFIX, "").split("\\?");
|
String[] uriParts = uri.replace(Constants.URI_PREFIX, "").split("\\?");
|
||||||
String finalAddress = uriParts[0];
|
String finalAddress = uriParts[0];
|
||||||
String queryParams = "";
|
String queryParams = "";
|
||||||
if(uriParts.length > 1) {
|
if (uriParts.length > 1) {
|
||||||
queryParams = uriParts[1];
|
queryParams = uriParts[1];
|
||||||
String[] queryParts = queryParams.split("&");
|
String[] queryParts = queryParams.split("&");
|
||||||
for (String param : queryParts) {
|
for (String param : queryParts) {
|
||||||
|
@ -49,10 +29,30 @@ public class UriData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean valid = Wallet.isAddressValid(finalAddress);
|
boolean valid = Wallet.isAddressValid(finalAddress);
|
||||||
if(valid) {
|
if (valid) {
|
||||||
return new UriData(finalAddress, params);
|
return new UriData(finalAddress, params);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HashMap<String, String> getParams() {
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAmount() {
|
||||||
|
String txAmount = params.get(Constants.URI_ARG_AMOUNT);
|
||||||
|
if (txAmount == null) {
|
||||||
|
return params.get(Constants.URI_ARG_AMOUNT2);
|
||||||
|
}
|
||||||
|
return txAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasAmount() {
|
||||||
|
return params.containsKey(Constants.URI_ARG_AMOUNT) || params.containsKey(Constants.URI_ARG_AMOUNT2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue