Skip to content

Commit 790bb3c

Browse files
HectorRoblesWolfneslihanturan
authored andcommitted
* 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
1 parent 2d6160c commit 790bb3c

File tree

2 files changed

+7
-37
lines changed

2 files changed

+7
-37
lines changed

app/src/main/java/fr/free/nrw/commons/notification/NotificationRenderer.java

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
package fr.free.nrw.commons.notification;
22

3-
import android.graphics.Color;
4-
import android.preference.PreferenceManager;
53
import android.text.Html;
6-
import android.text.SpannableString;
7-
import android.text.Spanned;
8-
import android.text.TextPaint;
9-
import android.text.style.ClickableSpan;
104
import android.view.LayoutInflater;
115
import android.view.View;
126
import android.view.ViewGroup;
137
import android.widget.ImageView;
148
import android.widget.TextView;
159

16-
import com.borjabravo.readmoretextview.ReadMoreTextView;
1710
import com.pedrogomez.renderers.Renderer;
1811

1912
import butterknife.BindView;
@@ -25,7 +18,7 @@
2518
*/
2619

2720
public class NotificationRenderer extends Renderer<Notification> {
28-
@BindView(R.id.title) ReadMoreTextView title;
21+
@BindView(R.id.title) TextView title;
2922
@BindView(R.id.time) TextView time;
3023
@BindView(R.id.icon) ImageView icon;
3124
private NotificationClicked listener;
@@ -65,32 +58,12 @@ public void render() {
6558
private void setTitle(String notificationText) {
6659
notificationText = notificationText.trim().replaceAll("(^\\s*)|(\\s*$)", "");
6760
notificationText = Html.fromHtml(notificationText).toString();
61+
if(notificationText.length()>280){
62+
notificationText = notificationText.substring(0,279);
63+
notificationText = notificationText.concat("...");
64+
}
6865
notificationText = notificationText.concat(" ");
69-
70-
SpannableString ss = new SpannableString(notificationText);
71-
ClickableSpan clickableSpan = new ClickableSpan() {
72-
@Override
73-
public void onClick(View view) {
74-
listener.notificationClicked(getContent());
75-
}
76-
77-
@Override
78-
public void updateDrawState(TextPaint ds) {
79-
super.updateDrawState(ds);
80-
ds.setUnderlineText(false);
81-
82-
if(PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("theme", false)) {
83-
ds.setColor(Color.WHITE);
84-
}
85-
else {
86-
ds.setColor(Color.BLACK);
87-
}
88-
}
89-
};
90-
91-
// Attach a ClickableSpan to the range (start:0, end:notificationText.length()) of the String
92-
ss.setSpan(clickableSpan, 0, notificationText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
93-
title.setText(ss, TextView.BufferType.SPANNABLE);
66+
title.setText(notificationText);
9467
}
9568

9669
public interface NotificationClicked{

app/src/main/res/layout/item_notification.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
tools:text="@string/placeholder_place_distance"
3434
/>
3535

36-
<com.borjabravo.readmoretextview.ReadMoreTextView
36+
<TextView
3737
android:id="@+id/title"
3838
android:layout_width="match_parent"
3939
android:layout_height="wrap_content"
@@ -45,10 +45,7 @@
4545
android:layout_toRightOf="@id/icon"
4646
android:layout_toStartOf="@id/time"
4747
android:ellipsize="end"
48-
app:trimMode="trimModeLength"
49-
app:trimLength="60"
5048
android:layout_alignParentTop="true"
51-
app:colorClickableText="#969494"
5249
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
5350
tools:text="@string/placeholder_place_name"
5451
android:padding="12dp"

0 commit comments

Comments
 (0)