Skip to content

Commit

Permalink
Refactor: Upgrade gradle build system & dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
jaydeep-p-simform authored and yashwantgowla-simform committed Sep 18, 2024
1 parent aed60c1 commit 42ce89e
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 110 deletions.
38 changes: 19 additions & 19 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.kapt)
}

android {
compileSdkVersion 31
buildToolsVersion "30.0.3"
compileSdk libs.versions.complieSdk.get().toInteger()
namespace = "com.sscustombottomnavigation"

defaultConfig {
applicationId "com.sscustombottomnavigation"
minSdkVersion 21
targetSdkVersion 31
minSdkVersion libs.versions.minSdk.get().toInteger()
targetSdkVersion libs.versions.targetSdk.get().toInteger()
versionCode 4
versionName "3.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -23,27 +26,24 @@ android {
}

kotlinOptions {
jvmTarget = '11'
jvmTarget = '1.8'
}

dataBinding {
enabled true
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

implementation project(':custombottomnavigation')
implementation(libs.androidx.core.ktx)
implementation(libs.appcompat)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.navigation.fragment)
implementation(libs.androidx.navigation.ui)
implementation(libs.androidx.lifecycle.extensions)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
}
35 changes: 6 additions & 29 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
mavenCentral()
google()
maven { url 'https://jitpack.io' }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.kapt) apply false
}
44 changes: 24 additions & 20 deletions custombottomnavigation/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'maven-publish'
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.kapt)
id("maven-publish")
}

