Skip to content

Commit

Permalink
bb x
Browse files Browse the repository at this point in the history
  • Loading branch information
polstianka committed Oct 16, 2024
1 parent 6ecffec commit 8bd3552
Show file tree
Hide file tree
Showing 129 changed files with 746 additions and 360 deletions.
2 changes: 0 additions & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions apps/wallet/instance/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ android {
}

dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.2")

implementation(Dependence.Koin.core)
implementation(Dependence.Koin.workmanager)
implementation(Dependence.KotlinX.datetime)
Expand Down
112 changes: 110 additions & 2 deletions apps/wallet/instance/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
</intent>
</queries>

<supports-screens android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true"/>

<uses-feature android:glEsVersion="0x00020000" android:required="false"/>
<uses-feature android:name="android.software.leanback" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
<uses-feature android:name="android.hardware.ram.low" android:required="false" />
Expand All @@ -19,6 +27,11 @@
<uses-feature android:name="android.hardware.faketouch" android:required="false" />
<uses-feature android:name="android.hardware.microphone" android:required="false" />
<uses-feature android:name="android.hardware.wifi" android:required="false"/>
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<uses-feature android:name="android.hardware.screen.PORTRAIT" android:required="false" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera2" android:required="false" />
<uses-feature android:name="android.hardware.sensor.proximity" android:required="false" />

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Expand Down Expand Up @@ -58,6 +71,103 @@
tools:targetApi="31"
tools:replace="android:allowBackup"
android:localeConfig="@xml/locales_config">

<activity-alias
android:enabled="true"
android:name="com.tonapps.tonkeeper.DefaultLauncherIcon"
android:targetActivity="com.tonapps.tonkeeper.ui.screen.root.RootActivity"
android:exported="true">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
</intent-filter>
</activity-alias>

<activity-alias
android:enabled="false"
android:name="com.tonapps.tonkeeper.GreenLauncherIcon"
android:targetActivity="com.tonapps.tonkeeper.ui.screen.root.RootActivity"
android:icon="@mipmap/ic_green_launcher"
android:roundIcon="@mipmap/ic_green_launcher_round"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
</intent-filter>
</activity-alias>

<activity-alias
android:enabled="false"
android:name="com.tonapps.tonkeeper.RedLauncherIcon"
android:targetActivity="com.tonapps.tonkeeper.ui.screen.root.RootActivity"
android:icon="@mipmap/ic_red_launcher"
android:roundIcon="@mipmap/ic_red_launcher_round"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
</intent-filter>
</activity-alias>

<activity-alias
android:enabled="false"
android:name="com.tonapps.tonkeeper.OrangeLauncherIcon"
android:targetActivity="com.tonapps.tonkeeper.ui.screen.root.RootActivity"
android:icon="@mipmap/ic_orange_launcher"
android:roundIcon="@mipmap/ic_orange_launcher_round"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
</intent-filter>
</activity-alias>

<activity-alias
android:enabled="false"
android:name="com.tonapps.tonkeeper.PurpleLauncherIcon"
android:targetActivity="com.tonapps.tonkeeper.ui.screen.root.RootActivity"
android:icon="@mipmap/ic_purple_launcher"
android:roundIcon="@mipmap/ic_purple_launcher_round"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
</intent-filter>
</activity-alias>

<activity-alias
android:enabled="false"
android:name="com.tonapps.tonkeeper.BlueLauncherIcon"
android:targetActivity="com.tonapps.tonkeeper.ui.screen.root.RootActivity"
android:icon="@mipmap/ic_blue_launcher"
android:roundIcon="@mipmap/ic_blue_launcher_round"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
</intent-filter>
</activity-alias>

<activity-alias
android:enabled="false"
android:name="com.tonapps.tonkeeper.BlackLauncherIcon"
android:targetActivity="com.tonapps.tonkeeper.ui.screen.root.RootActivity"
android:icon="@mipmap/ic_black_launcher"
android:roundIcon="@mipmap/ic_black_launcher_round"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
</intent-filter>
</activity-alias>
<activity
android:name="com.tonapps.tonkeeper.ui.screen.root.RootActivity"
android:exported="true"
Expand All @@ -70,8 +180,6 @@
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
</intent-filter>
<intent-filter android:priority="1">
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.tonapps.tonkeeper
import android.app.ActivityManager
import android.content.Context
import android.os.BatteryManager
import com.tonapps.tonkeeper.core.DevSettings

val Context.batteryLevel: Int
get() {
Expand All @@ -17,4 +18,4 @@ val Context.isLowDevice: Boolean
}

val Context.isBlurDisabled: Boolean
get() = isLowDevice && 20 >= batteryLevel
get() = !DevSettings.blurEnabled || (isLowDevice && 20 >= batteryLevel)
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,4 @@ class Environment(context: Context) {
val resultCode = googleApiAvailability.isGooglePlayServicesAvailable(context)
resultCode == ConnectionResult.SUCCESS
}

