From f50cfcb39849c72461f5847d5f4acabf31479d1a Mon Sep 17 00:00:00 2001 From: Floens Date: Mon, 20 Oct 2014 23:09:25 +0200 Subject: [PATCH] Add archived icon --- .../java/org/floens/chan/core/model/Post.java | 1 + .../chan/core/net/ChanReaderRequest.java | 3 +++ .../java/org/floens/chan/ui/view/PostView.java | 17 ++++++++++++----- .../java/org/floens/chan/utils/IconCache.java | 17 +++++++++++------ .../main/res/drawable-mdpi/archived_icon.png | Bin 0 -> 554 bytes 5 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 Clover/app/src/main/res/drawable-mdpi/archived_icon.png diff --git a/Clover/app/src/main/java/org/floens/chan/core/model/Post.java b/Clover/app/src/main/java/org/floens/chan/core/model/Post.java index 16dac0c4..75c5599f 100644 --- a/Clover/app/src/main/java/org/floens/chan/core/model/Post.java +++ b/Clover/app/src/main/java/org/floens/chan/core/model/Post.java @@ -69,6 +69,7 @@ public class Post { public String imageUrl; public boolean sticky = false; public boolean closed = false; + public boolean archived = false; public String tripcode = ""; public String id = ""; public String capcode = ""; diff --git a/Clover/app/src/main/java/org/floens/chan/core/net/ChanReaderRequest.java b/Clover/app/src/main/java/org/floens/chan/core/net/ChanReaderRequest.java index c2ee1607..3b0d8c90 100644 --- a/Clover/app/src/main/java/org/floens/chan/core/net/ChanReaderRequest.java +++ b/Clover/app/src/main/java/org/floens/chan/core/net/ChanReaderRequest.java @@ -331,6 +331,9 @@ public class ChanReaderRequest extends JsonReaderRequest> { case "closed": post.closed = reader.nextInt() == 1; break; + case "archived": + post.archived = reader.nextInt() == 1; + break; case "trip": post.tripcode = reader.nextString(); break; diff --git a/Clover/app/src/main/java/org/floens/chan/ui/view/PostView.java b/Clover/app/src/main/java/org/floens/chan/ui/view/PostView.java index fa834288..5473f4c7 100644 --- a/Clover/app/src/main/java/org/floens/chan/ui/view/PostView.java +++ b/Clover/app/src/main/java/org/floens/chan/ui/view/PostView.java @@ -78,6 +78,7 @@ public class PostView extends LinearLayout implements View.OnClickListener { private ImageView stickyView; private ImageView closedView; private ImageView deletedView; + private ImageView archivedView; private NetworkImageView countryView; private ImageView optionsView; private View lastSeen; @@ -215,14 +216,16 @@ public class PostView extends LinearLayout implements View.OnClickListener { boolean showCountryFlag = isList() && !TextUtils.isEmpty(post.country) && !TextUtils.isEmpty(post.countryUrl); boolean showStickyIcon = isList() && post.sticky; - boolean showClosedIcon = isList() && post.closed; boolean showDeletedIcon = isList() && post.deleted; + boolean showArchivedIcon = isList() && post.archived; + boolean showClosedIcon = isList() && post.closed && !showArchivedIcon; - iconsView.setVisibility((showCountryFlag || showStickyIcon || showClosedIcon || showDeletedIcon) ? View.VISIBLE : View.GONE); + iconsView.setVisibility((showCountryFlag || showStickyIcon || showClosedIcon || showDeletedIcon || showArchivedIcon) ? View.VISIBLE : View.GONE); stickyView.setVisibility(showStickyIcon ? View.VISIBLE : View.GONE); closedView.setVisibility(showClosedIcon ? View.VISIBLE : View.GONE); deletedView.setVisibility(showDeletedIcon ? View.VISIBLE : View.GONE); + archivedView.setVisibility(showArchivedIcon ? View.VISIBLE : View.GONE); if (showCountryFlag) { countryView.setVisibility(View.VISIBLE); countryView.setImageUrl(post.countryUrl, ChanApplication.getVolleyImageLoader()); @@ -352,17 +355,21 @@ public class PostView extends LinearLayout implements View.OnClickListener { iconsView.setPadding(postPadding, iconPadding, postPadding, 0); stickyView = new ImageView(context); - stickyView.setImageBitmap(IconCache.stickyIcon); + stickyView.setImageDrawable(IconCache.stickyIcon); iconsView.addView(stickyView, new LinearLayout.LayoutParams(iconWidth, iconHeight)); closedView = new ImageView(context); - closedView.setImageBitmap(IconCache.closedIcon); + closedView.setImageDrawable(IconCache.closedIcon); iconsView.addView(closedView, new LinearLayout.LayoutParams(iconWidth, iconHeight)); deletedView = new ImageView(context); - deletedView.setImageBitmap(IconCache.trashIcon); + deletedView.setImageDrawable(IconCache.trashIcon); iconsView.addView(deletedView, new LinearLayout.LayoutParams(iconWidth, iconHeight)); + archivedView = new ImageView(context); + archivedView.setImageDrawable(IconCache.archivedIcon); + iconsView.addView(archivedView, new LinearLayout.LayoutParams(iconWidth, iconHeight)); + countryView = new NetworkImageView(context); countryView.setScaleType(ImageView.ScaleType.FIT_CENTER); iconsView.addView(countryView, new LinearLayout.LayoutParams(iconWidth, iconHeight)); diff --git a/Clover/app/src/main/java/org/floens/chan/utils/IconCache.java b/Clover/app/src/main/java/org/floens/chan/utils/IconCache.java index 57189ec0..1bebb0d3 100644 --- a/Clover/app/src/main/java/org/floens/chan/utils/IconCache.java +++ b/Clover/app/src/main/java/org/floens/chan/utils/IconCache.java @@ -18,19 +18,24 @@ package org.floens.chan.utils; import android.content.Context; +import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; import org.floens.chan.R; public class IconCache { - public static Bitmap stickyIcon; - public static Bitmap closedIcon; - public static Bitmap trashIcon; + public static BitmapDrawable stickyIcon; + public static BitmapDrawable closedIcon; + public static BitmapDrawable trashIcon; + public static BitmapDrawable archivedIcon; public static void createIcons(final Context context) { - stickyIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.sticky_icon); - closedIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.closed_icon); - trashIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.trash_icon); + Resources res = context.getResources(); + stickyIcon = new BitmapDrawable(res, BitmapFactory.decodeResource(res, R.drawable.sticky_icon)); + closedIcon = new BitmapDrawable(res, BitmapFactory.decodeResource(res, R.drawable.closed_icon)); + trashIcon = new BitmapDrawable(res, BitmapFactory.decodeResource(res, R.drawable.trash_icon)); + archivedIcon = new BitmapDrawable(res, BitmapFactory.decodeResource(res, R.drawable.archived_icon)); } } diff --git a/Clover/app/src/main/res/drawable-mdpi/archived_icon.png b/Clover/app/src/main/res/drawable-mdpi/archived_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..94a38e2bc5ddea9a96853e7e377e9f14b2be4780 GIT binary patch literal 554 zcmV+_0@eMAP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02p*dSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E;Eegmrwuz0h>ugK~z{r?bl690znuDaKB4LfmqoKE)`{m z&K;s#5gj^9v9{{E_IB(W6cMJT7Y~)Vx zXiY073Sr+_ap7!NoXu!*`&>Y9M|9df3!>t%Wyo51xZtP$G|@ zvSM7oK=Z{9Fu7F$8c%GVflDib6e_{6mWP3rQ?M^3K%4+{n9xM?!}nF<1)y7E=8%t} zPf3F_kOfIAz}R{bMp>Ve)C`Clz-l=;+Gvz0dkvfTVmdE-HM#EDJ?NYObm+J}X^@ta zKpPPqMnv2IwDB}=!_8>Py@wA#$Fj_pom-1mLHqzNEeAtt7VPo~^sef9@~ literal 0 HcmV?d00001