0.5.8: Work on reducing apk file size and removing unnecessary dependencies

This commit is contained in:
pokkst 2023-12-10 10:43:58 -06:00
parent f23548b279
commit 44dd9e1d7a
No known key found for this signature in database
GPG key ID: EC4FAAA66859FAA4
9 changed files with 49 additions and 90 deletions

View file

@ -8,10 +8,10 @@ android {
ndkVersion '17.2.4988734' ndkVersion '17.2.4988734'
defaultConfig { defaultConfig {
applicationId "net.mynero.wallet" applicationId "net.mynero.wallet"
minSdkVersion 21 minSdkVersion 22
targetSdkVersion 34 targetSdkVersion 34
versionCode 50700 versionCode 50800
versionName "0.5.7 'Fluorine Fermi'" versionName "0.5.8 'Fluorine Fermi'"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild { externalNativeBuild {
cmake { cmake {
@ -113,48 +113,27 @@ static def getId(name) {
} }
dependencies { dependencies {
// Android stuff
implementation 'androidx.core:core-ktx:1.12.0' implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.3.2' implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.preference:preference-ktx:1.2.1' implementation 'androidx.preference:preference-ktx:1.2.1'
implementation 'com.google.android.material:material:1.10.0'
implementation 'com.ncorti:slidetoact:0.9.0'
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
implementation "com.jakewharton.timber:timber:5.0.1"
implementation fileTree(dir: 'libs/classes', include: ['*.jar'])
implementation 'org.slf4j:slf4j-nop:1.7.36'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2'
implementation 'androidx.navigation:navigation-fragment-ktx:2.7.5' implementation 'androidx.navigation:navigation-fragment-ktx:2.7.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.7.5' implementation 'androidx.navigation:navigation-ui-ktx:2.7.5'
implementation 'androidx.core:core-ktx:1.12.0' implementation 'androidx.core:core-ktx:1.12.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
// Slide to Send tx sliders
implementation 'com.ncorti:slidetoact:0.9.0'
// QR Code stuff
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
// Tor // Tor
def vTor = '4.8.6-0' def vTor = '4.8.6-0'
def vKmpTor = '1.4.4' def vKmpTor = '1.4.4'
implementation 'io.samourai.code.wallet:android-tor-binary:0.4.7.12'
implementation "io.matthewnelson.kotlin-components:kmp-tor:$vTor-$vKmpTor" implementation "io.matthewnelson.kotlin-components:kmp-tor:$vTor-$vKmpTor"
//noinspection GradleDependency
testImplementation "junit:junit:4.13.2"
testImplementation "org.mockito:mockito-all:1.10.19"
testImplementation "com.squareup.okhttp3:mockwebserver:4.9.3"
testImplementation 'org.json:json:20230227'
testImplementation 'net.jodah:concurrentunit:0.4.6'
}
//https://stackoverflow.com/questions/75274720/a-failure-occurred-while-executing-appcheckdebugduplicateclasses/75315276#75315276
//Not sure why this is needed since Kotlin isn't used in this project...
configurations.implementation {
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
} }

View file

@ -12,7 +12,6 @@
<application <application
android:name=".MoneroApplication" android:name=".MoneroApplication"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher_round" android:icon="@mipmap/ic_launcher_round"
android:label="@string/app_name" android:label="@string/app_name"
android:preserveLegacyExternalStorage="true" android:preserveLegacyExternalStorage="true"

View file

@ -15,12 +15,12 @@
*/ */
package net.mynero.wallet.data package net.mynero.wallet.data
import android.util.Log
import net.mynero.wallet.model.NetworkType import net.mynero.wallet.model.NetworkType
import net.mynero.wallet.model.WalletManager import net.mynero.wallet.model.WalletManager
import net.mynero.wallet.util.OnionHelper import net.mynero.wallet.util.OnionHelper
import org.json.JSONException import org.json.JSONException
import org.json.JSONObject import org.json.JSONObject
import timber.log.Timber
import java.io.UnsupportedEncodingException import java.io.UnsupportedEncodingException
import java.net.InetSocketAddress import java.net.InetSocketAddress
import java.net.URLDecoder import java.net.URLDecoder
@ -93,7 +93,7 @@ class Node {
try { try {
name = URLDecoder.decode(daParts[2], "UTF-8") name = URLDecoder.decode(daParts[2], "UTF-8")
} catch (ex: UnsupportedEncodingException) { } catch (ex: UnsupportedEncodingException) {
Timber.w(ex) // if we can't encode it, we don't use it Log.w("Node.kt", ex) // if we can't encode it, we don't use it
} }
} }
this.name = name this.name = name
@ -224,7 +224,7 @@ class Node {
if (name != null) try { if (name != null) try {
sb.append("/").append(URLEncoder.encode(name, "UTF-8")) sb.append("/").append(URLEncoder.encode(name, "UTF-8"))
} catch (ex: UnsupportedEncodingException) { } catch (ex: UnsupportedEncodingException) {
Timber.w(ex) // if we can't encode it, we don't store it Log.w("Node.kt", ex) // if we can't encode it, we don't store it
} }
return sb.toString() return sb.toString()
} }
@ -254,7 +254,7 @@ class Node {
return try { return try {
Node(nodeString) Node(nodeString)
} catch (ex: IllegalArgumentException) { } catch (ex: IllegalArgumentException) {
Timber.w(ex) Log.w("Node.kt", ex)
null null
} }
} }
@ -263,13 +263,13 @@ class Node {
return try { return try {
Node(jsonObject) Node(jsonObject)
} catch (ex: IllegalArgumentException) { } catch (ex: IllegalArgumentException) {
Timber.w(ex) Log.w("Node.kt", ex)
null null
} catch (ex: UnknownHostException) { } catch (ex: UnknownHostException) {
Timber.w(ex) Log.w("Node.kt", ex)
null null
} catch (ex: JSONException) { } catch (ex: JSONException) {
Timber.w(ex) Log.w("Node.kt", ex)
null null
} }
} }

View file

@ -2,6 +2,7 @@ package net.mynero.wallet.fragment.receive
import android.graphics.Bitmap import android.graphics.Bitmap
import android.os.Bundle import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -18,6 +19,7 @@ import com.google.zxing.EncodeHintType
import com.google.zxing.WriterException import com.google.zxing.WriterException
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 com.journeyapps.barcodescanner.BarcodeEncoder
import net.mynero.wallet.R import net.mynero.wallet.R
import net.mynero.wallet.adapter.SubaddressAdapter import net.mynero.wallet.adapter.SubaddressAdapter
import net.mynero.wallet.adapter.SubaddressAdapter.SubaddressAdapterListener import net.mynero.wallet.adapter.SubaddressAdapter.SubaddressAdapterListener
@ -25,7 +27,6 @@ import net.mynero.wallet.data.Subaddress
import net.mynero.wallet.fragment.dialog.EditAddressLabelBottomSheetDialog import net.mynero.wallet.fragment.dialog.EditAddressLabelBottomSheetDialog
import net.mynero.wallet.fragment.dialog.EditAddressLabelBottomSheetDialog.LabelListener import net.mynero.wallet.fragment.dialog.EditAddressLabelBottomSheetDialog.LabelListener
import net.mynero.wallet.util.Helper.clipBoardCopy import net.mynero.wallet.util.Helper.clipBoardCopy
import timber.log.Timber
import java.nio.charset.StandardCharsets import java.nio.charset.StandardCharsets
import java.util.EnumMap import java.util.EnumMap
@ -125,11 +126,13 @@ class ReceiveFragment : Fragment() {
EnumMap(com.google.zxing.EncodeHintType::class.java) EnumMap(com.google.zxing.EncodeHintType::class.java)
hints[EncodeHintType.CHARACTER_SET] = StandardCharsets.UTF_8 hints[EncodeHintType.CHARACTER_SET] = StandardCharsets.UTF_8
hints[EncodeHintType.ERROR_CORRECTION] = ErrorCorrectionLevel.M hints[EncodeHintType.ERROR_CORRECTION] = ErrorCorrectionLevel.M
try { try {
val bitMatrix = QRCodeWriter().encode(text, BarcodeFormat.QR_CODE, width, height, hints) val barcodeEncoder = BarcodeEncoder()
val pixels = IntArray(width * height) val bitMatrix = barcodeEncoder.encode(text, BarcodeFormat.QR_CODE, width, height, hints)
for (i in 0 until height) { val pixels = IntArray(bitMatrix.width * bitMatrix.height)
for (j in 0 until width) { for (i in 0 until bitMatrix.height) {
for (j in 0 until bitMatrix.width) {
if (bitMatrix[j, i]) { if (bitMatrix[j, i]) {
pixels[i * width + j] = -0x1 pixels[i * width + j] = -0x1
} else { } else {
@ -140,9 +143,9 @@ class ReceiveFragment : Fragment() {
} }
} }
} }
return Bitmap.createBitmap(pixels, 0, width, width, height, Bitmap.Config.RGB_565) return Bitmap.createBitmap(pixels, 0, bitMatrix.width, bitMatrix.width, bitMatrix.height, Bitmap.Config.ARGB_8888)
} catch (ex: WriterException) { } catch (ex: WriterException) {
Timber.e(ex) Log.e("ReceiveFragment.kt", ex.toString())
} }
return null return null
} }

View file

@ -15,7 +15,7 @@
*/ */
package net.mynero.wallet.model package net.mynero.wallet.model
import timber.log.Timber import android.util.Log
class Coins(private val handle: Long) { class Coins(private val handle: Long) {
var all: List<CoinsInfo> = ArrayList() var all: List<CoinsInfo> = ArrayList()
@ -23,7 +23,7 @@ class Coins(private val handle: Long) {
fun refresh() { fun refresh() {
val transactionInfos = refreshJ() val transactionInfos = refreshJ()
Timber.d("refresh size=%d", transactionInfos.size) Log.d("Coins.kt", "refresh size=${transactionInfos.size}")
all = transactionInfos all = transactionInfos
} }

View file

@ -15,7 +15,7 @@
*/ */
package net.mynero.wallet.model package net.mynero.wallet.model
import timber.log.Timber import android.util.Log
class TransactionHistory(private val handle: Long, var accountIndex: Int) { class TransactionHistory(private val handle: Long, var accountIndex: Int) {
var all: List<TransactionInfo> = ArrayList() var all: List<TransactionInfo> = ArrayList()
@ -43,7 +43,7 @@ class TransactionHistory(private val handle: Long, var accountIndex: Int) {
private fun refresh() { private fun refresh() {
val transactionInfos = refreshJ() val transactionInfos = refreshJ()
Timber.d("refresh size=%d", transactionInfos.size) Log.d("TransactionHistory.kt", "refresh size=${transactionInfos.size}")
val iterator = transactionInfos.iterator() val iterator = transactionInfos.iterator()
while (iterator.hasNext()) { while (iterator.hasNext()) {
val info = iterator.next() val info = iterator.next()

View file

@ -15,9 +15,9 @@
*/ */
package net.mynero.wallet.model package net.mynero.wallet.model
import android.util.Log
import net.mynero.wallet.data.Node import net.mynero.wallet.data.Node
import net.mynero.wallet.util.RestoreHeight import net.mynero.wallet.util.RestoreHeight
import timber.log.Timber
import java.io.File import java.io.File
import java.util.Calendar import java.util.Calendar
import java.util.Locale import java.util.Locale
@ -35,7 +35,7 @@ class WalletManager {
private set private set
private fun manageWallet(wallet: Wallet) { private fun manageWallet(wallet: Wallet) {
Timber.d("Managing %s", wallet.name) Log.d("WalletManager.kt", "Managing ${wallet.name}")
this.wallet = wallet this.wallet = wallet
} }
@ -43,7 +43,7 @@ class WalletManager {
requireNotNull(wallet) { "Cannot unmanage null!" } requireNotNull(wallet) { "Cannot unmanage null!" }
checkNotNull(this.wallet) { "No wallet under management!" } checkNotNull(this.wallet) { "No wallet under management!" }
check(this.wallet === wallet) { wallet.name + " not under management!" } check(this.wallet === wallet) { wallet.name + " not under management!" }
Timber.d("Unmanaging %s", wallet.name) Log.d("WalletManager.kt", "Unmanaging ${wallet.name}")
this.wallet = null this.wallet = null
} }
@ -62,9 +62,9 @@ class WalletManager {
if (restoreHeight != null) { if (restoreHeight != null) {
wallet.setRestoreHeight(restoreHeight) wallet.setRestoreHeight(restoreHeight)
} }
Timber.d("Changed Restore Height from %d to %d", oldHeight, wallet.getRestoreHeight()) Log.d("WalletManager.kt", "Changed Restore Height from $oldHeight to ${wallet.getRestoreHeight()}")
wallet.setPassword(password) // this rewrites the keys file (which contains the restore height) wallet.setPassword(password) // this rewrites the keys file (which contains the restore height)
} else Timber.e(wallet.status.toString()) } else Log.e("WalletManager.kt", wallet.status.toString())
return wallet return wallet
} }
@ -93,7 +93,7 @@ class WalletManager {
manageWallet(wallet) manageWallet(wallet)
if (wallet.status.isOk) { if (wallet.status.isOk) {
wallet.setPassword(password) // this rewrites the keys file (which contains the restore height) wallet.setPassword(password) // this rewrites the keys file (which contains the restore height)
} else Timber.e(wallet.status.toString()) } else Log.e("WalletManager.kt", wallet.status.toString())
return wallet return wallet
} }
@ -235,27 +235,7 @@ class WalletManager {
return queryWalletDeviceJ(keysFileName, password) >= 0 return queryWalletDeviceJ(keysFileName, password) >= 0
} }
fun queryWalletDevice(keysFileName: String, password: String): Wallet.Device {
val device = queryWalletDeviceJ(keysFileName, password)
return Wallet.Device.values()[device + 1] // mapping is monero+1=android
}
private external fun queryWalletDeviceJ(keysFileName: String, password: String): Int private external fun queryWalletDeviceJ(keysFileName: String, password: String): Int
fun findWallets(path: File): List<WalletInfo> {
val wallets: MutableList<WalletInfo> = ArrayList()
Timber.d("Scanning: %s", path.absolutePath)
val found =
path.listFiles { _, filename -> filename.endsWith(".keys") } ?: return emptyList()
for (i in found.indices) {
val filename = found[i].name
val f = File(
found[i].parent,
filename.substring(0, filename.length - 5)
) // 5 is length of ".keys"+1
wallets.add(WalletInfo(f))
}
return wallets
}
// this should not be called on the main thread as it connects to the node (and takes a long time) // this should not be called on the main thread as it connects to the node (and takes a long time)
fun setDaemon(node: Node?) { fun setDaemon(node: Node?) {

View file

@ -16,6 +16,7 @@
*/ */
package net.mynero.wallet.service package net.mynero.wallet.service
import android.util.Log
import net.mynero.wallet.model.PendingTransaction import net.mynero.wallet.model.PendingTransaction
import net.mynero.wallet.model.TransactionOutput import net.mynero.wallet.model.TransactionOutput
import net.mynero.wallet.model.Wallet import net.mynero.wallet.model.Wallet
@ -25,7 +26,6 @@ import net.mynero.wallet.model.Wallet.ConnectionStatus
import net.mynero.wallet.model.WalletListener import net.mynero.wallet.model.WalletListener
import net.mynero.wallet.model.WalletManager import net.mynero.wallet.model.WalletManager
import net.mynero.wallet.util.Constants import net.mynero.wallet.util.Constants
import timber.log.Timber
import java.security.SecureRandom import java.security.SecureRandom
/** /**
@ -93,7 +93,7 @@ class MoneroHandlerThread(name: String, val listener: Listener?, wallet: Wallet)
if (heightDiff >= 2) { if (heightDiff >= 2) {
tryRestartConnection() tryRestartConnection()
} else { } else {
Timber.d("refreshed() Synchronized") Log.d("MoneroHandlerThread.kt", "refreshed() Synchronized")
wallet.setSynchronized() wallet.setSynchronized()
wallet.store() wallet.store()
refresh(true) refresh(true)
@ -103,7 +103,7 @@ class MoneroHandlerThread(name: String, val listener: Listener?, wallet: Wallet)
} }
private fun tryRestartConnection() { private fun tryRestartConnection() {
Timber.d("refreshed() Starting connection retry") Log.d("MoneroHandlerThread.kt", "refreshed() Starting connection retry")
listener?.onConnectionFail() listener?.onConnectionFail()
wallet.init(0) wallet.init(0)
wallet.startRefresh() wallet.startRefresh()

View file

@ -29,16 +29,14 @@ import android.graphics.Canvas
import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.VectorDrawable import android.graphics.drawable.VectorDrawable
import android.os.Build import android.os.Build
import android.util.Log
import android.view.WindowManager import android.view.WindowManager
import android.view.animation.Animation import android.view.animation.Animation
import android.view.animation.AnimationUtils
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import android.widget.Toast import android.widget.Toast
import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.ActivityResultLauncher
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import net.mynero.wallet.R import net.mynero.wallet.R
import net.mynero.wallet.model.WalletManager
import timber.log.Timber
import java.io.File import java.io.File
import java.io.IOException import java.io.IOException
import java.io.InputStreamReader import java.io.InputStreamReader
@ -69,12 +67,12 @@ object Helper {
fun getStorage(context: Context, folderName: String?): File { fun getStorage(context: Context, folderName: String?): File {
val dir = File(context.filesDir, folderName) val dir = File(context.filesDir, folderName)
if (!dir.exists()) { if (!dir.exists()) {
Timber.i("Creating %s", dir.absolutePath) Log.i("Helper.kt", "Creating ${dir.absolutePath}")
dir.mkdirs() // try to make it dir.mkdirs() // try to make it
} }
if (!dir.isDirectory) { if (!dir.isDirectory) {
val msg = "Directory " + dir.absolutePath + " does not exist." val msg = "Directory " + dir.absolutePath + " does not exist."
Timber.e(msg) Log.e("Helper.kt",msg)
throw IllegalStateException(msg) throw IllegalStateException(msg)
} }
return dir return dir
@ -85,7 +83,7 @@ object Helper {
if (context.checkSelfPermission(Manifest.permission.CAMERA) if (context.checkSelfPermission(Manifest.permission.CAMERA)
== PackageManager.PERMISSION_DENIED == PackageManager.PERMISSION_DENIED
) { ) {
Timber.w("Permission denied for CAMERA - requesting it") Log.w("Helper.kt", "Permission denied for CAMERA - requesting it")
val permissions = arrayOf(Manifest.permission.CAMERA) val permissions = arrayOf(Manifest.permission.CAMERA)
context.requestPermissions( context.requestPermissions(
permissions, permissions,
@ -105,7 +103,7 @@ object Helper {
if (context.checkSelfPermission(Manifest.permission.CAMERA) if (context.checkSelfPermission(Manifest.permission.CAMERA)
== PackageManager.PERMISSION_DENIED == PackageManager.PERMISSION_DENIED
) { ) {
Timber.w("Permission denied for CAMERA - requesting it") Log.w("Helper.kt", "Permission denied for CAMERA - requesting it")
launcher.launch(Manifest.permission.CAMERA) launcher.launch(Manifest.permission.CAMERA)
false false
} else { } else {
@ -119,7 +117,7 @@ object Helper {
fun getWalletFile(context: Context, aWalletName: String?): File { fun getWalletFile(context: Context, aWalletName: String?): File {
val walletDir = getWalletRoot(context) val walletDir = getWalletRoot(context)
val f = File(walletDir, aWalletName) val f = File(walletDir, aWalletName)
Timber.d("wallet=%s size= %d", f.absolutePath, f.length()) Log.d("Helper.kt", "wallet=${f.absolutePath} size= ${f.length()}")
return f return f
} }
@ -230,11 +228,11 @@ object Helper {
} }
return sb.toString() return sb.toString()
} catch (ex: SocketTimeoutException) { } catch (ex: SocketTimeoutException) {
Timber.w("C %s", ex.localizedMessage) Log.w("Helper.kt", "C ${ex.localizedMessage}")
} catch (ex: MalformedURLException) { } catch (ex: MalformedURLException) {
Timber.e("A %s", ex.localizedMessage) Log.e("Helper.kt","A ${ex.localizedMessage}")
} catch (ex: IOException) { } catch (ex: IOException) {
Timber.e("B %s", ex.localizedMessage) Log.e("Helper.kt","B ${ex.localizedMessage}")
} finally { } finally {
urlConnection?.disconnect() urlConnection?.disconnect()
} }