Fixed drawable tinting bug in geofavs list

This commit is contained in:
Daniele Verducci (Slimpenguin) 2022-01-17 08:19:00 +01:00
parent 4aae6e90be
commit b7f61846e3
4 changed files with 15 additions and 9 deletions

View File

@ -109,7 +109,7 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
Geofavorite geofavorite = geofavoriteListFiltered.get(position); Geofavorite geofavorite = geofavoriteListFiltered.get(position);
holder.tv_category.setText(geofavorite.categoryLetter()); holder.tv_category.setText(geofavorite.categoryLetter());
holder.tv_category_background.setTint( holder.setCategoryColor(
geofavorite.categoryColor() == 0 ? context.getColor(R.color.defaultBrand) : geofavorite.categoryColor()); geofavorite.categoryColor() == 0 ? context.getColor(R.color.defaultBrand) : geofavorite.categoryColor());
holder.tv_title.setText(Html.fromHtml(geofavorite.getName())); holder.tv_title.setText(Html.fromHtml(geofavorite.getName()));
holder.tv_content.setText(geofavorite.getComment()); holder.tv_content.setText(geofavorite.getComment());
@ -164,7 +164,6 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
TextView tv_category, tv_title, tv_content, tv_date; TextView tv_category, tv_title, tv_content, tv_date;
ImageView bt_context_menu; ImageView bt_context_menu;
ImageView bt_nav; ImageView bt_nav;
Drawable tv_category_background;
ItemClickListener itemClickListener; ItemClickListener itemClickListener;
@ -178,7 +177,6 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
tv_date = itemView.findViewById(R.id.date); tv_date = itemView.findViewById(R.id.date);
bt_context_menu = itemView.findViewById(R.id.geofav_context_menu_bt); bt_context_menu = itemView.findViewById(R.id.geofav_context_menu_bt);
bt_nav = itemView.findViewById(R.id.geofav_nav_bt); bt_nav = itemView.findViewById(R.id.geofav_nav_bt);
tv_category_background = DrawableCompat.wrap(tv_category.getBackground());
this.itemClickListener = itemClickListener; this.itemClickListener = itemClickListener;
itemView.setOnClickListener(this); itemView.setOnClickListener(this);
@ -191,19 +189,26 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
public void onClick(View view) { public void onClick(View view) {
switch (view.getId()) { switch (view.getId()) {
case R.id.geofav_context_menu_bt: case R.id.geofav_context_menu_bt:
onOverflowIconClicked(view, getAdapterPosition()); onOverflowIconClicked(view, getBindingAdapterPosition());
break; break;
case R.id.geofav_nav_bt: case R.id.geofav_nav_bt:
if (itemClickListener != null) if (itemClickListener != null)
itemClickListener.onItemNavClick(get(getAdapterPosition())); itemClickListener.onItemNavClick(get(getBindingAdapterPosition()));
break; break;
default: default:
if (itemClickListener != null) if (itemClickListener != null)
itemClickListener.onItemClick(get(getAdapterPosition())); itemClickListener.onItemClick(get(getBindingAdapterPosition()));
} }
} }
public void setCategoryColor(int ccTint) {
Drawable bg = DrawableCompat.wrap(this.tv_category.getContext().getDrawable(R.drawable.ic_list_pin));
this.tv_category.setBackground(bg);
DrawableCompat.setTint(bg, ccTint);
}
} }
private void performSort() { private void performSort() {
if (sortRule == SORT_BY_TITLE) { if (sortRule == SORT_BY_TITLE) {
Collections.sort(geofavoriteListFiltered, Geofavorite.ByTitleAZ); Collections.sort(geofavoriteListFiltered, Geofavorite.ByTitleAZ);

View File

@ -197,7 +197,7 @@ public class Geofavorite implements Serializable {
* @see "https://github.com/nextcloud/maps/blob/master/src/utils.js" * @see "https://github.com/nextcloud/maps/blob/master/src/utils.js"
* @return the generated color or null for the default category * @return the generated color or null for the default category
*/ */
public int categoryColor() { public int categoryColor() {
// If category is default, return null: will be used Nextcloud's accent // If category is default, return null: will be used Nextcloud's accent
if (this.category.equals(DEFAULT_CATEGORY)) if (this.category.equals(DEFAULT_CATEGORY))
return 0; return 0;

View File

@ -1,4 +1,4 @@
<vector android:height="48dp" android:tint="@color/defaultBrand" <vector android:height="48dp"
android:viewportHeight="24" android:viewportWidth="24" android:viewportHeight="24" android:viewportWidth="24"
android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android"> android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13c0,-3.87 -3.13,-7 -7,-7z"/> <path android:fillColor="@android:color/white" android:pathData="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13c0,-3.87 -3.13,-7 -7,-7z"/>

View File

@ -38,7 +38,8 @@
android:paddingTop="5dp" android:paddingTop="5dp"
android:textSize="28dp" android:textSize="28dp"
android:textAllCaps="true" android:textAllCaps="true"
android:textColor="@color/white"/> android:textColor="@color/white"
app:drawableTint="@color/defaultBrand" />
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"