- Fixes an issue with clickable elements in toots
- Conversation opening no longer limited to clicks on toot content (whole element)
This commit is contained in:
parent
014d8e6cef
commit
8a1be63a4e
|
@ -24,8 +24,6 @@ import java.security.KeyStoreException;
|
|||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.UnrecoverableKeyException;
|
||||
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
|
||||
import static fr.gouv.etalab.mastodon.helper.Helper.USER_AGENT;
|
||||
|
||||
/**
|
||||
|
@ -75,4 +73,4 @@ public class OauthClient {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -24,7 +24,10 @@ import android.os.AsyncTask;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableString;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -110,6 +113,7 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
|
|||
if (convertView == null) {
|
||||
convertView = layoutInflater.inflate(R.layout.drawer_notification, parent, false);
|
||||
holder = new ViewHolder();
|
||||
holder.card_status_container = (CardView) convertView.findViewById(R.id.card_status_container);
|
||||
holder.notification_status_container = (LinearLayout) convertView.findViewById(R.id.notification_status_container);
|
||||
holder.status_document_container = (LinearLayout) convertView.findViewById(R.id.status_document_container);
|
||||
holder.notification_status_content = (TextView) convertView.findViewById(R.id.notification_status_content);
|
||||
|
@ -196,8 +200,11 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
|
|||
holder.notification_account_displayname.setCompoundDrawables( null, null, null, null);
|
||||
}
|
||||
|
||||
holder.notification_status_content = Helper.clickableElements(context, holder.notification_status_content,status.getContent(),
|
||||
SpannableString spannableString = Helper.clickableElements(context, status.getContent(),
|
||||
status.getReblog() != null?status.getReblog().getMentions():status.getMentions());
|
||||
holder.notification_status_content.setText(spannableString, TextView.BufferType.SPANNABLE);
|
||||
holder.notification_status_content.setMovementMethod(null);
|
||||
holder.notification_status_content.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
holder.status_favorite_count.setText(String.valueOf(status.getFavourites_count()));
|
||||
holder.status_reblog_count.setText(String.valueOf(status.getReblogs_count()));
|
||||
holder.status_date.setText(Helper.dateDiff(context, status.getCreated_at()));
|
||||
|
@ -205,6 +212,16 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
|
|||
//Adds attachment -> disabled, to enable them uncomment the line below
|
||||
//loadAttachments(status, holder);
|
||||
holder.notification_status_container.setVisibility(View.VISIBLE);
|
||||
holder.card_status_container.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(context, ShowConversationActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putString("statusId", status.getId());
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
holder.notification_status_content.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -466,6 +483,7 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
|
|||
|
||||
|
||||
private class ViewHolder {
|
||||
CardView card_status_container;
|
||||
TextView notification_status_content;
|
||||
TextView notification_type;
|
||||
TextView notification_account_username;
|
||||
|
|
|
@ -27,7 +27,10 @@ import android.os.AsyncTask;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableString;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -94,7 +97,6 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
private StatusListAdapter statusListAdapter;
|
||||
private final int REBLOG = 1;
|
||||
private final int FAVOURITE = 2;
|
||||
private ViewHolder holder;
|
||||
private RetrieveFeedsAsyncTask.Type type;
|
||||
private String targetedId;
|
||||
|
||||
|
@ -145,9 +147,11 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
||||
|
||||
final Status status = statuses.get(position);
|
||||
final ViewHolder holder;
|
||||
if (convertView == null) {
|
||||
convertView = layoutInflater.inflate(R.layout.drawer_status, parent, false);
|
||||
holder = new ViewHolder();
|
||||
holder.card_status_container = (CardView) convertView.findViewById(R.id.card_status_container);
|
||||
holder.status_document_container = (LinearLayout) convertView.findViewById(R.id.status_document_container);
|
||||
holder.status_content = (TextView) convertView.findViewById(R.id.status_content);
|
||||
holder.status_content_translated = (TextView) convertView.findViewById(R.id.status_content_translated);
|
||||
|
@ -309,6 +313,16 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
holder.card_status_container.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(context, ShowConversationActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putString("statusId", status.getId());
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
}else {
|
||||
if( theme == Helper.THEME_LIGHT){
|
||||
if( position == ShowConversationActivity.position){
|
||||
|
@ -363,14 +377,19 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
holder.status_content = Helper.clickableElements(context, holder.status_content,content,
|
||||
SpannableString spannableString = Helper.clickableElements(context,content,
|
||||
status.getReblog() != null?status.getReblog().getMentions():status.getMentions());
|
||||
holder.status_content.setText(spannableString, TextView.BufferType.SPANNABLE);
|
||||
|
||||
if( status.getContent_translated() != null && status.getContent_translated().length() > 0){
|
||||
holder.status_content_translated = Helper.clickableElements(context, holder.status_content_translated,status.getContent_translated(),
|
||||
SpannableString spannableStringTrans = Helper.clickableElements(context, status.getContent_translated(),
|
||||
status.getReblog() != null?status.getReblog().getMentions():status.getMentions());
|
||||
holder.status_content_translated.setText(spannableStringTrans, TextView.BufferType.SPANNABLE);
|
||||
holder.status_content_translated.setMovementMethod(null);
|
||||
holder.status_content_translated.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
holder.status_content.setMovementMethod(null);
|
||||
holder.status_content.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
holder.status_favorite_count.setText(String.valueOf(status.getFavourites_count()));
|
||||
holder.status_reblog_count.setText(String.valueOf(status.getReblogs_count()));
|
||||
holder.status_toot_date.setText(Helper.dateDiff(context, status.getCreated_at()));
|
||||
|
@ -395,7 +414,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
} else {
|
||||
//If medias are loaded without any conditions or if device is on wifi
|
||||
if (!status.isSensitive() && (behaviorWithAttachments == Helper.ATTACHMENT_ALWAYS || (behaviorWithAttachments == Helper.ATTACHMENT_WIFI && isOnWifi))) {
|
||||
loadAttachments(status);
|
||||
loadAttachments(status, holder);
|
||||
holder.status_show_more.setVisibility(View.GONE);
|
||||
status.setAttachmentShown(true);
|
||||
} else {
|
||||
|
@ -406,7 +425,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
holder.status_show_more.setVisibility(View.VISIBLE);
|
||||
holder.status_document_container.setVisibility(View.GONE);
|
||||
} else {
|
||||
loadAttachments(status);
|
||||
loadAttachments(status, holder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -417,7 +436,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
} else {
|
||||
//If medias are loaded without any conditions or if device is on wifi
|
||||
if (!status.getReblog().isSensitive() && (behaviorWithAttachments == Helper.ATTACHMENT_ALWAYS || (behaviorWithAttachments == Helper.ATTACHMENT_WIFI && isOnWifi))) {
|
||||
loadAttachments(status.getReblog());
|
||||
loadAttachments(status.getReblog(), holder);
|
||||
holder.status_show_more.setVisibility(View.GONE);
|
||||
status.getReblog().setAttachmentShown(true);
|
||||
} else {
|
||||
|
@ -428,7 +447,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
holder.status_show_more.setVisibility(View.VISIBLE);
|
||||
holder.status_document_container.setVisibility(View.GONE);
|
||||
} else {
|
||||
loadAttachments(status.getReblog());
|
||||
loadAttachments(status.getReblog(), holder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -468,7 +487,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
holder.status_show_more.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
loadAttachments(status);
|
||||
loadAttachments(status, holder);
|
||||
holder.status_show_more.setVisibility(View.GONE);
|
||||
status.setAttachmentShown(true);
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
|
@ -580,7 +599,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
|
||||
|
||||
|
||||
private void loadAttachments(final Status status){
|
||||
private void loadAttachments(final Status status, ViewHolder holder){
|
||||
List<Attachment> attachments = status.getMedia_attachments();
|
||||
if( attachments != null && attachments.size() > 0){
|
||||
int i = 0;
|
||||
|
@ -746,7 +765,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
LinearLayout status_spoiler_container;
|
||||
TextView status_spoiler;
|
||||
Button status_spoiler_button;
|
||||
|
||||
CardView card_status_container;
|
||||
TextView status_content;
|
||||
TextView status_content_translated;
|
||||
LinearLayout status_content_translated_container;
|
||||
|
|
|
@ -1008,12 +1008,11 @@ public class Helper {
|
|||
* Click on account => ShowAccountActivity
|
||||
* Click on tag => HashTagActivity
|
||||
* @param context Context
|
||||
* @param statusTV Textview
|
||||
* @param fullContent String, should be the st
|
||||
* @param mentions List<Mention>
|
||||
* @return TextView
|
||||
*/
|
||||
public static TextView clickableElements(final Context context, TextView statusTV, String fullContent, List<Mention> mentions) {
|
||||
public static SpannableString clickableElements(final Context context, String fullContent, List<Mention> mentions) {
|
||||
|
||||
SpannableString spannableString;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
|
@ -1098,13 +1097,15 @@ public class Helper {
|
|||
}
|
||||
}, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
return spannableString;
|
||||
/*
|
||||
statusTV.setText(spannableString, TextView.BufferType.SPANNABLE);
|
||||
statusTV.setMovementMethod(null);
|
||||
statusTV.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
statusTV.setMovementMethod(ArrowKeyMovementMethod.getInstance());
|
||||
statusTV.setFocusable(true);
|
||||
statusTV.setFocusableInTouchMode(true);
|
||||
return statusTV;
|
||||
return statusTV;*/
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -173,7 +173,13 @@ public class HomeTimelineSyncJob extends Job implements OnRetrieveHomeTimelineSe
|
|||
DisplayImageOptions options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
|
||||
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
||||
final String finalMessage = message;
|
||||
final String finalTitle = getContext().getResources().getString(R.string.notif_pouet, status.getAccount().getUsername());
|
||||
String title;
|
||||
if( status.getAccount().getDisplay_name() != null && status.getAccount().getDisplay_name().length() > 0 )
|
||||
title = getContext().getResources().getString(R.string.notif_pouet, Helper.shortnameToUnicode(status.getAccount().getDisplay_name(), true));
|
||||
else
|
||||
title = getContext().getResources().getString(R.string.notif_pouet, status.getAccount().getUsername());
|
||||
final String finalTitle = title;
|
||||
|
||||
imageLoaderNoty.loadImage(notificationUrl, options, new SimpleImageLoadingListener(){
|
||||
@Override
|
||||
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||
|
|
|
@ -164,7 +164,10 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications
|
|||
newMentions++;
|
||||
if( notificationUrl == null){
|
||||
notificationUrl = notification.getAccount().getAvatar();
|
||||
title = String.format("@%s %s", notification.getAccount().getUsername(),getContext().getString(R.string.notif_mention));
|
||||
if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0 )
|
||||
title = String.format("@%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),getContext().getString(R.string.notif_mention));
|
||||
else
|
||||
title = String.format("@%s %s", notification.getAccount().getUsername(),getContext().getString(R.string.notif_mention));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -173,7 +176,11 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications
|
|||
newShare++;
|
||||
if( notificationUrl == null){
|
||||
notificationUrl = notification.getAccount().getAvatar();
|
||||
title = String.format("@%s %s", notification.getAccount().getUsername(),getContext().getString(R.string.notif_reblog));
|
||||
if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0 )
|
||||
title = String.format("@%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),getContext().getString(R.string.notif_reblog));
|
||||
else
|
||||
title = String.format("@%s %s", notification.getAccount().getUsername(),getContext().getString(R.string.notif_reblog));
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -182,7 +189,10 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications
|
|||
newAdds++;
|
||||
if( notificationUrl == null){
|
||||
notificationUrl = notification.getAccount().getAvatar();
|
||||
title = String.format("@%s %s", notification.getAccount().getUsername(),getContext().getString(R.string.notif_favourite));
|
||||
if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0 )
|
||||
title = String.format("@%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),getContext().getString(R.string.notif_favourite));
|
||||
else
|
||||
title = String.format("@%s %s", notification.getAccount().getUsername(),getContext().getString(R.string.notif_favourite));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -191,7 +201,10 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications
|
|||
newFollows++;
|
||||
if( notificationUrl == null){
|
||||
notificationUrl = notification.getAccount().getAvatar();
|
||||
title = String.format("@%s %s", notification.getAccount().getUsername(),getContext().getString(R.string.notif_follow));
|
||||
if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0 )
|
||||
title = String.format("@%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),getContext().getString(R.string.notif_follow));
|
||||
else
|
||||
title = String.format("@%s %s", notification.getAccount().getUsername(),getContext().getString(R.string.notif_follow));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
xmlns:card_view="http://schemas.android.com/tools"
|
||||
android:layout_marginTop="10dp"
|
||||
style="?attr/cardStyle"
|
||||
android:id="@+id/card_status_container"
|
||||
card_view:cardPreventCornerOverlap="true"
|
||||
app:cardUseCompatPadding="true">
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/card_status_container"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:card_view="http://schemas.android.com/tools"
|
||||
style="?attr/cardStyle"
|
||||
|
|
Loading…
Reference in New Issue