Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ public BackgroundPluginSettingSection(SettingActivity activity) {
@Override
protected List<SettingItem> buildItems() {
List<SettingItem> items = new ArrayList<>();
items.add(textItem(R.string.background_plugin_title, currentPluginDescription()));
List<BackgroundPluginManager.BackgroundPluginEntry> 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;
}

Expand All @@ -29,12 +34,15 @@ public void onItemClick(int position) {
}

private String currentPluginDescription() {
return describeSelected(BackgroundPluginManager.listInstalled(activity));
}

private String describeSelected(List<BackgroundPluginManager.BackgroundPluginEntry> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ public IconPackSettingSection(SettingActivity activity, PreferencesUtils prefs)
@Override
protected List<SettingItem> buildItems() {
List<SettingItem> items = new ArrayList<>();
items.add(textItem(R.string.icon_pack_title, currentPackDescription()));
List<IconPackManager.IconPackEntry> 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;
}

Expand All @@ -33,11 +37,15 @@ public void onItemClick(int position) {
}

private String currentPackDescription() {
return describeSelected(IconPackManager.listInstalled(activity));
}

private String describeSelected(List<IconPackManager.IconPackEntry> 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();
Expand Down
Loading