mirror of https://github.com/readrops/Readrops.git
Add icons with favicon dominant color for drawer feeds items
This commit is contained in:
parent
0734eaa5da
commit
1ba3f4f745
|
@ -1,6 +1,14 @@
|
|||
package com.readrops.app.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
import android.graphics.drawable.shapes.OvalShape;
|
||||
import android.graphics.drawable.shapes.Shape;
|
||||
import android.support.annotation.ColorInt;
|
||||
|
||||
import com.mikepenz.materialdrawer.Drawer;
|
||||
import com.mikepenz.materialdrawer.model.DividerDrawerItem;
|
||||
|
@ -16,6 +24,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.readrops.app.utils.Utils.drawableWithColor;
|
||||
|
||||
public class DrawerManager {
|
||||
|
||||
public static final int ARTICLES_ITEM_ID = 1;
|
||||
|
@ -43,8 +53,11 @@ public class DrawerManager {
|
|||
List<IDrawerItem> secondaryDrawerItems = new ArrayList<>();
|
||||
|
||||
for (Feed feed : folderListMap.get(folder)) {
|
||||
int color = feed.getTextColor();
|
||||
|
||||
SecondaryDrawerItem secondaryDrawerItem = new SecondaryDrawerItem()
|
||||
.withName(feed.getName())
|
||||
.withIcon(color != 0 ? drawableWithColor(color) : drawableWithColor(context.getResources().getColor(R.color.colorPrimary)))
|
||||
.withIdentifier(feed.getId());
|
||||
|
||||
secondaryDrawerItems.add(secondaryDrawerItem);
|
||||
|
@ -56,8 +69,11 @@ public class DrawerManager {
|
|||
}
|
||||
} else { // no folder case, items to add after the folders
|
||||
for (Feed feed : folderListMap.get(folder)) {
|
||||
int color = feed.getTextColor();
|
||||
|
||||
SecondaryDrawerItem primaryDrawerItem = new SecondaryDrawerItem()
|
||||
.withName(feed.getName())
|
||||
.withIcon(color != 0 ? drawableWithColor(color) : drawableWithColor(context.getResources().getColor(R.color.colorPrimary)))
|
||||
.withIdentifier(feed.getId());
|
||||
|
||||
feedsWithoutFolder.add(primaryDrawerItem);
|
||||
|
|
|
@ -9,6 +9,8 @@ import android.graphics.Color;
|
|||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
import android.graphics.drawable.shapes.OvalShape;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.support.annotation.ColorInt;
|
||||
|
@ -88,4 +90,14 @@ public final class Utils {
|
|||
drawable.mutate().setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
|
||||
}
|
||||
|
||||
public static Drawable drawableWithColor(@ColorInt int color) {
|
||||
ShapeDrawable drawable = new ShapeDrawable(new OvalShape());
|
||||
drawable.setIntrinsicWidth(50);
|
||||
drawable.setIntrinsicHeight(50);
|
||||
|
||||
drawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
|
||||
|
||||
return drawable;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue