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

Cleanup modules #135

Merged
merged 6 commits into from
Apr 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions client/src/main/java/com/jraska/github/client/AppComponent.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.jraska.github.client

import android.content.Context
import androidx.lifecycle.ViewModelProvider
import com.google.firebase.database.FirebaseDatabase
import com.jraska.github.client.analytics.AnalyticsProperty
Expand All @@ -11,22 +12,35 @@ import com.jraska.github.client.push.PushHandler
import com.jraska.github.client.push.PushModule
import com.jraska.github.client.settings.SettingsModule
import com.jraska.github.client.users.UsersModule
import dagger.BindsInstance
import dagger.Component
import dagger.Module
import dagger.Provides
import retrofit2.Retrofit

@PerApp
@Component(modules = [UsersModule::class, NavigationModule::class,
PushModule::class, AppModule::class, SettingsModule::class,
HttpComponentModule::class, CoreComponentModule::class])
@Component(
modules = [UsersModule::class, NavigationModule::class,
PushModule::class, AppModule::class, SettingsModule::class,
HttpComponentModule::class, CoreComponentModule::class]
)
interface AppComponent {

fun onAppCreateActions(): Set<OnAppCreate>

fun pushHandler(): PushHandler

fun viewModelFactory(): ViewModelProvider.Factory

@Component.Builder
interface Builder {
fun build(): AppComponent

fun coreComponentModule(module: CoreComponentModule): Builder
fun httpComponentModule(module: HttpComponentModule): Builder

@BindsInstance fun appContext(context: Context): Builder
}
}

@Module
Expand Down
21 changes: 14 additions & 7 deletions client/src/main/java/com/jraska/github/client/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,55 +22,60 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers

