mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-07 03:05:18 +08:00
Changed: Move UrlUtils to TermuxUrlUtils
This commit is contained in:
@@ -2,13 +2,11 @@ package com.termux.app.terminal;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.ActivityNotFoundException;
|
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
import android.content.ClipboardManager;
|
import android.content.ClipboardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
@@ -22,7 +20,6 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import com.termux.R;
|
import com.termux.R;
|
||||||
import com.termux.app.TermuxActivity;
|
import com.termux.app.TermuxActivity;
|
||||||
import com.termux.shared.data.UrlUtils;
|
|
||||||
import com.termux.shared.file.FileUtils;
|
import com.termux.shared.file.FileUtils;
|
||||||
import com.termux.shared.interact.MessageDialogUtils;
|
import com.termux.shared.interact.MessageDialogUtils;
|
||||||
import com.termux.shared.interact.ShareUtils;
|
import com.termux.shared.interact.ShareUtils;
|
||||||
@@ -40,10 +37,10 @@ import com.termux.shared.data.DataUtils;
|
|||||||
import com.termux.shared.logger.Logger;
|
import com.termux.shared.logger.Logger;
|
||||||
import com.termux.shared.markdown.MarkdownUtils;
|
import com.termux.shared.markdown.MarkdownUtils;
|
||||||
import com.termux.shared.termux.TermuxUtils;
|
import com.termux.shared.termux.TermuxUtils;
|
||||||
|
import com.termux.shared.termux.data.TermuxUrlUtils;
|
||||||
import com.termux.shared.view.KeyboardUtils;
|
import com.termux.shared.view.KeyboardUtils;
|
||||||
import com.termux.shared.view.ViewUtils;
|
import com.termux.shared.view.ViewUtils;
|
||||||
import com.termux.terminal.KeyHandler;
|
import com.termux.terminal.KeyHandler;
|
||||||
import com.termux.terminal.TerminalBuffer;
|
|
||||||
import com.termux.terminal.TerminalEmulator;
|
import com.termux.terminal.TerminalEmulator;
|
||||||
import com.termux.terminal.TerminalSession;
|
import com.termux.terminal.TerminalSession;
|
||||||
|
|
||||||
@@ -179,7 +176,7 @@ public class TermuxTerminalViewClient extends TermuxTerminalViewClientBase {
|
|||||||
if (mActivity.getProperties().shouldOpenTerminalTranscriptURLOnClick()) {
|
if (mActivity.getProperties().shouldOpenTerminalTranscriptURLOnClick()) {
|
||||||
int[] columnAndRow = mActivity.getTerminalView().getColumnAndRow(e, true);
|
int[] columnAndRow = mActivity.getTerminalView().getColumnAndRow(e, true);
|
||||||
String wordAtTap = term.getScreen().getWordAtLocation(columnAndRow[0], columnAndRow[1]);
|
String wordAtTap = term.getScreen().getWordAtLocation(columnAndRow[0], columnAndRow[1]);
|
||||||
LinkedHashSet<CharSequence> urlSet = UrlUtils.extractUrls(wordAtTap);
|
LinkedHashSet<CharSequence> urlSet = TermuxUrlUtils.extractUrls(wordAtTap);
|
||||||
|
|
||||||
if (!urlSet.isEmpty()) {
|
if (!urlSet.isEmpty()) {
|
||||||
String url = (String) urlSet.iterator().next();
|
String url = (String) urlSet.iterator().next();
|
||||||
@@ -665,7 +662,7 @@ public class TermuxTerminalViewClient extends TermuxTerminalViewClientBase {
|
|||||||
|
|
||||||
String text = ShellUtils.getTerminalSessionTranscriptText(session, true, true);
|
String text = ShellUtils.getTerminalSessionTranscriptText(session, true, true);
|
||||||
|
|
||||||
LinkedHashSet<CharSequence> urlSet = UrlUtils.extractUrls(text);
|
LinkedHashSet<CharSequence> urlSet = TermuxUrlUtils.extractUrls(text);
|
||||||
if (urlSet.isEmpty()) {
|
if (urlSet.isEmpty()) {
|
||||||
new AlertDialog.Builder(mActivity).setMessage(R.string.title_select_url_none_found).show();
|
new AlertDialog.Builder(mActivity).setMessage(R.string.title_select_url_none_found).show();
|
||||||
return;
|
return;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package com.termux.app;
|
package com.termux.app;
|
||||||
|
|
||||||
import com.termux.shared.data.UrlUtils;
|
import com.termux.shared.termux.data.TermuxUrlUtils;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -13,7 +13,7 @@ public class TermuxActivityTest {
|
|||||||
private void assertUrlsAre(String text, String... urls) {
|
private void assertUrlsAre(String text, String... urls) {
|
||||||
LinkedHashSet<String> expected = new LinkedHashSet<>();
|
LinkedHashSet<String> expected = new LinkedHashSet<>();
|
||||||
Collections.addAll(expected, urls);
|
Collections.addAll(expected, urls);
|
||||||
Assert.assertEquals(expected, UrlUtils.extractUrls(text));
|
Assert.assertEquals(expected, TermuxUrlUtils.extractUrls(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
package com.termux.shared.data;
|
package com.termux.shared.termux.data;
|
||||||
|
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class UrlUtils {
|
public class TermuxUrlUtils {
|
||||||
|
|
||||||
public static Pattern URL_MATCH_REGEX;
|
public static Pattern URL_MATCH_REGEX;
|
||||||
|
|
Reference in New Issue
Block a user