mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
* 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
This commit is contained in:
parent
2d6160c843
commit
790bb3c19e
2 changed files with 7 additions and 37 deletions
|
|
@ -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<Notification> {
|
||||
@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<Notification> {
|
|||
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{
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
tools:text="@string/placeholder_place_distance"
|
||||
/>
|
||||
|
||||
<com.borjabravo.readmoretextview.ReadMoreTextView
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -45,10 +45,7 @@
|
|||
android:layout_toRightOf="@id/icon"
|
||||
android:layout_toStartOf="@id/time"
|
||||
android:ellipsize="end"
|
||||
app:trimMode="trimModeLength"
|
||||
app:trimLength="60"
|
||||
android:layout_alignParentTop="true"
|
||||
app:colorClickableText="#969494"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
|
||||
tools:text="@string/placeholder_place_name"
|
||||
android:padding="12dp"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue