This commit is contained in:
androiddevkotlin 2021-03-10 17:49:32 +02:00
parent e30e2e1034
commit edb4dc19e0
2 changed files with 6 additions and 7 deletions

View file

@ -6,7 +6,6 @@ import android.content.DialogInterface;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -23,7 +22,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.PopupMenu;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
@ -228,7 +226,6 @@ public class PluginsFragment extends BaseOsmAndFragment implements PluginStateLi
int color = AndroidUtils.getColorFromAttr(context, R.attr.list_background_color); int color = AndroidUtils.getColorFromAttr(context, R.attr.list_background_color);
Drawable pluginIcon = plugin.getLogoResource(); Drawable pluginIcon = plugin.getLogoResource();
pluginIcon.clearColorFilter();
pluginLogo.setImageDrawable(UiUtilities.tintDrawable(pluginIcon, color)); pluginLogo.setImageDrawable(UiUtilities.tintDrawable(pluginIcon, color));
pluginLogo.setOnClickListener(new View.OnClickListener() { pluginLogo.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -253,7 +250,7 @@ public class PluginsFragment extends BaseOsmAndFragment implements PluginStateLi
if (active) { if (active) {
pluginLogo.setBackgroundResource(nightMode ? R.drawable.bg_plugin_logo_enabled_dark : R.drawable.bg_plugin_logo_enabled_light); pluginLogo.setBackgroundResource(nightMode ? R.drawable.bg_plugin_logo_enabled_dark : R.drawable.bg_plugin_logo_enabled_light);
} else { } else {
TypedArray attributes = context.getTheme().obtainStyledAttributes(new int[] {R.attr.bg_plugin_logo_disabled}); TypedArray attributes = context.getTheme().obtainStyledAttributes(new int[]{R.attr.bg_plugin_logo_disabled});
pluginLogo.setBackgroundDrawable(attributes.getDrawable(0)); pluginLogo.setBackgroundDrawable(attributes.getDrawable(0));
attributes.recycle(); attributes.recycle();
} }

View file

@ -2,7 +2,6 @@ package net.osmand.plus.dialogs;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
@ -91,8 +90,11 @@ public class PluginInstalledBottomSheetDialog extends MenuBottomSheetDialogFragm
SpannableString pluginTitleSpan = new SpannableString(plugin.getName()); SpannableString pluginTitleSpan = new SpannableString(plugin.getName());
pluginTitleSpan.setSpan(new CustomTypefaceSpan(typeface), 0, pluginTitleSpan.length(), 0); pluginTitleSpan.setSpan(new CustomTypefaceSpan(typeface), 0, pluginTitleSpan.length(), 0);
Drawable pluginIcon = plugin.getLogoResource(); Drawable pluginIcon = plugin.getLogoResource();
pluginIcon.setColorFilter(ContextCompat.getColor( if (pluginIcon.getConstantState() != null) {
context, nightMode ? R.color.icon_color_default_light : R.color.icon_color_default_dark), PorterDuff.Mode.MULTIPLY); pluginIcon = pluginIcon.getConstantState().newDrawable().mutate();
}
pluginIcon = UiUtilities.tintDrawable(pluginIcon, ContextCompat.getColor(
context, nightMode ? R.color.icon_color_default_light : R.color.icon_color_default_dark));
BaseBottomSheetItem pluginTitle = new SimpleBottomSheetItem.Builder() BaseBottomSheetItem pluginTitle = new SimpleBottomSheetItem.Builder()
.setTitle(pluginTitleSpan) .setTitle(pluginTitleSpan)