Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE REQUEST] - Accept all file types #123

Open
1bacon opened this issue Feb 1, 2025 · 2 comments
Open

[FEATURE REQUEST] - Accept all file types #123

1bacon opened this issue Feb 1, 2025 · 2 comments
Labels
Feature request New feature proposal

Comments

@1bacon
Copy link

1bacon commented Feb 1, 2025

Is your feature request related to a problem? Please describe.
Currently only specific file types are allowed to be encrypted. This is determined by their file name extension. I don't see any reason for that. File types should be determined by their contents, instead of their names. Even if they are unsupported they should still be encryptable. Support for audio only files (mp3, aac. etc.) for example is trivial via the video viewer.

Describe the solution you'd like
All files should be encryptable.
Files with unknown extensions should trigger a prompt on how to open them (Image, Video, Text, etc.)
All other files should also have the opportunity to be opened in the other modes.

Additional context
Every other filesystem/application does it that way, you can rename an image to image.pdf and still open it with an image viewer.

@1bacon 1bacon added the Feature request New feature proposal label Feb 1, 2025
@hej2010
Copy link
Member

hej2010 commented Feb 1, 2025

The app imports by mime type, not by extension:

String[] mimeTypes = new String[]{"image/*", "video/*"};

I guess I can add a way to import other file types as well, but then it would not only be a gallery app.

@1bacon
Copy link
Author

1bacon commented Feb 26, 2025

Ah, that makes more sense, I was going off of this file:

public enum FileType {
DIRECTORY(0, null, null, 1),
IMAGE_V1(1, ".jpg", Encryption.PREFIX_IMAGE_FILE, 1),
IMAGE_V2(1, ".jpg", Encryption.SUFFIX_IMAGE_FILE, 2),
GIF_V1(2, ".gif", Encryption.PREFIX_GIF_FILE, 1),
GIF_V2(2, ".gif", Encryption.SUFFIX_GIF_FILE, 2),
VIDEO_V1(3, ".mp4", Encryption.PREFIX_VIDEO_FILE, 1),
VIDEO_V2(3, ".mp4", Encryption.SUFFIX_VIDEO_FILE, 2),
TEXT_V1(4, ".txt", Encryption.PREFIX_TEXT_FILE, 1),
TEXT_V2(4, ".txt", Encryption.SUFFIX_TEXT_FILE, 2);
public static final int TYPE_DIRECTORY = 0;
public static final int TYPE_IMAGE = 1;
public static final int TYPE_GIF = 2;
public static final int TYPE_VIDEO = 3;
public static final int TYPE_TEXT = 4;
public final String extension, suffixPrefix;
public final int type, version;
FileType(int type, String extension, String suffixPrefix, int version) {
this.type = type;
this.extension = extension;
this.suffixPrefix = suffixPrefix;
this.version = version;
}
public static FileType fromFilename(@NonNull String name) {
if (name.startsWith(Encryption.PREFIX_IMAGE_FILE)) {
return IMAGE_V1;
} else if (name.endsWith(Encryption.SUFFIX_IMAGE_FILE)) {
return IMAGE_V2;
} else if (name.startsWith(Encryption.PREFIX_GIF_FILE)) {
return GIF_V1;
} else if (name.endsWith(Encryption.SUFFIX_GIF_FILE)) {
return GIF_V2;
} else if (name.startsWith(Encryption.PREFIX_VIDEO_FILE)) {
return VIDEO_V1;
} else if (name.endsWith(Encryption.SUFFIX_VIDEO_FILE)) {
return VIDEO_V2;
} else if (name.startsWith(Encryption.PREFIX_TEXT_FILE)) {
return TEXT_V1;
} else if (name.endsWith(Encryption.SUFFIX_TEXT_FILE)) {
return TEXT_V2;
} else {
return DIRECTORY;
}
}


Seems like text support is already implemented? But importing is still limited to "image/*", "video/*" mime-types.

public static String getSuffixFromMime(@Nullable String mimeType) {
if (mimeType == null) {
return Encryption.SUFFIX_IMAGE_FILE;
} else if (mimeType.equals("image/gif")) {
return Encryption.SUFFIX_GIF_FILE;
} else if (mimeType.startsWith("image/")) {
return Encryption.SUFFIX_IMAGE_FILE;
} else if (mimeType.startsWith("text/")) {
return Encryption.SUFFIX_TEXT_FILE;
} else {
return Encryption.SUFFIX_VIDEO_FILE;
}
}

A more separate approach where, everything can be imported and encrypted, and certain files can then be opened/viewed in the vault, would make more sense to me. (I'm also just a user and haven't looked at the code much)
But if the scope is just a gallery, then that's certainly understandable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request New feature proposal
Projects
None yet
Development

No branches or pull requests

2 participants