Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

offline storage ? #89

Closed
abate opened this issue Dec 20, 2015 · 13 comments
Closed

offline storage ? #89

abate opened this issue Dec 20, 2015 · 13 comments

Comments

@abate
Copy link

abate commented Dec 20, 2015

Hi all.
First let me thank you for this very nice app ! I've a small request. I often find myself offline and in need to check a message I received earlier. Would it be possible to add some kind of offline storage or cache to make it possible to use the app even without network connection ? I really miss this feature.

thank you for your work !

@indywidualny
Copy link
Owner

A nice idea. I will add this in the next release. I'm not sure how to solve switching to "live" mode when there is a connection after a lack of connection. Perhaps one refresh (pull down) will be needed to do so. Stay tuned, I'm a little busy at the moment but I'm trying to reply all the issues and solve them :)

@indywidualny
Copy link
Owner

A note to myself: Floating Action Button - "Go online": https://gist.github.com/Jogan/9def6110edf3247825c9

When an user is offline and wants to go online (there's a network connection again).
Just in case - perhaps it cannot be done automatically.

@indywidualny
Copy link
Owner

I tried to do it a few times but apparently Facebook doesn't allow to cache the whole page. Although I managed to implement caching mechanism it didn't work. The idea is nice but unfortunately it's not gonna happen. The "problem" is in the website itself.

@abate
Copy link
Author

abate commented Feb 2, 2016

that's unfortunate. what do you mean "to cache the whole page" ? My request was actually related to messages more then to the main page. Is it really complicated to store all received messages somewhere and build the message page from there ? You would need to parse the message page, look for individual messages and then store the html fragments . I'm sorry I can't help you with a bit of code, but java is definitely not my language ...

Maybe you can publish in a separate branch your attempts, so others can start from there ...

thank you for trying anyway :+1

@indywidualny
Copy link
Owner

Ok. I think there is a way to do it. Do you need images too? Or just text versions for offline mode? If text versions are enough than good and it's not so complicated.

All the (selected at preferences) pages would be saved to a plain text file when visited. During offline mode the file would be loaded instead. The file would be obviously private.

  • Small file sizes, extremely fast, easy to customize
  • Bigger data consumption, will not work for a dynamically loaded content, often disk writes/reads (it may impact battery life). And what's the most important I'm not sure whether it will work at all. But I'll give it a shot :)

On the other hand there is a serialization, but I'm not quite sure how to use it properly for a WebView.

@abate
Copy link
Author

abate commented Feb 2, 2016

I think text is more then enough. In the end all fb messages are usually short and not very content-rich.

What about using a small sqlite db to store everything ? This should remove clutter on the disk and maybe avoid over complicated lookup routines to retrieve a message ... 👍

@indywidualny
Copy link
Owner

Ooooh! It's a good point! I learned how to use SQLite recently.

But in fact in Android the database is still saved in a file xD

@indywidualny
Copy link
Owner

Ok, it's actually done. A dissappointing thing is: it doesn't work for a dynamically loaded content (e.g. opening the whole message thread). But it works great for a wide variety of cases. Let's assume there was something at the top of your newsfeed or you want to check upcoming events. If you have visited those pages recently there will be the latest version of them in a database. It saves just a plain html, so it doesn't use much data. All the images are loaded from cache. It was not possible to load the whole page from cache so I've invented a quite complicated workaround. Try for yourself. It may be usefull sometimes but it's not a must have :)

@abate
Copy link
Author

abate commented Feb 8, 2016

I'll test it sometimes this evening / tomorrow and get back to you 👍

@indywidualny
Copy link
Owner

Great! Use the latest version please :)

indywidualny pushed a commit that referenced this issue Feb 11, 2016
indywidualny pushed a commit that referenced this issue Feb 11, 2016
@vuyibiran
Copy link

Hello.

Tanks for implementing this. One question: you say that it is not possible to have the offline function for dynamically loaded content. Is this in any case, even for chats? Or do you think that there might be a way to solve this?

@abate
Copy link
Author

abate commented Feb 11, 2016

ok, I've tested it now for a couple of days. My first impression is that the network detection is still a bit problematic. Sometimes it gets stuck in offline mode. This is just an impression. I didn't pinpoint the problem. Second , I see you present an overlay of the list of cached pages. This is ok, but it would be even better if you could maintain a cache of the message page (as it was seen the last time) and use that as an index to retrieve messages in offline mode. This way you could get rid of the small circle and just change the color of the bar when in offline mode, so to maintain the look and feel more consistent. Basically the different from offline and online mode would be just the color of the upper bar and the fact that some content would not be available...

Other than that, I haven't noticed any regressions with the rest of the functionalities.

@indywidualny
Copy link
Owner

Network detection should be good for the official release. I changed some things yesterday. Changing color of status bar looks like a great idea but remember that app supports also ICS and Jellybean and there is no way to change the color for those versions.

To save a chat thread you have to pull to refresh the page because it cannot be done automatically. This way it will be saved to a database. I don't think it's possible to make it different.

So in general I achieved more less the thing I was supposed to. To save a dynamically loaded page you have to refresh it unfortunatelly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants