Added: Add UriScheme and move UriUtils to com.termux.shared.net package

This commit is contained in:
agnostic-apollo
2021-10-26 00:46:54 +05:00
parent 37b9bcf5af
commit 549a772d45
5 changed files with 54 additions and 25 deletions

View File

@@ -2,7 +2,6 @@ package com.termux.app;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
@@ -16,8 +15,9 @@ import android.webkit.MimeTypeMap;
import com.termux.app.utils.PluginUtils;
import com.termux.shared.data.IntentUtils;
import com.termux.shared.data.UriUtils;
import com.termux.shared.net.UriUtils;
import com.termux.shared.logger.Logger;
import com.termux.shared.models.net.UriScheme;
import com.termux.shared.termux.TermuxConstants;
import java.io.File;
@@ -55,7 +55,7 @@ public class TermuxOpenReceiver extends BroadcastReceiver {
}
String scheme = data.getScheme();
if (scheme != null && !ContentResolver.SCHEME_FILE.equals(scheme)) {
if (scheme != null && !UriScheme.SCHEME_FILE.equals(scheme)) {
Intent urlIntent = new Intent(intentAction, data);
if (intentAction.equals(Intent.ACTION_SEND)) {
urlIntent.putExtra(Intent.EXTRA_TEXT, data.toString());

View File

@@ -26,7 +26,7 @@ import com.termux.app.settings.properties.TermuxAppSharedProperties;
import com.termux.app.terminal.TermuxTerminalSessionClient;
import com.termux.app.utils.PluginUtils;
import com.termux.shared.data.IntentUtils;
import com.termux.shared.data.UriUtils;
import com.termux.shared.net.UriUtils;
import com.termux.shared.models.errors.Errno;
import com.termux.shared.shell.ShellUtils;
import com.termux.shared.termux.shell.TermuxShellEnvironmentClient;

View File

@@ -1,7 +1,6 @@
package com.termux.filepicker;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
@@ -13,8 +12,9 @@ import androidx.annotation.NonNull;
import com.termux.R;
import com.termux.shared.data.DataUtils;
import com.termux.shared.data.IntentUtils;
import com.termux.shared.data.UriUtils;
import com.termux.shared.net.UriUtils;
import com.termux.shared.interact.MessageDialogUtils;
import com.termux.shared.models.net.UriScheme;
import com.termux.shared.termux.interact.TextInputDialogUtils;
import com.termux.shared.termux.TermuxConstants;
import com.termux.shared.termux.TermuxConstants.TERMUX_APP.TERMUX_SERVICE;
@@ -93,9 +93,9 @@ public class TermuxFileReceiverActivity extends Activity {
return;
}
if (ContentResolver.SCHEME_CONTENT.equals(scheme)) {
if (UriScheme.SCHEME_CONTENT.equals(scheme)) {
handleContentUri(dataUri, sharedTitle);
} else if (ContentResolver.SCHEME_FILE.equals(scheme)) {
} else if (UriScheme.SCHEME_FILE.equals(scheme)) {
Logger.logVerbose(LOG_TAG, "uri: \"" + dataUri + "\", path: \"" + dataUri.getPath() + "\", fragment: \"" + dataUri.getFragment() + "\"");
// Get full path including fragment (anything after last "#")