simplemagic icon indicating copy to clipboard operation
simplemagic copied to clipboard

Questions about compatibility with Android

Open AndroidDeveloperLB opened this issue 6 years ago • 3 comments

From my understanding by reading the description, this library can be used to guess the type of a file based on its content, similar to the "file" command on linux.

  1. Am I correct?
  2. Could this also work on Android? If so, from which version?
  3. Is it possible to use it via Gradle? If so, what is the dependency I need to add? Is there a way to get updated about the version ? Maybe here?
  4. How much space does it add to the app's size?
  5. Where can I see all of the supported mime-types that it can return? Does it have support for those that are supported by Android (here) ?

AndroidDeveloperLB avatar Jul 11 '19 17:07 AndroidDeveloperLB

OK was curious and tried it myself.

gradle:

implementation 'com.j256.simplemagic:simplemagic:1.16'

Code:

        AsyncTask.execute {
            val util = ContentInfoUtil()
            val input = URL("https://img.freepik.com/free-vector/abstract-dynamic-pattern-wallpaper-vector_53876-59131.jpg?size=338&ext=jpg").openStream()
            val info = util.findMatch(input)
            Log.d("AppLog", "info:$info")
        }

And the result:

info:jpeg, type JPEG, mime 'image/jpeg', msg 'JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16'

So to answer the questions:

  1. Seems so.
  2. Working even on Android Q beta 5. Tested also on emulator with Android API 16 (4.1).
  3. Yes. But not sure about updates. Just need to check from time to time on the website, I guess.
  4. Seems not to add much. The app became 2,522KB in side, and was 2,347KB . Rising in just ~200KB, and might be smaller when used with R8 minimizer. I wonder how much it reads from the InputStream and if it can be checked somehow, and how efficient it is. Probably very efficient and barely reads data.
  5. This I don't know yet.

Attached here the tiny sample project.

My Application.zip

Good job on this library!

AndroidDeveloperLB avatar Jul 12 '19 13:07 AndroidDeveloperLB

Thanks @AndroidDeveloperLB . I need to add Gradle support to all of my libraries. Sigh. So much to do.

j256 avatar Jul 12 '19 18:07 j256

@j256 Can you please confirm and/or answer what I wrote ?

Is there a list somewhere of all the file-types that you support? Does it at least include those that Android support (probably so) ?

AndroidDeveloperLB avatar Jul 13 '19 08:07 AndroidDeveloperLB