Add plugin icon to install dialog
This commit is contained in:
parent
4502d56394
commit
57669086a7
2 changed files with 18 additions and 19 deletions
|
@ -328,25 +328,11 @@ public class CustomOsmandPlugin extends OsmandPlugin {
|
|||
File[] files = pluginResDir.listFiles();
|
||||
for (File resFile : files) {
|
||||
String path = resFile.getAbsolutePath();
|
||||
for (Map.Entry<String, String> entry : iconNames.entrySet()) {
|
||||
String value = entry.getValue();
|
||||
if (value.startsWith("@")) {
|
||||
value = value.substring(1);
|
||||
if (path.endsWith(value)) {
|
||||
icon = BitmapDrawable.createFromPath(path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (icon == null) {
|
||||
icon = getIconForFile(path, iconNames);
|
||||
}
|
||||
for (Map.Entry<String, String> entry : imageNames.entrySet()) {
|
||||
String value = entry.getValue();
|
||||
if (value.startsWith("@")) {
|
||||
value = value.substring(1);
|
||||
if (path.endsWith(value)) {
|
||||
image = BitmapDrawable.createFromPath(path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (image == null) {
|
||||
image = getIconForFile(path, imageNames);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -354,6 +340,19 @@ public class CustomOsmandPlugin extends OsmandPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
private Drawable getIconForFile(String path, Map<String, String> fileNames) {
|
||||
for (Map.Entry<String, String> entry : fileNames.entrySet()) {
|
||||
String value = entry.getValue();
|
||||
if (value.startsWith("@")) {
|
||||
value = value.substring(1);
|
||||
}
|
||||
if (path.endsWith(value)) {
|
||||
return BitmapDrawable.createFromPath(path);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Drawable getLogoResource() {
|
||||
|
|
|
@ -91,7 +91,7 @@ public class PluginInstalledBottomSheetDialog extends MenuBottomSheetDialogFragm
|
|||
BaseBottomSheetItem pluginTitle = new SimpleBottomSheetItem.Builder()
|
||||
.setTitle(pluginTitleSpan)
|
||||
.setTitleColorId(nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light)
|
||||
.setIcon(getContentIcon(R.drawable.ic_extension_dark))
|
||||
.setIcon(plugin.getLogoResource())
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple_56dp)
|
||||
.create();
|
||||
items.add(pluginTitle);
|
||||
|
|
Loading…
Reference in a new issue