From 9b4cd9860a71da2171ece92416ce7037f9af27cb Mon Sep 17 00:00:00 2001 From: pokkst Date: Fri, 23 Sep 2022 02:33:55 -0500 Subject: [PATCH] Prevent locked UTXOs from being selected --- app/src/main/cpp/monerujo.cpp | 5 +++-- .../net/mynero/wallet/adapter/CoinsInfoAdapter.java | 11 ++++++++--- .../main/java/net/mynero/wallet/model/CoinsInfo.java | 8 +++++++- app/src/main/res/values-night/colors.xml | 1 + app/src/main/res/values/colors.xml | 1 + 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/src/main/cpp/monerujo.cpp b/app/src/main/cpp/monerujo.cpp index 9c0e482..21489de 100644 --- a/app/src/main/cpp/monerujo.cpp +++ b/app/src/main/cpp/monerujo.cpp @@ -1083,7 +1083,7 @@ Java_net_mynero_wallet_model_Wallet_getCoinsJ(JNIEnv *env, jobject instance) { jobject newCoinsInfo(JNIEnv *env, Monero::CoinsInfo *info) { jmethodID c = env->GetMethodID(class_CoinsInfo, "", - "(JZLjava/lang/String;JLjava/lang/String;Ljava/lang/String;)V"); + "(JZLjava/lang/String;JLjava/lang/String;Ljava/lang/String;Z)V"); jstring _key_image = env->NewStringUTF(info->keyImage().c_str()); jstring _pub_key = env->NewStringUTF(info->pubKey().c_str()); jstring _hash = env->NewStringUTF(info->hash().c_str()); @@ -1093,7 +1093,8 @@ jobject newCoinsInfo(JNIEnv *env, Monero::CoinsInfo *info) { _key_image, static_cast (info->amount()), _hash, - _pub_key); + _pub_key, + info->unlocked()); env->DeleteLocalRef(_key_image); env->DeleteLocalRef(_hash); env->DeleteLocalRef(_pub_key); diff --git a/app/src/main/java/net/mynero/wallet/adapter/CoinsInfoAdapter.java b/app/src/main/java/net/mynero/wallet/adapter/CoinsInfoAdapter.java index 445d1a7..8fb6ec1 100644 --- a/app/src/main/java/net/mynero/wallet/adapter/CoinsInfoAdapter.java +++ b/app/src/main/java/net/mynero/wallet/adapter/CoinsInfoAdapter.java @@ -103,11 +103,16 @@ public class CoinsInfoAdapter extends RecyclerView.Adapter { - listener.onUtxoSelected(coinsInfo); - return true; + boolean unlocked = coinsInfo.isUnlocked(); + if(unlocked) { + listener.onUtxoSelected(coinsInfo); + } + return unlocked; }); - if(selected) { + if(!coinsInfo.isUnlocked()) { + itemView.setBackgroundColor(ContextCompat.getColor(itemView.getContext(), R.color.oled_locked_utxo)); + } else if(selected) { itemView.setBackgroundColor(ContextCompat.getColor(itemView.getContext(), R.color.oled_negativeColor)); } else { itemView.setBackgroundColor(ContextCompat.getColor(itemView.getContext(), android.R.color.transparent)); diff --git a/app/src/main/java/net/mynero/wallet/model/CoinsInfo.java b/app/src/main/java/net/mynero/wallet/model/CoinsInfo.java index 961b52d..cf47594 100644 --- a/app/src/main/java/net/mynero/wallet/model/CoinsInfo.java +++ b/app/src/main/java/net/mynero/wallet/model/CoinsInfo.java @@ -35,14 +35,16 @@ public class CoinsInfo implements Parcelable, Comparable { long amount; String hash; String pubKey; + boolean unlocked; - public CoinsInfo(long globalOutputIndex, boolean spent, String keyImage, long amount, String hash, String pubKey) { + public CoinsInfo(long globalOutputIndex, boolean spent, String keyImage, long amount, String hash, String pubKey, boolean unlocked) { this.globalOutputIndex = globalOutputIndex; this.spent = spent; this.keyImage = keyImage; this.amount = amount; this.hash = hash; this.pubKey = pubKey; + this.unlocked = unlocked; } protected CoinsInfo(Parcel in) { @@ -85,6 +87,10 @@ public class CoinsInfo implements Parcelable, Comparable { return pubKey; } + public boolean isUnlocked() { + return unlocked; + } + @Override public int describeContents() { return 0; diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index 1b0c751..bdf8845 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -29,6 +29,7 @@ @color/oled_favouriteColor #ffffff #202020 + #956E43 diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 0307dec..bb4992b 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -30,6 +30,7 @@ @color/oled_colorBackground #CCCCCC #454545 + #B5895A