Skip to content

Commit

Permalink
migrate to ksp, update libs
Browse files Browse the repository at this point in the history
  • Loading branch information
quanda-0562 committed May 31, 2023
1 parent 884c726 commit c40a897
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 34 deletions.
43 changes: 22 additions & 21 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
id("com.android.application")
id("kotlin-android")
id("kotlin-parcelize")
id("com.google.devtools.ksp")
id("kotlin-kapt")
id("androidx.navigation.safeargs.kotlin")
id("com.google.gms.google-services")
Expand Down Expand Up @@ -127,7 +128,6 @@ android {
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
// freeCompilerArgs = listOf("-Xallow-result-return-type")
}
// https://developer.android.com/topic/libraries/data-binding
buildFeatures {
Expand Down Expand Up @@ -156,14 +156,14 @@ dependencies {

// List of KTX extensions
// https://developer.android.com/kotlin/ktx/extensions-list
implementation("androidx.core:core-ktx:1.10.0")
implementation("androidx.activity:activity-ktx:1.7.1")
implementation("androidx.core:core-ktx:1.10.1")
implementation("androidx.activity:activity-ktx:1.7.2")
implementation("androidx.fragment:fragment-ktx:1.5.7")

// Lifecycle
// https://developer.android.com/jetpack/androidx/releases/lifecycle
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.6.1")
// implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.6.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
implementation("androidx.lifecycle:lifecycle-common-java8:2.6.1")

Expand All @@ -174,7 +174,7 @@ dependencies {
// room
// https://developer.android.com/topic/libraries/architecture/room
implementation("androidx.room:room-runtime:2.5.1")
kapt("androidx.room:room-compiler:2.5.1")
ksp("androidx.room:room-compiler:2.5.1")
implementation("androidx.room:room-ktx:2.5.1")

// paging
Expand All @@ -189,13 +189,13 @@ dependencies {

// coroutines
// https://github.com/Kotlin/kotlinx.coroutines
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.0")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.1")

// moshi
implementation("com.squareup.moshi:moshi-kotlin:1.14.0")
kapt("com.squareup.moshi:moshi-kotlin-codegen:1.14.0")
implementation("com.squareup.moshi:moshi-kotlin:1.15.0")
ksp("com.squareup.moshi:moshi-kotlin-codegen:1.15.0")

// retrofit
// https://github.com/square/retrofit
Expand All @@ -215,13 +215,12 @@ dependencies {
// glide
// https://github.com/bumptech/glide
implementation("com.github.bumptech.glide:glide:4.15.1")
kapt("com.github.bumptech.glide:compiler:4.15.1")
ksp("com.github.bumptech.glide:ksp:4.15.1")

// dagger hilt
implementation("com.google.dagger:hilt-android:2.45")
kapt("com.google.dagger:hilt-android-compiler:2.45")
implementation("com.google.dagger:hilt-android:2.46.1")
kapt("com.google.dagger:hilt-android-compiler:2.46.1")
implementation("androidx.hilt:hilt-navigation-fragment:1.0.0")
// implementation("androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03")
kapt("androidx.hilt:hilt-compiler:1.0.0")

// runtime permission
Expand Down Expand Up @@ -381,12 +380,12 @@ dependencies {
// or Material Design 2
implementation("androidx.compose.material:material:1.4.3")
// Material Design 3
implementation("androidx.compose.material3:material3:1.1.0-rc01")
implementation("androidx.compose.material3:material3:1.1.0")
// Android Studio Preview support
implementation("androidx.compose.ui:ui-tooling-preview:1.4.3")
debugImplementation("androidx.compose.ui:ui-tooling:1.4.3")
// UI Tests
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.5.0-alpha03")
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.4.3")
debugImplementation("androidx.compose.ui:ui-test-manifest:1.4.3")
// Animations
implementation("androidx.compose.animation:animation:1.4.3")
Expand All @@ -399,20 +398,22 @@ dependencies {
// Optional - Add full set of material icons
implementation("androidx.compose.material:material-icons-extended:1.4.3")
// Optional - Add window size utils
implementation("androidx.compose.material3:material3-window-size-class:1.0.1")
implementation("androidx.compose.material3:material3-window-size-class:1.1.0")
// Optional - Integration with activities
implementation("androidx.activity:activity-compose:1.7.1")
implementation("androidx.activity:activity-compose:1.7.2")
// Optional - Integration with ViewModels
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1")
// Optional - Integration with LiveData
implementation("androidx.compose.runtime:runtime-livedata:1.4.3")
// implementation("androidx.compose.runtime:runtime-livedata:1.4.3")
// Lifecycle utilities for Compose
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.6.1")
// navigation
implementation("androidx.navigation:navigation-compose:2.5.3")
implementation("androidx.hilt:hilt-navigation-compose:1.0.0")
// https://github.com/skydoves/landscapist
// implementation("com.github.skydoves:landscape-bom:2.1.7")
implementation("com.github.skydoves:landscapist-glide:2.1.13")
implementation("com.github.skydoves:landscapist-placeholder:2.1.13")
implementation("com.github.skydoves:landscapist-glide:2.2.0")
implementation("com.github.skydoves:landscapist-placeholder:2.2.0")
// https://google.github.io/accompanist/
// https://github.com/google/accompanist
val accompanistVersion = "0.28.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import androidx.compose.material.pullrefresh.pullRefresh
import androidx.compose.material.pullrefresh.rememberPullRefreshState
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/java/com/example/moviedb/di/AppModule.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.example.moviedb.di

import android.content.Context
import android.content.SharedPreferences
import android.content.res.AssetManager
import android.content.res.Resources
import androidx.datastore.core.DataStore
Expand Down Expand Up @@ -38,10 +37,10 @@ class AppModule {
@Provides
fun provideAssetManager(context: Context): AssetManager = context.assets

@Singleton
/*@Singleton
@Provides
fun provideSharedPrefs(context: Context): SharedPreferences =
context.getSharedPreferences(context.packageName, Context.MODE_PRIVATE)
context.getSharedPreferences(context.packageName, Context.MODE_PRIVATE)*/

@Singleton
@Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import android.content.Intent
import android.util.SparseArray
import androidx.core.util.forEach
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.navigation.NavController
import androidx.navigation.fragment.NavHostFragment
import com.google.android.material.bottomnavigation.BottomNavigationView
import kotlinx.coroutines.flow.MutableStateFlow

/**
* Manages the various graphs needed for a [BottomNavigationView].
Expand All @@ -24,12 +23,12 @@ fun BottomNavigationView.setupWithNavController(
fragmentManager: FragmentManager,
containerId: Int,
intent: Intent
): LiveData<NavController> {
): MutableStateFlow<NavController> {

// Map of tags
val graphIdToTagMap = SparseArray<String>()
// Result. Mutable live data with the selected controlled
val selectedNavController = MutableLiveData<NavController>()
val selectedNavController = MutableStateFlow(NavController(context))

var firstFragmentGraphId = 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ fun ImageView.loadImage(
}
}

GlideApp.with(context).load(imageUrl).apply {
Glide.with(context).load(imageUrl).apply {
transition(DrawableTransitionOptions.withCrossFade())
addListener(requestListener)
// breaks sharedElementEnterTransition
Expand Down
10 changes: 6 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ buildscript {
repositories {
google()
mavenCentral()
// maven("https://maven.google.com")
}
dependencies {
classpath("com.android.tools.build:gradle:8.0.1")
classpath("com.android.tools.build:gradle:8.0.2")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.21")
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:2.5.3")
classpath("com.google.dagger:hilt-android-gradle-plugin:2.44.2")
classpath("com.google.dagger:hilt-android-gradle-plugin:2.46.1")
// classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Libs.kotlinVersion}")
// classpath("androidx.navigation:navigation-safe-args-gradle-plugin:${Libs.navigationVersion}")
// classpath("com.google.dagger:hilt-android-gradle-plugin:${Libs.daggerHiltVersion}")
Expand All @@ -21,10 +20,13 @@ allprojects {
repositories {
google()
mavenCentral()
// maven("https://maven.google.com")
}
}

tasks.register("clean", Delete::class.java) {
delete(rootProject.buildDir)
}

plugins {
id("com.google.devtools.ksp") version "1.8.21-1.0.11" apply false
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ android.databinding.incremental=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
kapt.incremental.apt=true
ksp.incremental.apt=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=true
android.nonFinalResIds=false
Expand Down

0 comments on commit c40a897

Please sign in to comment.