diff --git a/src/main/kotlin/com/machiav3lli/fdroid/Common.kt b/src/main/kotlin/com/machiav3lli/fdroid/Common.kt index 280a7f14..657f91ab 100644 --- a/src/main/kotlin/com/machiav3lli/fdroid/Common.kt +++ b/src/main/kotlin/com/machiav3lli/fdroid/Common.kt @@ -50,6 +50,7 @@ const val ROW_CAN_UPDATE = "can_update" const val ROW_MATCH_RANK = "match_rank" const val ROW_IGNORED_VERSION = "ignoredVersion" const val ROW_IGNORE_UPDATES = "ignoreUpdates" +const val ROW_FAVORITE = "favorite" const val RELEASE_STATE_NONE = 0 const val RELEASE_STATE_SUGGESTED = 1 diff --git a/src/main/kotlin/com/machiav3lli/fdroid/database/dao/ProductDao.kt b/src/main/kotlin/com/machiav3lli/fdroid/database/dao/ProductDao.kt index 5c0e5127..1a3638fd 100644 --- a/src/main/kotlin/com/machiav3lli/fdroid/database/dao/ProductDao.kt +++ b/src/main/kotlin/com/machiav3lli/fdroid/database/dao/ProductDao.kt @@ -16,6 +16,7 @@ import com.machiav3lli.fdroid.ROW_COMPATIBLE import com.machiav3lli.fdroid.ROW_DESCRIPTION import com.machiav3lli.fdroid.ROW_DONATES import com.machiav3lli.fdroid.ROW_ENABLED +import com.machiav3lli.fdroid.ROW_FAVORITE import com.machiav3lli.fdroid.ROW_ICON import com.machiav3lli.fdroid.ROW_ID import com.machiav3lli.fdroid.ROW_IGNORED_VERSION @@ -191,6 +192,8 @@ interface ProductDao : BaseDao { } else if (section is Section.Repository) { builder += "AND $TABLE_PRODUCT.$ROW_REPOSITORY_ID = ?" builder %= section.id.toString() + } else if (section is Section.FAVORITE) { + builder += "AND COALESCE($TABLE_EXTRAS.$ROW_FAVORITE, 0) != 0" } // Filter only apps that have some matching score to the search query diff --git a/src/main/kotlin/com/machiav3lli/fdroid/entity/Section.kt b/src/main/kotlin/com/machiav3lli/fdroid/entity/Section.kt index 0d7d6f16..f1af8c6a 100644 --- a/src/main/kotlin/com/machiav3lli/fdroid/entity/Section.kt +++ b/src/main/kotlin/com/machiav3lli/fdroid/entity/Section.kt @@ -10,6 +10,12 @@ sealed class Section : KParcelable { val CREATOR = KParcelable.creator { All } } + object FAVORITE : Section() { + @Suppress("unused") + @JvmField + val CREATOR = KParcelable.creator { FAVORITE } + } + data class Category(val name: String) : Section() { override fun writeToParcel(dest: Parcel, flags: Int) { dest.writeString(name) diff --git a/src/main/kotlin/com/machiav3lli/fdroid/ui/fragments/ExploreFragment.kt b/src/main/kotlin/com/machiav3lli/fdroid/ui/fragments/ExploreFragment.kt index f1b7f2e8..197c7eac 100644 --- a/src/main/kotlin/com/machiav3lli/fdroid/ui/fragments/ExploreFragment.kt +++ b/src/main/kotlin/com/machiav3lli/fdroid/ui/fragments/ExploreFragment.kt @@ -120,12 +120,14 @@ class ExploreFragment : MainNavFragmentX() { CategoryChipList( list = listOf( stringResource(id = R.string.all_applications), + stringResource(id = R.string.favorite_applications), *categories.sorted().toTypedArray() ) ) { viewModel.sections.postValue( when (it) { getString(R.string.all_applications) -> Section.All + getString(R.string.favorite_applications) -> Section.FAVORITE else -> Section.Category(it) } ) diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 9cc5f8d3..0bfdc81b 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -208,4 +208,5 @@ Releases No versions available System dynamic + Favorites