Skip to content

Commit

Permalink
fix for browser
Browse files Browse the repository at this point in the history
  • Loading branch information
polstianka committed Dec 3, 2024
1 parent 6b8007b commit 979ab7e
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ internal class InternalApi(
.appendQueryParameter("build", build)
.appendQueryParameter("platform", platform)
.appendQueryParameter("chainName", if (testnet) "testnet" else "mainnet")

return builder.build().toString()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class BrowserRepository(context: Context, api: API) {
locale: Locale
) = flow {
loadLocal(country, locale)?.let { emit(it) }
load(country, testnet, locale)?.let { emit(it) }
loadRemote(country, testnet, locale)?.let { emit(it) }
}

suspend fun load(country: String, testnet: Boolean, locale: Locale): BrowserDataEntity? = withContext(Dispatchers.IO) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.tonapps.wallet.data.browser.entities
import android.graphics.Color
import android.net.Uri
import android.os.Parcelable
import com.tonapps.extensions.toUriOrNull
import kotlinx.parcelize.Parcelize
import org.json.JSONArray
import org.json.JSONObject
Expand Down Expand Up @@ -37,7 +38,7 @@ data class BrowserAppEntity(
description = json.getString("description"),
icon = Uri.parse(json.getString("icon")),
poster = json.optString("poster")?.let { Uri.parse(it) },
url = Uri.parse(json.getString("url")),
url = json.optString("url").toUriOrNull() ?: Uri.EMPTY,
textColor = Color.parseColor(json.optString("textColor", "#ffffff")),
button = json.optJSONObject("button")?.let { Button(it) }
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.tonapps.wallet.data.browser.entities

import android.os.Parcelable
import android.util.Log
import kotlinx.parcelize.Parcelize
import org.json.JSONObject

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tonapps.wallet.data.browser.source

import android.util.Log
import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.tonapps.wallet.api.API
import com.tonapps.wallet.data.browser.entities.BrowserDataEntity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,16 +294,18 @@ class TonConnectManager(

val clientId = tonConnect.clientId
try {
val targetWallet = if (wallet != null && wallet.isTonConnectSupported) wallet else null

val app = readManifest(tonConnect.manifestUrl)
if (isScam(activity, wallet ?: WalletEntity.EMPTY, app.iconUrl.toUri(), app.url)) {
if (isScam(activity, targetWallet ?: WalletEntity.EMPTY, app.iconUrl.toUri(), app.url)) {
return@withContext JsonBuilder.connectEventError(BridgeError.badRequest("client error"))
}

val screen = TonConnectScreen.newInstance(
app = app,
proofPayload = tonConnect.proofPayload,
returnUri = tonConnect.returnUri,
wallet = wallet,
wallet = targetWallet,
fromPackageName = tonConnect.fromPackageName
)
val bundle = activity.addForResult(screen)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class BrowserMainScreen(wallet: WalletEntity): WalletContextScreen(R.layout.frag
spanSizeLookup = object : SpanSizeLookup() {
override fun getSpanSize(position: Int): Int {
return when (exploreAdapter.getItemViewType(position)) {
ExploreItem.TYPE_TITLE, ExploreItem.TYPE_BANNERS -> 4
ExploreItem.TYPE_TITLE, ExploreItem.TYPE_BANNERS, ExploreItem.TYPE_ADS -> 4
else -> 1
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.tonapps.tonkeeper.ui.screen.browser.main

import android.app.Application
import android.util.Log
import androidx.lifecycle.viewModelScope
import com.tonapps.extensions.MutableEffectFlow
import com.tonapps.extensions.mapList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ class ExploreTitleExploreHolder(
): ExploreHolder<ExploreItem.Title>(parent, R.layout.view_browser_title) {

private val titleView = findViewById<AppCompatTextView>(R.id.title)
private val allView = findViewById<AppCompatTextView>(R.id.all)
// private val allView = findViewById<AppCompatTextView>(R.id.all)

override fun onBind(item: ExploreItem.Title) {
titleView.text = item.title
allView.setOnClickListener {
itemView.setOnClickListener {
onMoreClick(item.id)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
import uikit.extensions.collectFlow

class BrowserMoreViewModel(
application: Application,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import com.tonapps.tonkeeper.manager.tonconnect.TonConnectManager
import com.tonapps.tonkeeper.manager.tonconnect.bridge.model.BridgeError
import com.tonapps.tonkeeper.ui.base.BaseWalletVM
import com.tonapps.tonkeeper.ui.component.UpdateAvailableDialog
import com.tonapps.tonkeeper.ui.screen.add.AddWalletScreen
import com.tonapps.tonkeeper.ui.screen.backup.main.BackupScreen
import com.tonapps.tonkeeper.ui.screen.battery.BatteryScreen
import com.tonapps.tonkeeper.ui.screen.browser.dapp.DAppScreen
Expand Down Expand Up @@ -486,7 +487,11 @@ class RootViewModel(

private suspend fun processDeepLink(wallet: WalletEntity, deeplink: DeepLink, fromPackageName: String?) {
val route = deeplink.route
if (route is DeepLinkRoute.TonConnect && !wallet.isWatchOnly) {
if (route is DeepLinkRoute.TonConnect) {
if (!wallet.isTonConnectSupported && accountRepository.getWallets().count { it.isTonConnectSupported } == 0) {
openScreen(AddWalletScreen.newInstance(true))
return
}
processTonConnectDeepLink(deeplink, fromPackageName)
} else if (route is DeepLinkRoute.Story) {
showStory(route.id, "deep-link")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@
android:layout_width="match_parent"
android:layout_height="76dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:padding="@dimen/offsetMedium">
android:padding="@dimen/offsetMedium"
android:layout_marginHorizontal="@dimen/offsetMedium"
android:layout_marginBottom="@dimen/offsetMedium"
android:background="@drawable/bg_content">

<uikit.widget.FrescoView
android:id="@+id/icon"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_gravity="center"
app:roundedCornerRadius="12dp"/>

<uikit.widget.ColumnLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center"
android:padding="@dimen/offsetMedium">
android:paddingHorizontal="@dimen/offsetMedium">

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/title"
Expand All @@ -43,8 +47,9 @@
android:layout_height="36dp"
android:layout_gravity="center"
android:text="@string/open"
android:backgroundTint="?attr/backgroundContentTintColor"
android:textAppearance="@style/TextAppearance.Label2"
android:paddingVertical="0dp"
android:paddingHorizontal="16dp"/>
android:paddingHorizontal="8dp"/>

</uikit.widget.RowLayout>

0 comments on commit 979ab7e

Please sign in to comment.