aashishksahu / SafeSpace

A safe place for your valuable information
GNU General Public License v3.0
144 stars 9 forks source link

Files are not properly ordering by numerical order #26

Closed ondemind closed 4 months ago

ondemind commented 6 months ago

Hey, firstly, I would like to thank you for bringing to us a very easy option to storing and encrypting our most valuable files in your application. However, I noticed that since your application is very new (which is understandable, and I hope this application gets more popular), there is a little issue.

When I have a folder with a sequence of numbers in a PNG format file, let's say, something like this:

1.png 2.png 3.png

It would be obvious that in this case, the applications need to order files like that, however, in my case, it does not happen, instead I get something like this:

3.png 1.png 2.png

I know that this is not something of a big deal when dealing with little numbers, but what happens when we are dealing with most files? I think that this is an issue related to the way that the application sort by the files, so maybe there's something that it's failing in this case or there's a lacking feature? Also tried seeing these files in a normal gallery app, and it does order the files properly without any issues.

I tried sorting the files by alphabetical order to see if it does do something, but nothing. So my possible solution will be one or two:

  1. Adding a separate option to sort the files by a numerical order
  2. Adding the function to order too numbers in case it finds in the option to sort by name of the application.

I would like to support this project by adding a code that solves this issue, however, I'm not very familiar with android developing since it is not my strong point.

I know that I wrote a very large walltext, but it is because I have a mania to get as detailed as possible. Well, that's all, and feel free to ask me if you would like to know more information about my issue. Thanks and have a great day!

atomuspilius commented 6 months ago

836061497>85351227 but when sorted by name, 85 million comes after 836 million

aashishksahu commented 6 months ago

@atomuspilius Thank you very much for using my app! The ordering definitely seems broken. I'll surely look into it :)

aashishksahu commented 6 months ago

Hi @ondemind @atomuspilius I tried replicating your issue with the png files, but it is correctly ordering it. Please take a look at the following screen recording. Screen_recording_20240115_155654.webm

Please share your region and language from settings, it could be a language and region specific ordering.

aashishksahu commented 5 months ago

So I did some digging but didn't reach a reliable solution. There are ways to sort with natural order but it comes with certain pitfalls, for example, if the numbers are small natural sorting works as intended, but if one of the files has a really long number in the name such as 16 times 9.jpg, then the app crashes. I tried to fix this by using BigInteger, but then sorting doesn't work and gives some random sort that makes no sense. As of now I don't have a reliable solution (maybe I'll have to write my own algorithm). Will come back to this once I find something.

aashishksahu commented 4 months ago

Released v1.4.4 that fixes this issue.