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/upgrade kotlin version #1709

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 8 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-parcelize'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.firebase.appdistribution'
apply plugin: "com.github.triplet.play"
Expand Down Expand Up @@ -158,6 +158,12 @@ android {
packagingOptions {
resources.excludes.add("META-INF/versions/9/previous-compilation-data.bin")
resources.excludes.add("META-INF/DEPENDENCIES")
resources.excludes.add("META-INF/NOTICE.md")
}


buildFeatures {
viewBinding true
}
}

Expand Down Expand Up @@ -264,6 +270,7 @@ dependencies {

implementation biometricDep


implementation androidDep
implementation constraintDep

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.novafoundation.nova.app.root.navigation.delayedNavigation

import io.novafoundation.nova.common.navigation.DelayedNavigation
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize

@Parcelize
object BackDelayedNavigation : DelayedNavigation
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package io.novafoundation.nova.app.root.navigation.delayedNavigation

import android.os.Bundle
import io.novafoundation.nova.common.navigation.DelayedNavigation
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize

@Parcelize
class NavComponentDelayedNavigation(val globalActionId: Int, val extras: Bundle? = null) : DelayedNavigation
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package io.novafoundation.nova.app.root.presentation

import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import androidx.navigation.NavController
import androidx.navigation.fragment.NavHostFragment

import io.novafoundation.nova.app.R
import io.novafoundation.nova.app.databinding.ActivityRootBinding
import io.novafoundation.nova.app.root.di.RootApi
import io.novafoundation.nova.app.root.di.RootComponent
import io.novafoundation.nova.app.root.navigation.NavigationHolder
Expand All @@ -18,10 +21,10 @@ import io.novafoundation.nova.common.utils.systemCall.SystemCallExecutor
import io.novafoundation.nova.common.utils.updatePadding
import io.novafoundation.nova.common.view.bottomSheet.action.observeActionBottomSheet
import io.novafoundation.nova.splash.presentation.SplashBackgroundHolder
import kotlinx.android.synthetic.main.activity_root.rootNetworkBar

import javax.inject.Inject

class RootActivity : BaseActivity<RootViewModel>(), SplashBackgroundHolder {
class RootActivity : BaseActivity<RootViewModel, ActivityRootBinding>(), SplashBackgroundHolder {

@Inject
lateinit var navigationHolder: NavigationHolder
Expand All @@ -32,6 +35,10 @@ class RootActivity : BaseActivity<RootViewModel>(), SplashBackgroundHolder {
@Inject
lateinit var contextManager: ContextManager

override fun createBinding(): ActivityRootBinding {
return ActivityRootBinding.inflate(LayoutInflater.from(this))
}

override fun inject() {
FeatureUtils.getFeature<RootComponent>(this, RootApi::class.java)
.mainActivityComponentFactory()
Expand All @@ -58,7 +65,7 @@ class RootActivity : BaseActivity<RootViewModel>(), SplashBackgroundHolder {
navigationHolder.attach(navController)
contextManager.attachActivity(this)

rootNetworkBar.setOnApplyWindowInsetsListener { view, insets ->
binder.rootNetworkBar.setOnApplyWindowInsetsListener { view, insets ->
view.updatePadding(top = insets.systemWindowInsetTop)

insets
Expand All @@ -77,10 +84,6 @@ class RootActivity : BaseActivity<RootViewModel>(), SplashBackgroundHolder {
navigationHolder.detach()
}

override fun layoutResource(): Int {
return R.layout.activity_root
}

override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)

Expand All @@ -106,7 +109,7 @@ class RootActivity : BaseActivity<RootViewModel>(), SplashBackgroundHolder {
observeActionBottomSheet(viewModel)

viewModel.showConnectingBarLiveData.observe(this) { show ->
rootNetworkBar.setVisible(show)
binder.rootNetworkBar.setVisible(show)
}

viewModel.messageLiveData.observe(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package io.novafoundation.nova.app.root.presentation.main

import android.graphics.RectF
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.activity.OnBackPressedCallback
import androidx.navigation.NavController
import androidx.navigation.NavDestination
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController

import io.novafoundation.nova.app.R
import io.novafoundation.nova.app.databinding.FragmentMainBinding
import io.novafoundation.nova.app.root.di.RootApi
import io.novafoundation.nova.app.root.di.RootComponent
import io.novafoundation.nova.app.root.navigation.staking.StakingDashboardNavigator
Expand All @@ -19,11 +17,12 @@ import io.novafoundation.nova.common.di.FeatureUtils
import io.novafoundation.nova.common.utils.blur.SweetBlur
import io.novafoundation.nova.common.utils.setBackgroundColorRes
import io.novafoundation.nova.common.utils.updatePadding
import kotlinx.android.synthetic.main.fragment_main.bottomNavHost
import kotlinx.android.synthetic.main.fragment_main.bottomNavigationView

import javax.inject.Inject

class MainFragment : BaseFragment<MainViewModel>() {
class MainFragment : BaseFragment<MainViewModel, FragmentMainBinding>() {

override fun createBinding() = FragmentMainBinding.inflate(layoutInflater)

@Inject
lateinit var stakingDashboardNavigator: StakingDashboardNavigator
Expand All @@ -36,10 +35,6 @@ class MainFragment : BaseFragment<MainViewModel>() {
}
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_main, container, false)
}

override fun onDestroyView() {
super.onDestroyView()

Expand All @@ -48,17 +43,17 @@ class MainFragment : BaseFragment<MainViewModel>() {
}

override fun initViews() {
bottomNavigationView.setOnApplyWindowInsetsListener { _, insets ->
binder.bottomNavigationView.setOnApplyWindowInsetsListener { _, insets ->
// overwrite BottomNavigation behavior and ignore insets
insets
}

bottomNavHost.setOnApplyWindowInsetsListener { v, insets ->
binder.bottomNavHost.setOnApplyWindowInsetsListener { v, insets ->
val systemWindowInsetBottom = insets.systemWindowInsetBottom

// post to prevent bottomNavigationView.height being 0 if callback is called before view has been measured
v.post {
val padding = (systemWindowInsetBottom - bottomNavigationView.height).coerceAtLeast(0)
val padding = (systemWindowInsetBottom - binder.bottomNavigationView.height).coerceAtLeast(0)
v.updatePadding(bottom = padding)
}

Expand All @@ -70,8 +65,8 @@ class MainFragment : BaseFragment<MainViewModel>() {
navController = nestedNavHostFragment.navController
stakingDashboardNavigator.setStakingTabNavController(navController!!)

bottomNavigationView.setupWithNavController(navController!!)
bottomNavigationView.itemIconTintList = null
binder.bottomNavigationView.setupWithNavController(navController!!)
binder.bottomNavigationView.itemIconTintList = null

requireActivity().onBackPressedDispatcher.addCallback(backCallback)

Expand Down Expand Up @@ -102,9 +97,9 @@ class MainFragment : BaseFragment<MainViewModel>() {
.captureExtraSpace(RectF(0f, offset, 0f, 0f))
.cutSpace(RectF(0f, offset, 0f, offset))
.radius(radiusInPx)
.captureFrom(bottomNavHost)
.toTarget(bottomNavigationView)
.catchException { bottomNavigationView.setBackgroundColorRes(R.color.solid_navigation_background) }
.captureFrom(binder.bottomNavHost)
.toTarget(binder.bottomNavigationView)
.catchException { binder.bottomNavigationView.setBackgroundColorRes(R.color.solid_navigation_background) }
.build()
// .start()
}
Expand Down
9 changes: 5 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ buildscript {
minSdkVersion = 24
targetSdkVersion = 34

kotlinVersion = '1.7.21'
kotlinVersion = '1.9.22'

ktlintPinterestVersion = '0.47.0'

Expand All @@ -21,13 +21,13 @@ buildscript {
cardViewVersion = '1.0.0'
constraintVersion = '1.1.3'

coroutinesVersion = '1.6.3'
coroutinesVersion = '1.8.1'

biometricVersion = '1.0.1'

progressButtonsVersion = '2.1.0'

daggerVersion = '2.44.2'
daggerVersion = '2.52'
javaxInjectVersion = '1'

architectureComponentVersion = '2.2.0'
Expand Down Expand Up @@ -79,7 +79,7 @@ buildscript {

bleVersion = '2.5.1'

roomVersion = '2.4.3'
roomVersion = '2.6.1'

markwonVersion = '4.6.2'

Expand Down Expand Up @@ -123,6 +123,7 @@ buildscript {

lifecycleDep = "androidx.lifecycle:lifecycle-extensions:$architectureComponentVersion"
lifecycleKapt = "androidx.lifecycle:lifecycle-compiler:$architectureComponentVersion"
lifecycleRuntime = "androidx.lifecycle:lifecycle-runtime-android:$architectureComponentVersion"

coroutinesDep = "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion"
coroutinesAndroidDep = "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
Expand Down
8 changes: 7 additions & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-parcelize'

android {
compileSdkVersion rootProject.compileSdkVersion
Expand Down Expand Up @@ -66,6 +66,10 @@ android {
jvmTarget = '1.8'
freeCompilerArgs = ["-Xcontext-receivers"]
}

buildFeatures {
viewBinding true
}
}

dependencies {
Expand All @@ -77,6 +81,7 @@ dependencies {

implementation kotlinDep


implementation androidDep
implementation cardViewDep
implementation recyclerViewDep
Expand Down Expand Up @@ -141,4 +146,5 @@ dependencies {
implementation kotlinReflect

implementation playServicesAuthDep

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.LifecycleOwner
import androidx.viewbinding.ViewBinding
import io.novafoundation.nova.common.di.FeatureContainer
import io.novafoundation.nova.common.utils.showToast
import javax.inject.Inject

abstract class BaseActivity<T : BaseViewModel> :
abstract class BaseActivity<T : BaseViewModel, B : ViewBinding> :
AppCompatActivity(), BaseScreenMixin<T> {

override val providedContext: Context
Expand All @@ -18,9 +19,14 @@ abstract class BaseActivity<T : BaseViewModel> :
override val lifecycleOwner: LifecycleOwner
get() = this

protected lateinit var binder: B
private set

@Inject
override lateinit var viewModel: T

protected abstract fun createBinding(): B

override fun attachBaseContext(base: Context) {
val commonApi = (base.applicationContext as FeatureContainer).commonApi()
val contextManager = commonApi.contextManager()
Expand All @@ -37,7 +43,9 @@ abstract class BaseActivity<T : BaseViewModel> :
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
)

setContentView(layoutResource())
binder = createBinding()

setContentView(binder.root)

inject()
initViews()
Expand All @@ -50,7 +58,5 @@ abstract class BaseActivity<T : BaseViewModel> :
viewModel.toastLiveData.observeEvent { showToast(it) }
}

abstract fun layoutResource(): Int

abstract fun changeLanguage()
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
package io.novafoundation.nova.common.base

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.viewbinding.ViewBinding
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import javax.inject.Inject

abstract class BaseBottomSheetFragment<T : BaseViewModel> : BottomSheetDialogFragment(), BaseFragmentMixin<T> {
abstract class BaseBottomSheetFragment<T : BaseViewModel, B : ViewBinding> : BottomSheetDialogFragment(), BaseFragmentMixin<T> {

@Inject override lateinit var viewModel: T
@Inject
override lateinit var viewModel: T

protected lateinit var binder: B
private set

override val fragment: Fragment
get() = this

private val delegate by lazy(LazyThreadSafetyMode.NONE) { BaseFragmentDelegate(this) }

protected abstract fun createBinding(): B

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binder = createBinding()
return binder.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

Expand Down
Loading
Loading