Skip to content

Commit

Permalink
fix fastlane
Browse files Browse the repository at this point in the history
  • Loading branch information
polstianka committed Jan 16, 2025
1 parent abe28f7 commit bb22395
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ data class WalletEntity(
}

val maxMessages: Int
get() = if (isLedger) 1 else contract.maxMessages
get() = contract.maxMessages

val testnet: Boolean
get() = type == Wallet.Type.Testnet
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.tonapps.tonkeeper.ui.screen.collectibles.main

import android.os.Bundle
import android.view.Gravity
import android.view.View
import androidx.core.view.updatePadding
import androidx.recyclerview.widget.GridLayoutManager
Expand Down Expand Up @@ -42,13 +43,20 @@ class CollectiblesScreen(wallet: WalletEntity): MainScreen.Child(R.layout.fragme
super.onViewCreated(view, savedInstanceState)
headerView = view.findViewById(R.id.header)
headerView.title = getString(Localization.collectibles)
headerView.setTitleGravity(Gravity.START)
headerView.hideCloseIcon()
if (requireContext().isLightTheme) {
headerView.setColor(requireContext().backgroundPageColor)
} else {
headerView.setColor(requireContext().backgroundTransparentColor)
}
headerView.setAction(UIKitIcon.ic_sliders_16)
headerView.doOnActionClick = { navigation?.add(CollectiblesManageScreen.newInstance(wallet)) }
headerView.doOnActionClick = {
navigation?.add(CollectiblesManageScreen.newInstance(wallet))
}
headerView.setRightButton(Localization.spam) {
navigation?.add(CollectiblesManageScreen.newInstance(wallet, true))
}

refreshView = view.findViewById(R.id.refresh)
refreshView.setOnRefreshListener { viewModel.refresh() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class CollectiblesManageScreen(wallet: WalletEntity): BaseListWalletScreen<Scree

override val fragmentName: String = "CollectiblesManageScreen"

private var spamArg: Boolean = false

private val spamDialog: CollectionSpamDialog by lazy { CollectionSpamDialog(requireContext()) }

override val viewModel: CollectiblesManageViewModel by walletViewModel()
Expand All @@ -31,11 +33,32 @@ class CollectiblesManageScreen(wallet: WalletEntity): BaseListWalletScreen<Scree
showAllClick = { viewModel.showAll() }
)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
spamArg = arguments?.getBoolean(ARG_SPAM) ?: false
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setTitle(getString(Localization.collectibles))
setAdapter(adapter)
collectFlow(viewModel.uiItemsFlow, adapter::submitList)
collectFlow(viewModel.uiItemsFlow, ::setUiItems)
}

private fun setUiItems(uiItems: List<Item>) {
adapter.submitList(uiItems) {
if (spamArg) {
scrollToSpam()
spamArg = false
}
}
}

private fun scrollToSpam() {
val index = adapter.currentList.indexOf(viewModel.spamItem)
if (index != -1) {
listView.scrollToPosition(index)
}
}

