From 790bb3c19ec9bddd7f83a0a3580db9e6cd376b95 Mon Sep 17 00:00:00 2001 From: HectorRoblesWolf <42679963+HectorRoblesWolf@users.noreply.github.com> Date: Tue, 18 Dec 2018 04:59:33 -0700 Subject: [PATCH] Issue #1981 fixed (#1998) * notification: replaced ReadMoreTextView by TextView * removed com.borjabravo:readmoretextview:2.1.0 package * Update build.gradle Re-add implementation 'com.borjabravo:readmoretextview:2.1.0' to prevent travis fail --- .../notification/NotificationRenderer.java | 39 +++---------------- app/src/main/res/layout/item_notification.xml | 5 +-- 2 files changed, 7 insertions(+), 37 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/notification/NotificationRenderer.java b/app/src/main/java/fr/free/nrw/commons/notification/NotificationRenderer.java index 87a6f0409..22bebb37a 100644 --- a/app/src/main/java/fr/free/nrw/commons/notification/NotificationRenderer.java +++ b/app/src/main/java/fr/free/nrw/commons/notification/NotificationRenderer.java @@ -1,19 +1,12 @@ package fr.free.nrw.commons.notification; -import android.graphics.Color; -import android.preference.PreferenceManager; import android.text.Html; -import android.text.SpannableString; -import android.text.Spanned; -import android.text.TextPaint; -import android.text.style.ClickableSpan; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; -import com.borjabravo.readmoretextview.ReadMoreTextView; import com.pedrogomez.renderers.Renderer; import butterknife.BindView; @@ -25,7 +18,7 @@ import fr.free.nrw.commons.R; */ public class NotificationRenderer extends Renderer { - @BindView(R.id.title) ReadMoreTextView title; + @BindView(R.id.title) TextView title; @BindView(R.id.time) TextView time; @BindView(R.id.icon) ImageView icon; private NotificationClicked listener; @@ -65,32 +58,12 @@ public class NotificationRenderer extends Renderer { private void setTitle(String notificationText) { notificationText = notificationText.trim().replaceAll("(^\\s*)|(\\s*$)", ""); notificationText = Html.fromHtml(notificationText).toString(); + if(notificationText.length()>280){ + notificationText = notificationText.substring(0,279); + notificationText = notificationText.concat("..."); + } notificationText = notificationText.concat(" "); - - SpannableString ss = new SpannableString(notificationText); - ClickableSpan clickableSpan = new ClickableSpan() { - @Override - public void onClick(View view) { - listener.notificationClicked(getContent()); - } - - @Override - public void updateDrawState(TextPaint ds) { - super.updateDrawState(ds); - ds.setUnderlineText(false); - - if(PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("theme", false)) { - ds.setColor(Color.WHITE); - } - else { - ds.setColor(Color.BLACK); - } - } - }; - - // Attach a ClickableSpan to the range (start:0, end:notificationText.length()) of the String - ss.setSpan(clickableSpan, 0, notificationText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - title.setText(ss, TextView.BufferType.SPANNABLE); + title.setText(notificationText); } public interface NotificationClicked{ diff --git a/app/src/main/res/layout/item_notification.xml b/app/src/main/res/layout/item_notification.xml index ec777ba52..aa67e13d2 100644 --- a/app/src/main/res/layout/item_notification.xml +++ b/app/src/main/res/layout/item_notification.xml @@ -33,7 +33,7 @@ tools:text="@string/placeholder_place_distance" /> -