Giter Club home page Giter Club logo

malinda-lin / android-image-gallery-app Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 20.89 MB

This photo gallery application lets users browse randomly selected images from Unsplash.com and save or download them.

Home Page: https://drive.google.com/file/d/1vGZciqb5i_0QqLpZ_kQ2m1kQEaLYNCqY/view

License: Apache License 2.0

Java 3.75% Kotlin 96.25%
android-room architecture-pattern mvp retrieve-data unsplash-api android-application kotlin coroutines-retrofit glideimageloader

android-image-gallery-app's Introduction

Photo Gallery

This photo gallery application lets users browse randomly selected images from Unsplash.com and save or download them.

Table of Contents

Application Overview

Users may save their favorite images to the application by tapping the image and tapping the heart button. Favorite images are viewable in the favorites screen.

Users may also download images to their internal storage by selecting "download" from the overflow menu in the top app bar, switching on for the images they're interested in, and tapping "Start Download".

Downloaded images can be found in:
Internal storage>Android>data>com.onramp.android.takehome>files>Pictures>galleryApp.

The search option is a work in progress, it currently does not function.
Try the app here: APK Link

Architectural Overview

This application currently has two core features and those features are separated into two activities (Explore & Favorites). These activities share core UI components such as the top app bar, "GridView", and bottom navigation. Both activities follow the model view presenter (MVP) architecture pattern to decouple the UI and the back end implementation. Both activities deal with sending and receiving image data so they share a repository for the implementation of those functions.

The data sources are divided into local and remote. The local data source utilizes Android Room to store data and retrieve data while the remote data source utilizes the Unsplash API only to retrieve data.

For the file structure, files are divided by feature and purpose. For example, all files related to the explore activity are grouped, these include the explore activity, explore presenter, and explore contract. Files that are reused and shared such as fragments are grouped under the category of fragments, these include UI components like the bottom navigation and top app bar.

See Application Creation and Learning Process to learn about how I would optimize this structure.

Project Requirements

This section goes over how I addressed the requirements below:

Activities and Fragment Components

This application has "Explore" and "Favorites" activities. The top app bar and bottom navigation are implemented as fragments.

Service Component

This application's image downloading feature is a background service. I chose this feature as such because file downloads should continue even when users leave the application.

MVP Architecture Pattern

This application follows the MVP architectural pattern. This pattern allows for easier testing and separation of concerns. For each activity, I utilize a presenter that regulates the communication between the view (UI) and the model (data layer). The view receives user input or interactions and responses by updating the UI after the presenter provides the data. The presenter and view are linked through the contract which cleanly lay out the executable functions. The implementation for those functions are stored in the presenter. The data layer communicates with the presenter through the repository. The repository stores implementation for requesting or sending data to and from the data sources.

Below is an example specific to the explore activity:

REST API

This application uses the Retrofit API interface to make GET requests from the Unsplash API. I chose the random images API route so that users could see different images every time they open the "Explore Activity". This API required registering for an API key. I stored this API key using BuildConfig to avoid exposing it.

UI Components from Android Material Design Component Library

UI Components Used: App Bar: Top, Switches, Cards, Button, Bottom Navigation, Snackbar

Data Persistence (Android Room)

This application uses Android Room to store image data of images favored by users. This local database is set up through 3 key components. (Image Class, Image Data Access Object, Database)
The image data class defines the image properties and their types so the database knows what it's storing. The image data access object or DAO is where the query types are defined and implemented. The image database class builds and create an instance of the room database. The database instance is used by the image repository to implement data transfers between the model and view. In this application, every time a user favors an image, the presenter triggers the repository and an instance of the image class is created and stored to the database using a database instance.

Installation

Using your phone or emulator: APK Link

  Phone -> Install .apk file on your phone and enable "download from unknown sources"

  Emulator -> Drag file to emulator

Using this repo:

  git clone <this repo>
  Connect device (phone/emulator)
  Press "Run app" (Android Studio)

Application Creation and Learning Process

To start this project, I outlined the requirements to use for the basis of a rough UI design. Next, I researched project requirements that were unfamiliar to me, mainly the MVP architecture pattern. Then, I outlined the file structure and potential files that I would need in order to follow this architecture pattern. Finally, I started developing my application by referring to my UI design.

Since this was my first native Android application, I heavily relied on documentation, video tutorials, Stack Overflow, and Logcat. I celebrated every small victory and successfully implemented features but as I was developing, I was also thinking about how I could optimize. In future development, I would create my Explore Activity and Favorites activity as fragments hosted on a main activity because they share many UI components. This would eliminate the need for the top app bar and bottom navigation as fragments. Instead, I would include them as regular view components in the main activity layout. Looking back on my code, I can see that there is much refactoring to do and additional best practices to be applied.

Nonetheless, this project was an intense and rewarding learning experience. I used Android Studio to generate an .apk file and was so excited to see it running on my phone. Now, I look forward to building out my other ideas for the Android platform.

Technologies Used

  • Android Studio (IDE)
  • Kotlin (Language)
  • Retrofit (REST Client built on OkHttp)
  • Glide (Image Loading Framework)
  • Android Room (Data Persistence, Local Database)
  • Unsplash API (Third Party API)

Resources Used and Credits

Android Dev Docs on App Architecture
MVP Architecture Kotlin Code Example
MVP Architecture Video
MVP Architecture Tutorial
Logcat Video Tutorial
Retrofit Documentation
Retrofit Video Tutorial
Android Room Documentation
Android Room Video Tutorial
Glide - Image Loading Library
Using "setTag" Method
Using GridView and BaseAdapter Video Tutorial
Coroutine Kotlin Language Documentation
Coroutine Beginner Video Tutorial
Guide to Storing Secret Keys
Adding Fragments Video Tutorial
Unsplash API
Extracting APK
Stack Overflow
Material Design

android-image-gallery-app's People

Contributors

malinda-lin avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.