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

Scope SavedStateFlowHandle to ViewModel's, create assisted injection extension functions, & add CI to run unit tests and build #11

Merged
merged 6 commits into from
Jan 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

# Builds the release artifacts of the library
- name: Release build
run: ./gradlew :savedstateflow:assembleRelease :savedstateflow-test:assembleRelease
run: ./gradlew :savedstateflow:assembleRelease :savedstateflow-hilt:assembleRelease :savedstateflow-test:assembleRelease

# Generates other artifacts (javadocJar is optional)
- name: Source jar and dokka
Expand Down
2 changes: 1 addition & 1 deletion sample/hilt-di/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ android {
}

dependencies {
implementation(project(":savedstateflow"))
implementation(project(":savedstateflow-hilt"))
implementation "androidx.core:core-ktx:$core_ktx_version"
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@ import dagger.hilt.android.components.ViewModelComponent
import dagger.hilt.android.scopes.ViewModelScoped
import dagger.hilt.components.SingletonComponent

@InstallIn(ViewModelComponent::class)
plusmobileapps marked this conversation as resolved.
Show resolved Hide resolved
@Module
object SavedStateFlowHandleModule {

@Provides
@ViewModelScoped
fun providesSavedStateFlowHandle(savedStateHandle: SavedStateHandle): SavedStateFlowHandle =
savedStateHandle.toSavedStateFlowHandle()

}

@Module
@InstallIn(SingletonComponent::class)
abstract class NewsModule {
Expand Down
1 change: 1 addition & 0 deletions savedstateflow-hilt/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
56 changes: 56 additions & 0 deletions savedstateflow-hilt/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}

ext {
PUBLISH_GROUP_ID = "$publish_group_id"
// PUBLISH_VERSION = "$publish_version"
PUBLISH_VERSION = "0.1-alpha01"
plusmobileapps marked this conversation as resolved.
Show resolved Hide resolved
PUBLISH_ARTIFACT_ID = 'saved-state-flow-hilt'
}

android {
compileSdk compile_sdk

defaultConfig {
minSdk min_sdk
targetSdk target_sdk

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}

dependencies {
api(project(':savedstateflow'))
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-compiler:$hilt_version"

implementation "androidx.appcompat:appcompat:$appcompat_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$livedata_ktx_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$viewmodel_ktx_version"

testImplementation "junit:junit:$junit_version"
testImplementation "io.mockk:mockk:$mockk_version"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"
testImplementation "app.cash.turbine:turbine:$turbine_version"
plusmobileapps marked this conversation as resolved.
Show resolved Hide resolved
}

apply from: "${rootProject.projectDir}/scripts/publish-module.gradle"
Empty file.
21 changes: 21 additions & 0 deletions savedstateflow-hilt/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
5 changes: 5 additions & 0 deletions savedstateflow-hilt/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.plusmobileapps.savedstateflow_hilt">

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.plusmobileapps.savedstateflow_hilt

import androidx.lifecycle.SavedStateHandle
import com.plusmobileapps.savedstateflow.SavedStateFlowHandle
import com.plusmobileapps.savedstateflow.toSavedStateFlowHandle
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ViewModelComponent
import dagger.hilt.android.scopes.ViewModelScoped

@InstallIn(ViewModelComponent::class)
@Module
object SavedStateFlowHandleModule {

@Provides
@ViewModelScoped
fun providesSavedStateFlowHandle(savedStateHandle: SavedStateHandle): SavedStateFlowHandle =
savedStateHandle.toSavedStateFlowHandle()

}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ include ':sample:manual-di'
include ':sample:hilt-di'
include ':savedstateflow'
include ':savedstateflow-test'
include ':savedstateflow-hilt'