mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-06-08 00:39:54 +00:00
Clean up
This commit is contained in:
parent
0bf3dad2f2
commit
e854b57b08
@ -15,8 +15,8 @@ const val TABLE_CATEGORY_NAME = "category"
|
|||||||
const val TABLE_CATEGORY_TEMP_NAME = "temporary_category"
|
const val TABLE_CATEGORY_TEMP_NAME = "temporary_category"
|
||||||
const val TABLE_INSTALLED = "installed"
|
const val TABLE_INSTALLED = "installed"
|
||||||
const val TABLE_INSTALLED_NAME = "memory_installed"
|
const val TABLE_INSTALLED_NAME = "memory_installed"
|
||||||
const val TABLE_LOCK = "lock"
|
const val TABLE_IGNORED = "lock"
|
||||||
const val TABLE_LOCK_NAME = "memory_lock"
|
const val TABLE_IGNORED_NAME = "memory_lock"
|
||||||
const val TABLE_PRODUCT = "product"
|
const val TABLE_PRODUCT = "product"
|
||||||
const val TABLE_PRODUCT_NAME = "product"
|
const val TABLE_PRODUCT_NAME = "product"
|
||||||
const val TABLE_PRODUCT_TEMP_NAME = "temporary_product"
|
const val TABLE_PRODUCT_TEMP_NAME = "temporary_product"
|
||||||
@ -43,7 +43,6 @@ const val ROW_ANTIFEATURES = "antiFeatures"
|
|||||||
const val ROW_LICENSES = "licenses"
|
const val ROW_LICENSES = "licenses"
|
||||||
const val ROW_DONATES = "donates"
|
const val ROW_DONATES = "donates"
|
||||||
const val ROW_SCREENSHOTS = "screenshots"
|
const val ROW_SCREENSHOTS = "screenshots"
|
||||||
const val ROW_VERSION = "version"
|
|
||||||
const val ROW_SIGNATURE = "signature"
|
const val ROW_SIGNATURE = "signature"
|
||||||
const val ROW_ID = "_id"
|
const val ROW_ID = "_id"
|
||||||
const val ROW_ENABLED = "enabled"
|
const val ROW_ENABLED = "enabled"
|
||||||
|
@ -3,7 +3,7 @@ package com.looker.droidify.content
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import com.looker.droidify.database.DatabaseX
|
import com.looker.droidify.database.DatabaseX
|
||||||
import com.looker.droidify.database.entity.Lock
|
import com.looker.droidify.database.entity.Ignored
|
||||||
import com.looker.droidify.entity.ProductPreference
|
import com.looker.droidify.entity.ProductPreference
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@ -27,13 +27,13 @@ object ProductPreferences {
|
|||||||
db.lockDao.insert(*preferences.all.keys
|
db.lockDao.insert(*preferences.all.keys
|
||||||
.mapNotNull { pName ->
|
.mapNotNull { pName ->
|
||||||
this@ProductPreferences[pName].databaseVersionCode?.let {
|
this@ProductPreferences[pName].databaseVersionCode?.let {
|
||||||
Lock(pName, it)
|
Ignored(pName, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.toTypedArray()
|
.toTypedArray()
|
||||||
)
|
)
|
||||||
subject.collect { (packageName, versionCode) ->
|
subject.collect { (packageName, versionCode) ->
|
||||||
if (versionCode != null) db.lockDao.insert(Lock(packageName, versionCode))
|
if (versionCode != null) db.lockDao.insert(Ignored(packageName, versionCode))
|
||||||
else db.lockDao.delete(packageName)
|
else db.lockDao.delete(packageName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ interface ProductDao : BaseDao<Product> {
|
|||||||
builder += """SELECT $TABLE_PRODUCT.rowid AS $ROW_ID, $TABLE_PRODUCT.$ROW_REPOSITORY_ID,
|
builder += """SELECT $TABLE_PRODUCT.rowid AS $ROW_ID, $TABLE_PRODUCT.$ROW_REPOSITORY_ID,
|
||||||
$TABLE_PRODUCT.$ROW_PACKAGE_NAME, $TABLE_PRODUCT.$ROW_LABEL,
|
$TABLE_PRODUCT.$ROW_PACKAGE_NAME, $TABLE_PRODUCT.$ROW_LABEL,
|
||||||
$TABLE_PRODUCT.$ROW_SUMMARY, $TABLE_PRODUCT.$ROW_DESCRIPTION,
|
$TABLE_PRODUCT.$ROW_SUMMARY, $TABLE_PRODUCT.$ROW_DESCRIPTION,
|
||||||
(COALESCE($TABLE_LOCK.$ROW_VERSION_CODE, -1) NOT IN (0, $TABLE_PRODUCT.$ROW_VERSION_CODE) AND
|
(COALESCE($TABLE_IGNORED.$ROW_VERSION_CODE, -1) NOT IN (0, $TABLE_PRODUCT.$ROW_VERSION_CODE) AND
|
||||||
$TABLE_PRODUCT.$ROW_COMPATIBLE != 0 AND
|
$TABLE_PRODUCT.$ROW_COMPATIBLE != 0 AND
|
||||||
$TABLE_PRODUCT.$ROW_VERSION_CODE > COALESCE($TABLE_INSTALLED.$ROW_VERSION_CODE, 0xffffffff) AND
|
$TABLE_PRODUCT.$ROW_VERSION_CODE > COALESCE($TABLE_INSTALLED.$ROW_VERSION_CODE, 0xffffffff) AND
|
||||||
$signatureMatches) AS $ROW_CAN_UPDATE, $TABLE_PRODUCT.$ROW_ICON,
|
$signatureMatches) AS $ROW_CAN_UPDATE, $TABLE_PRODUCT.$ROW_ICON,
|
||||||
@ -173,8 +173,8 @@ interface ProductDao : BaseDao<Product> {
|
|||||||
ON $TABLE_PRODUCT.$ROW_REPOSITORY_ID = $TABLE_REPOSITORY.$ROW_ID"""
|
ON $TABLE_PRODUCT.$ROW_REPOSITORY_ID = $TABLE_REPOSITORY.$ROW_ID"""
|
||||||
|
|
||||||
// Merge the matching locks
|
// Merge the matching locks
|
||||||
builder += """LEFT JOIN $TABLE_LOCK_NAME AS $TABLE_LOCK
|
builder += """LEFT JOIN $TABLE_IGNORED_NAME AS $TABLE_IGNORED
|
||||||
ON $TABLE_PRODUCT.$ROW_PACKAGE_NAME = $TABLE_LOCK.$ROW_PACKAGE_NAME"""
|
ON $TABLE_PRODUCT.$ROW_PACKAGE_NAME = $TABLE_IGNORED.$ROW_PACKAGE_NAME"""
|
||||||
|
|
||||||
// Merge the matching installed
|
// Merge the matching installed
|
||||||
if (!installed && !updates) builder += "LEFT"
|
if (!installed && !updates) builder += "LEFT"
|
||||||
@ -291,7 +291,7 @@ interface InstalledDao : BaseDao<Installed> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
interface LockDao : BaseDao<Lock> {
|
interface LockDao : BaseDao<Ignored> {
|
||||||
@Query("DELETE FROM memory_lock WHERE packageName = :packageName")
|
@Query("DELETE FROM memory_lock WHERE packageName = :packageName")
|
||||||
fun delete(packageName: String)
|
fun delete(packageName: String)
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ import kotlinx.coroutines.launch
|
|||||||
Category::class,
|
Category::class,
|
||||||
CategoryTemp::class,
|
CategoryTemp::class,
|
||||||
Installed::class,
|
Installed::class,
|
||||||
Lock::class
|
Ignored::class
|
||||||
], version = 6
|
], version = 6
|
||||||
)
|
)
|
||||||
@TypeConverters(Converters::class)
|
@TypeConverters(Converters::class)
|
||||||
|
@ -2,10 +2,11 @@ package com.looker.droidify.database.entity
|
|||||||
|
|
||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
import androidx.room.PrimaryKey
|
import androidx.room.PrimaryKey
|
||||||
import com.looker.droidify.TABLE_LOCK_NAME
|
import com.looker.droidify.TABLE_IGNORED_NAME
|
||||||
|
|
||||||
@Entity(tableName = TABLE_LOCK_NAME)
|
// TODO complete renaming to Ignored
|
||||||
data class Lock(
|
@Entity(tableName = TABLE_IGNORED_NAME)
|
||||||
|
data class Ignored(
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
var packageName: String = "",
|
var packageName: String = "",
|
||||||
var versionCode: Long = 0L
|
var versionCode: Long = 0L
|
@ -37,6 +37,7 @@ import java.io.File
|
|||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
|
// TODO maybe replace by using WorkManager instead?
|
||||||
class DownloadService : ConnectionService<DownloadService.Binder>() {
|
class DownloadService : ConnectionService<DownloadService.Binder>() {
|
||||||
companion object {
|
companion object {
|
||||||
private const val ACTION_CANCEL = "${BuildConfig.APPLICATION_ID}.intent.action.CANCEL"
|
private const val ACTION_CANCEL = "${BuildConfig.APPLICATION_ID}.intent.action.CANCEL"
|
||||||
|
@ -28,12 +28,13 @@ fun ProductCard(
|
|||||||
onUserClick: (ProductItem) -> Unit = {}
|
onUserClick: (ProductItem) -> Unit = {}
|
||||||
) {
|
) {
|
||||||
|
|
||||||
val imageData by remember(item, repo) {
|
val product by remember(item) { mutableStateOf(item) }
|
||||||
|
val imageData by remember(product, repo) {
|
||||||
mutableStateOf(
|
mutableStateOf(
|
||||||
CoilDownloader.createIconUri(
|
CoilDownloader.createIconUri(
|
||||||
item.packageName,
|
product.packageName,
|
||||||
item.icon,
|
product.icon,
|
||||||
item.metadataIcon,
|
product.metadataIcon,
|
||||||
repo?.address,
|
repo?.address,
|
||||||
repo?.authentication
|
repo?.authentication
|
||||||
).toString()
|
).toString()
|
||||||
@ -46,7 +47,7 @@ fun ProductCard(
|
|||||||
.requiredSize(80.dp, 116.dp)
|
.requiredSize(80.dp, 116.dp)
|
||||||
.clip(shape = RoundedCornerShape(8.dp))
|
.clip(shape = RoundedCornerShape(8.dp))
|
||||||
.background(color = MaterialTheme.colorScheme.surface)
|
.background(color = MaterialTheme.colorScheme.surface)
|
||||||
.clickable(onClick = { onUserClick(item) }),
|
.clickable(onClick = { onUserClick(product) }),
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
verticalArrangement = Arrangement.Center
|
verticalArrangement = Arrangement.Center
|
||||||
) {
|
) {
|
||||||
@ -57,7 +58,7 @@ fun ProductCard(
|
|||||||
|
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier.padding(4.dp, 2.dp),
|
modifier = Modifier.padding(4.dp, 2.dp),
|
||||||
text = item.name,
|
text = product.name,
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
@ -65,7 +66,7 @@ fun ProductCard(
|
|||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier.padding(4.dp, 1.dp),
|
modifier = Modifier.padding(4.dp, 1.dp),
|
||||||
text = item.version,
|
text = product.version,
|
||||||
style = MaterialTheme.typography.labelSmall,
|
style = MaterialTheme.typography.labelSmall,
|
||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
|
@ -32,12 +32,13 @@ fun ProductsListItem(
|
|||||||
onFavouriteClick: (ProductItem) -> Unit = {},
|
onFavouriteClick: (ProductItem) -> Unit = {},
|
||||||
onInstallClick: (ProductItem) -> Unit = {}
|
onInstallClick: (ProductItem) -> Unit = {}
|
||||||
) {
|
) {
|
||||||
val imageData by remember(item, repo) {
|
val product by remember(item) { mutableStateOf(item) }
|
||||||
|
val imageData by remember(product, repo) {
|
||||||
mutableStateOf(
|
mutableStateOf(
|
||||||
CoilDownloader.createIconUri(
|
CoilDownloader.createIconUri(
|
||||||
item.packageName,
|
product.packageName,
|
||||||
item.icon,
|
product.icon,
|
||||||
item.metadataIcon,
|
product.metadataIcon,
|
||||||
repo?.address,
|
repo?.address,
|
||||||
repo?.authentication
|
repo?.authentication
|
||||||
).toString()
|
).toString()
|
||||||
@ -46,10 +47,10 @@ fun ProductsListItem(
|
|||||||
|
|
||||||
ExpandableCard(
|
ExpandableCard(
|
||||||
modifier = Modifier.padding(horizontal = 8.dp, vertical = 8.dp),
|
modifier = Modifier.padding(horizontal = 8.dp, vertical = 8.dp),
|
||||||
onClick = { onUserClick(item) },
|
onClick = { onUserClick(product) },
|
||||||
expandedContent = {
|
expandedContent = {
|
||||||
ExpandedItemContent(
|
ExpandedItemContent(
|
||||||
item = item,
|
item = product,
|
||||||
onFavourite = onFavouriteClick,
|
onFavourite = onFavouriteClick,
|
||||||
onInstallClicked = onInstallClick
|
onInstallClicked = onInstallClick
|
||||||
)
|
)
|
||||||
@ -74,7 +75,7 @@ fun ProductsListItem(
|
|||||||
.fillMaxHeight(0.4f),
|
.fillMaxHeight(0.4f),
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = item.name,
|
text = product.name,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.align(Alignment.CenterVertically)
|
.align(Alignment.CenterVertically)
|
||||||
.weight(1f),
|
.weight(1f),
|
||||||
@ -84,8 +85,8 @@ fun ProductsListItem(
|
|||||||
style = MaterialTheme.typography.titleMedium
|
style = MaterialTheme.typography.titleMedium
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = item.version,
|
|
||||||
modifier = Modifier.align(Alignment.CenterVertically),
|
modifier = Modifier.align(Alignment.CenterVertically),
|
||||||
|
text = product.version,
|
||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
@ -95,7 +96,7 @@ fun ProductsListItem(
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxHeight()
|
.fillMaxHeight()
|
||||||
.fillMaxWidth(),
|
.fillMaxWidth(),
|
||||||
text = item.summary,
|
text = product.summary,
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
maxLines = 2,
|
maxLines = 2,
|
||||||
|
@ -27,7 +27,8 @@ fun ChipRow(
|
|||||||
) {
|
) {
|
||||||
LazyRow(
|
LazyRow(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
|
contentPadding = PaddingValues(horizontal = 8.dp)
|
||||||
) {
|
) {
|
||||||
items(list) {
|
items(list) {
|
||||||
Chip(
|
Chip(
|
||||||
@ -38,7 +39,7 @@ fun ChipRow(
|
|||||||
Text(
|
Text(
|
||||||
text = it,
|
text = it,
|
||||||
style = MaterialTheme.typography.labelLarge,
|
style = MaterialTheme.typography.labelLarge,
|
||||||
color = MaterialTheme.colorScheme.primary.copy(alpha = ChipDefaults.ContentOpacity)
|
color = chipColors.contentColor(enabled = true).value
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,8 @@ import androidx.fragment.app.Fragment
|
|||||||
abstract class BaseNavFragment : Fragment() {
|
abstract class BaseNavFragment : Fragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
setupAdapters()
|
|
||||||
setupLayout()
|
setupLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract fun setupAdapters()
|
|
||||||
abstract fun setupLayout()
|
abstract fun setupLayout()
|
||||||
}
|
}
|
@ -48,9 +48,6 @@ class ExploreFragment : MainNavFragmentX() {
|
|||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setupAdapters() {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun setupLayout() {
|
override fun setupLayout() {
|
||||||
viewModel.repositories.observe(viewLifecycleOwner) {
|
viewModel.repositories.observe(viewLifecycleOwner) {
|
||||||
repositories = it.associateBy { repo -> repo.id }
|
repositories = it.associateBy { repo -> repo.id }
|
||||||
|
@ -39,9 +39,6 @@ class InstalledFragment : MainNavFragmentX() {
|
|||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setupAdapters() {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun setupLayout() {
|
override fun setupLayout() {
|
||||||
viewModel.repositories.observe(viewLifecycleOwner) {
|
viewModel.repositories.observe(viewLifecycleOwner) {
|
||||||
repositories = it.associateBy { repo -> repo.id }
|
repositories = it.associateBy { repo -> repo.id }
|
||||||
|
@ -39,9 +39,6 @@ class LatestFragment : MainNavFragmentX() {
|
|||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setupAdapters() {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun setupLayout() {
|
override fun setupLayout() {
|
||||||
viewModel.repositories.observe(viewLifecycleOwner) {
|
viewModel.repositories.observe(viewLifecycleOwner) {
|
||||||
repositories = it.associateBy { repo -> repo.id }
|
repositories = it.associateBy { repo -> repo.id }
|
||||||
|
@ -43,12 +43,9 @@ class PrefsRepositoriesFragment : BaseNavFragment() {
|
|||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setupAdapters() {
|
override fun setupLayout() {
|
||||||
syncConnection.bind(requireContext())
|
syncConnection.bind(requireContext())
|
||||||
binding.addRepository.setOnClickListener { viewModel.addRepository() }
|
binding.addRepository.setOnClickListener { viewModel.addRepository() }
|
||||||
}
|
|
||||||
|
|
||||||
override fun setupLayout() {
|
|
||||||
viewModel.repositories.observe(requireActivity()) {
|
viewModel.repositories.observe(requireActivity()) {
|
||||||
binding.reposRecycler.setContent {
|
binding.reposRecycler.setContent {
|
||||||
AppTheme(
|
AppTheme(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user