Wallagram
Wallagram is an Android application that allows users to update their phones Home screen / Lock screen wallpaper periodically from posts on their favourite subreddit.
Scroll
How it works
On the apps homescreen, a search bar allows the user to enter the name of a subreddit. On search, an android PeriodicWorkRequest is set to run.
Next a work manager is created and the the work request is enqueued.
Firstly the subreddit logo is retrieved and displayed on the app's main screen. Next, a Url is built to retreive the subreddits posts and a JsonObject is returned.'
This JsonObject is then processed as there are many differnet types of Reddit posts. A post can be text only, contain a video, a gallery of many images or just a single image. Posts are checked to contain an image, if the post contains a gallery of many images, a random image is chosen.
An image name is created and all important information is stored to ensure that the same subreddit to searched each time until the user changes the input.
The image is then processed to match the resolution of the phone's display and the wallpaper is set.
FindNewRedditPostWorker.java
Suggestions
On toggle of the light-bulb icon, a suggestion menu of Reddit accounts are shown. As Reddit has a variety of post types (Images, videos, text etc), I have suggested a few subreddits that post pleasing images that would work as a phone wallpaper.
AWS RDS
Firstly I created a AWS RDS database instance. This database was used to store the needed values (Name and Icon image Url) to suggest Reddit accounts to a user. Then I created an AWS lambda function using python to retreive the suggestions in a Json list.
As AWS is a paid service, I began to look into other alternatives.
Firebase
A friend suggested the use of Firebase as it is free to use and easily implemented. I created a Firestore database and added a suggestions collection (table). Next I added the Firebase dependancies in android studio and used the built in functions to retreive the data.
Updating suggestions
To keep suggestions fresh, I created a python script to read suggestions from a text file and update the firestore database. As suggestions are loaded from the database on app open, everyone's suggestions will stay up-to-date.
Scraping
Instagram was the initial choice for Wallagram. A scraping Url was built into the app and the returned Json would be parse for the needed information. Over the space of a year, the Url formatting changed multiple times breaking the app each time. Instagram also added a redirect to the login page, forcing an instagram login on the wallagram app. This is when I decided to change to Reddit.
On Reddit, I created the Wallagram subreddit to allow a personalisable experience for the users. I populated this subreddit by creating a script to read in a list of accounts from a text file and using python to scrap Instagram for the account most recent post. The important information is saved and using the Reddit Api, I create a new post on the Wallagram subreddit.
insta-scrapper.py
To keep the subreddit fresh, I used the Task Scheduler app to run the script every 4 hours.