diff --git a/README.md b/README.md index 9b8228c..db5c75c 100644 --- a/README.md +++ b/README.md @@ -51,9 +51,9 @@ Firstly, you should declare your view in xml file android:layout_width="0dp" android:layout_height="wrap_content" android:layout_margin="20dp" - app:backgroundCornerRadius="25dp" - app:backgroundColor="#2e2e2e" - app:itemInactiveBackgroundColor="#fff" + app:exb_backgroundCornerRadius="25dp" + app:exb_backgroundColor="#2e2e2e" + app:exb_itemInactiveBackgroundColor="#fff" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> @@ -99,20 +99,20 @@ Firstly, you should declare menu items in xml + app:exb_color="#FF8888" + app:exb_icon="@drawable/ic_home" /> + app:exb_color="@color/colorSettings" + app:exb_icon="@drawable/ic_settings" /> + app:exb_color="#fa2" + app:exb_icon="@drawable/ic_bookmarks" /> ``` @@ -135,9 +135,9 @@ Then you should reference this xml file at the view attributes android:layout_width="0dp" android:layout_height="wrap_content" android:layout_margin="20dp" - app:backgroundCornerRadius="25dp" - app:itemInactiveBackgroundColor="#fff" - app:items="@menu/bottom_bar" + app:exb_backgroundCornerRadius="25dp" + app:exb_itemInactiveBackgroundColor="#fff" + app:exb_items="@menu/bottom_bar" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> @@ -147,18 +147,18 @@ Then you should reference this xml file at the view attributes | property | type | description | | ----- | ----- | ----- | -| **elevation** | dimen | component elevation (important: api 21+) | -| **backgroundColor** | color | bottom bar background color | -| **transitionDuration** | integer | time between one item collapsed and another item expanded | -| **backgroundCornerRadius** | dimen | bottom bar background corners radius | -| **itemInactiveColor** | color | item menu color, when its inactive | -| **itemBackgroundCornerRadius** | dimen | item background corner radius | -| **itemBackgroundOpacity** | float | item background opacity (important: final color alpha calculates by next formulae alpha = opacity * 255) | -| **item_vertical_margin** | dimen | top & bottom item margins | -| **item_horizontal_margin** | dimen | left & right item margins | -| **item_vertical_padding** | dimen | top & bottom item padding | -| **item_horizontal_padding** | dimen | left & right item padding | -| **items** | reference | xml supported menu format | +| **exb_elevation** | dimen | component elevation (important: api 21+) | +| **exb_backgroundColor** | color | bottom bar background color | +| **exb_transitionDuration** | integer | time between one item collapsed and another item expanded | +| **exb_backgroundCornerRadius** | dimen | bottom bar background corners radius | +| **exb_itemInactiveColor** | color | item menu color, when its inactive | +| **exb_itemBackgroundCornerRadius** | dimen | item background corner radius | +| **exb_itemBackgroundOpacity** | float | item background opacity (important: final color alpha calculates by next formulae alpha = opacity * 255) | +| **exb_item_vertical_margin** | dimen | top & bottom item margins | +| **exb_item_horizontal_margin** | dimen | left & right item margins | +| **exb_item_vertical_padding** | dimen | top & bottom item padding | +| **exb_item_horizontal_padding** | dimen | left & right item padding | +| **exb_items** | reference | xml supported menu format | ## Coordinator Layout support diff --git a/app/src/main/res/layout/activity_coordinator_layout.xml b/app/src/main/res/layout/activity_coordinator_layout.xml index aed62a3..b1f04ac 100644 --- a/app/src/main/res/layout/activity_coordinator_layout.xml +++ b/app/src/main/res/layout/activity_coordinator_layout.xml @@ -20,6 +20,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" - app:items="@menu/bottom_bar" /> + app:exb_items="@menu/bottom_bar" /> diff --git a/app/src/main/res/layout/activity_java.xml b/app/src/main/res/layout/activity_java.xml index 0b7a1c5..0e10f27 100644 --- a/app/src/main/res/layout/activity_java.xml +++ b/app/src/main/res/layout/activity_java.xml @@ -12,9 +12,9 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_margin="20dp" - app:backgroundCornerRadius="25dp" - app:backgroundColor="#2e2e2e" - app:itemInactiveColor="#fff" + app:exb_backgroundCornerRadius="25dp" + app:exb_backgroundColor="#2e2e2e" + app:exb_itemInactiveColor="#fff" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> diff --git a/app/src/main/res/layout/activity_programmatically_declared.xml b/app/src/main/res/layout/activity_programmatically_declared.xml index 924b073..ceb68f5 100644 --- a/app/src/main/res/layout/activity_programmatically_declared.xml +++ b/app/src/main/res/layout/activity_programmatically_declared.xml @@ -16,9 +16,9 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_margin="20dp" - app:backgroundCornerRadius="25dp" - app:backgroundColor="#2e2e2e" - app:itemInactiveColor="#fff" + app:exb_backgroundCornerRadius="25dp" + app:exb_backgroundColor="#2e2e2e" + app:exb_itemInactiveColor="#fff" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> diff --git a/app/src/main/res/layout/activity_scrollable_coordinator_layout.xml b/app/src/main/res/layout/activity_scrollable_coordinator_layout.xml index fc2ffb8..08c6b54 100644 --- a/app/src/main/res/layout/activity_scrollable_coordinator_layout.xml +++ b/app/src/main/res/layout/activity_scrollable_coordinator_layout.xml @@ -27,6 +27,6 @@ android:layout_height="wrap_content" android:layout_gravity="bottom" app:layout_behavior="github.com.st235.lib_expandablebottombar.behavior.ExpandableBottomBarScrollableBehavior" - app:items="@menu/bottom_bar" /> + app:exb_items="@menu/bottom_bar" /> diff --git a/app/src/main/res/layout/activity_xml_declared.xml b/app/src/main/res/layout/activity_xml_declared.xml index f0f6396..4b65364 100644 --- a/app/src/main/res/layout/activity_xml_declared.xml +++ b/app/src/main/res/layout/activity_xml_declared.xml @@ -15,7 +15,7 @@ android:id="@+id/expandable_bottom_bar" android:layout_width="0dp" android:layout_height="wrap_content" - app:items="@menu/bottom_bar" + app:exb_items="@menu/bottom_bar" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> diff --git a/app/src/main/res/menu/bottom_bar.xml b/app/src/main/res/menu/bottom_bar.xml index 35e3c7b..633399d 100644 --- a/app/src/main/res/menu/bottom_bar.xml +++ b/app/src/main/res/menu/bottom_bar.xml @@ -3,18 +3,18 @@ + app:exb_color="#FF8888" + app:exb_icon="@drawable/ic_home" /> + app:exb_color="@color/colorSettings" + app:exb_icon="@drawable/ic_settings" /> + app:exb_color="#fa2" + app:exb_icon="@drawable/ic_bookmarks" /> \ No newline at end of file diff --git a/build.gradle b/build.gradle index 0178321..12b55ff 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ buildscript { - ext.kotlin_version = '1.3.30' + ext.kotlin_version = '1.3.41' + repositories { google() jcenter() diff --git a/lib-expandablebottombar/build.gradle b/lib-expandablebottombar/build.gradle index 129ea7e..d48c890 100644 --- a/lib-expandablebottombar/build.gradle +++ b/lib-expandablebottombar/build.gradle @@ -16,7 +16,7 @@ publish { userOrg = 'st235' groupId = 'com.github.st235' artifactId = 'expandablebottombar' - publishVersion = '1.0.1' + publishVersion = '1.1.0' desc = 'A new way to improve navigation in your app.' website = 'https://github.com/st235/ExpandableBottomBar' } @@ -26,13 +26,13 @@ androidExtensions { } android { - compileSdkVersion 28 + compileSdkVersion 29 defaultConfig { minSdkVersion 19 - targetSdkVersion 28 - versionCode 21 - versionName "1.0.1" + targetSdkVersion 29 + versionCode 23 + versionName "1.1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -55,7 +55,7 @@ android { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'com.google.android.material:material:1.0.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' diff --git a/lib-expandablebottombar/src/main/java/github/com/st235/lib_expandablebottombar/ExpandableBottomBar.kt b/lib-expandablebottombar/src/main/java/github/com/st235/lib_expandablebottombar/ExpandableBottomBar.kt index 187c5ae..34ab19e 100644 --- a/lib-expandablebottombar/src/main/java/github/com/st235/lib_expandablebottombar/ExpandableBottomBar.kt +++ b/lib-expandablebottombar/src/main/java/github/com/st235/lib_expandablebottombar/ExpandableBottomBar.kt @@ -29,10 +29,10 @@ internal const val ITEM_NOT_SELECTED = -1 typealias OnItemClickListener = (v: View, menuItem: ExpandableBottomBarMenuItem) -> Unit /** - * Widget, which implements bottom bar navigation pattern xyn + * Widget, which implements bottom bar navigation pattern */ class ExpandableBottomBar @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = R.attr.expandableButtonBarDefaultStyle + context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = R.attr.exb_expandableButtonBarDefaultStyle ) : ConstraintLayout(context, attrs, defStyleAttr), CoordinatorLayout.AttachedBehavior { @FloatRange(from = 0.0, to = 1.0) private var backgroundOpacity: Float = 0F @@ -76,26 +76,26 @@ class ExpandableBottomBar @JvmOverloads constructor( val typedArray = context.obtainStyledAttributes(attrs, R.styleable.ExpandableBottomBar, defStyleAttr, R.style.ExpandableBottomBar) - backgroundOpacity = typedArray.getFloat(R.styleable.ExpandableBottomBar_itemBackgroundOpacity, 0.2F) - backgroundCornerRadius = typedArray.getDimension(R.styleable.ExpandableBottomBar_itemBackgroundCornerRadius, 30F.toPx()) - transitionDuration = typedArray.getInt(R.styleable.ExpandableBottomBar_transitionDuration, 100) - itemInactiveColor = typedArray.getColor(R.styleable.ExpandableBottomBar_itemInactiveColor, Color.BLACK) - menuItemHorizontalMargin = typedArray.getDimension(R.styleable.ExpandableBottomBar_item_horizontal_margin, 5F.toPx()).toInt() - menuItemVerticalMargin = typedArray.getDimension(R.styleable.ExpandableBottomBar_item_vertical_margin, 5F.toPx()).toInt() - menuHorizontalPadding = typedArray.getDimension(R.styleable.ExpandableBottomBar_item_horizontal_padding, 15F.toPx()).toInt() - menuVerticalPadding = typedArray.getDimension(R.styleable.ExpandableBottomBar_item_vertical_padding, 10F.toPx()).toInt() + backgroundOpacity = typedArray.getFloat(R.styleable.ExpandableBottomBar_exb_itemBackgroundOpacity, 0.2F) + backgroundCornerRadius = typedArray.getDimension(R.styleable.ExpandableBottomBar_exb_itemBackgroundCornerRadius, 30F.toPx()) + transitionDuration = typedArray.getInt(R.styleable.ExpandableBottomBar_exb_transitionDuration, 100) + itemInactiveColor = typedArray.getColor(R.styleable.ExpandableBottomBar_exb_itemInactiveColor, Color.BLACK) + menuItemHorizontalMargin = typedArray.getDimension(R.styleable.ExpandableBottomBar_exb_item_horizontal_margin, 5F.toPx()).toInt() + menuItemVerticalMargin = typedArray.getDimension(R.styleable.ExpandableBottomBar_exb_item_vertical_margin, 5F.toPx()).toInt() + menuHorizontalPadding = typedArray.getDimension(R.styleable.ExpandableBottomBar_exb_item_horizontal_padding, 15F.toPx()).toInt() + menuVerticalPadding = typedArray.getDimension(R.styleable.ExpandableBottomBar_exb_item_vertical_padding, 10F.toPx()).toInt() - val backgroundColor = typedArray.getColor(R.styleable.ExpandableBottomBar_backgroundColor, Color.WHITE) - val backgroundCornerRadius = typedArray.getDimension(R.styleable.ExpandableBottomBar_backgroundCornerRadius, 0F) + val backgroundColor = typedArray.getColor(R.styleable.ExpandableBottomBar_exb_backgroundColor, Color.WHITE) + val backgroundCornerRadius = typedArray.getDimension(R.styleable.ExpandableBottomBar_exb_backgroundCornerRadius, 0F) background = DrawableHelper.createShapeDrawable(backgroundColor, backgroundCornerRadius, 1.0F) applyForApiLAndHigher { - elevation = typedArray.getDimension(R.styleable.ExpandableBottomBar_elevation, 16F.toPx()) + elevation = typedArray.getDimension(R.styleable.ExpandableBottomBar_exb_elevation, 16F.toPx()) } - val menuId = typedArray.getResourceId(R.styleable.ExpandableBottomBar_items, View.NO_ID) + val menuId = typedArray.getResourceId(R.styleable.ExpandableBottomBar_exb_items, View.NO_ID) if (menuId != View.NO_ID) { val barParser = ExpandableBottomBarParser(context) val items = barParser.inflate(menuId) diff --git a/lib-expandablebottombar/src/main/java/github/com/st235/lib_expandablebottombar/parsers/ExpandableBottomBarParser.kt b/lib-expandablebottombar/src/main/java/github/com/st235/lib_expandablebottombar/parsers/ExpandableBottomBarParser.kt index ca592ec..2339d7a 100644 --- a/lib-expandablebottombar/src/main/java/github/com/st235/lib_expandablebottombar/parsers/ExpandableBottomBarParser.kt +++ b/lib-expandablebottombar/src/main/java/github/com/st235/lib_expandablebottombar/parsers/ExpandableBottomBarParser.kt @@ -77,8 +77,8 @@ internal class ExpandableBottomBarParser(private val context: Context) { val typedArray = context.obtainStyledAttributes(attrs, R.styleable.ExpandableBottomBarItem) val id = typedArray.getResourceId(R.styleable.ExpandableBottomBarItem_android_id, NO_ID) - val iconId = typedArray.getResourceId(R.styleable.ExpandableBottomBarItem_icon, NO_ID) - val color = typedArray.getColor(R.styleable.ExpandableBottomBarItem_color, NO_COLOR) + val iconId = typedArray.getResourceId(R.styleable.ExpandableBottomBarItem_exb_icon, NO_ID) + val color = typedArray.getColor(R.styleable.ExpandableBottomBarItem_exb_color, NO_COLOR) val text = typedArray.getString(R.styleable.ExpandableBottomBarItem_android_title) ?: NO_TEXT typedArray.recycle() diff --git a/lib-expandablebottombar/src/main/res/values-v21/styles.xml b/lib-expandablebottombar/src/main/res/values-v21/styles.xml index fb22bf5..9adc586 100644 --- a/lib-expandablebottombar/src/main/res/values-v21/styles.xml +++ b/lib-expandablebottombar/src/main/res/values-v21/styles.xml @@ -1,15 +1,15 @@ \ No newline at end of file diff --git a/lib-expandablebottombar/src/main/res/values/attrs.xml b/lib-expandablebottombar/src/main/res/values/attrs.xml index 9fde291..4314338 100644 --- a/lib-expandablebottombar/src/main/res/values/attrs.xml +++ b/lib-expandablebottombar/src/main/res/values/attrs.xml @@ -3,26 +3,26 @@ - - + + - - - - - - - + + + + + + + - - - - + + + + - + - + \ No newline at end of file diff --git a/lib-expandablebottombar/src/main/res/values/styles.xml b/lib-expandablebottombar/src/main/res/values/styles.xml index fb22bf5..9adc586 100644 --- a/lib-expandablebottombar/src/main/res/values/styles.xml +++ b/lib-expandablebottombar/src/main/res/values/styles.xml @@ -1,15 +1,15 @@ \ No newline at end of file