-
Notifications
You must be signed in to change notification settings - Fork 759
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
CB-7487 [Android] Broadcast file write #81
Conversation
This allows MTP USB shares to show the file immediately without reboot/manual refresh using 3rd party app.
|
||
//Get file | ||
File file = new File(this.filesystemPathForURL(inputURL)); | ||
if (file != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this comparison for? I'm pretty sure that new
can't ever return null
. It also doesn't check for file existence; you'd want file.exists()
for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, I will update this.
Added the fix to check for file exists instead of null check. |
Merged! You can close this PR any time. (I squashed the two commits together, and rebased against the current head, so github won't automatically close the issue :( ) |
Hey guys, I'm still experiencing the same problem with Do you know how I could get this to work with the Pi? |
Wait. I think your fix only applies when you write to a file. The broadcast isn't triggered if you move or copy an existing file. I'll try to update the code and, if that works, open a separate PR for that. |
@tvanesse you are correct, my fix was only for writing files as that's all I was using the plug-in for. It would make sense that if you were moving/copying the files the same function I implemented (broadcastNewFile) should be called. |
@dpeacock Thanks for your quick response. Now I am not really familiar with cordova plugins development but I guess adding
at the end of As I said, I'm not sure how I should set up my environment so that my application uses my locally modified plugin. I can modify the plugin directly in my Ionic project (yes, I'm using ionic) but I don't know how to force Cordova to re-compile the plugin. Can you help me on this? Cheers. |
@tvanesse For a move I'm not sure whether you would need to do it on both the dest and src file, you would have to try I guess or read up on the best practices. But you have the right idea of what's required. The best way to test this would be to 'Fork' the plugin from github, you'll see the icon on the main page. You can then use your favourite Git tool (something like GitKraken for example) to download the source locally and work on it. From your cordova project remove the cordova-plugin-file. You can then either add the plugin specifying your local path, or if you have pushed the changes to your Git repo you can add the plugin using your repo's URL. Each time you make a change you can remove and re-add the plugin. One other thing to note is in some older cordova versions I've had issues where sometimes removing and re-adding the plug-in wasn't working quite right. Doing a cordova platform remove android then re-adding it seemed to solve it. You shouldn't have to do this, but if you run into issues it might be worth trying. Working from Git is best, because once you're satisfied with the changes you can then make a pull request to get your fixes moved into the main plug-in. I would suggest you create a bug on the Cordova Issue tracker for this so you can reference it in your pull request https://issues.apache.org/jira/projects/CB/issues Hopefully that's enough to get you going. I know there were some good blog posts (much more detailed) about this as well that you could probably google if you get stuck. |
@dpeacock Thanks for your support, I successfully tested the patch locally and will open an issue on Jira as you suggest, then a PR on Github. |
This allows MTP USB shares to show the file immediately without reboot/manual refresh using 3rd party app.