From 5d305fddb4d26412930e59aab6fa9e06bb29b904 Mon Sep 17 00:00:00 2001 From: Afton-programmer Date: Wed, 21 Oct 2026 03:08:53 +0330 Subject: [PATCH] fix(settings): hide icon-pack and background-plugin sections when no plugin is installed Both sections built their single row unconditionally, so with zero installed plugins the settings screen showed a dead "Default" row in a card that could never do anything. They now build zero rows when listInstalled() is empty; the existing hideSectionIfEmpty() then removes the whole card, exactly like the other empty sections. --- .../settings/BackgroundPluginSettingSection.java | 14 +++++++++++--- .../ghostide/settings/IconPackSettingSection.java | 12 ++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/ir/hanzodev1375/ghostide/settings/BackgroundPluginSettingSection.java b/app/src/main/java/ir/hanzodev1375/ghostide/settings/BackgroundPluginSettingSection.java index 61c86df..b04d6f8 100644 --- a/app/src/main/java/ir/hanzodev1375/ghostide/settings/BackgroundPluginSettingSection.java +++ b/app/src/main/java/ir/hanzodev1375/ghostide/settings/BackgroundPluginSettingSection.java @@ -19,7 +19,12 @@ public BackgroundPluginSettingSection(SettingActivity activity) { @Override protected List buildItems() { List items = new ArrayList<>(); - items.add(textItem(R.string.background_plugin_title, currentPluginDescription())); + List plugins = + BackgroundPluginManager.listInstalled(activity); + // With no background plugin installed there is nothing to pick; leave the list empty so the + // host hides the whole section instead of showing a dead row. + if (plugins.isEmpty()) return items; + items.add(textItem(R.string.background_plugin_title, describeSelected(plugins))); return items; } @@ -29,12 +34,15 @@ public void onItemClick(int position) { } private String currentPluginDescription() { + return describeSelected(BackgroundPluginManager.listInstalled(activity)); + } + + private String describeSelected(List plugins) { String selected = BackgroundPluginManager.selected(activity); if (selected == null || selected.isEmpty()) { return getString(R.string.background_plugin_default); } - for (BackgroundPluginManager.BackgroundPluginEntry entry : - BackgroundPluginManager.listInstalled(activity)) { + for (BackgroundPluginManager.BackgroundPluginEntry entry : plugins) { if (entry.id().equals(selected)) { if (entry.version() == null || entry.version().isEmpty()) { return entry.name(); diff --git a/app/src/main/java/ir/hanzodev1375/ghostide/settings/IconPackSettingSection.java b/app/src/main/java/ir/hanzodev1375/ghostide/settings/IconPackSettingSection.java index 197670a..5b6431e 100644 --- a/app/src/main/java/ir/hanzodev1375/ghostide/settings/IconPackSettingSection.java +++ b/app/src/main/java/ir/hanzodev1375/ghostide/settings/IconPackSettingSection.java @@ -23,7 +23,11 @@ public IconPackSettingSection(SettingActivity activity, PreferencesUtils prefs) @Override protected List buildItems() { List items = new ArrayList<>(); - items.add(textItem(R.string.icon_pack_title, currentPackDescription())); + List packs = IconPackManager.listInstalled(activity); + // With no icon pack plugin installed there is nothing to pick; leave the list empty so the + // host hides the whole section instead of showing a dead row. + if (packs.isEmpty()) return items; + items.add(textItem(R.string.icon_pack_title, describeSelected(packs))); return items; } @@ -33,11 +37,15 @@ public void onItemClick(int position) { } private String currentPackDescription() { + return describeSelected(IconPackManager.listInstalled(activity)); + } + + private String describeSelected(List packs) { String selected = prefs.getIconPack(); if (selected == null || selected.isEmpty()) { return getString(R.string.icon_pack_default); } - for (IconPackManager.IconPackEntry entry : IconPackManager.listInstalled(activity)) { + for (IconPackManager.IconPackEntry entry : packs) { if (entry.id().equals(selected)) { if (entry.version() == null || entry.version().isEmpty()) { return entry.name();