New plugin added dialog missing plugin icon

https://github.com/osmandapp/OsmAnd-Issues/issues/489
This commit is contained in:
androiddevkotlin 2021-03-10 16:17:39 +02:00
parent c0e769b746
commit e30e2e1034
2 changed files with 14 additions and 4 deletions

View file

@ -4,6 +4,7 @@ import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
@ -225,7 +226,10 @@ public class PluginsFragment extends BaseOsmAndFragment implements PluginStateLi
pluginDescription.setText(plugin.getDescription());
int color = AndroidUtils.getColorFromAttr(context, R.attr.list_background_color);
pluginLogo.setImageDrawable(UiUtilities.tintDrawable(plugin.getLogoResource(), color));
Drawable pluginIcon = plugin.getLogoResource();
pluginIcon.clearColorFilter();
pluginLogo.setImageDrawable(UiUtilities.tintDrawable(pluginIcon, color));
pluginLogo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View file

@ -2,7 +2,9 @@ package net.osmand.plus.dialogs;
import android.app.Activity;
import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.SpannableString;
import android.view.View;
@ -11,12 +13,11 @@ import android.widget.LinearLayout;
import android.widget.ProgressBar;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentManager;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.plus.profiles.ProfileDataUtils;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
@ -34,6 +35,8 @@ import net.osmand.plus.download.DownloadValidationManager;
import net.osmand.plus.download.IndexItem;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.profiles.ProfileDataUtils;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.widgets.style.CustomTypefaceSpan;
import org.apache.commons.logging.Log;
@ -87,11 +90,14 @@ public class PluginInstalledBottomSheetDialog extends MenuBottomSheetDialogFragm
Typeface typeface = FontCache.getRobotoMedium(getContext());
SpannableString pluginTitleSpan = new SpannableString(plugin.getName());
pluginTitleSpan.setSpan(new CustomTypefaceSpan(typeface), 0, pluginTitleSpan.length(), 0);
Drawable pluginIcon = plugin.getLogoResource();
pluginIcon.setColorFilter(ContextCompat.getColor(
context, nightMode ? R.color.icon_color_default_light : R.color.icon_color_default_dark), PorterDuff.Mode.MULTIPLY);
BaseBottomSheetItem pluginTitle = new SimpleBottomSheetItem.Builder()
.setTitle(pluginTitleSpan)
.setTitleColorId(nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light)
.setIcon(plugin.getLogoResource())
.setIcon(pluginIcon)
.setLayoutId(R.layout.bottom_sheet_item_simple_56dp)
.create();
items.add(pluginTitle);