diff --git a/app/build.gradle b/app/build.gradle index 8e9f615bb..ce08dc265 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,6 +6,7 @@ apply plugin: "kotlin-android" apply plugin: "kotlin-kapt" apply from: "../download-libwallet.gradle" apply plugin: "io.sentry.android.gradle" +apply plugin: "kotlin-parcelize" android { namespace "com.tari.android.wallet" @@ -37,6 +38,7 @@ android { buildConfigField("String", "YAT_ORGANIZATION_RETURN_URL", "\"${yatProperties.getProperty("yat.returnUrl")}\"") def dropboxProperties = loadDropboxProps() buildConfigField("String", "DROPBOX_ACCESS_TOKEN", "\"${dropboxProperties.getProperty("dropbox_key")}\"") + buildConfigField("String", "LIB_WALLET_MIN_VALID_VERSION", "\"$libwalletMinValidVersion\"") } flavorDimensions.add("privacy-mode") diff --git a/app/src/main/java/com/tari/android/wallet/application/MigrationManager.kt b/app/src/main/java/com/tari/android/wallet/application/MigrationManager.kt index 2d1da2e82..7c5ba7866 100644 --- a/app/src/main/java/com/tari/android/wallet/application/MigrationManager.kt +++ b/app/src/main/java/com/tari/android/wallet/application/MigrationManager.kt @@ -1,6 +1,7 @@ package com.tari.android.wallet.application import androidx.lifecycle.viewModelScope +import com.tari.android.wallet.BuildConfig import com.tari.android.wallet.ui.common.SimpleViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -11,13 +12,12 @@ import javax.inject.Singleton @Singleton class MigrationManager @Inject constructor(private val manager: WalletManager) { - private val minValidVersion = DefaultArtifactVersion("v0.52.0") private val simpleViewModel = SimpleViewModel() fun validateVersion(onValid: () -> Unit, onError: () -> Unit) { val walletVersion = getCurrentWalletVersion() - if (walletVersion.isEmpty() || DefaultArtifactVersion(walletVersion) < minValidVersion) { + if (walletVersion.isEmpty() || DefaultArtifactVersion(walletVersion) < DefaultArtifactVersion(BuildConfig.LIB_WALLET_MIN_VALID_VERSION)) { simpleViewModel.viewModelScope.launch(Dispatchers.Main) { onError() } } else { simpleViewModel.viewModelScope.launch(Dispatchers.Main) { onValid() } diff --git a/app/src/main/java/com/tari/android/wallet/application/baseNodes/BaseNodes.kt b/app/src/main/java/com/tari/android/wallet/application/baseNodes/BaseNodes.kt index 6652be265..fc614fbf0 100644 --- a/app/src/main/java/com/tari/android/wallet/application/baseNodes/BaseNodes.kt +++ b/app/src/main/java/com/tari/android/wallet/application/baseNodes/BaseNodes.kt @@ -20,11 +20,16 @@ import com.tari.android.wallet.service.connection.TariWalletServiceConnection import io.reactivex.disposables.CompositeDisposable import org.apache.commons.io.IOUtils +private const val REGEX_ONION = "(.+::[A-Za-z0-9 ]{64}::/onion3/[A-Za-z0-9]+:[\\d]+)" +private const val REGEX_IPV4 = "(.+::[A-Za-z0-9 ]{64}::/ip4/[0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}/tcp/[0-9]{2,6})" + class BaseNodes( private val context: Context, private val baseNodeSharedRepository: BaseNodeSharedRepository, private val networkRepository: NetworkRepository, ) { + private val logger = Logger.t(this::class.simpleName) + private val compositeDisposable = CompositeDisposable() private val serviceConnection = TariWalletServiceConnection() @@ -45,9 +50,6 @@ class BaseNodes( }.addTo(compositeDisposable) } - val onionRegex = "(.+::[A-Za-z0-9 ]{64}::/onion3/[A-Za-z0-9]+:[\\d]+)" - val ipV4Regex = "(.+::[A-Za-z0-9 ]{64}::/ip4/[0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}/tcp/[0-9]{2,6})" - /** * Returns the list of base nodes in the resource file base_nodes.txt as pairs of * ({name}, {public_key_hex}, {public_address}). @@ -57,10 +59,10 @@ class BaseNodes( context.resources.openRawResource(getBaseNodeResource(networkRepository.currentNetwork!!.network)), "UTF-8" ) - Logger.t(this::class.simpleName).e("baseNodeList: $fileContent") + logger.i("baseNodeList: $fileContent") val list = mutableListOf() - val onionBaseNodes = findAndAddBaseNode(fileContent, onionRegex).toList() - val ipV4BaseNodes = findAndAddBaseNode(fileContent, ipV4Regex).toList() + val onionBaseNodes = findAndAddBaseNode(fileContent, REGEX_ONION).toList() + val ipV4BaseNodes = findAndAddBaseNode(fileContent, REGEX_IPV4).toList() list.addAll(onionBaseNodes) list.addAll(ipV4BaseNodes) list.sortedBy { it.name } @@ -68,9 +70,9 @@ class BaseNodes( private fun findAndAddBaseNode(fileContent: String, regex: String): Sequence { return Regex(regex).findAll(fileContent).map { matchResult -> - val tripleString = matchResult.value.split("::") - Logger.t(this::class.simpleName).i("baseNodeList0: $tripleString, baseNodeList1: ${tripleString[1]}, baseNodeList2: ${tripleString[2]}") - BaseNodeDto(tripleString[0], tripleString[1], tripleString[2]) + val (name, publicKeyHex, address) = matchResult.value.split("::") + logger.i("baseNodeList0: $name, baseNodeList1: $publicKeyHex, baseNodeList2: $address") + BaseNodeDto(name, publicKeyHex, address) } } @@ -95,21 +97,21 @@ class BaseNodes( fun startSync() { try { - Logger.t(this::class.simpleName).i("startSync") + logger.i("startSync") //essential for wallet creation flow val baseNode = baseNodeSharedRepository.currentBaseNode ?: return serviceConnection.currentState.service ?: return if (EventBus.walletState.publishSubject.value != WalletState.Running) return - Logger.t(this::class.simpleName).i("startSync:publicKeyHex: ${baseNode.publicKeyHex}") - Logger.t(this::class.simpleName).i("startSync:address: ${baseNode.address}") - Logger.t(this::class.simpleName).i("startSync:address: ${Gson().toJson(baseNodeSharedRepository.userBaseNodes)}") + logger.i("startSync:publicKeyHex: ${baseNode.publicKeyHex}") + logger.i("startSync:address: ${baseNode.address}") + logger.i("startSync:userBaseNodes: ${Gson().toJson(baseNodeSharedRepository.userBaseNodes)}") val baseNodeKeyFFI = FFIPublicKey(HexString(baseNode.publicKeyHex)) FFIWallet.instance?.addBaseNodePeer(baseNodeKeyFFI, baseNode.address) baseNodeKeyFFI.destroy() walletService.getWithError { error, wallet -> wallet.startBaseNodeSync(error) } } catch (e: Throwable) { - Logger.t(this::class.simpleName).i("startSync") + logger.i("startSync:error connecting to base node: ${e.message}") setNextBaseNode() startSync() } diff --git a/app/src/main/java/com/tari/android/wallet/ui/common/CommonFragment.kt b/app/src/main/java/com/tari/android/wallet/ui/common/CommonFragment.kt index 47a3ab559..5bf9b07db 100644 --- a/app/src/main/java/com/tari/android/wallet/ui/common/CommonFragment.kt +++ b/app/src/main/java/com/tari/android/wallet/ui/common/CommonFragment.kt @@ -79,6 +79,7 @@ abstract class CommonFragment : Fra override fun onResume() { super.onResume() + if (!isAdded) return if (blockScreenRecording) { requireActivity().window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE) diff --git a/app/src/main/java/com/tari/android/wallet/ui/common/recyclerView/CommonAdapter.kt b/app/src/main/java/com/tari/android/wallet/ui/common/recyclerView/CommonAdapter.kt index bad5bab7f..159db6e0e 100644 --- a/app/src/main/java/com/tari/android/wallet/ui/common/recyclerView/CommonAdapter.kt +++ b/app/src/main/java/com/tari/android/wallet/ui/common/recyclerView/CommonAdapter.kt @@ -11,7 +11,7 @@ abstract class CommonAdapter : ListAdapter - fun update(newItems: MutableList) { + fun update(newItems: List) { submitList(newItems.toList()) } diff --git a/app/src/main/java/com/tari/android/wallet/ui/fragment/onboarding/localAuth/LocalAuthFragment.kt b/app/src/main/java/com/tari/android/wallet/ui/fragment/onboarding/localAuth/LocalAuthFragment.kt index a6387159e..2908d6446 100644 --- a/app/src/main/java/com/tari/android/wallet/ui/fragment/onboarding/localAuth/LocalAuthFragment.kt +++ b/app/src/main/java/com/tari/android/wallet/ui/fragment/onboarding/localAuth/LocalAuthFragment.kt @@ -40,6 +40,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.viewModels +import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import com.daasuu.ei.Ease import com.daasuu.ei.EasingInterpolator @@ -49,7 +50,7 @@ import com.tari.android.wallet.application.WalletState import com.tari.android.wallet.databinding.FragmentLocalAuthBinding import com.tari.android.wallet.event.EventBus import com.tari.android.wallet.extension.addTo -import com.tari.android.wallet.extension.observe +import com.tari.android.wallet.extension.launchAndRepeatOnLifecycle import com.tari.android.wallet.infrastructure.security.biometric.BiometricAuthenticationException import com.tari.android.wallet.ui.common.CommonFragment import com.tari.android.wallet.ui.extension.doOnGlobalLayout @@ -78,11 +79,15 @@ class LocalAuthFragment : CommonFragment + ui.continueBtn.setVisible(state.pinCodeSecured) + ui.authTypeBiometrics.setVisible(state.biometricsAvailable) + ui.secureWithPasscode.setVisible(!state.pinCodeSecured) + ui.secureWithBiometrics.setVisible(state.biometricsAvailable && !state.biometricsSecured) + } + } } } @@ -122,10 +127,11 @@ class LocalAuthFragment : CommonFragment() val openYatOnboarding: LiveData = _openYatOnboarding - private val _allSettingsOptions = MutableLiveData>() - val allSettingsOptions: LiveData> = _allSettingsOptions + private val _allSettingsOptions = MutableLiveData>() + val allSettingsOptions: LiveData> = _allSettingsOptions init { component.inject(this) @@ -141,7 +145,7 @@ class AllSettingsViewModel : CommonViewModel() { val alias = settingsRepository.name.orEmpty() + " " + settingsRepository.surname.orEmpty() val pinCode = securityPrefRepository.pinCode - val allOptions = mutableListOf( + _allSettingsOptions.postValue(listOfNotNull( MyProfileViewHolderItem(settingsRepository.emojiId.orEmpty(), yatSharedPrefsRepository.connectedYat.orEmpty(), alias) { navigation.postValue(AllSettingsNavigation.ToMyProfile) }, @@ -208,9 +212,9 @@ class AllSettingsViewModel : CommonViewModel() { _openLink.postValue(resourceManager.getString(disclaimer_url)) }, DividerViewHolderItem(), -// ButtonViewDto(resourceManager.getString(all_settings_explorer), vector_all_settings_block_explorer_icon) { -// _openLink.postValue(resourceManager.getString(explorer_url)) -// }, + SettingsRowViewDto(resourceManager.getString(all_settings_explorer), vector_all_settings_block_explorer_icon) { + _openLink.postValue(resourceManager.getString(explorer_url)) + }.takeIf { DebugConfig.isBlockExplorerEnabled }, SettingsTitleViewHolderItem(resourceManager.getString(all_settings_advanced_settings_label)), SettingsRowViewDto(resourceManager.getString(all_settings_select_theme), vector_all_settings_select_theme_icon) { navigation.postValue(AllSettingsNavigation.ToThemeSelection) @@ -251,9 +255,8 @@ class AllSettingsViewModel : CommonViewModel() { style = SettingsRowStyle.Warning, ) { navigation.postValue(AllSettingsNavigation.ToDeleteWallet) }, DividerViewHolderItem(), - SettingsVersionViewHolderItem(versionText) { _copyToClipboard.postValue(versionArgs) } + SettingsVersionViewHolderItem(versionText) { _copyToClipboard.postValue(versionArgs) }) ) - _allSettingsOptions.postValue(allOptions) } private fun onBackupStateChanged(backupState: BackupsState?) { diff --git a/app/src/main/java/com/tari/android/wallet/ui/fragment/tx/details/TxDetailsFragment.kt b/app/src/main/java/com/tari/android/wallet/ui/fragment/tx/details/TxDetailsFragment.kt index 0e7803aca..1c28855eb 100644 --- a/app/src/main/java/com/tari/android/wallet/ui/fragment/tx/details/TxDetailsFragment.kt +++ b/app/src/main/java/com/tari/android/wallet/ui/fragment/tx/details/TxDetailsFragment.kt @@ -107,6 +107,7 @@ import com.tari.android.wallet.ui.fragment.contact_book.data.contacts.ContactDto import com.tari.android.wallet.ui.fragment.tx.details.gif.GIFView import com.tari.android.wallet.ui.fragment.tx.details.gif.GIFViewModel import com.tari.android.wallet.ui.fragment.tx.details.gif.TxState +import com.tari.android.wallet.util.DebugConfig import com.tari.android.wallet.util.WalletUtil import java.util.Date @@ -161,7 +162,11 @@ class TxDetailsFragment : CommonFragment + if (DebugConfig.isBlockExplorerEnabled) { + showExplorerLink(link) + } + } } private fun updateContactInfo(contact: ContactDto) { diff --git a/app/src/main/java/com/tari/android/wallet/util/DebugConfig.kt b/app/src/main/java/com/tari/android/wallet/util/DebugConfig.kt index 9e1655dd3..c1a536c99 100644 --- a/app/src/main/java/com/tari/android/wallet/util/DebugConfig.kt +++ b/app/src/main/java/com/tari/android/wallet/util/DebugConfig.kt @@ -49,6 +49,8 @@ object DebugConfig { private const val _useYatSandbox = false val yatEnvironment = if (_useYatSandbox && isDebug()) YatEnvironment.SANDBOX else YatEnvironment.PRODUCTION + val isBlockExplorerEnabled = false + private fun isDebug() = BuildConfig.BUILD_TYPE == "debug" } diff --git a/app/src/main/res/raw/nextnet_base_nodes.txt b/app/src/main/res/raw/nextnet_base_nodes.txt index dd4490ce8..785d25cae 100644 --- a/app/src/main/res/raw/nextnet_base_nodes.txt +++ b/app/src/main/res/raw/nextnet_base_nodes.txt @@ -1,3 +1,6 @@ -NextNet 01::0cff11dff44458bfea3e39444d440e54260746ff2a5ce6a6c3f7355decff2167::/ip4/54.195.217.107/tcp/18189 -NextNet 02::0cff11dff44458bfea3e39444d440e54260746ff2a5ce6a6c3f7355decff2167::/onion3/h6oj2cusgtaxo63zbfw2wjir4mltkqzz4jquoak2i5mvgyszaieowwad:18141 -NextNet 03::4c236de788e803ef9615f72a4d973cf3f8a9b83c9d2fb176cbaf65c1b0442572::/onion3/3jtk3e2ud3zqtbrq36sw6ata6u5epkjmqgr5tfuemcfpyhisrzkgbtyd:18141 \ No newline at end of file +NextNet 1::0cff11dff44458bfea3e39444d440e54260746ff2a5ce6a6c3f7355decff2167::/ip4/54.195.217.107/tcp/18189 +NextNet 2::0cff11dff44458bfea3e39444d440e54260746ff2a5ce6a6c3f7355decff2167::/onion3/cmdlunlzessyz7snnat6ktxwmcl7bubvfzneb7ljva4w4izcmlqyc2id:18141 +NextNet 3::2caf4be53523ecf2b71ca23db33f7df590fd41792b2d14c2bb0bbebe1b2c4b52::/ip4/34.254.114.227/tcp/18189 +NextNet 4::2caf4be53523ecf2b71ca23db33f7df590fd41792b2d14c2bb0bbebe1b2c4b52::/onion3/wi2teiwyyq33jwblcuy7anmja6d7iyuciyrzbwumvldeiw73d6ce5ryd:18141 +NextNet 5::4c236de788e803ef9615f72a4d973cf3f8a9b83c9d2fb176cbaf65c1b0442572::/ip4/52.210.35.123/tcp/18189 +NextNet 6::4c236de788e803ef9615f72a4d973cf3f8a9b83c9d2fb176cbaf65c1b0442572::/onion3/7gwfakr7ko5uo3fl3yz3fsjc7elccbzter5botggodrmmwi2exm3vbid:18141 \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 58b3984a4..ef75d6f5e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -11,8 +11,8 @@ https://www.tari.com/user_agreement/ https://www.tari.com/privacy_policy/ https://www.tari.com/disclaimer/ - https://explore-esme.tari.com/ - https://explore-esme.tari.com/kernel/ + https://explore.tari.com/ + https://explore.tari.com/kernel/ https://bridges.torproject.org/bridges https://tlu.tarilabs.com/ diff --git a/build.gradle b/build.gradle index 6b519af00..4067b3ef8 100644 --- a/build.gradle +++ b/build.gradle @@ -6,12 +6,13 @@ buildscript { ext.lifecycle_version = '2.6.2' // build & version - ext.buildNumber = 288 - ext.versionNumber = "0.25.2" + ext.buildNumber = 290 + ext.versionNumber = "0.25.3" // JNI libs ext.libwalletHostURL = "https://github.com/tari-project/tari/releases/download/" ext.libwalletVersion = "v1.0.0-rc.5" + ext.libwalletMinValidVersion = "v1.0.0-rc.5" ext.libwalletx64A = "libminotari_wallet_ffi.android_x86_64.a" ext.libwalletArmA = "libminotari_wallet_ffi.android_aarch64.a" ext.libwalletHeader = "libminotari_wallet_ffi.h"