Fix getColorFromAttr

This commit is contained in:
Dima-1 2020-07-07 17:42:18 +03:00
parent 6e6a33d053
commit 04d8392cab
4 changed files with 6 additions and 19 deletions

View file

@ -192,8 +192,7 @@ public class PluginsActivity extends OsmandListActivity implements DownloadIndex
AndroidUtils.removeLinkUnderline(pluginDescription);
OsmandApplication app = getMyApplication();
int color = ContextCompat.getColor(PluginsActivity.this,
light ? R.color.list_background_color_light : R.color.list_background_color_dark);
int color = AndroidUtils.getColorFromAttr(PluginsActivity.this, R.attr.list_background_color);
pluginLogo.setImageDrawable(UiUtilities.tintDrawable(plugin.getLogoResource(), color));
pluginLogo.setOnClickListener(new View.OnClickListener() {
@Override

View file

@ -3,11 +3,9 @@ package net.osmand.plus.liveupdates;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@ -21,8 +19,6 @@ import android.widget.ProgressBar;
import android.widget.Spinner;
import android.widget.TextView;
import androidx.annotation.AttrRes;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import com.google.gson.Gson;
@ -205,9 +201,9 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
};
monthReportsSpinner.setOnItemSelectedListener(onItemSelectedListener);
inactiveColor = getColorFromAttr(R.attr.plugin_details_install_header_bg);
textColorPrimary = getColorFromAttr(android.R.attr.textColorPrimary);
textColorSecondary = getColorFromAttr(android.R.attr.textColorSecondary);
inactiveColor = AndroidUtils.getColorFromAttr(container.getContext(), R.attr.plugin_details_install_header_bg);
textColorPrimary = AndroidUtils.getColorFromAttr(container.getContext(), android.R.attr.textColorPrimary);
textColorSecondary = AndroidUtils.getColorFromAttr(container.getContext(), android.R.attr.textColorSecondary);
return view;
}
@ -427,12 +423,4 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
donationsTotalTextView.setTextColor(textColorPrimary);
recipientsTextView.setTextColor(textColorPrimary);
}
@ColorInt
private int getColorFromAttr(@AttrRes int colorAttribute) {
TypedValue typedValue = new TypedValue();
Resources.Theme theme = getActivity().getTheme();
theme.resolveAttribute(colorAttribute, typedValue, true);
return typedValue.data;
}
}

View file

@ -973,7 +973,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
categoryName = getString(R.string.shared_string_waypoints);
}
SpannableStringBuilder text = new SpannableStringBuilder(categoryName).append(" (").append(String.valueOf(getChildrenCount(groupPosition))).append(")");
text.setSpan(new ForegroundColorSpan(AndroidUtils.getColorFromAttr(app, R.attr.wikivoyage_primary_text_color)),
text.setSpan(new ForegroundColorSpan(AndroidUtils.getColorFromAttr(mainView.getContext(), R.attr.wikivoyage_primary_text_color)),
0, categoryName.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
text.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, R.color.wikivoyage_secondary_text)),
categoryName.length() + 1, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

View file

@ -933,7 +933,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
public void setupPrefRoundedBg(PreferenceViewHolder holder) {
View selectableView = holder.itemView.findViewById(R.id.selectable_list_item);
if (selectableView != null) {
int color = AndroidUtils.getColorFromAttr(app, R.attr.activity_background_color);
int color = AndroidUtils.getColorFromAttr(holder.itemView.getContext(), R.attr.activity_background_color);
int selectedColor = UiUtilities.getColorWithAlpha(getActiveProfileColor(), 0.3f);
Drawable bgDrawable = getPaintedIcon(R.drawable.rectangle_rounded, color);