blonsky95 / DigiCoachAndroid

0 stars 0 forks source link

Investigate video path file in results #98

Closed blonsky95 closed 4 years ago

blonsky95 commented 4 years ago

So when you add a result you can add a pathfile - so either an image or a media file - user can then press the link, which sends an intent to open the file

blonsky95 commented 4 years ago

Button with +media added, and when you click it it sends intent to pick video or image from gallery - GOOD - using intent with onactivityresult with: val intent = Intent( Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI )

Now display the name of the file on a text view, and save it with the results when getfield contents and test its integration with the other results. Also get rid +media after 1. - GOOD - displays the path after adding and when in read mode - integrates fine but have to clean up the whole get field contents stuff - need to get rid of media after 1 - GOOD - now when you tap edit result it dissapears - investigate and fix - GOOD so I had to use a mediaItemCount and a "should overwrite media" boolean to make it easier to read

Then look at how to display it when opening a result in view mode, if nothing then nothing, if there is a media file then send intent to open with gallery or whatever

blonsky95 commented 4 years ago

bit of a problem with file provider and turning the files into URIS - put a question in stackoverflow but otherwise might need to do ContentProvider/FileProvider research

blonsky95 commented 4 years ago

So file provider turns the filepath into a URI to better handle permissions so the app to which the intent is sent, we know have permission.

Atm, just fix External storage directory, if it contains emulated, then build the string with Environment.getExternalStorageDirectory/whatever_the_file_is.ext DONE - this will be a temporary solution - handle error for non ext storage uris when receiving result DONE (just ignores) - the best thing might be adding my own mediaplayer basic play pause, let's see - add features like slow mo later

then change the media name for video or photo and make it a button.

test this with Joni

blonsky95 commented 4 years ago

Working but yet to be tested more thoroughly

Added a new code thingy - there is a hashmap in results creator with a file_path key and a file_name key so that it displays the file_name value on the textview, but collects the file_path value when it gets fields contents - as there can only be 1 media it is all in one same variable

Also this is only working with media stored in Environment.getExternalStorageDirectory() aka storage/emulated/0 - will test with another device first but have to do other types of storage

blonsky95 commented 4 years ago

see if I can figure out the uris for the videos/media coming from other apps - or make it only gallery? - if not just send error message saying file must be located in ext storage or some shit

blonsky95 commented 4 years ago

Ok so what im trying to do now is convert the uri to string and vice versa, I get a security error so investigate this better - test different apps from which to get media + closing and opening app and opening those files -------------------- 1 also have to get the right file name -------------------- 2 and the right type if possible + intent that allows other apps too -------------------- 3

blonsky95 commented 4 years ago

I'll explain tomorrow - but commonsware saved my ass - ill lecture myself on this later - but - will probably add a button for image and a button for video, and they overwrite each other! proceeeeed tomorrow biiitch night night

blonsky95 commented 4 years ago

https://stackoverflow.com/questions/63478041/android-storing-and-reusing-obtained-uris

So, URIs are short lived, or more precisely, depend on circumstances. When I try and get a content uri through a ACTION_PICK, Mediastore.EXTERNAL_CONTENT_URI, the URI I get has permissions granted because the Mediastore has better accesibility than me as a normal user. As such, the uri works but as soon as the instance of the uri is finished, any form of this uri's copy will search for a permission and not find it, aka not reusable.

Instead, the intent Intent.ACTION_OPEN_DOCUMENT does give back a ContentURI which permission you can make persistent (across reboots or app lifecycles), check the documentation for this constant for more info. The only downside is you need to select your media item through the document provider which most users are probably not friendly with, but its still simple and it also has access to cloud.

blonsky95 commented 4 years ago

I am not specifying type so any document format is "in theory" supported, so now just figure out names

blonsky95 commented 4 years ago

done!!!! test with a friend!