The date background for both litem list and item activities has the now the color of the feed

This commit is contained in:
Shinokuni 2019-03-23 13:31:24 +01:00
parent 789f9d24ea
commit 5fabec0c1c
4 changed files with 30 additions and 9 deletions

View File

@ -5,7 +5,9 @@ import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.FloatingActionButton;
@ -36,6 +38,7 @@ public class ItemActivity extends AppCompatActivity {
private TextView readTime;
private RelativeLayout readTimeLayout;
RelativeLayout dateLayout;
private CollapsingToolbarLayout toolbarLayout;
private Toolbar toolbar;
@ -58,7 +61,7 @@ public class ItemActivity extends AppCompatActivity {
int itemId = intent.getIntExtra(ITEM_ID, 0);
String imageUrl = intent.getStringExtra(IMAGE_URL);
toolbar = findViewById(R.id.collasping_layout_toolbar);
toolbar = findViewById(R.id.collapsing_layout_toolbar);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null)
@ -76,6 +79,7 @@ public class ItemActivity extends AppCompatActivity {
author = findViewById(R.id.activity_item_author);
readTime = findViewById(R.id.activity_item_readtime);
readTimeLayout = findViewById(R.id.activity_item_readtime_layout);
dateLayout = findViewById(R.id.activity_item_date_layout);
if (imageUrl == null) {
appBarLayout.setExpanded(false);
@ -111,6 +115,7 @@ public class ItemActivity extends AppCompatActivity {
actionButton.setOnClickListener(v -> openLink());
}
@RequiresApi(api = Build.VERSION_CODES.O)
private void bindUI(ItemWithFeed itemWithFeed) {
this.itemWithFeed = itemWithFeed;
Item item = itemWithFeed.getItem();
@ -129,10 +134,13 @@ public class ItemActivity extends AppCompatActivity {
title.setText(item.getTitle());
if (itemWithFeed.getBgColor() != 0)
if (itemWithFeed.getBgColor() != 0) {
title.setTextColor(itemWithFeed.getBgColor());
else if (itemWithFeed.getColor() != 0)
Utils.setDrawableColor(dateLayout.getBackground(), itemWithFeed.getBgColor());
} else if (itemWithFeed.getColor() != 0) {
title.setTextColor(itemWithFeed.getColor());
Utils.setDrawableColor(dateLayout.getBackground(), itemWithFeed.getColor());
}
if (item.getAuthor() != null) {
author.setText(getString(R.string.by_author, item.getAuthor()));

View File

@ -6,6 +6,9 @@ import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.ColorInt;
@ -81,4 +84,8 @@ public final class Utils {
|| type.equals("image/png");
}
public static void setDrawableColor(Drawable drawable, int color) {
drawable.mutate().setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
}
}

View File

@ -11,6 +11,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.bumptech.glide.ListPreloader;
@ -27,6 +28,7 @@ import com.readrops.app.database.pojo.ItemWithFeed;
import com.readrops.app.database.entities.Item;
import com.readrops.app.utils.DateUtils;
import com.readrops.app.utils.GlideRequests;
import com.readrops.app.utils.Utils;
import java.util.Collections;
import java.util.List;
@ -106,11 +108,14 @@ public class MainItemListAdapter extends ListAdapter<ItemWithFeed, MainItemListA
viewHolder.feedIcon.setImageResource(R.drawable.ic_rss_feed);
Resources resources = viewHolder.itemView.getResources();
if (itemWithFeed.getColor() != 0)
if (itemWithFeed.getColor() != 0) {
viewHolder.feedName.setTextColor(itemWithFeed.getColor());
else
Utils.setDrawableColor(viewHolder.dateLayout.getBackground(), itemWithFeed.getColor());
} else
viewHolder.feedName.setTextColor(resources.getColor(android.R.color.tab_indicator_text));
if (itemWithFeed.getBgColor() != 0)
Utils.setDrawableColor(viewHolder.dateLayout.getBackground(), itemWithFeed.getBgColor());
int minutes = (int)Math.round(itemWithFeed.getItem().getReadTime());
if (minutes < 1)
@ -171,6 +176,7 @@ public class MainItemListAdapter extends ListAdapter<ItemWithFeed, MainItemListA
private ImageView itemImage;
private TextView itemReadTime;
private TextView itemFolderName;
private RelativeLayout dateLayout;
ItemViewHolder(@NonNull View itemView) {
super(itemView);
@ -190,6 +196,7 @@ public class MainItemListAdapter extends ListAdapter<ItemWithFeed, MainItemListA
itemImage = itemView.findViewById(R.id.item_image);
itemReadTime = itemView.findViewById(R.id.item_readtime);
itemFolderName = itemView.findViewById(R.id.item_folder_name);
dateLayout = itemView.findViewById(R.id.item_date_layout);
}
private void bind(ItemWithFeed itemWithFeed) {
@ -204,8 +211,6 @@ public class MainItemListAdapter extends ListAdapter<ItemWithFeed, MainItemListA
itemDescription.setText(item.getCleanDescription());
} else
itemDescription.setVisibility(View.GONE);
}
public ImageView getItemImage() {

View File

@ -35,7 +35,7 @@
android:background="@drawable/toolbar_scrim" />
<android.support.v7.widget.Toolbar
android:id="@+id/collasping_layout_toolbar"
android:id="@+id/collapsing_layout_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/AlertDialog.AppCompat.Light"
@ -89,7 +89,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/colorBackground"
tools:text="10 february 2019" />
tools:text="10 feb 2019" />
</RelativeLayout>
@ -116,6 +116,7 @@
android:ellipsize="end"
android:maxLines="1"
android:minLines="1"
android:textStyle="italic"
android:visibility="gone"
tools:text="By Santa Klaus"
tools:visibility="visible" />