Skip to content

Commit 5dbea15

Browse files
Merge pull request #21 from reactivedroid/feature/compose-migration
Migrate UI to Jetpack Compose
2 parents 3f36749 + 43806bb commit 5dbea15

52 files changed

Lines changed: 801 additions & 1629 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/android.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ jobs:
88
build:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v1
12-
- name: set up JDK 1.11
13-
uses: actions/setup-java@v1
11+
- uses: actions/checkout@v4
12+
- name: set up JDK 17
13+
uses: actions/setup-java@v4
1414
with:
15-
java-version: 1.11
15+
java-version: 17
16+
distribution: temurin
1617
- name: Build with Gradle
17-
run: ./gradlew assembleDebug
18+
run: ./gradlew assembleDebug

README.md

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,38 @@
11
![Android CI](https://github.com/ashwini009/TvFlix/workflows/Android%20CI/badge.svg?branch=master&event=push) ![GitHub top language](https://img.shields.io/github/languages/top/ashwini009/TvFlix?style=plastic) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![API](https://img.shields.io/badge/API-21%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=21) ![GitHub stars](https://img.shields.io/github/stars/ashwini009/TvFlix?style=social) ![GitHub forks](https://img.shields.io/github/forks/ashwini009/TvFlix?style=social)
22

33

4-
# TvFlix :tv:
4+
# TvFlix :tv:
55

6-
The aim of this app is to replicate the high level functionality of www.tvmaze.com and showcase an android app out of it.
6+
The aim of this app is to replicate the high level functionality of www.tvmaze.com and showcase an android app out of it.
77
It connects with [TVDB API](https://api.thetvdb.com) to give you popular shows and let you mark anyone as favorite.
88
TvFlix consists of 3 pieces of UI right now:
99
1. Home with Popular Shows
1010
2. Favorites
1111
3. All Shows
1212

13-
This app is under development. :construction_worker: :hammer_and_wrench:
14-
1513
*Note: TvFlix is an unofficial app built only for learning and sharing the latest concepts with #AndroidDevs*
1614

1715
## Android Development and Architecture
1816

1917
* The entire codebase is in [Kotlin](https://kotlinlang.org/)
20-
* Uses Kotlin [Coroutines](https://kotlinlang.org/docs/reference/coroutines/coroutines-guide.html).
18+
* Uses [Jetpack Compose](https://developer.android.com/jetpack/compose) for UI
19+
* Uses Kotlin [Coroutines](https://kotlinlang.org/docs/reference/coroutines/coroutines-guide.html) and [StateFlow](https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-state-flow/) for reactive state management
2120
* Uses MVVM Architecture by [Architecture Components](https://developer.android.com/topic/libraries/architecture/). Room, ViewModel, Paging
2221
* Uses [Hilt Android](https://developer.android.com/training/dependency-injection/hilt-android) with [Dagger](https://dagger.dev/) for dependency injection
22+
* Uses [KSP](https://developer.android.com/build/migrate-to-ksp) for annotation processing
2323
* Unit Testing by [Mockito](https://github.com/mockito/mockito)
2424
* Tests Coroutines and architecture components like ViewModel
25-
* UI Test by [Espresso](https://developer.android.com/training/testing/espresso) based on [Robot Pattern](https://academy.realm.io/posts/kau-jake-wharton-testing-robots/)
25+
* UI Test by [Compose Testing](https://developer.android.com/jetpack/compose/testing)
2626
* Uses [Kotlin Coroutines Test](https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-test/) to unit test Kotlin Coroutines
27-
* Uses [StateFlow](https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-state-flow/) as a replacement over LiveData as a state-holder observable
2827
* Uses [Firebase Remote Config](https://firebase.google.com/products/remote-config) for experimentation and feature rollout
2928
* Uses [Firebase App Distribution](https://firebase.google.com/products/app-distribution) for internal distribution and quality testing
30-
31-
## Further Reading
32-
33-
There are several articles written on this repository which state the design and architecture.
34-
35-
### Kotlin Everywhere. Coroutines, Tests, Robots and much more…
36-
37-
The TvFlix complete repository has been re-written in Kotlin with Coroutines covering
38-
Unit Tests across ViewModels and UI tests for the app.
39-
Know more:
40-
[Kotlin Everywhere. Coroutines, Tests, Robots and much more…](https://proandroiddev.com/kotlin-everywhere-coroutines-tests-robots-and-much-more-b02030206cc9)
41-
42-
### MVVM using Android Architecture Components
43-
44-
The codebase tries to follow Uncle Bob Clean Code Architecture with [SOLID principles](https://en.wikipedia.org/wiki/SOLID).
45-
Know more:
46-
[Migration from MVP to MVVM using Android Architecture Components](https://medium.com/@kumarashwini/migration-from-mvp-to-mvvm-using-android-architecture-components-4bc058a1f73c)
47-
48-
### Pagination using Paging Library
49-
50-
The Shows screen displays the list of shows fetched from TvMaze API using [Paging3](https://developer.android.com/topic/libraries/architecture/paging/v3-overview) of Android Architecture Components. It also handles the retry if any network error occurred. Recently the repository has been [migrated to use Paging3](https://github.com/reactivedroid/TvFlix/pull/14).
51-
Paging3 is in heavy development, and if you want to catch up with stable library(Paging 2), then check out this blog
52-
[Pagination using Paging Library with RxJava and Dagger](https://medium.com/@kumarashwini/pagination-using-paging-library-with-rxjava-and-dagger-d9d05dbd8eac)
53-
54-
### Room Persistence Library
55-
56-
The Favourites screen displays the list of shows marked favourites from the Home screen. The user can add/remove from
57-
the favorites as and when required. The implementation of the favorites is done using `Room` Persistence Library with RxJava and Dagger.
58-
Know more:
59-
[Room with RxJava and Dagger](https://medium.com/@kumarashwini/room-with-rxjava-and-dagger-2722f4420651)
60-
61-
### Static Code Analysis
62-
63-
TvFlix has Static Code Analysis tools like FindBugs, PMD and Checkstyle integrated. These tools help in finding potential bugs that would have been missed and help in making the codebase clean.
64-
Know more:
65-
[Static Code Analysis for Android Using FindBugs, PMD and CheckStyle](https://blog.mindorks.com/static-code-analysis-for-android-using-findbugs-pmd-and-checkstyle-3a2861834c6a)
29+
* Uses [Paging3](https://developer.android.com/topic/libraries/architecture/paging/v3-overview) for paginated show listing
6630

6731
## Contributions
6832

6933
If you have found an issue in this sample, please file it.
7034
Better yet, if you want to contribute to the repository, go ahead, any kind of patches are encouraged,
71-
and may be submitted by forking this project and submitting a pull request.
35+
and may be submitted by forking this project and submitting a pull request.
7236
If you have something big in mind, or any architectural change, please raise an issue first to discuss it.
7337

7438
## License
@@ -93,4 +57,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
9357
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
9458
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
9559
SOFTWARE.
96-
```
60+
```

app/build.gradle.kts

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
plugins {
22
id("com.android.application")
33
kotlin("android")
4-
kotlin("kapt")
4+
kotlin("plugin.compose")
5+
id("com.google.devtools.ksp")
56
kotlin("plugin.parcelize")
67
id("dagger.hilt.android.plugin")
78
id("com.google.gms.google-services")
@@ -21,6 +22,7 @@ android {
2122
buildFeatures {
2223
viewBinding = true
2324
dataBinding = true
25+
compose = true
2426
buildConfig = true
2527
}
2628

@@ -31,17 +33,11 @@ android {
3133
versionCode = Deps.Versions.app_version_code
3234
versionName = Deps.Versions.app_version_name
3335
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
34-
javaCompileOptions {
35-
annotationProcessorOptions {
36-
// Refer https://developer.android.com/jetpack/androidx/releases/room#compiler-options
37-
arguments(
38-
mapOf(
39-
"room.schemaLocation" to "$projectDir/schemas",
40-
"room.incremental" to "true",
41-
"room.expandProjection" to "true"
42-
)
43-
)
44-
}
36+
37+
ksp {
38+
arg("room.schemaLocation", "$projectDir/schemas")
39+
arg("room.incremental", "true")
40+
arg("room.expandProjection", "true")
4541
}
4642
}
4743
flavorDimensions.addAll(listOf("default"))
@@ -76,26 +72,18 @@ android {
7672
}
7773
}
7874
compileOptions {
79-
sourceCompatibility = JavaVersion.VERSION_11
80-
targetCompatibility = JavaVersion.VERSION_11
75+
sourceCompatibility = JavaVersion.VERSION_17
76+
targetCompatibility = JavaVersion.VERSION_17
8177
}
8278

8379
testOptions {
8480
unitTests.isIncludeAndroidResources = true
8581
animationsDisabled = true
8682
}
8783

88-
kapt {
89-
useBuildCache = true
90-
javacOptions {
91-
// Increase the max count of errors from annotation processors.
92-
// Default is 100.
93-
option("-Xmaxerrs", 500)
94-
}
95-
}
9684
testBuildType = "debug"
9785

98-
packagingOptions {
86+
packaging {
9987
resources.excludes.addAll(
10088
listOf(
10189
"META-INF/ASL2.0",
@@ -110,8 +98,9 @@ android {
11098
}
11199

112100
kotlinOptions {
113-
jvmTarget = "11"
101+
jvmTarget = "17"
114102
}
103+
namespace = "com.android.tvflix"
115104
}
116105

117106
dependencies {
@@ -121,13 +110,22 @@ dependencies {
121110
implementation(Deps.AndroidX.ktx_core)
122111
implementation(Deps.AndroidX.ktx_fragment)
123112
implementation(Deps.AndroidX.ktx_activity)
113+
implementation(Deps.AndroidX.compose_activity)
124114
implementation(Deps.AndroidX.constraint_layout)
125-
kapt(Deps.AndroidX.Lifecycle.compiler)
115+
implementation(platform(Deps.AndroidX.Compose.bom))
116+
implementation(Deps.AndroidX.Compose.ui)
117+
implementation(Deps.AndroidX.Compose.foundation)
118+
implementation(Deps.AndroidX.Compose.material)
119+
implementation(Deps.AndroidX.Compose.material_icons)
120+
implementation(Deps.AndroidX.Compose.tooling_preview)
121+
implementation(Deps.AndroidX.Compose.navigation)
122+
implementation(Deps.AndroidX.Compose.hilt_navigation)
126123
implementation(Deps.AndroidX.Lifecycle.viewmodel)
127124
implementation(Deps.AndroidX.Paging.runtime)
125+
implementation(Deps.AndroidX.Paging.compose)
128126
testImplementation(Deps.AndroidX.Paging.common)
129127
implementation(Deps.AndroidX.Room.runtime)
130-
kapt(Deps.AndroidX.Room.compiler)
128+
ksp(Deps.AndroidX.Room.compiler)
131129
testImplementation(Deps.AndroidX.Room.testing)
132130
implementation(Deps.AndroidX.Room.ktx)
133131
implementation(Deps.AndroidX.annotation)
@@ -138,7 +136,8 @@ dependencies {
138136
implementation(Deps.OkHttp.logging_interceptor)
139137
implementation(Deps.Glide.runtime)
140138
implementation(Deps.Glide.okhttp_integration)
141-
kapt(Deps.Glide.compiler)
139+
implementation(Deps.Coil.compose)
140+
ksp(Deps.Glide.ksp)
142141
implementation(Deps.Retrofit.main)
143142
implementation(Deps.Retrofit.moshi)
144143

@@ -154,27 +153,25 @@ dependencies {
154153
testImplementation(Deps.AndroidX.Test.core)
155154
androidTestImplementation(Deps.AndroidX.Test.runner)
156155
androidTestImplementation(Deps.AndroidX.Test.junit)
157-
// Espresso
158-
androidTestImplementation(Deps.AndroidX.Test.Espresso.core)
159-
androidTestImplementation(Deps.AndroidX.Test.Espresso.contrib)
160-
androidTestImplementation(Deps.AndroidX.Test.Espresso.idling_resource)
161-
androidTestImplementation(Deps.AndroidX.Test.rules)
156+
androidTestImplementation(Deps.AndroidX.Compose.test_junit4)
162157
testImplementation(Deps.Test.truth)
163158
testImplementation(Deps.Test.robolectric)
164159
testImplementation(Deps.Coroutines.test)
165160
// end-region Test
166161

167162
implementation(Deps.Moshi.kotlin)
168-
kapt(Deps.Moshi.codegen)
163+
ksp(Deps.Moshi.codegen)
169164

170165
implementation(Deps.Coroutines.core)
171166
implementation(Deps.Coroutines.android)
172167

173168
debugImplementation(Deps.Chucker.debug)
169+
debugImplementation(Deps.AndroidX.Compose.tooling)
170+
debugImplementation(Deps.AndroidX.Compose.test_manifest)
174171
releaseImplementation(Deps.Chucker.release)
175172

176173
implementation(Deps.Hilt.android)
177-
kapt(Deps.Hilt.android_compiler)
174+
ksp(Deps.Hilt.android_compiler)
178175

179176
// start-region Firebase
180177
implementation(platform(Deps.Firebase.firebase_bom))
@@ -184,5 +181,3 @@ dependencies {
184181
implementation(Deps.Firebase.remote_config)
185182
// end-region Firebase
186183
}
187-
188-

app/src/androidTest/java/com/android/tvflix/home/HomeRobot.kt

Lines changed: 0 additions & 47 deletions
This file was deleted.

app/src/androidTest/java/com/android/tvflix/home/HomeTest.kt

Lines changed: 0 additions & 48 deletions
This file was deleted.

app/src/androidTest/java/com/android/tvflix/idlingresource/LoadingIdlingResource.kt

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)