Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: exported activity fix #1048

Merged
merged 3 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,10 @@ dependencies {

implementation "com.dropbox.core:dropbox-core-sdk:5.4.6"

// implementation "com.github.yat-labs:yat-lib-android:0.1.42"
implementation project(":yatlib")
// It's recommended to use the latest version of the library from the JitPack repository,
// but you can also use a locally build version of the library by using the ":yatlib" module and `yat-lib-debug-snapshot.aar` file with your build
implementation "com.github.tari-project:yat-lib-android:0.4.1"
// implementation project(":yatlib")

// custom libraries region
// flex layout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.viewbinding.ViewBinding
import com.tari.android.wallet.BuildConfig
import com.tari.android.wallet.R
import com.tari.android.wallet.di.DiContainer
import com.tari.android.wallet.extension.observe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import com.tari.android.wallet.extension.observe
import com.tari.android.wallet.infrastructure.security.biometric.BiometricAuthenticationException
import com.tari.android.wallet.ui.common.CommonFragment
import com.tari.android.wallet.ui.extension.string
import com.tari.android.wallet.util.TariBuild.MOCKED
import com.tari.android.wallet.util.DebugConfig
import kotlinx.coroutines.launch

class ChangeBiometricsFragment : CommonFragment<FragmentChangeBiometricsBinding, ChangeBiometricsViewModel>() {
Expand Down Expand Up @@ -45,7 +45,7 @@ class ChangeBiometricsFragment : CommonFragment<FragmentChangeBiometricsBinding,
viewModel.startAuth(isTurningOn)
lifecycleScope.launch {
try {
if (!MOCKED) {
if (!DebugConfig.mockedDataEnabled) {
// prompt system authentication dialog
viewModel.authService.authenticate(
this@ChangeBiometricsFragment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import androidx.lifecycle.MutableLiveData
import com.tari.android.wallet.extension.addTo
import com.tari.android.wallet.model.TariWalletAddress
import com.tari.android.wallet.ui.common.CommonViewModel
import com.tari.android.wallet.util.TariBuild
import com.tari.android.wallet.util.DebugConfig
import com.tari.android.wallet.util.MockDataStub
import java.util.UUID
import javax.inject.Inject
import javax.inject.Singleton
Expand All @@ -25,7 +26,7 @@ class ChatsRepository @Inject constructor(private val chatsPrefRepository: Chats
private fun updateList() {
val list = chatsPrefRepository.getSavedChats().toMutableList()

if (TariBuild.MOCKED && list.isEmpty()) {
if (DebugConfig.mockedDataEnabled && list.isEmpty()) {
val mockedList = mutableListOf(
ChatItemDto(
UUID.randomUUID().toString(),
Expand All @@ -38,7 +39,7 @@ class ChatsRepository @Inject constructor(private val chatsPrefRepository: Chats
false
)
),
TariBuild.mocked_wallet_address
MockDataStub.WALLET_ADDRESS
),
ChatItemDto(
UUID.randomUUID().toString(),
Expand All @@ -51,7 +52,7 @@ class ChatsRepository @Inject constructor(private val chatsPrefRepository: Chats
false
)
),
TariBuild.mocked_wallet_address
MockDataStub.WALLET_ADDRESS
),
ChatItemDto(
UUID.randomUUID().toString(),
Expand All @@ -64,7 +65,7 @@ class ChatsRepository @Inject constructor(private val chatsPrefRepository: Chats
true
)
),
TariBuild.mocked_wallet_address
MockDataStub.WALLET_ADDRESS
),
ChatItemDto(
UUID.randomUUID().toString(),
Expand All @@ -77,7 +78,7 @@ class ChatsRepository @Inject constructor(private val chatsPrefRepository: Chats
true
)
),
TariBuild.mocked_wallet_address
MockDataStub.WALLET_ADDRESS
),
ChatItemDto(
UUID.randomUUID().toString(),
Expand All @@ -90,7 +91,7 @@ class ChatsRepository @Inject constructor(private val chatsPrefRepository: Chats
false
)
),
TariBuild.mocked_wallet_address
MockDataStub.WALLET_ADDRESS
),
ChatItemDto(
UUID.randomUUID().toString(),
Expand All @@ -103,7 +104,7 @@ class ChatsRepository @Inject constructor(private val chatsPrefRepository: Chats
false
)
),
TariBuild.mocked_wallet_address
MockDataStub.WALLET_ADDRESS
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ import com.tari.android.wallet.ui.fragment.splash.SplashActivity
import com.tari.android.wallet.ui.fragment.store.StoreFragment
import com.tari.android.wallet.ui.fragment.tx.HomeFragment
import com.tari.android.wallet.util.Constants
import com.tari.android.wallet.util.TariBuild
import com.tari.android.wallet.util.DebugConfig
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -269,20 +269,20 @@ class HomeActivity : CommonActivity<ActivityHomeBinding, HomeViewModel>() {

private fun setupBottomNavigation() {
enableNavigationView(ui.homeImageView)
ui.viewPager.adapter = if (TariBuild.isChat) HomeChatAdapter(supportFragmentManager, this.lifecycle)
ui.viewPager.adapter = if (DebugConfig.isChatEnabled) HomeChatAdapter(supportFragmentManager, this.lifecycle)
else HomeStoreAdapter(supportFragmentManager, this.lifecycle)
ui.viewPager.isUserInputEnabled = false
ui.viewPager.offscreenPageLimit = 3
ui.homeView.setOnClickListener {
ui.viewPager.setCurrentItem(INDEX_HOME, NO_SMOOTH_SCROLL)
enableNavigationView(ui.homeImageView)
}
ui.storeImageView.setImageResource(if (TariBuild.isChat) R.drawable.vector_home_book else R.drawable.vector_ttl_store_icon)
ui.storeImageView.setImageResource(if (DebugConfig.isChatEnabled) R.drawable.vector_home_book else R.drawable.vector_ttl_store_icon)
ui.storeView.setOnClickListener {
ui.viewPager.setCurrentItem(INDEX_CONTACT_BOOK, NO_SMOOTH_SCROLL)
enableNavigationView(ui.storeImageView)
}
ui.chatImageView.setImageResource(if (TariBuild.isChat) R.drawable.vector_home_chat else R.drawable.vector_home_book)
ui.chatImageView.setImageResource(if (DebugConfig.isChatEnabled) R.drawable.vector_home_chat else R.drawable.vector_home_book)
ui.chatView.setOnClickListener {
ui.viewPager.setCurrentItem(INDEX_CHAT, NO_SMOOTH_SCROLL)
enableNavigationView(ui.chatImageView)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,13 @@ class AddAmountFragment : CommonFragment<FragmentAddAmountBinding, AddAmountView

val amount = keyboardController.currentAmount
if (error == WalletError.NoError && fee != null) {
if (amount > balanceInfo.availableBalance && !TariBuild.MOCKED) {
if (amount > balanceInfo.availableBalance && !DebugConfig.mockedDataEnabled) {
lifecycleScope.launch(Dispatchers.Main) {
actualBalanceExceeded()
}
} else {
lifecycleScope.launch(Dispatchers.Main) {
if (fee > amount && !TariBuild.MOCKED) {
if (fee > amount && !DebugConfig.mockedDataEnabled) {
val args = ErrorDialogArgs(
string(error_fee_more_than_amount_title),
string(error_fee_more_than_amount_description)
Expand Down Expand Up @@ -292,7 +292,7 @@ class AddAmountFragment : CommonFragment<FragmentAddAmountBinding, AddAmountView

updateBalanceInfo()

if (!TariBuild.MOCKED && (keyboardController.currentAmount + viewModel.selectedFeeData?.calculatedFee!!) > availableBalance) {
if (!DebugConfig.mockedDataEnabled && (keyboardController.currentAmount + viewModel.selectedFeeData?.calculatedFee!!) > availableBalance) {
showErrorState()
} else {
showSuccessState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.os.Bundle
import androidx.activity.viewModels
import androidx.lifecycle.lifecycleScope
import com.google.gson.Gson
import com.orhanobut.logger.Logger
import com.tari.android.wallet.extension.observe
import com.tari.android.wallet.extension.observeOnLoad
import com.tari.android.wallet.ui.fragment.send.common.TransactionData
Expand All @@ -17,18 +18,27 @@ class YatFinalizeSendTxActivity : YatLibOutcomingTransactionActivity() {

val viewModel: FinalizeSendTxViewModel by viewModels()

private val logger
get() = Logger.t(YatFinalizeSendTxActivity::class.simpleName)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

val gson = intent.getStringExtra(FinalizeSendTxViewModel.transactionDataKey)!!
val entity = Gson().fromJson(gson, TransactionData::class.java)

viewModel.transactionData = entity
intent.getStringExtra(FinalizeSendTxViewModel.transactionDataKey)
?.let { Gson().fromJson(it, TransactionData::class.java) }
?.let { entity ->
viewModel.transactionData = entity

subscribeOnUI()
launchObserver()
subscribeOnUI()
launchObserver()
} ?: run {
logger.e("Transaction data is null. Finishing activity.")
finish()
return
}
}


private fun subscribeOnUI() = with(viewModel) {
observe(txFailureReason) { setTransactionState(TransactionState.Failed) }

Expand All @@ -52,6 +62,6 @@ class YatFinalizeSendTxActivity : YatLibOutcomingTransactionActivity() {
super.onStop()
viewModel.sentTxId.value?.let { viewModel.tariNavigator.onSendTxSuccessful(true, it) }

viewModel.txFailureReason.value?.let {viewModel.tariNavigator.onSendTxFailure(true, it) }
viewModel.txFailureReason.value?.let { viewModel.tariNavigator.onSendTxFailure(true, it) }
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.tari.android.wallet.ui.fragment.settings.backup.verifySeedPhrase

import com.tari.android.wallet.util.TariBuild
import com.tari.android.wallet.util.DebugConfig

class SeedPhrase(private val seedWords: List<String>) : Iterable<String> {
val length
get() = seedWords.size

private fun sorted(): SeedPhrase = SeedPhrase(if (TariBuild.MOCKED) seedWords else seedWords.sorted())
private fun sorted(): SeedPhrase = SeedPhrase(if (DebugConfig.mockedDataEnabled) seedWords else seedWords.sorted())

fun consistsOf(result: List<String>): Boolean = seedWords == result

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import com.tari.android.wallet.ui.common.recyclerView.CommonViewHolderItem
import com.tari.android.wallet.ui.common.recyclerView.items.TitleViewHolderItem
import com.tari.android.wallet.ui.fragment.contact_book.data.ContactsRepository
import com.tari.android.wallet.ui.fragment.tx.adapter.TransactionItem
import com.tari.android.wallet.util.TariBuild
import com.tari.android.wallet.util.TariBuild.MOCKED
import com.tari.android.wallet.util.DebugConfig
import com.tari.android.wallet.util.MockDataStub
import io.reactivex.BackpressureStrategy
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -173,7 +173,7 @@ class TransactionRepository @Inject constructor() : CommonViewModel() {
})
}

if (MOCKED) {
if (DebugConfig.mockedDataEnabled) {

val title = TitleViewHolderItem("Mocked Transactions", true)
val messageGiphy = " https://giphy.com/embed/5885nYOgBHdCw"
Expand All @@ -187,7 +187,7 @@ class TransactionRepository @Inject constructor() : CommonViewModel() {
message = messageGiphy
timestamp = BigInteger.valueOf(System.currentTimeMillis())
id = BigInteger.valueOf(1)
tariContact = TariContact(TariBuild.moched_zero_contact, "test1")
tariContact = TariContact(MockDataStub.WALLET_ADDRESS_ZERO, "test1")
},
contactsRepository.ffiBridge.getContactForTx(CompletedTx()),
0,
Expand All @@ -203,7 +203,7 @@ class TransactionRepository @Inject constructor() : CommonViewModel() {
timestamp = BigInteger.valueOf(System.currentTimeMillis())
id = BigInteger.valueOf(1)
message = messageGiphy
tariContact = TariContact(TariBuild.moched_zero_contact, "test2")
tariContact = TariContact(MockDataStub.WALLET_ADDRESS_ZERO, "test2")
}
val item2 = TransactionItem(
tx2,
Expand All @@ -221,7 +221,7 @@ class TransactionRepository @Inject constructor() : CommonViewModel() {
fee = MicroTari(BigInteger.valueOf(1000))
timestamp = BigInteger.valueOf(System.currentTimeMillis())
id = BigInteger.valueOf(1)
tariContact = TariContact(TariBuild.mocked_wallet_address, "test3")
tariContact = TariContact(MockDataStub.WALLET_ADDRESS, "test3")

}
val item3 = TransactionItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import com.tari.android.wallet.ui.fragment.utxos.list.module.DetailItemModule
import com.tari.android.wallet.ui.fragment.utxos.list.module.ListItemModule
import com.tari.android.wallet.ui.fragment.utxos.list.module.UtxoAmountModule
import com.tari.android.wallet.ui.fragment.utxos.list.module.UtxoSplitModule
import com.tari.android.wallet.util.TariBuild
import com.tari.android.wallet.util.DebugConfig
import java.math.BigInteger
import kotlin.random.Random

Expand Down Expand Up @@ -165,7 +165,7 @@ class UtxosListViewModel : CommonViewModel() {
wallet.getAllUtxos(error)
}.itemsList.map { UtxosViewHolderItem(it) }.filter { it.isShowingStatus }.toMutableList()

if (TariBuild.MOCKED && allItems.isEmpty()) {
if (DebugConfig.mockedDataEnabled && allItems.isEmpty()) {
for (i in 0 until 20) {
allItems.add(0, UtxosViewHolderItem(TariUtxo().apply {
value = MicroTari(BigInteger.valueOf(Random.nextLong(1, 100000) * 10000))
Expand Down
60 changes: 0 additions & 60 deletions app/src/main/java/com/tari/android/wallet/util/BuildUtil.kt

This file was deleted.

Loading