afterEvaluate {
publishing {
Expand All @@ -18,13 +20,12 @@ afterEvaluate {
}

android {
compileSdkVersion 31
buildToolsVersion "30.0.3"
compileSdk libs.versions.complieSdk.get().toInteger()
namespace "com.simform.custombottomnavigation"

defaultConfig {
minSdkVersion 21
targetSdkVersion 31

minSdkVersion libs.versions.minSdk.get().toInteger()
targetSdkVersion libs.versions.targetSdk.get().toInteger()
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
multiDexEnabled true
Expand All @@ -38,20 +39,23 @@ android {
}

kotlinOptions {
jvmTarget = '11'
jvmTarget = '1.8'
}

buildFeatures {
viewBinding = true
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'com.google.android.material:material:1.7.0-alpha02'
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.0'
implementation 'com.android.support:multidex:2.0.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation(libs.androidx.core.ktx)
implementation(libs.appcompat)
implementation(libs.android.material)
implementation(libs.androidx.navigation.fragment)
implementation(libs.androidx.navigation.ui)
implementation(libs.androidx.multidex)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,28 @@ import android.view.View
import android.widget.RelativeLayout
import androidx.core.view.ViewCompat
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
import kotlinx.android.extensions.LayoutContainer
import kotlinx.android.synthetic.main.custom_bottom_navigation_icon.view.*
import com.simform.custombottomnavigation.databinding.CustomBottomNavigationIconBinding

@Suppress("unused")
class CustomBottomNavigationIcon : RelativeLayout, LayoutContainer {
class CustomBottomNavigationIcon : RelativeLayout {

companion object {
const val EMPTY_VALUE = "empty"
}

private lateinit var binding: CustomBottomNavigationIconBinding

var defaultIconColor = 0
set(value) {
field = value
if (allowDraw)
iv.color = if (!isEnabledCell) defaultIconColor else selectedIconColor
binding.iv.color = if (!isEnabledCell) defaultIconColor else selectedIconColor
}
var selectedIconColor = Color.parseColor("#00C957")
set(value) {
field = value
if (allowDraw)
iv.color = if (isEnabledCell) selectedIconColor else defaultIconColor
binding.iv.color = if (isEnabledCell) selectedIconColor else defaultIconColor
}
var circleColor = 0
set(value) {
Expand All @@ -49,21 +50,21 @@ class CustomBottomNavigationIcon : RelativeLayout, LayoutContainer {
set(value) {
field = value
if (allowDraw)
iv.resource = value
binding.iv.resource = value
}

var iconText = ""
set(value) {
field = value
if (allowDraw)
tv.text = value
binding.tv.text = value
}

var iconTextColor = 0
set(value) {
field = value
if (allowDraw) {
if (!isEnabledCell) tv.setTextColor(iconTextColor) else tv.setTextColor(
if (!isEnabledCell) binding.tv.setTextColor(iconTextColor) else binding.tv.setTextColor(
selectedIconTextColor
)

Expand All @@ -74,7 +75,7 @@ class CustomBottomNavigationIcon : RelativeLayout, LayoutContainer {
set(value) {
field = value
if (allowDraw)
if (isEnabledCell) tv.setTextColor(selectedIconTextColor) else tv.setTextColor(
if (isEnabledCell) binding.tv.setTextColor(selectedIconTextColor) else binding.tv.setTextColor(
iconTextColor
)
}
Expand All @@ -83,14 +84,14 @@ class CustomBottomNavigationIcon : RelativeLayout, LayoutContainer {
set(value) {
field = value
if (allowDraw && field != null)
tv.typeface = field
binding.tv.typeface = field
}

var iconTextSize = 10f
set(value) {
field = value
if (allowDraw) {
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, field)
binding.tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, field)
}
}

Expand All @@ -99,17 +100,17 @@ class CustomBottomNavigationIcon : RelativeLayout, LayoutContainer {
field = value
if (allowDraw) {
if (count != null && count == EMPTY_VALUE) {
tv_count.text = ""
tv_count.visibility = View.INVISIBLE
binding.tvCount.text = ""
binding.tvCount.visibility = View.INVISIBLE
} else {
if (count != null && count?.length ?: 0 >= 3) {
field = count?.substring(0, 1) + ".."
}
tv_count.text = count
tv_count.visibility = View.VISIBLE
binding.tvCount.text = count
binding.tvCount.visibility = View.VISIBLE
val scale = if (count?.isEmpty() == true) 0.5f else 1f
tv_count.scaleX = scale
tv_count.scaleY = scale
binding.tvCount.scaleX = scale
binding.tvCount.scaleY = scale
}
}
}
Expand All @@ -118,17 +119,17 @@ class CustomBottomNavigationIcon : RelativeLayout, LayoutContainer {
set(value) {
field = value
if (allowDraw) {
iv.size = value
iv.pivotX = iconSize / 2f
iv.pivotY = iconSize / 2f
binding.iv.size = value
binding.iv.pivotX = iconSize / 2f
binding.iv.pivotY = iconSize / 2f
}
}

var countTextColor = 0
set(value) {
field = value
if (allowDraw)
tv_count.setTextColor(field)
binding.tvCount.setTextColor(field)
}

var countBackgroundColor = 0
Expand All @@ -138,7 +139,7 @@ class CustomBottomNavigationIcon : RelativeLayout, LayoutContainer {
val d = GradientDrawable()
d.setColor(field)
d.shape = GradientDrawable.OVAL
ViewCompat.setBackground(tv_count, d)
ViewCompat.setBackground(binding.tvCount, d)
}
}

Expand All @@ -147,7 +148,7 @@ class CustomBottomNavigationIcon : RelativeLayout, LayoutContainer {
field = value
if (allowDraw && field != null)
field?.let {
tv_count.typeface = it
binding.tvCount.typeface = it
}
}

Expand All @@ -164,14 +165,14 @@ class CustomBottomNavigationIcon : RelativeLayout, LayoutContainer {
private var progress = 0f
set(value) {
field = value
Log.e("TAG", "height is ${containerView.layoutParams.height} ${dip(context, 18)}")
fl.y = (1f - progress) * dip(context, 18) + dip(context, -2)
Log.e("TAG", "height is ${binding.root.layoutParams.height} ${dip(context, 18)}")
binding.fl.y = (1f - progress) * dip(context, 18) + dip(context, -2)

iv.color = if (progress == 1f) selectedIconColor else iconTextColor
tv.setTextColor(if (progress == 1f) selectedIconTextColor else defaultIconColor)
binding.iv.color = if (progress == 1f) selectedIconColor else iconTextColor
binding.tv.setTextColor(if (progress == 1f) selectedIconTextColor else defaultIconColor)
val scale = (1f - progress) * (-0.2f) + 1f
iv.scaleX = scale
iv.scaleY = scale
binding.iv.scaleX = scale
binding.iv.scaleY = scale
}

var isEnabledCell = false
Expand All @@ -181,23 +182,22 @@ class CustomBottomNavigationIcon : RelativeLayout, LayoutContainer {
d.setColor(circleColor)
d.shape = GradientDrawable.OVAL
if (Build.VERSION.SDK_INT >= 21 && !isEnabledCell) {
fl.background = RippleDrawable(ColorStateList.valueOf(rippleColor), null, d)
binding.fl.background = RippleDrawable(ColorStateList.valueOf(rippleColor), null, d)
} else {
fl.runAfterDelay(200) {
fl.setBackgroundColor(Color.TRANSPARENT)
binding.fl.runAfterDelay(200) {
binding.fl.setBackgroundColor(Color.TRANSPARENT)
}
}
}

var onClickListener: () -> Unit = {}
set(value) {
field = value
fl?.setOnClickListener {
binding.fl.setOnClickListener {
onClickListener()
}
}

override lateinit var containerView: View
private var allowDraw = false

constructor(context: Context) : super(context) {
Expand All @@ -224,8 +224,7 @@ class CustomBottomNavigationIcon : RelativeLayout, LayoutContainer {

private fun initializeView() {
allowDraw = true
containerView =
LayoutInflater.from(context).inflate(R.layout.custom_bottom_navigation_icon, this)
binding = CustomBottomNavigationIconBinding.inflate(LayoutInflater.from(context), this)
draw()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,10 @@ class SSCustomBottomNavigation : FrameLayout {
}
val builder = NavOptions.Builder()
.setLaunchSingleTop(true)
.setEnterAnim(R.anim.nav_default_enter_anim)
.setExitAnim(R.anim.nav_default_exit_anim)
.setPopEnterAnim(R.anim.nav_default_pop_enter_anim)
.setPopExitAnim(R.anim.nav_default_pop_exit_anim)
.setEnterAnim(android.R.anim.fade_in)
.setExitAnim(android.R.anim.fade_out)
.setPopEnterAnim(android.R.anim.fade_in)
.setPopExitAnim(android.R.anim.fade_out)
// pop to the navigation graph's start destination
builder.setPopUpTo(findStartDestination(navController.graph).id, false)
val options = builder.build()
Expand Down Expand Up @@ -490,7 +490,7 @@ class SSCustomBottomNavigation : FrameLayout {
isAnimating = false
}
addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator?) {
override fun onAnimationEnd(animation: Animator) {
isAnimating = false
}
})
Expand Down
Loading

0 comments on commit 42ce89e

Please sign in to comment.