Handle clicks on non-linkified task list text

pull/757/head
Alex Baker 6 years ago
parent 108de56ba9
commit 2d4c0a62e8

@ -26,12 +26,17 @@ public class Linkify {
}
public void linkify(TextView textView) {
linkify(textView, () -> {});
linkify(textView, () -> {}, () -> {});
}
public void linkify(TextView textView, Runnable onEdit) {
public void linkify(TextView textView, Runnable onClick, Runnable onLongClick) {
BetterLinkMovementMethod.linkify(android.text.util.Linkify.ALL, textView)
.setOnLinkClickListener((tv, url) -> handleLink(url, onEdit));
.setOnLinkClickListener((tv, url) -> handleLink(url, onClick))
.setOnLinkLongClickListener(
(tv, url) -> {
onLongClick.run();
return true;
});
}
private boolean handleLink(String url, Runnable onEdit) {

@ -212,8 +212,12 @@ class ViewHolder extends RecyclerView.ViewHolder {
description.setVisibility(task.hasNotes() ? View.VISIBLE : View.GONE);
}
if (preferences.getBoolean(R.string.p_linkify_task_list, false)) {
linkify.linkify(nameView, this::onRowBodyClick);
linkify.linkify(description, this::onRowBodyClick);
linkify.linkify(nameView, this::onRowBodyClick, this::onRowBodyLongClick);
linkify.linkify(description, this::onRowBodyClick, this::onRowBodyLongClick);
nameView.setOnClickListener(view -> onRowBodyClick());
nameView.setOnLongClickListener(view -> onRowBodyLongClick());
description.setOnClickListener(view -> onRowBodyClick());
description.setOnLongClickListener(view -> onRowBodyLongClick());
}
}
@ -274,7 +278,8 @@ class ViewHolder extends RecyclerView.ViewHolder {
String tags = task.getTagsString();
List<String> tagUuids = tags != null ? newArrayList(tags.split(",")) : Lists.newArrayList();
List<Chip> chips = chipProvider.getChips(task.getCaldav(), task.getGoogleTaskList(), tagUuids);
List<Chip> chips =
chipProvider.getChips(task.getCaldav(), task.getGoogleTaskList(), tagUuids);
if (chips.isEmpty()) {
chipGroup.setVisibility(View.GONE);
} else {

Loading…
Cancel
Save