Skip to content

Commit

Permalink
bug fixeds
Browse files Browse the repository at this point in the history
  • Loading branch information
polstianka committed Oct 4, 2024
1 parent 4ccd647 commit 012c2e0
Show file tree
Hide file tree
Showing 52 changed files with 1,458 additions and 599 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class API(

fun realtime(accountId: String, testnet: Boolean): Flow<SSEvent> {
val endpoint = if (testnet) config.tonapiSSETestnetEndpoint else config.tonapiSSEEndpoint
val url = "$endpoint/sse/transactions?account=$accountId"
val url = "$endpoint/sse/traces?account=$accountId"
return tonAPIHttpClient.sse(url)
}

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

import android.content.Context
import android.util.Log
import com.tonapps.blockchain.ton.contract.BaseWalletContract
import com.tonapps.blockchain.ton.contract.WalletVersion
import com.tonapps.blockchain.ton.contract.walletVersion
Expand Down Expand Up @@ -397,7 +398,7 @@ class AccountRepository(
return
}

val entity = database.getAccount(id)
val entity = database.getAccount(id) ?: database.getAccounts().firstOrNull()
if (entity == null) {
setSelectedWallet(null)
} else {
Expand Down Expand Up @@ -486,16 +487,4 @@ class AccountRepository(
transfers = transfers
)
}

/*suspend fun createSignedMessage(
wallet: WalletEntity,
seqno: Int,
privateKeyEd25519: PrivateKeyEd25519 = EmptyPrivateKeyEd25519,
validUntil: Long,
transfers: List<WalletTransfer>,
internalMessage: Boolean = false,
): Cell {
val data = messageBody(wallet, seqno, validUntil, transfers, internalMessage)
return wallet.sign(privateKeyEd25519, data.seqNo, data.body)
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.content.Context
import android.database.Cursor
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper
import android.util.Log
import androidx.core.database.getStringOrNull
import com.tonapps.blockchain.ton.contract.walletVersion
import com.tonapps.extensions.toByteArray
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,22 @@ class BackupRepository(
backportToRN(_stream.value)
return entity
}

fun addBackups(
walletIds: List<String>,
source: BackupEntity.Source = BackupEntity.Source.LOCAL,
date: Long = System.currentTimeMillis()
) {
for (walletId in walletIds) {
addBackup(walletId, source, date)
}
}

fun addBackupsAsync(
walletIds: List<String>,
source: BackupEntity.Source = BackupEntity.Source.LOCAL,
date: Long = System.currentTimeMillis()
) {
scope.launch(Dispatchers.IO) { addBackups(walletIds, source, date) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.appcompat.app.AppCompatDelegate
import androidx.camera.camera2.Camera2Config
import androidx.camera.core.CameraXConfig
import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.imagepipeline.core.DownsampleMode
import com.facebook.imagepipeline.core.ImagePipelineConfig
import com.facebook.imagepipeline.core.ImageTranscoderType
import com.facebook.imagepipeline.core.MemoryChunkType
Expand Down Expand Up @@ -88,7 +89,9 @@ class App: Application(), CameraXConfig.Provider, KoinComponent {
configBuilder.setMemoryChunkType(MemoryChunkType.BUFFER_MEMORY)
configBuilder.setImageTranscoderType(ImageTranscoderType.JAVA_TRANSCODER)
configBuilder.experiment().setNativeCodeDisabled(true)
configBuilder.setDownsampleEnabled(false)
configBuilder.experiment().setUseDownsampligRatioForResizing(true)
configBuilder.experiment().useBitmapPrepareToDraw = true
configBuilder.setDownsampleMode(DownsampleMode.ALWAYS)

Fresco.initialize(this, configBuilder.build())
}
Expand All @@ -98,14 +101,4 @@ class App: Application(), CameraXConfig.Provider, KoinComponent {
.fromConfig(Camera2Config.defaultConfig())
.setMinimumLoggingLevel(Log.ERROR).build()
}

fun isOriginalAppInstalled(): Boolean {
val pm = packageManager
return try {
pm.getPackageInfo("com.ton_keeper", 0)
true
} catch (e: Exception) {
false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@ package com.tonapps.tonkeeper

import android.app.ActivityManager
import android.content.Context
import android.os.Build
import com.tonapps.tonkeeper.koin.remoteConfig
import com.tonapps.tonkeeper.os.isMediatek
import com.tonapps.wallet.api.entity.FlagsEntity
import android.os.BatteryManager

val Context.featureFlags: FlagsEntity
get() = this.remoteConfig?.flags ?: FlagsEntity()
val Context.batteryLevel: Int
get() {
val batteryManager = getSystemService(Context.BATTERY_SERVICE) as BatteryManager
return batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
}

val Context.isLowDevice: Boolean
get() {
if (isMediatek()) {
return true
}
val activityManager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
return activityManager.isLowRamDevice
}

val Context.isBlurDisabled: Boolean
get() = isLowDevice || featureFlags.disableBlur || (Build.VERSION_CODES.S > Build.VERSION.SDK_INT && featureFlags.disableLegacyBlur)
get() = isLowDevice && 20 >= batteryLevel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tonapps.tonkeeper.api

import com.tonapps.wallet.api.entity.AccountEventEntity
import io.tonapi.models.AccountEvent

data class AccountEventWrap(
Expand All @@ -8,15 +9,42 @@ data class AccountEventWrap(
val eventIds: List<String>,
) {

companion object {

fun cached(event: AccountEvent): AccountEventWrap {
return AccountEventWrap(event, cached = true, eventIds = listOf(event.eventId))
}

fun cached(event: AccountEventEntity): AccountEventWrap {
return cached(event.body)
}
}

val eventId: String
get() = event.eventId

val timestamp: Long
get() = event.timestamp
get() = if (inProgress) {
System.currentTimeMillis()
} else {
event.timestamp
}

val lt: Long
get() = event.lt

val inProgress: Boolean
get() = event.inProgress

constructor(event: AccountEvent) : this(
event = event,
cached = false,
eventIds = listOf(event.eventId)
)

constructor(event: AccountEventEntity) : this(
event = event.body,
cached = false,
eventIds = listOf(event.body.eventId)
)
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,14 @@ class HistoryHelper(
)
}

fun transform(loading: Boolean, items: List<HistoryItem>): List<HistoryItem> {
return if (loading) {
withLoadingItem(items)
} else {
removeLoadingItem(items)
}
}

fun withLoadingItem(items: List<HistoryItem>): List<HistoryItem> {
val last = items.lastOrNull()
if (last is HistoryItem.Loader) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.view.View
import android.view.ViewGroup
import androidx.annotation.ColorInt
import androidx.appcompat.widget.AppCompatTextView
import com.facebook.imagepipeline.common.ResizeOptions
import com.facebook.imagepipeline.postprocessors.BlurPostProcessor
import com.facebook.imagepipeline.request.ImageRequestBuilder
import com.tonapps.extensions.logError
Expand Down Expand Up @@ -125,7 +126,10 @@ class HistoryActionHolder(

private fun loadIcon(uri: Uri) {
iconView.imageTintList = null
iconView.setImageURI(uri, this)

val builder = ImageRequestBuilder.newBuilderWithSource(uri)
builder.resizeOptions = ResizeOptions.forSquareSize(128)
iconView.setImageRequest(builder.build())
}

private fun bindPending(pending: Boolean) {
Expand Down Expand Up @@ -218,14 +222,12 @@ class HistoryActionHolder(
}

private fun loadNftImage(uri: Uri, blur: Boolean) {
val builder = ImageRequestBuilder.newBuilderWithSource(uri)
builder.resizeOptions = ResizeOptions.forSquareSize(320)
if (blur) {
val request = ImageRequestBuilder.newBuilderWithSource(uri)
.setPostprocessor(BlurPostProcessor(25, context, 3))
.build()
nftIconView.setImageRequest(request)
} else {
nftIconView.setImageURI(uri, null)
builder.setPostprocessor(BlurPostProcessor(25, context, 3))
}
nftIconView.setImageRequest(builder.build())
}

@ColorInt
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.tonapps.tonkeeper.deeplink

import android.net.Uri

data class DeepLink(
val route: DeepLinkRoute,
val fromQR: Boolean,
val referrer: Uri?,
) {

val isUnknown: Boolean
get() = route is DeepLinkRoute.Unknown

constructor(
uri: Uri,
fromQR: Boolean,
referrer: Uri?
): this(
route = DeepLinkRoute.resolve(uri),
fromQR = fromQR,
referrer = referrer
)

}
Loading

0 comments on commit 012c2e0

Please sign in to comment.