Automatically track websites changes on Android in background.
The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:
This app tracks changes on websites you otherwise would visit frequently to see if there is something new. Use cases: * Teacher says grades will be published "soon", but no one knows what "soon" means and you are tired of reloading. * You are working with a server and wants to know the result from a request, periodically. * You are waiting for updates on an Exam, like if something was postponed or updated. * You want to monitor the Dagger documentation to see when Thermosiphon's explanation improves.
| Main Screen | Text Diff | PDF Diff | Settings | |:-:|:-:|:-:|:-:| | | | | |
This app contains the following screens: * A list of websites that are currently being tracked. * A text details view, that allows the user to compare the current website version with previous versions. * An image details view, that allows the user to compare images in a carousel. * A pdf details view, that allows the user to compare pdfs in a carousel, similar to the images. * A settings view, that allows user to toggle auto-sync on/off and configure what is required for a sync to occur. * An about screen, with contact information.
This app is a Single-Activity app, with the following components: * A main activity that handles navigation. * A fragment to display the list of websites currently tracked. * A fragment to display the history of changes from the selected website, when changes are not an image or a pdf. * A fragment to display the history of changes from images in a carousel format. * A fragment to display the history of changes from pdfs in a carousel format.
The app uses a Model-View-ViewModel (MVVM) architecture for the presentation layer. Each of the fragments corresponds to a MVVM View. The View and ViewModel communicate using LiveData and general good principles.
The database is created using Room and it has two entities: a
Snapthat generate corresponding SQLite tables at runtime. There is a one to many relationshiop between them. The id from
Siteis a foreign key on
Snap. Snap only contains the snapshot metadata, all the data retrieved from the http request (body response) is stored in Android's own File storage.
To let other components know when the data has finished populating, the
LiveDataobject via callbacks using interfaces (inspired from this todo app). This could be, eventually, easily extended to work with server and sync. The app also makes use of Kotlin's Coroutines to deal with some callbacks.
The app works like this:
| Inside the App | Outside the App | |:-:|:-:| | | |
After a change is detected and user taps to see it, a byte to byte comparision wouldn't be readable, so it makes sense to make a text comparison.
That's why this app makes extensive use from java-diff-utils. In fact, part of the library was converted to Kotlin and is now working perfectly on Java 6 (the original library makes use of Streams, which is only supported on Java 8). All the diff process is made using Myer's diff algorithm, and the result, for performance reasons, is put on a RecyclerView.
When this diff process happens, the app will use jsoup with a relaxed whitelist to remove all the useless tags from html to avoid pages that generate them at every request. Example: pages that make use of Google Analytics and pages that were made in WordPress. The app will also use jsoup to unescape "<" and ">" from html.
It makes no sense to compare images and visual files using strings, so there is a carousel to compare them. PDF's are rendered to an imageView, while images are rendered with support for tiling, which is great for ultra-heavy pictures - in case user is tracking changes for a 20mb photo.
Navigation: this is a single activity app. All fragment transactions (except one) are made using Navigation library.
WorkManager: responsible for automatically syncing when the app is in background. There are four constraints: battery not low, device on idle state (API 23+), device charging and wifi on. Wifi is currently not a constraint from WorkManager, so I implemented it myself to work together.
Paging: on details fragment. As time goes, it is possible for a website to receive hundreds of updates. To avoid OOM error once and for all, Paging was implemented. When visualizing PDF/Image changes (the carousel view), paging is implemented on the carousel, so that it doesn't loads all Files into memory at once.
LiveData/ViewModel: written above.
Room: written above.
Issues and Pull Requests are welcome. You can report here.
Copyright 2018 Bernardo Ferrari.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.