Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Update Views-Hilt Project to API Level 34 with Gradle 8.4 #1003

Open
wants to merge 1 commit into
base: views-hilt
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ apply plugin: 'dagger.hilt.android.plugin'
apply plugin: 'androidx.navigation.safeargs.kotlin'

android {
compileSdkVersion rootProject.compileSdkVersion
namespace = "com.example.android.architecture.blueprints.todoapp"
compileSdk rootProject.compileSdkVersion

defaultConfig {
applicationId "com.example.android.architecture.blueprints.master"
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
minSdk rootProject.minSdkVersion
targetSdk rootProject.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true

testInstrumentationRunner "com.example.android.architecture.blueprints.todoapp.CustomTestRunner"

Expand Down Expand Up @@ -177,4 +179,7 @@ dependencies {
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
implementation "androidx.fragment:fragment-ktx:$fragmentKtxVersion"

//MultiDex
implementation "androidx.multidex:multidex:$multiDexVersion"
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import androidx.test.core.app.ApplicationProvider
*/
inline fun <reified T : Fragment> launchFragmentInHiltContainer(
fragmentArgs: Bundle? = null,
@StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme,
@StyleRes themeResId: Int = R.style.AppTheme,
crossinline action: Fragment.() -> Unit = {}
) {
val startActivityIntent = Intent.makeMainActivity(
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
<activity
android:name="com.example.android.architecture.blueprints.todoapp.tasks.TasksActivity"
android:windowSoftInputMode="adjustResize"
android:theme="@style/AppTheme.OverlapSystemBar">
android:theme="@style/AppTheme.OverlapSystemBar"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ open class Event<out T>(private val content: T) {
* [onEventUnhandledContent] is *only* called if the [Event]'s contents has not been handled.
*/
class EventObserver<T>(private val onEventUnhandledContent: (T) -> Unit) : Observer<Event<T>> {
override fun onChanged(event: Event<T>?) {
event?.getContentIfNotHandled()?.let {

override fun onChanged(event: Event<T>) {
event.getContentIfNotHandled()?.let {
onEventUnhandledContent(it)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.example.android.architecture.blueprints.todoapp

import android.app.Application
import androidx.multidex.BuildConfig
import dagger.hilt.android.HiltAndroidApp
import timber.log.Timber
import timber.log.Timber.DebugTree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import androidx.annotation.StringRes
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.Transformations
import androidx.lifecycle.ViewModel
import androidx.lifecycle.distinctUntilChanged
import androidx.lifecycle.map
import androidx.lifecycle.switchMap
import androidx.lifecycle.viewModelScope
import com.example.android.architecture.blueprints.todoapp.Event
Expand Down Expand Up @@ -91,9 +91,8 @@ class TasksViewModel @Inject constructor(
val newTaskEvent: LiveData<Event<Unit>> = _newTaskEvent

private var resultMessageShown: Boolean = false

// This LiveData depends on another so we can use a transformation.
val empty: LiveData<Boolean> = Transformations.map(_items) {

val empty: LiveData<Boolean> = _items.map {
it.isEmpty()
}

Expand Down Expand Up @@ -121,12 +120,14 @@ class TasksViewModel @Inject constructor(
R.drawable.logo_no_fill, true
)
}

ACTIVE_TASKS -> {
setFilter(
R.string.label_active, R.string.no_tasks_active,
R.drawable.ic_check_circle_96dp, false
)
}

COMPLETED_TASKS -> {
setFilter(
R.string.label_completed, R.string.no_tasks_completed,
Expand Down Expand Up @@ -229,13 +230,14 @@ class TasksViewModel @Inject constructor(
ACTIVE_TASKS -> if (task.isActive) {
tasksToShow.add(task)
}

COMPLETED_TASKS -> if (task.isCompleted) {
tasksToShow.add(task)
}
}
}
return tasksToShow
}
}

fun refresh() {
_forceUpdate.value = true
Expand Down
47 changes: 24 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
buildscript {
ext.kotlinVersion = '1.5.10'
ext.navigationVersion = '2.3.5'
ext.kotlinVersion = '1.9.23'
ext.navigationVersion = '2.7.7'
ext.ktlintVersion = '0.33.0'
ext.hiltVersion = "2.36"
ext.hiltVersion = "2.51"
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.android.tools.build:gradle:8.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigationVersion"
classpath "com.google.dagger:hilt-android-gradle-plugin:$hiltVersion"
Expand Down Expand Up @@ -41,34 +41,35 @@ allprojects {
// Define versions in a single place
ext {
// Sdk and tools
minSdkVersion = 21
targetSdkVersion = 30
compileSdkVersion = 30
minSdkVersion = 24
targetSdkVersion = 34
compileSdkVersion = 34

// App dependencies
androidXVersion = '1.0.0'
androidXTestCoreVersion = '1.3.0'
androidXTestExtKotlinRunnerVersion = '1.1.2'
androidXTestRulesVersion = '1.2.0'
androidXAnnotations = '1.2.0'
androidXTestCoreVersion = '1.5.0'
androidXTestExtKotlinRunnerVersion = '1.1.5'
androidXTestRulesVersion = '1.5.0'
androidXAnnotations = '1.7.1'
androidXLegacySupport = '1.0.0'
appCompatVersion = '1.3.0'
archLifecycleVersion = '2.3.1'
archTestingVersion = '2.1.0'
appCompatVersion = '1.6.1'
archLifecycleVersion = '2.7.0'
archTestingVersion = '2.2.0'
cardVersion = '1.0.0'
coroutinesVersion = '1.5.0'
coroutinesVersion = '1.8.0'
dexMakerVersion = '2.12.1'
espressoVersion = '3.3.0'
fragmentVersion = '1.3.4'
fragmentKtxVersion = '1.3.4'
espressoVersion = '3.5.1'
fragmentVersion = '1.6.2'
fragmentKtxVersion = '1.6.2'
hamcrestVersion = '1.3'
junitVersion = '4.13.1'
materialVersion = '1.3.0'
materialVersion = '1.11.0'
multiDexVersion = '2.0.1'
recyclerViewVersion = '1.2.0'
robolectricVersion = '4.5.1'
roomVersion = '2.3.0'
recyclerViewVersion = '1.3.2'
robolectricVersion = '4.7.3'
roomVersion = '2.6.1'
rulesVersion = '1.0.1'
timberVersion = '4.7.1'
timberVersion = '5.0.1'
truthVersion = '1.1.2'
multidex = '2.0.1'
}
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Jun 01 08:01:38 UTC 2021
#Fri Apr 19 10:35:11 IST 2024
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists