feat(caddy&deck): add sys and g apps folder
This commit is contained in:
1 parent
f7208730e4
commit
0ff9636c38
3 files changed
+34
-22
No files matched your search
@@ -8,10 +8,10 @@ import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import app.lawnchair.data.folder.model.FolderOrderUtils
|
||||
import app.lawnchair.data.folder.model.FolderViewModel
|
||||
import app.lawnchair.flowerpot.Flowerpot
|
||||
import app.lawnchair.launcher
|
||||
import app.lawnchair.preferences.PreferenceManager
|
||||
import app.lawnchair.preferences2.PreferenceManager2
|
||||
import app.lawnchair.util.categorizeAppsWithSystemAndGoogle
|
||||
import com.android.launcher3.InvariantDeviceProfile.OnIDPChangeListener
|
||||
import com.android.launcher3.allapps.AllAppsStore
|
||||
import com.android.launcher3.allapps.AlphabeticalAppsList
|
||||
@@ -44,7 +44,6 @@ class LawnchairAlphabeticalAppsList<T>(
|
||||
private val filteredList = mutableListOf<AppInfo>()
|
||||
|
||||
private val folderOrder = FolderOrderUtils.stringToIntList(prefs.drawerListOrder.get())
|
||||
private val potsManager = Flowerpot.Manager.getInstance(context)
|
||||
|
||||
init {
|
||||
context.launcher.deviceProfile.inv.addOnChangeListener(this)
|
||||
@@ -87,8 +86,10 @@ class LawnchairAlphabeticalAppsList<T>(
|
||||
if (isWorkOrPrivateSpace(appList)) return super.addAppsWithSections(appList, position)
|
||||
|
||||
if (!drawerListDefault) {
|
||||
val categorizedApps = potsManager.categorizeApps(appList)
|
||||
categorizedApps.forEach { (category, apps) ->
|
||||
val validApps = appList.mapNotNull { it }
|
||||
val finalCategorizedApps = categorizeAppsWithSystemAndGoogle(validApps, context)
|
||||
|
||||
finalCategorizedApps.forEach { (category, apps) ->
|
||||
if (apps.size == 1) {
|
||||
mAdapterItems.add(AdapterItem.asApp(apps.first()))
|
||||
} else {
|
||||
|
||||
@@ -6,6 +6,7 @@ import app.lawnchair.LawnchairLauncher
|
||||
import app.lawnchair.flowerpot.Flowerpot
|
||||
import app.lawnchair.launcher
|
||||
import app.lawnchair.launcherNullable
|
||||
import app.lawnchair.util.categorizeAppsWithSystemAndGoogle
|
||||
import app.lawnchair.util.restartLauncher
|
||||
import com.android.launcher3.InvariantDeviceProfile
|
||||
import com.android.launcher3.LauncherAppState
|
||||
@@ -17,6 +18,7 @@ import com.android.launcher3.model.data.FolderInfo
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo
|
||||
import com.android.launcher3.provider.RestoreDbTask
|
||||
import com.android.launcher3.util.ComponentKey
|
||||
import com.android.launcher3.util.PackageManagerHelper
|
||||
import java.io.File
|
||||
import java.util.Locale
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
@@ -101,9 +103,8 @@ class LawndeckManager(private val context: Context) {
|
||||
|
||||
onProgress?.invoke("Categorizing apps...")
|
||||
|
||||
// Use flowerpot to categorize apps
|
||||
val potsManager = Flowerpot.Manager.getInstance(context)
|
||||
val categorizedApps = potsManager.categorizeApps(apps.map { it as? AppInfo })
|
||||
val validApps = apps.mapNotNull { it as? AppInfo }
|
||||
val finalCategorizedApps = categorizeAppsWithSystemAndGoogle(validApps, context)
|
||||
|
||||
onProgress?.invoke("Adding apps to workspace...")
|
||||
|
||||
@@ -115,7 +116,7 @@ class LawndeckManager(private val context: Context) {
|
||||
var singleAppCount = 0
|
||||
|
||||
// Process each category
|
||||
categorizedApps.forEach { (category, categoryApps) ->
|
||||
finalCategorizedApps.forEach { (category, categoryApps) ->
|
||||
if (categoryApps.isEmpty()) return@forEach
|
||||
|
||||
if (categoryApps.size == 1) {
|
||||
@@ -188,22 +189,32 @@ class LawndeckManager(private val context: Context) {
|
||||
val activityInfo = activities[0]
|
||||
val appInfo = AppInfo(context, activityInfo, user)
|
||||
|
||||
// Use flowerpot to categorize the app
|
||||
val potsManager = Flowerpot.Manager.getInstance(context)
|
||||
val categorizedApps = potsManager.categorizeApps(listOf(appInfo))
|
||||
val intent = appInfo.intent
|
||||
|
||||
if (categorizedApps.isEmpty()) {
|
||||
// No category found, add directly to workspace
|
||||
ItemInstallQueue.INSTANCE.get(context).queueItem(packageName, user)
|
||||
return
|
||||
}
|
||||
// Determine category: Google Apps > System Apps > Flowerpot categories
|
||||
val category = when {
|
||||
packageName.startsWith("com.google.") -> "Google Apps"
|
||||
|
||||
// Get the category for this app (categorizedApps is a Map<String, List<AppInfo>>)
|
||||
val categoryEntry = categorizedApps.entries.firstOrNull() ?: run {
|
||||
ItemInstallQueue.INSTANCE.get(context).queueItem(packageName, user)
|
||||
return
|
||||
intent != null && PackageManagerHelper.isSystemApp(context, intent) -> "System Apps"
|
||||
|
||||
else -> {
|
||||
// Use flowerpot to categorize the app
|
||||
val potsManager = Flowerpot.Manager.getInstance(context)
|
||||
val categorizedApps = potsManager.categorizeApps(listOf(appInfo))
|
||||
|
||||
if (categorizedApps.isEmpty()) {
|
||||
// No category found, add directly to workspace
|
||||
ItemInstallQueue.INSTANCE.get(context).queueItem(packageName, user)
|
||||
return
|
||||
}
|
||||
|
||||
// Get the category from flowerpot
|
||||
categorizedApps.entries.firstOrNull()?.key ?: run {
|
||||
ItemInstallQueue.INSTANCE.get(context).queueItem(packageName, user)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
val category = categoryEntry.key
|
||||
|
||||
// Check if there's already a folder for this category on workspace
|
||||
val existingFolder = findFolderByCategory(category, dataModel)
|
||||
|
||||
@@ -46,7 +46,7 @@ data object Google : QsbSearchProvider(
|
||||
Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK,
|
||||
Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK,
|
||||
0,
|
||||
options.toBundle()
|
||||
options.toBundle(),
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user