Skip to content

Commit

Permalink
5.0.6
Browse files Browse the repository at this point in the history
polstianka committed Oct 31, 2024
1 parent aeaa0e7 commit 20e8108
Showing 13 changed files with 52 additions and 26 deletions.
6 changes: 4 additions & 2 deletions apps/wallet/api/src/main/java/com/tonapps/wallet/api/API.kt
Original file line number Diff line number Diff line change
@@ -482,10 +482,12 @@ class API(
}

suspend fun batteryVerifyPurchasePromo(testnet: Boolean, code: String): Boolean = withContext(Dispatchers.IO) {
withRetry {
try {
battery(testnet).verifyPurchasePromo(code)
true
} ?: false
} catch (e: Throwable) {
false
}
}

fun tonconnectProof(address: String, proof: String): String {
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@ class RNLegacy(
RNSeedStorage(context)
}

@Volatile
private var cacheWallets: RNWallets? = null

@Volatile
@@ -251,19 +252,19 @@ class RNLegacy(
return Pair(setupDismissed, hasOpenedTelegramChannel)
}

fun setSetupLastBackupAt(walletId: String, date: Long) {
suspend fun setSetupLastBackupAt(walletId: String, date: Long) {
val json = getSetupJSON(walletId)
json.put("lastBackupAt", date)
setSetupJSON(walletId, json)
}

fun setSetupDismissed(walletId: String) {
suspend fun setSetupDismissed(walletId: String) {
val json = getSetupJSON(walletId)
json.put("setupDismissed", true)
setSetupJSON(walletId, json)
}

fun setHasOpenedTelegramChannel(walletId: String) {
suspend fun setHasOpenedTelegramChannel(walletId: String) {
val json = getSetupJSON(walletId)
json.put("hasOpenedTelegramChannel", true)
setSetupJSON(walletId, json)
Original file line number Diff line number Diff line change
@@ -39,7 +39,6 @@ internal class RNSql(context: Context): SQLiteHelper(context, DATABASE_NAME, DAT
val cursor = db.query(KV_TABLE_NAME, arrayOf(KV_TABLE_VALUE_COLUMN), "$KV_TABLE_KEY_COLUMN = ?", arrayOf(key), null, null, null)
val value = if (cursor.moveToFirst()) cursor.getString(0) else null
cursor.close()
db.close()
return value
} catch (e: Throwable) {
FirebaseCrashlytics.getInstance().recordException(e)
@@ -63,7 +62,6 @@ internal class RNSql(context: Context): SQLiteHelper(context, DATABASE_NAME, DAT
}
val db = writableDatabase
db.insertWithOnConflict(KV_TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE)
db.close()
} catch (e: Throwable) {
FirebaseCrashlytics.getInstance().recordException(e)
if (attempt > 3) {
Original file line number Diff line number Diff line change
@@ -255,7 +255,7 @@ class SettingsRepository(

fun getPushWallet(walletId: String): Boolean = walletPrefsFolder.isPushEnabled(walletId)

fun setPushWallet(walletId: String, value: Boolean) {
suspend fun setPushWallet(walletId: String, value: Boolean) {
walletPrefsFolder.setPushEnabled(walletId, value)
rnLegacy.setNotificationsEnabled(walletId, value)
_walletPush.tryEmit(Unit)
@@ -265,18 +265,24 @@ class SettingsRepository(

fun setupHide(walletId: String) {
walletPrefsFolder.setupHide(walletId)
rnLegacy.setSetupDismissed(walletId)
scope.launch {
rnLegacy.setSetupDismissed(walletId)
}
}

fun setTelegramChannel(walletId: String) {
walletPrefsFolder.setTelegramChannel(walletId)
rnLegacy.setHasOpenedTelegramChannel(walletId)
scope.launch {
rnLegacy.setHasOpenedTelegramChannel(walletId)
}
}

fun isTelegramChannel(walletId: String) = walletPrefsFolder.isTelegramChannel(walletId)

fun setLastBackupAt(walletId: String, date: Long) {
rnLegacy.setSetupLastBackupAt(walletId, date)
scope.launch {
rnLegacy.setSetupLastBackupAt(walletId, date)
}
}

fun getBatteryTxEnabled(accountId: String) = walletPrefsFolder.getBatteryTxEnabled(accountId)
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ internal class Bridge(private val api: API) {
): Flow<BridgeEvent> {
DevSettings.tonConnectLog("Start listening events[lastEventId=$lastEventId; connections=${connections.map { it.clientId }}]")
val publicKeys = connections.map { it.publicKeyHex }
return api.tonconnectEvents(publicKeys, lastEventId, onFailure = { FirebaseCrashlytics.getInstance().recordException(it) })
return api.tonconnectEvents(publicKeys, lastEventId, onFailure = null)
.mapNotNull { event ->
DevSettings.tonConnectLog("Received event:\n$event")
val from = event.json.optStringCompatJS("from") ?: throw BridgeException(
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ class TransactionManager(
private fun realtime(wallet: WalletEntity) = api.realtime(
accountId = wallet.accountId,
testnet = wallet.testnet,
onFailure = { FirebaseCrashlytics.getInstance().recordException(it) }
onFailure = null
).map { it.data }.map { getTransaction(wallet, it) }

private suspend fun getTransaction(
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.util.Log
import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.tonapps.extensions.getParcelableCompat
import com.tonapps.extensions.whileTimeoutOrNull
import com.tonapps.tonkeeper.App
@@ -100,11 +101,22 @@ object WidgetManager {
putExtra(ARG_TYPE, type)
}

val flags = when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
if (intent.component != null || intent.hasCategory(Intent.CATEGORY_BROWSABLE)) {
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
} else {
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
}
}
else -> PendingIntent.FLAG_UPDATE_CURRENT
}

val successCallback = PendingIntent.getBroadcast(
activity,
0,
intent,
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT,
flags,
)

val provider = ComponentName(activity, cls)
@@ -141,6 +153,7 @@ object WidgetManager {
else -> null
}
} catch (e: Throwable) {
FirebaseCrashlytics.getInstance().recordException(e)
return null
}
}
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package com.tonapps.tonkeeper.manager.widget
import android.content.Context
import android.content.SharedPreferences
import android.util.Log
import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.tonapps.extensions.constructor
import com.tonapps.extensions.string

@@ -31,7 +32,7 @@ internal class WidgetSettings(context: Context) {
val constructor = T::class.constructor(String::class, SharedPreferences::class)
constructor.newInstance(keyParamsPrefix(widgetId), prefs)
} catch (e: Throwable) {
Log.e("WidgetUpdaterWorker", "resolveParams", e)
FirebaseCrashlytics.getInstance().recordException(e)
null
}
}
Original file line number Diff line number Diff line change
@@ -9,15 +9,18 @@ class WalletFragmentFactory: FragmentFactory() {
override fun instantiate(classLoader: ClassLoader, className: String): Fragment {
val fragmentClass = loadFragmentClass(classLoader, className)
val constructors = fragmentClass.constructors
if (constructors.size > 1) {
throw IllegalStateException("$fragmentClass class should have only one constructor")
}
/*if (constructors.size > 1) {
throw IllegalStateException("$className class should have only one constructor")
}*/
val constructor = constructors.first()
val parameters = constructor.parameterTypes
if (parameters.size > 1) {
throw IllegalStateException("$fragmentClass class should have only one constructor with one parameter")
/*if (parameters.size > 1) {
throw IllegalStateException("$className class should have only one constructor with one parameter")
} else if (parameters.isEmpty()) {
return fragmentClass.getConstructor().newInstance()
}*/
if (parameters.isEmpty()) {
return fragmentClass.getConstructor().newInstance()
}
val parameter = parameters.first()
if (parameter == WalletEntity::class.java) {
Original file line number Diff line number Diff line change
@@ -114,9 +114,9 @@ class RootActivity: BaseWalletActivity() {
}

override fun attachBaseContext(newBase: Context) {
val newConfig = Configuration(newBase.resources.configuration)
/*val newConfig = Configuration(newBase.resources.configuration)
newConfig.fontScale = 1.0f
applyOverrideConfiguration(newConfig)
applyOverrideConfiguration(newConfig)*/
super.attachBaseContext(newBase)
}

Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package com.tonapps.tonkeeper.ui.screen.root
import android.app.Application
import android.net.Uri
import android.os.Bundle
import android.util.Log
import androidx.core.content.pm.ShortcutInfoCompat
import androidx.core.content.pm.ShortcutManagerCompat
import androidx.core.net.toUri
Original file line number Diff line number Diff line change
@@ -125,7 +125,7 @@ class WidgetUpdaterWorker(
) = withContext(Dispatchers.Main) {
val removeView = RemoteViews(context.packageName, R.layout.widget_rate)
removeView.setTextViewText(R.id.symbol, symbol)
removeView.setOnClickIntent(context, R.id.content, Uri.parse("tonkeeper://token/$jettonAddress"))
removeView.setOnClickIntent(context, android.R.id.background, Uri.parse("tonkeeper://token/$jettonAddress"))
removeView.setTextViewText(R.id.update_date, context.getString(Localization.widget_updated, updatedDate))
removeView.setTextViewText(R.id.price, price.withCustomSymbol(context))
removeView.setTextViewText(R.id.diff, diff)
@@ -168,7 +168,7 @@ class WidgetUpdaterWorker(
icon: Bitmap,
) = withContext(Dispatchers.Main) {
val removeView = RemoteViews(context.packageName, R.layout.widget_balance)
removeView.setOnClickIntent(context, R.id.content, Uri.parse("tonkeeper://pick/$walletId"))
removeView.setOnClickIntent(context, android.R.id.background, Uri.parse("tonkeeper://pick/$walletId"))
removeView.setTextViewText(R.id.fiat, balance)
removeView.setTextViewText(R.id.address, label)
removeView.setImageViewBitmap(R.id.icon, icon)
5 changes: 3 additions & 2 deletions ui/uikit/core/src/main/java/uikit/widget/ToastView.kt
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import android.util.Log
import android.view.View
import android.view.ViewGroup
import android.view.WindowInsets
import android.view.animation.AccelerateDecelerateInterpolator
import androidx.appcompat.widget.AppCompatTextView
import androidx.core.animation.doOnEnd
import androidx.core.view.WindowInsetsCompat
@@ -51,7 +52,7 @@ class ToastView @JvmOverloads constructor(
val endY = statusBarHeight + 24f.dp

val valueAnimator = ValueAnimator.ofFloat(startY, endY)
valueAnimator.duration = 200L
valueAnimator.duration = 160L
valueAnimator.addListener(this@ToastView)
valueAnimator.addUpdateListener(this@ToastView)
valueAnimator
@@ -129,7 +130,7 @@ class ToastView @JvmOverloads constructor(
private fun showDefault() {
loaderView.visibility = View.GONE
show()
postDelayed(::hide, 2600)
postDelayed(::hide, 2000)
}

private fun show() {

0 comments on commit 20e8108

Please sign in to comment.