Skip to content

Commit

Permalink
Fix check version
Browse files Browse the repository at this point in the history
  • Loading branch information
furenster committed Oct 16, 2024
1 parent 58ab787 commit 06c69d1
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ extract-universal-apk:
./scripts/extract_aab_apk.sh

release:
./gradlew clean buildCargoNdkGoogleRelease assembleGoogleRelease :app:bundleGoogleRelease
./gradlew clean :app:bundleGoogleRelease
./gradlew clean assembleUniversalRelease
./gradlew clean assembleHuaweiRelease
./gradlew clean assembleSolanaRelease

localize:
@sh scripts/localize.sh android
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/gemwallet/android/di/ClientsModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import com.wallet.core.primitives.Chain
import com.wallet.core.primitives.Device
import com.wallet.core.primitives.NameRecord
import com.wallet.core.primitives.Node
import com.wallet.core.primitives.Release
import com.wallet.core.primitives.Subscription
import com.wallet.core.primitives.SwapQuote
import dagger.Module
Expand Down Expand Up @@ -103,6 +104,7 @@ object ClientsModule {
.registerTypeAdapter(Transactions::class.java, GemApiClient.TransactionsSerializer())
.registerTypeAdapter(NameRecord::class.java, GemApiClient.NameRecordDeserialize())
.registerTypeAdapter(SwapQuote::class.java, GemApiClient.SwapQuoteDeserializer())
.registerTypeAdapter(Release::class.java, GemApiClient.ReleaseDeserialize())
.registerTypeAdapter(AssetId::class.java, AssetIdSerializer())
.create()
}
Expand Down
22 changes: 22 additions & 0 deletions app/src/main/java/com/gemwallet/android/services/GemApiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import com.wallet.core.primitives.NameRecord
import com.wallet.core.primitives.Node
import com.wallet.core.primitives.NodeState
import com.wallet.core.primitives.Platform
import com.wallet.core.primitives.PlatformStore
import com.wallet.core.primitives.Release
import com.wallet.core.primitives.Subscription
import com.wallet.core.primitives.SwapApprovalData
import com.wallet.core.primitives.SwapProvider
Expand Down Expand Up @@ -389,5 +391,25 @@ interface GemApiClient {
)
}
}

class ReleaseDeserialize : JsonDeserializer<Release?> {
override fun deserialize(
json: JsonElement,
typeOfT: Type?,
context: JsonDeserializationContext?
): Release? {
val jObj = json.asJsonObject
val version = jObj["version"].asString
val upgradeRequired = jObj["upgradeRequired"].asBoolean
val store = jObj["store"].asString
val platformStore = PlatformStore.entries.firstOrNull { it.string == store} ?: throw IllegalArgumentException()
return Release(
version = version,
store = platformStore,
upgradeRequired = upgradeRequired
)
}

}
}

8 changes: 4 additions & 4 deletions app/src/main/java/com/gemwallet/android/ui/AppViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ class AppViewModel @Inject constructor(
if (BuildConfig.DEBUG) {
return@withContext
}
val current = gemApiClient.getConfig().getOrNull()
?.releases?.filter {
if (it.store == null) return@filter false
val response = gemApiClient.getConfig().getOrNull()
val current = response?.releases?.filter {
val versionFlavor = when (it.store) {
PlatformStore.GooglePlay -> "google"
PlatformStore.Fdroid -> "fdroid"
Expand All @@ -71,7 +70,8 @@ class AppViewModel @Inject constructor(
}
BuildConfig.FLAVOR == versionFlavor
}
?.firstOrNull()?.version ?: BuildConfig.VERSION_NAME
?.firstOrNull()?.version ?: return@withContext

val skipVersion = configRepository.getAppVersionSkip()
if (current.compareTo(BuildConfig.VERSION_NAME) > 0 && skipVersion != current) {
state.update {
Expand Down

0 comments on commit 06c69d1

Please sign in to comment.