mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-06-08 00:39:54 +00:00
Fix: Conflict/breakage after merging #159
This commit is contained in:
parent
8dc4dcce0f
commit
3e149cf946
@ -295,6 +295,9 @@ interface InstalledDao : BaseDao<Installed> {
|
||||
@Query("SELECT * FROM memory_installed WHERE package_name = :packageName")
|
||||
fun get(packageName: String): Cursor
|
||||
|
||||
@Query("SELECT * FROM memory_installed WHERE package_name = :packageName")
|
||||
fun getObject(packageName: String): Installed?
|
||||
|
||||
@Query("DELETE FROM memory_installed WHERE package_name = :packageName")
|
||||
fun delete(packageName: String)
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.looker.droidify.entity
|
||||
import com.fasterxml.jackson.core.JsonGenerator
|
||||
import com.fasterxml.jackson.core.JsonParser
|
||||
import com.fasterxml.jackson.core.JsonToken
|
||||
import com.looker.droidify.database.Installed
|
||||
import com.looker.droidify.utility.extension.json.*
|
||||
import com.looker.droidify.utility.extension.text.nullIfEmpty
|
||||
|
||||
@ -87,9 +88,9 @@ data class Product(
|
||||
)
|
||||
}
|
||||
|
||||
fun canUpdate(installedItem: InstalledItem?): Boolean {
|
||||
return installedItem != null && compatible && versionCode > installedItem.versionCode &&
|
||||
installedItem.signature in signatures
|
||||
fun canUpdate(installed: Installed?): Boolean {
|
||||
return installed != null && compatible && versionCode > installed.version_code &&
|
||||
installed.signature in signatures
|
||||
}
|
||||
|
||||
fun serialize(generator: JsonGenerator) {
|
||||
@ -162,12 +163,12 @@ data class Product(
|
||||
companion object {
|
||||
fun <T> findSuggested(
|
||||
products: List<T>,
|
||||
installedItem: InstalledItem?,
|
||||
installed: Installed?,
|
||||
extract: (T) -> Product,
|
||||
): T? {
|
||||
return products.maxWithOrNull(compareBy({
|
||||
extract(it).compatible &&
|
||||
(installedItem == null || installedItem.signature in extract(it).signatures)
|
||||
(installed == null || installed.signature in extract(it).signatures)
|
||||
}, { extract(it).versionCode }))
|
||||
}
|
||||
|
||||
|
@ -435,8 +435,8 @@ class SyncService : ConnectionService<SyncService.Binder>() {
|
||||
// run startUpdate on every item
|
||||
productItems.map { productItem ->
|
||||
Pair(
|
||||
Database.InstalledAdapter.get(productItem.packageName, null),
|
||||
Database.RepositoryAdapter.get(productItem.repositoryId)
|
||||
db.installedDao.getObject(productItem.packageName),
|
||||
db.repositoryDao.get(productItem.repositoryId)
|
||||
)
|
||||
}
|
||||
.filter { pair -> pair.first != null && pair.second != null }
|
||||
@ -446,16 +446,15 @@ class SyncService : ConnectionService<SyncService.Binder>() {
|
||||
val installedItem = installedRepository.first!!
|
||||
val repository = installedRepository.second!!
|
||||
|
||||
val productRepository = Database.ProductAdapter.get(
|
||||
installedItem.packageName,
|
||||
null
|
||||
val productRepository = db.productDao.get(
|
||||
installedItem.package_name
|
||||
)
|
||||
.filter { product -> product.repositoryId == repository.id }
|
||||
.map { product -> Pair(product, repository) }
|
||||
.filter { product -> product?.repository_id == repository.id }
|
||||
.map { product -> Pair(product?.data!!, repository.data!!) }
|
||||
|
||||
scope.launch {
|
||||
Utils.startUpdate(
|
||||
installedItem.packageName,
|
||||
installedItem.package_name,
|
||||
installedRepository.first,
|
||||
productRepository,
|
||||
downloadConnection
|
||||
|
@ -43,6 +43,7 @@ import com.google.android.material.textview.MaterialTextView
|
||||
import com.looker.droidify.R
|
||||
import com.looker.droidify.content.Preferences
|
||||
import com.looker.droidify.content.ProductPreferences
|
||||
import com.looker.droidify.database.Installed
|
||||
import com.looker.droidify.entity.*
|
||||
import com.looker.droidify.network.CoilDownloader
|
||||
import com.looker.droidify.screen.ScreenshotsAdapter
|
||||
@ -537,13 +538,13 @@ class AppDetailAdapter(private val callbacks: Callbacks) :
|
||||
private val items = mutableListOf<Item>()
|
||||
private val expanded = mutableSetOf<ExpandType>()
|
||||
private var product: Product? = null
|
||||
private var installedItem: InstalledItem? = null
|
||||
private var installed: Installed? = null
|
||||
|
||||
fun setProducts(
|
||||
context: Context, packageName: String,
|
||||
products: List<Pair<Product, Repository>>, installedItem: InstalledItem?,
|
||||
products: List<Pair<Product, Repository>>, installed: Installed?,
|
||||
) {
|
||||
val productRepository = Product.findSuggested(products, installedItem) { it.first }
|
||||
val productRepository = Product.findSuggested(products, installed) { it.first }
|
||||
items.clear()
|
||||
|
||||
if (productRepository != null) {
|
||||
@ -579,7 +580,7 @@ class AppDetailAdapter(private val callbacks: Callbacks) :
|
||||
}
|
||||
}
|
||||
|
||||
if (installedItem != null) {
|
||||
if (installed != null) {
|
||||
items.add(
|
||||
Item.SwitchItem(
|
||||
SwitchType.IGNORE_ALL_UPDATES,
|
||||
@ -587,7 +588,7 @@ class AppDetailAdapter(private val callbacks: Callbacks) :
|
||||
productRepository.first.versionCode
|
||||
)
|
||||
)
|
||||
if (productRepository.first.canUpdate(installedItem)) {
|
||||
if (productRepository.first.canUpdate(installed)) {
|
||||
items.add(
|
||||
Item.SwitchItem(
|
||||
SwitchType.IGNORE_THIS_UPDATE,
|
||||
@ -853,7 +854,7 @@ class AppDetailAdapter(private val callbacks: Callbacks) :
|
||||
items += Item.EmptyItem(packageName)
|
||||
}
|
||||
this.product = productRepository?.first
|
||||
this.installedItem = installedItem
|
||||
this.installed = installed
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
@ -1301,8 +1302,8 @@ class AppDetailAdapter(private val callbacks: Callbacks) :
|
||||
val incompatibility = item.release.incompatibilities.firstOrNull()
|
||||
val singlePlatform =
|
||||
if (item.release.platforms.size == 1) item.release.platforms.first() else null
|
||||
val installed = installedItem?.versionCode == item.release.versionCode &&
|
||||
installedItem?.signature == item.release.signature
|
||||
val installed = installed?.version_code == item.release.versionCode &&
|
||||
installed?.signature == item.release.signature
|
||||
val suggested =
|
||||
incompatibility == null && item.release.selected && item.selectedRepository
|
||||
|
||||
|
@ -31,7 +31,6 @@ import com.looker.droidify.utility.Utils.rootInstallerEnabled
|
||||
import com.looker.droidify.utility.Utils.startUpdate
|
||||
import com.looker.droidify.utility.extension.android.*
|
||||
import com.looker.droidify.utility.extension.text.trimAfter
|
||||
import com.looker.droidify.utility.getInstalledItem
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxjava3.core.Observable
|
||||
import io.reactivex.rxjava3.disposables.Disposable
|
||||
@ -71,7 +70,7 @@ class AppDetailFragment() : ScreenFragment(), AppDetailAdapter.Callbacks {
|
||||
}
|
||||
|
||||
private class Installed(
|
||||
val installedItem: InstalledItem, val isSystem: Boolean,
|
||||
val data: com.looker.droidify.database.Installed, val isSystem: Boolean,
|
||||
val launcherActivities: List<Pair<String, String>>,
|
||||
)
|
||||
|
||||
@ -156,7 +155,7 @@ class AppDetailFragment() : ScreenFragment(), AppDetailAdapter.Callbacks {
|
||||
}
|
||||
.flatMapSingle { products ->
|
||||
RxUtils
|
||||
.querySingle { Nullable(screenActivity.db.installedDao.get(packageName).getInstalledItem()) }
|
||||
.querySingle { Nullable(screenActivity.db.installedDao.getObject(packageName)) }
|
||||
.map { Pair(products, it) }
|
||||
}
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -165,7 +164,7 @@ class AppDetailFragment() : ScreenFragment(), AppDetailAdapter.Callbacks {
|
||||
val firstChanged = first
|
||||
first = false
|
||||
val productChanged = this.products != products
|
||||
val installedItemChanged = this.installed?.installedItem != installedItem.value
|
||||
val installedItemChanged = this.installed?.data != installedItem.value
|
||||
if (firstChanged || productChanged || installedItemChanged) {
|
||||
layoutManagerState?.let {
|
||||
recyclerView?.layoutManager!!.onRestoreInstanceState(
|
||||
@ -265,12 +264,12 @@ class AppDetailFragment() : ScreenFragment(), AppDetailAdapter.Callbacks {
|
||||
withContext(Dispatchers.Default) {
|
||||
val installed = installed
|
||||
val product =
|
||||
Product.findSuggested(products, installed?.installedItem) { it.first }?.first
|
||||
Product.findSuggested(products, installed?.data) { it.first }?.first
|
||||
val compatible = product != null && product.selectedReleases.firstOrNull()
|
||||
.let { it != null && it.incompatibilities.isEmpty() }
|
||||
val canInstall = product != null && installed == null && compatible
|
||||
val canUpdate =
|
||||
product != null && compatible && product.canUpdate(installed?.installedItem) &&
|
||||
product != null && compatible && product.canUpdate(installed?.data) &&
|
||||
!preference.shouldIgnoreUpdate(product.versionCode)
|
||||
val canUninstall = product != null && installed != null && !installed.isSystem
|
||||
val canLaunch =
|
||||
@ -415,7 +414,7 @@ class AppDetailFragment() : ScreenFragment(), AppDetailAdapter.Callbacks {
|
||||
AppDetailAdapter.Action.INSTALL,
|
||||
AppDetailAdapter.Action.UPDATE,
|
||||
-> {
|
||||
val installedItem = installed?.installedItem
|
||||
val installedItem = installed?.data
|
||||
lifecycleScope.launch {
|
||||
startUpdate(
|
||||
packageName,
|
||||
@ -520,7 +519,7 @@ class AppDetailFragment() : ScreenFragment(), AppDetailAdapter.Callbacks {
|
||||
}
|
||||
|
||||
override fun onReleaseClick(release: Release) {
|
||||
val installedItem = installed?.installedItem
|
||||
val installedItem = installed?.data
|
||||
when {
|
||||
release.incompatibilities.isNotEmpty() -> {
|
||||
MessageDialog(
|
||||
@ -530,7 +529,7 @@ class AppDetailFragment() : ScreenFragment(), AppDetailAdapter.Callbacks {
|
||||
)
|
||||
).show(childFragmentManager)
|
||||
}
|
||||
installedItem != null && installedItem.versionCode > release.versionCode -> {
|
||||
installedItem != null && installedItem.version_code > release.versionCode -> {
|
||||
MessageDialog(MessageDialog.Message.ReleaseOlder).show(childFragmentManager)
|
||||
}
|
||||
installedItem != null && installedItem.signature != release.signature -> {
|
||||
|
@ -14,6 +14,7 @@ import com.fasterxml.jackson.core.JsonGenerator
|
||||
import com.fasterxml.jackson.core.JsonParser
|
||||
import com.looker.droidify.*
|
||||
import com.looker.droidify.content.Preferences
|
||||
import com.looker.droidify.database.Installed
|
||||
import com.looker.droidify.entity.InstalledItem
|
||||
import com.looker.droidify.entity.Product
|
||||
import com.looker.droidify.entity.ProductItem
|
||||
@ -31,7 +32,6 @@ import com.looker.droidify.utility.extension.resources.getDrawableCompat
|
||||
import com.looker.droidify.utility.extension.text.hex
|
||||
import com.topjohnwu.superuser.Shell
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.security.MessageDigest
|
||||
import java.security.cert.Certificate
|
||||
@ -99,13 +99,13 @@ object Utils {
|
||||
|
||||
suspend fun startUpdate(
|
||||
packageName: String,
|
||||
installedItem: InstalledItem?,
|
||||
installed: Installed?,
|
||||
products: List<Pair<Product, Repository>>,
|
||||
downloadConnection: Connection<DownloadService.Binder, DownloadService>,
|
||||
) {
|
||||
val productRepository = Product.findSuggested(products, installedItem) { it.first }
|
||||
val productRepository = Product.findSuggested(products, installed) { it.first }
|
||||
val compatibleReleases = productRepository?.first?.selectedReleases.orEmpty()
|
||||
.filter { installedItem == null || installedItem.signature == it.signature }
|
||||
.filter { installed == null || installed.signature == it.signature }
|
||||
val releaseFlow = MutableStateFlow(compatibleReleases.firstOrNull())
|
||||
if (compatibleReleases.size > 1) {
|
||||
releaseFlow.emit(
|
||||
|
Loading…
x
Reference in New Issue
Block a user