Add filter to list & update apps installed by Aurora Store only

- Improves fdroid filter
- Remove all apps that have no launch intent:
This commit is contained in:
Rahul Patel
2023-10-18 05:29:24 +05:30
parent 79516bbc20
commit c7c2781281
11 changed files with 79 additions and 36 deletions

View File

@@ -61,6 +61,10 @@ fun isTAndAbove(): Boolean {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
}
fun isUAndAbove(): Boolean {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE
}
fun isMIUI(): Boolean {
return getSystemProperty("ro.miui.ui.version.name").isNotEmpty()
}

View File

@@ -61,7 +61,7 @@ class NativeInstaller(context: Context) : InstallerBase(context) {
}
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true)
intent.putExtra(Intent.EXTRA_INSTALLER_PACKAGE_NAME, "com.android.vending")
intent.putExtra(Intent.EXTRA_INSTALLER_PACKAGE_NAME, context.packageName)
context.startActivity(intent)
}
}

View File

@@ -28,6 +28,7 @@ import com.aurora.extensions.isNAndAbove
import com.aurora.extensions.isOAndAbove
import com.aurora.extensions.isSAndAbove
import com.aurora.extensions.isTAndAbove
import com.aurora.extensions.isUAndAbove
import com.aurora.store.util.Log
@@ -54,6 +55,9 @@ class SessionInstaller(context: Context) : SessionInstallerBase(context) {
if (isTAndAbove()) {
setPackageSource(PACKAGE_SOURCE_STORE)
}
if (isUAndAbove()) {
setInstallerPackageName(context.packageName)
}
}
val sessionId = packageInstaller.createSession(sessionParams)

View File

