Skip to content

Commit

Permalink
Removoe dynamic features (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
jraska authored May 9, 2020
1 parent 07fdc23 commit 8219aea
Show file tree
Hide file tree
Showing 44 changed files with 78 additions and 906 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Experimental architecture app with example usage intended to be a showcase, test
- Plugin based composition of features and modules contributing to collection of "plugins" - see: `OnAppCreate`, or `LinkLauncher`
- Android Architectue Components `LiveData` and `ViewModel` are used to connect Activities with app logic
- Deep Link navigation used across the app - [Article](https://proandroiddev.com/in-app-deep-link-navigation-because-deep-links-matter-17f0c91f2658)
- Dynamic features are implemented. See e.g. `:about_entrance_module`
- UI Instrumentation testing using Espresso and mocking network layer to achieve isolation [OkReplay](https://github.com/airbnb/okreplay) See `ReplayHttpComponent`
- All core services have its lightweight fake implementation. See `Fakes`
- Dependency replacement in test is done by Dagger components in `TestUITestApp`
Expand Down
8 changes: 2 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ android {
packagingOptions {
exclude 'META-INF/licenses/ASM'
}

dynamicFeatures = [":feature:about", ":feature:settings"]
}

dependencies {
Expand All @@ -85,12 +83,11 @@ dependencies {
implementation project(':navigation')
implementation project(':lib:navigation-deeplink')
implementation project(':lib:identity')
implementation project(':lib:dynamic-features')
implementation project(':lib:network-status')
implementation project(':feature:push')
implementation project(':feature:users')
implementation project(':feature:settings_entrance')
implementation project(':feature:about_entrance')
implementation project(':feature:settings')
implementation project(':feature:about')
implementation project(':feature:shortcuts')

implementation 'androidx.appcompat:appcompat:1.1.0'
Expand Down Expand Up @@ -118,7 +115,6 @@ dependencies {

implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'com.jakewharton.threetenabp:threetenabp:1.2.4'
implementation 'com.google.android.play:core:1.6.1'
implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0'

testImplementation 'com.google.code.gson:gson:2.8.6'
Expand Down
25 changes: 4 additions & 21 deletions app/src/main/java/com/jraska/github/client/AppComponent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,19 @@ package com.jraska.github.client

import android.content.Context
import androidx.lifecycle.ViewModelProvider
import com.jraska.github.client.about.entrance.AboutFeatureEntranceModule
import com.jraska.github.client.analytics.EventAnalytics
import com.jraska.github.client.about.AboutModule
import com.jraska.github.client.core.android.CoreAndroidModule
import com.jraska.github.client.core.android.OnAppCreate
import com.jraska.github.client.core.android.ServiceModel
import com.jraska.github.client.dynamicbase.DynamicFeaturesModule
import com.jraska.github.client.identity.IdentityModule
import com.jraska.github.client.identity.IdentityProvider
import com.jraska.github.client.navigation.Navigator
import com.jraska.github.client.navigation.deeplink.DeepLinkNavigationModule
import com.jraska.github.client.networkstatus.NetworkStatusModule
import com.jraska.github.client.push.PushModule
import com.jraska.github.client.settings.entrance.SettingsEntranceModule
import com.jraska.github.client.settings.SettingsModule
import com.jraska.github.client.shortcuts.ShortcutsModule
import com.jraska.github.client.users.UsersModule
import dagger.BindsInstance
import dagger.Component
import dagger.Subcomponent
import javax.inject.Singleton

@Singleton
Expand All @@ -28,14 +23,13 @@ import javax.inject.Singleton
AppModule::class,
CoreAndroidModule::class,
ChromeCustomTabsModule::class,
DynamicFeaturesModule::class,
DeepLinkNavigationModule::class,
IdentityModule::class,
NetworkStatusModule::class,
UsersModule::class,
PushModule::class,
SettingsEntranceModule::class,
AboutFeatureEntranceModule::class,
SettingsModule::class,
AboutModule::class,
ShortcutsModule::class],
dependencies = [
HasRetrofit::class,
Expand All @@ -50,8 +44,6 @@ interface AppComponent {

fun viewModelFactory(): ViewModelProvider.Factory

fun dynamicFeaturesComponent(): DynamicFeaturesComponent

@Component.Builder
interface Builder {
fun build(): AppComponent
Expand All @@ -63,12 +55,3 @@ interface AppComponent {
fun appContext(context: Context): Builder
}
}

@Subcomponent
interface DynamicFeaturesComponent {
fun navigator(): Navigator

fun identityProvider(): IdentityProvider

fun eventAnalytics(): EventAnalytics
}
13 changes: 1 addition & 12 deletions app/src/main/java/com/jraska/github/client/GitHubClientApp.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.jraska.github.client

import android.app.Application
import android.content.Context
import android.os.Looper
import androidx.lifecycle.ViewModelProvider
import com.google.android.play.core.splitcompat.SplitCompat
import com.google.firebase.perf.metrics.AddTrace
import com.jraska.github.client.core.android.HasServiceModelFactory
import com.jraska.github.client.core.android.HasViewModelFactory
Expand All @@ -16,7 +14,7 @@ import okhttp3.logging.HttpLoggingInterceptor
import timber.log.Timber
import java.io.File

open class GitHubClientApp : Application(), HasViewModelFactory, HasServiceModelFactory, HasDynamicFeaturesComponent {
open class GitHubClientApp : Application(), HasViewModelFactory, HasServiceModelFactory {

private val appComponent: AppComponent by lazy { componentBuilder().build() }

Expand All @@ -28,15 +26,6 @@ open class GitHubClientApp : Application(), HasViewModelFactory, HasServiceModel
return appComponent.serviceModelFactory()
}

override fun dynamicFeaturesComponent(): DynamicFeaturesComponent {
return appComponent.dynamicFeaturesComponent()
}

override fun attachBaseContext(base: Context) {
super.attachBaseContext(base)
SplitCompat.install(this)
}

@AddTrace(name = "App.onCreate")
override fun onCreate() {
super.onCreate()
Expand Down

This file was deleted.

11 changes: 1 addition & 10 deletions feature/about/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apply plugin: 'com.android.dynamic-feature'
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
Expand All @@ -17,16 +17,10 @@ android {

dependencies {

implementation project(':app')

implementation project(':core')
implementation project(':core-android')
implementation project(':navigation')
implementation project(':lib:identity')
implementation project(':lib:dynamic-features')

implementation 'com.google.android.play:core:1.6.1'
implementation 'com.google.android.gms:play-services-basement:17.1.1'

kapt 'com.google.dagger:dagger-compiler:2.27'
implementation 'com.google.dagger:dagger:2.27'
Expand All @@ -38,7 +32,4 @@ dependencies {
testImplementation 'androidx.arch.core:core-testing:2.1.0'
testImplementation 'org.mockito:mockito-core:3.3.3'
testImplementation project(':core-testing')

androidTestImplementation 'androidx.appcompat:appcompat:1.1.0'
androidTestImplementation 'com.google.android.gms:play-services-basement:17.1.1'
}
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
package com.jraska.github.client.about

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.GridLayoutManager
import com.airbnb.epoxy.EpoxyModel
import com.airbnb.epoxy.SimpleEpoxyAdapter
import com.google.android.play.core.splitcompat.SplitCompat
import com.jraska.github.client.DynamicFeaturesComponent
import com.jraska.github.client.core.android.BaseActivity
import com.jraska.github.client.core.android.ViewModelFactory
import com.jraska.github.client.dynamicFeaturesComponent
import dagger.Component
import com.jraska.github.client.core.android.viewModel
import kotlinx.android.synthetic.main.activity_about.toolbar
import kotlinx.android.synthetic.main.content_about.about_recycler

internal class AboutActivity : BaseActivity() {

private val viewModel: AboutViewModel by lazy {
ViewModelProvider(this, viewModelFactory()).get(AboutViewModel::class.java)
}

override fun attachBaseContext(newBase: Context?) {
super.attachBaseContext(newBase)
SplitCompat.install(this)
}
private val viewModel: AboutViewModel by lazy { viewModel(AboutViewModel::class.java) }

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -61,19 +48,4 @@ internal class AboutActivity : BaseActivity() {
inActivity.startActivity(intent)
}
}

private fun viewModelFactory(): ViewModelProvider.Factory {
return DaggerAboutComponent.builder()
.dynamicFeaturesComponent(dynamicFeaturesComponent())
.build()
.viewModelFactory()
}
}

@Component(
modules = [AboutModule::class],
dependencies = [DynamicFeaturesComponent::class]
)
internal interface AboutComponent {
fun viewModelFactory(): ViewModelFactory
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.jraska.github.client.about

import android.app.Activity
import com.jraska.github.client.core.android.LinkLauncher
import okhttp3.HttpUrl
import javax.inject.Inject

internal class AboutLinkLauncher @Inject constructor() : LinkLauncher {
override fun launch(inActivity: Activity, deepLink: HttpUrl): LinkLauncher.Result {
return if ("/about" == deepLink.encodedPath) {
AboutActivity.start(inActivity)
LinkLauncher.Result.LAUNCHED
} else {
LinkLauncher.Result.NOT_LAUNCHED
}
}

override fun priority(): LinkLauncher.Priority = LinkLauncher.Priority.EXACT_MATCH
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
package com.jraska.github.client.about

import androidx.lifecycle.ViewModel
import com.jraska.github.client.core.android.LinkLauncher
import dagger.Binds
import dagger.Module
import dagger.Provides
import dagger.multibindings.ClassKey
import dagger.multibindings.IntoMap
import dagger.multibindings.IntoSet

@Module
object AboutModule {
abstract class AboutModule {

@Provides
@Binds
@IntoMap
@ClassKey(AboutViewModel::class)
internal fun provideViewModel(viewModel: AboutViewModel): ViewModel {
return viewModel
}
internal abstract fun provideViewModel(viewModel: AboutViewModel): ViewModel

@Binds
@IntoSet
internal abstract fun provideLauncher(launcher: AboutLinkLauncher): LinkLauncher
}
1 change: 0 additions & 1 deletion feature/about_entrance/.gitignore

This file was deleted.

27 changes: 0 additions & 27 deletions feature/about_entrance/build.gradle

This file was deleted.

1 change: 0 additions & 1 deletion feature/about_entrance/src/main/AndroidManifest.xml

This file was deleted.

This file was deleted.

Loading

0 comments on commit 8219aea

Please sign in to comment.