amahi / android

Amahi Android App
GNU General Public License v3.0
165 stars 277 forks source link

No direct Download option #355

Closed arihant-001 closed 6 years ago

arihant-001 commented 6 years ago

Description

For videos, audios, and images there is no direct option for downloading. If a user wants to download a file then only way around is to click on share option.

Solution

Download option can be added to the action bar along with other options.

cpg commented 6 years ago

where are the downloaded files placed?

just wondering, .. e.g. if the user were to want to access it, say an mp3 file with vlc, or a pdf in some pdf-reader?

arihant-001 commented 6 years ago

We can save downloaded files in external storage in Public files so even after uninstalling the app, they will be there to be used by other apps.

cpg commented 6 years ago

Well, we can. I was asking more along the lines of "what is typically done in Android for something like this? .. is there a file system view to the user?"

In this case, are users aware of a "public" area commonly in Android?

arihant-001 commented 6 years ago

In most Android apps, like in Google drive and one Drive, the downloaded file gets saved in the Download folder. In some apps, the file gets saved in a folder according to its type: music file in the music folder, picture in the pictures folder. I was thinking of saving the file in the download folder.

cpg commented 6 years ago

How about we get going on the feature, assuming the destination is the download folder, and later change the location according of the advice from @octacode, @megabitdragon and any others that are regular users?

sanjitchak commented 6 years ago

I think we may later change the destination to 'Amahi' folder, with separate folders for separate file types (images , videos, documents, etc).

'Whatsapp' store all our downloaded media in its own folder name.
screenshot_2018-05-03-11-40-10-607_com estrongs android pop

cpg commented 6 years ago

I just had this idea: what if the folders in the file system where these files are stored (even if we did not download anything) were to be browsable as a share?

So, basically we could play the files again with the app itself! Or share them, etc.

We could make up a "virtual share" called Android Phone Storage or something like that, and we'd see it all the time after the first time a file has been downloaded? (or even before, we always present that virtual share, if it's simpler)

megabitdragon commented 6 years ago

We can do something where we have a download option for audio/video files and have a "share" like @cpg suggested. On top of that we can make something more transparent to the user. For example we could only show files that have been downloaded in their original share. A real life example will be: I need to get on plane and I download some songs for the takeoff. Once I switch to airplane mode, the app should work the same way but only files that are on device should be available. The difference is that they will not be in a special share but in the original share.

arihant-001 commented 6 years ago

@megabitdragon idea looks good. With the idea of @cpg of making a toggle instead of a button for download makes it more precise. So there will be a separate share as @cpg suggested say Offline Data, and on opening the app when the internet connection isn't available, the user will only see the Offline Data share containing original share with downloaded files.

cpg commented 6 years ago

Ok, thinking about this a little more, there are two distinct things, though the second one could affect how the state of the first one is implemnting:

1) There is state and queueing. To the user, there is a "download" button (it could be an icon like 🔽, for example). A) Once tapped, the icon switches to some "downloading" icon (like 🔃 for example) reflecting the state change. B) If tapped while downloading, the option is given to cancel the download via some alert. If cancelled, the button goes to the initial state C) After a while, the icon goes to "the file is downloaded" state, like a checkmark (for example ✅) D) If the file is touched when downloaded, the file is played. There should be a way to delete the file

There are a billion corner cases here, so this is not such a small feature. It could also perhaps leverage the use of a database to maintain the state. This needs to be done with care and testing has to be detailed, given all the possible corner cases.

2) Separately, when the user is offline in an airplane or something, they may not be able to browse shares in the original location (so, what @megabitdragon mentioned above of browsing "like normal" makes things hard in general, because right now the back-end server has to be online to be able to browse).

In this case we could have a "virtual share", called for example Android Phone Storage or whatever (or thinking about it, maybe My Downloads is better). One way to handle the browsing is to make this share a "linear" list of files -- each showing the state (downloading 🔃 or downloaded ✅). We could also have the functionality to play/delete the file here.

arihant-001 commented 6 years ago
cpg commented 6 years ago

Got it. Thanks for expanding the details. So let's split this into several (maybe two, maybe three?) steps and focus one at a time.

arihant-001 commented 6 years ago

This can be broken down into these steps:

  1. adding option dialog and option button and also adding the download option and download completion snackbar.
  2. Implementing a DB for storing list of downloaded files. This will be used to check whether a file is already downloaded, updated or downloading. So according to its state options will change.
  3. Adding My Downloads share. This will display list of all downloaded files with options to play, share and delete from local storage.
csoni111 commented 6 years ago

Just a addition, in case if a downloaded file is manually deleted by a user using some other file browser app, then we must also remove the entry from our database for that file and change the download symbol for that file accordingly.

megabitdragon commented 6 years ago

That's a good point @csoni111. I wonder if there is any way to prevent that. Also, what if someone removes the file from the HDA, what are we going to do? Delete the file from local storage? Restore it? Ask?

octacode commented 6 years ago

For this what Google drive does is that it keeps the downloaded file in the local storage even if the file is deleted from the cloud storage.

cpg commented 6 years ago

Good points. Lots of cases. In my view, we have to define:

This is akin to a cache coherency protocol - defining how things can diverge and how to manage the evolution of those states.

arihant-001 commented 6 years ago

Valid states can be:

There are two ways proposed for the issue.

  1. mentioned by @cpg: here
    • this includes showing different icons according to different downloading states.
  2. mentioned here
    • this includes showing a dialog box for different options available to the user for the selected item.

I think, its necessary to decide one among the two ways before discussing any further.

cpg commented 6 years ago

I think your suggestion, option 2, is a good idea and more extensible.

As for the states, would you consider trying to formally draw a state machine with valid transitions within states? It may be a little bit of work up front, but I think it will help in the long term.

Would be great if we can make it editable to we evolve, for example using dot. Below is a start to that (assuming a file called download-states.dot). Get a PNG file with dot -o downloaded.png -Tpng download-states.dot

digraph download_states {
        rankdir=LR;
        size="8,5"
        node [shape = doublecircle]; online;
        node [shape = circle];
        online -> downloading [ label = "get it" ];
        downloading -> online [ label = "dl failed" ];
        downloading -> downloaded [ label = "dl completed" ];
        downloaded -> remote_updated [ label = "hda updated" ];
        downloaded -> local_vanished [ label = "local removed" ];
        downloaded -> remote_deleted [ label = "remote removed" ];
}
cpg commented 6 years ago

Latest state diagram for discussion download_states_diagram