Merge pull request #11104 from osmandapp/New-plugin-added
New plugin added dialog missing plugin icon
This commit is contained in:
commit
0d09754376
2 changed files with 18 additions and 7 deletions
|
@ -4,8 +4,8 @@ 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;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
@ -22,7 +22,6 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
|
@ -225,7 +224,11 @@ 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();
|
||||
if (pluginIcon.getConstantState() != null) {
|
||||
pluginIcon = pluginIcon.getConstantState().newDrawable().mutate();
|
||||
}
|
||||
pluginLogo.setImageDrawable(UiUtilities.tintDrawable(pluginIcon, color));
|
||||
pluginLogo.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.dialogs;
|
|||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableString;
|
||||
import android.view.View;
|
||||
|
@ -11,12 +12,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 +34,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 +89,17 @@ 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();
|
||||
if (pluginIcon.getConstantState() != null) {
|
||||
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()
|
||||
.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);
|
||||
|
|
Loading…
Reference in a new issue