mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Merge branch '90-clickable-links' into 'master'
Resolve "Handle Hyperlinks (Clickable Links)" Closes #90 See merge request briar/briar!1757
This commit is contained in:
@@ -3,6 +3,7 @@ package org.briarproject.briar.android.blog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.Spanned;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -170,7 +171,12 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
|
||||
// TODO make author clickable #624
|
||||
|
||||
text.setText(c.getComment());
|
||||
if (fullText) text.setTextIsSelectable(true);
|
||||
Linkify.addLinks(text, Linkify.WEB_URLS);
|
||||
text.setMovementMethod(null);
|
||||
if (fullText) {
|
||||
text.setTextIsSelectable(true);
|
||||
makeLinksClickable(text, listener::onLinkClick);
|
||||
}
|
||||
|
||||
commentContainer.addView(v);
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ import org.briarproject.briar.android.view.TextAttachmentController.AttachmentLi
|
||||
import org.briarproject.briar.android.view.TextInputView;
|
||||
import org.briarproject.briar.android.view.TextSendController;
|
||||
import org.briarproject.briar.android.view.TextSendController.SendState;
|
||||
import org.briarproject.briar.android.widget.LinkDialogFragment;
|
||||
import org.briarproject.briar.api.android.AndroidNotificationManager;
|
||||
import org.briarproject.briar.api.attachment.AttachmentHeader;
|
||||
import org.briarproject.briar.api.autodelete.event.ConversationMessagesDeletedEvent;
|
||||
@@ -476,6 +477,12 @@ public class ConversationActivity extends BriarActivity
|
||||
actionMode = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLinkClick(String url) {
|
||||
LinkDialogFragment f = LinkDialogFragment.newInstance(url);
|
||||
f.show(getSupportFragmentManager(), f.getUniqueTag());
|
||||
}
|
||||
|
||||
private void addSelectionTracker() {
|
||||
RecyclerView recyclerView = list.getRecyclerView();
|
||||
if (recyclerView.getAdapter() != adapter)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.briarproject.briar.android.conversation;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
@@ -19,6 +20,7 @@ import static android.view.View.VISIBLE;
|
||||
import static org.briarproject.bramble.util.StringUtils.trim;
|
||||
import static org.briarproject.briar.android.util.UiUtils.formatDate;
|
||||
import static org.briarproject.briar.android.util.UiUtils.formatDuration;
|
||||
import static org.briarproject.briar.android.util.UiUtils.makeLinksClickable;
|
||||
import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.NO_AUTO_DELETE_TIMER;
|
||||
|
||||
@UiThread
|
||||
@@ -58,6 +60,8 @@ abstract class ConversationItemViewHolder extends ViewHolder {
|
||||
|
||||
if (item.getText() != null) {
|
||||
text.setText(trim(item.getText()));
|
||||
Linkify.addLinks(text, Linkify.WEB_URLS);
|
||||
makeLinksClickable(text, listener::onLinkClick);
|
||||
}
|
||||
|
||||
long timestamp = item.getTime();
|
||||
|
||||
@@ -20,4 +20,6 @@ interface ConversationListener {
|
||||
|
||||
void onAutoDeleteTimerNoticeClicked();
|
||||
|
||||
void onLinkClick(String url);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.briarproject.briar.android.conversation;
|
||||
|
||||
import android.text.util.Linkify;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -13,6 +14,7 @@ import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static org.briarproject.bramble.util.StringUtils.isNullOrEmpty;
|
||||
import static org.briarproject.bramble.util.StringUtils.trim;
|
||||
import static org.briarproject.briar.android.util.UiUtils.makeLinksClickable;
|
||||
|
||||
@UiThread
|
||||
@NotNullByDefault
|
||||
@@ -40,6 +42,8 @@ class ConversationNoticeViewHolder extends ConversationItemViewHolder {
|
||||
} else {
|
||||
msgText.setVisibility(VISIBLE);
|
||||
msgText.setText(trim(text));
|
||||
Linkify.addLinks(msgText, Linkify.WEB_URLS);
|
||||
makeLinksClickable(msgText, listener::onLinkClick);
|
||||
layout.setBackgroundResource(isIncoming() ?
|
||||
R.drawable.notice_in_bottom : R.drawable.notice_out_bottom);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.briarproject.briar.android.privategroup.memberlist.GroupMemberListAct
|
||||
import org.briarproject.briar.android.privategroup.reveal.RevealContactsActivity;
|
||||
import org.briarproject.briar.android.threaded.ThreadListActivity;
|
||||
import org.briarproject.briar.android.threaded.ThreadListViewModel;
|
||||
import org.briarproject.briar.android.widget.LinkDialogFragment;
|
||||
import org.briarproject.nullsafety.MethodsNotNullByDefault;
|
||||
import org.briarproject.nullsafety.ParametersNotNullByDefault;
|
||||
|
||||
@@ -158,6 +159,12 @@ public class GroupActivity extends
|
||||
if (isDissolved != null && !isDissolved) super.onReplyClick(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLinkClick(String url){
|
||||
LinkDialogFragment f = LinkDialogFragment.newInstance(url);
|
||||
f.show(getSupportFragmentManager(), f.getUniqueTag());
|
||||
}
|
||||
|
||||
private void setGroupEnabled(boolean enabled) {
|
||||
sendController.setReady(enabled);
|
||||
list.getRecyclerView().setAlpha(enabled ? 1f : 0.5f);
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.animation.Animator;
|
||||
import android.animation.ArgbEvaluator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
@@ -20,6 +21,7 @@ import androidx.annotation.UiThread;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import static androidx.core.content.ContextCompat.getColor;
|
||||
import static org.briarproject.briar.android.util.UiUtils.makeLinksClickable;
|
||||
|
||||
@UiThread
|
||||
@NotNullByDefault
|
||||
@@ -43,6 +45,8 @@ public abstract class BaseThreadItemViewHolder<I extends ThreadItem>
|
||||
@CallSuper
|
||||
public void bind(I item, ThreadItemListener<I> listener) {
|
||||
textView.setText(StringUtils.trim(item.getText()));
|
||||
Linkify.addLinks(textView, Linkify.WEB_URLS);
|
||||
makeLinksClickable(textView, listener::onLinkClick);
|
||||
|
||||
author.setAuthor(item.getAuthor(), item.getAuthorInfo());
|
||||
author.setDate(item.getTimestamp());
|
||||
|
||||
@@ -137,6 +137,7 @@ public class ThreadItemAdapter<I extends ThreadItem>
|
||||
|
||||
public interface ThreadItemListener<I> {
|
||||
void onReplyClick(I item);
|
||||
void onLinkClick(String url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.briarproject.briar.android.view.TextSendController;
|
||||
import org.briarproject.briar.android.view.TextSendController.SendListener;
|
||||
import org.briarproject.briar.android.view.TextSendController.SendState;
|
||||
import org.briarproject.briar.android.view.UnreadMessageButton;
|
||||
import org.briarproject.briar.android.widget.LinkDialogFragment;
|
||||
import org.briarproject.briar.api.attachment.AttachmentHeader;
|
||||
import org.briarproject.nullsafety.MethodsNotNullByDefault;
|
||||
import org.briarproject.nullsafety.ParametersNotNullByDefault;
|
||||
@@ -202,6 +203,12 @@ public abstract class ThreadListActivity<I extends ThreadItem, A extends ThreadI
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLinkClick(String url) {
|
||||
LinkDialogFragment f = LinkDialogFragment.newInstance(url);
|
||||
f.show(getSupportFragmentManager(), f.getUniqueTag());
|
||||
}
|
||||
|
||||
protected void setToolbarSubTitle(SharingInfo sharingInfo) {
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
android:paddingBottom="@dimen/listitem_vertical_margin"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/text_size_small"
|
||||
android:textColorLink="@color/briar_text_link"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/authorView"
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
android:layout_marginRight="@dimen/message_bubble_padding_sides_inner"
|
||||
android:layout_marginBottom="@dimen/message_bubble_padding_bottom_inner"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textColorLink="@color/briar_text_link"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constraintBottom_toTopOf="@+id/statusLayout"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
android:layout_marginRight="@dimen/message_bubble_padding_sides_inner"
|
||||
android:layout_marginBottom="@dimen/message_bubble_padding_bottom_inner"
|
||||
android:textColor="@color/briar_text_primary_inverse"
|
||||
android:textColorLink="@color/briar_text_link_inverse"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constraintBottom_toTopOf="@+id/statusLayout"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
android:layout_marginRight="@dimen/message_bubble_margin_non_tail"
|
||||
android:background="@drawable/msg_in_top"
|
||||
android:elevation="@dimen/message_bubble_elevation"
|
||||
android:textColorLink="@color/briar_text_link"
|
||||
tools:text="Short message"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
android:background="@drawable/msg_out_top"
|
||||
android:elevation="@dimen/message_bubble_elevation"
|
||||
android:textColor="@color/briar_text_primary_inverse"
|
||||
android:textColorLink="@color/briar_text_link_inverse"
|
||||
tools:text="This is a long long long message that spans over several lines.\n\nIt ends here."
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
android:background="@drawable/msg_in_top"
|
||||
android:elevation="@dimen/message_bubble_elevation"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textColorLink="@color/briar_text_link"
|
||||
tools:text="Short message"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
@@ -114,6 +114,7 @@
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
android:textColorLink="@color/briar_text_link"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
|
||||
<!-- text colors -->
|
||||
<color name="briar_text_link">@color/briar_blue_400</color>
|
||||
<color name="briar_text_link_inverse">@android:color/white</color>
|
||||
<color name="briar_text_primary">#df000000</color>
|
||||
<color name="briar_text_primary_inverse">@android:color/white</color>
|
||||
<color name="briar_text_secondary_inverse">#b4ffffff</color>
|
||||
|
||||
Reference in New Issue
Block a user