Commit d8b07401 authored by Dayona Joseph's avatar Dayona Joseph Committed by Arnau Vàzquez
Browse files

Updates based on greatest version code

parent ebf4f59a
......@@ -49,9 +49,6 @@ dependencies {
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
testImplementation 'junit:junit:4.12'
implementation files('libs/jackson-databind-2.9.7.jar')
implementation files('libs/jackson-annotations-2.9.7.jar')
implementation files('libs/jackson-core-2.9.7.jar')
implementation group: 'commons-codec', name: 'commons-codec', version: '1.11'
implementation 'org.bouncycastle:bcprov-jdk15on:1.60'
implementation 'org.bouncycastle:bcpg-jdk15on:1.60'
......@@ -82,7 +79,11 @@ dependencies {
implementation 'com.trello.rxlifecycle3:rxlifecycle-components-preference:3.1.0'
implementation 'com.makeramen:roundedimageview:2.3.0'
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
// Jackson
implementation "com.fasterxml.jackson.core:jackson-core:2.11.1"
implementation "com.fasterxml.jackson.core:jackson-annotations:2.11.1"
implementation "com.fasterxml.jackson.core:jackson-databind:2.11.1"
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.11.1"
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
}
......@@ -19,3 +19,17 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
# Without these lines, jackson will fail to create any immutable/nonnull kotlin classes
-keep class kotlin.* { *; }
-keep class kotlin.Metadata { *; }
-dontwarn kotlin.**
-keepclassmembers class **$WhenMappings {
<fields>;
}
-keepclassmembers class kotlin.Metadata {
public <methods>;
}
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
static void checkParameterIsNotNull(java.lang.Object, java.lang.String);
}
......@@ -3,6 +3,7 @@ package foundation.e.apps.api
import android.content.Context
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonProperty
import foundation.e.apps.MainActivity
import foundation.e.apps.application.model.Application
......@@ -54,6 +55,7 @@ class HomePwaRequest {
}
class PwasSubHomeResult @JsonCreator constructor() {
@JsonIgnore
val apps = LinkedHashMap<Category, ArrayList<PwasBasicData>>()
lateinit var bannerApps: Array<PwasBasicData>
......
......@@ -18,8 +18,6 @@
package foundation.e.apps.api
import android.content.Context
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
import foundation.e.apps.MainActivity.Companion.mActivity
import foundation.e.apps.application.model.Application
......@@ -34,89 +32,76 @@ import foundation.e.apps.utils.Error
class HomeRequest {
companion object {
private val reader = Common.getObjectMapper().readerFor(HomeResult::class.java)
private val mapper = Common.getObjectMapper()
}
fun request(callback: (Error?, HomeResult?) -> Unit) {
fun request(callback: (Error?, Result?) -> Unit) {
try {
var appType =mActivity.showApplicationTypePreference()
val appType = mActivity.showApplicationTypePreference()
val url = Constants.BASE_URL + "apps?action=list_home&source=$appType&type=$appType"
val urlConnection = Common.createConnection(url, Constants.REQUEST_METHOD_GET)
val result = reader.readValue<HomeResult>(urlConnection.inputStream)
val result = mapper.readValue(urlConnection.inputStream, Result::class.java)
urlConnection.disconnect()
callback.invoke(null, result)
} catch (e: Exception) {
e.printStackTrace()
callback.invoke(Error.findError(e), null)
}
}
class HomeResult @JsonCreator
constructor(@JsonProperty("home") private val home: SubHomeResult) {
data class Result(val success: Boolean, val home: Home)
data class Home(
@JsonProperty(BANNER_APPS_KEY)
val bannerApps: List<BasicData>,
@JsonProperty(TOP_UPDATED_APPS_KEY)
val topUpdatedApps: List<BasicData>,
@JsonProperty(TOP_UPDATED_GAMES_KEY)
val topUpdatedGames: List<BasicData>,
@JsonProperty(POPULAR_APPS_24_HOUR_KEY)
val popularAppsIn24Hours: List<BasicData>,
@JsonProperty(POPULAR_GAMES_24_HOUR_KEY)
val popularGamesIn24Hours: List<BasicData>,
@JsonProperty(DISCOVER_KEY)
val discover: List<BasicData>
) {
companion object {
private const val BANNER_APPS_KEY = "banner_apps"
private const val TOP_UPDATED_APPS_KEY = "top_updated_apps"
private const val TOP_UPDATED_GAMES_KEY = "top_updated_games"
private const val POPULAR_APPS_24_HOUR_KEY = "popular_apps_in_last_24_hours"
private const val POPULAR_GAMES_24_HOUR_KEY = "popular_games_in_last_24_hours"
private const val DISCOVER_KEY = "discover"
private val KEYS = setOf(TOP_UPDATED_APPS_KEY,
TOP_UPDATED_GAMES_KEY, POPULAR_APPS_24_HOUR_KEY,
POPULAR_GAMES_24_HOUR_KEY, DISCOVER_KEY)
}
fun getBannerApps(applicationManager: ApplicationManager, context: Context): ArrayList<Application> {
return ApplicationParser.parseToApps(applicationManager, context, home.bannerApps)
return ApplicationParser.parseToApps(applicationManager, context, bannerApps.toTypedArray())
}
fun getApps(applicationManager: ApplicationManager, context: Context): LinkedHashMap<Category, ArrayList<Application>> {
val apps = LinkedHashMap<Category, ArrayList<Application>>()
for (pair in home.apps) {
if(pair.value .isEmpty() ){
apps.remove(pair.key)
}else {
apps[pair.key] = ApplicationParser.parseToApps(applicationManager, context, pair.value.toTypedArray())
KEYS.forEach {
val parsedApps = when (it) {
TOP_UPDATED_APPS_KEY -> ApplicationParser.parseToApps(applicationManager, context, topUpdatedApps.toTypedArray())
TOP_UPDATED_GAMES_KEY -> ApplicationParser.parseToApps(applicationManager, context, topUpdatedGames.toTypedArray())
POPULAR_APPS_24_HOUR_KEY -> ApplicationParser.parseToApps(applicationManager, context, popularAppsIn24Hours.toTypedArray())
POPULAR_GAMES_24_HOUR_KEY -> ApplicationParser.parseToApps(applicationManager, context, popularGamesIn24Hours.toTypedArray())
DISCOVER_KEY -> ApplicationParser.parseToApps(applicationManager, context, discover.toTypedArray())
else -> throw IllegalArgumentException("Unrecognised key $it encountered")
}
apps[Category(it)] = parsedApps
}
return apps
}
}
class SubHomeResult @JsonCreator constructor() {
val apps = LinkedHashMap<Category, ArrayList<BasicData>>()
lateinit var bannerApps: Array<BasicData>
@JsonAnySetter
fun append(key: String, value: Any) {
val apps = value as ArrayList<*>
val appsData = ArrayList<BasicData>()
apps.forEach {
val data = it as LinkedHashMap<*, *>
val appData = BasicData(
data["_id"] as String,
data["name"] as String,
data["package_name"] as String,
data["latest_version_number"].toString(),
data["latest_downloaded_version"].toString(),
data["x86_64_latest_downloaded_version"].toString(),
data["x86_64_latest_version_number"].toString(),
data["armeabi_latest_downloaded_version"].toString(),
data["armeabi_latest_version_number"].toString(),
data["arm64-v8a_latest_downloaded_version"].toString(),
data["arm64-v8a_latest_version_number"].toString(),
data["x86_latest_downloaded_version"].toString(),
data["x86_latest_version_number"].toString(),
data["armeabi-v7a_latest_downloaded_version"].toString(),
data["armeabi-v7a_latest_version_number"].toString(),
data["architectures"]as List<String> as ArrayList<String>,
data["author"] as String,
data["icon_image_path"] as String,
(data["other_images_path"] as List<String>).toTypedArray(),
data["exodus_score"].toString().toFloat(),
BasicData.Ratings(
(data["ratings"] as LinkedHashMap<String, Int>)
["usageQualityScore"]!!.toFloat(),
(data["ratings"] as LinkedHashMap<String, Int>)
["privacyScore"]!!.toFloat()),
data["category"] as String,
data["is_pwa"]as Boolean)
appsData.add(appData)
}
if (key == "banner_apps") {
bannerApps = appsData.toTypedArray()
} else {
this.apps[Category(key)] = appsData
}
}
}
}
......@@ -30,28 +30,35 @@ import foundation.e.apps.utils.ImagesLoader
import java.net.URL
import javax.net.ssl.HttpsURLConnection
class BasicData @JsonCreator
constructor(@param:JsonProperty("_id") val id: String,
@param:JsonProperty("name") val name: String,
@param:JsonProperty("package_name") val packageName: String,
@param:JsonProperty("latest_version_number") var lastVersionNumber: String?,
@param:JsonProperty("latest_downloaded_version") val latestDownloadableUpdate: String?,
@param:JsonProperty("x86_64_latest_downloaded_version") val x86_64_latestDownloadableUpdate: String?,
@param:JsonProperty("x86_64_latest_version_number") val x86_64_lastVersionNumber: String?,
@param:JsonProperty("armeabi_latest_downloaded_version") val armeabi_latestDownloadableUpdate: String?,
@param:JsonProperty("armeabi_latest_version_number") val armeabi_lastVersionNumber: String?,
@param:JsonProperty("arm64-v8a_latest_downloaded_version") val arm64_v8a_latest_latestDownloadableUpdate: String?,
@param:JsonProperty("arm64-v8a_latest_version_number") val arm64_v8a_lastVersionNumber: String?,
@param:JsonProperty("x86_latest_downloaded_version") val x86_latestDownloadableUpdate: String?,
@param:JsonProperty("x86_latest_version_number") val x86_lastVersionNumber: String?,
@param:JsonProperty("armeabi-v7a_latest_downloaded_version") val armeabi_v7a_latestDownloadableUpdate: String?,
@param:JsonProperty("armeabi-v7a_latest_version_number") val armeabi_v7a_lastVersionNumber: String?,
@param:JsonProperty("latest_version_number") var lastVersionNumber: String,
@param:JsonProperty("latest_version_code") var lastVersionCode: Long,
@param:JsonProperty("latest_downloaded_version") val latestDownloadableUpdate: String,
@param:JsonProperty("x86_64_latest_downloaded_version") val x86_64_latestDownloadableUpdate: String,
@param:JsonProperty("x86_64_latest_version_number") val x86_64_lastVersionNumber: String = "-1",
@param:JsonProperty("x86_64_latest_version_code") var x86_64_lastVersionCode: Long = -1,
@param:JsonProperty("armeabi_latest_downloaded_version") val armeabi_latestDownloadableUpdate: String,
@param:JsonProperty("armeabi_latest_version_number") val armeabi_lastVersionNumber: String = "-1",
@param:JsonProperty("armeabi_latest_version_code") var armeabi_lastVersionCode: Long = -1,
@param:JsonProperty("arm64-v8a_latest_downloaded_version") val arm64_v8a_latest_latestDownloadableUpdate: String,
@param:JsonProperty("arm64-v8a_latest_version_number") val arm64_v8a_lastVersionNumber: String = "-1",
@param:JsonProperty("arm64-v8a_latest_version_code") var arm64_v8a_lastVersionCode: Long = -1,
@param:JsonProperty("x86_latest_downloaded_version") val x86_latestDownloadableUpdate: String,
@param:JsonProperty("x86_latest_version_number") val x86_lastVersionNumber: String = "-1",
@param:JsonProperty("x86_latest_version_code") var x86_lastVersionCode: Long = -1,
@param:JsonProperty("armeabi-v7a_latest_downloaded_version") val armeabi_v7a_latestDownloadableUpdate: String,
@param:JsonProperty("armeabi-v7a_latest_version_number") val armeabi_v7a_lastVersionNumber: String = "-1",
@param:JsonProperty("armeabi-v7a_latest_version_code") var armeabi_v7a_lastVersionCode: Long = -1,
@param:JsonProperty("architectures") val apkArchitecture: ArrayList<String>?,
@param:JsonProperty("author") val author: String?,
@param:JsonProperty("author") val author: String,
@param:JsonProperty("icon_image_path") private val iconUri: String,
@param:JsonProperty("other_images_path") val imagesUri: Array<String>,
@param:JsonProperty("exodus_score") val privacyRating: Float?,
@param:JsonProperty("ratings") val ratings: Ratings?,
@param:JsonProperty("ratings") val ratings: Ratings,
@param:JsonProperty("category") val category: String,
@param:JsonProperty("is_pwa") val is_pwa: Boolean){
......@@ -61,7 +68,7 @@ constructor(@param:JsonProperty("_id") val id: String,
fun loadImagesAsyncly(getter: (List<Bitmap>) -> Unit) {
if (images == null) {
Execute({
Execute({
loadImagesSynced()
}, {
getter.invoke(images!!)
......@@ -133,52 +140,58 @@ constructor(@param:JsonProperty("_id") val id: String,
fun getLastVersion(): String? {
if(apkArchitecture!=null) {
//An ordered list of ABIs supported by this device. The most preferred ABI is the first element in the list.
val arch = android.os.Build.SUPPORTED_ABIS.toList()
when(arch[0]) {
"arm64-v8a" -> {
if (arm64_v8a_latest_latestDownloadableUpdate != "-1")
return arm64_v8a_lastVersionNumber // arm64 architecture
else if (armeabi_v7a_latestDownloadableUpdate != "-1")
return armeabi_v7a_lastVersionNumber //armeabi_v7a
else if (armeabi_latestDownloadableUpdate != "-1")
return armeabi_lastVersionNumber //armeabi
else lastVersionNumber
}
//An ordered list of ABIs supported by this device. The most preferred ABI is the first element in the list.
val arch = android.os.Build.SUPPORTED_ABIS.toList()
when(arch[0]) {
"arm64-v8a" -> {
return largestVersion(Pair(arm64_v8a_lastVersionNumber, arm64_v8a_lastVersionCode),
Pair(armeabi_v7a_lastVersionNumber, armeabi_v7a_lastVersionCode),
Pair(armeabi_lastVersionNumber, armeabi_lastVersionCode),
Pair(lastVersionNumber, lastVersionCode))
}
"armeabi-v7a" -> {
if (armeabi_v7a_latestDownloadableUpdate != "-1")
return armeabi_v7a_lastVersionNumber
else if (armeabi_latestDownloadableUpdate != "-1")
return armeabi_lastVersionNumber
else lastVersionNumber //universal
}
"armeabi-v7a" -> {
return largestVersion(
Pair(armeabi_v7a_lastVersionNumber, armeabi_v7a_lastVersionCode),
Pair(armeabi_lastVersionNumber, armeabi_lastVersionCode),
Pair(lastVersionNumber, lastVersionCode))
}
"armeabi" -> {
if (armeabi_latestDownloadableUpdate != "-1")
return armeabi_lastVersionNumber
else lastVersionNumber
}
"armeabi" -> {
return largestVersion(
Pair(armeabi_lastVersionNumber, armeabi_lastVersionCode),
Pair(lastVersionNumber, lastVersionCode))
}
"x86-64" -> {
if(x86_64_latestDownloadableUpdate != "-1")
return x86_64_lastVersionNumber
else if(x86_latestDownloadableUpdate != "-1")
return x86_lastVersionNumber
else lastVersionNumber
}
"x86-64" -> {
return largestVersion(
Pair(x86_64_lastVersionNumber, x86_64_lastVersionCode),
Pair(x86_lastVersionNumber, x86_lastVersionCode),
Pair(lastVersionNumber, lastVersionCode))
}
"x86" -> {
if(x86_latestDownloadableUpdate != "-1")
return x86_lastVersionNumber
else lastVersionNumber
}
"x86" -> {
return largestVersion(Pair(x86_lastVersionNumber, x86_lastVersionCode),
Pair(lastVersionNumber, lastVersionCode))
}
}
}
return lastVersionNumber //universal
}
private fun largestVersion(vararg versions: Pair<String, Long>): String {
var largestVersion = versions[0]
versions.forEach {
val version = it
if (version.second > largestVersion.second) {
largestVersion = version
}
}
return largestVersion.first
}
}
......@@ -28,20 +28,26 @@ constructor(
@JsonProperty("_id") id: String,
@JsonProperty("name") name: String,
@JsonProperty("package_name") packageName: String,
@JsonProperty("latest_version_number") latestVersionNumber: String?,
@JsonProperty("latest_downloaded_version") latestDownloadableUpdate: String?,
@JsonProperty("x86_64_latest_downloaded_version") val x86_64_latestDownloadableUpdate: String?,
@JsonProperty("x86_64_latest_version_number") val x86_64_lastVersionNumber: String?,
@JsonProperty("armeabi_latest_downloaded_version") val armeabi_latestDownloadableUpdate: String?,
@JsonProperty("armeabi_latest_version_number") val armeabi_lastVersionNumber: String?,
@JsonProperty("arm64-v8a_latest_downloaded_version") val arm64_v8a_latest_latestDownloadableUpdate: String?,
@JsonProperty("arm64-v8a_latest_version_number") val arm64_v8a_lastVersionNumber: String?,
@JsonProperty("x86_latest_downloaded_version") val x86_latestDownloadableUpdate: String?,
@JsonProperty("x86_latest_version_number") val x86_lastVersionNumber: String?,
@JsonProperty("armeabi-v7a_latest_downloaded_version") val armeabi_v7a_latestDownloadableUpdate: String?,
@JsonProperty("armeabi-v7a_latest_version_number") val armeabi_v7a_lastVersionNumber: String?,
@JsonProperty("latest_version_number") latestVersionNumber: String,
@JsonProperty("latest_version_code") lastVersionCode: Long,
@JsonProperty("latest_downloaded_version") latestDownloadableUpdate: String,
@JsonProperty("x86_64_latest_downloaded_version") val x86_64_latestDownloadableUpdate: String = "-1",
@JsonProperty("x86_64_latest_version_number") val x86_64_lastVersionNumber: String = "-1",
@JsonProperty("x86_64_latest_version_code") var x86_64_lastVersionCode: Long = -1,
@JsonProperty("armeabi_latest_downloaded_version") val armeabi_latestDownloadableUpdate: String = "-1",
@JsonProperty("armeabi_latest_version_number") val armeabi_lastVersionNumber: String = "-1",
@JsonProperty("armeabi_latest_version_code") var armeabi_lastVersionCode: Long = -1,
@JsonProperty("arm64-v8a_latest_downloaded_version") val arm64_v8a_latest_latestDownloadableUpdate: String = "-1",
@JsonProperty("arm64-v8a_latest_version_number") val arm64_v8a_lastVersionNumber: String = "-1",
@JsonProperty("arm64-v8a_latest_version_code") var arm64_v8a_lastVersionCode: Long = -1,
@JsonProperty("x86_latest_downloaded_version") val x86_latestDownloadableUpdate: String = "-1",
@JsonProperty("x86_latest_version_number") val x86_lastVersionNumber: String = "-1",
@JsonProperty("x86_latest_version_code") var x86_lastVersionCode: Long = -1,
@JsonProperty("armeabi-v7a_latest_downloaded_version") val armeabi_v7a_latestDownloadableUpdate: String = "-1",
@JsonProperty("armeabi-v7a_latest_version_number") val armeabi_v7a_lastVersionNumber: String = "-1",
@JsonProperty("armeabi-v7a_latest_version_code") var armeabi_v7a_lastVersionCode: Long = -1,
@JsonProperty("architectures") val apkArchitecture: ArrayList<String>?,
@JsonProperty("author") author: String?,
@JsonProperty("author") author: String,
@JsonProperty("icon_image_path") iconUri: String,
@JsonProperty("other_images_path") imagesUri: Array<String>,
@JsonProperty("category") categoryId: String,
......@@ -52,16 +58,16 @@ constructor(
var basicData = if (ratings == null) {
BasicData(id, name,packageName, latestVersionNumber, latestDownloadableUpdate,
x86_64_latestDownloadableUpdate,x86_64_lastVersionNumber,armeabi_latestDownloadableUpdate,
armeabi_lastVersionNumber,arm64_v8a_latest_latestDownloadableUpdate,arm64_v8a_lastVersionNumber,
x86_latestDownloadableUpdate,x86_lastVersionNumber,armeabi_v7a_latestDownloadableUpdate,armeabi_v7a_lastVersionNumber,apkArchitecture,
BasicData(id, name,packageName, latestVersionNumber,lastVersionCode, latestDownloadableUpdate,
x86_64_latestDownloadableUpdate,x86_64_lastVersionNumber,x86_64_lastVersionCode,armeabi_latestDownloadableUpdate,
armeabi_lastVersionNumber,armeabi_lastVersionCode,arm64_v8a_latest_latestDownloadableUpdate,arm64_v8a_lastVersionNumber,arm64_v8a_lastVersionCode,
x86_latestDownloadableUpdate,x86_lastVersionNumber,x86_lastVersionCode,armeabi_v7a_latestDownloadableUpdate,armeabi_v7a_lastVersionNumber,armeabi_v7a_lastVersionCode,apkArchitecture,
author,iconUri, imagesUri, null,BasicData.Ratings(-1f, -1f), categoryId,is_pwa)
} else {
BasicData(id, name,packageName, latestVersionNumber, latestDownloadableUpdate,
x86_64_latestDownloadableUpdate,x86_64_lastVersionNumber,armeabi_latestDownloadableUpdate,
armeabi_lastVersionNumber,arm64_v8a_latest_latestDownloadableUpdate,arm64_v8a_lastVersionNumber,
x86_latestDownloadableUpdate,x86_lastVersionNumber,armeabi_v7a_latestDownloadableUpdate,armeabi_v7a_lastVersionNumber,apkArchitecture,
BasicData(id, name,packageName, latestVersionNumber,lastVersionCode, latestDownloadableUpdate,
x86_64_latestDownloadableUpdate,x86_64_lastVersionNumber,x86_64_lastVersionCode,armeabi_latestDownloadableUpdate,
armeabi_lastVersionNumber,armeabi_lastVersionCode,arm64_v8a_latest_latestDownloadableUpdate,arm64_v8a_lastVersionNumber,arm64_v8a_lastVersionCode,
x86_latestDownloadableUpdate,x86_lastVersionNumber,x86_lastVersionCode,armeabi_v7a_latestDownloadableUpdate,armeabi_v7a_lastVersionNumber,armeabi_v7a_lastVersionCode,apkArchitecture,
author,iconUri, imagesUri, ratings.privacyRating, ratings, categoryId,is_pwa)
}
......
......@@ -2,8 +2,11 @@ package foundation.e.apps.application.model.data
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.util.Log
import androidx.core.content.res.ResourcesCompat
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
import foundation.e.apps.R
import foundation.e.apps.application.model.Application
import foundation.e.apps.utils.Constants
import foundation.e.apps.utils.Error
......@@ -12,31 +15,38 @@ import java.net.URL
import javax.net.ssl.HttpsURLConnection
class SearchAppsBasicData@JsonCreator
constructor(@param:JsonProperty("_id") val id: String,
@param:JsonProperty("name") val name: String,
@param:JsonProperty("package_name") val packageName: String?,
@param:JsonProperty("latest_version_number") var lastVersionNumber: String?,
@param:JsonProperty("x86_64_latest_downloaded_version") val x86_64_latestDownloadableUpdate: String?,
@param:JsonProperty("x86_64_latest_version_number") val x86_64_lastVersionNumber: String?,
@param:JsonProperty("armeabi_latest_downloaded_version") val armeabi_latestDownloadableUpdate: String?,
@param:JsonProperty("armeabi_latest_version_number") val armeabi_lastVersionNumber: String?,
@param:JsonProperty("arm64-v8a_latest_downloaded_version") val arm64_v8a_latest_latestDownloadableUpdate: String?,
@param:JsonProperty("arm64-v8a_latest_version_number") val arm64_v8a_lastVersionNumber: String?,
@param:JsonProperty("x86_latest_downloaded_version") val x86_latestDownloadableUpdate: String?,
@param:JsonProperty("x86_latest_version_number") val x86_lastVersionNumber: String?,
@param:JsonProperty("armeabi-v7a_latest_downloaded_version") val armeabi_v7a_latestDownloadableUpdate: String?,
@param:JsonProperty("armeabi-v7a_latest_version_number") val armeabi_v7a_lastVersionNumber: String?,
@param:JsonProperty("architectures") val apkArchitecture: ArrayList<String>?,
@param:JsonProperty("is_pwa") val is_pwa: Boolean,
@param:JsonProperty("author") val author: String?,
@param:JsonProperty("is_web_app") val is_web_app: Boolean,
@param:JsonProperty("category") val category: String,
@param:JsonProperty("icon_image_path") val icon_uri: String,
@param:JsonProperty("other_images_path") val imagesUri: Array<String>){
private var icon: Bitmap? = null
private var images: List<Bitmap>? = null
constructor(@param:JsonProperty("_id") val id: String,
@param:JsonProperty("name") val name: String,
@param:JsonProperty("package_name") val packageName: String?,
@param:JsonProperty("latest_version_number") var lastVersionNumber: String,
@param:JsonProperty("latest_version_code") var lastVersionCode: Long,
@param:JsonProperty("latest_downloaded_version") val latestDownloadableUpdate: String,
@param:JsonProperty("x86_64_latest_downloaded_version") val x86_64_latestDownloadableUpdate: String,
@param:JsonProperty("x86_64_latest_version_number") val x86_64_lastVersionNumber: String = "-1",
@param:JsonProperty("x86_64_latest_version_code") var x86_64_lastVersionCode: Long = -1,
@param:JsonProperty("armeabi_latest_downloaded_version") val armeabi_latestDownloadableUpdate: String,
@param:JsonProperty("armeabi_latest_version_number") val armeabi_lastVersionNumber: String = "-1",
@param:JsonProperty("armeabi_latest_version_code") var armeabi_lastVersionCode: Long = -1,
@param:JsonProperty("arm64-v8a_latest_downloaded_version") val arm64_v8a_latest_latestDownloadableUpdate: String,
@param:JsonProperty("arm64-v8a_latest_version_number") val arm64_v8a_lastVersionNumber: String = "-1",
@param:JsonProperty("arm64-v8a_latest_version_code") var arm64_v8a_lastVersionCode: Long = -1,
@param:JsonProperty("x86_latest_downloaded_version") val x86_latestDownloadableUpdate: String,
@param:JsonProperty("x86_latest_version_number") val x86_lastVersionNumber: String = "-1",
@param:JsonProperty("x86_latest_version_code") var x86_lastVersionCode: Long = -1,
@param:JsonProperty("armeabi-v7a_latest_downloaded_version") val armeabi_v7a_latestDownloadableUpdate: String,
@param:JsonProperty("armeabi-v7a_latest_version_number") val armeabi_v7a_lastVersionNumber: String = "-1",
@param:JsonProperty("armeabi-v7a_latest_version_code") var armeabi_v7a_lastVersionCode: Long = -1,
@param:JsonProperty("architectures") val apkArchitecture: ArrayList<String>?,
@param:JsonProperty("is_pwa") val is_pwa: Boolean,
@param:JsonProperty("author") val author: String,
@param:JsonProperty("is_web_app") val is_web_app: Boolean,
@param:JsonProperty("category") val category: String,
@param:JsonProperty("icon_image_path") val icon_uri: String,
@param:JsonProperty("other_images_path") val imagesUri: Array<String>){
private var icon: Bitmap? = null
private var images: List<Bitmap>? = null
fun updateLoadedImages(other: SearchAppsBasicData) {
......@@ -93,48 +103,50 @@ class SearchAppsBasicData@JsonCreator
val arch = android.os.Build.SUPPORTED_ABIS.toList()
when(arch[0]) {
"arm64-v8a" -> {
if (arm64_v8a_latest_latestDownloadableUpdate != "-1")
return arm64_v8a_lastVersionNumber // arm64 architecture
else if (armeabi_v7a_latestDownloadableUpdate != "-1")
return armeabi_v7a_lastVersionNumber //armeabi_v7a
else if (armeabi_latestDownloadableUpdate != "-1")
return armeabi_lastVersionNumber //armeabi
else lastVersionNumber
return largestVersion(Pair(arm64_v8a_lastVersionNumber, arm64_v8a_lastVersionCode),
Pair(armeabi_v7a_lastVersionNumber, armeabi_v7a_lastVersionCode),
Pair(armeabi_lastVersionNumber, armeabi_lastVersionCode),
Pair(lastVersionNumber, lastVersionCode))
}
"armeabi-v7a" -> {
if (armeabi_v7a_latestDownloadableUpdate != "-1")
return armeabi_v7a_lastVersionNumber
else if (armeabi_latestDownloadableUpdate != "-1")
return armeabi_lastVersionNumber
else lastVersionNumber //universal
return largestVersion(
Pair(armeabi_v7a_lastVersionNumber, armeabi_v7a_lastVersionCode),
Pair(armeabi_lastVersionNumber, armeabi_lastVersionCode),
Pair(lastVersionNumber, lastVersionCode))
}
"armeabi" -> {
if (armeabi_latestDownloadableUpdate != "-1")
return armeabi_lastVersionNumber
else lastVersionNumber
return largestVersion(
Pair(armeabi_lastVersionNumber, armeabi_lastVersionCode),
Pair(lastVersionNumber, lastVersionCode))
}
"x86-64" -> {
if(x86_64_latestDownloadableUpdate != "-1")
return x86_64_lastVersionNumber
else if(x86_latestDownloadableUpdate != "-1")
return x86_lastVersionNumber
else lastVersionNumber
return largestVersion(
Pair(x86_64_lastVersionNumber, x86_64_lastVersionCode),
Pair(x86_lastVersionNumber, x86_lastVersionCode),
Pair(lastVersionNumber, lastVersionCode))
}