fix gradle build file and clean enotes

This commit is contained in:
- 2024-12-22 17:12:34 +01:00
parent 4ed7071872
commit 893ae7b2c1
3 changed files with 27 additions and 33 deletions

View File

@ -9,7 +9,7 @@ android {
minSdkVersion 26
targetSdkVersion 34
compileSdk 34
versionCode 51004
versionCode 60000
versionName "0.6.0 'Fluorine Fermi'"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
@ -123,7 +123,8 @@ static def getId(name) {
dependencies {
// Android stuff
implementation 'androidx.core:core-ktx:1.15.0'
//noinspection GradleDependency cannot be updated past 1.13.1 without bumping minSdkVersion
implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'

View File

@ -45,24 +45,24 @@ class EnotesActivity : AppCompatActivity(), WalletServiceObserver {
enotesRecyclerView = findViewById(R.id.transaction_history_recyclerview)
val streetMode = PreferenceUtils.isStreetMode(this)
adapter = EnotesAdapter(streetMode, object : EnotesAdapter.EnotesAdapterListener {
adapter = EnotesAdapter(listOf(), streetMode, object : EnotesAdapter.EnotesAdapterListener {
override fun onEnoteSelected(coinsInfo: CoinsInfo) {
val selected = adapter.contains(coinsInfo)
if (selected) {
adapter.deselectUtxo(coinsInfo)
adapter.deselectEnote(coinsInfo)
} else {
adapter.selectUtxo(coinsInfo)
adapter.selectEnote(coinsInfo)
}
var frozenExists = false
var unfrozenExists = false
for (selectedUtxo in adapter.selectedUtxos.values) {
for (selectedUtxo in adapter.getSelectedEnotes().values) {
if (selectedUtxo.isFrozen)
frozenExists = true
else {
unfrozenExists = true
}
}
if (adapter.selectedUtxos.isEmpty()) {
if (adapter.getSelectedEnotes().isEmpty()) {
sendUtxosButton.isEnabled = false
freezeUtxosButton.isEnabled = false
unfreezeUtxosButton.isEnabled = false
@ -96,7 +96,7 @@ class EnotesActivity : AppCompatActivity(), WalletServiceObserver {
private fun bindListeners() {
sendUtxosButton.setOnClickListener {
val selectedKeyImages = ArrayList<String>()
for (coinsInfo in adapter.selectedUtxos.values) {
for (coinsInfo in adapter.getSelectedEnotes().values) {
coinsInfo.keyImage?.let { keyImage -> selectedKeyImages.add(keyImage) }
}
val intent = Intent(this, SendActivity::class.java)
@ -107,13 +107,13 @@ class EnotesActivity : AppCompatActivity(), WalletServiceObserver {
freezeUtxosButton.setOnClickListener {
Toast.makeText(this, "Freezing enotes, please wait.", Toast.LENGTH_SHORT)
.show()
walletService?.freezeEnote(adapter.selectedUtxos.keys.filterNotNull().toList())
walletService?.freezeEnote(adapter.getSelectedEnotes().keys.filterNotNull().toList())
}
unfreezeUtxosButton.setOnClickListener {
Toast.makeText(this, "Thawing enotes, please wait.", Toast.LENGTH_SHORT)
.show()
walletService?.thawEnote(adapter.selectedUtxos.keys.filterNotNull().toList())
walletService?.thawEnote(adapter.getSelectedEnotes().keys.filterNotNull().toList())
}
}

View File

@ -28,53 +28,46 @@ import net.mynero.wallet.model.Wallet
import net.mynero.wallet.util.Constants
class EnotesAdapter(
val streetMode: Boolean,
val listener: EnotesAdapterListener
private var enotes: List<CoinsInfo>,
private val streetMode: Boolean,
private val listener: EnotesAdapterListener
) : RecyclerView.Adapter<EnotesAdapter.ViewHolder>() {
private var enotes: List<CoinsInfo> = listOf()
val selectedUtxos // <public-key, coinsinfo>
: MutableMap<String?, CoinsInfo>
private val selectedEnotes: MutableMap<String, CoinsInfo> = HashMap()
private var editing = false
/**
* Initialize the dataset of the Adapter.
*/
init {
selectedUtxos = HashMap()
}
fun submitList(enotes: List<CoinsInfo>) {
this.enotes = enotes
notifyDataSetChanged()
}
fun deselectUtxo(coinsInfo: CoinsInfo) {
selectedUtxos.remove(coinsInfo.pubKey)
if (selectedUtxos.size == 0) {
fun getSelectedEnotes(): Map<String, CoinsInfo> = selectedEnotes
fun deselectEnote(coinsInfo: CoinsInfo) {
selectedEnotes.remove(coinsInfo.pubKey)
if (selectedEnotes.size == 0) {
editing = false
}
notifyDataSetChanged()
}
fun selectUtxo(coinsInfo: CoinsInfo) {
fun selectEnote(coinsInfo: CoinsInfo) {
editing = true
selectedUtxos[coinsInfo.pubKey] = coinsInfo
selectedEnotes[coinsInfo.pubKey!!] = coinsInfo
notifyDataSetChanged()
}
operator fun contains(coinsInfo: CoinsInfo): Boolean {
return selectedUtxos.containsKey(coinsInfo.pubKey)
return selectedEnotes.containsKey(coinsInfo.pubKey)
}
fun clear() {
selectedUtxos.clear()
selectedEnotes.clear()
editing = false
notifyDataSetChanged()
}
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): ViewHolder {
// Create a new view, which defines the UI of the list item
val view = LayoutInflater.from(viewGroup.context)
.inflate(R.layout.enote_selection_item, viewGroup, false)
return ViewHolder(listener, view, streetMode)
@ -82,7 +75,7 @@ class EnotesAdapter(
override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) {
val tx = enotes[position]
viewHolder.bind(editing, tx, selectedUtxos)
viewHolder.bind(editing, tx, selectedEnotes)
}
override fun getItemCount(): Int {
@ -106,11 +99,11 @@ class EnotesAdapter(
fun bind(
editing: Boolean,
coinsInfo: CoinsInfo,
selectedUtxos: Map<String?, CoinsInfo>
selectedEnotes: Map<String, CoinsInfo>
) {
this.editing = editing
this.coinsInfo = coinsInfo
val selected = selectedUtxos.containsKey(coinsInfo.pubKey)
val selected = selectedEnotes.containsKey(coinsInfo.pubKey)
val pubKeyTextView = itemView.findViewById<TextView>(R.id.utxo_pub_key_textview)
val amountTextView = itemView.findViewById<TextView>(R.id.utxo_amount_textview)
val addressTextView = itemView.findViewById<TextView>(R.id.utxo_address_textview)