diff --git a/build.gradle b/build.gradle index d910de7..ea7c34d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = "1.4.32" + ext.kotlin_version = '1.4.32' repositories { google() mavenCentral() @@ -17,7 +17,6 @@ allprojects { google() mavenCentral() } - plugins.withId("com.vanniktech.maven.publish") { mavenPublish { sonatypeHost = "S01" diff --git a/demo/build.gradle b/demo/build.gradle index 8494a61..ae469e2 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -3,14 +3,14 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { - compileSdkVersion 29 + + compileSdkVersion 32 defaultConfig { applicationId "nl.joery.demo.animatedbottombar" minSdkVersion 21 - targetSdkVersion 29 + targetSdkVersion 32 versionCode 3 - versionName "1.0.2" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -32,17 +32,24 @@ android { } dependencies { + implementation fileTree(dir: "libs", include: ["*.jar"]) - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.2.0' - implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'com.google.android.material:material:1.1.0' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - implementation 'androidx.navigation:navigation-fragment-ktx:2.2.1' - implementation 'androidx.navigation:navigation-ui-ktx:2.2.1' + implementation 'androidx.appcompat:appcompat:1.4.1' + implementation 'androidx.core:core-ktx:1.7.0' + implementation 'com.google.android.material:material:1.5.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.3' + + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + + implementation 'androidx.navigation:navigation-fragment-ktx:2.4.1' + implementation 'androidx.navigation:navigation-ui-ktx:2.4.1' + implementation 'com.jaredrummler:colorpicker:1.1.0' + implementation project(path: ':library') - testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test.ext:junit:1.1.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.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' + } \ No newline at end of file diff --git a/demo/src/main/AndroidManifest.xml b/demo/src/main/AndroidManifest.xml index 65e65d9..6466da2 100644 --- a/demo/src/main/AndroidManifest.xml +++ b/demo/src/main/AndroidManifest.xml @@ -16,6 +16,7 @@ diff --git a/demo/src/main/java/nl/joery/demo/animatedbottombar/playground/PlaygroundActivity.kt b/demo/src/main/java/nl/joery/demo/animatedbottombar/playground/PlaygroundActivity.kt index b2f3495..222c754 100644 --- a/demo/src/main/java/nl/joery/demo/animatedbottombar/playground/PlaygroundActivity.kt +++ b/demo/src/main/java/nl/joery/demo/animatedbottombar/playground/PlaygroundActivity.kt @@ -216,6 +216,11 @@ class PlaygroundActivity : AppCompatActivity() { TypedValue.COMPLEX_UNIT_SP ) ) + properties.add( + TypefaceProperty( + "badgeTypeface" + ) + ) } private fun initRecyclerView() { diff --git a/demo/src/main/java/nl/joery/demo/animatedbottombar/playground/properties/TypefaceProperty.kt b/demo/src/main/java/nl/joery/demo/animatedbottombar/playground/properties/TypefaceProperty.kt new file mode 100644 index 0000000..cd2d357 --- /dev/null +++ b/demo/src/main/java/nl/joery/demo/animatedbottombar/playground/properties/TypefaceProperty.kt @@ -0,0 +1,3 @@ +package nl.joery.demo.animatedbottombar.playground.properties + +class TypefaceProperty(name: String) : Property(name) \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index cee161b..dff9686 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip \ No newline at end of file diff --git a/library/build.gradle b/library/build.gradle index 3e3a2ef..0bf5723 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -3,6 +3,7 @@ apply plugin: 'kotlin-android' apply plugin: "com.vanniktech.maven.publish" android { + compileSdkVersion 29 defaultConfig { @@ -43,7 +44,7 @@ dependencies { api "androidx.navigation:navigation-ui-ktx:2.3.5" - testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' } diff --git a/library/src/main/java/nl/joery/animatedbottombar/AnimatedBottomBar.kt b/library/src/main/java/nl/joery/animatedbottombar/AnimatedBottomBar.kt index 23aa760..edad6c2 100644 --- a/library/src/main/java/nl/joery/animatedbottombar/AnimatedBottomBar.kt +++ b/library/src/main/java/nl/joery/animatedbottombar/AnimatedBottomBar.kt @@ -16,6 +16,7 @@ import android.view.animation.AnimationUtils import android.widget.FrameLayout import androidx.annotation.* import androidx.core.content.ContextCompat +import androidx.core.content.res.ResourcesCompat import androidx.navigation.NavController import androidx.recyclerview.widget.RecyclerView import androidx.viewpager.widget.ViewPager @@ -218,6 +219,13 @@ class AnimatedBottomBar @JvmOverloads constructor( R.styleable.AnimatedBottomBar_abb_badgeTextSize, tabStyle.badge.textSize ) + badgeTypeface = + if (attr.hasValue(R.styleable.AnimatedBottomBar_abb_badgeTypeface)) + ResourcesCompat.getFont( + context, + attr.getResourceId(R.styleable.AnimatedBottomBar_abb_badgeTypeface, 0) + ) ?: tabStyle.badge.typeface + else tabStyle.badge.typeface // Initials tabs val tabsResId = attr.getResourceId(R.styleable.AnimatedBottomBar_abb_tabs, -1) @@ -1076,6 +1084,13 @@ class AnimatedBottomBar @JvmOverloads constructor( applyTabStyle(BottomBarStyle.StyleUpdateType.BADGE) } + var badgeTypeface + get() = tabStyle.badge.typeface + set(value) { + tabStyle.badge.typeface = value + applyTabStyle(BottomBarStyle.StyleUpdateType.BADGE) + } + class Tab internal constructor( val icon: Drawable, var iconSize: Int = -1, @@ -1090,10 +1105,11 @@ class AnimatedBottomBar @JvmOverloads constructor( val text: String? = null, @ColorInt val backgroundColor: Int? = null, @ColorInt val textColor: Int? = null, - @Dimension val textSize: Int? = null + @Dimension val textSize: Int? = null, + val typeface: Typeface? = null ) { - constructor() : this(null, null, null, null) - constructor(text: String?) : this(text, null, null, null) + constructor() : this(null, null, null, null, null) + constructor(text: String?) : this(text, null, null, null, null) } enum class TabType(val id: Int) { diff --git a/library/src/main/java/nl/joery/animatedbottombar/BadgeView.kt b/library/src/main/java/nl/joery/animatedbottombar/BadgeView.kt index 6520fc6..2b8edc5 100644 --- a/library/src/main/java/nl/joery/animatedbottombar/BadgeView.kt +++ b/library/src/main/java/nl/joery/animatedbottombar/BadgeView.kt @@ -124,6 +124,17 @@ class BadgeView @JvmOverloads constructor( invalidate() } + private var _typeface: Typeface = Typeface.DEFAULT + var typeface: Typeface + get() = _typeface + set(value) { + _typeface = value + + textPaint.typeface = value + updateTextBounds() + invalidate() + } + init { isEnabled = false } diff --git a/library/src/main/java/nl/joery/animatedbottombar/BottomBarStyle.kt b/library/src/main/java/nl/joery/animatedbottombar/BottomBarStyle.kt index 228159a..a093571 100644 --- a/library/src/main/java/nl/joery/animatedbottombar/BottomBarStyle.kt +++ b/library/src/main/java/nl/joery/animatedbottombar/BottomBarStyle.kt @@ -47,7 +47,8 @@ object BottomBarStyle { var animationDuration: Int = 150, @ColorInt var backgroundColor: Int = Color.rgb(255, 12, 16), @ColorInt var textColor: Int = Color.WHITE, - @Dimension var textSize: Int = 9.spPx + @Dimension var textSize: Int = 9.spPx, + var typeface: Typeface = Typeface.DEFAULT ) data class Indicator( diff --git a/library/src/main/java/nl/joery/animatedbottombar/TabView.kt b/library/src/main/java/nl/joery/animatedbottombar/TabView.kt index 955895a..477d3e8 100644 --- a/library/src/main/java/nl/joery/animatedbottombar/TabView.kt +++ b/library/src/main/java/nl/joery/animatedbottombar/TabView.kt @@ -320,6 +320,7 @@ internal class TabView @JvmOverloads constructor( it.setBackgroundColor(badge.backgroundColor ?: style.badge.backgroundColor) it.textColor = badge.textColor ?: style.badge.textColor it.textSize = badge.textSize ?: style.badge.textSize + it.typeface = badge.typeface ?: style.badge.typeface it.isEnabled = true } diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml index 71fb458..063d0a0 100644 --- a/library/src/main/res/values/attrs.xml +++ b/library/src/main/res/values/attrs.xml @@ -68,5 +68,6 @@ + \ No newline at end of file