nativescript-community / ui-document-picker

A NativeScript plugin that allows you to select files from the device.
https://nativescript-community.github.io/ui-document-picker/
Apache License 2.0
10 stars 8 forks source link

Including ui-document-picker breaks navigation #20

Closed BikeBr0 closed 2 years ago

BikeBr0 commented 2 years ago

I'm experiencing some strange app behavior simply by adding this library to my project. When it is added, and running on Android (I have not tested iOS) navigation from ComponentA to ComponentB does not work. At least the UI does not update even though log statements from ComponentB do execute.

The simplest way to reproduce this problem is to create a new project using NativeScript 8.1.5, select Angular and the Tabs project:

ns create test-app Angular Tabs

Then build and run the project on a connected Android device:

ns build android ns run android

Tapping on an "Item" will correctly navigate to the item detail screen:

Now add this plugin via the command:

ns plugin add @nativescript-community/ui-document-picker

Building the project at this point will result in a minSdkVersion error, so you will need to bump the minSdkVersion to 19 in app.gradle. At this point the build will succeed. However, when you run the app on your device, tapping the "Item" does not cause the item detail screen to load, even though the plugin is not actually used at runtime. Tab navigation continues to work however.

Any suggestions?

farfromrefug commented 2 years ago

@BikeBr0 ok so i ran some test. The issue lies actually within N not being compatible with latest androidx fragment lib. You can get the same issue without this plugin just by upgrading @nativescript/android to to the latest alpha (clean everything!). nativescript 8.2.0 should fix that though (there is a test version i think , but i am not 100% sure as i use a fork). I am sorry but there is nothing i can do.

BikeBr0 commented 2 years ago

Thanks for getting back to me @farfromrefug. I suspect this plugin did/does work for a lot of developers though. I have @nativescript/android version 8.1.1 in package.json. Can I downgrade that to a previously known working version or will that break the project? I ask because my actual project works just fine and only has issues with this plugin. For example:

"@nativescript-community/ble": "^3.0.29",
"@nativescript-community/insomnia": "^2.0.2",
"@nativescript-community/ui-material-bottomnavigationbar": "^6.2.3",
"@nativescript-community/ui-material-button": "^6.2.3",
"@nativescript-community/ui-material-textfield": "^6.2.3",
"@nativescript-community/ui-pulltorefresh": "^2.5.0",

Do not cause problems.

Cheers,

farfromrefug commented 2 years ago

i think rhe issue is that because of this plugin newer native deps were required which N does not support yet. did you try N 8.2.0 alpha?

BikeBr0 commented 2 years ago

I'm not sure how to do that @farfromrefug. Running:

npm i nativescript@next

gives me:

"nativescript": "^8.1.5-next-02-15-2022-1847360438",

And I still have the problem.

https://www.npmjs.com/package/nativescript/v/8.2.0-alpha.0 does not exist (but I see previous Alphas are available this way). How do I access the 8.2.0 Alpha release?

farfromrefug commented 2 years ago

@BikeBr0 i am talking about @nativescript/core. please try 8.2.0-alpha.7

BikeBr0 commented 2 years ago

Okay, back to nativescript 8.1.5 and bumping @nativescript/core to "~8.2.0-alpha.7" I get the following error when trying to build:

ERROR in ./node_modules/@nativescript-community/ui-document-picker/index.android.js 2:0-56
Module not found: Error: Can't resolve '@nativescript-community/perms' in 'C:\Users\...\test-app\node_modules\@nativescript-community\ui-document-picker'
farfromrefug commented 2 years ago

@BikeBr0 sorry you found a bug :s just fixed it in 1.1.11

BikeBr0 commented 2 years ago

@farfromrefug That works! I'm running @nativescript/core 8.1.1 and @nativescript-community/ui-document-picker 1.1.11 and the App builds and runs with minSdkVersion 17. However, I am experiencing 2 problems that might mean I need to update to the Alpha release:

  1. openFilePicker does not seem to restrict files to the array of file extensions I specify (i.e. it shows all file types)
  2. File.fromPath fails to open using the path returned (e.g.: content://com.android.providers.downloads.documents/document/msf%3A123). Do I need to manipulate the path?
farfromrefug commented 2 years ago

@BikeBr0 good. for the first one how did you pass the filter? on android it must be mimetypes. for the second sadly N does not support android 12 storage scope yet :s

BikeBr0 commented 2 years ago

1) Yes, I passed in the "extensions" property but I used file extensions. In my case:

openFilePicker({
        extensions: ['hex'],
        pickerMode: 1
})

'hex' is the file extension I want to restrict the picker to. This is a proprietary file format that I have specified as 'application/octet' on iOS. Do I need to register this as a custom mimetype on Android too? Do you have any documentation for this?

2) This is concerning. Do you mean it is impossible to open a file picked through this plugin on Android 12?

BikeBr0 commented 2 years ago

I think the original bug reported has been resolved but the plugin is not working for me so I will open a new ticket. Thanks for your help!