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