Skip to content
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
3 changes: 1 addition & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

91 changes: 52 additions & 39 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,33 @@ apply plugin: 'kotlin-android'

apply plugin: 'kotlin-kapt'

apply plugin: 'kotlin-android-extensions'

Comment on lines -7 to -8
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why you remove this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that Kotlin extensions are deprecated and replaced with ViewBinding. @hrodrick I'm right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kotlin extension are deprecated. We should use view binding and @parcelize. Good update!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Kotlin extensions are deprecated and kotlin synthetics is replaced by View & Data binding

apply plugin: 'dagger.hilt.android.plugin'

apply plugin: 'com.google.gms.google-services'

apply plugin: 'com.google.firebase.crashlytics'

android {
compileSdkVersion 29
dataBinding.enabled = true
compileSdkVersion 31
defaultConfig {
applicationId "com.rootstrap.android"
minSdkVersion 23
targetSdkVersion 29
targetSdkVersion 31
versionCode 42
versionName "1.0"
testInstrumentationRunner 'com.rootstrap.android.CustomTestRunner'
}

viewBinding {
enabled = true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

buildFeatures {
viewBinding true
dataBinding true
}

kotlinOptions {
jvmTarget = '1.8'
}
Expand All @@ -58,6 +56,10 @@ android {
}
}

kapt {
correctErrorTypes true
}

flavorDimensions "server"

productFlavors {
Expand Down Expand Up @@ -137,63 +139,74 @@ android {
}

dependencies {
def room_version = "2.3.0"
def lifecycle_version = "2.4.0"

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation "androidx.preference:preference-ktx:1.1.1"
implementation 'com.google.android.material:material:1.2.1'
implementation 'com.google.android.material:material:1.4.0'
testImplementation 'junit:junit:4.13.1'
testImplementation 'org.mockito:mockito-core:2.28.2'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
androidTestImplementation 'androidx.test:rules:1.3.0'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestImplementation 'com.squareup.okhttp3:mockwebserver:4.3.1'
//---- ANDROID ARCH ROOM ----
implementation 'android.arch.persistence.room:runtime:1.1.1'
kapt "android.arch.persistence.room:compiler:1.1.1"
//---- ANDROID ARCH LIFECYCLE ----
implementation 'android.arch.lifecycle:common-java8:1.1.1'
kapt "android.arch.lifecycle:compiler:1.1.1"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0"

//---- ROOM ----
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
// Kotlin Extensions and Coroutines support for Room
implementation "androidx.room:room-ktx:$room_version"

//---- LIFECYCLE ----]
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"

//---- GOOGLE JSON SERIALIZER/DESERIALIZER ----
implementation 'com.google.code.gson:gson:2.8.6'

//---- MixPanel ----
implementation 'com.mixpanel.android:mixpanel-android:5.6.1'

//---- Firebase ----
implementation platform('com.google.firebase:firebase-bom:26.1.0')
implementation 'com.google.firebase:firebase-core:18.0.2'
implementation platform('com.google.firebase:firebase-bom:28.4.2')
implementation 'com.google.firebase:firebase-core:20.0.0'
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-crashlytics-ktx'
implementation 'org.jetbrains.kotlin:kotlin-reflect:1.4.10'
implementation 'org.jetbrains.kotlin:kotlin-reflect:1.5.31'

//---- Image ----
implementation group: 'com.github.bumptech.glide', name: 'glide', version: '4.10.0'

//---- Network ----
implementation 'com.squareup.retrofit2:retrofit:2.6.2'
implementation 'com.squareup.moshi:moshi-kotlin:1.9.2'
implementation 'com.squareup.moshi:moshi-kotlin:1.12.0'
implementation 'com.squareup.retrofit2:converter-moshi:2.5.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.3.1'

//---- Events ----
implementation 'com.squareup:otto:1.3.8'

//---- Linters ----
ktlint "com.pinterest:ktlint:0.35.0"

//---- Hilt ----
implementation "com.google.dagger:hilt-android:2.28-alpha"
implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02'
kapt "com.google.dagger:hilt-android-compiler:2.28-alpha"
kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha02'
androidTestImplementation 'com.google.dagger:hilt-android-testing:2.28-alpha'
kaptAndroidTest 'com.google.dagger:hilt-android-compiler:2.28-alpha'
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
kapt 'androidx.hilt:hilt-compiler:1.0.0'
androidTestImplementation "com.google.dagger:hilt-android-testing:$hilt_version"
kaptAndroidTest "com.google.dagger:hilt-android-compiler:$hilt_version"

//security crypto
implementation "androidx.security:security-crypto:1.1.0-alpha03"
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 @@ -17,7 +17,8 @@

<activity
android:name=".ui.activity.main.SignUpActivity"
android:screenOrientation="portrait">
android:screenOrientation="portrait"
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 @@ -7,11 +7,11 @@ import com.rootstrap.android.network.managers.user.UserManagerImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ApplicationComponent
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(ApplicationComponent::class)
@InstallIn(SingletonComponent::class)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please explain this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ApplicationComponent was renamed to SingletonComponent to allow the usage of Hilt in non-Android modules. You can check this release notes for further information : https://github.com/google/dagger/releases/tag/dagger-2.28.2

abstract class ManagerModule {

@Binds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import com.squareup.moshi.Moshi
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ApplicationComponent
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import dagger.hilt.components.SingletonComponent
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
import javax.inject.Singleton

@Module
@InstallIn(ApplicationComponent::class)
@InstallIn(SingletonComponent::class)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ApplicationComponent was renamed to SingletonComponent to allow the usage of Hilt in non-Android modules. You can check this release notes for further information : https://github.com/google/dagger/releases/tag/dagger-2.28.2

class ServiceProviderModule {

@Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package com.rootstrap.android.network.services
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ApplicationComponent
import dagger.hilt.components.SingletonComponent
import retrofit2.Retrofit

@Module
@InstallIn(ApplicationComponent::class)
@InstallIn(SingletonComponent::class)
class ApiModule {

@Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.os.Bundle
import androidx.activity.viewModels
import androidx.lifecycle.Observer
import com.rootstrap.android.R
import com.rootstrap.android.databinding.ActivityProfileBinding
import com.rootstrap.android.metrics.Analytics
import com.rootstrap.android.metrics.PageEvents
import com.rootstrap.android.metrics.VISIT_PROFILE
Expand All @@ -12,7 +13,6 @@ import com.rootstrap.android.ui.base.BaseActivity
import com.rootstrap.android.ui.view.ProfileView
import com.rootstrap.android.util.NetworkState
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.android.synthetic.main.activity_profile.*
import javax.inject.Inject

@AndroidEntryPoint
Expand All @@ -21,15 +21,18 @@ class ProfileActivity : BaseActivity(), ProfileView {
@Inject lateinit var sessionManager: SessionManager

private val viewModel: ProfileActivityViewModel by viewModels()
private val binding by lazy { ActivityProfileBinding.inflate(layoutInflater) }

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_profile)

Analytics.track(PageEvents.visit(VISIT_PROFILE))

welcome_text_view.text = getString(R.string.welcome_message, sessionManager.user?.firstName)
sign_out_button.setOnClickListener { viewModel.signOut() }
with(binding) {
setContentView(root)
welcomeTextView.text = getString(R.string.welcome_message, sessionManager.user?.firstName)
signOutButton.setOnClickListener { viewModel.signOut() }
}

lifecycle.addObserver(viewModel)
setObservers()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.rootstrap.android.ui.activity.main

import androidx.hilt.lifecycle.ViewModelInject
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
Expand All @@ -10,9 +9,12 @@ import com.rootstrap.android.ui.base.BaseViewModel
import com.rootstrap.android.util.NetworkState
import com.rootstrap.android.util.extensions.ApiErrorType
import com.rootstrap.android.util.extensions.ApiException
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

open class ProfileActivityViewModel @ViewModelInject constructor(
@HiltViewModel
open class ProfileActivityViewModel @Inject constructor(
private val sessionManager: SessionManager,
private val userManager: UserManager
) : BaseViewModel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ import dagger.hilt.android.AndroidEntryPoint
class SignInActivity : PermissionActivity(), AuthView {

private val viewModel: SignInActivityViewModel by viewModels()
private lateinit var binding: ActivitySignInBinding
private val binding: ActivitySignInBinding by lazy {
ActivitySignInBinding.inflate(layoutInflater)
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivitySignInBinding.inflate(layoutInflater)

setContentView(binding.root)
Analytics.track(PageEvents.visit(VISIT_SIGN_IN))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.rootstrap.android.ui.activity.main

import androidx.hilt.lifecycle.ViewModelInject
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
Expand All @@ -11,9 +10,12 @@ import com.rootstrap.android.ui.base.BaseViewModel
import com.rootstrap.android.util.NetworkState
import com.rootstrap.android.util.extensions.ApiErrorType
import com.rootstrap.android.util.extensions.ApiException
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

open class SignInActivityViewModel @ViewModelInject constructor(
@HiltViewModel
open class SignInActivityViewModel @Inject constructor(
private val sessionManager: SessionManager,
private val userManager: UserManager
) : BaseViewModel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import dagger.hilt.android.AndroidEntryPoint
class SignUpActivity : BaseActivity(), AuthView {

private val viewModel: SignUpActivityViewModel by viewModels()
private lateinit var binding: ActivitySignUpBinding
private val binding: ActivitySignUpBinding by lazy {
ActivitySignUpBinding.inflate(layoutInflater)
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivitySignUpBinding.inflate(layoutInflater)

setContentView(binding.root)
Analytics.track(PageEvents.visit(VISIT_SIGN_UP))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.rootstrap.android.ui.activity.main

import androidx.hilt.lifecycle.ViewModelInject
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
Expand All @@ -11,9 +10,12 @@ import com.rootstrap.android.ui.base.BaseViewModel
import com.rootstrap.android.util.NetworkState
import com.rootstrap.android.util.extensions.ApiErrorType
import com.rootstrap.android.util.extensions.ApiException
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

open class SignUpActivityViewModel @ViewModelInject constructor(
@HiltViewModel
open class SignUpActivityViewModel @Inject constructor(
private val sessionManager: SessionManager,
private val userManager: UserManager
) : BaseViewModel() {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/rootstrap/android/util/UtilModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import com.squareup.otto.Bus
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 javax.inject.Singleton

@Module
@InstallIn(ApplicationComponent::class)
@InstallIn(SingletonComponent::class)
class UtilModule {

@Provides
Expand Down
Loading