From 6222f6a234b16f358a92e3701eab4aee1abc7305 Mon Sep 17 00:00:00 2001 From: bliveinhack Date: Sat, 19 Dec 2020 16:23:20 +0530 Subject: [PATCH 01/12] - Added text title functionality --- .idea/codeStyles/Project.xml | 16 ++++++ .idea/compiler.xml | 55 ++++++++++--------- .idea/gradle.xml | 1 + .idea/misc.xml | 2 +- .../meow/bottomnavigation/BezierView.kt | 16 ++++-- .../bottomnavigation/MeowBottomNavigation.kt | 17 +++++- .../MeowBottomNavigationCell.kt | 24 ++++++++ .../main/res/layout/meow_navigation_cell.xml | 12 ++++ .../src/main/res/values/attrs.xml | 2 + .../bottomnavigation_sample/MainActivity.kt | 15 +++-- 10 files changed, 121 insertions(+), 39 deletions(-) diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 88ea3aa..3cc336b 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -1,6 +1,22 @@ + + diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 0a1e86f..a86cd8a 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -5,42 +5,43 @@ - - - - - - - - - - - - - - + + + + + - + + + + + + + + + + + - + + + - + + + + + + - - - + - - - - - - - + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index a165c15..eeeac96 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -17,6 +17,7 @@ diff --git a/.idea/misc.xml b/.idea/misc.xml index 7bfef59..d5d35ec 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/MeowBottomNavigation/src/main/kotlin/meow/bottomnavigation/BezierView.kt b/MeowBottomNavigation/src/main/kotlin/meow/bottomnavigation/BezierView.kt index 4c4b588..a8b5423 100644 --- a/MeowBottomNavigation/src/main/kotlin/meow/bottomnavigation/BezierView.kt +++ b/MeowBottomNavigation/src/main/kotlin/meow/bottomnavigation/BezierView.kt @@ -16,15 +16,14 @@ package meow.bottomnavigation +import android.R import android.annotation.SuppressLint import android.content.Context -import android.graphics.Canvas -import android.graphics.Paint -import android.graphics.Path -import android.graphics.PointF +import android.graphics.* import android.util.AttributeSet import android.view.View + /** * Bezier View class. * @@ -49,6 +48,7 @@ class BezierView @JvmOverloads constructor( private var width = 0f private var height = 0f + private var bgRes = 0 private var bezierOuterWidth = 0f private var bezierOuterHeight = 0f private var bezierInnerWidth = 0f @@ -61,6 +61,13 @@ class BezierView @JvmOverloads constructor( mainPaint?.color = field invalidate() } + var backgroundResourceId = 0 + set(value) { + if (value != 0) { + field=value; + invalidate() + } + } var shadowColor = 0 set(value) { field = value @@ -118,6 +125,7 @@ class BezierView @JvmOverloads constructor( isAntiAlias = true style = Paint.Style.FILL color = this@BezierView.color + } shadowPaint = Paint(Paint.ANTI_ALIAS_FLAG) diff --git a/MeowBottomNavigation/src/main/kotlin/meow/bottomnavigation/MeowBottomNavigation.kt b/MeowBottomNavigation/src/main/kotlin/meow/bottomnavigation/MeowBottomNavigation.kt index dfca858..746bf86 100644 --- a/MeowBottomNavigation/src/main/kotlin/meow/bottomnavigation/MeowBottomNavigation.kt +++ b/MeowBottomNavigation/src/main/kotlin/meow/bottomnavigation/MeowBottomNavigation.kt @@ -28,6 +28,7 @@ import android.util.LayoutDirection import android.view.Gravity import android.widget.FrameLayout import android.widget.LinearLayout +import androidx.core.graphics.drawable.DrawableCompat import androidx.interpolator.view.animation.FastOutSlowInInterpolator import com.etebarian.meowbottomnavigation.R import kotlin.math.abs @@ -74,6 +75,7 @@ class MeowBottomNavigation : FrameLayout { field = value updateAllIfAllowDraw() } + var circleColor = Color.parseColor("#ffffff") set(value) { field = value @@ -85,6 +87,11 @@ class MeowBottomNavigation : FrameLayout { field = value updateAllIfAllowDraw() } + var titleTextColor = Color.parseColor("#000000") + set(value) { + field = value + updateAllIfAllowDraw() + } var countBackgroundColor = Color.parseColor("#ff0000") set(value) { field = value @@ -104,6 +111,7 @@ class MeowBottomNavigation : FrameLayout { private var allowDraw = false + @Suppress("PrivatePropertyName") private lateinit var ll_cells: LinearLayout private lateinit var bezierView: BezierView @@ -149,10 +157,13 @@ class MeowBottomNavigation : FrameLayout { R.styleable.MeowBottomNavigation_mbn_backgroundBottomColor, backgroundBottomColor ) + circleColor = getColor(R.styleable.MeowBottomNavigation_mbn_circleColor, circleColor) countTextColor = getColor(R.styleable.MeowBottomNavigation_mbn_countTextColor, countTextColor) + titleTextColor = + getColor(R.styleable.MeowBottomNavigation_mbn_titleTextColor, titleTextColor) countBackgroundColor = getColor( R.styleable.MeowBottomNavigation_mbn_countBackgroundColor, countBackgroundColor @@ -217,10 +228,12 @@ class MeowBottomNavigation : FrameLayout { layoutParams = params icon = model.icon count = model.count + title=model.title; defaultIconColor = this@MeowBottomNavigation.defaultIconColor selectedIconColor = this@MeowBottomNavigation.selectedIconColor circleColor = this@MeowBottomNavigation.circleColor countTextColor = this@MeowBottomNavigation.countTextColor + titleTextColor = this@MeowBottomNavigation.titleTextColor countBackgroundColor = this@MeowBottomNavigation.countBackgroundColor countTypeface = this@MeowBottomNavigation.countTypeface rippleColor = this@MeowBottomNavigation.rippleColor @@ -299,6 +312,7 @@ class MeowBottomNavigation : FrameLayout { addUpdateListener { val f = it.animatedFraction bezierView.progress = f * 2f + } start() } @@ -382,8 +396,7 @@ class MeowBottomNavigation : FrameLayout { onReselectListener = listener } - class Model(var id: Int, var icon: Int) { - + class Model(var id: Int,var icon: Int,var title: String) { var count: String = MeowBottomNavigationCell.EMPTY_VALUE } diff --git a/MeowBottomNavigation/src/main/kotlin/meow/bottomnavigation/MeowBottomNavigationCell.kt b/MeowBottomNavigation/src/main/kotlin/meow/bottomnavigation/MeowBottomNavigationCell.kt index c58076e..fd7fd35 100644 --- a/MeowBottomNavigation/src/main/kotlin/meow/bottomnavigation/MeowBottomNavigationCell.kt +++ b/MeowBottomNavigation/src/main/kotlin/meow/bottomnavigation/MeowBottomNavigationCell.kt @@ -116,6 +116,22 @@ class MeowBottomNavigationCell @JvmOverloads constructor( } } + var title: String? = + EMPTY_VALUE + set(value) { + field = value + if (allowDraw) { + if (title != null && title == EMPTY_VALUE) { + binding.tvCount.text = "" + binding.tvCount.visibility = View.INVISIBLE + } else { + binding.tvTitle.text = title + binding.tvTitle.visibility = View.VISIBLE + + } + } + } + private var iconSize = 48f.dp(context) set(value) { field = value @@ -136,6 +152,13 @@ class MeowBottomNavigationCell @JvmOverloads constructor( binding.tvCount.setTextColor(field) } + var titleTextColor = 0 + set(value) { + field = value + if (allowDraw) + binding.tvTitle.setTextColor(field) + } + var countBackgroundColor = 0 set(value) { field = value @@ -257,6 +280,7 @@ class MeowBottomNavigationCell @JvmOverloads constructor( private fun animateProgress(enableCell: Boolean, isAnimate: Boolean = true) { val d = if (enableCell) duration else 250 val anim = ValueAnimator.ofFloat(0f, 1f) + binding.tvTitle?.visibility = if (enableCell) View.GONE else View.VISIBLE anim.apply { startDelay = if (enableCell) d / 4 else 0L duration = if (isAnimate) d else 1L diff --git a/MeowBottomNavigation/src/main/res/layout/meow_navigation_cell.xml b/MeowBottomNavigation/src/main/res/layout/meow_navigation_cell.xml index 2747f24..43b75fe 100644 --- a/MeowBottomNavigation/src/main/res/layout/meow_navigation_cell.xml +++ b/MeowBottomNavigation/src/main/res/layout/meow_navigation_cell.xml @@ -39,6 +39,18 @@ android:textDirection="ltr" android:textSize="8dp" tools:ignore="RtlHardcoded,SpUsage" /> + diff --git a/MeowBottomNavigation/src/main/res/values/attrs.xml b/MeowBottomNavigation/src/main/res/values/attrs.xml index 7ead227..690ab8e 100644 --- a/MeowBottomNavigation/src/main/res/values/attrs.xml +++ b/MeowBottomNavigation/src/main/res/values/attrs.xml @@ -5,8 +5,10 @@ + + diff --git a/Sample/src/main/kotlin/meow/bottomnavigation_sample/MainActivity.kt b/Sample/src/main/kotlin/meow/bottomnavigation_sample/MainActivity.kt index ec5ebdc..a6562a2 100644 --- a/Sample/src/main/kotlin/meow/bottomnavigation_sample/MainActivity.kt +++ b/Sample/src/main/kotlin/meow/bottomnavigation_sample/MainActivity.kt @@ -45,31 +45,36 @@ class MainActivity : AppCompatActivity() { add( MeowBottomNavigation.Model( ID_HOME, - R.drawable.ic_home + R.drawable.ic_home, + "Home" ) ) add( MeowBottomNavigation.Model( ID_EXPLORE, - R.drawable.ic_explore + R.drawable.ic_explore, + "Explore" ) ) add( MeowBottomNavigation.Model( ID_MESSAGE, - R.drawable.ic_message + R.drawable.ic_message, + "Messages" ) ) add( MeowBottomNavigation.Model( ID_NOTIFICATION, - R.drawable.ic_notification + R.drawable.ic_notification, + "Notification" ) ) add( MeowBottomNavigation.Model( ID_ACCOUNT, - R.drawable.ic_account + R.drawable.ic_account, + "Account" ) ) From e6f7474619a8ce119980a975a59913efc8cb0168 Mon Sep 17 00:00:00 2001 From: bliveinhack Date: Sat, 19 Dec 2020 17:02:29 +0530 Subject: [PATCH 02/12] - Added text title functionality - Support for jitpack publish --- .idea/compiler.xml | 2 +- .idea/gradle.xml | 2 +- .../.gitignore | 0 .../build.gradle.kts | 0 .../proguard-rules.pro | 0 .../src/main/AndroidManifest.xml | 0 .../src/main/kotlin/meow/bottomnavigation/BezierView.kt | 0 .../main/kotlin/meow/bottomnavigation/MeowBottomNavigation.kt | 0 .../kotlin/meow/bottomnavigation/MeowBottomNavigationCell.kt | 0 .../src/main/kotlin/meow/bottomnavigation/Utils.kt | 0 .../src/main/res/layout/meow_navigation_cell.xml | 0 .../src/main/res/values/attrs.xml | 0 .../src/main/res/values/strings.xml | 0 Sample/build.gradle.kts | 3 +-- settings.gradle.kts | 2 +- 15 files changed, 4 insertions(+), 5 deletions(-) rename {MeowBottomNavigation => MeowBottomNavigationTextSupport}/.gitignore (100%) rename {MeowBottomNavigation => MeowBottomNavigationTextSupport}/build.gradle.kts (100%) rename {MeowBottomNavigation => MeowBottomNavigationTextSupport}/proguard-rules.pro (100%) rename {MeowBottomNavigation => MeowBottomNavigationTextSupport}/src/main/AndroidManifest.xml (100%) rename {MeowBottomNavigation => MeowBottomNavigationTextSupport}/src/main/kotlin/meow/bottomnavigation/BezierView.kt (100%) rename {MeowBottomNavigation => MeowBottomNavigationTextSupport}/src/main/kotlin/meow/bottomnavigation/MeowBottomNavigation.kt (100%) rename {MeowBottomNavigation => MeowBottomNavigationTextSupport}/src/main/kotlin/meow/bottomnavigation/MeowBottomNavigationCell.kt (100%) rename {MeowBottomNavigation => MeowBottomNavigationTextSupport}/src/main/kotlin/meow/bottomnavigation/Utils.kt (100%) rename {MeowBottomNavigation => MeowBottomNavigationTextSupport}/src/main/res/layout/meow_navigation_cell.xml (100%) rename {MeowBottomNavigation => MeowBottomNavigationTextSupport}/src/main/res/values/attrs.xml (100%) rename {MeowBottomNavigation => MeowBottomNavigationTextSupport}/src/main/res/values/strings.xml (100%) diff --git a/.idea/compiler.xml b/.idea/compiler.xml index a86cd8a..998bda3 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -39,7 +39,7 @@ - + diff --git a/.idea/gradle.xml b/.idea/gradle.xml index eeeac96..83371d4 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -11,7 +11,7 @@ \ No newline at end of file diff --git a/MeowBottomNavigationTextSupport/build.gradle.kts b/MeowBottomNavigationTextSupport/build.gradle.kts index cc77038..ed3c07d 100644 --- a/MeowBottomNavigationTextSupport/build.gradle.kts +++ b/MeowBottomNavigationTextSupport/build.gradle.kts @@ -3,7 +3,6 @@ import meow.AppConfig import meow.AppConfig.Dependencies import meow.AppConfig.Publishing import meow.AppConfig.Versions -import meow.getPropertyAny import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { @@ -68,7 +67,7 @@ android { dependencies { implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) - + implementation ("com.intuit.sdp:sdp-android:1.0.6") // Implementation Dependencies Dependencies.implementationItems.forEach { implementation(it) diff --git a/MeowBottomNavigationTextSupport/src/main/kotlin/meow/bottomnavigation/MeowBottomNavigation.kt b/MeowBottomNavigationTextSupport/src/main/kotlin/meow/bottomnavigation/MeowBottomNavigation.kt index 002f960..da755e9 100644 --- a/MeowBottomNavigationTextSupport/src/main/kotlin/meow/bottomnavigation/MeowBottomNavigation.kt +++ b/MeowBottomNavigationTextSupport/src/main/kotlin/meow/bottomnavigation/MeowBottomNavigation.kt @@ -25,6 +25,7 @@ import android.graphics.Typeface import android.os.Build import android.util.AttributeSet import android.util.LayoutDirection +import android.util.Log import android.view.Gravity import android.widget.FrameLayout import android.widget.LinearLayout @@ -116,7 +117,9 @@ class MeowBottomNavigation : FrameLayout { private lateinit var bezierView: BezierView init { - heightCell = 76.dp(context) + + heightCell = context.resources.getDimension(R.dimen._32sdp).toInt() + heightCell=heightCell.dp(context) } constructor(context: Context) : super(context) { @@ -201,7 +204,7 @@ class MeowBottomNavigation : FrameLayout { color = backgroundBottomColor shadowColor = this@MeowBottomNavigation.shadowColor } - + Log.e("DIMEN", heightCell.toString()) addView(bezierView) addView(ll_cells) allowDraw = true diff --git a/Sample/build.gradle.kts b/Sample/build.gradle.kts index 36efa8b..9f14677 100644 --- a/Sample/build.gradle.kts +++ b/Sample/build.gradle.kts @@ -79,7 +79,6 @@ tasks { dependencies { implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) implementation(project(":MeowBottomNavigationTextSupport")) - // Implementation Dependencies Dependencies.implementationItems.forEach { implementation(it) diff --git a/Sample/src/main/kotlin/meow/bottomnavigation_sample/MainActivity.kt b/Sample/src/main/kotlin/meow/bottomnavigation_sample/MainActivity.kt index a6562a2..58973ac 100644 --- a/Sample/src/main/kotlin/meow/bottomnavigation_sample/MainActivity.kt +++ b/Sample/src/main/kotlin/meow/bottomnavigation_sample/MainActivity.kt @@ -39,7 +39,6 @@ class MainActivity : AppCompatActivity() { val tvSelected = binding.tvSelected tvSelected.typeface = Typeface.createFromAsset(assets, "fonts/SourceSansPro-Regular.ttf") - binding.bottomNavigation.apply { add( diff --git a/build.gradle.kts b/build.gradle.kts index afa9c96..540e7d7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -22,6 +22,10 @@ allprojects { repositories { google() jcenter() + maven { + url = uri("https://dl.bintray.com/chrynan/chrynan") + } + maven { url =uri("https://jitpack.io") } } } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 5a1d5d4..4113135 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -8,4 +8,7 @@ kotlinDslPluginOptions { repositories { jcenter() + maven { + url = uri("https://dl.bintray.com/chrynan/chrynan") + } } \ No newline at end of file From 5e4c23f24ae867a587c807a377cfe5909904d951 Mon Sep 17 00:00:00 2001 From: bliveinhack Date: Wed, 23 Dec 2020 18:05:36 +0530 Subject: [PATCH 12/12] Added height changing functions --- .../kotlin/meow/bottomnavigation/MeowBottomNavigation.kt | 6 ++++-- .../src/main/res/values/attrs.xml | 1 + Sample/src/main/res/layout/activity_main.xml | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/MeowBottomNavigationTextSupport/src/main/kotlin/meow/bottomnavigation/MeowBottomNavigation.kt b/MeowBottomNavigationTextSupport/src/main/kotlin/meow/bottomnavigation/MeowBottomNavigation.kt index da755e9..fcdd964 100644 --- a/MeowBottomNavigationTextSupport/src/main/kotlin/meow/bottomnavigation/MeowBottomNavigation.kt +++ b/MeowBottomNavigationTextSupport/src/main/kotlin/meow/bottomnavigation/MeowBottomNavigation.kt @@ -32,6 +32,7 @@ import android.widget.LinearLayout import androidx.interpolator.view.animation.FastOutSlowInInterpolator import com.etebarian.meowbottomnavigation.R import kotlin.math.abs +import kotlin.math.roundToInt /** * Meow Bottom Navigation Cell class. @@ -117,8 +118,7 @@ class MeowBottomNavigation : FrameLayout { private lateinit var bezierView: BezierView init { - - heightCell = context.resources.getDimension(R.dimen._32sdp).toInt() + heightCell = context.resources.getDimension(R.dimen._30sdp).toInt() heightCell=heightCell.dp(context) } @@ -159,6 +159,8 @@ class MeowBottomNavigation : FrameLayout { R.styleable.MeowBottomNavigation_mbn_backgroundBottomColor, backgroundBottomColor ) + heightCell = + getDimension(R.styleable.MeowBottomNavigation_mbn_height,heightCell.toFloat()).roundToInt() circleColor = getColor(R.styleable.MeowBottomNavigation_mbn_circleColor, circleColor) diff --git a/MeowBottomNavigationTextSupport/src/main/res/values/attrs.xml b/MeowBottomNavigationTextSupport/src/main/res/values/attrs.xml index 690ab8e..33066b3 100644 --- a/MeowBottomNavigationTextSupport/src/main/res/values/attrs.xml +++ b/MeowBottomNavigationTextSupport/src/main/res/values/attrs.xml @@ -7,6 +7,7 @@ + diff --git a/Sample/src/main/res/layout/activity_main.xml b/Sample/src/main/res/layout/activity_main.xml index 529d808..6746023 100644 --- a/Sample/src/main/res/layout/activity_main.xml +++ b/Sample/src/main/res/layout/activity_main.xml @@ -54,6 +54,7 @@ android:layout_height="wrap_content" android:layout_gravity="bottom" app:mbn_circleColor="#ffffff" + app:mbn_height="78dip" app:mbn_backgroundBottomColor="#ffffff" app:mbn_countBackgroundColor="#ff6f00" app:mbn_countTextColor="#ffffff"