Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -17,7 +17,6 @@ allprojects {
google()
mavenCentral()
}

plugins.withId("com.vanniktech.maven.publish") {
mavenPublish {
sonatypeHost = "S01"
Expand Down
33 changes: 20 additions & 13 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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'

}
1 change: 1 addition & 0 deletions demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
</activity>
<activity
android:name=".playground.PlaygroundActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ class PlaygroundActivity : AppCompatActivity() {
TypedValue.COMPLEX_UNIT_SP
)
)
properties.add(
TypefaceProperty(
"badgeTypeface"
)
)
}

private fun initRecyclerView() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package nl.joery.demo.animatedbottombar.playground.properties

class TypefaceProperty(name: String) : Property(name)
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 4 additions & 3 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apply plugin: 'kotlin-android'
apply plugin: "com.vanniktech.maven.publish"

android {

compileSdkVersion 29

defaultConfig {
Expand Down Expand Up @@ -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'
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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) {
Expand Down
11 changes: 11 additions & 0 deletions library/src/main/java/nl/joery/animatedbottombar/BadgeView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@
<attr name="abb_badgeBackgroundColor" format="color" />
<attr name="abb_badgeTextColor" format="color" />
<attr name="abb_badgeTextSize" format="dimension" />
<attr name="abb_badgeTypeface" format="reference" />
</declare-styleable>
</resources>