@@ -143,7 +143,18 @@ object PackageUtil {
val flags: Int = PackageManager.GET_META_DATA
var packageInfoList: List<PackageInfo> = packageManager.getInstalledPackages(flags)
val isFdroidFilterEnabled = Preferences.getBoolean(
val isGoogleFilterEnabled = Preferences.getBoolean(
context,
Preferences.PREFERENCE_FILTER_GOOGLE
)
val isAuroraOnlyUpdateEnabled = Preferences.getBoolean(
context,
Preferences.PREFERENCE_FILTER_AURORA_ONLY,
false
)
val isFDroidFilterEnabled = Preferences.getBoolean(
context,
Preferences.PREFERENCE_FILTER_FDROID
)
@@ -154,18 +165,54 @@ object PackageUtil {
)
packageInfoList = packageInfoList.filter {
it.packageName != null && it.applicationInfo != null
it.packageName != null
&& it.applicationInfo != null
&& packageManager.getLaunchIntentForPackage(it.packageName) != null
}
/*Filter google apps*/
if (isGoogleFilterEnabled) {
packageInfoList = packageInfoList
.filter {
!listOf(
"com.chrome.beta",
"com.chrome.canary",
"com.chrome.dev",
"com.android.chrome",
"com.niksoftware.snapseed",
"com.google.toontastic",
).contains(it.packageName)
}.filter {
it.packageName?.contains("com.google") == false
}
}
/*Select only Aurora STore installed apps*/
if (isAuroraOnlyUpdateEnabled) {
packageInfoList = packageInfoList
.filter {
val packageInstaller = packageManager.getInstallerPackageName(it.packageName)
listOf(
"com.aurora.store",
"com.aurora.store.nightly",
"com.aurora.services"
).contains(packageInstaller)
}
}
if (!isExtendedUpdateEnabled) {
packageInfoList = packageInfoList.filter { it.applicationInfo.enabled }
}
if (isFdroidFilterEnabled) {
/*Filter F-Droid apps*/
if (isFDroidFilterEnabled) {
packageInfoList = packageInfoList
.filter {
val packageInstaller = packageManager.getInstallerPackageName(it.packageName)
packageInstaller != "org.fdroid.fdroid.privileged"
!listOf(
"org.fdroid.fdroid",
"org.fdroid.fdroid.privileged"
).contains(packageInstaller)
}.filter {
!CertUtil.isFDroidApp(context, it.packageName)
}

View File

@@ -41,6 +41,7 @@ object Preferences {
const val PREFERENCE_FILTER_GOOGLE = "PREFERENCE_FILTER_GOOGLE"
const val PREFERENCE_FILTER_FDROID = "PREFERENCE_FILTER_FDROID"
const val PREFERENCE_FILTER_SEARCH = "PREFERENCE_FILTER_SEARCH"
const val PREFERENCE_FILTER_AURORA_ONLY = "PREFERENCE_FILTER_AURORA_ONLY"
const val PREFERENCE_AUTO_INSTALL = "PREFERENCE_AUTO_INSTALL"
const val PREFERENCE_AUTO_DELETE = "PREFERENCE_AUTO_DELETE"
@@ -107,8 +108,8 @@ object Preferences {
return getPrefs(context).getLong(key, 0L)
}
fun getBoolean(context: Context, key: String): Boolean {
return getPrefs(context).getBoolean(key, false)
fun getBoolean(context: Context, key: String, default: Boolean = false): Boolean {
return getPrefs(context).getBoolean(key, default)
}
}

View File

@@ -59,6 +59,7 @@ class InstalledAppsFragment : BaseFragment() {
)
VM = ViewModelProvider(requireActivity())[InstalledViewModel::class.java]
VM.observe()
return B.root
}

View File

@@ -40,6 +40,7 @@ import com.aurora.store.util.Preferences.PREFERENCE_DOWNLOAD_ACTIVE
import com.aurora.store.util.Preferences.PREFERENCE_DOWNLOAD_DIRECTORY
import com.aurora.store.util.Preferences.PREFERENCE_DOWNLOAD_EXTERNAL
import com.aurora.store.util.Preferences.PREFERENCE_DOWNLOAD_WIFI_ONLY
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_AURORA_ONLY
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_FDROID
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_GOOGLE
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_SEARCH
@@ -151,6 +152,7 @@ class OnboardingFragment : Fragment(R.layout.fragment_onboarding) {
private fun loadDefaultPreferences() {
/*Filters*/
save(PREFERENCE_FILTER_AURORA_ONLY, false)
save(PREFERENCE_FILTER_FDROID, true)
save(PREFERENCE_FILTER_GOOGLE, false)
save(PREFERENCE_FILTER_SEARCH, true)

View File

@@ -28,7 +28,6 @@ import com.aurora.store.data.network.HttpClient
import com.aurora.store.data.providers.AuthProvider
import com.aurora.store.data.providers.BlacklistProvider
import com.aurora.store.util.PackageUtil
import com.aurora.store.util.Preferences
import com.aurora.store.viewmodel.BaseAndroidViewModel
abstract class BaseAppsViewModel(application: Application) : BaseAndroidViewModel(application) {
@@ -50,41 +49,18 @@ abstract class BaseAppsViewModel(application: Application) : BaseAndroidViewMode
fun getFilteredApps(): List<App> {
val blackList = blacklistProvider.getBlackList()
val gapps = getGApps()
val isGoogleFilterEnabled = Preferences.getBoolean(
getApplication(),
Preferences.PREFERENCE_FILTER_GOOGLE
)
packageInfoMap.clear()
packageInfoMap = PackageUtil.getPackageInfoMap(getApplication())
packageInfoMap.keys.let { packages ->
/*Filter black list*/
var filtersPackages = packages
val filtersPackages = packages
.filter { !blackList.contains(it) }
/*Filter google apps*/
if (isGoogleFilterEnabled)
filtersPackages = filtersPackages
.filter { !it.startsWith("com.google") }
.filter { !gapps.contains(it) }
return appDetailsHelper
.getAppByPackageName(filtersPackages)
.filter { it.displayName.isNotEmpty() }
}
}
open fun getGApps(): Set<String> {
val gapps: MutableSet<String> = HashSet()
gapps.add("com.chrome.beta")
gapps.add("com.chrome.canary")
gapps.add("com.chrome.dev")
gapps.add("com.android.chrome")
gapps.add("com.niksoftware.snapseed")
gapps.add("com.google.toontastic")
return gapps
}
}

View File

@@ -37,7 +37,6 @@ class InstalledViewModel(application: Application) : BaseAppsViewModel(applicati
EventBus.getDefault().register(this)
requestState = RequestState.Init
observe()
}
override fun observe() {

View File

@@ -217,9 +217,9 @@
<string name="pref_downloader_path_title">"Download path"</string>
<string name="pref_downloader_wifi_title">"Download using WiFi only"</string>
<string name="pref_download_directory_error">"Selected path is not writable"</string>
<string name="pref_filter_fdroid_summary">"Removes F-Droid apps from app lists"</string>
<string name="pref_filter_fdroid_summary">"Ignore F-Droid apps from Updates and Installed apps"</string>
<string name="pref_filter_fdroid_title">"Filter F-Droid apps"</string>
<string name="pref_filter_google_summary">"Removes all Google Apps from search results and category apps"</string>
<string name="pref_filter_google_summary">"Ignore Google apps from Updates and Installed apps"</string>
<string name="pref_filter_google_title">"Filter Google apps"</string>
<string name="pref_filter_search_summary">"Search filters are reset on each search. Turn off to save search filters"</string>
<string name="pref_filter_search_title">"Use non-persistent search filter"</string>
@@ -254,7 +254,9 @@
<string name="pref_ui_similar_apps">"Similar and related apps"</string>
<string name="pref_ui_similar_apps_desc">"Display similar and related clusters on app details page"</string>
<string name="pref_updates_extended">Extended updates</string>
<string name="pref_updates_extended_desc">Looks for new versions of disabled apps too</string>
<string name="pref_updates_extended_desc">Look for new versions of disabled apps and games</string>
<string name="pref_aurora_only">Aurora Store apps only</string>
<string name="pref_aurora_only_desc">Show only Aurora Store installed apps in Updates and Installed apps</string>
<string name="purchase_failed">"Download Failed"</string>
<string name="purchase_invalid">"App not purchased"</string>
<string name="purchase_unsupported">"App not supported"</string>

View File

@@ -19,6 +19,13 @@
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
<SwitchPreferenceCompat
app:defaultValue="false"
app:iconSpaceReserved="false"
app:key="PREFERENCE_FILTER_AURORA_ONLY"
app:summary="@string/pref_aurora_only_desc"
app:title="@string/pref_aurora_only" />
<SwitchPreferenceCompat
app:defaultValue="false"
app:iconSpaceReserved="false"