|  |  | @ -8,17 +8,24 @@ import android.graphics.drawable.ColorDrawable; | 
			
		
	
		
		
			
				
					
					|  |  |  | import android.os.Build; |  |  |  | import android.os.Build; | 
			
		
	
		
		
			
				
					
					|  |  |  | import android.os.Bundle; |  |  |  | import android.os.Bundle; | 
			
		
	
		
		
			
				
					
					|  |  |  | import android.support.annotation.NonNull; |  |  |  | import android.support.annotation.NonNull; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import android.text.SpannableString; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import android.text.method.LinkMovementMethod; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import android.text.style.URLSpan; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import android.text.util.Linkify; | 
			
		
	
		
		
			
				
					
					|  |  |  | import android.view.MenuItem; |  |  |  | import android.view.MenuItem; | 
			
		
	
		
		
			
				
					
					|  |  |  | import android.view.View; |  |  |  | import android.view.View; | 
			
		
	
		
		
			
				
					
					|  |  |  | import android.view.ViewGroup; |  |  |  | import android.view.ViewGroup; | 
			
		
	
		
		
			
				
					
					|  |  |  | import android.widget.TextView; |  |  |  | import android.widget.TextView; | 
			
		
	
		
		
			
				
					
					|  |  |  | import android.widget.Toast; |  |  |  | import android.widget.Toast; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.annimon.stream.Stream; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity; |  |  |  | import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.thoughtcrime.securesms.R; |  |  |  | import org.thoughtcrime.securesms.R; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.thoughtcrime.securesms.color.MaterialColor; |  |  |  | import org.thoughtcrime.securesms.color.MaterialColor; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.thoughtcrime.securesms.components.ConversationItemFooter; |  |  |  | import org.thoughtcrime.securesms.components.ConversationItemFooter; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.thoughtcrime.securesms.database.Address; |  |  |  | import org.thoughtcrime.securesms.database.Address; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import org.thoughtcrime.securesms.linkpreview.LinkPreviewUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.thoughtcrime.securesms.recipients.Recipient; |  |  |  | import org.thoughtcrime.securesms.recipients.Recipient; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.thoughtcrime.securesms.recipients.RecipientModifiedListener; |  |  |  | import org.thoughtcrime.securesms.recipients.RecipientModifiedListener; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.thoughtcrime.securesms.util.DynamicLanguage; |  |  |  | import org.thoughtcrime.securesms.util.DynamicLanguage; | 
			
		
	
	
		
		
			
				
					|  |  | @ -142,8 +149,21 @@ public class LongMessageActivity extends PassphraseRequiredActionBarActivity imp | 
			
		
	
		
		
			
				
					
					|  |  |  |       ConversationItemFooter footer = bubble.findViewById(R.id.longmessage_footer); |  |  |  |       ConversationItemFooter footer = bubble.findViewById(R.id.longmessage_footer); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |       bubble.setVisibility(View.VISIBLE); |  |  |  |       bubble.setVisibility(View.VISIBLE); | 
			
		
	
		
		
			
				
					
					|  |  |  |       text.setText(message.get().getFullBody()); |  |  |  |       text.setText(linkifyMessageBody(new SpannableString(message.get().getFullBody()))); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       text.setMovementMethod(LinkMovementMethod.getInstance()); | 
			
		
	
		
		
			
				
					
					|  |  |  |       footer.setMessageRecord(message.get().getMessageRecord(), dynamicLanguage.getCurrentLocale()); |  |  |  |       footer.setMessageRecord(message.get().getMessageRecord(), dynamicLanguage.getCurrentLocale()); | 
			
		
	
		
		
			
				
					
					|  |  |  |     }); |  |  |  |     }); | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   private SpannableString linkifyMessageBody(SpannableString messageBody) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     int     linkPattern = Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES | Linkify.PHONE_NUMBERS; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     boolean hasLinks    = Linkify.addLinks(messageBody, linkPattern); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     if (hasLinks) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       Stream.of(messageBody.getSpans(0, messageBody.length(), URLSpan.class)) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             .filterNot(url -> LinkPreviewUtil.isLegalUrl(url.getURL())) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             .forEach(messageBody::removeSpan); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     return messageBody; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |