Skip to content

About

Android app to save GitHub repositories and browse their branches, commits and issues. Kotlin, MVVM, Room, Retrofit, coroutines.

Topics

Resources

Stars

8 stars

Watchers

1 watching

Forks

Repository files navigation

GithubBrowser

GithubBrowser

An Android app for keeping an eye on GitHub repositories. Add any public repository by owner and name, save it on the device, then browse its branches and commit history, check its open issues and share it with others.

Built in Kotlin on the GitHub REST API, using MVVM with Jetpack ViewModel, LiveData, Room and coroutines. Made by Prateek.

Download APK

Features

  • Add a repository. Enter an owner and repository name. The app checks it against the GitHub API and saves it locally.
  • Saved list. Saved repositories live in a Room database, so the list loads without a network call.
  • Repository details. Description, open-issue count and a list of every branch.
  • Commit history per branch. Tap a branch to see its commits.
  • Share and open. Share a repository link through the Android share sheet, or open it in the browser.
  • Manage the list. Remove a single repository or clear them all.
  • Offline awareness. A Snackbar tells you when there's no connection and links to settings.

Screenshots

Overview

Screen 1 Screen 2 Screen 3 Screen 4 Screen 5

Tech stack

Layer Library
Language Kotlin
Async Kotlin Coroutines with viewModelScope
Architecture ViewModel, LiveData, Data Binding
Persistence Room
Networking Retrofit + Gson converter, OkHttp
Images Coil, CircleImageView
UI Material Components, RecyclerView, single activity with fragments

Architecture

The app follows MVVM with a single repository class that sits in front of both the network and the local database.

flowchart LR
    F["Fragments<br/>Home · AddRepo · Detail · Commit"] -- "observe LiveData" --> VM["ApiViewModel"]
    VM -- "viewModelScope" --> R["Repository"]
    R --> API["Retrofit RestApi<br/>api.github.com/repos/"]
    R --> DAO["Room Repodao<br/>RepoTable"]
Loading
app/src/main/java/com/prateekcode/githubbrowser/
├── api/         Retrofit instance, endpoints, base URL
├── db/          Room entity (Repotity), DAO, database
├── repository/  Repository: single source for API + DB calls
├── viewmodel/   ApiViewModel + factory, exposes LiveData
├── fragment/    Home, AddRepo, Detail, Commit screens
├── adapter/     RecyclerView adapters (repos, branches, commits)
├── model/       GitHub API response models (repo, branch, commit, issue)
└── util/        Connectivity check and helpers

Data flow. When you add a repository, AddRepoFragment asks the ApiViewModel for GET /repos/{owner}/{repo}. On success the result is saved to Room as a Repotity. DetailFragment loads /branches and open /issues for that repository, and CommitFragment loads /commits?sha={branch}.

Technical decisions

  • One repository class for network and database. Fragments never touch Retrofit or Room directly, so the data sources can change without touching the UI.
  • LiveData of Response<T>. The ViewModel exposes the raw Retrofit response and each fragment checks isSuccessful itself. For example, Add Repository shows "Owner/Repo not found" on a failed lookup.
  • Unauthenticated GitHub API. No sign-in is needed. The trade-off is GitHub's limit for unauthenticated requests (60 per hour per IP).
  • Fragment transactions instead of the Navigation component. This keeps a small app simple.

Build and run

Requirements: Android Studio, JDK 8+, Android SDK 30. Minimum supported device: Android 7.0 (API 24).

git clone https://github.com/prateekcode/GithubBrowser.git
cd GithubBrowser
./gradlew assembleDebug      # APK in app/build/outputs/apk/debug/
./gradlew installDebug       # install on a connected device or emulator

The project dates from 2021 (Gradle 6.5, AGP 4.1, Kotlin 1.4, compileSdk 30, kotlin-android-extensions) and resolves some dependencies from JCenter. Recent Android Studio versions will need a Gradle/AGP upgrade before it syncs.

Testing

The project contains the default test scaffolding:

  • app/src/test/.../ExampleUnitTest.kt: a JVM test that calls the GitHub issues endpoint directly (it needs network access).
  • app/src/androidTest/.../ExampleInstrumentedTest.kt: the default instrumented test.
./gradlew test               # unit tests
./gradlew connectedAndroidTest   # instrumented tests (device/emulator required)

There are no tests yet for the ViewModel, repository or database.

Contributing

Issues and pull requests are welcome. Please open an issue describing the change first. Templates for bug reports and feature requests are in .github/ISSUE_TEMPLATE.

About

Android app to save GitHub repositories and browse their branches, commits and issues. Kotlin, MVVM, Room, Retrofit, coroutines.

Topics

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages