From 18f829040653fbee31337d4634c3e0005f87f4bd Mon Sep 17 00:00:00 2001 From: Iiro Krankka Date: Thu, 13 Apr 2017 23:49:12 +0300 Subject: [PATCH] v2.3.1 (#751) * Bug fix/shadow not respecting flag (#749) * Data binding fixes clean (#712) * Fix Bottom Bar issues with Android Data Binding * keep .idea * travis changes * Fix for shadow (#716) * - Removing the view for API 21 - Adding a negative margin for API 20 or less so that the content is overlapped with the shadow - Fix the annotation for the MiscUtils * - Removing the view for API 21 - Adding a negative margin for API 20 or less so that the content is overlapped with the shadow - Fix the annotation for the MiscUtils * - Removing the view for API 21 - Adding a negative margin for API 20 or less so that the content is overlapped with the shadow - Fix the annotation for the MiscUtils * SelectableItemBackground Ripple! (#713) * Add selectableItemBackground programmatically which shows user touch response with either ripple or slight change of colour if below lollipop. * Remove style in tablet mode which makes ripple go out of bounds. Without it ripple is contained within its view. * Remove unnecessary local reference. * Added getTypedValue and getDrawableRes methods in MiscUtils and changed to selectableItemBackgroundBorderless. * Change color to resId. * Fix for wrong size in tabs - Setting the modified LayoutParams so that the views are changed (#719) * Tabs without titles (#717) * Update CHANGELOG.md * Update README.md * Update README.md * Basic support for tabs that have no title, only icons. * Reverted debug code. * Made sure that icon-only tabs throw an exception if they don't have icons. * There's no need to set visibility to the title, as it's already visible. * Added a sample for the icons only mode. * Made the titleless mode combined with shifting mode work. * Removed the eight dp padding from XML layout, since that offsets titleless tab icons from the center & isn't needed anyway since it's set dynamically. * Added some zoom to active tab icons that are both shifting and titleless. * Cleared up the select & unselect methods. * Modified the color changing tabs sample height, so it looks less crammed and more like the design specs. * Show & Hide methods when on shy mode. (#722) * Added methods for showing / hiding the BottomBar when on shy mode. * Better naming. * Refactored the hide / show methods to a separate ShySettings class, since they were only related for a shy BottomBar. * Made getting shy settings not throw an exception when the bottombar isn't shy, but have a log warning instead. * Made it possible to have individual titleless tabs. (#726) * Feature/optional long press toasts (#714) * Update CHANGELOG.md * Update README.md * Update README.md * Made it possible to control whether or not the Toasts are shown when long pressing tabs. * Updated changelog. * - Fix for shadow not respecting flag - API 21+ was not using the flag at all - API 20- where not removing the margin when no shadow was displayed - API 20- set the default visibility of the shadow to GONE * Bumped up version numbers & updated changelog for new release. --- CHANGELOG.md | 10 +++ README.md | 4 +- bottom-bar/build.gradle | 2 +- .../com/roughike/bottombar/BottomBar.java | 69 +++++++++++-------- .../layout/bb_bottom_bar_item_container.xml | 7 +- build.gradle | 2 +- 6 files changed, 58 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57a43657..1e35d583 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Changelog +### 2.3.1 + +* [#749](https://github.com/roughike/BottomBar/pull/749): Quick fix for the issue where *bb_showShadow* set to false didn't have any effect. Thanks @yombunker! + ### 2.3.0 * [#713](https://github.com/roughike/BottomBar/pull/713): Ripple touch feedback for tabs! @@ -24,6 +28,12 @@ Thanks for @yombunker, @MarcRubio and @tushar-acharya for their contributions! * Overriding tab selections is now supported, by using [TabSelectionInterceptor](https://github.com/roughike/BottomBar/blob/master/bottom-bar/src/main/java/com/roughike/bottombar/TabSelectionInterceptor.java) * Internal code quality improvements and small changes +### 2.2.0 + +* Ability to change icons when the tabs are selected, using drawable selectors +* Overriding tab selections is now supported, by using [TabSelectionInterceptor](https://github.com/roughike/BottomBar/blob/master/bottom-bar/src/main/java/com/roughike/bottombar/TabSelectionInterceptor.java) +* Internal code quality improvements and small changes + ### 2.1.2 * Merged [#703](https://github.com/roughike/BottomBar/pull/703) that allows controlling badge visibility for tabs that are active. diff --git a/README.md b/README.md index cbad3755..630ca9b0 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Nope. The minSDK version is **API level 11 (Honeycomb).** ## Gimme that Gradle sweetness, pls? ```groovy -compile 'com.roughike:bottom-bar:2.3.0' +compile 'com.roughike:bottom-bar:2.3.1' ``` **Maven:** @@ -37,7 +37,7 @@ compile 'com.roughike:bottom-bar:2.3.0' com.roughike bottom-bar - 2.3.0 + 2.3.1 pom ``` diff --git a/bottom-bar/build.gradle b/bottom-bar/build.gradle index 571624a2..4be58ab1 100644 --- a/bottom-bar/build.gradle +++ b/bottom-bar/build.gradle @@ -14,7 +14,7 @@ ext { siteUrl = 'https://github.com/roughike/BottomBar' gitUrl = 'https://github.com/roughike/BottomBar.git' - libraryVersion = '2.3.0' + libraryVersion = '2.3.1' developerId = 'roughike' developerName = 'Iiro Krankka' diff --git a/bottom-bar/src/main/java/com/roughike/bottombar/BottomBar.java b/bottom-bar/src/main/java/com/roughike/bottombar/BottomBar.java index faa07b16..350cc316 100644 --- a/bottom-bar/src/main/java/com/roughike/bottombar/BottomBar.java +++ b/bottom-bar/src/main/java/com/roughike/bottombar/BottomBar.java @@ -83,6 +83,7 @@ public class BottomBar extends LinearLayout implements View.OnClickListener, Vie private Typeface titleTypeFace; private boolean showShadow; private float shadowElevation; + private View shadowView; private View backgroundOverlay; private ViewGroup outerContainer; @@ -153,7 +154,8 @@ protected void onAttachedToWindow() { super.onAttachedToWindow(); // This is so that in Pre-Lollipop devices there is a shadow BUT without pushing the content - if (showShadow) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && showShadow && shadowView != null) { + shadowView.setVisibility(VISIBLE); ViewGroup.LayoutParams params = getLayoutParams(); if (params instanceof MarginLayoutParams) { MarginLayoutParams layoutParams = (MarginLayoutParams) params; @@ -170,12 +172,14 @@ protected void onAttachedToWindow() { @RequiresApi(Build.VERSION_CODES.LOLLIPOP) private void init21(Context context) { - shadowElevation = getElevation(); - shadowElevation = shadowElevation > 0 - ? shadowElevation - : getResources().getDimensionPixelSize(R.dimen.bb_default_elevation); - setElevation(MiscUtils.dpToPixel(context, shadowElevation)); - setOutlineProvider(ViewOutlineProvider.BOUNDS); + if (showShadow) { + shadowElevation = getElevation(); + shadowElevation = shadowElevation > 0 + ? shadowElevation + : getResources().getDimensionPixelSize(R.dimen.bb_default_elevation); + setElevation(MiscUtils.dpToPixel(context, shadowElevation)); + setOutlineProvider(ViewOutlineProvider.BOUNDS); + } } private void populateAttributes(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { @@ -184,7 +188,8 @@ private void populateAttributes(Context context, AttributeSet attrs, int defStyl tenDp = MiscUtils.dpToPixel(getContext(), 10); maxFixedItemWidth = MiscUtils.dpToPixel(getContext(), 168); - TypedArray ta = context.getTheme().obtainStyledAttributes(attrs, R.styleable.BottomBar, defStyleAttr, defStyleRes); + TypedArray ta = context.getTheme() + .obtainStyledAttributes(attrs, R.styleable.BottomBar, defStyleAttr, defStyleRes); try { tabXmlResource = ta.getResourceId(R.styleable.BottomBar_bb_tabXmlResource, 0); @@ -230,7 +235,9 @@ boolean isShyHeightAlreadyCalculated() { return shyHeightAlreadyCalculated; } - private boolean isIconsOnlyMode() { return !isTabletMode && hasBehavior(BEHAVIOR_ICONS_ONLY); } + private boolean isIconsOnlyMode() { + return !isTabletMode && hasBehavior(BEHAVIOR_ICONS_ONLY); + } private boolean hasBehavior(int behavior) { return (behaviors | behavior) == behaviors; @@ -260,6 +267,7 @@ private void initializeViews() { backgroundOverlay = rootView.findViewById(R.id.bb_bottom_bar_background_overlay); outerContainer = (ViewGroup) rootView.findViewById(R.id.bb_bottom_bar_outer_container); tabContainer = (ViewGroup) rootView.findViewById(R.id.bb_bottom_bar_item_container); + shadowView = findViewById(R.id.bb_bottom_bar_shadow); } private void determineInitialBackgroundColor() { @@ -386,7 +394,8 @@ private void resizeTabsToCorrectSizes(BottomBarTab[] tabsToAdd) { inActiveShiftingItemWidth = (int) (proposedItemWidth * 0.9); activeShiftingItemWidth = (int) (proposedItemWidth + (proposedItemWidth * ((tabsToAdd.length - 1) * 0.1))); - int height = Math.round(getContext().getResources().getDimension(R.dimen.bb_height)); + int height = Math.round(getContext().getResources() + .getDimension(R.dimen.bb_height)); for (BottomBarTab tabView : tabsToAdd) { ViewGroup.LayoutParams params = tabView.getLayoutParams(); @@ -925,7 +934,8 @@ private boolean handleLongClick(BottomBarTab longClickedTab) { && longPressHintsEnabled; if (shouldShowHint) { - Toast.makeText(getContext(), longClickedTab.getTitle(), Toast.LENGTH_SHORT).show(); + Toast.makeText(getContext(), longClickedTab.getTitle(), Toast.LENGTH_SHORT) + .show(); } return true; @@ -1044,23 +1054,24 @@ private void onEnd() { private void backgroundCrossfadeAnimation(final int newColor) { ViewCompat.setAlpha(backgroundOverlay, 0); ViewCompat.animate(backgroundOverlay) - .alpha(1) - .setListener(new ViewPropertyAnimatorListenerAdapter() { - @Override - public void onAnimationEnd(View view) { - onEnd(); - } - - @Override - public void onAnimationCancel(View view) { - onEnd(); - } - - private void onEnd() { - outerContainer.setBackgroundColor(newColor); - backgroundOverlay.setVisibility(View.INVISIBLE); - ViewCompat.setAlpha(backgroundOverlay, 1); - } - }).start(); + .alpha(1) + .setListener(new ViewPropertyAnimatorListenerAdapter() { + @Override + public void onAnimationEnd(View view) { + onEnd(); + } + + @Override + public void onAnimationCancel(View view) { + onEnd(); + } + + private void onEnd() { + outerContainer.setBackgroundColor(newColor); + backgroundOverlay.setVisibility(View.INVISIBLE); + ViewCompat.setAlpha(backgroundOverlay, 1); + } + }) + .start(); } } diff --git a/bottom-bar/src/main/res/layout/bb_bottom_bar_item_container.xml b/bottom-bar/src/main/res/layout/bb_bottom_bar_item_container.xml index ef8f7b6e..4c742a4a 100644 --- a/bottom-bar/src/main/res/layout/bb_bottom_bar_item_container.xml +++ b/bottom-bar/src/main/res/layout/bb_bottom_bar_item_container.xml @@ -5,7 +5,8 @@ android:id="@+id/bb_bottom_bar_shadow" android:layout_width="match_parent" android:layout_height="@dimen/bb_fake_shadow_height" - android:background="@drawable/bb_bottom_bar_top_shadow" /> + android:background="@drawable/bb_bottom_bar_top_shadow" + android:visibility="gone"/> + android:visibility="invisible"/> + android:orientation="horizontal"/> diff --git a/build.gradle b/build.gradle index ed7d94f6..9fdfa3a9 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.0' + classpath 'com.android.tools.build:gradle:2.3.1' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.4.0'