Fix: Conflict/breakage after merging #159

This commit is contained in:
machiav3lli
2022-01-05 00:43:06 +01:00
parent 8dc4dcce0f
commit 3e149cf946
6 changed files with 37 additions and 34 deletions

View File

@ -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

View File

@ -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 -> {