diff --git a/README.md b/README.md index 520a496de..92a1629ca 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,14 @@ Support PayPal Liberapay Or buy the [Cloud Plugin](https://play.google.com/store/apps/details?id=com.filemanager.amazecloud) supports Google Driveā„¢, Dropbox, OneDrive and Box accounts. +Try our app - [Amaze File Utilities](https://play.google.com/store/apps/details?id=com.amaze.fileutilities) +1. List videos / images / music documents in your device in a interactive UI where you're able to group / sort and quickly jump to any headers. +2. Open videos / images / music / documents (pdf / docx / epub) with inbuilt player. +3. Share / delete / cast on your tv +4. Analyse internal storage for junk files, duplicate files, large videos / old downloads / screenshots or recordings. +5. Analyse and group images between memes, low light / blurry / selfies / group pics. +7. Transfer files directly between two mobile devices on same wifi network using high speed peer to peer network +8. Gesture support in image / video player, play in background, picture in picture mode, download subtitles within the player. Warning --- diff --git a/app/src/main/java/com/amaze/filemanager/filesystem/HybridFile.java b/app/src/main/java/com/amaze/filemanager/filesystem/HybridFile.java index 547318aa8..c0c30aa54 100644 --- a/app/src/main/java/com/amaze/filemanager/filesystem/HybridFile.java +++ b/app/src/main/java/com/amaze/filemanager/filesystem/HybridFile.java @@ -1457,13 +1457,19 @@ public class HybridFile { AtomicReference md5 = new AtomicReference<>(activity.getString(R.string.calculating)); AtomicReference sha256 = new AtomicReference<>(activity.getString(R.string.calculating)); + AtomicReference pathToDisplay = new AtomicReference<>(); + pathToDisplay.set(path); + if (isSftp() || isSmb()) { + LOG.debug("convert authorised path to simple path for display"); + pathToDisplay.set(parseAndFormatUriForDisplay(path)); + } AtomicReference dialogContent = new AtomicReference<>( String.format( activity.getResources().getString(R.string.open_file_confirmation), getName(activity), - path, + pathToDisplay.get(), Formatter.formatShortFileSize(activity, length(activity)), md5.get(), sha256.get())); @@ -1479,7 +1485,7 @@ public class HybridFile { String.format( activity.getResources().getString(R.string.open_file_confirmation), getName(activity), - path, + pathToDisplay.get(), Formatter.formatShortFileSize(activity, length(activity)), md5.get(), sha256.get())); @@ -1494,7 +1500,7 @@ public class HybridFile { String.format( activity.getResources().getString(R.string.open_file_confirmation), getName(activity), - path, + pathToDisplay.get(), Formatter.formatShortFileSize(activity, length(activity)), md5.get(), sha256.get())); diff --git a/app/src/main/java/com/amaze/filemanager/filesystem/ssh/SshClientUtils.java b/app/src/main/java/com/amaze/filemanager/filesystem/ssh/SshClientUtils.java index 06e056fd0..0f5e8d491 100644 --- a/app/src/main/java/com/amaze/filemanager/filesystem/ssh/SshClientUtils.java +++ b/app/src/main/java/com/amaze/filemanager/filesystem/ssh/SshClientUtils.java @@ -28,6 +28,7 @@ import java.io.File; import java.io.IOException; import java.security.GeneralSecurityException; import java.security.KeyPair; +import java.util.ArrayList; import java.util.List; import org.slf4j.Logger; @@ -246,6 +247,33 @@ public abstract class SshClientUtils { return hostPath.indexOf('/') == -1 ? "/" : hostPath.substring(hostPath.indexOf('/')); } + /** + * Converts plain path smb://127.0.0.1/test.pdf to authorized path + * smb://test:123@127.0.0.1/test.pdf from server list + * + * @param path + * @return + */ + public static String formatPlainServerPathToAuthorised(ArrayList servers, String path) { + synchronized (servers) { + for (String[] serverEntry : servers) { + Uri inputUri = Uri.parse(path); + Uri serverUri = Uri.parse(serverEntry[1]); + if (serverUri.getAuthority().contains(inputUri.getAuthority())) { + String output = + inputUri + .buildUpon() + .encodedAuthority(serverUri.getEncodedAuthority()) + .build() + .toString(); + LOG.info("build authorised path {} from plain path {}", output, path); + return output; + } + } + return path; + } + } + /** * Disconnects the given {@link SSHClient} but wrap all exceptions beneath, so callers are free * from the hassles of handling thrown exceptions. diff --git a/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivity.java b/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivity.java index deaaac010..d796e1001 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivity.java +++ b/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivity.java @@ -98,6 +98,7 @@ import com.amaze.filemanager.filesystem.MakeFileOperation; import com.amaze.filemanager.filesystem.PasteHelper; import com.amaze.filemanager.filesystem.RootHelper; import com.amaze.filemanager.filesystem.files.FileUtils; +import com.amaze.filemanager.filesystem.ssh.SshClientUtils; import com.amaze.filemanager.filesystem.ssh.SshConnectionPool; import com.amaze.filemanager.ui.ExtensionsKt; import com.amaze.filemanager.ui.activities.superclasses.PermissionsActivity; @@ -470,6 +471,14 @@ public class MainActivity extends PermissionsActivity if (!isCloudRefresh) { goToMain(null); } + if (file.isSmb() || file.isSftp()) { + String authorisedPath = + SshClientUtils.formatPlainServerPathToAuthorised(dataUtils.getServers(), path); + file.setPath(authorisedPath); + LOG.info( + "Opening smb file from deeplink, modify plain path to authorised path {}", + authorisedPath); + } file.openFile(this, true); } } else if (!isCloudRefresh) { @@ -584,7 +593,7 @@ public class MainActivity extends PermissionsActivity */ path = Utils.sanitizeInput(uri.getQueryParameter("path")); } else { - Log.w(getClass().getSimpleName(), getString(R.string.error_cannot_find_way_open)); + LOG.warn(getString(R.string.error_cannot_find_way_open)); } } else if (actionIntent.equals(Intent.ACTION_SEND)) { diff --git a/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java b/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java index 517aca48e..c7a260048 100644 --- a/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java +++ b/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java @@ -25,6 +25,9 @@ import java.util.Collections; import java.util.LinkedList; import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.amaze.filemanager.adapters.data.LayoutElementParcelable; import com.amaze.filemanager.application.AppConfig; import com.amaze.filemanager.fileoperations.filesystem.OpenMode; @@ -40,7 +43,6 @@ import com.googlecode.concurrenttrees.radixinverted.ConcurrentInvertedRadixTree; import com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree; import android.text.TextUtils; -import android.util.Log; import android.view.MenuItem; import androidx.annotation.Nullable; @@ -50,7 +52,7 @@ import androidx.annotation.Nullable; // Central data being used across activity,fragments and classes public class DataUtils { - private static final String TAG = DataUtils.class.getSimpleName(); + private static final Logger LOG = LoggerFactory.getLogger(DataUtils.class); private ConcurrentRadixTree hiddenfiles = new ConcurrentRadixTree<>(new DefaultCharArrayNodeFactory()); @@ -352,7 +354,7 @@ public class DataUtils { try { return getHiddenFiles().getValueForExactKey(path) != null; } catch (IllegalStateException e) { - Log.w(TAG, e); + LOG.warn("failed to get hidden file", e); return false; } } @@ -411,7 +413,7 @@ public class DataUtils { tree.put(path, item.getItemId()); return true; } catch (IllegalStateException e) { - Log.w(TAG, e); + LOG.warn("failed to put drawer path", e); return false; } }