From 6fc46302e759a84a058ae0c2c9511e91d0ccdfc3 Mon Sep 17 00:00:00 2001 From: stom79 Date: Sat, 28 Oct 2017 19:22:02 +0200 Subject: [PATCH] Material design for pinned icon --- .../mastodon/drawers/StatusListAdapter.java | 33 ++++++++----------- .../main/res/drawable-anydpi/ic_pin_drop.xml | 9 +++++ .../res/drawable-anydpi/ic_pin_drop_p.xml | 9 +++++ app/src/main/res/layout/drawer_status.xml | 2 +- 4 files changed, 33 insertions(+), 20 deletions(-) create mode 100644 app/src/main/res/drawable-anydpi/ic_pin_drop.xml create mode 100644 app/src/main/res/drawable-anydpi/ic_pin_drop_p.xml diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java index 022ab2f47..d145bdf96 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java @@ -415,7 +415,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct changeDrawableColor(context, R.drawable.ic_mail_outline,R.color.dark_icon); changeDrawableColor(context, R.drawable.ic_repeat,R.color.dark_icon); changeDrawableColor(context, R.drawable.ic_star_border,R.color.dark_icon); - changeDrawableColor(context, R.drawable.ic_action_pin_dark, R.color.dark_icon); + changeDrawableColor(context, R.drawable.ic_pin_drop, R.color.dark_icon); changeDrawableColor(context, R.drawable.ic_photo,R.color.dark_text); changeDrawableColor(context, R.drawable.ic_remove_red_eye,R.color.dark_text); changeDrawableColor(context, R.drawable.ic_translate,R.color.dark_text); @@ -428,7 +428,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct changeDrawableColor(context, R.drawable.ic_mail_outline,R.color.black); changeDrawableColor(context, R.drawable.ic_repeat,R.color.black); changeDrawableColor(context, R.drawable.ic_star_border,R.color.black); - changeDrawableColor(context, R.drawable.ic_action_pin_dark, R.color.black); + changeDrawableColor(context, R.drawable.ic_pin_drop, R.color.black); changeDrawableColor(context, R.drawable.ic_photo,R.color.white); changeDrawableColor(context, R.drawable.ic_remove_red_eye,R.color.white); changeDrawableColor(context, R.drawable.ic_translate,R.color.white); @@ -683,7 +683,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct break; } - Drawable imgFav, imgReblog, imgPinned, imgReply; + Drawable imgFav, imgReblog, imgReply; if( status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited())) { changeDrawableColor(context, R.drawable.ic_star,R.color.marked_icon); imgFav = ContextCompat.getDrawable(context, R.drawable.ic_star); @@ -706,16 +706,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct imgReblog = ContextCompat.getDrawable(context, R.drawable.ic_repeat); } - if( status.isPinned()|| (status.getReblog() != null && status.getReblog().isPinned())) { - changeDrawableColor(context, R.drawable.ic_action_pin_yellow,R.color.marked_icon); - imgPinned = ContextCompat.getDrawable(context, R.drawable.ic_action_pin_yellow); - }else { - if( theme == THEME_DARK) - changeDrawableColor(context, R.drawable.ic_action_pin_dark,R.color.dark_icon); - else - changeDrawableColor(context, R.drawable.ic_action_pin_dark,R.color.black); - imgPinned = ContextCompat.getDrawable(context, R.drawable.ic_action_pin_dark); - } + if( theme == THEME_DARK) changeDrawableColor(context, R.drawable.ic_reply,R.color.dark_icon); else @@ -725,12 +716,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct imgFav.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (20 * iconSizePercent/100 * scale + 0.5f)); imgReblog.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (20 * iconSizePercent/100 * scale + 0.5f)); - imgPinned.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (20 * iconSizePercent/100 * scale + 0.5f)); imgReply.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (20 * iconSizePercent/100 * scale + 0.5f)); holder.status_favorite_count.setCompoundDrawables(imgFav, null, null, null); holder.status_reblog_count.setCompoundDrawables(imgReblog, null, null, null); - holder.status_pin.setImageDrawable(imgPinned); holder.status_reply.setCompoundDrawables(imgReply, null, null, null); if( theme == Helper.THEME_LIGHT) { @@ -743,10 +732,16 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct // Pinning toots is only available on Mastodon 1._6_.0 instances. if (isOwner && Helper.canPin && (status.getVisibility().equals("public") || status.getVisibility().equals("unlisted")) && status.getReblog() == null) { Drawable imgPin; - if( status.isPinned()) - imgPin = ContextCompat.getDrawable(context, R.drawable.ic_action_pin_yellow); - else - imgPin = ContextCompat.getDrawable(context, R.drawable.ic_action_pin_dark); + if( status.isPinned()|| (status.getReblog() != null && status.getReblog().isPinned())) { + changeDrawableColor(context, R.drawable.ic_pin_drop_p,R.color.marked_icon); + imgPin = ContextCompat.getDrawable(context, R.drawable.ic_pin_drop_p); + }else { + if( theme == THEME_DARK) + changeDrawableColor(context, R.drawable.ic_pin_drop,R.color.dark_icon); + else + changeDrawableColor(context, R.drawable.ic_pin_drop,R.color.black); + imgPin = ContextCompat.getDrawable(context, R.drawable.ic_pin_drop); + } imgPin.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (20 * iconSizePercent/100 * scale + 0.5f)); holder.status_pin.setImageDrawable(imgPin); diff --git a/app/src/main/res/drawable-anydpi/ic_pin_drop.xml b/app/src/main/res/drawable-anydpi/ic_pin_drop.xml new file mode 100644 index 000000000..49a331741 --- /dev/null +++ b/app/src/main/res/drawable-anydpi/ic_pin_drop.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable-anydpi/ic_pin_drop_p.xml b/app/src/main/res/drawable-anydpi/ic_pin_drop_p.xml new file mode 100644 index 000000000..49a331741 --- /dev/null +++ b/app/src/main/res/drawable-anydpi/ic_pin_drop_p.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/drawer_status.xml b/app/src/main/res/layout/drawer_status.xml index dcce161c1..a1acc7047 100644 --- a/app/src/main/res/layout/drawer_status.xml +++ b/app/src/main/res/layout/drawer_status.xml @@ -403,7 +403,7 @@ android:layout_gravity="center_vertical" android:layout_width="20dp" android:layout_height="20dp" - android:src="@drawable/ic_action_pin_dark"/> + android:src="@drawable/ic_pin_drop"/>