diff --git a/README.md b/README.md index bd1fa8f..ed33313 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ #


Jokes

Gradle Build - Kotlin Version + Kotlin Version Min API License Contributors
@@ -19,7 +19,7 @@ * Gson * ViewBinding * Coroutines -* Hilt +* Hilt beta * Jetpack navigation * [razir/ProgressButton](https://github.com/razir/ProgressButton) * [15Dkatz/official_joke_api](https://github.com/15Dkatz/official_joke_api) diff --git a/app/build.gradle b/app/build.gradle index 08de985..32f63cc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,15 +6,15 @@ plugins { } android { - compileSdkVersion 29 - buildToolsVersion "30.0.2" + compileSdkVersion 30 + buildToolsVersion "30.0.3" defaultConfig { applicationId "com.cybershark.jokes" minSdkVersion 23 - targetSdkVersion 29 + targetSdkVersion 30 versionCode 1 - versionName "1.0" + versionName "1.1" vectorDrawables.useSupportLibrary = true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -57,12 +57,12 @@ dependencies { // Lifecycle dependencies implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' - implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0" - implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0" + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.0" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0" + implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.3.0" // Design dependencies - implementation 'com.google.android.material:material:1.2.1' + implementation 'com.google.android.material:material:1.3.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'com.github.razir.progressbutton:progressbutton:2.1.0' @@ -72,30 +72,28 @@ dependencies { implementation 'com.squareup.retrofit2:converter-gson:2.9.0' //room - implementation "androidx.room:room-runtime:2.2.5" - kapt "androidx.room:room-compiler:2.2.5" - implementation "androidx.room:room-ktx:2.2.5" + implementation "androidx.room:room-runtime:2.2.6" + kapt "androidx.room:room-compiler:2.2.6" + implementation "androidx.room:room-ktx:2.2.6" // Navigation dependencies - implementation 'androidx.navigation:navigation-fragment-ktx:2.3.2' - implementation 'androidx.navigation:navigation-ui-ktx:2.3.2' + implementation 'androidx.navigation:navigation-fragment-ktx:2.3.4' + implementation 'androidx.navigation:navigation-ui-ktx:2.3.4' //hilt dependencies - implementation 'com.google.dagger:hilt-android:2.29.1-alpha' - kapt 'com.google.dagger:hilt-android-compiler:2.29.1-alpha' - implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02' - kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha02' + implementation 'com.google.dagger:hilt-android:2.33-beta' + kapt 'com.google.dagger:hilt-android-compiler:2.33-beta' //coil dependencies implementation "io.coil-kt:coil:1.0.0-rc3" //coroutines dependencies implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1' // Testing dependencies debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.5' - testImplementation 'junit:junit:4.13.1' + testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' } \ No newline at end of file diff --git a/app/src/main/java/com/cybershark/jokes/di/DataModule.kt b/app/src/main/java/com/cybershark/jokes/di/DataModule.kt index 23d27e8..e33bbbc 100644 --- a/app/src/main/java/com/cybershark/jokes/di/DataModule.kt +++ b/app/src/main/java/com/cybershark/jokes/di/DataModule.kt @@ -12,14 +12,14 @@ import com.cybershark.jokes.data.room.FavoriteJokeDao import dagger.Module import dagger.Provides import dagger.hilt.InstallIn -import dagger.hilt.android.components.ApplicationComponent import dagger.hilt.android.qualifiers.ApplicationContext +import dagger.hilt.components.SingletonComponent import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory import javax.inject.Singleton @Module -@InstallIn(ApplicationComponent::class) +@InstallIn(SingletonComponent::class) object DataModule { @Provides @@ -52,7 +52,7 @@ object DataModule { @Provides @Singleton - fun getRetrofit(@ApplicationContext context: Context): JokeApiService { + fun getRetrofit(): JokeApiService { return Retrofit.Builder() .baseUrl(ApiConstants.apiEndpoint) .addConverterFactory(GsonConverterFactory.create()) diff --git a/app/src/main/java/com/cybershark/jokes/ui/favorite/FavoritesViewModel.kt b/app/src/main/java/com/cybershark/jokes/ui/favorite/FavoritesViewModel.kt index 48c7339..95ef590 100644 --- a/app/src/main/java/com/cybershark/jokes/ui/favorite/FavoritesViewModel.kt +++ b/app/src/main/java/com/cybershark/jokes/ui/favorite/FavoritesViewModel.kt @@ -1,17 +1,18 @@ package com.cybershark.jokes.ui.favorite -import androidx.hilt.Assisted -import androidx.hilt.lifecycle.ViewModelInject import androidx.lifecycle.* import com.cybershark.jokes.data.respositories.MainRepository import com.cybershark.jokes.data.room.JokeEntity import com.cybershark.jokes.util.* +import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.launch +import javax.inject.Inject +@HiltViewModel class FavoritesViewModel -@ViewModelInject +@Inject constructor( - @Assisted savedStateHandle: SavedStateHandle, + private val savedStateHandle: SavedStateHandle, private val mainRepository: MainRepository ) : ViewModel() { diff --git a/app/src/main/java/com/cybershark/jokes/ui/home/HomeFragment.kt b/app/src/main/java/com/cybershark/jokes/ui/home/HomeFragment.kt index 4503c17..3c386a7 100644 --- a/app/src/main/java/com/cybershark/jokes/ui/home/HomeFragment.kt +++ b/app/src/main/java/com/cybershark/jokes/ui/home/HomeFragment.kt @@ -9,6 +9,7 @@ import androidx.fragment.app.viewModels import coil.load import com.cybershark.jokes.R import com.cybershark.jokes.databinding.FragmentHomeBinding +import com.cybershark.jokes.ui.home.util.JokeState import com.cybershark.jokes.util.UIState import com.cybershark.jokes.util.makeVisible import com.cybershark.jokes.util.observe diff --git a/app/src/main/java/com/cybershark/jokes/ui/home/HomeViewModel.kt b/app/src/main/java/com/cybershark/jokes/ui/home/HomeViewModel.kt index 9b86f6b..31380e0 100644 --- a/app/src/main/java/com/cybershark/jokes/ui/home/HomeViewModel.kt +++ b/app/src/main/java/com/cybershark/jokes/ui/home/HomeViewModel.kt @@ -1,17 +1,19 @@ package com.cybershark.jokes.ui.home -import androidx.hilt.Assisted -import androidx.hilt.lifecycle.ViewModelInject import androidx.lifecycle.* import com.cybershark.jokes.data.models.Joke import com.cybershark.jokes.data.respositories.MainRepository +import com.cybershark.jokes.ui.home.util.JokeState import com.cybershark.jokes.util.* +import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.launch +import javax.inject.Inject +@HiltViewModel class HomeViewModel -@ViewModelInject +@Inject constructor( - @Assisted savedStateHandle: SavedStateHandle, + private val savedStateHandle: SavedStateHandle, private val mainRepository: MainRepository ) : ViewModel() { @@ -80,7 +82,3 @@ constructor( } } -data class JokeState( - val joke: Joke, - val isJokeFavorite: Boolean -) \ No newline at end of file diff --git a/app/src/main/java/com/cybershark/jokes/ui/home/util/JokeState.kt b/app/src/main/java/com/cybershark/jokes/ui/home/util/JokeState.kt new file mode 100644 index 0000000..c5d3381 --- /dev/null +++ b/app/src/main/java/com/cybershark/jokes/ui/home/util/JokeState.kt @@ -0,0 +1,8 @@ +package com.cybershark.jokes.ui.home.util + +import com.cybershark.jokes.data.models.Joke + +data class JokeState( + val joke: Joke, + val isJokeFavorite: Boolean +) diff --git a/app/src/main/java/com/cybershark/jokes/ui/settings/SettingsViewModel.kt b/app/src/main/java/com/cybershark/jokes/ui/settings/SettingsViewModel.kt index 6a2b63c..866228c 100644 --- a/app/src/main/java/com/cybershark/jokes/ui/settings/SettingsViewModel.kt +++ b/app/src/main/java/com/cybershark/jokes/ui/settings/SettingsViewModel.kt @@ -1,19 +1,20 @@ package com.cybershark.jokes.ui.settings -import androidx.hilt.Assisted -import androidx.hilt.lifecycle.ViewModelInject import androidx.lifecycle.* import com.cybershark.jokes.data.respositories.MainRepository import com.cybershark.jokes.util.UIState import com.cybershark.jokes.util.getDefault import com.cybershark.jokes.util.setError import com.cybershark.jokes.util.setSuccess +import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.launch +import javax.inject.Inject +@HiltViewModel class SettingsViewModel -@ViewModelInject +@Inject constructor( - @Assisted savedStateHandle: SavedStateHandle, + private val savedStateHandle: SavedStateHandle, private val mainRepository: MainRepository ) : ViewModel() { diff --git a/app/src/main/java/com/cybershark/jokes/util/HelperFunctions.kt b/app/src/main/java/com/cybershark/jokes/util/HelperFunctions.kt index 04b2c8e..01fdfbe 100644 --- a/app/src/main/java/com/cybershark/jokes/util/HelperFunctions.kt +++ b/app/src/main/java/com/cybershark/jokes/util/HelperFunctions.kt @@ -18,10 +18,10 @@ internal fun View.shortSnackBar( message: String, action: (Snackbar.() -> Unit)? = null ) { - val snackbar = Snackbar.make(this, message, Snackbar.LENGTH_SHORT) - action?.let { snackbar.it() } - snackbar.setAnchorView(R.id.bottomNavigation) - snackbar.show() + val snackBar = Snackbar.make(this, message, Snackbar.LENGTH_SHORT) + action?.let { snackBar.it() } + snackBar.setAnchorView(R.id.bottomNavigation) + snackBar.show() } internal fun Snackbar.action(message: String, action: (View) -> Unit) { diff --git a/build.gradle b/build.gradle index 09b3feb..9c20456 100644 --- a/build.gradle +++ b/build.gradle @@ -1,14 +1,14 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = "1.4.20" + ext.kotlin_version = "1.4.31" repositories { google() jcenter() } dependencies { - classpath "com.android.tools.build:gradle:4.1.1" + classpath 'com.android.tools.build:gradle:4.1.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'com.google.dagger:hilt-android-gradle-plugin:2.29.1-alpha' + classpath 'com.google.dagger:hilt-android-gradle-plugin:2.33-beta' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0d16ccb..5370a9c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Nov 27 19:47:55 IST 2020 +#Fri Mar 19 10:37:39 IST 2021 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip