diff --git a/README.md b/README.md
index d3d29cd..9f676de 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,10 @@ A very simple Android way to use Bottom Bar on Android
Api-level 14+
+Versions:
+1.0.10 uses AppCompat libraries
+2.0.0 uses AndroidX libraries
+
Usage:
Add the repository to your gradle app
@@ -16,7 +20,7 @@ allprojects {
}
dependencies {
- compile 'com.github.khirr:Android-Bottom-Bar:1.0.10'
+ compile 'com.github.khirr:Android-Bottom-Bar:2.0.0'
}
```
@@ -34,17 +38,20 @@ Add items
Java
```
final BottomBarView bottomBarView = (BottomBarView) findViewById(R.id.bottomBarView);
+// set custom colors
+final BottomBarColors bottomBarColors = new BottomBarColors()
+ .setBackgroundColor(ContextCompat.getColor(this, R.color.colorBackground))
+ .setUnselectedColor(ContextCompat.getColor(this, R.color.colorUnselected))
+ .setSelectedColor(ContextCompat.getColor(this, R.color.colorSelected))
+ .setBadgeColor(Color.parseColor("#00ab48"))
+ .setDividerColor(Color.parseColor("#b23c09"));
+
// addItem method needs id, name, icon
mBottomBar = new BottomBar(this, bottomBarView)
- .addItem(new BottomBar.Item(0,
- "Home",
- R.drawable.ic_home_white_24dp))
- .addItem(new BottomBar.Item(1,
- "Chat",
- R.drawable.ic_chat_bubble_white_24dp))
- .addItem(new BottomBar.Item(2,
- "Notifications",
- R.drawable.ic_notifications_white_24dp))
+ .setBottomBarColors(bottomBarColors)
+ .addItem(new BottomBar.Item(0, "Home", R.drawable.ic_home_white_24dp))
+ .addItem(new BottomBar.Item(1, "Chat", R.drawable.ic_chat_bubble_white_24dp))
+ .addItem(new BottomBar.Item(2, "Notifications", R.drawable.ic_notifications_white_24dp))
.build();
```
diff --git a/app/build.gradle b/app/build.gradle
index 75d3d22..da00d07 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,15 +1,16 @@
apply plugin: 'com.android.application'
+apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
- compileSdkVersion 28
+ compileSdkVersion 30
defaultConfig {
applicationId "net.khirr.android.bottombar.example"
minSdkVersion 14
- targetSdkVersion 28
+ targetSdkVersion 30
versionCode 1
versionName "1.0"
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
@@ -24,17 +25,14 @@ repositories {
}
dependencies {
- ext {
- supportLibraryVersion = '28.0.0'
- }
implementation fileTree(dir: 'libs', include: ['*.jar'])
- androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
+ androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation project(':library')
- implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
- implementation "com.android.support:design:${supportLibraryVersion}"
- implementation 'com.android.support.constraint:constraint-layout:1.0.2'
+ implementation 'androidx.appcompat:appcompat:1.1.0'
+ implementation 'com.google.android.material:material:1.1.0'
+ implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
diff --git a/app/src/androidTest/java/net/khirr/android/bottombar/example/ExampleInstrumentedTest.java b/app/src/androidTest/java/net/khirr/android/bottombar/example/ExampleInstrumentedTest.java
index 5f24994..43b5049 100644
--- a/app/src/androidTest/java/net/khirr/android/bottombar/example/ExampleInstrumentedTest.java
+++ b/app/src/androidTest/java/net/khirr/android/bottombar/example/ExampleInstrumentedTest.java
@@ -1,8 +1,8 @@
package net.khirr.android.bottombar.example;
import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/app/src/main/java/net/khirr/android/bottombar/example/FragmentExample.java b/app/src/main/java/net/khirr/android/bottombar/example/FragmentExample.java
index bf69429..b3162b9 100644
--- a/app/src/main/java/net/khirr/android/bottombar/example/FragmentExample.java
+++ b/app/src/main/java/net/khirr/android/bottombar/example/FragmentExample.java
@@ -1,8 +1,8 @@
package net.khirr.android.bottombar.example;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
diff --git a/app/src/main/java/net/khirr/android/bottombar/example/MainActivity.java b/app/src/main/java/net/khirr/android/bottombar/example/MainActivity.java
index 3f71ba2..8425fd5 100644
--- a/app/src/main/java/net/khirr/android/bottombar/example/MainActivity.java
+++ b/app/src/main/java/net/khirr/android/bottombar/example/MainActivity.java
@@ -1,10 +1,13 @@
package net.khirr.android.bottombar.example;
+import android.graphics.Color;
import android.os.Bundle;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
+import androidx.core.content.ContextCompat;
import net.khirr.library.bottombar.BottomBar;
+import net.khirr.library.bottombar.BottomBarColors;
import net.khirr.library.bottombar.BottomBarView;
import net.khirr.library.bottombar.MultipleFragmentsManager;
@@ -35,19 +38,18 @@ protected void onCreate(Bundle savedInstanceState) {
final BottomBarView bottomBarView = (BottomBarView) findViewById(R.id.bottomBarView);
+ final BottomBarColors bottomBarColors = new BottomBarColors()
+ .setBackgroundColor(ContextCompat.getColor(this, R.color.colorBackground))
+ .setUnselectedColor(ContextCompat.getColor(this, R.color.colorUnselected))
+ .setSelectedColor(ContextCompat.getColor(this, R.color.colorSelected))
+ .setBadgeColor(Color.parseColor("#00ab48"))
+ .setDividerColor(Color.parseColor("#b23c09"));
+
mBottomBar = new BottomBar(this, bottomBarView)
- .setBackgroundColor(R.color.colorBackground)
- .setUnselectedColor(R.color.colorUnselected)
- .setSelectedColor(R.color.colorSelected)
- .setDividerColor(R.color.colorDivider)
- .addItem(new BottomBar.Item(0,
- R.drawable.ic_home_white_24dp))
- .addItem(new BottomBar.Item(1,
- "Chat",
- R.drawable.ic_chat_bubble_white_24dp))
- .addItem(new BottomBar.Item(2,
- "Notifications",
- R.drawable.ic_notifications_white_24dp))
+ .setBottomBarColors(bottomBarColors)
+ .addItem(new BottomBar.Item(0, R.drawable.ic_home_white_24dp))
+ .addItem(new BottomBar.Item(1, "Chat", R.drawable.ic_chat_bubble_white_24dp))
+ .addItem(new BottomBar.Item(2, "Notifications", R.drawable.ic_notifications_white_24dp))
.build();
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 241ddc9..635924d 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -11,21 +11,21 @@
android:id="@+id/bottomBarView"
android:layout_alignParentBottom="true"/>
-
-
-
-
+
-
+
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 9a77949..32eda70 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
- ext.kotlin_version = '1.3.11'
+ ext.kotlin_version = '1.3.72'
repositories {
jcenter()
maven {
@@ -10,7 +10,7 @@ buildscript {
}
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.2.1'
+ classpath 'com.android.tools.build:gradle:4.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
diff --git a/gradle.properties b/gradle.properties
index aac7c9b..9e6fce1 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -9,6 +9,8 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
+android.enableJetifier=true
+android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 5d2e8dc..1b65ec4 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Sun Dec 09 01:17:15 CET 2018
+#Wed Jul 08 14:21:49 CEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
diff --git a/library/build.gradle b/library/build.gradle
index 8d3fcbd..cd4e4aa 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -2,15 +2,15 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
- compileSdkVersion 28
+ compileSdkVersion 30
defaultConfig {
minSdkVersion 14
- targetSdkVersion 28
+ targetSdkVersion 30
versionCode 1
versionName "1.0"
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
@@ -28,14 +28,11 @@ repositories {
dependencies {
- ext {
- supportLibraryVersion = '28.0.0'
- }
implementation fileTree(dir: 'libs', include: ['*.jar'])
- androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
+ androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
- implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
+ implementation 'androidx.appcompat:appcompat:1.1.0'
testImplementation 'junit:junit:4.12'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'q.rorbin:badgeview:1.1.2'
diff --git a/library/src/androidTest/java/net/khirr/library/bottombar/ExampleInstrumentedTest.java b/library/src/androidTest/java/net/khirr/library/bottombar/ExampleInstrumentedTest.java
index 87e4303..e68c387 100644
--- a/library/src/androidTest/java/net/khirr/library/bottombar/ExampleInstrumentedTest.java
+++ b/library/src/androidTest/java/net/khirr/library/bottombar/ExampleInstrumentedTest.java
@@ -1,8 +1,8 @@
package net.khirr.library.bottombar;
import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/library/src/main/java/net/khirr/library/bottombar/BottomBar.kt b/library/src/main/java/net/khirr/library/bottombar/BottomBar.kt
index ba09e38..185e7f8 100644
--- a/library/src/main/java/net/khirr/library/bottombar/BottomBar.kt
+++ b/library/src/main/java/net/khirr/library/bottombar/BottomBar.kt
@@ -2,13 +2,12 @@ package net.khirr.library.bottombar
import android.app.Activity
import android.content.res.Resources
-import android.graphics.Color
import android.graphics.PorterDuff
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.GradientDrawable
import android.graphics.drawable.RippleDrawable
import android.os.Build
-import android.support.v4.content.ContextCompat
+import androidx.core.content.ContextCompat
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
@@ -49,16 +48,9 @@ class BottomBar(private val context: Activity, bottomBarView: BottomBarView) {
private val barItems = ArrayList()
private var onItemClickListener: OnItemClickListener? = null
-
- private var backgroundColor = Color.parseColor("#FFFFFF")
- private var selectedColor = Color.parseColor("#FF4081")
- private var unselectedColor = Color.parseColor("#757575")
- private var badgeColor = Color.parseColor("#FF4081")
- private var dividerColor = Color.parseColor("#dcdcdc")
- private var badgeStrokeColor = Color.parseColor("#FFFFFF")
- private var bottomDividerColor = Color.parseColor("#FF4081")
private var enableBottomDivider = false
private var badgeIndicatorSize = dpToPx(8)
+ private var bottomBarColors = BottomBarColors()
var selectedId: Int = -1
@@ -79,41 +71,8 @@ class BottomBar(private val context: Activity, bottomBarView: BottomBarView) {
return this
}
- fun setBackgroundColor(color: Int): BottomBar {
- backgroundColor = getColor(color)
- setBackgroundColor(bottomBar, backgroundColor)
- return this
- }
-
- fun setSelectedColor(color: Int): BottomBar {
- selectedColor = getColor(color)
- return this
- }
-
- fun setUnselectedColor(color: Int): BottomBar {
- unselectedColor = getColor(color)
- return this
- }
-
- fun setBadgeColor(color: Int): BottomBar {
- badgeColor = getColor(color)
- return this
- }
-
- fun setDividerColor(color: Int): BottomBar {
- dividerColor = getColor(color)
- setBackgroundColor(bottomBarDivider, dividerColor)
- return this
- }
-
- fun setBadgeStrokeColor(color: Int): BottomBar {
- badgeStrokeColor = getColor(color)
- return this
- }
-
- fun setBottomDividerColor(color: Int): BottomBar {
- bottomDividerColor = getColor(color)
- bottomBarDividerBottom.setBackgroundColor(bottomDividerColor)
+ fun setBottomBarColors(bottomBarColors: BottomBarColors): BottomBar {
+ this.bottomBarColors = bottomBarColors
return this
}
@@ -151,18 +110,18 @@ class BottomBar(private val context: Activity, bottomBarView: BottomBarView) {
title.text = item.title
icon.setImageResource(item.icon)
- setBackgroundColor(view, backgroundColor)
+ setBackgroundColor(view, bottomBarColors.backgroundColor)
val drawable = badgeIndicator.background as GradientDrawable
- drawable.setColor(badgeColor)
+ drawable.setColor(bottomBarColors.badgeColor)
// Badge indicator size
badgeIndicator.layoutParams.width = badgeIndicatorSize
badgeIndicator.layoutParams.height = badgeIndicatorSize
// Default colors
- title.setTextColor(unselectedColor)
- tint(icon, unselectedColor)
+ title.setTextColor(bottomBarColors.unselectedColor)
+ tint(icon, bottomBarColors.unselectedColor)
val viewItem = BarViewItem(view, container, badgeIndicator, subItemsContainer, icon, title)
val barItem = BarItem(viewItem, item)
@@ -172,8 +131,6 @@ class BottomBar(private val context: Activity, bottomBarView: BottomBarView) {
setPressed(barItem.item.id)
}
-
-
return this
}
@@ -185,11 +142,11 @@ class BottomBar(private val context: Activity, bottomBarView: BottomBarView) {
selectedId = id
barItems.forEach { item ->
- item.view.title.setTextColor(unselectedColor)
- tint(item.view.icon, unselectedColor)
+ item.view.title.setTextColor(bottomBarColors.unselectedColor)
+ tint(item.view.icon, bottomBarColors.unselectedColor)
if (item.item.id == id) {
- item.view.title.setTextColor(selectedColor)
- tint(item.view.icon, selectedColor)
+ item.view.title.setTextColor(bottomBarColors.selectedColor)
+ tint(item.view.icon, bottomBarColors.selectedColor)
}
}
}
@@ -204,6 +161,9 @@ class BottomBar(private val context: Activity, bottomBarView: BottomBarView) {
setPressed(barItem.item.id)
}
}
+ setBackgroundColor(bottomBar, bottomBarColors.backgroundColor)
+ setBackgroundColor(bottomBarDivider, bottomBarColors.dividerColor)
+ bottomBarDividerBottom.setBackgroundColor(bottomBarColors.bottomDividerColor)
return this
}
@@ -260,8 +220,8 @@ class BottomBar(private val context: Activity, bottomBarView: BottomBarView) {
if (barItem.view.badgeCountView == null) {
val badge = QBadgeView(context)
badge.isShowShadow = false
- badge.stroke(badgeStrokeColor, 1.0f, true)
- badge.badgeBackgroundColor = badgeColor
+ badge.stroke(bottomBarColors.badgeStrokeColor, 1.0f, true)
+ badge.badgeBackgroundColor = bottomBarColors.badgeColor
badge.bindTarget(barItem.view.subItemsContainer)
barItem.view.badgeCountView = badge
}
diff --git a/library/src/main/java/net/khirr/library/bottombar/BottomBarColors.kt b/library/src/main/java/net/khirr/library/bottombar/BottomBarColors.kt
new file mode 100644
index 0000000..38aa533
--- /dev/null
+++ b/library/src/main/java/net/khirr/library/bottombar/BottomBarColors.kt
@@ -0,0 +1,48 @@
+package net.khirr.library.bottombar
+
+import android.graphics.Color
+
+open class BottomBarColors {
+ internal var backgroundColor = Color.parseColor("#FFFFFF")
+ internal var selectedColor = Color.parseColor("#FF4081")
+ internal var unselectedColor = Color.parseColor("#757575")
+ internal var badgeColor = Color.parseColor("#FF4081")
+ internal var dividerColor = Color.parseColor("#dcdcdc")
+ internal var badgeStrokeColor = Color.parseColor("#FFFFFF")
+ internal var bottomDividerColor = Color.parseColor("#FF4081")
+
+ fun setBackgroundColor(color: Int): BottomBarColors {
+ backgroundColor = color
+ return this
+ }
+
+ fun setSelectedColor(color: Int): BottomBarColors {
+ selectedColor = color
+ return this
+ }
+
+ fun setUnselectedColor(color: Int): BottomBarColors {
+ unselectedColor = color
+ return this
+ }
+
+ fun setBadgeColor(color: Int): BottomBarColors {
+ badgeColor = color
+ return this
+ }
+
+ fun setDividerColor(color: Int): BottomBarColors {
+ dividerColor = color
+ return this
+ }
+
+ fun setBadgeStrokeColor(color: Int): BottomBarColors {
+ badgeStrokeColor = color
+ return this
+ }
+
+ fun setBottomDividerColor(color: Int): BottomBarColors {
+ bottomDividerColor = color
+ return this
+ }
+}
\ No newline at end of file
diff --git a/library/src/main/java/net/khirr/library/bottombar/MultipleFragmentManager.kt b/library/src/main/java/net/khirr/library/bottombar/MultipleFragmentManager.kt
index f750873..5d62dbf 100644
--- a/library/src/main/java/net/khirr/library/bottombar/MultipleFragmentManager.kt
+++ b/library/src/main/java/net/khirr/library/bottombar/MultipleFragmentManager.kt
@@ -1,8 +1,8 @@
package net.khirr.library.bottombar
-import android.support.v4.app.Fragment
-import android.support.v4.app.FragmentTransaction
-import android.support.v7.app.AppCompatActivity
+import androidx.fragment.app.Fragment
+import androidx.fragment.app.FragmentTransaction
+import androidx.appcompat.app.AppCompatActivity
/**
* @context Activity context
diff --git a/local.properties b/local.properties
new file mode 100644
index 0000000..3f7f762
--- /dev/null
+++ b/local.properties
@@ -0,0 +1,8 @@
+## This file must *NOT* be checked into Version Control Systems,
+# as it contains information specific to your local configuration.
+#
+# Location of the SDK. This is only used by Gradle.
+# For customization when using a Version Control System, please read the
+# header note.
+#Wed Jul 08 14:13:54 CEST 2020
+sdk.dir=/Users/khirr/Library/Android/sdk