HBiSoft / PickiT

An Android library that returns real paths from Uri's

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

An isUnknownProvider function could be util

selankon opened this issue · comments

Is your feature request related to a problem? Please describe.

You can use wasLocalFileSelected to check if is a local file before trying to get it locally, for example, to notice the user the file is going to be downloaded before access it.

Unfortunately, you have to use getPath before know if is an unknown provider, causing, if I understood it well, the tmp copy download into project directory, without a way to check this before

Describe the solution you'd like

A function such as isUnknownProvider could be useful to use it before getPath and download the temporary file.

The problem is isUnknownProvider can't be called before checking the Uri. isUnknownProvider does not necessarily mean that it is a file from an unknown provider, but also when a file path can't be retrieved. So, we first have to check if the file path can be "retrieved" before we can know if it's from an "unkown" provider.

What you can do is to call wasLocalFileSelected(Uri uri) to check if a local file was selected.
By calling the above you can at least find out if the file was selected from local storage.

What I don't want is to start a download when I execute getPath(), what as I understand, occurs if isUnknownProvider is true.

And also, can I ask, if, for example, a file is present on the google drive folder but is already downloaded, wasLocalFileSelected will return true?

Thanks in advance

My apologies for the delay.

With the new release (2.0.2), you are able to check if the Uri is from an unknown provider by using pickiT.isUnknownProvider(uri, Build.VERSION.SDK_INT);.

If you want to find out if the file needs to be downloaded first, you can do the following:

if (pickiT.isUnknownProvider(uri, Build.VERSION.SDK_INT) || pickiT.isDriveFile(uri)){
    // File first needs to be downloaded
}else {
    // Path is available, no need to download the file
}

Thanks for your answer and your implementation.

So, to know if file need to be download I could use, for example:

if (!pickiT.isUnknownProvider(uri, Build.VERSION.SDK_INT) || pickiT.wasLocalFileSelected(uri))

The question here is if the method wasLocalFileSelected is deprecated.

The question here is if the method wasLocalFileSelected is deprecated

I wanted to change wasLocalFileSelected to isDriveFile, but I forgot. So yes it can still be used.


if (pickiT.isUnknownProvider(uri, Build.VERSION.SDK_INT) || !pickiT.wasLocalFileSelected(uri)){
    // File needs to be downloaded 
} else {
   // No need to download file
}

You can use the above to check if the file needs to be downloaded first.

That's nice thanks!

Hi,

I got this error:

error: cannot find symbol
      if(pickiT.isUnknownProvider(uri, Build.VERSION.SDK_INT) || !pickiT.wasLocalFileSelected(uri)) {
               ^
  symbol:   method isUnknownProvider(Uri,int)
  location: variable pickiT of type PickiT

I'm not pretty sure if I'm updating the package properly. I update version number on my build.gradle file and then just compile again...

I can't locate the function isUnknownProvider on last commit on master neither, I guess is not merged properly?

Hi, any updates?

pickiT.isUnknownProvider doesn't seem to exist on master: https://github.com/HBiSoft/PickiT/blob/master/pickit/src/main/java/com/hbisoft/pickit/PickiT.java