Skip to content

Commit 2f9935b

Browse files
committed
ref: move to kotlin 2.0
1 parent afb584d commit 2f9935b

22 files changed

+437
-589
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ build
3939
*.ipr
4040
*~
4141
*.swp
42+
43+
# Kotlin Compilation
44+
.kotlin/

app/build.gradle.kts

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
@file:Suppress("UnstableApiUsage")
22

3+
import org.jetbrains.kotlin.config.JvmTarget
4+
5+
36
class AppConfig {
47
val id = "com.fernandocejas.sample"
58
val versionCode = 1
@@ -16,7 +19,8 @@ class AppConfig {
1619
plugins {
1720
alias(libs.plugins.android.application)
1821
alias(libs.plugins.kotlin.android)
19-
alias(libs.plugins.kotlin.kapt)
22+
// alias(libs.plugins.kotlin.compose.compiler)
23+
alias(libs.plugins.kotlin.kasp)
2024
alias(libs.plugins.kotlin.parcelize)
2125
}
2226

@@ -43,13 +47,9 @@ android {
4347
targetCompatibility = appConfig.javaVersion
4448
}
4549

46-
kotlinOptions {
47-
jvmTarget = appConfig.javaVersion.toString()
48-
}
49-
50-
buildFeatures {
51-
viewBinding = true
52-
}
50+
// composeCompiler {
51+
// enableStrongSkippingMode = true
52+
// }
5353

5454
buildTypes {
5555
getByName("debug") {
@@ -63,34 +63,26 @@ android {
6363

6464
// https://kotlinlang.org/docs/gradle-configure-project.html#gradle-java-toolchains-support
6565
kotlin {
66-
jvmToolchain(appConfig.javaVersion.toString().toInt())
67-
}
68-
69-
kapt {
70-
correctErrorTypes = true
66+
// jvmToolchain(appConfig.javaVersion.toString().toInt())
67+
compilerOptions {
68+
// jvmTarget.set(JvmTarget.JVM_17)
69+
}
7170
}
7271

7372
dependencies {
7473
//Compile time dependencies
75-
kapt(libs.androidx.lifecycle.compiler)
74+
// implementation(libs.kotlin.compose.compiler.plugin.embeddable)
75+
// implementation(libs.kotlin.compose.compiler.plugin)
7676

7777
// Application dependencies
7878
implementation(libs.kotlin.stdlib.jdk8)
7979
implementation(libs.kotlinx.coroutines.core)
8080
implementation(libs.kotlinx.coroutines.android)
8181
implementation(libs.koin.android)
8282
implementation(libs.android.appcompat)
83-
implementation(libs.android.core.ktx)
84-
implementation(libs.androidx.fragment.ktx)
85-
implementation(libs.androidx.constraintlayout)
86-
implementation(libs.androidx.lifecycle.viewmodel.ktx)
87-
implementation(libs.androidx.lifecycle.livedata.ktx)
88-
implementation(libs.androidx.lifecycle.extensions)
89-
implementation(libs.androidx.cardview)
90-
implementation(libs.androidx.recyclerview)
9183
implementation(libs.material)
9284
implementation(libs.androidx.annotation)
93-
implementation(libs.glide)
85+
// implementation(libs.glide)
9486
implementation(libs.converter.gson)
9587

9688
// Unit/Integration tests dependencies

app/src/main/kotlin/com/fernandocejas/sample/core/extension/Fragment.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ import android.content.Context
1919
import android.view.View
2020
import androidx.fragment.app.FragmentManager
2121
import androidx.fragment.app.FragmentTransaction
22-
import com.fernandocejas.sample.core.platform.DeprecatedBaseActivity
23-
import com.fernandocejas.sample.core.platform.DeprecatedBaseFragment
22+
import com.fernandocejas.sample.core.platform.BaseActivity
23+
import com.fernandocejas.sample.core.platform.BaseFragment
2424

2525
inline fun FragmentManager.inTransaction(func: FragmentTransaction.() -> FragmentTransaction) =
2626
beginTransaction().func().commit()
2727

28-
fun DeprecatedBaseFragment.close() = fragmentManager?.popBackStack()
28+
fun BaseFragment.close() = fragmentManager?.popBackStack()
2929

30-
val DeprecatedBaseFragment.viewContainer: View get() = (activity as DeprecatedBaseActivity).fragmentContainer()
30+
//val BaseFragment.viewContainer: View get() = (activity as BaseActivity).fragmentContainer()
3131

32-
val DeprecatedBaseFragment.appContext: Context get() = activity?.applicationContext!!
32+
val BaseFragment.appContext: Context get() = activity?.applicationContext!!

app/src/main/kotlin/com/fernandocejas/sample/core/extension/View.kt

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ import android.view.ViewGroup
2222
import android.widget.ImageView
2323
import androidx.annotation.LayoutRes
2424
import androidx.fragment.app.FragmentActivity
25-
import com.bumptech.glide.Glide
26-
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
27-
import com.bumptech.glide.request.target.BaseTarget
28-
import com.bumptech.glide.request.target.SizeReadyCallback
29-
import com.bumptech.glide.request.target.Target
30-
import com.bumptech.glide.request.transition.Transition
25+
//import com.bumptech.glide.Glide
26+
//import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
27+
//import com.bumptech.glide.request.target.BaseTarget
28+
//import com.bumptech.glide.request.target.SizeReadyCallback
29+
//import com.bumptech.glide.request.target.Target
30+
//import com.bumptech.glide.request.transition.Transition
3131

3232
fun View.cancelTransition() {
3333
transitionName = null
@@ -46,33 +46,33 @@ fun View.invisible() {
4646
fun ViewGroup.inflate(@LayoutRes layoutRes: Int): View =
4747
LayoutInflater.from(context).inflate(layoutRes, this, false)
4848

49-
fun ImageView.loadFromUrl(url: String) =
50-
Glide.with(this.context.applicationContext)
51-
.load(url)
52-
.transition(DrawableTransitionOptions.withCrossFade())
53-
.into(this)
54-
55-
fun ImageView.loadUrlAndPostponeEnterTransition(url: String, activity: FragmentActivity) {
56-
val target: Target<Drawable> = ImageViewBaseTarget(this, activity)
57-
Glide.with(context.applicationContext).load(url).into(target)
58-
}
59-
60-
private class ImageViewBaseTarget(var imageView: ImageView?, var activity: FragmentActivity?) :
61-
BaseTarget<Drawable>() {
62-
override fun onLoadFailed(errorDrawable: Drawable?) {
63-
super.onLoadFailed(errorDrawable)
64-
activity?.supportStartPostponedEnterTransition()
65-
}
66-
67-
override fun getSize(cb: SizeReadyCallback) = cb.onSizeReady(SIZE_ORIGINAL, SIZE_ORIGINAL)
68-
69-
override fun removeCallback(cb: SizeReadyCallback) {
70-
imageView = null
71-
activity = null
72-
}
73-
74-
override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>?) {
75-
imageView?.setImageDrawable(resource)
76-
activity?.supportStartPostponedEnterTransition()
77-
}
78-
}
49+
//fun ImageView.loadFromUrl(url: String) =
50+
// Glide.with(this.context.applicationContext)
51+
// .load(url)
52+
// .transition(DrawableTransitionOptions.withCrossFade())
53+
// .into(this)
54+
//
55+
//fun ImageView.loadUrlAndPostponeEnterTransition(url: String, activity: FragmentActivity) {
56+
// val target: Target<Drawable> = ImageViewBaseTarget(this, activity)
57+
// Glide.with(context.applicationContext).load(url).into(target)
58+
//}
59+
//
60+
//private class ImageViewBaseTarget(var imageView: ImageView?, var activity: FragmentActivity?) :
61+
// BaseTarget<Drawable>() {
62+
// override fun onLoadFailed(errorDrawable: Drawable?) {
63+
// super.onLoadFailed(errorDrawable)
64+
// activity?.supportStartPostponedEnterTransition()
65+
// }
66+
//
67+
// override fun getSize(cb: SizeReadyCallback) = cb.onSizeReady(SIZE_ORIGINAL, SIZE_ORIGINAL)
68+
//
69+
// override fun removeCallback(cb: SizeReadyCallback) {
70+
// imageView = null
71+
// activity = null
72+
// }
73+
//
74+
// override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>?) {
75+
// imageView?.setImageDrawable(resource)
76+
// activity?.supportStartPostponedEnterTransition()
77+
// }
78+
//}

app/src/main/kotlin/com/fernandocejas/sample/core/navigation/Navigator.kt

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,36 @@ import android.content.Context
2020
import android.content.Intent
2121
import android.net.Uri
2222
import android.view.View
23-
import android.widget.ImageView
24-
import androidx.core.app.ActivityOptionsCompat
2523
import androidx.fragment.app.FragmentActivity
2624
import com.fernandocejas.sample.core.extension.emptyString
2725
import com.fernandocejas.sample.features.auth.credentials.Authenticator
28-
import com.fernandocejas.sample.features.login.ui.LoginActivity
29-
import com.fernandocejas.sample.features.movies.ui.MovieDetailsActivity
3026
import com.fernandocejas.sample.features.movies.ui.MovieView
3127
import com.fernandocejas.sample.features.movies.ui.MoviesActivity
3228

3329

3430
class Navigator(private val authenticator: Authenticator) {
3531

36-
private fun showLogin(context: Context) =
37-
context.startActivity(LoginActivity.callingIntent(context))
32+
// private fun showLogin(context: Context) =
33+
// context.startActivity(LoginActivity.callingIntent(context))
3834

3935
fun showMain(context: Context) {
40-
when (authenticator.userLoggedIn()) {
41-
true -> showMovies(context)
42-
false -> showLogin(context)
43-
}
36+
// TODO()
37+
showMovies(context)
38+
// when (authenticator.userLoggedIn()) {
39+
// true -> showMovies(context)
40+
// false -> showLogin(context)
41+
// }
4442
}
4543

4644
private fun showMovies(context: Context) =
4745
context.startActivity(MoviesActivity.callingIntent(context))
4846

4947
fun showMovieDetails(activity: FragmentActivity, movie: MovieView, navigationExtras: Extras) {
50-
val intent = MovieDetailsActivity.callingIntent(activity, movie)
51-
val sharedView = navigationExtras.transitionSharedElement as ImageView
52-
val activityOptions = ActivityOptionsCompat
53-
.makeSceneTransitionAnimation(activity, sharedView, sharedView.transitionName)
54-
activity.startActivity(intent, activityOptions.toBundle())
48+
// val intent = MovieDetailsActivity.callingIntent(activity, movie)
49+
// val sharedView = navigationExtras.transitionSharedElement as ImageView
50+
// val activityOptions = ActivityOptionsCompat
51+
// .makeSceneTransitionAnimation(activity, sharedView, sharedView.transitionName)
52+
// activity.startActivity(intent, activityOptions.toBundle())
5553
}
5654

5755
private val videoUrlHttp = "http://www.youtube.com/watch?v="
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* Copyright (C) 2020 Fernando Cejas Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.fernandocejas.sample.core.platform
17+
18+
import androidx.appcompat.app.AppCompatActivity
19+
20+
/**
21+
* Base Activity class with helper methods for handling fragment transactions and back button
22+
* events.
23+
*
24+
* @see AppCompatActivity
25+
*/
26+
abstract class BaseActivity : AppCompatActivity() {
27+
28+
// private lateinit var binding: ActivityLayoutBinding
29+
//
30+
// override fun onCreate(savedInstanceState: Bundle?) {
31+
// super.onCreate(savedInstanceState)
32+
//
33+
// binding = ActivityLayoutBinding.inflate(layoutInflater)
34+
//
35+
// setContentView(binding.root)
36+
// setSupportActionBar(binding.toolBarContainer.toolbar)
37+
// addFragment(savedInstanceState)
38+
// }
39+
//
40+
// @Deprecated("Deprecated in Java")
41+
// override fun onBackPressed() {
42+
// (supportFragmentManager.findFragmentById(binding.fragmentContainer.id) as BaseFragment).onBackPressed()
43+
// super.onBackPressed()
44+
// }
45+
//
46+
// fun toolbar() = binding.toolBarContainer.toolbar
47+
//
48+
// fun fragmentContainer() = binding.fragmentContainer
49+
// fun progressBar() = binding.toolBarContainer.progress
50+
//
51+
// private fun addFragment(savedInstanceState: Bundle?) =
52+
// savedInstanceState ?: supportFragmentManager.inTransaction {
53+
// add(binding.fragmentContainer.id, fragment())
54+
// }
55+
56+
// abstract fun fragment(): BaseFragment
57+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* Copyright (C) 2020 Fernando Cejas Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.fernandocejas.sample.core.platform
17+
18+
import androidx.fragment.app.Fragment
19+
20+
/**
21+
* Base Fragment class with helper methods for handling views and back button events.
22+
*
23+
* @see Fragment
24+
*/
25+
abstract class BaseFragment : Fragment() {
26+
27+
// open fun onBackPressed() {}
28+
//
29+
// internal fun firstTimeCreated(savedInstanceState: Bundle?) = savedInstanceState == null
30+
//
31+
// internal fun showProgress() = progressStatus(View.VISIBLE)
32+
//
33+
// internal fun hideProgress() = progressStatus(View.GONE)
34+
//
35+
// private fun progressStatus(viewStatus: Int) =
36+
// with(activity) { if (this is BaseActivity) this.progressBar().visibility = viewStatus }
37+
//
38+
// internal fun notify(@StringRes message: Int) =
39+
// Snackbar.make(viewContainer, message, Snackbar.LENGTH_SHORT).show()
40+
//
41+
// internal fun notifyWithAction(
42+
// @StringRes message: Int,
43+
// @StringRes actionText: Int,
44+
// action: () -> Any
45+
// ) {
46+
// val snackBar = Snackbar.make(viewContainer, message, Snackbar.LENGTH_INDEFINITE)
47+
// snackBar.setAction(actionText) { _ -> action.invoke() }
48+
// snackBar.setActionTextColor(ContextCompat.getColor(appContext, color.colorTextPrimary))
49+
// snackBar.show()
50+
// }
51+
}

app/src/main/kotlin/com/fernandocejas/sample/core/platform/BaseViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (C) 2020 Fernando Cejas Open Source Project
2+
* Copyright (C) 2024 Fernando Cejas Open Source Project
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)