1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-09 15:08:31 -04:00

launcher: dispatch plugin-category items as plugin, not app

fixes #2988
port 1.5
This commit is contained in:
bbedward
2026-08-03 20:05:23 -04:00
parent dc8a47644a
commit 365474b0d9
2 changed files with 37 additions and 33 deletions
+19 -11
View File
@@ -819,16 +819,24 @@ Item {
} }
if (isCategoryFiltered) { if (isCategoryFiltered) {
var rawApps = AppSearchService.getAppsInCategory(appCategory); var categoryPluginId = AppSearchService.getPluginIdForCategory(appCategory);
for (var i = 0; i < rawApps.length; i++) { if (categoryPluginId) {
allItems.push(getOrTransformApp(rawApps[i])); var pluginCategoryItems = getPluginItems(categoryPluginId, "");
} for (var i = 0; i < pluginCategoryItems.length; i++) {
// Also include core apps (DMS Settings etc.) that match this category allItems.push(pluginCategoryItems[i]);
var allCoreApps = AppSearchService.getCoreApps(""); }
for (var i = 0; i < allCoreApps.length; i++) { } else {
var coreAppCats = AppSearchService.getCategoriesForApp(allCoreApps[i]); var rawApps = AppSearchService.getAppsInCategory(appCategory);
if (coreAppCats.indexOf(appCategory) !== -1) for (var i = 0; i < rawApps.length; i++) {
allItems.push(transformCoreApp(allCoreApps[i])); allItems.push(getOrTransformApp(rawApps[i]));
}
// Also include core apps (DMS Settings etc.) that match this category
var allCoreApps = AppSearchService.getCoreApps("");
for (var i = 0; i < allCoreApps.length; i++) {
var coreAppCats = AppSearchService.getCategoriesForApp(allCoreApps[i]);
if (coreAppCats.indexOf(appCategory) !== -1)
allItems.push(transformCoreApp(allCoreApps[i]));
}
} }
} else { } else {
var apps = searchApps(searchQuery); var apps = searchApps(searchQuery);
@@ -839,7 +847,7 @@ Item {
var scoredItems = Scorer.scoreItems(allItems, searchQuery, getFrecencyForItem); var scoredItems = Scorer.scoreItems(allItems, searchQuery, getFrecencyForItem);
var sortAlpha = !searchQuery && SettingsData.sortAppsAlphabetically; var sortAlpha = !searchQuery && SettingsData.sortAppsAlphabetically;
var newSections = Scorer.groupBySection(scoredItems, sectionDefinitions, sortAlpha, searchQuery ? 50 : 500); var newSections = Scorer.groupBySection(scoredItems, buildDynamicSectionDefs(allItems), sortAlpha, searchQuery ? 50 : 500);
for (var sid in collapsedSections) { for (var sid in collapsedSections) {
for (var i = 0; i < newSections.length; i++) { for (var i = 0; i < newSections.length; i++) {
+18 -22
View File
@@ -785,16 +785,24 @@ Singleton {
if (category === I18n.tr("All")) if (category === I18n.tr("All"))
return visibleApps; return visibleApps;
const pluginItems = getPluginItems(category, "");
if (pluginItems.length > 0)
return pluginItems;
return visibleApps.filter(app => { return visibleApps.filter(app => {
const appCategories = getCategoriesForApp(app); const appCategories = getCategoriesForApp(app);
return appCategories.includes(category); return appCategories.includes(category);
}); });
} }
function getPluginIdForCategory(category) {
if (typeof PluginService === "undefined")
return null;
const launchers = PluginService.getLauncherPlugins();
for (const pluginId in launchers) {
if ((launchers[pluginId].name || pluginId) === category)
return pluginId;
}
return null;
}
// Plugin launcher support functions // Plugin launcher support functions
function getPluginCategories() { function getPluginCategories() {
if (typeof PluginService === "undefined") { if (typeof PluginService === "undefined") {
@@ -814,31 +822,19 @@ Singleton {
} }
function getPluginCategoryIcon(category) { function getPluginCategoryIcon(category) {
if (typeof PluginService === "undefined") const pluginId = getPluginIdForCategory(category);
if (!pluginId)
return null; return null;
const launchers = PluginService.getLauncherPlugins(); return PluginService.getLauncherPlugins()[pluginId].icon || "extension";
for (const pluginId in launchers) {
const plugin = launchers[pluginId];
if ((plugin.name || pluginId) === category) {
return plugin.icon || "extension";
}
}
return null;
} }
function getPluginItems(category, query) { function getPluginItems(category, query) {
if (typeof PluginService === "undefined") const pluginId = getPluginIdForCategory(category);
if (!pluginId)
return []; return [];
const launchers = PluginService.getLauncherPlugins(); return getPluginItemsForPlugin(pluginId, query);
for (const pluginId in launchers) {
const plugin = launchers[pluginId];
if ((plugin.name || pluginId) === category) {
return getPluginItemsForPlugin(pluginId, query);
}
}
return [];
} }
function getPluginItemsForPlugin(pluginId, query) { function getPluginItemsForPlugin(pluginId, query) {