val isGooglePlayAvailable: Boolean by lazy {
installerSource == AppInstall.Source.GOOGLE_PLAY && isGooglePlayServicesAvailable
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.android.billingclient.api.PurchasesUpdatedListener
import com.android.billingclient.api.QueryProductDetailsParams
import com.android.billingclient.api.QueryPurchasesParams
import com.android.billingclient.api.consumePurchase
import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.tonapps.extensions.MutableEffectFlow
import com.tonapps.extensions.filterList
import com.tonapps.wallet.data.account.entities.WalletEntity
Expand Down Expand Up @@ -53,6 +54,10 @@ class BillingManager(
val purchasesUpdatedFlow = _purchasesUpdatedFlow.shareIn(scope, SharingStarted.Lazily, 0).distinctUntilChanged()

override fun onPurchasesUpdated(result: BillingResult, purchases: MutableList<Purchase>?) {
if (!result.isSuccess) {
log("Purchases updated", BillingException(result))
}

if (result.isSuccess && !purchases.isNullOrEmpty()) {
_purchasesUpdatedFlow.tryEmit(PurchasesUpdated(result, purchases))
}
Expand Down Expand Up @@ -95,7 +100,6 @@ class BillingManager(
if (productIds.isEmpty()) {
return@ready emptyList()
}

try {
val productList = productIds.map { productId ->
QueryProductDetailsParams.Product.newBuilder()
Expand All @@ -110,15 +114,32 @@ class BillingManager(

getProductDetails(client, params)
} catch (e: Throwable) {
log("Failed to get products", e)
FirebaseCrashlytics.getInstance().recordException(e)
emptyList()
}
}

private fun log(msg: String, e: Throwable? = null) {
if (e == null) {
Log.d("BillingManager", msg)
} else {
Log.e("BillingManager", e.message ?: msg)
Log.e("BillingManager", msg, e)
FirebaseCrashlytics.getInstance().recordException(e)
}
}

private suspend fun getPendingPurchases(client: BillingClient): List<Purchase> {
val params = QueryPurchasesParams.newBuilder()
.setProductType(ProductType.INAPP)
try {
val params = QueryPurchasesParams.newBuilder()
.setProductType(ProductType.INAPP)

return queryPurchases(client, params.build()).filter { !it.isAcknowledged }
return queryPurchases(client, params.build()).filter { !it.isAcknowledged }
} catch (e: Throwable) {
log("Failed to get pending purchases", e)
return emptyList()
}
}

private suspend fun queryPurchases(client: BillingClient, params: QueryPurchasesParams): List<Purchase> = suspendCancellableCoroutine { continuation ->
Expand All @@ -141,12 +162,13 @@ class BillingManager(
.build()

val billingFlowParams = BillingFlowParams.newBuilder()
.setObfuscatedAccountId(wallet.accountId)
.setObfuscatedProfileId(wallet.accountId)
.setProductDetailsParamsList(listOf(productDetailsParams))
.build()

client.launchBillingFlow(activity, billingFlowParams)
val result = client.launchBillingFlow(activity, billingFlowParams)
if (result.responseCode != BillingClient.BillingResponseCode.OK) {
log("Failed to launch billing flow", BillingException(result))
}
Unit
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.tonapps.tonkeeper.core

import com.tonapps.tonkeeper.App

object DevSettings {

private val prefs = App.instance.getSharedPreferences("dev_settings", 0)

var blurEnabled: Boolean = prefs.getBoolean("blur_enabled", true)
set(value) {
if (field != value) {
field = value
prefs.edit().putBoolean("blur_enabled", value).apply()
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.tonapps.tonkeeper.core

import android.content.ComponentName
import android.content.Context
import android.content.pm.PackageManager
import androidx.annotation.DrawableRes
import androidx.webkit.internal.ApiFeature.T
import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.tonapps.tonkeeperx.R

enum class LauncherIcon(val type: String, @DrawableRes val iconRes: Int) {
Default("Default", R.mipmap.ic_launcher),
Green("Green", R.mipmap.ic_green_launcher),
Red("Red", R.mipmap.ic_red_launcher),
Orange("Orange", R.mipmap.ic_orange_launcher),
Purple("Purple", R.mipmap.ic_purple_launcher),
Blue("Blue", R.mipmap.ic_blue_launcher),
Black("Black", R.mipmap.ic_black_launcher);

fun getComponent(context: Context): ComponentName {
return ComponentName(context.packageName, "com.tonapps.tonkeeper.${type}LauncherIcon")
}

fun isEnabled(context: Context): Boolean {
val enableState = context.packageManager.getComponentEnabledSetting(getComponent(context))
return enableState == PackageManager.COMPONENT_ENABLED_STATE_ENABLED || enableState == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT && this == Default
}

companion object {

fun setEnable(context: Context, newIcon: LauncherIcon): Boolean {
try {
if (newIcon.isEnabled(context)) {
return false
}

val packageManager = context.packageManager
for (icon in entries) {
val component = icon.getComponent(context)
val newState = if (icon == newIcon) {
PackageManager.COMPONENT_ENABLED_STATE_ENABLED
} else {
PackageManager.COMPONENT_ENABLED_STATE_DISABLED
}
packageManager.setComponentEnabledSetting(component, newState, PackageManager.DONT_KILL_APP)
}
return true
} catch (e: Throwable) {
FirebaseCrashlytics.getInstance().recordException(e)
return false
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class TonConnectManager(
bridgeConnected.set(true)

bridgeJob = scope.launch(Dispatchers.IO) {
val connections = dAppsRepository.getConnections().chunked(50)
val connections = dAppsRepository.getConnections().chunked(20)
if (connections.isEmpty()) {
return@launch
}
Expand Down
Loading

0 comments on commit 8bd3552

Please sign in to comment.