@Module
class AppModule(private val app: GitHubClientApp) {

@Provides internal fun provideContext(): Context {
return app
}
object AppModule {

@Provides
@JvmStatic
@PerApp internal fun topActivityProvider(): TopActivityProvider {
return TopActivityProvider()
}

@Provides
@IntoSet
@JvmStatic
fun topActivityOnCreate(setup: TopActivityProvider.OnCreateSetup): OnAppCreate {
return setup
}

@Provides
@JvmStatic
@PerApp internal fun provideLayoutInflater(context: Context): LayoutInflater {
return LayoutInflater.from(context)
}

@Provides
@JvmStatic
internal fun provideViewModelFactory(factory: ViewModelFactory): ViewModelProvider.Factory {
return factory
}

@JvmStatic
@Provides
@PerApp internal fun dateTimeProvider(): DateTimeProvider {
return RealDateTimeProvider()
}

@Provides internal fun notificationManager(): NotificationManager {
return app.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
@JvmStatic
@Provides internal fun notificationManager(context: Context): NotificationManager {
return context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
}

@JvmStatic
@Provides
@PerApp
fun schedulers(): AppSchedulers {
return AppSchedulers(AndroidSchedulers.mainThread(),
Schedulers.io(), Schedulers.computation())
}

@JvmStatic
@Provides
@IntoSet
internal fun setupLoggingOnCreate(setupLogging: SetupLogging): OnAppCreate {
return setupLogging
}

@JvmStatic
@Provides
@IntoSet
fun reportAppCreateEvent(eventAnalytics: EventAnalytics): OnAppCreate {
Expand All @@ -82,6 +87,7 @@ class AppModule(private val app: GitHubClientApp) {
}
}

@JvmStatic
@Provides
@IntoSet
fun setupFresco(): OnAppCreate {
Expand All @@ -90,6 +96,7 @@ class AppModule(private val app: GitHubClientApp) {
}
}

@JvmStatic
@Provides
@IntoSet
fun setupThreeTen(): OnAppCreate {
Expand Down
10 changes: 5 additions & 5 deletions client/src/main/java/com/jraska/github/client/FirebaseModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import timber.log.Timber
import javax.inject.Singleton

@Module
open class FirebaseModule {
class FirebaseModule {

@Provides
@Singleton internal fun firebaseAnalytics(config: Config): FirebaseEventAnalytics {
Expand All @@ -31,17 +31,17 @@ open class FirebaseModule {
return FirebaseEventAnalytics(firebaseAnalytics)
}

@Provides internal open fun eventAnalytics(analytics: FirebaseEventAnalytics): EventAnalytics {
@Provides internal fun eventAnalytics(analytics: FirebaseEventAnalytics): EventAnalytics {
return analytics
}

@Provides internal open fun analyticsProperty(analytics: FirebaseEventAnalytics): AnalyticsProperty {
@Provides internal fun analyticsProperty(analytics: FirebaseEventAnalytics): AnalyticsProperty {
return analytics
}

@Provides
@Singleton
internal open fun firebaseCrash(): CrashReporter {
internal fun firebaseCrash(): CrashReporter {
return FirebaseCrashlyticsReporter()
}

Expand All @@ -56,7 +56,7 @@ open class FirebaseModule {

@Provides
@Singleton
internal open fun firebaseDatabase(): FirebaseDatabase {
internal fun firebaseDatabase(): FirebaseDatabase {
return FirebaseDatabase.getInstance()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ open class GitHubClientApp : Application(), HasViewModelFactory, HasPushHandler
}
}

private fun componentBuilder(): DaggerAppComponent.Builder {
private fun componentBuilder(): AppComponent.Builder {
return DaggerAppComponent.builder()
.appModule(AppModule(this))
.appContext(this)
.httpComponentModule(HttpComponentModule(httpComponent()))
.coreComponentModule(CoreComponentModule(coreComponent()))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.jraska.github.client.push
import com.jraska.github.client.Config
import com.jraska.github.client.analytics.AnalyticsProperty

class ConfigAsPropertyCommand constructor(
internal class ConfigAsPropertyCommand constructor(
private val config: Config,
private val analyticsProperty: AnalyticsProperty
) : PushActionCommand {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.jraska.github.client.core.android.OnAppCreate

import javax.inject.Inject

class NotificationSetup @Inject constructor(
internal class NotificationSetup @Inject constructor(
private val notificationManager: NotificationManager,
private val context: Context
) : OnAppCreate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.app.Application
import android.os.Bundle
import androidx.lifecycle.LifecycleOwner

class PushCallbacks(private val intentObserver: PushIntentObserver) : Application.ActivityLifecycleCallbacks {
internal class PushCallbacks(private val intentObserver: PushIntentObserver) : Application.ActivityLifecycleCallbacks {

override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
if (activity is LifecycleOwner) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.jraska.github.client.push
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage

class PushHandleService : FirebaseMessagingService() {
internal class PushHandleService : FirebaseMessagingService() {
override fun onMessageReceived(remoteMessage: RemoteMessage) {
val action = RemoteMessageToActionConverter.convert(remoteMessage)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.google.firebase.messaging.RemoteMessage
import com.jraska.github.client.core.android.OnAppCreate
import javax.inject.Inject

class PushIntentObserver(private val pushHandler: PushHandler) : LifecycleObserver {
internal class PushIntentObserver(private val pushHandler: PushHandler) : LifecycleObserver {

@OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
fun onCreate(owner: LifecycleOwner) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,46 +16,46 @@ object PushModule {
@JvmStatic
@Provides
@IntoSet
fun bindObserverSetup(observerSetup: PushIntentObserver.CallbacksSetup): OnAppCreate {
internal fun bindObserverSetup(observerSetup: PushIntentObserver.CallbacksSetup): OnAppCreate {
return observerSetup
}

@Provides
@JvmStatic
@IntoSet
fun setupNotificationsOnCreate(notificationSetup: NotificationSetup): OnAppCreate {
internal fun setupNotificationsOnCreate(notificationSetup: NotificationSetup): OnAppCreate {
return notificationSetup
}

@JvmStatic
@Provides
@IntoMap
@StringKey("refresh_config")
fun refreshConfigCommand(config: Config): PushActionCommand {
internal fun refreshConfigCommand(config: Config): PushActionCommand {
return RefreshConfigCommand(config)
}

@JvmStatic
@Provides
@IntoMap
@StringKey("set_config_as_property")
fun configAsPropertyCommand(config: Config, analyticsProperty: AnalyticsProperty): PushActionCommand {
internal fun configAsPropertyCommand(config: Config, analyticsProperty: AnalyticsProperty): PushActionCommand {
return ConfigAsPropertyCommand(config, analyticsProperty)
}

@JvmStatic
@Provides
@IntoMap
@StringKey("set_analytics_property")
fun setAnalyticsProperty(analyticsProperty: AnalyticsProperty): PushActionCommand {
internal fun setAnalyticsProperty(analyticsProperty: AnalyticsProperty): PushActionCommand {
return SetAnalyticsPropertyPushCommand(analyticsProperty)
}

@JvmStatic
@Provides
@IntoMap
@StringKey("notification")
fun notificationCommand(context: Context, notificationManager: NotificationManager): PushActionCommand {
internal fun notificationCommand(context: Context, notificationManager: NotificationManager): PushActionCommand {
return ShowNotificationPushCommand(context, notificationManager)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.jraska.github.client.push

import com.jraska.github.client.Config

class RefreshConfigCommand constructor(private val config: Config) : PushActionCommand {
internal class RefreshConfigCommand constructor(private val config: Config) : PushActionCommand {
override fun execute(action: PushAction): Boolean {
config.triggerRefresh()
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.jraska.github.client.push

import com.jraska.github.client.analytics.AnalyticsProperty

class SetAnalyticsPropertyPushCommand constructor(private val analyticsProperty: AnalyticsProperty) : PushActionCommand {
internal class SetAnalyticsPropertyPushCommand constructor(private val analyticsProperty: AnalyticsProperty) : PushActionCommand {
override fun execute(action: PushAction): Boolean {
val key = action.parameters["property_key"] ?: return false
val value = action.parameters["property_value"] ?: return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.net.Uri
import androidx.core.app.NotificationCompat
import com.jraska.github.client.core.android.UriHandlerActivity

class ShowNotificationPushCommand constructor(
internal class ShowNotificationPushCommand constructor(
private val context: Context,
private val notificationManager: NotificationManager
) : PushActionCommand {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.jraska.github.client.core.android.viewModel
import kotlinx.android.synthetic.main.activity_settings.toolbar
import kotlinx.android.synthetic.main.content_settings.settings_recycler

class SettingsActivity : BaseActivity(), PurchaseReportModel.PurchaseListener {
internal class SettingsActivity : BaseActivity(), PurchaseReportModel.PurchaseListener {
private val viewModel: SettingsViewModel by lazy { viewModel(SettingsViewModel::class.java) }

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ object SettingsModule {
@Provides
@IntoMap
@ClassKey(SettingsViewModel::class)
fun provideUserDetailModel(viewModel: SettingsViewModel): ViewModel {
internal fun provideUserDetailModel(viewModel: SettingsViewModel): ViewModel {
return viewModel
}

@JvmStatic
@Provides
@IntoSet
fun consoleLoggingSetup(): OnAppCreate {
internal fun consoleLoggingSetup(): OnAppCreate {
return SetupConsoleLogging()
}

@JvmStatic
@Provides
@IntoSet
fun provideSettingsLauncher(): LinkLauncher {
internal fun provideSettingsLauncher(): LinkLauncher {
return object : LinkLauncher {
override fun launch(inActivity: Activity, deepLink: HttpUrl): LinkLauncher.Result {
return if ("/settings" == deepLink.encodedPath()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.jraska.github.client.analytics.AnalyticsEvent
import com.jraska.github.client.analytics.EventAnalytics
import javax.inject.Inject

class SettingsViewModel @Inject constructor(private val eventAnalytics: EventAnalytics) : ViewModel() {
internal class SettingsViewModel @Inject constructor(private val eventAnalytics: EventAnalytics) : ViewModel() {
fun onPurchaseSubmitted(value: String) {
val money = value.toDoubleOrNull() ?: return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.jraska.console.timber.ConsoleTree
import com.jraska.github.client.core.android.OnAppCreate
import timber.log.Timber

class SetupConsoleLogging : OnAppCreate {
internal class SetupConsoleLogging : OnAppCreate {
override fun onCreate(app: Application) {
if (BuildConfig.DEBUG) {
Timber.plant(ConsoleTree.create())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ import com.jraska.github.client.Navigator
import com.jraska.github.client.Urls
import com.jraska.github.client.analytics.AnalyticsEvent
import com.jraska.github.client.analytics.EventAnalytics
import com.jraska.github.client.rx.AppSchedulers
import com.jraska.github.client.core.android.rx.RxLiveData
import com.jraska.github.client.rx.AppSchedulers
import com.jraska.github.client.users.model.RepoHeader
import com.jraska.github.client.users.model.UserDetail
import com.jraska.github.client.users.model.UsersRepository

class UserDetailViewModel internal constructor(
internal class UserDetailViewModel internal constructor(
private val usersRepository: UsersRepository,
private val schedulers: AppSchedulers,
private val navigator: Navigator,
Expand Down

This file was deleted.

Loading