private fun showSpamDialog(item: Item.Collection) {
Expand All @@ -46,6 +69,15 @@ class CollectiblesManageScreen(wallet: WalletEntity): BaseListWalletScreen<Scree

companion object {

fun newInstance(wallet: WalletEntity) = CollectiblesManageScreen(wallet)
private const val ARG_SPAM = "spam"

fun newInstance(
wallet: WalletEntity,
spam: Boolean = false
): CollectiblesManageScreen {
val screen = CollectiblesManageScreen(wallet)
screen.putBooleanArg(ARG_SPAM, spam)
return screen
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class CollectiblesManageViewModel(
private val api: API,
): BaseWalletVM(app) {

val spamItem = Item.Title(getString(Localization.spam))

private val safeMode: Boolean
get() = settingsRepository.isSafeModeEnabled(api)

Expand Down Expand Up @@ -124,7 +126,7 @@ class CollectiblesManageViewModel(
}

if (spamCollection.isNotEmpty()) {
uiItems.add(Item.Title(getString(Localization.spam)))
uiItems.add(spamItem)
uiItems.add(Item.Space)
for ((index, item) in spamCollection.withIndex()) {
uiItems.add(item.copy(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.tonapps.tonkeeper.ui.screen.events.main

import android.os.Bundle
import android.view.Gravity
import android.view.View
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.RecyclerView
Expand All @@ -13,6 +14,7 @@ import com.tonapps.tonkeeper.extensions.applyColors
import com.tonapps.tonkeeper.extensions.isLightTheme
import com.tonapps.tonkeeper.koin.walletViewModel
import com.tonapps.tonkeeper.ui.screen.browser.base.BrowserBaseScreen
import com.tonapps.tonkeeper.ui.screen.collectibles.manage.CollectiblesManageScreen
import com.tonapps.tonkeeper.ui.screen.events.main.filters.FilterItem
import com.tonapps.tonkeeper.ui.screen.events.main.filters.FiltersAdapter
import com.tonapps.tonkeeper.ui.screen.events.spam.SpamEventsScreen
Expand Down Expand Up @@ -69,12 +71,17 @@ class EventsScreen(wallet: WalletEntity) : MainScreen.Child(R.layout.fragment_ma
super.onViewCreated(view, savedInstanceState)
headerView = view.findViewById(R.id.header)
headerView.title = getString(Localization.history)
headerView.setTitleGravity(Gravity.START)
headerView.setSubtitle(Localization.updating)
headerView.hideIcon()
if (requireContext().isLightTheme) {
headerView.setColor(requireContext().backgroundPageColor)
} else {
headerView.setColor(requireContext().backgroundTransparentColor)
}
headerView.setRightButton(Localization.spam) {
navigation?.add(SpamEventsScreen.newInstance(screenContext.wallet))
}

refreshView = view.findViewById(R.id.refresh)
refreshView.offsetTopAndBottom(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class EventsViewModel(
val uiFilterItems = mutableListOf<FilterItem>()
uiFilterItems.add(FilterItem.Send(selected?.type == FilterItem.TYPE_SEND))
uiFilterItems.add(FilterItem.Receive(selected?.type == FilterItem.TYPE_RECEIVE))
uiFilterItems.add(FilterItem.Spam())
// uiFilterItems.add(FilterItem.Spam())
uiFilterItems.toList()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ class SendTransactionScreen(wallet: WalletEntity) : WalletContextScreen(R.layout
} else {
setErrorTask(BridgeException(cause = it))
}
}.onEach { boc ->
setSuccessTask(boc)
}.onEach { bocList ->
if (bocList.isNotEmpty()) {
setSuccessTask(bocList.first())
}
}.launchIn(lifecycleScope)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.launch
import org.ton.cell.Cell
import org.ton.contract.wallet.WalletTransfer
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicLong
Expand Down Expand Up @@ -164,20 +165,24 @@ class SendTransactionViewModel(

private fun getLedgerTransaction(
message: MessageBodyEntity
): Transaction? {
): List<Transaction> {
if (!message.wallet.isLedger) {
return null
return emptyList()
}
if (message.transfers.size > 1) {
/*if (message.transfers.size > 1) {
throw IllegalStateException("Ledger does not support multiple messages")
}
val transfer = message.transfers.firstOrNull() ?: return null
val transfer = message.transfers.firstOrNull() ?: return null */
val transactions = mutableListOf<Transaction>()
for ((index, transfer) in message.transfers.withIndex()) {
transactions.add(Transaction.fromWalletTransfer(
walletTransfer = transfer,
seqno = message.seqNo + index,
timeout = message.validUntil
))
}

return Transaction.fromWalletTransfer(
walletTransfer = transfer,
seqno = message.seqNo,
timeout = message.validUntil
)
return transactions.toList()
}

fun send() = flow {
Expand All @@ -186,16 +191,28 @@ class SendTransactionViewModel(
val transfers = transfers(compressedTokens, false)
val message = accountRepository.messageBody(wallet, request.validUntil, transfers)
val unsignedBody = message.createUnsignedBody(isBattery)
val ledgerTransaction = getLedgerTransaction(message)

val boc = signUseCase(
context = context,
wallet = wallet,
unsignedBody = unsignedBody,
seqNo = message.seqNo,
ledgerTransaction = ledgerTransaction
).base64()

val ledgerTransactions = getLedgerTransaction(message)

val cells = mutableListOf<Cell>()
if (ledgerTransactions.size >= 2) {
for (transaction in ledgerTransactions) {
val cell = signUseCase(
context = context,
wallet = wallet,
seqNo = transaction.seqno,
ledgerTransaction = transaction
)
cells.add(cell)
}
} else {
val cell = signUseCase(
context = context,
wallet = wallet,
unsignedBody = unsignedBody,
seqNo = message.seqNo
)
cells.add(cell)
}

val confirmationTimeSeconds = getConfirmationTimeMillis() / 1000.0

Expand All @@ -207,18 +224,24 @@ class SendTransactionViewModel(
request.appUri.host ?: "unknown"
}

val status = transactionManager.send(
wallet = wallet,
boc = boc,
withBattery = isBattery,
source = source,
confirmationTime = confirmationTimeSeconds
)
val states = mutableListOf<SendBlockchainState>()
for (cell in cells) {
val boc = cell.base64()
val status = transactionManager.send(
wallet = wallet,
boc = boc,
withBattery = isBattery,
source = source,
confirmationTime = confirmationTimeSeconds
)
states.add(status)
}

if (status == SendBlockchainState.SUCCESS) {
emit(boc)
val isSuccessful = states.all { it == SendBlockchainState.SUCCESS }
if (isSuccessful) {
emit(cells.map { it.base64() }.toTypedArray())
} else {
throw IllegalStateException("Failed to send transaction to blockchain: $status")
throw IllegalStateException("Failed to send transaction to blockchain: $states")
}
}.flowOn(Dispatchers.IO)

Expand Down
2 changes: 1 addition & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ platform :android do
)

max = internal_version_codes[0] > production_version_codes[0] ? internal_version_codes[0] : production_version_codes[0]
updated_version_code = max + 1
updated_version_code = max + 2

increment_version_code(
gradle_file_path: "./apps/wallet/instance/main/build.gradle.kts",
Expand Down
42 changes: 35 additions & 7 deletions ui/uikit/core/src/main/java/uikit/widget/HeaderView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@ import android.view.View
import android.view.ViewGroup
import android.view.WindowInsets
import android.widget.Button
import android.widget.FrameLayout
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.appcompat.widget.AppCompatImageView
import androidx.appcompat.widget.AppCompatTextView
import androidx.appcompat.widget.LinearLayoutCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updateLayoutParams
import androidx.core.view.updatePadding
import uikit.R
import uikit.drawable.BarDrawable
import uikit.drawable.HeaderDrawable
import uikit.extensions.dp
import uikit.extensions.getDimensionPixelSize
import uikit.extensions.inflate
import uikit.extensions.setPaddingHorizontal
import uikit.extensions.setPaddingTop
import uikit.extensions.useAttributes
Expand Down Expand Up @@ -63,10 +68,10 @@ open class HeaderView @JvmOverloads constructor(
}

private val drawable = HeaderDrawable(context)
private val subtitleContainerView: View
private val subtitleContainerView: RowLayout
val subtitleView: AppCompatTextView
private val loaderView: LoaderView
private val textView: View
private val textView: ColumnLayout

var doOnCloseClick: (() -> Unit)? = null
set(value) {
Expand Down Expand Up @@ -164,6 +169,17 @@ open class HeaderView @JvmOverloads constructor(
}
}

fun setRightButton(@StringRes resId: Int, onClick: () -> Unit) {
setRightButton(context.getString(resId), onClick)
}

fun setRightButton(text: String, onClick: () -> Unit) {
val button = inflate(R.layout.view_header_right_button) as Button
button.text = text
button.setOnClickListener { onClick() }
setRightContent(button)
}

fun contentMatchParent() {
titleView.layoutParams = titleView.layoutParams.apply {
width = ViewGroup.LayoutParams.MATCH_PARENT
Expand Down Expand Up @@ -216,14 +232,26 @@ open class HeaderView @JvmOverloads constructor(
}

fun hideIcon() {
closeView.visibility = View.GONE
hideCloseIcon()
actionView.visibility = View.GONE
}

fun setTitleGravity(gravity: Int) {
val layoutParams = titleView.layoutParams as LayoutParams
layoutParams.gravity = gravity
titleView.gravity = gravity
fun hideCloseIcon() {
closeView.visibility = View.GONE
}

fun setTitleGravity(newGravity: Int) {
titleView.updateLayoutParams<LayoutParams> {
this.gravity = newGravity
}
titleView.gravity = newGravity

subtitleContainerView.updateLayoutParams<LayoutParams> {
this.gravity = newGravity
}
subtitleView.gravity = newGravity
subtitleContainerView.updatePadding(left = 0)
textView.updatePadding(left = 4.dp)
}

fun hideText() {
Expand Down
5 changes: 4 additions & 1 deletion ui/uikit/core/src/main/java/uikit/widget/PhraseWords.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ class PhraseWords @JvmOverloads constructor(
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
val isSmall = 1320 >= context.resources.displayMetrics.heightPixels
scale = if (isSmall) {
val isVerySmall = 720 >= context.resources.displayMetrics.heightPixels
scale = if (isVerySmall) {
.4f
} else if (isSmall) {
.7f
} else {
1f
Expand Down
Loading

0 comments on commit bb22395

Please sign in to comment.