mirror of
https://codeberg.org/r4v3r23/mysu.git
synced 2024-11-25 23:32:30 +00:00
Cleanup/reformat code
This commit is contained in:
parent
68dfd3797c
commit
83c26a0ea3
44 changed files with 338 additions and 215 deletions
|
@ -1,7 +1,6 @@
|
|||
package net.mynero.wallet
|
||||
|
||||
import android.os.Bundle
|
||||
import android.os.PersistableBundle
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
|
|
|
@ -33,6 +33,7 @@ class CoinsInfoAdapter(val listener: CoinsInfoAdapterListener?) :
|
|||
RecyclerView.Adapter<CoinsInfoAdapter.ViewHolder>() {
|
||||
private var localDataSet // <public-key, coinsinfo>
|
||||
: List<CoinsInfo>
|
||||
|
||||
@JvmField
|
||||
val selectedUtxos // <public-key, coinsinfo>
|
||||
: HashMap<String?, CoinsInfo>
|
||||
|
|
|
@ -71,7 +71,8 @@ class SubaddressAdapter(val listener: SubaddressAdapterListener?) :
|
|||
* Provide a reference to the type of views that you are using
|
||||
* (custom ViewHolder).
|
||||
*/
|
||||
class ViewHolder(view: View, val listener: SubaddressAdapterListener?) : RecyclerView.ViewHolder(
|
||||
class ViewHolder(view: View, val listener: SubaddressAdapterListener?) :
|
||||
RecyclerView.ViewHolder(
|
||||
view
|
||||
) {
|
||||
|
||||
|
|
|
@ -75,7 +75,8 @@ class TransactionInfoAdapter(val listener: TxInfoAdapterListener?) :
|
|||
* Provide a reference to the type of views that you are using
|
||||
* (custom ViewHolder).
|
||||
*/
|
||||
class ViewHolder(val listener: TxInfoAdapterListener?, view: View) : RecyclerView.ViewHolder(view) {
|
||||
class ViewHolder(val listener: TxInfoAdapterListener?, view: View) :
|
||||
RecyclerView.ViewHolder(view) {
|
||||
private val outboundColour: Int
|
||||
private val inboundColour: Int
|
||||
private val pendingColour: Int
|
||||
|
|
|
@ -19,8 +19,84 @@ import org.json.JSONException
|
|||
import org.json.JSONObject
|
||||
|
||||
// Nodes stolen from https://moneroworld.com/#nodes
|
||||
enum class DefaultNodes(val address: String, private val port: Int, private val network: String, private val nodeName: String) {
|
||||
SAMOURAI("163.172.56.213", 18089, "mainnet", "SamouraiWallet"), MONERUJO("nodex.monerujo.io", 18081, "mainnet", "monerujo"), SUPPORTXMR("node.supportxmr.com", 18081, "mainnet", "SupportXMR"), HASHVAULT("nodes.hashvault.pro", 18081, "mainnet", "Hashvault"), MONEROWORLD("node.moneroworld.com", 18089, "mainnet", "MoneroWorld"), XMRTW("opennode.xmr-tw.org", 18089, "mainnet", "XMRTW"), MYNERO_I2P("ynk3hrwte23asonojqeskoulek2g2cd6tqg4neghnenfyljrvhga.b32.i2p", 0, "mainnet", "node.mysu.i2p"), MYNERO_ONION("tiopyrxseconw73thwlv2pf5hebfcqxj5zdolym7z6pbq6gl4z7xz4ad.onion", 18081, "mainnet", "node.mysu.onion"), SAMOURAI_ONION("446unwib5vc7pfbzflosy6m6vtyuhddnalr3hutyavwe4esfuu5g6ryd.onion", 18089, "mainnet", "SamouraiWallet.onion"), MONERUJO_ONION("monerujods7mbghwe6cobdr6ujih6c22zu5rl7zshmizz2udf7v7fsad.onion", 18081, "mainnet", "monerujo.onion"), Criminales78("56wl7y2ebhamkkiza4b7il4mrzwtyvpdym7bm2bkg3jrei2je646k3qd.onion", 18089, "mainnet", "Criminales78.onion"), xmrfail("mxcd4577fldb3ppzy7obmmhnu3tf57gbcbd4qhwr2kxyjj2qi3dnbfqd.onion", 18081, "mainnet", "xmrfail.onion"), boldsuck("6dsdenp6vjkvqzy4wzsnzn6wixkdzihx3khiumyzieauxuxslmcaeiad.onion", 18081, "mainnet", "boldsuck.onion");
|
||||
enum class DefaultNodes(
|
||||
val address: String,
|
||||
private val port: Int,
|
||||
private val network: String,
|
||||
private val nodeName: String
|
||||
) {
|
||||
SAMOURAI("163.172.56.213", 18089, "mainnet", "SamouraiWallet"), MONERUJO(
|
||||
"nodex.monerujo.io",
|
||||
18081,
|
||||
"mainnet",
|
||||
"monerujo"
|
||||
),
|
||||
SUPPORTXMR(
|
||||
"node.supportxmr.com",
|
||||
18081,
|
||||
"mainnet",
|
||||
"SupportXMR"
|
||||
),
|
||||
HASHVAULT(
|
||||
"nodes.hashvault.pro",
|
||||
18081,
|
||||
"mainnet",
|
||||
"Hashvault"
|
||||
),
|
||||
MONEROWORLD(
|
||||
"node.moneroworld.com",
|
||||
18089,
|
||||
"mainnet",
|
||||
"MoneroWorld"
|
||||
),
|
||||
XMRTW(
|
||||
"opennode.xmr-tw.org",
|
||||
18089,
|
||||
"mainnet",
|
||||
"XMRTW"
|
||||
),
|
||||
MYNERO_I2P(
|
||||
"ynk3hrwte23asonojqeskoulek2g2cd6tqg4neghnenfyljrvhga.b32.i2p",
|
||||
0,
|
||||
"mainnet",
|
||||
"node.mysu.i2p"
|
||||
),
|
||||
MYNERO_ONION(
|
||||
"tiopyrxseconw73thwlv2pf5hebfcqxj5zdolym7z6pbq6gl4z7xz4ad.onion",
|
||||
18081,
|
||||
"mainnet",
|
||||
"node.mysu.onion"
|
||||
),
|
||||
SAMOURAI_ONION(
|
||||
"446unwib5vc7pfbzflosy6m6vtyuhddnalr3hutyavwe4esfuu5g6ryd.onion",
|
||||
18089,
|
||||
"mainnet",
|
||||
"SamouraiWallet.onion"
|
||||
),
|
||||
MONERUJO_ONION(
|
||||
"monerujods7mbghwe6cobdr6ujih6c22zu5rl7zshmizz2udf7v7fsad.onion",
|
||||
18081,
|
||||
"mainnet",
|
||||
"monerujo.onion"
|
||||
),
|
||||
Criminales78(
|
||||
"56wl7y2ebhamkkiza4b7il4mrzwtyvpdym7bm2bkg3jrei2je646k3qd.onion",
|
||||
18089,
|
||||
"mainnet",
|
||||
"Criminales78.onion"
|
||||
),
|
||||
xmrfail(
|
||||
"mxcd4577fldb3ppzy7obmmhnu3tf57gbcbd4qhwr2kxyjj2qi3dnbfqd.onion",
|
||||
18081,
|
||||
"mainnet",
|
||||
"xmrfail.onion"
|
||||
),
|
||||
boldsuck(
|
||||
"6dsdenp6vjkvqzy4wzsnzn6wixkdzihx3khiumyzieauxuxslmcaeiad.onion",
|
||||
18081,
|
||||
"mainnet",
|
||||
"boldsuck.onion"
|
||||
);
|
||||
|
||||
val nodeString: String
|
||||
get() = "$address:$port/$network/$nodeName"
|
||||
|
|
|
@ -51,8 +51,10 @@ class Node {
|
|||
this.username = ""
|
||||
this.password = ""
|
||||
}
|
||||
|
||||
2 -> { // credentials
|
||||
val userPassword = a[0].split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
val userPassword =
|
||||
a[0].split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
require(userPassword.size == 2) { "User:Password invalid" }
|
||||
this.username = userPassword[0]
|
||||
this.password = if (this.username.isNotEmpty()) {
|
||||
|
@ -62,11 +64,13 @@ class Node {
|
|||
}
|
||||
daemonAddress = a[1]
|
||||
}
|
||||
|
||||
else -> {
|
||||
throw IllegalArgumentException("Too many @")
|
||||
}
|
||||
}
|
||||
val daParts = daemonAddress.split("/".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
val daParts =
|
||||
daemonAddress.split("/".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
require(!(daParts.size > 3 || daParts.isEmpty())) { "Too many '/' or too few" }
|
||||
daemonAddress = daParts[0]
|
||||
val da = daemonAddress.split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
|
@ -240,6 +244,7 @@ class Node {
|
|||
const val TESTNET = "testnet"
|
||||
private var DEFAULT_LEVIN_PORT = 0
|
||||
private var DEFAULT_RPC_PORT = 0
|
||||
|
||||
@JvmStatic
|
||||
fun fromString(nodeString: String?): Node? {
|
||||
return try {
|
||||
|
|
|
@ -17,7 +17,12 @@ package net.mynero.wallet.data
|
|||
|
||||
import java.util.regex.Pattern
|
||||
|
||||
class Subaddress(private val accountIndex: Int, @JvmField val addressIndex: Int, @JvmField val address: String, val label: String) : Comparable<Subaddress> {
|
||||
class Subaddress(
|
||||
private val accountIndex: Int,
|
||||
@JvmField val addressIndex: Int,
|
||||
@JvmField val address: String,
|
||||
val label: String
|
||||
) : Comparable<Subaddress> {
|
||||
@JvmField
|
||||
var amount: Long = 0
|
||||
|
||||
|
@ -29,10 +34,13 @@ class Subaddress(private val accountIndex: Int, @JvmField val addressIndex: Int,
|
|||
val squashedAddress: String
|
||||
get() = address.substring(0, 8) + "…" + address.substring(address.length - 8)
|
||||
val displayLabel: String
|
||||
get() = if (label.isEmpty() || DEFAULT_LABEL_FORMATTER.matcher(label).matches()) "#$addressIndex" else label
|
||||
get() = if (label.isEmpty() || DEFAULT_LABEL_FORMATTER.matcher(label)
|
||||
.matches()
|
||||
) "#$addressIndex" else label
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val DEFAULT_LABEL_FORMATTER: Pattern = Pattern.compile("^[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{2}:[0-9]{2}:[0-9]{2}$")
|
||||
val DEFAULT_LABEL_FORMATTER: Pattern =
|
||||
Pattern.compile("^[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{2}:[0-9]{2}:[0-9]{2}$")
|
||||
}
|
||||
}
|
|
@ -41,11 +41,13 @@ class TxData : Parcelable {
|
|||
preferredInputs = txData.preferredInputs
|
||||
}
|
||||
|
||||
constructor(dstAddr: String?,
|
||||
constructor(
|
||||
dstAddr: String?,
|
||||
amount: Long,
|
||||
mixin: Int,
|
||||
priority: PendingTransaction.Priority?,
|
||||
preferredInputs: ArrayList<String>?) {
|
||||
preferredInputs: ArrayList<String>?
|
||||
) {
|
||||
destinationAddress = dstAddr
|
||||
this.amount = amount
|
||||
this.mixin = mixin
|
||||
|
|
|
@ -19,15 +19,20 @@ import java.util.regex.Pattern
|
|||
|
||||
class UserNotes(txNotes: String?) {
|
||||
var txNotes: String? = ""
|
||||
|
||||
@JvmField
|
||||
var note: String? = ""
|
||||
|
||||
@JvmField
|
||||
var xmrtoTag: String? = null
|
||||
|
||||
@JvmField
|
||||
var xmrtoKey: String? = null
|
||||
|
||||
@JvmField
|
||||
var xmrtoAmount: String? = null // could be a double - but we are not doing any calculations
|
||||
var xmrtoCurrency: String? = null
|
||||
|
||||
@JvmField
|
||||
var xmrtoDestination: String? = null
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.content.Context;
|
|||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Patterns;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -48,8 +47,14 @@ public class AddNodeBottomSheetDialog extends BottomSheetDialogFragment {
|
|||
ImageButton pastePasswordImageButton = view.findViewById(R.id.paste_password_imagebutton);
|
||||
|
||||
usernameEditText.addTextChangedListener(new TextWatcher() {
|
||||
@Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
||||
@Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
if (editable.toString().isEmpty()) {
|
||||
|
|
|
@ -19,10 +19,8 @@ import net.mynero.wallet.model.WalletManager;
|
|||
import net.mynero.wallet.service.AddressService;
|
||||
import net.mynero.wallet.util.Helper;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
public class EditAddressLabelBottomSheetDialog extends BottomSheetDialogFragment {
|
||||
|
@ -47,7 +45,8 @@ public class EditAddressLabelBottomSheetDialog extends BottomSheetDialogFragment
|
|||
try {
|
||||
new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss", Locale.US).parse(wallet.getSubaddressLabel(addressIndex));
|
||||
isDate = true;
|
||||
} catch (ParseException ignored) { }
|
||||
} catch (ParseException ignored) {
|
||||
}
|
||||
|
||||
labelEditText.setText(isDate ? null : wallet.getSubaddressLabel(addressIndex));
|
||||
pasteButton.setOnClickListener(view1 -> labelEditText.setText(Helper.getClipBoardText(view.getContext())));
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.content.Context;
|
|||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Patterns;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -20,19 +19,11 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
|||
|
||||
import net.mynero.wallet.R;
|
||||
import net.mynero.wallet.data.Node;
|
||||
import net.mynero.wallet.service.PrefService;
|
||||
import net.mynero.wallet.util.Constants;
|
||||
import net.mynero.wallet.util.Helper;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
public class EditNodeBottomSheetDialog extends BottomSheetDialogFragment {
|
||||
public EditNodeListener listener = null;
|
||||
public Node node = null;
|
||||
|
@ -66,8 +57,14 @@ public class EditNodeBottomSheetDialog extends BottomSheetDialogFragment {
|
|||
}
|
||||
|
||||
usernameEditText.addTextChangedListener(new TextWatcher() {
|
||||
@Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
||||
@Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
if (editable.toString().isEmpty()) {
|
||||
|
@ -141,6 +138,7 @@ public class EditNodeBottomSheetDialog extends BottomSheetDialogFragment {
|
|||
|
||||
public interface EditNodeListener {
|
||||
void onNodeDeleted(Node node);
|
||||
|
||||
void onNodeEdited(Node oldNode, Node newNode);
|
||||
}
|
||||
}
|
|
@ -60,7 +60,9 @@ public class NodeSelectionBottomSheetDialog extends BottomSheetDialogFragment im
|
|||
JSONArray jsonArray = null;
|
||||
try {
|
||||
jsonArray = new JSONArray(nodesArray);
|
||||
} catch (JSONException e) { throw new RuntimeException(e); }
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject nodeJsonObject = null;
|
||||
|
@ -122,7 +124,9 @@ public class NodeSelectionBottomSheetDialog extends BottomSheetDialogFragment im
|
|||
|
||||
public interface NodeSelectionDialogListener {
|
||||
void onNodeSelected();
|
||||
|
||||
void onClickedEditNode(Node node);
|
||||
|
||||
void onClickedAddNode();
|
||||
}
|
||||
}
|
|
@ -46,7 +46,7 @@ public class SendBottomSheetDialog extends BottomSheetDialogFragment {
|
|||
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<PendingTransaction> pendingTransaction = _pendingTransaction; private final ActivityResultLauncher<String> cameraPermissionsLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(),
|
||||
granted -> {
|
||||
if (granted) {
|
||||
onScan();
|
||||
|
@ -54,7 +54,6 @@ public class SendBottomSheetDialog extends BottomSheetDialogFragment {
|
|||
Toast.makeText(getActivity(), getString(R.string.no_camera_permission), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
public LiveData<PendingTransaction> pendingTransaction = _pendingTransaction;
|
||||
public UriData uriData = null;
|
||||
public boolean isChurning = false;
|
||||
public Listener listener = null;
|
||||
|
@ -350,4 +349,6 @@ public class SendBottomSheetDialog extends BottomSheetDialogFragment {
|
|||
public interface Listener {
|
||||
void onSentTransaction();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -11,7 +11,6 @@ import android.widget.TextView;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
@ -24,7 +23,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
import net.mynero.wallet.MainActivity;
|
||||
import net.mynero.wallet.R;
|
||||
import net.mynero.wallet.adapter.TransactionInfoAdapter;
|
||||
import net.mynero.wallet.fragment.dialog.SendBottomSheetDialog;
|
||||
import net.mynero.wallet.model.TransactionInfo;
|
||||
import net.mynero.wallet.model.Wallet;
|
||||
import net.mynero.wallet.model.WalletManager;
|
||||
|
|
|
@ -151,7 +151,11 @@ public class OnboardingFragment extends Fragment implements NodeSelectionBottomS
|
|||
private void bindListeners() {
|
||||
seedOffsetCheckbox.setChecked(useOffset);
|
||||
// Disable onBack click
|
||||
OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(true) { @Override public void handleOnBackPressed() { } };
|
||||
OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
}
|
||||
};
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), onBackPressedCallback);
|
||||
|
@ -303,7 +307,8 @@ public class OnboardingFragment extends Fragment implements NodeSelectionBottomS
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onClickedEditNode(Node node) { }
|
||||
public void onClickedEditNode(Node node) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickedAddNode() {
|
||||
|
|
|
@ -22,10 +22,10 @@ import java.util.Calendar;
|
|||
|
||||
public class OnboardingViewModel extends ViewModel {
|
||||
private final MutableLiveData<Boolean> _showMoreOptions = new MutableLiveData<>(false);
|
||||
public LiveData<Boolean> showMoreOptions = _showMoreOptions;
|
||||
private final MutableLiveData<Boolean> _enableCreateButton = new MutableLiveData<>(true);
|
||||
public LiveData<Boolean> enableCreateButton = _enableCreateButton;
|
||||
private final MutableLiveData<SeedType> _seedType = new MutableLiveData<>(SeedType.POLYSEED);
|
||||
public LiveData<Boolean> showMoreOptions = _showMoreOptions;
|
||||
public LiveData<Boolean> enableCreateButton = _enableCreateButton;
|
||||
public LiveData<SeedType> seedType = _seedType;
|
||||
private String proxyAddress = "";
|
||||
private String proxyPort = "";
|
||||
|
@ -166,7 +166,7 @@ public class OnboardingViewModel extends ViewModel {
|
|||
POLYSEED(R.string.seed_desc_polyseed),
|
||||
UNKNOWN(0);
|
||||
|
||||
private int descResId;
|
||||
private final int descResId;
|
||||
|
||||
SeedType(int descResId) {
|
||||
this.descResId = descResId;
|
||||
|
|
|
@ -27,9 +27,7 @@ import net.mynero.wallet.R;
|
|||
import net.mynero.wallet.adapter.SubaddressAdapter;
|
||||
import net.mynero.wallet.data.Subaddress;
|
||||
import net.mynero.wallet.fragment.dialog.EditAddressLabelBottomSheetDialog;
|
||||
import net.mynero.wallet.util.DayNightMode;
|
||||
import net.mynero.wallet.util.Helper;
|
||||
import net.mynero.wallet.util.NightmodeHelper;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
|
|
|
@ -15,8 +15,8 @@ import java.util.List;
|
|||
|
||||
public class ReceiveViewModel extends ViewModel {
|
||||
private final MutableLiveData<Subaddress> _address = new MutableLiveData<>();
|
||||
public LiveData<Subaddress> address = _address;
|
||||
private final MutableLiveData<List<Subaddress>> _addresses = new MutableLiveData<>();
|
||||
public LiveData<Subaddress> address = _address;
|
||||
public LiveData<List<Subaddress>> addresses = _addresses;
|
||||
|
||||
public void init() {
|
||||
|
|
|
@ -2,7 +2,6 @@ package net.mynero.wallet.fragment.send;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
|
@ -25,8 +24,6 @@ import androidx.constraintlayout.widget.ConstraintLayout;
|
|||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.zxing.client.android.Intents;
|
||||
import com.journeyapps.barcodescanner.ScanContract;
|
||||
|
@ -48,6 +45,7 @@ import java.util.List;
|
|||
import kotlin.Pair;
|
||||
|
||||
public class SendFragment extends Fragment {
|
||||
public PendingTransaction.Priority priority;
|
||||
private SendViewModel mViewModel;
|
||||
private Button sendMaxButton;
|
||||
private ImageButton addOutputImageView;
|
||||
|
@ -57,12 +55,9 @@ public class SendFragment extends Fragment {
|
|||
private SlideToActView sendTxSlider;
|
||||
private RadioGroup feeRadioGroup;
|
||||
private TextView feeRadioGroupLabelTextView;
|
||||
|
||||
private TextView feeTextView;
|
||||
private TextView addressTextView;
|
||||
private TextView amountTextView;
|
||||
|
||||
public PendingTransaction.Priority priority;
|
||||
private int currentEntryIndex = -1;
|
||||
private final ActivityResultLauncher<ScanOptions> qrCodeLauncher = registerForActivityResult(new ScanContract(), result -> {
|
||||
if (result.getContents() != null) {
|
||||
|
@ -72,7 +67,12 @@ public class SendFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
});
|
||||
private final ActivityResultLauncher<String> cameraPermissionsLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(),
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_send, container, false);
|
||||
} private final ActivityResultLauncher<String> cameraPermissionsLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(),
|
||||
granted -> {
|
||||
if (granted) {
|
||||
onScan(currentEntryIndex);
|
||||
|
@ -82,12 +82,6 @@ public class SendFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_send, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
@ -249,8 +243,14 @@ public class SendFragment extends Fragment {
|
|||
ImageButton removeOutputImageButton = entryView.findViewById(R.id.remove_output_imagebutton);
|
||||
EditText addressField = entryView.findViewById(R.id.address_edittext);
|
||||
addressField.addTextChangedListener(new TextWatcher() {
|
||||
@Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
||||
@Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
int currentOutputs = getDestCount();
|
||||
|
@ -478,4 +478,6 @@ public class SendFragment extends Fragment {
|
|||
private void setAddOutputButtonVisibility(int visibility) {
|
||||
addOutputImageView.setVisibility(visibility);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -8,10 +8,10 @@ import net.mynero.wallet.model.PendingTransaction;
|
|||
|
||||
public class SendViewModel extends ViewModel {
|
||||
private final MutableLiveData<Boolean> _sendingMax = new MutableLiveData<>(false);
|
||||
public LiveData<Boolean> sendingMax = _sendingMax;
|
||||
private final MutableLiveData<Boolean> _showAddOutputButton = new MutableLiveData<>(true);
|
||||
public LiveData<Boolean> showAddOutputButton = _showAddOutputButton;
|
||||
private final MutableLiveData<PendingTransaction> _pendingTransaction = new MutableLiveData<>(null);
|
||||
public LiveData<Boolean> sendingMax = _sendingMax;
|
||||
public LiveData<Boolean> showAddOutputButton = _showAddOutputButton;
|
||||
public LiveData<PendingTransaction> pendingTransaction = _pendingTransaction;
|
||||
|
||||
public void setSendingMax(boolean value) {
|
||||
|
|
|
@ -24,13 +24,12 @@ import androidx.navigation.fragment.NavHostFragment;
|
|||
|
||||
import net.mynero.wallet.MoneroApplication;
|
||||
import net.mynero.wallet.R;
|
||||
import net.mynero.wallet.data.DefaultNodes;
|
||||
import net.mynero.wallet.data.Node;
|
||||
import net.mynero.wallet.fragment.dialog.AddNodeBottomSheetDialog;
|
||||
import net.mynero.wallet.fragment.dialog.EditNodeBottomSheetDialog;
|
||||
import net.mynero.wallet.fragment.dialog.WalletKeysBottomSheetDialog;
|
||||
import net.mynero.wallet.fragment.dialog.NodeSelectionBottomSheetDialog;
|
||||
import net.mynero.wallet.fragment.dialog.PasswordBottomSheetDialog;
|
||||
import net.mynero.wallet.fragment.dialog.WalletKeysBottomSheetDialog;
|
||||
import net.mynero.wallet.model.Wallet;
|
||||
import net.mynero.wallet.model.WalletManager;
|
||||
import net.mynero.wallet.service.BalanceService;
|
||||
|
@ -38,8 +37,6 @@ import net.mynero.wallet.service.BlockchainService;
|
|||
import net.mynero.wallet.service.HistoryService;
|
||||
import net.mynero.wallet.service.PrefService;
|
||||
import net.mynero.wallet.util.Constants;
|
||||
import net.mynero.wallet.util.DayNightMode;
|
||||
import net.mynero.wallet.util.NightmodeHelper;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.util.Patterns;
|
|||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import net.mynero.wallet.MoneroApplication;
|
||||
import net.mynero.wallet.data.DefaultNodes;
|
||||
import net.mynero.wallet.data.Node;
|
||||
import net.mynero.wallet.model.WalletManager;
|
||||
import net.mynero.wallet.service.PrefService;
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
package net.mynero.wallet.fragment.transaction;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import net.mynero.wallet.model.TransactionInfo;
|
||||
import net.mynero.wallet.model.Wallet;
|
||||
import net.mynero.wallet.model.WalletManager;
|
||||
|
||||
public class TransactionViewModel extends ViewModel {
|
||||
}
|
|
@ -24,14 +24,12 @@ import net.mynero.wallet.util.MoneroThreadPoolExecutor;
|
|||
import net.mynero.wallet.util.UriData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class UtxosFragment extends Fragment implements CoinsInfoAdapter.CoinsInfoAdapterListener, SendBottomSheetDialog.Listener {
|
||||
|
||||
private UtxosViewModel mViewModel;
|
||||
private final CoinsInfoAdapter adapter = new CoinsInfoAdapter(this);
|
||||
private UtxosViewModel mViewModel;
|
||||
private Button sendUtxosButton;
|
||||
private Button churnUtxosButton;
|
||||
private Button freezeUtxosButton;
|
||||
|
|
|
@ -36,6 +36,7 @@ import java.util.concurrent.atomic.AtomicBoolean
|
|||
*/
|
||||
class SingleLiveEvent<T> : MutableLiveData<T>() {
|
||||
private val mPending = AtomicBoolean(false)
|
||||
|
||||
@MainThread
|
||||
override fun observe(owner: LifecycleOwner, observer: Observer<in T>) {
|
||||
if (hasActiveObservers()) {
|
||||
|
|
|
@ -23,18 +23,24 @@ class CoinsInfo : Parcelable, Comparable<CoinsInfo> {
|
|||
@JvmField
|
||||
var globalOutputIndex: Long
|
||||
var isSpent = false
|
||||
|
||||
@JvmField
|
||||
var keyImage: String? = null
|
||||
|
||||
@JvmField
|
||||
var amount: Long = 0
|
||||
|
||||
@JvmField
|
||||
var hash: String? = null
|
||||
|
||||
@JvmField
|
||||
var pubKey: String? = null
|
||||
var isUnlocked = false
|
||||
|
||||
@JvmField
|
||||
var localOutputIndex: Long = 0
|
||||
var isFrozen = false
|
||||
|
||||
@JvmField
|
||||
var address: String? = null
|
||||
|
||||
|
@ -89,7 +95,7 @@ class CoinsInfo : Parcelable, Comparable<CoinsInfo> {
|
|||
companion object {
|
||||
@JvmField
|
||||
val CREATOR: Creator<CoinsInfo?> = object : Creator<CoinsInfo?> {
|
||||
override fun createFromParcel(`in`: Parcel): CoinsInfo? {
|
||||
override fun createFromParcel(`in`: Parcel): CoinsInfo {
|
||||
return CoinsInfo(`in`)
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ package net.mynero.wallet.model
|
|||
class PendingTransaction internal constructor(var handle: Long) {
|
||||
val status: Status
|
||||
get() = Status.values()[getStatusJ()]
|
||||
|
||||
external fun getStatusJ(): Int
|
||||
external fun getErrorString(): String?
|
||||
|
||||
|
@ -29,6 +30,7 @@ class PendingTransaction internal constructor(var handle: Long) {
|
|||
external fun getFee(): Long
|
||||
val firstTxId: String
|
||||
get() = getFirstTxIdJ() ?: throw IndexOutOfBoundsException()
|
||||
|
||||
external fun getFirstTxIdJ(): String?
|
||||
external fun getTxCount(): Long
|
||||
|
||||
|
|
|
@ -170,10 +170,6 @@ public class TransactionInfo implements Parcelable, Comparable<TransactionInfo>
|
|||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static Direction fromInteger(int n) {
|
||||
switch (n) {
|
||||
case 0:
|
||||
|
@ -183,5 +179,9 @@ public class TransactionInfo implements Parcelable, Comparable<TransactionInfo>
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ import android.os.Parcelable.Creator
|
|||
|
||||
class Transfer : Parcelable {
|
||||
var amount: Long
|
||||
|
||||
@JvmField
|
||||
var address: String?
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ class Wallet {
|
|||
}
|
||||
|
||||
private external fun statusWithErrorString(): Status
|
||||
|
||||
@Synchronized
|
||||
external fun setPassword(password: String?): Boolean
|
||||
val address: String
|
||||
|
@ -126,6 +127,7 @@ class Wallet {
|
|||
subaddress.amount = amount
|
||||
return subaddress
|
||||
}
|
||||
|
||||
external fun getPath(): String?
|
||||
val networkType: NetworkType?
|
||||
get() = fromInteger(nettype())
|
||||
|
@ -217,6 +219,7 @@ class Wallet {
|
|||
external fun getBalanceAll(): Long
|
||||
val unlockedBalance: Long
|
||||
get() = getUnlockedBalance(accountIndex)
|
||||
|
||||
external fun getUnlockedBalanceAll(): Long
|
||||
|
||||
external fun getUnlockedBalance(accountIndex: Int): Long
|
||||
|
@ -349,6 +352,7 @@ class Wallet {
|
|||
external fun setUserNote(txid: String?, note: String?): Boolean
|
||||
external fun getUserNote(txid: String?): String?
|
||||
external fun getTxKey(txid: String?): String?
|
||||
|
||||
@JvmOverloads
|
||||
external fun addAccount(label: String? = NEW_ACCOUNT_NAME)
|
||||
var accountLabel: String?
|
||||
|
@ -428,6 +432,7 @@ class Wallet {
|
|||
|
||||
class Status internal constructor(status: Int, @JvmField val errorString: String) {
|
||||
val status: StatusEnum
|
||||
|
||||
@JvmField
|
||||
var connectionStatus: ConnectionStatus? = null // optional
|
||||
|
||||
|
@ -454,22 +459,30 @@ class Wallet {
|
|||
|
||||
@JvmStatic
|
||||
external fun getDisplayAmount(amount: Long): String
|
||||
|
||||
@JvmStatic
|
||||
external fun getAmountFromString(amount: String?): Long
|
||||
|
||||
@JvmStatic
|
||||
external fun getAmountFromDouble(amount: Double): Long
|
||||
|
||||
@JvmStatic
|
||||
external fun generatePaymentId(): String
|
||||
|
||||
@JvmStatic
|
||||
external fun isPaymentIdValid(payment_id: String): Boolean
|
||||
|
||||
@JvmStatic
|
||||
fun isAddressValid(address: String): Boolean {
|
||||
return instance?.networkType?.value?.let { isAddressValid(address, it) } == true
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
external fun isAddressValid(address: String?, networkType: Int): Boolean
|
||||
|
||||
@JvmStatic
|
||||
external fun getPaymentIdFromAddress(address: String?, networkType: Int): String?
|
||||
|
||||
@JvmStatic
|
||||
external fun getMaximumAllowedAmount(): Long
|
||||
}
|
||||
|
|
|
@ -245,7 +245,8 @@ class WalletManager {
|
|||
fun findWallets(path: File): List<WalletInfo> {
|
||||
val wallets: MutableList<WalletInfo> = ArrayList()
|
||||
Timber.d("Scanning: %s", path.absolutePath)
|
||||
val found = path.listFiles { dir, filename -> filename.endsWith(".keys") } ?: return emptyList()
|
||||
val found =
|
||||
path.listFiles { dir, filename -> filename.endsWith(".keys") } ?: return emptyList()
|
||||
for (i in found.indices) {
|
||||
val filename = found[i].name
|
||||
val f = File(
|
||||
|
@ -354,16 +355,22 @@ class WalletManager {
|
|||
|
||||
@JvmStatic
|
||||
external fun initLogger(argv0: String?, defaultLogBaseName: String?)
|
||||
|
||||
@JvmStatic
|
||||
external fun setLogLevel(level: Int)
|
||||
|
||||
@JvmStatic
|
||||
external fun logDebug(category: String?, message: String?)
|
||||
|
||||
@JvmStatic
|
||||
external fun logInfo(category: String?, message: String?)
|
||||
|
||||
@JvmStatic
|
||||
external fun logWarning(category: String?, message: String?)
|
||||
|
||||
@JvmStatic
|
||||
external fun logError(category: String?, message: String?)
|
||||
|
||||
@JvmStatic
|
||||
external fun moneroVersion(): String?
|
||||
}
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
package net.mynero.wallet.service;
|
||||
|
||||
import net.mynero.wallet.MoneroApplication;
|
||||
import net.mynero.wallet.data.Subaddress;
|
||||
import net.mynero.wallet.model.TransactionInfo;
|
||||
import net.mynero.wallet.model.Wallet;
|
||||
import net.mynero.wallet.model.WalletManager;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class AddressService extends ServiceBase {
|
||||
|
|
|
@ -5,9 +5,6 @@ import androidx.lifecycle.MutableLiveData;
|
|||
|
||||
import net.mynero.wallet.model.BalanceInfo;
|
||||
import net.mynero.wallet.model.CoinsInfo;
|
||||
import net.mynero.wallet.model.Wallet;
|
||||
import net.mynero.wallet.model.WalletManager;
|
||||
import net.mynero.wallet.util.Constants;
|
||||
|
||||
public class BalanceService extends ServiceBase {
|
||||
public static BalanceService instance = null;
|
||||
|
|
|
@ -232,6 +232,7 @@ public class MoneroHandlerThread extends Thread implements WalletListener {
|
|||
|
||||
public interface Listener {
|
||||
void onRefresh(boolean walletSynced);
|
||||
|
||||
void onConnectionFail();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import net.mynero.wallet.data.DefaultNodes;
|
|||
import net.mynero.wallet.data.Node;
|
||||
import net.mynero.wallet.util.Constants;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
|
@ -22,6 +21,10 @@ public class PrefService extends ServiceBase {
|
|||
instance = this;
|
||||
}
|
||||
|
||||
public static PrefService getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public SharedPreferences.Editor edit() {
|
||||
return preferences.edit();
|
||||
}
|
||||
|
@ -104,8 +107,4 @@ public class PrefService extends ServiceBase {
|
|||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static PrefService getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,9 @@ import java.util.List;
|
|||
|
||||
public class UTXOService extends ServiceBase {
|
||||
public static UTXOService instance = null;
|
||||
private List<CoinsInfo> internalCachedUtxos = new ArrayList<>();
|
||||
private final MutableLiveData<List<CoinsInfo>> _utxos = new MutableLiveData<>();
|
||||
public LiveData<List<CoinsInfo>> utxos = _utxos;
|
||||
private List<CoinsInfo> internalCachedUtxos = new ArrayList<>();
|
||||
private ArrayList<String> frozenCoins = new ArrayList<>();
|
||||
|
||||
public UTXOService(MoneroHandlerThread thread) {
|
||||
|
|
|
@ -18,6 +18,7 @@ object Constants {
|
|||
const val URI_ARG_AMOUNT2 = "amount"
|
||||
const val NAV_ARG_TXINFO = "nav_arg_txinfo"
|
||||
const val STREET_MODE_BALANCE = "#.############"
|
||||
|
||||
@JvmField
|
||||
val DONATION_ADDRESSES = arrayOf(
|
||||
"87BqQYkugEzh6Tuyotm2uc3DzJzKM6MuZaC161e6u1TsQxxPmXVPHpdNRyK47JY4d1hhbe25YVz4e9vTXCLDxvHkRXEAeBC", // primary Mysu Donation address
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.Date
|
|||
object DateHelper {
|
||||
@JvmField
|
||||
val DATETIME_FORMATTER = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
||||
|
||||
@Throws(ParseException::class)
|
||||
fun parse(dateString: String): Date {
|
||||
return DATETIME_FORMATTER.parse(dateString.replace("Z$".toRegex(), "+0000"))
|
||||
|
|
|
@ -45,7 +45,6 @@ import java.io.File
|
|||
import java.io.IOException
|
||||
import java.io.InputStreamReader
|
||||
import java.math.BigDecimal
|
||||
import java.math.BigInteger
|
||||
import java.net.MalformedURLException
|
||||
import java.net.SocketTimeoutException
|
||||
import java.net.URL
|
||||
|
@ -63,6 +62,7 @@ object Helper {
|
|||
private const val MONERO_DIR = "monero"
|
||||
private val HexArray = "0123456789ABCDEF".toCharArray()
|
||||
var ALLOW_SHIFT = false
|
||||
|
||||
@JvmField
|
||||
var DISPLAY_DIGITS_INFO = 5
|
||||
private var ShakeAnimation: Animation? = null
|
||||
|
|
|
@ -194,6 +194,7 @@ class RestoreHeight internal constructor() {
|
|||
companion object {
|
||||
const val DIFFICULTY_TARGET = 120 // seconds
|
||||
private var Singleton: RestoreHeight? = null
|
||||
|
||||
@JvmStatic
|
||||
val instance: RestoreHeight?
|
||||
get() {
|
||||
|
|
|
@ -7,7 +7,8 @@ import net.mynero.wallet.model.WalletManager.Companion.instance
|
|||
class UriData(@JvmField val address: String, val params: HashMap<String, String>) {
|
||||
|
||||
fun hasPaymentId(): Boolean {
|
||||
return instance?.wallet?.nettype()?.let { getPaymentIdFromAddress(address, it) }?.isNotEmpty() == true
|
||||
return instance?.wallet?.nettype()?.let { getPaymentIdFromAddress(address, it) }
|
||||
?.isNotEmpty() == true
|
||||
}
|
||||
|
||||
val amount: String?
|
||||
|
|
Loading…
Reference in a new issue