mirror of
https://codeberg.org/anoncontributorxmr/mysu.git
synced 2024-11-22 15:32:24 +00:00
Convert services to Kotlin; just need to convert fragment/UI stuff next, then eventually convert to Compose
This commit is contained in:
parent
e4cae3bbb7
commit
08b989eaab
14 changed files with 73 additions and 59 deletions
|
@ -9,7 +9,7 @@ import net.mynero.wallet.fragment.dialog.PasswordBottomSheetDialog
|
||||||
import net.mynero.wallet.fragment.dialog.PasswordBottomSheetDialog.PasswordListener
|
import net.mynero.wallet.fragment.dialog.PasswordBottomSheetDialog.PasswordListener
|
||||||
import net.mynero.wallet.fragment.dialog.SendBottomSheetDialog
|
import net.mynero.wallet.fragment.dialog.SendBottomSheetDialog
|
||||||
import net.mynero.wallet.livedata.SingleLiveEvent
|
import net.mynero.wallet.livedata.SingleLiveEvent
|
||||||
import net.mynero.wallet.model.WalletManager.Companion.instance
|
import net.mynero.wallet.model.WalletManager
|
||||||
import net.mynero.wallet.service.AddressService
|
import net.mynero.wallet.service.AddressService
|
||||||
import net.mynero.wallet.service.BalanceService
|
import net.mynero.wallet.service.BalanceService
|
||||||
import net.mynero.wallet.service.BlockchainService
|
import net.mynero.wallet.service.BlockchainService
|
||||||
|
@ -41,8 +41,8 @@ class MainActivity : AppCompatActivity(), MoneroHandlerThread.Listener, Password
|
||||||
val walletKeysFile = File(applicationInfo.dataDir, Constants.WALLET_NAME + ".keys")
|
val walletKeysFile = File(applicationInfo.dataDir, Constants.WALLET_NAME + ".keys")
|
||||||
if (walletKeysFile.exists()) {
|
if (walletKeysFile.exists()) {
|
||||||
val promptPassword =
|
val promptPassword =
|
||||||
PrefService.getInstance().getBoolean(Constants.PREF_USES_PASSWORD, false)
|
PrefService.instance?.getBoolean(Constants.PREF_USES_PASSWORD, false)
|
||||||
if (!promptPassword) {
|
if (promptPassword == false) {
|
||||||
init(walletFile, "")
|
init(walletFile, "")
|
||||||
} else {
|
} else {
|
||||||
val passwordDialog = PasswordBottomSheetDialog()
|
val passwordDialog = PasswordBottomSheetDialog()
|
||||||
|
@ -70,15 +70,17 @@ class MainActivity : AppCompatActivity(), MoneroHandlerThread.Listener, Password
|
||||||
}
|
}
|
||||||
|
|
||||||
fun init(walletFile: File, password: String?) {
|
fun init(walletFile: File, password: String?) {
|
||||||
val wallet = password?.let { instance?.openWallet(walletFile.absolutePath, it) }
|
val wallet = WalletManager.instance?.openWallet(walletFile.absolutePath, password ?: "")
|
||||||
thread = MoneroHandlerThread("WalletService", this, wallet)
|
thread = wallet?.let { MoneroHandlerThread("WalletService", this, it) }
|
||||||
TxService(thread)
|
thread?.let { thread ->
|
||||||
balanceService = BalanceService(thread)
|
TxService(thread)
|
||||||
addressService = AddressService(thread)
|
balanceService = BalanceService(thread)
|
||||||
historyService = HistoryService(thread)
|
addressService = AddressService(thread)
|
||||||
blockchainService = BlockchainService(thread)
|
historyService = HistoryService(thread)
|
||||||
utxoService = UTXOService(thread)
|
blockchainService = BlockchainService(thread)
|
||||||
thread?.start()
|
utxoService = UTXOService(thread)
|
||||||
|
thread.start()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRefresh(walletSynced: Boolean) {
|
override fun onRefresh(walletSynced: Boolean) {
|
||||||
|
|
|
@ -127,9 +127,9 @@ class CoinsInfoAdapter(val listener: CoinsInfoAdapterListener?) :
|
||||||
val globalIdxTextView = itemView.findViewById<TextView>(R.id.utxo_global_index_textview)
|
val globalIdxTextView = itemView.findViewById<TextView>(R.id.utxo_global_index_textview)
|
||||||
val outpointTextView = itemView.findViewById<TextView>(R.id.utxo_outpoint_textview)
|
val outpointTextView = itemView.findViewById<TextView>(R.id.utxo_outpoint_textview)
|
||||||
val streetModeEnabled =
|
val streetModeEnabled =
|
||||||
PrefService.getInstance().getBoolean(Constants.PREF_STREET_MODE, false)
|
PrefService.instance?.getBoolean(Constants.PREF_STREET_MODE, false)
|
||||||
val balanceString =
|
val balanceString =
|
||||||
if (streetModeEnabled) Constants.STREET_MODE_BALANCE else Wallet.getDisplayAmount(
|
if (streetModeEnabled == true) Constants.STREET_MODE_BALANCE else Wallet.getDisplayAmount(
|
||||||
coinsInfo.amount
|
coinsInfo.amount
|
||||||
)
|
)
|
||||||
amountTextView.text =
|
amountTextView.text =
|
||||||
|
@ -148,7 +148,7 @@ class CoinsInfoAdapter(val listener: CoinsInfoAdapterListener?) :
|
||||||
if (selected) {
|
if (selected) {
|
||||||
itemView.backgroundTintList =
|
itemView.backgroundTintList =
|
||||||
ContextCompat.getColorStateList(itemView.context, R.color.oled_colorSecondary)
|
ContextCompat.getColorStateList(itemView.context, R.color.oled_colorSecondary)
|
||||||
} else if (coinsInfo.isFrozen || UTXOService.instance.isCoinFrozen(coinsInfo)) {
|
} else if (coinsInfo.isFrozen || UTXOService.instance?.isCoinFrozen(coinsInfo) == true) {
|
||||||
itemView.backgroundTintList =
|
itemView.backgroundTintList =
|
||||||
ContextCompat.getColorStateList(itemView.context, R.color.oled_frozen_utxo)
|
ContextCompat.getColorStateList(itemView.context, R.color.oled_frozen_utxo)
|
||||||
} else if (!coinsInfo.isUnlocked) {
|
} else if (!coinsInfo.isUnlocked) {
|
||||||
|
|
|
@ -80,7 +80,7 @@ class NodeSelectionAdapter(val listener: NodeSelectionAdapterListener?) :
|
||||||
view
|
view
|
||||||
) {
|
) {
|
||||||
fun bind(node: Node) {
|
fun bind(node: Node) {
|
||||||
val currentNode = PrefService.getInstance().node
|
val currentNode = PrefService.instance?.node
|
||||||
val match = node == currentNode
|
val match = node == currentNode
|
||||||
if (match) {
|
if (match) {
|
||||||
itemView.setBackgroundColor(itemView.resources.getColor(R.color.oled_colorSecondary))
|
itemView.setBackgroundColor(itemView.resources.getColor(R.color.oled_colorSecondary))
|
||||||
|
|
|
@ -92,8 +92,8 @@ class SubaddressAdapter(val listener: SubaddressAdapterListener?) :
|
||||||
val amount = subaddress.amount
|
val amount = subaddress.amount
|
||||||
if (amount > 0) {
|
if (amount > 0) {
|
||||||
val streetMode =
|
val streetMode =
|
||||||
PrefService.getInstance().getBoolean(Constants.PREF_STREET_MODE, false)
|
PrefService.instance?.getBoolean(Constants.PREF_STREET_MODE, false)
|
||||||
if (streetMode) {
|
if (streetMode == true) {
|
||||||
addressAmountTextView.text = itemView.context.getString(
|
addressAmountTextView.text = itemView.context.getString(
|
||||||
R.string.tx_list_amount_positive,
|
R.string.tx_list_amount_positive,
|
||||||
Constants.STREET_MODE_BALANCE
|
Constants.STREET_MODE_BALANCE
|
||||||
|
|
|
@ -95,9 +95,9 @@ class TransactionInfoAdapter(val listener: TxInfoAdapterListener?) :
|
||||||
|
|
||||||
fun bind(txInfo: TransactionInfo) {
|
fun bind(txInfo: TransactionInfo) {
|
||||||
val streetModeEnabled =
|
val streetModeEnabled =
|
||||||
PrefService.getInstance().getBoolean(Constants.PREF_STREET_MODE, false)
|
PrefService.instance?.getBoolean(Constants.PREF_STREET_MODE, false)
|
||||||
val displayAmount =
|
val displayAmount =
|
||||||
if (streetModeEnabled) Constants.STREET_MODE_BALANCE else getDisplayAmount(
|
if (streetModeEnabled == true) Constants.STREET_MODE_BALANCE else getDisplayAmount(
|
||||||
txInfo.amount,
|
txInfo.amount,
|
||||||
Helper.DISPLAY_DIGITS_INFO
|
Helper.DISPLAY_DIGITS_INFO
|
||||||
)
|
)
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class EditAddressLabelBottomSheetDialog extends BottomSheetDialogFragment
|
||||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
Wallet wallet = WalletManager.getInstance().getWallet();
|
Wallet wallet = WalletManager.getInstance().getWallet();
|
||||||
AddressService addressService = AddressService.getInstance();
|
AddressService addressService = AddressService.instance;
|
||||||
ImageButton pasteButton = view.findViewById(R.id.paste_password_imagebutton);
|
ImageButton pasteButton = view.findViewById(R.id.paste_password_imagebutton);
|
||||||
EditText labelEditText = view.findViewById(R.id.wallet_password_edittext);
|
EditText labelEditText = view.findViewById(R.id.wallet_password_edittext);
|
||||||
Button saveLabelButton = view.findViewById(R.id.unlock_wallet_button);
|
Button saveLabelButton = view.findViewById(R.id.unlock_wallet_button);
|
||||||
|
|
|
@ -46,7 +46,8 @@ public class SendBottomSheetDialog extends BottomSheetDialogFragment {
|
||||||
private final MutableLiveData<PendingTransaction> _pendingTransaction = new MutableLiveData<>(null);
|
private final MutableLiveData<PendingTransaction> _pendingTransaction = new MutableLiveData<>(null);
|
||||||
public ArrayList<String> selectedUtxos = new ArrayList<>();
|
public ArrayList<String> selectedUtxos = new ArrayList<>();
|
||||||
public LiveData<Boolean> sendingMax = _sendingMax;
|
public LiveData<Boolean> sendingMax = _sendingMax;
|
||||||
public LiveData<PendingTransaction> pendingTransaction = _pendingTransaction; private final ActivityResultLauncher<String> cameraPermissionsLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(),
|
public LiveData<PendingTransaction> pendingTransaction = _pendingTransaction;
|
||||||
|
public UriData uriData = null; private final ActivityResultLauncher<String> cameraPermissionsLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(),
|
||||||
granted -> {
|
granted -> {
|
||||||
if (granted) {
|
if (granted) {
|
||||||
onScan();
|
onScan();
|
||||||
|
@ -54,7 +55,6 @@ 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();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
public UriData uriData = null;
|
|
||||||
public boolean isChurning = false;
|
public boolean isChurning = false;
|
||||||
public Listener listener = null;
|
public Listener listener = null;
|
||||||
public PendingTransaction.Priority priority;
|
public PendingTransaction.Priority priority;
|
||||||
|
@ -138,7 +138,7 @@ public class SendBottomSheetDialog extends BottomSheetDialogFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bindObservers() {
|
private void bindObservers() {
|
||||||
BalanceService.getInstance().balanceInfo.observe(getViewLifecycleOwner(), balanceInfo -> {
|
BalanceService.instance.balanceInfo.observe(getViewLifecycleOwner(), balanceInfo -> {
|
||||||
createButton.setEnabled(balanceInfo.getRawUnlocked() != 0);
|
createButton.setEnabled(balanceInfo.getRawUnlocked() != 0);
|
||||||
if (!isChurning) {
|
if (!isChurning) {
|
||||||
sendMaxButton.setEnabled(balanceInfo.getRawUnlocked() != 0);
|
sendMaxButton.setEnabled(balanceInfo.getRawUnlocked() != 0);
|
||||||
|
@ -212,7 +212,7 @@ public class SendBottomSheetDialog extends BottomSheetDialogFragment {
|
||||||
boolean validAddress = Wallet.isAddressValid(address);
|
boolean validAddress = Wallet.isAddressValid(address);
|
||||||
if (validAddress && (!amount.isEmpty() || sendAll)) {
|
if (validAddress && (!amount.isEmpty() || sendAll)) {
|
||||||
long amountRaw = Wallet.getAmountFromString(amount);
|
long amountRaw = Wallet.getAmountFromString(amount);
|
||||||
long balance = BalanceService.getInstance().getUnlockedBalanceRaw();
|
long balance = BalanceService.instance.getUnlockedBalanceRaw();
|
||||||
if ((amountRaw >= balance || amountRaw <= 0) && !sendAll) {
|
if ((amountRaw >= balance || amountRaw <= 0) && !sendAll) {
|
||||||
Toast.makeText(activity, getString(R.string.send_amount_invalid), Toast.LENGTH_SHORT).show();
|
Toast.makeText(activity, getString(R.string.send_amount_invalid), Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
|
@ -253,7 +253,7 @@ public class SendBottomSheetDialog extends BottomSheetDialogFragment {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
((MoneroApplication) activity.getApplication()).getExecutor().execute(() -> {
|
((MoneroApplication) activity.getApplication()).getExecutor().execute(() -> {
|
||||||
boolean success = TxService.getInstance().sendTx(pendingTx);
|
boolean success = TxService.instance.sendTx(pendingTx);
|
||||||
activity.runOnUiThread(() -> {
|
activity.runOnUiThread(() -> {
|
||||||
if (success) {
|
if (success) {
|
||||||
Toast.makeText(activity, getString(R.string.sent_tx), Toast.LENGTH_SHORT).show();
|
Toast.makeText(activity, getString(R.string.sent_tx), Toast.LENGTH_SHORT).show();
|
||||||
|
@ -275,7 +275,7 @@ public class SendBottomSheetDialog extends BottomSheetDialogFragment {
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
((MoneroApplication) activity.getApplication()).getExecutor().execute(() -> {
|
((MoneroApplication) activity.getApplication()).getExecutor().execute(() -> {
|
||||||
try {
|
try {
|
||||||
PendingTransaction pendingTx = TxService.getInstance().createTx(address, amount, sendAll, feePriority, selectedUtxos);
|
PendingTransaction pendingTx = TxService.instance.createTx(address, amount, sendAll, feePriority, selectedUtxos);
|
||||||
if (pendingTx != null && pendingTx.getStatus() == PendingTransaction.Status.Status_Ok) {
|
if (pendingTx != null && pendingTx.getStatus() == PendingTransaction.Status.Status_Ok) {
|
||||||
_pendingTransaction.postValue(pendingTx);
|
_pendingTransaction.postValue(pendingTx);
|
||||||
} else {
|
} else {
|
||||||
|
@ -351,4 +351,6 @@ public class SendBottomSheetDialog extends BottomSheetDialogFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -83,9 +83,9 @@ public class HomeFragment extends Fragment implements TransactionInfoAdapter.TxI
|
||||||
TextView unlockedBalanceTextView = view.findViewById(R.id.balance_unlocked_textview);
|
TextView unlockedBalanceTextView = view.findViewById(R.id.balance_unlocked_textview);
|
||||||
TextView lockedBalanceTextView = view.findViewById(R.id.balance_locked_textview);
|
TextView lockedBalanceTextView = view.findViewById(R.id.balance_locked_textview);
|
||||||
|
|
||||||
BalanceService balanceService = BalanceService.getInstance();
|
BalanceService balanceService = BalanceService.instance;
|
||||||
HistoryService historyService = HistoryService.getInstance();
|
HistoryService historyService = HistoryService.getInstance();
|
||||||
BlockchainService blockchainService = BlockchainService.getInstance();
|
BlockchainService blockchainService = BlockchainService.instance;
|
||||||
|
|
||||||
if (balanceService != null) {
|
if (balanceService != null) {
|
||||||
balanceService.balanceInfo.observe(getViewLifecycleOwner(), balanceInfo -> {
|
balanceService.balanceInfo.observe(getViewLifecycleOwner(), balanceInfo -> {
|
||||||
|
|
|
@ -20,14 +20,16 @@ public class ReceiveViewModel extends ViewModel {
|
||||||
public LiveData<List<Subaddress>> addresses = _addresses;
|
public LiveData<List<Subaddress>> addresses = _addresses;
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
_address.setValue(AddressService.getInstance().currentSubaddress());
|
if (AddressService.instance != null) {
|
||||||
|
_address.setValue(AddressService.instance.currentSubaddress());
|
||||||
|
}
|
||||||
_addresses.setValue(getSubaddresses());
|
_addresses.setValue(getSubaddresses());
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Subaddress> getSubaddresses() {
|
private List<Subaddress> getSubaddresses() {
|
||||||
Wallet wallet = WalletManager.getInstance().getWallet();
|
Wallet wallet = WalletManager.getInstance().getWallet();
|
||||||
ArrayList<Subaddress> subaddresses = new ArrayList<>();
|
ArrayList<Subaddress> subaddresses = new ArrayList<>();
|
||||||
int addressesSize = AddressService.getInstance().getLatestAddressIndex();
|
int addressesSize = AddressService.instance != null ? AddressService.instance.getLatestAddressIndex() : 0;
|
||||||
for (int i = addressesSize - 1; i >= 0; i--) {
|
for (int i = addressesSize - 1; i >= 0; i--) {
|
||||||
subaddresses.add(wallet.getSubaddressObject(i));
|
subaddresses.add(wallet.getSubaddressObject(i));
|
||||||
}
|
}
|
||||||
|
@ -35,7 +37,9 @@ public class ReceiveViewModel extends ViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getFreshSubaddress() {
|
public void getFreshSubaddress() {
|
||||||
_address.setValue(AddressService.getInstance().freshSubaddress());
|
if (AddressService.instance != null) {
|
||||||
|
_address.setValue(AddressService.instance.freshSubaddress());
|
||||||
|
}
|
||||||
_addresses.setValue(getSubaddresses());
|
_addresses.setValue(getSubaddresses());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,15 +72,7 @@ public class SendFragment extends Fragment {
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||||
@Nullable Bundle savedInstanceState) {
|
@Nullable Bundle savedInstanceState) {
|
||||||
return inflater.inflate(R.layout.fragment_send, container, false);
|
return inflater.inflate(R.layout.fragment_send, container, false);
|
||||||
} private final ActivityResultLauncher<String> cameraPermissionsLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(),
|
}
|
||||||
granted -> {
|
|
||||||
if (granted) {
|
|
||||||
onScan(currentEntryIndex);
|
|
||||||
} else {
|
|
||||||
Toast.makeText(getActivity(), getString(R.string.no_camera_permission), Toast.LENGTH_SHORT).show();
|
|
||||||
currentEntryIndex = -1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
|
@ -105,7 +97,15 @@ public class SendFragment extends Fragment {
|
||||||
bindListeners();
|
bindListeners();
|
||||||
bindObservers();
|
bindObservers();
|
||||||
init();
|
init();
|
||||||
}
|
} private final ActivityResultLauncher<String> cameraPermissionsLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(),
|
||||||
|
granted -> {
|
||||||
|
if (granted) {
|
||||||
|
onScan(currentEntryIndex);
|
||||||
|
} else {
|
||||||
|
Toast.makeText(getActivity(), getString(R.string.no_camera_permission), Toast.LENGTH_SHORT).show();
|
||||||
|
currentEntryIndex = -1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
addOutput(true);
|
addOutput(true);
|
||||||
|
@ -170,7 +170,7 @@ public class SendFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
long amountRaw = Wallet.getAmountFromString(amount);
|
long amountRaw = Wallet.getAmountFromString(amount);
|
||||||
long balance = BalanceService.getInstance().getUnlockedBalanceRaw();
|
long balance = BalanceService.instance.getUnlockedBalanceRaw();
|
||||||
if (amountRaw >= balance || amountRaw <= 0) {
|
if (amountRaw >= balance || amountRaw <= 0) {
|
||||||
Toast.makeText(getActivity(), getString(R.string.send_amount_invalid), Toast.LENGTH_SHORT).show();
|
Toast.makeText(getActivity(), getString(R.string.send_amount_invalid), Toast.LENGTH_SHORT).show();
|
||||||
return false;
|
return false;
|
||||||
|
@ -429,7 +429,7 @@ public class SendFragment extends Fragment {
|
||||||
private void createTx(List<Pair<String, String>> dests, boolean sendAll, PendingTransaction.Priority feePriority) {
|
private void createTx(List<Pair<String, String>> dests, boolean sendAll, PendingTransaction.Priority feePriority) {
|
||||||
((MoneroApplication) getActivity().getApplication()).getExecutor().execute(() -> {
|
((MoneroApplication) getActivity().getApplication()).getExecutor().execute(() -> {
|
||||||
try {
|
try {
|
||||||
PendingTransaction pendingTx = TxService.getInstance().createTx(dests, sendAll, feePriority, new ArrayList<>());
|
PendingTransaction pendingTx = TxService.instance.createTx(dests, sendAll, feePriority, new ArrayList<>());
|
||||||
if (pendingTx != null && pendingTx.getStatus() == PendingTransaction.Status.Status_Ok) {
|
if (pendingTx != null && pendingTx.getStatus() == PendingTransaction.Status.Status_Ok) {
|
||||||
mViewModel.setPendingTransaction(pendingTx);
|
mViewModel.setPendingTransaction(pendingTx);
|
||||||
} else {
|
} else {
|
||||||
|
@ -459,7 +459,7 @@ public class SendFragment extends Fragment {
|
||||||
|
|
||||||
private void sendTx(PendingTransaction pendingTx) {
|
private void sendTx(PendingTransaction pendingTx) {
|
||||||
((MoneroApplication) getActivity().getApplication()).getExecutor().execute(() -> {
|
((MoneroApplication) getActivity().getApplication()).getExecutor().execute(() -> {
|
||||||
boolean success = TxService.getInstance().sendTx(pendingTx);
|
boolean success = TxService.instance.sendTx(pendingTx);
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity.runOnUiThread(() -> {
|
activity.runOnUiThread(() -> {
|
||||||
|
@ -480,4 +480,6 @@ public class SendFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -107,7 +107,7 @@ public class SettingsFragment extends Fragment implements PasswordBottomSheetDia
|
||||||
streetModeSwitch.setChecked(PrefService.getInstance().getBoolean(Constants.PREF_STREET_MODE, false));
|
streetModeSwitch.setChecked(PrefService.getInstance().getBoolean(Constants.PREF_STREET_MODE, false));
|
||||||
streetModeSwitch.setOnCheckedChangeListener((compoundButton, b) -> {
|
streetModeSwitch.setOnCheckedChangeListener((compoundButton, b) -> {
|
||||||
PrefService.getInstance().edit().putBoolean(Constants.PREF_STREET_MODE, b).apply();
|
PrefService.getInstance().edit().putBoolean(Constants.PREF_STREET_MODE, b).apply();
|
||||||
BalanceService.getInstance().refreshBalance();
|
BalanceService.instance.refreshBalance();
|
||||||
});
|
});
|
||||||
|
|
||||||
monerochanSwitch.setChecked(PrefService.getInstance().getBoolean(Constants.PREF_MONEROCHAN, true));
|
monerochanSwitch.setChecked(PrefService.getInstance().getBoolean(Constants.PREF_MONEROCHAN, true));
|
||||||
|
@ -172,7 +172,7 @@ 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.instance.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) {
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class UtxosFragment extends Fragment implements CoinsInfoAdapter.CoinsInf
|
||||||
SendBottomSheetDialog sendDialog = new SendBottomSheetDialog();
|
SendBottomSheetDialog sendDialog = new SendBottomSheetDialog();
|
||||||
sendDialog.listener = this;
|
sendDialog.listener = this;
|
||||||
sendDialog.isChurning = true;
|
sendDialog.isChurning = true;
|
||||||
sendDialog.uriData = UriData.parse(AddressService.getInstance().currentSubaddress().address);
|
sendDialog.uriData = UriData.parse(AddressService.instance.currentSubaddress().address);
|
||||||
sendDialog.selectedUtxos = selectedKeyImages;
|
sendDialog.selectedUtxos = selectedKeyImages;
|
||||||
sendDialog.show(getActivity().getSupportFragmentManager(), null);
|
sendDialog.show(getActivity().getSupportFragmentManager(), null);
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,8 +12,8 @@ class BalanceInfo(val rawUnlocked: Long, val rawLocked: Long) {
|
||||||
val unlockedDisplay: String
|
val unlockedDisplay: String
|
||||||
get() {
|
get() {
|
||||||
val streetModeEnabled =
|
val streetModeEnabled =
|
||||||
PrefService.getInstance().getBoolean(Constants.PREF_STREET_MODE, false)
|
PrefService.instance?.getBoolean(Constants.PREF_STREET_MODE, false)
|
||||||
return if (streetModeEnabled) {
|
return if (streetModeEnabled == true) {
|
||||||
Constants.STREET_MODE_BALANCE
|
Constants.STREET_MODE_BALANCE
|
||||||
} else {
|
} else {
|
||||||
Wallet.getDisplayAmount(rawUnlocked)
|
Wallet.getDisplayAmount(rawUnlocked)
|
||||||
|
@ -22,8 +22,8 @@ class BalanceInfo(val rawUnlocked: Long, val rawLocked: Long) {
|
||||||
val lockedDisplay: String
|
val lockedDisplay: String
|
||||||
get() {
|
get() {
|
||||||
val streetModeEnabled =
|
val streetModeEnabled =
|
||||||
PrefService.getInstance().getBoolean(Constants.PREF_STREET_MODE, false)
|
PrefService.instance?.getBoolean(Constants.PREF_STREET_MODE, false)
|
||||||
return if (streetModeEnabled) {
|
return if (streetModeEnabled == true) {
|
||||||
Constants.STREET_MODE_BALANCE
|
Constants.STREET_MODE_BALANCE
|
||||||
} else {
|
} else {
|
||||||
Wallet.getDisplayAmount(rawLocked)
|
Wallet.getDisplayAmount(rawLocked)
|
||||||
|
|
|
@ -18,7 +18,6 @@ package net.mynero.wallet.model
|
||||||
import android.util.Pair
|
import android.util.Pair
|
||||||
import net.mynero.wallet.data.Subaddress
|
import net.mynero.wallet.data.Subaddress
|
||||||
import net.mynero.wallet.model.NetworkType.Companion.fromInteger
|
import net.mynero.wallet.model.NetworkType.Companion.fromInteger
|
||||||
import net.mynero.wallet.model.WalletManager.Companion.instance
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
|
@ -150,17 +149,17 @@ class Wallet {
|
||||||
external fun store(path: String?): Boolean
|
external fun store(path: String?): Boolean
|
||||||
fun close(): Boolean {
|
fun close(): Boolean {
|
||||||
disposePendingTransaction()
|
disposePendingTransaction()
|
||||||
return instance?.close(this) == true
|
return WalletManager.instance?.close(this) == true
|
||||||
}
|
}
|
||||||
|
|
||||||
external fun getFilename(): String
|
external fun getFilename(): String
|
||||||
|
|
||||||
// virtual std::string keysFilename() const = 0;
|
// virtual std::string keysFilename() const = 0;
|
||||||
fun init(upperTransactionSizeLimit: Long): Boolean {
|
fun init(upperTransactionSizeLimit: Long): Boolean {
|
||||||
var daemonAddress = instance?.getDaemonAddress()
|
var daemonAddress = WalletManager.instance?.getDaemonAddress()
|
||||||
var daemonUsername = instance?.daemonUsername
|
var daemonUsername = WalletManager.instance?.daemonUsername
|
||||||
var daemonPassword = instance?.daemonPassword
|
var daemonPassword = WalletManager.instance?.daemonPassword
|
||||||
var proxyAddress = instance?.proxy
|
var proxyAddress = WalletManager.instance?.proxy
|
||||||
Timber.d("init(")
|
Timber.d("init(")
|
||||||
if (daemonAddress != null) {
|
if (daemonAddress != null) {
|
||||||
Timber.d(daemonAddress.toString())
|
Timber.d(daemonAddress.toString())
|
||||||
|
@ -474,7 +473,12 @@ class Wallet {
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun isAddressValid(address: String): Boolean {
|
fun isAddressValid(address: String): Boolean {
|
||||||
return instance?.networkType?.value?.let { isAddressValid(address, it) } == true
|
return WalletManager.instance?.networkType?.value?.let {
|
||||||
|
isAddressValid(
|
||||||
|
address,
|
||||||
|
it
|
||||||
|
)
|
||||||
|
} == true
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
|
Loading…
Reference in a new issue