Skip to content

Commit

Permalink
Upgrade to AndroidX & Added Custom Colors class
Browse files Browse the repository at this point in the history
  • Loading branch information
khirr committed Jul 8, 2020
1 parent 56cddb1 commit 017be3b
Show file tree
Hide file tree
Showing 15 changed files with 139 additions and 117 deletions.
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
}
```

Expand All @@ -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();
```

Expand Down
18 changes: 8 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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"
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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();


Expand Down
10 changes: 5 additions & 5 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@
android:id="@+id/bottomBarView"
android:layout_alignParentBottom="true"/>

<android.support.design.widget.CoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_above="@id/bottomBarView"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"
app:elevation="0dp">

<android.support.v7.widget.Toolbar
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:layout_scrollFlags="scroll|enterAlways"/>

</android.support.design.widget.AppBarLayout>
</com.google.android.material.appbar.AppBarLayout>

<include layout="@layout/content_main" />

</android.support.design.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

</RelativeLayout>
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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'

Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
13 changes: 5 additions & 8 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Loading

0 comments on commit 017be3b

Please sign in to comment.