Repository: roughike/BottomBar Branch: master Commit: 885d70e62359 Files: 105 Total size: 576.4 KB Directory structure: gitextract_7tzdrylq/ ├── .gitignore ├── .idea/ │ ├── .name │ ├── compiler.xml │ ├── copyright/ │ │ └── profiles_settings.xml │ ├── encodings.xml │ ├── gradle.xml │ ├── kotlinc.xml │ ├── markdown-exported-files.xml │ ├── markdown-navigator/ │ │ └── profiles_settings.xml │ ├── markdown-navigator.xml │ ├── misc.xml │ ├── modules.xml │ ├── runConfigurations/ │ │ └── All_Tests.xml │ ├── runConfigurations.xml │ └── vcs.xml ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── NOTICE ├── README.md ├── app/ │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── assets/ │ │ └── fonts/ │ │ ├── GREAT-VIBES-LICENSE │ │ └── GreatVibes-Regular.otf │ ├── java/ │ │ └── com/ │ │ └── example/ │ │ └── bottombar/ │ │ └── sample/ │ │ ├── BadgeActivity.java │ │ ├── CustomColorAndFontActivity.java │ │ ├── FiveColorChangingTabsActivity.java │ │ ├── IconsOnlyActivity.java │ │ ├── MainActivity.java │ │ ├── SampleFragment.java │ │ ├── TabMessage.java │ │ ├── ThreeTabsActivity.java │ │ └── ThreeTabsQRActivity.java │ └── res/ │ ├── layout/ │ │ ├── activity_color_changing_tabs.xml │ │ ├── activity_custom_color_and_font.xml │ │ ├── activity_icons_only.xml │ │ ├── activity_main.xml │ │ ├── activity_three_tabs.xml │ │ └── activity_three_tabs_quick_return.xml │ ├── layout-sw600dp/ │ │ ├── activity_color_changing_tabs.xml │ │ └── activity_three_tabs.xml │ ├── values/ │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ ├── values-land-v21/ │ │ └── styles.xml │ ├── values-sw600dp/ │ │ └── styles.xml │ ├── values-v21/ │ │ └── styles.xml │ ├── values-w820dp/ │ │ └── dimens.xml │ └── xml/ │ ├── bottombar_tabs_color_changing.xml │ ├── bottombar_tabs_five.xml │ └── bottombar_tabs_three.xml ├── bottom-bar/ │ ├── build.gradle │ └── src/ │ ├── androidTest/ │ │ ├── assets/ │ │ │ └── fonts/ │ │ │ ├── GREAT-VIBES-LICENSE │ │ │ └── GreatVibes-Regular.otf │ │ ├── java/ │ │ │ └── com/ │ │ │ └── roughike/ │ │ │ └── bottombar/ │ │ │ ├── BadgeTest.java │ │ │ ├── BottomBarTabTest.java │ │ │ ├── BottomBarTest.java │ │ │ └── TabParserTest.java │ │ └── res/ │ │ ├── values/ │ │ │ ├── colors.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── xml/ │ │ ├── dummy_tabs_five.xml │ │ └── dummy_tabs_three.xml │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── roughike/ │ │ │ └── bottombar/ │ │ │ ├── BadgeCircle.java │ │ │ ├── BadgeContainer.java │ │ │ ├── BatchTabPropertyApplier.java │ │ │ ├── BottomBar.java │ │ │ ├── BottomBarBadge.java │ │ │ ├── BottomBarTab.java │ │ │ ├── BottomNavigationBehavior.java │ │ │ ├── MiscUtils.java │ │ │ ├── NavbarUtils.java │ │ │ ├── OnTabReselectListener.java │ │ │ ├── OnTabSelectListener.java │ │ │ ├── ShySettings.java │ │ │ ├── TabParser.java │ │ │ ├── TabSelectionInterceptor.java │ │ │ └── VerticalScrollingBehavior.java │ │ └── res/ │ │ ├── drawable/ │ │ │ └── bb_bottom_bar_top_shadow.xml │ │ ├── layout/ │ │ │ ├── bb_bottom_bar_item_container.xml │ │ │ ├── bb_bottom_bar_item_container_tablet.xml │ │ │ ├── bb_bottom_bar_item_fixed.xml │ │ │ ├── bb_bottom_bar_item_fixed_tablet.xml │ │ │ ├── bb_bottom_bar_item_shifting.xml │ │ │ └── bb_bottom_bar_item_titleless.xml │ │ ├── layout-v21/ │ │ │ └── bb_bottom_bar_item_container.xml │ │ ├── values/ │ │ │ ├── attrs.xml │ │ │ ├── bools.xml │ │ │ ├── colors.xml │ │ │ ├── dimensions.xml │ │ │ ├── ids.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── values-land/ │ │ └── bools.xml │ └── test/ │ └── java/ │ └── com/ │ └── roughike/ │ └── bottombar/ │ └── ExampleUnitTest.java ├── build.gradle ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── projectFilesBackup/ │ └── .idea/ │ └── workspace.xml └── settings.gradle ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ # Built application files *.apk *.ap_ # Files for the ART/Dalvik VM *.dex # Java class files *.class # Generated files bin/ gen/ out/ # Gradle files .gradle/ build/ # Local configuration file (sdk path, etc) local.properties # Proguard folder generated by Eclipse proguard/ # Log Files *.log # Android Studio Navigation editor temp files .navigation/ # Android Studio captures folder captures/ # Intellij *.iml .idea/workspace.xml .idea/libraries # Keystore files *.jks ================================================ FILE: .idea/.name ================================================ BottomBar ================================================ FILE: .idea/compiler.xml ================================================ ================================================ FILE: .idea/copyright/profiles_settings.xml ================================================ ================================================ FILE: .idea/encodings.xml ================================================ ================================================ FILE: .idea/gradle.xml ================================================ ================================================ FILE: .idea/kotlinc.xml ================================================ ================================================ FILE: .idea/markdown-exported-files.xml ================================================ ================================================ FILE: .idea/markdown-navigator/profiles_settings.xml ================================================ ================================================ FILE: .idea/markdown-navigator.xml ================================================ ================================================ FILE: .idea/misc.xml ================================================ ================================================ FILE: .idea/modules.xml ================================================ ================================================ FILE: .idea/runConfigurations/All_Tests.xml ================================================ ================================================ FILE: .idea/runConfigurations.xml ================================================ ================================================ FILE: .idea/vcs.xml ================================================ ================================================ FILE: .travis.yml ================================================ language: android jdk: oraclejdk8 android: components: - tools - platform-tools - build-tools-25.0.2 - android-25 - extra-android-m2repository before_script: - echo no | android create avd --force -n test -t android-18 --abi armeabi-v7a - emulator -avd test -no-audio -no-window & - android-wait-for-emulator - adb shell input keyevent 82 & script: - ./gradlew connectedAndroidTest coveralls ================================================ FILE: CHANGELOG.md ================================================ ## 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! * [#716](https://github.com/roughike/BottomBar/pull/716): Bugfix for misbehaving shadow. No more weird white spaces above the bar! * [#717](https://github.com/roughike/BottomBar/pull/717): Support for tabs with icons only, without titles! * [#722](https://github.com/roughike/BottomBar/pull/722): Showing / hiding the BottomBar when on shy mode. * [#714](https://github.com/roughike/BottomBar/pull/714): Controlling whether Toasts of tab titles are shown when long pressing tabs. * [#719](https://github.com/roughike/BottomBar/pull/719): Fix for wrong size in tabs * [#712](https://github.com/roughike/BottomBar/pull/712): Data binding fixes. Thanks for @yombunker, @MarcRubio and @tushar-acharya for their contributions! ### 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.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.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. ### 2.1.1 * A quick fix for a really critical bug that could affect some devices. More specifically, [this one.](https://github.com/roughike/BottomBar/issues/625) ### 2.1.0 * Fixed a bug in the Badge positioning, causing the Badges to clip when there was many tabs. * Fixed a bug where the lower portion of unselected titles were clipped off in fixed mode. * Made changes to Badge restoration logic to fix [445](https://github.com/roughike/BottomBar/issues/445). Credit goes to [@Kevinrob](https://github.com/Kevinrob) for reporting and helping to reproduce the issue. * Fixed [#448](https://github.com/roughike/BottomBar/issues/448), [#471](https://github.com/roughike/BottomBar/issues/471), [#436](https://github.com/roughike/BottomBar/issues/436) and [#591](https://github.com/roughike/BottomBar/issues/591) * Fixed a faulty behavior where the tabs' widths were calculated according to phone screen width, but should've been calculated according to the parent view's width by merging [#504](https://github.com/roughike/BottomBar/pull/504) * Optimized the tab resizing calculations; now the tabs aren't needlessly removed and readded, only the layout params get changed. * Merged [#468](https://github.com/roughike/BottomBar/pull/468) and [#457](https://github.com/roughike/BottomBar/pull/457) * Fixed [#554](https://github.com/roughike/BottomBar/issues/554) by merging [#512](https://github.com/roughike/BottomBar/pull/512). * Made most of the BottomBarTab methods public. ### 2.0.2 * Now we're animating the color change on tab titles and icons. * Fixed a bug where the BottomBar wouldn't hide completely when it was both shy and drawing under navbar. * Made possible to inflate the BottomBar programmatically. * Made it possible to control whether the shadow is shown or not. * Made setItems to be public to allow writing tests without a designated Activity * Made setters for allowing setting tab colors, alphas, textappearances and typefaces programmatically. * Increased test coverage a little bit. ### 2.0.1 * Fixed a bug where the tab selection listener is set and multiple tabs could be selected at once * Fixed a bug where the reselection listener was fired even it shouldn't have. ### 2.0 * Cleaner code and better APIs * No more unnecessary stuff or spaghetti mess * Now the look, feel and behavior is defined in XML, as it should be * No more nasty regressions, thanks to the automated tests * **Everything is a little different compared to earlier, but it's for the greater good!** See the readme for how to use the new version. ### 1.4.0.1 * Merged a [PR that fixes removing all tabs from BottomBar](https://github.com/roughike/BottomBar/pull/339) ### 1.4.0 * Started writing some tests. **Contributions more than welcome**, as I'm still a noob when it comes to testing. * Merged a [PR that adds support for vector drawables](https://github.com/roughike/BottomBar/pull/280) * Merged a [PR that adds support for disabling text scale animation](https://github.com/roughike/BottomBar/pull/298) * Merged a [PR that adds support for custom background and tab icon colors, and also custom alpha](https://github.com/roughike/BottomBar/pull/302) * Merged a [PR that fixes wrong method name for message shown by an exception](https://github.com/roughike/BottomBar/pull/320) ### 1.3.9 * Merged [another PR that should get rid of the infinite Badge loop for good](https://github.com/roughike/BottomBar/pull/289). ### 1.3.8 * Merged a [PR that fixes infinite loop caused by a layout listener when adding Badges.](https://github.com/roughike/BottomBar/pull/286) ### 1.3.7 * Merged a [PR that fixes elliptical Badges](https://github.com/roughike/BottomBar/pull/275). * Fixed issues [#276](https://github.com/roughike/BottomBar/issues/276) and [#277](https://github.com/roughike/BottomBar/issues/277) ### 1.3.6 * Fixed a bug that would cause the navigation bar to not be transparent. * Flattened View hierarchy. * Throwing a nice little Exception if someone tries to call ```noResizeGoodness()``` improperly, instead of just failing silently. ### 1.3.5 * [Merged](https://github.com/roughike/BottomBar/pull/260) [some](https://github.com/roughike/BottomBar/pull/268) [pull](https://github.com/roughike/BottomBar/pull/269) [requests.](https://github.com/roughike/BottomBar/pull/271) * Thanks to @henhal, now the unselection bug when using badges is fixed. * Deprecated the ```setItemsFromMenu(@MenuRes int resId, OnMenuTabClickListener listener)``` method in favor of two separate methods: ```mBottomBar.setItems(@MenuRes int resId)``` and ```mBottomBar.setOnMenuTabClickListener(OnMenuTabClickListener listener)```. Not only because deprecating stuff is so fun (it is), but because this actually makes more sense than the old approach. The old approach still works. ### 1.3.4 * Now the BottomBar is 56dp tall, as it should be! Make sure your icons are 24dp and **trimmed**, meaning that the whole png size musn't be more than 24dp. So **don't use padding** around the icon. * Fixed a minor bug when programmatically selecting a tab. * Added a ```setAutoHideOnSelection(boolean autoHideOnSelection)``` method for the BottomBarBadge to control whether it is automatically hidden after the tab that contains it is selected or not. * Titles are now forced to be single line, make sure your title texts are short enough, or else they'll get truncated with a "..." ! * Updated some dependencies and Gradle. ### 1.3.3 * The show / hide methods now behave nicely with CoordinatorLayout. * Added alpha animation for the tab titles when using the shifting tabs. ### 1.3.2 * Now it's possible to use fixed mode (show titles on inactive tabs) even when there's more than three tabs. ### 1.3.1 * Fixed a critical bug in OnLongClickListener behavior (why didn't I see that before?) when using badges. ### 1.3.0 * Fixed a critical bug in OnClickListener behavior when using badges. ### 1.2.9 * Fixed the issue when using badges and the tab resize animation is enabled. Now the badges automatically adjust their position when the tab's size (or position) updates. ### 1.2.8 * Fixed the [ugly layout bug](https://github.com/roughike/BottomBar/issues/126) that happened when calling the ```setDefaultTabPosition()``` or ```selectTabAtPosition()``` methods. ### Versions 0.0.1 - 1.2.7 * Sweating my ass off making this library and trying to compete with the other ones. ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS ================================================ FILE: NOTICE ================================================ BottomBar library for Android Copyright 2016 Iiro Krankka This product includes software developed by Iiro Krankka (https://github.com/roughike). ================================================ FILE: README.md ================================================ # BottomBar (Deprecated) I don't have time to maintain this anymore. I basically wrote the whole library in a rush, without tests, while being a serious expert beginner at the time. As a result, there's a lot of unpredictable moving parts and the tests probably aren't that great either. Don't really know, since I haven't touched this in ages. I'd recommend you to use the official BottomNavigationView from Google and urge them to implement the features you need. Or use another 3rd party library. [![Build Status](https://travis-ci.org/roughike/BottomBar.svg?branch=master)](https://travis-ci.org/roughike/BottomBar) [![Coverage Status](https://coveralls.io/repos/github/roughike/BottomBar/badge.svg?branch=development)](https://coveralls.io/github/roughike/BottomBar?branch=master) [![Download](https://api.bintray.com/packages/roughike/maven/bottom-bar/images/download.svg)](https://bintray.com/roughike/maven/bottom-bar/_latestVersion) ## Version 2.0 released! [The latest version before that can be found in the v1 branch](https://github.com/roughike/BottomBar/tree/v1) * Cleaner code and better APIs * No more unnecessary stuff or spaghetti mess * Now the look, feel and behavior is defined in XML, as it should be * No more nasty regressions, thanks to the automated tests * **Everything is a little different compared to earlier, but it's for the greater good!** [How to contribute](https://github.com/roughike/BottomBar/blob/master/README.md#contributions) [Changelog](https://github.com/roughike/BottomBar/blob/master/CHANGELOG.md) ## What? A custom view component that mimics the new [Material Design Bottom Navigation pattern](https://www.google.com/design/spec/components/bottom-navigation.html). ## Does it work on my Grandpa Gary's HTC Dream? Nope. The minSDK version is **API level 11 (Honeycomb).** ## Gimme that Gradle sweetness, pls? ```groovy compile 'com.roughike:bottom-bar:2.3.1' ``` **Maven:** ```xml com.roughike bottom-bar 2.3.1 pom ``` ## How? You can add items by **writing a XML resource file**. ### Creating the icons The icons must be fully opaque, solid black color, 24dp and **with no padding**. For example, [with Android Asset Studio Generic Icon generator](https://romannurik.github.io/AndroidAssetStudio/icons-generic.html), select "TRIM" and make sure the padding is 0dp. Here's what your icons should look like: ![Sample icons](https://raw.githubusercontent.com/roughike/BottomBar/master/graphics/icons-howto.png) ### Adding items from XML resource Define your tabs in an XML resource file. **res/xml/bottombar_tabs.xml:** ```xml ``` Then, add the BottomBar to your layout and give it a resource id for your tabs xml file. **layout/activity_main.xml** ```xml ``` ### Setting up listeners By default, the tabs don't do anything unless you listen for selection events and do something when the tabs are selected. **MainActivity.java:** ```java public class MainActivity extends Activity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); BottomBar bottomBar = (BottomBar) findViewById(R.id.bottomBar); bottomBar.setOnTabSelectListener(new OnTabSelectListener() { @Override public void onTabSelected(@IdRes int tabId) { if (tabId == R.id.tab_favorites) { // The tab with id R.id.tab_favorites was selected, // change your content accordingly. } } }); } } ``` If you want to listen for reselection events, here's how you do it: ```java bottomBar.setOnTabReselectListener(new OnTabReselectListener() { @Override public void onTabReSelected(@IdRes int tabId) { if (tabId == R.id.tab_favorites) { // The tab with id R.id.tab_favorites was reselected, // change your content accordingly. } } }); ``` ### Intercepting tab selections If you want to conditionally cancel selection of any tab, you absolutely can. Just assign a ```TabSelectionInterceptor``` to the BottomBar, and return true from the ```shouldInterceptTabSelection()``` method. ```java bottomBar.setTabSelectionInterceptor(new TabSelectionInterceptor() { @Override public boolean shouldInterceptTabSelection(@IdRes int oldTabId, @IdRes int newTabId) { if (newTabId == R.id.tab_pro_feature && !userHasProVersion()) { startProVersionPurchaseFlow(); return true; } return false; } }); ``` ### Changing icons based on selection state If you want to have different icon when a specific tab is selected, just use state list drawables. **res/drawable/my_tab_icon.xml** ```xml ``` **res/xml/bottombar_tabs.xml** ```xml ... ... ``` ### Those color changing tabs look dope. Howdoidodat? Just add ```barColorWhenSelected``` to each tab. When that tab is selected, the whole BottomBar background color is changed with a nice animation. **res/xml/bottombar_tabs.xml** ```xml ``` ### How do I draw it under the navbar? First, define a style that is a child of your main application theme: **res/values-v21/styles.xml** ```xml ``` You'll also have to **make a stub version of the same theme** to avoid crashes in previous API levels than Lollipop: **res/values/styles.xml** ```xml ================================================ FILE: app/src/main/res/values-land-v21/styles.xml ================================================ ================================================ FILE: app/src/main/res/values-w820dp/dimens.xml ================================================ 64dp ================================================ FILE: app/src/main/res/xml/bottombar_tabs_color_changing.xml ================================================ ================================================ FILE: app/src/main/res/xml/bottombar_tabs_five.xml ================================================ ================================================ FILE: app/src/main/res/xml/bottombar_tabs_three.xml ================================================ ================================================ FILE: bottom-bar/build.gradle ================================================ apply plugin: 'com.android.library' apply plugin: 'com.github.kt3k.coveralls' ext { bintrayRepo = 'maven' bintrayName = 'bottom-bar' publishedGroupId = 'com.roughike' libraryName = 'bottom-bar' artifact = 'bottom-bar' libraryDescription = 'A custom view component that mimics the Material Design "Bottom navigation" pattern.' siteUrl = 'https://github.com/roughike/BottomBar' gitUrl = 'https://github.com/roughike/BottomBar.git' libraryVersion = '2.3.1' developerId = 'roughike' developerName = 'Iiro Krankka' developerEmail = 'iiro.krankka@gmail.com' licenseName = 'The Apache Software License, Version 2.0' licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' allLicenses = ["Apache-2.0"] } android { compileSdkVersion rootProject.ext.compileSdkVersion buildToolsVersion rootProject.ext.buildToolsVersion buildTypes { debug { testCoverageEnabled true } } defaultConfig { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } } coveralls { jacocoReportPath = "${buildDir}/reports/coverage/debug/report.xml" } tasks.coveralls { dependsOn 'connectedAndroidTest' onlyIf { System.env.'CI' } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:' + rootProject.ext.supportLibraryVersion compile 'com.android.support:design:' + rootProject.ext.supportLibraryVersion testCompile 'junit:junit:' + rootProject.ext.junitVersion androidTestCompile 'junit:junit:4.12' androidTestCompile 'com.android.support.test:runner:0.5' androidTestCompile 'com.android.support.test:rules:0.5' androidTestCompile 'org.mockito:mockito-core:1.+' androidTestCompile "com.google.dexmaker:dexmaker:1.2" androidTestCompile "com.google.dexmaker:dexmaker-mockito:1.2" } apply plugin: 'com.github.dcendents.android-maven' group = publishedGroupId // Maven Group ID for the artifact install { repositories.mavenInstaller { // This generates POM.xml with proper parameters pom { project { packaging 'aar' groupId publishedGroupId artifactId artifact // Add your description here name libraryName description libraryDescription url siteUrl // Set your license licenses { license { name licenseName url licenseUrl } } developers { developer { id developerId name developerName email developerEmail } } scm { connection gitUrl developerConnection gitUrl url siteUrl } } } } } apply plugin: 'com.jfrog.bintray' version = libraryVersion if (project.hasProperty("android")) { // Android libraries task sourcesJar(type: Jar) { classifier = 'sources' from android.sourceSets.main.java.srcDirs } task javadoc(type: Javadoc) { source = android.sourceSets.main.java.srcDirs classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) } } else { // Java libraries task sourcesJar(type: Jar, dependsOn: classes) { classifier = 'sources' from sourceSets.main.allSource } } task javadocJar(type: Jar, dependsOn: javadoc) { classifier = 'javadoc' from javadoc.destinationDir } artifacts { archives javadocJar archives sourcesJar } // Bintray File localProps = project.rootProject.file('local.properties') if (localProps.exists()) { Properties properties = new Properties() properties.load(localProps.newDataInputStream()) bintray { user = properties.getProperty("bintray.user") key = properties.getProperty("bintray.apikey") configurations = ['archives'] pkg { repo = bintrayRepo name = bintrayName desc = libraryDescription websiteUrl = siteUrl vcsUrl = gitUrl licenses = allLicenses publish = true publicDownloadNumbers = true version { desc = libraryDescription gpg { sign = true //Determines whether to GPG sign the files. The default is false passphrase = properties.getProperty("bintray.gpg.password") //Optional. The passphrase for GPG signing' } } } } } ================================================ FILE: bottom-bar/src/androidTest/assets/fonts/GREAT-VIBES-LICENSE ================================================ SIL Open Font License v1.10 This license can also be found at this permalink: https://www.fontsquirrel.com/license/great-vibes Copyright (c) 2012, TypeSETit, LLC (typesetit@att.net), with Reserved Font Name "Great Vibes" This Font Software is licensed under the SIL Open Font License, Version 1.1. This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL —————————————————————————————- SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 —————————————————————————————- PREAMBLE The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others. The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives. DEFINITIONS “Font Software” refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation. “Reserved Font Name” refers to any names specified as such after the copyright statement(s). “Original Version” refers to the collection of Font Software components as distributed by the Copyright Holder(s). “Modified Version” refers to any derivative made by adding to, deleting, or substituting—in part or in whole—any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment. “Author” refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software. PERMISSION & CONDITIONS Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions: 1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself. 2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user. 3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users. 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission. 5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software. TERMINATION This license becomes null and void if any of the above conditions are not met. DISCLAIMER THE FONT SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. ================================================ FILE: bottom-bar/src/androidTest/java/com/roughike/bottombar/BadgeTest.java ================================================ package com.roughike.bottombar; import android.os.Bundle; import android.support.test.InstrumentationRegistry; import android.support.test.annotation.UiThreadTest; import android.support.test.filters.LargeTest; import android.support.test.runner.AndroidJUnit4; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertNull; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; /** * Created by iiro on 8.8.2016. */ @RunWith(AndroidJUnit4.class) @LargeTest public class BadgeTest { private BottomBar bottomBar; private BottomBarTab nearby; @Before public void setUp() { bottomBar = new BottomBar(InstrumentationRegistry.getContext()); bottomBar.setItems(com.roughike.bottombar.test.R.xml.dummy_tabs_three); nearby = bottomBar.getTabWithId(com.roughike.bottombar.test.R.id.tab_nearby); nearby.setBadgeCount(5); } @Test public void hasNoBadges_ExceptNearby() { assertNull(bottomBar.getTabWithId(com.roughike.bottombar.test.R.id.tab_favorites).badge); assertNull(bottomBar.getTabWithId(com.roughike.bottombar.test.R.id.tab_friends).badge); assertNotNull(nearby.badge); } @Test @UiThreadTest public void whenTabWithBadgeClicked_BadgeIsHidden() { InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { bottomBar.selectTabWithId(com.roughike.bottombar.test.R.id.tab_nearby); assertFalse(nearby.badge.isVisible()); } }); } @Test @UiThreadTest public void whenBadgeCountIsZero_BadgeIsRemoved() { nearby.setBadgeCount(0); assertNull(nearby.badge); } @Test @UiThreadTest public void whenBadgeCountIsNegative_BadgeIsRemoved() { nearby.setBadgeCount(-1); assertNull(nearby.badge); } @Test @UiThreadTest public void whenBadgeStateRestored_CountPersists() { nearby.setBadgeCount(1); assertEquals(1, nearby.badge.getCount()); int tabIndex = nearby.getIndexInTabContainer(); Bundle savedInstanceState = new Bundle(); savedInstanceState.putInt(BottomBarTab.STATE_BADGE_COUNT + tabIndex, 2); nearby.restoreState(savedInstanceState); assertEquals(2, nearby.badge.getCount()); } @Test @UiThreadTest public void badgeRemovedProperly() { assertNotEquals(bottomBar.findViewById(R.id.bb_bottom_bar_item_container), nearby.getOuterView()); assertEquals(2, nearby.getOuterView().getChildCount()); assertTrue(nearby.getOuterView().getChildAt(1) instanceof BottomBarBadge); nearby.removeBadge(); assertNull(nearby.badge); assertEquals(bottomBar.findViewById(R.id.bb_bottom_bar_item_container), nearby.getOuterView()); } } ================================================ FILE: bottom-bar/src/androidTest/java/com/roughike/bottombar/BottomBarTabTest.java ================================================ package com.roughike.bottombar; import android.os.Bundle; import android.support.test.InstrumentationRegistry; import android.support.test.runner.AndroidJUnit4; import android.widget.FrameLayout; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.assertEquals; @RunWith(AndroidJUnit4.class) public class BottomBarTabTest { private FrameLayout tabContainer; private BottomBarTab tab; @Before public void setUp() { tabContainer = new FrameLayout(InstrumentationRegistry.getContext()); tab = new BottomBarTab(InstrumentationRegistry.getContext()); tabContainer.addView(tab); } @Test public void correctLayoutReturnedForFixedTab() { tab.setType(BottomBarTab.Type.FIXED); assertEquals(R.layout.bb_bottom_bar_item_fixed, tab.getLayoutResource()); } @Test(expected = IllegalStateException.class) public void setIsTitleless_WhenTrueAndIconDoesNotExist_ThrowsException() { tab.setIsTitleless(true); assertEquals(R.layout.bb_bottom_bar_item_titleless, tab.getLayoutResource()); } @Test public void correctLayoutForShiftingTab() { tab.setType(BottomBarTab.Type.SHIFTING); assertEquals(R.layout.bb_bottom_bar_item_shifting, tab.getLayoutResource()); } @Test public void correctLayoutForTabletTab() { tab.setType(BottomBarTab.Type.TABLET); assertEquals(R.layout.bb_bottom_bar_item_fixed_tablet, tab.getLayoutResource()); } @Test public void testSavedStateWithBadge_StaysIntact() { tab.setBadgeCount(5); tab.setIndexInContainer(69); assertEquals(69, tab.getIndexInTabContainer()); Bundle savedState = (Bundle) tab.onSaveInstanceState(); assertEquals(5, savedState.getInt(BottomBarTab.STATE_BADGE_COUNT + 69)); tab.setBadgeCount(9); assertEquals(9, tab.badge.getCount()); tab.onRestoreInstanceState(savedState); assertEquals(5, tab.badge.getCount()); } } ================================================ FILE: bottom-bar/src/androidTest/java/com/roughike/bottombar/BottomBarTest.java ================================================ package com.roughike.bottombar; import android.content.Context; import android.graphics.Color; import android.graphics.Typeface; import android.os.Bundle; import android.support.test.InstrumentationRegistry; import android.support.test.annotation.UiThreadTest; import android.support.test.filters.LargeTest; import android.support.test.runner.AndroidJUnit4; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InOrder; import static android.support.test.InstrumentationRegistry.getInstrumentation; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.anyInt; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; /** * Created by iiro on 13.8.2016. */ @RunWith(AndroidJUnit4.class) @LargeTest public class BottomBarTest { private static final int THREE_TABS = com.roughike.bottombar.test.R.xml.dummy_tabs_three; private static final float INACTIVE_TAB_ALPHA = 0.69f; private static final float ACTIVE_TAB_ALPHA = 0.96f; private static final int INACTIVE_TAB_COLOR = Color.parseColor("#111111"); private static final int ACTIVE_TAB_COLOR = Color.parseColor("#222222"); private static final int BACKGROUND_COLOR = Color.parseColor("#333333"); private static final int BADGE_BACKGROUND_COLOR = Color.parseColor("#444444"); private static final boolean DEFAULT_BADGE_HIDES_WHEN_SELECTED_VALUE = true; private static final int TITLE_TEXT_APPEARANCE = com.roughike.bottombar.test.R.style.dummy_text_appearance; private static final Typeface TYPEFACE = Typeface.DEFAULT_BOLD; private static final BottomBarTab.Config DEFAULT_CONFIG = new BottomBarTab.Config.Builder() .inActiveTabAlpha(INACTIVE_TAB_ALPHA) .activeTabAlpha(ACTIVE_TAB_ALPHA) .inActiveTabColor(INACTIVE_TAB_COLOR) .activeTabColor(ACTIVE_TAB_COLOR) .barColorWhenSelected(BACKGROUND_COLOR) .badgeBackgroundColor(BADGE_BACKGROUND_COLOR) .hideBadgeWhenSelected(DEFAULT_BADGE_HIDES_WHEN_SELECTED_VALUE) .titleTextAppearance(TITLE_TEXT_APPEARANCE) .titleTypeFace(TYPEFACE) .build(); private Context context; private TabSelectionInterceptor tabSelectionInterceptor; private OnTabSelectListener selectListener; private OnTabReselectListener reselectListener; private BottomBar bottomBar; @Before public void setUp() { context = InstrumentationRegistry.getTargetContext(); tabSelectionInterceptor = mock(TabSelectionInterceptor.class); selectListener = mock(OnTabSelectListener.class); reselectListener = mock(OnTabReselectListener.class); bottomBar = new BottomBar(context); bottomBar.setItems(THREE_TABS, DEFAULT_CONFIG); bottomBar.setOnTabSelectListener(selectListener); bottomBar.setOnTabReselectListener(reselectListener); } @Test public void canCreateNewInstanceFromXml_WithoutXmlMenuResource() { new BottomBar(context, null); } @Test(expected = RuntimeException.class) public void setItems_ThrowsExceptionWithNoResource() { BottomBar secondBar = new BottomBar(context); secondBar.setItems(0); } @Test public void setItems_AfterAlreadySet_ReplacesPreviousWithNewOnes() { int previousItemCount = bottomBar.getTabCount(); assertThat(previousItemCount, is(3)); bottomBar.setItems(com.roughike.bottombar.test.R.xml.dummy_tabs_five); assertThat(bottomBar.getTabCount(), is(5)); } @Test public void setItemsWithCustomConfig_OverridesPreviousValues() { BottomBar newBar = new BottomBar(context); newBar.setItems(THREE_TABS, DEFAULT_CONFIG); BottomBarTab first = newBar.getTabAtPosition(0); assertEquals(INACTIVE_TAB_ALPHA, first.getInActiveAlpha(), 0); assertEquals(ACTIVE_TAB_ALPHA, first.getActiveAlpha(), 0); assertEquals(INACTIVE_TAB_COLOR, first.getInActiveColor()); assertEquals(ACTIVE_TAB_COLOR, first.getActiveColor()); assertEquals(BACKGROUND_COLOR, first.getBarColorWhenSelected()); assertEquals(BADGE_BACKGROUND_COLOR, first.getBadgeBackgroundColor()); assertEquals(DEFAULT_BADGE_HIDES_WHEN_SELECTED_VALUE, first.getBadgeHidesWhenActive()); assertEquals(TITLE_TEXT_APPEARANCE, first.getTitleTextAppearance()); assertEquals(TYPEFACE, first.getTitleTypeFace()); } @Test public void setOverrideTabSelectionListener_preventSelection() { bottomBar.setTabSelectionInterceptor(tabSelectionInterceptor); when(tabSelectionInterceptor.shouldInterceptTabSelection(anyInt(), anyInt())).thenReturn(true); BottomBarTab oldTab = bottomBar.getCurrentTab(); BottomBarTab newTab = bottomBar.getTabAtPosition(2); newTab.performClick(); verify(tabSelectionInterceptor, times(1)).shouldInterceptTabSelection(oldTab.getId(), newTab.getId()); assertNotSame(bottomBar.getCurrentTab(), newTab); } @Test @UiThreadTest public void setOverrideTabSelectionListener_allowingSelection() { bottomBar.setTabSelectionInterceptor(tabSelectionInterceptor); when(tabSelectionInterceptor.shouldInterceptTabSelection(anyInt(), anyInt())).thenReturn(false); BottomBarTab oldTab = bottomBar.getCurrentTab(); final BottomBarTab newTab = bottomBar.getTabAtPosition(2); getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { newTab.performClick(); } }); verify(tabSelectionInterceptor, times(1)).shouldInterceptTabSelection(oldTab.getId(), newTab.getId()); assertSame(bottomBar.getCurrentTab(), newTab); } @Test @UiThreadTest public void setOverrideTabSelectionListener_whenNoListenerSet() { bottomBar.removeOverrideTabSelectionListener(); BottomBarTab oldTab = bottomBar.getCurrentTab(); final BottomBarTab newTab = bottomBar.getTabAtPosition(2); getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { newTab.performClick(); } }); verify(tabSelectionInterceptor, times(0)).shouldInterceptTabSelection(oldTab.getId(), newTab.getId()); assertSame(bottomBar.getCurrentTab(), newTab); } @Test public void setOnTabSelectListener_WhenShouldFireInitiallySetToTrue_FiresWhenSet() { OnTabSelectListener listener = mock(OnTabSelectListener.class); bottomBar.setOnTabSelectListener(listener); bottomBar.setOnTabSelectListener(listener, true); verify(listener, times(2)).onTabSelected(com.roughike.bottombar.test.R.id.tab_favorites); } @Test public void setOnTabSelectListener_WhenShouldFireInitiallySetToFalse_DoesNotFireWhenSet() { OnTabSelectListener listener = mock(OnTabSelectListener.class); bottomBar.setOnTabSelectListener(listener, false); verifyZeroInteractions(listener); } @Test @UiThreadTest public void tabCount_IsCorrect() { assertEquals(3, bottomBar.getTabCount()); } @Test @UiThreadTest public void findingPositionForTabs_ReturnsCorrectPositions() { assertEquals(0, bottomBar.findPositionForTabWithId(com.roughike.bottombar.test.R.id.tab_favorites)); assertEquals(1, bottomBar.findPositionForTabWithId(com.roughike.bottombar.test.R.id.tab_nearby)); assertEquals(2, bottomBar.findPositionForTabWithId(com.roughike.bottombar.test.R.id.tab_friends)); } @Test @UiThreadTest public void whenTabIsSelected_SelectionListenerIsFired() { bottomBar.selectTabWithId(com.roughike.bottombar.test.R.id.tab_friends); bottomBar.selectTabWithId(com.roughike.bottombar.test.R.id.tab_nearby); bottomBar.selectTabWithId(com.roughike.bottombar.test.R.id.tab_favorites); InOrder inOrder = inOrder(selectListener); inOrder.verify(selectListener, times(1)).onTabSelected(com.roughike.bottombar.test.R.id.tab_friends); inOrder.verify(selectListener, times(1)).onTabSelected(com.roughike.bottombar.test.R.id.tab_nearby); inOrder.verify(selectListener, times(1)).onTabSelected(com.roughike.bottombar.test.R.id.tab_favorites); inOrder.verifyNoMoreInteractions(); } @Test @UiThreadTest public void afterConfigurationChanged_SavedStateRestored_AndSelectedTabPersists() { bottomBar.selectTabWithId(com.roughike.bottombar.test.R.id.tab_favorites); Bundle savedState = bottomBar.saveState(); bottomBar.selectTabWithId(com.roughike.bottombar.test.R.id.tab_nearby); bottomBar.restoreState(savedState); assertEquals(com.roughike.bottombar.test.R.id.tab_favorites, bottomBar.getCurrentTabId()); } @Test @UiThreadTest public void whenTabIsReselected_ReselectionListenerIsFired() { int firstTabId = com.roughike.bottombar.test.R.id.tab_favorites; bottomBar.selectTabWithId(firstTabId); verify(reselectListener, times(1)).onTabReSelected(firstTabId); int secondTabId = com.roughike.bottombar.test.R.id.tab_nearby; bottomBar.selectTabWithId(secondTabId); bottomBar.selectTabWithId(secondTabId); verify(reselectListener, times(1)).onTabReSelected(secondTabId); int thirdTabId = com.roughike.bottombar.test.R.id.tab_friends; bottomBar.selectTabWithId(thirdTabId); bottomBar.selectTabWithId(thirdTabId); verify(reselectListener, times(1)).onTabReSelected(thirdTabId); } @Test @UiThreadTest public void whenDefaultTabIsSet_ItsSelectedAtFirst() { int defaultTabId = com.roughike.bottombar.test.R.id.tab_friends; bottomBar.setDefaultTab(defaultTabId); verify(selectListener).onTabSelected(defaultTabId); } @Test(expected = IndexOutOfBoundsException.class) public void settingTooLowDefaultPosition_Throws() { bottomBar.setDefaultTabPosition(-1); } @Test(expected = IndexOutOfBoundsException.class) public void settingTooHighDefaultPosition_Throws() { bottomBar.setDefaultTabPosition(bottomBar.getTabCount()); } @Test @UiThreadTest public void afterConfigurationChanged_UserSelectedTabPersistsWhenResettingDefaultTab() { int defaultTabId = com.roughike.bottombar.test.R.id.tab_friends; bottomBar.setDefaultTab(defaultTabId); bottomBar.selectTabWithId(com.roughike.bottombar.test.R.id.tab_nearby); Bundle savedState = bottomBar.saveState(); bottomBar.restoreState(savedState); bottomBar.setDefaultTab(defaultTabId); assertNotSame(defaultTabId, bottomBar.getCurrentTabId()); assertEquals(com.roughike.bottombar.test.R.id.tab_nearby, bottomBar.getCurrentTabId()); } @Test @UiThreadTest public void whenGettingCurrentTab_ReturnsCorrectOne() { int firstTabId = com.roughike.bottombar.test.R.id.tab_favorites; bottomBar.selectTabWithId(firstTabId); assertEquals(firstTabId, bottomBar.getCurrentTabId()); assertEquals(bottomBar.findPositionForTabWithId(firstTabId), bottomBar.getCurrentTabPosition()); assertEquals(bottomBar.getTabWithId(firstTabId), bottomBar.getCurrentTab()); int secondTabId = com.roughike.bottombar.test.R.id.tab_nearby; bottomBar.selectTabWithId(secondTabId); assertEquals(secondTabId, bottomBar.getCurrentTabId()); assertEquals(bottomBar.findPositionForTabWithId(secondTabId), bottomBar.getCurrentTabPosition()); assertEquals(bottomBar.getTabWithId(secondTabId), bottomBar.getCurrentTab()); int thirdTabId = com.roughike.bottombar.test.R.id.tab_friends; bottomBar.selectTabWithId(thirdTabId); assertEquals(thirdTabId, bottomBar.getCurrentTabId()); assertEquals(bottomBar.findPositionForTabWithId(thirdTabId), bottomBar.getCurrentTabPosition()); assertEquals(bottomBar.getTabWithId(thirdTabId), bottomBar.getCurrentTab()); } @Test @UiThreadTest public void whenSelectionChanges_AndHasNoListeners_onlyOneTabIsSelectedAtATime() { bottomBar.removeOnTabSelectListener(); bottomBar.removeOnTabReselectListener(); int firstTabId = com.roughike.bottombar.test.R.id.tab_favorites; int secondTabId = com.roughike.bottombar.test.R.id.tab_nearby; int thirdTabId = com.roughike.bottombar.test.R.id.tab_friends; bottomBar.selectTabWithId(secondTabId); assertOnlyHasOnlyOneSelectedTabWithId(secondTabId); bottomBar.selectTabWithId(thirdTabId); assertOnlyHasOnlyOneSelectedTabWithId(thirdTabId); bottomBar.selectTabWithId(firstTabId); assertOnlyHasOnlyOneSelectedTabWithId(firstTabId); } private void assertOnlyHasOnlyOneSelectedTabWithId(int tabId) { for (int i = 0; i < bottomBar.getTabCount(); i++) { BottomBarTab tab = bottomBar.getTabAtPosition(i); if (tab.getId() == tabId) { assertTrue(tab.isActive()); } else { assertFalse(tab.isActive()); } } } @Test @UiThreadTest public void whenTabIsSelectedOnce_AndNoSelectionListenerSet_ReselectionListenerIsNotFired() { bottomBar.removeOnTabSelectListener(); bottomBar.selectTabWithId(com.roughike.bottombar.test.R.id.tab_friends); bottomBar.selectTabWithId(com.roughike.bottombar.test.R.id.tab_nearby); bottomBar.selectTabWithId(com.roughike.bottombar.test.R.id.tab_favorites); verifyZeroInteractions(reselectListener); } @Test @UiThreadTest public void setInActiveAlpha_UpdatesAlpha() { BottomBarTab inActiveTab = bottomBar.getTabAtPosition(1); assertNotEquals(bottomBar.getCurrentTab(), inActiveTab); float previousAlpha = inActiveTab.getInActiveAlpha(); float testAlpha = 0.1f; assertNotEquals(testAlpha, previousAlpha); assertNotEquals(testAlpha, inActiveTab.getIconView().getAlpha()); assertNotEquals(testAlpha, inActiveTab.getTitleView().getAlpha()); bottomBar.setInActiveTabAlpha(testAlpha); assertEquals(testAlpha, inActiveTab.getInActiveAlpha(), 0); assertEquals(testAlpha, inActiveTab.getIconView().getAlpha(), 0); assertEquals(testAlpha, inActiveTab.getTitleView().getAlpha(), 0); } @Test public void setInactiveTabAlpha_LeavesOtherValuesIntact() { bottomBar.setInActiveTabAlpha(0.2f); BottomBarTab inActiveTab = bottomBar.getTabAtPosition(1); assertNotEquals(inActiveTab, bottomBar.getCurrentTab()); assertEquals(0.2f, inActiveTab.getInActiveAlpha(), 0); assertEquals(ACTIVE_TAB_ALPHA, inActiveTab.getActiveAlpha(), 0); assertEquals(INACTIVE_TAB_COLOR, inActiveTab.getInActiveColor()); assertEquals(ACTIVE_TAB_COLOR, inActiveTab.getActiveColor()); assertEquals(BACKGROUND_COLOR, inActiveTab.getBarColorWhenSelected()); assertEquals(BADGE_BACKGROUND_COLOR, inActiveTab.getBadgeBackgroundColor()); assertEquals(TITLE_TEXT_APPEARANCE, inActiveTab.getTitleTextAppearance()); assertEquals(TYPEFACE, inActiveTab.getTitleTypeFace()); } @Test @UiThreadTest public void setActiveAlpha_UpdatesAlpha() { BottomBarTab activeTab = bottomBar.getCurrentTab(); float previousAlpha = activeTab.getActiveAlpha(); float testAlpha = 0.69f; assertNotEquals(testAlpha, previousAlpha); assertNotEquals(testAlpha, activeTab.getIconView().getAlpha()); assertNotEquals(testAlpha, activeTab.getTitleView().getAlpha()); bottomBar.setActiveTabAlpha(testAlpha); assertEquals(testAlpha, activeTab.getActiveAlpha(), 0); assertEquals(testAlpha, activeTab.getIconView().getAlpha(), 0); assertEquals(testAlpha, activeTab.getTitleView().getAlpha(), 0); } @Test public void setActiveTabAlpha_LeavesOtherValuesIntact() { bottomBar.setActiveTabAlpha(0.2f); BottomBarTab activeTab = bottomBar.getCurrentTab(); assertEquals(INACTIVE_TAB_ALPHA, activeTab.getInActiveAlpha(), 0); assertEquals(0.2f, activeTab.getActiveAlpha(), 0); assertEquals(INACTIVE_TAB_COLOR, activeTab.getInActiveColor()); assertEquals(ACTIVE_TAB_COLOR, activeTab.getActiveColor()); assertEquals(BACKGROUND_COLOR, activeTab.getBarColorWhenSelected()); assertEquals(BADGE_BACKGROUND_COLOR, activeTab.getBadgeBackgroundColor()); assertEquals(TITLE_TEXT_APPEARANCE, activeTab.getTitleTextAppearance()); assertEquals(TYPEFACE, activeTab.getTitleTypeFace()); } @Test @UiThreadTest public void setInActiveColor_UpdatesColor() { BottomBarTab inActiveTab = bottomBar.getTabAtPosition(1); assertNotEquals(bottomBar.getCurrentTab(), inActiveTab); int previousInActiveColor = inActiveTab.getInActiveColor(); int previousIconColor = inActiveTab.getCurrentDisplayedIconColor(); int previousTitleColor = inActiveTab.getCurrentDisplayedTitleColor(); int testColor = Color.GREEN; assertNotEquals(testColor, previousInActiveColor); assertNotEquals(testColor, previousIconColor); assertNotEquals(testColor, previousTitleColor); bottomBar.setInActiveTabColor(testColor); assertEquals(testColor, inActiveTab.getInActiveColor()); assertEquals(testColor, inActiveTab.getCurrentDisplayedIconColor()); assertEquals(testColor, inActiveTab.getCurrentDisplayedTitleColor()); } @Test public void setInactiveColor_LeavesOtherValuesIntact() { bottomBar.setInActiveTabColor(Color.BLUE); BottomBarTab inActiveTab = bottomBar.getTabAtPosition(1); assertNotEquals(inActiveTab, bottomBar.getCurrentTab()); assertEquals(INACTIVE_TAB_ALPHA, inActiveTab.getInActiveAlpha(), 0); assertEquals(ACTIVE_TAB_ALPHA, inActiveTab.getActiveAlpha(), 0); assertEquals(Color.BLUE, inActiveTab.getInActiveColor()); assertEquals(ACTIVE_TAB_COLOR, inActiveTab.getActiveColor()); assertEquals(BACKGROUND_COLOR, inActiveTab.getBarColorWhenSelected()); assertEquals(BADGE_BACKGROUND_COLOR, inActiveTab.getBadgeBackgroundColor()); assertEquals(TITLE_TEXT_APPEARANCE, inActiveTab.getTitleTextAppearance()); assertEquals(TYPEFACE, inActiveTab.getTitleTypeFace()); } @Test @UiThreadTest public void setActiveColor_UpdatesColor() { BottomBarTab activeTab = bottomBar.getCurrentTab(); int previousActiveColor = activeTab.getActiveColor(); int previousIconColor = activeTab.getCurrentDisplayedIconColor(); int previousTitleColor = activeTab.getCurrentDisplayedTitleColor(); int testColor = Color.GRAY; assertNotEquals(testColor, previousActiveColor); assertNotEquals(testColor, previousIconColor); assertNotEquals(testColor, previousTitleColor); bottomBar.setActiveTabColor(testColor); assertEquals(testColor, activeTab.getActiveColor()); assertEquals(testColor, activeTab.getCurrentDisplayedIconColor()); assertEquals(testColor, activeTab.getCurrentDisplayedTitleColor()); } @Test public void setActiveColor_LeavesOtherValuesIntact() { bottomBar.setActiveTabColor(Color.BLUE); BottomBarTab inActiveTab = bottomBar.getTabAtPosition(1); assertNotEquals(inActiveTab, bottomBar.getCurrentTab()); assertEquals(INACTIVE_TAB_ALPHA, inActiveTab.getInActiveAlpha(), 0); assertEquals(ACTIVE_TAB_ALPHA, inActiveTab.getActiveAlpha(), 0); assertEquals(INACTIVE_TAB_COLOR, inActiveTab.getInActiveColor()); assertEquals(Color.BLUE, inActiveTab.getActiveColor()); assertEquals(BACKGROUND_COLOR, inActiveTab.getBarColorWhenSelected()); assertEquals(BADGE_BACKGROUND_COLOR, inActiveTab.getBadgeBackgroundColor()); assertEquals(TITLE_TEXT_APPEARANCE, inActiveTab.getTitleTextAppearance()); assertEquals(TYPEFACE, inActiveTab.getTitleTypeFace()); } @Test @UiThreadTest public void setBadgeBackgroundColor_UpdatesColor() { BottomBarTab inActiveTab = bottomBar.getTabAtPosition(1); inActiveTab.setBadgeCount(3); int previousBadgeColor = inActiveTab.getBadgeBackgroundColor(); int testColor = Color.GREEN; assertNotEquals(testColor, previousBadgeColor); bottomBar.setBadgeBackgroundColor(testColor); assertEquals(testColor, inActiveTab.getBadgeBackgroundColor()); } @Test public void setBadgeBackgroundColor_LeavesOtherValuesIntact() { bottomBar.setBadgeBackgroundColor(Color.BLUE); BottomBarTab inActiveTab = bottomBar.getTabAtPosition(1); assertNotEquals(inActiveTab, bottomBar.getCurrentTab()); assertEquals(INACTIVE_TAB_ALPHA, inActiveTab.getInActiveAlpha(), 0); assertEquals(ACTIVE_TAB_ALPHA, inActiveTab.getActiveAlpha(), 0); assertEquals(INACTIVE_TAB_COLOR, inActiveTab.getInActiveColor()); assertEquals(ACTIVE_TAB_COLOR, inActiveTab.getActiveColor()); assertEquals(BACKGROUND_COLOR, inActiveTab.getBarColorWhenSelected()); assertEquals(Color.BLUE, inActiveTab.getBadgeBackgroundColor()); assertEquals(TITLE_TEXT_APPEARANCE, inActiveTab.getTitleTextAppearance()); assertEquals(TYPEFACE, inActiveTab.getTitleTypeFace()); } @Test @UiThreadTest public void setBadgeHidesWhenSelected_UpdatesBadgeHidesWhenSelected() { BottomBarTab tab = bottomBar.getCurrentTab(); boolean previousBadgeHidesValue = tab.getBadgeHidesWhenActive(); assertTrue(previousBadgeHidesValue); bottomBar.setBadgesHideWhenActive(false); assertFalse(tab.getBadgeHidesWhenActive()); } @Test public void setBadgeHidesWhenSelected_LeavesOtherValuesIntact() { bottomBar.setBadgesHideWhenActive(true); BottomBarTab tab = bottomBar.getCurrentTab(); assertEquals(INACTIVE_TAB_ALPHA, tab.getInActiveAlpha(), 0); assertEquals(ACTIVE_TAB_ALPHA, tab.getActiveAlpha(), 0); assertEquals(INACTIVE_TAB_COLOR, tab.getInActiveColor()); assertEquals(ACTIVE_TAB_COLOR, tab.getActiveColor()); assertEquals(BACKGROUND_COLOR, tab.getBarColorWhenSelected()); assertEquals(BADGE_BACKGROUND_COLOR, tab.getBadgeBackgroundColor()); assertTrue(tab.getBadgeHidesWhenActive()); assertEquals(TITLE_TEXT_APPEARANCE, tab.getTitleTextAppearance()); assertEquals(TYPEFACE, tab.getTitleTypeFace()); } @Test @UiThreadTest public void setTitleTextAppearance_UpdatesAppearance() { BottomBarTab tab = bottomBar.getCurrentTab(); int testTextApperance = -666; assertNotEquals(testTextApperance, tab.getTitleTextAppearance()); assertNotEquals(testTextApperance, tab.getCurrentDisplayedTextAppearance()); bottomBar.setTabTitleTextAppearance(testTextApperance); assertEquals(testTextApperance, tab.getTitleTextAppearance()); assertEquals(testTextApperance, tab.getCurrentDisplayedTextAppearance()); } @Test public void setTitleTextAppearance_LeavesOtherValuesIntact() { bottomBar.setTabTitleTextAppearance(-666); BottomBarTab inActiveTab = bottomBar.getTabAtPosition(1); assertNotEquals(inActiveTab, bottomBar.getCurrentTab()); assertEquals(INACTIVE_TAB_ALPHA, inActiveTab.getInActiveAlpha(), 0); assertEquals(ACTIVE_TAB_ALPHA, inActiveTab.getActiveAlpha(), 0); assertEquals(INACTIVE_TAB_COLOR, inActiveTab.getInActiveColor()); assertEquals(ACTIVE_TAB_COLOR, inActiveTab.getActiveColor()); assertEquals(BACKGROUND_COLOR, inActiveTab.getBarColorWhenSelected()); assertEquals(BADGE_BACKGROUND_COLOR, inActiveTab.getBadgeBackgroundColor()); assertEquals(-666, inActiveTab.getTitleTextAppearance()); assertEquals(TYPEFACE, inActiveTab.getTitleTypeFace()); } @Test @UiThreadTest public void setTitleTypeface_UpdatesTypeface() { BottomBarTab tab = bottomBar.getCurrentTab(); Typeface testTypeface = Typeface.createFromAsset( bottomBar.getContext().getAssets(), "fonts/GreatVibes-Regular.otf"); assertNotEquals(testTypeface, tab.getTitleTypeFace()); assertNotEquals(testTypeface, tab.getTitleView().getTypeface()); bottomBar.setTabTitleTypeface(testTypeface); assertEquals(testTypeface, tab.getTitleTypeFace()); assertEquals(testTypeface, tab.getTitleView().getTypeface()); } @Test public void setTitleTypeface_LeavesOtherValuesIntact() { bottomBar.setTabTitleTypeface(Typeface.DEFAULT); BottomBarTab inActiveTab = bottomBar.getTabAtPosition(1); assertNotEquals(inActiveTab, bottomBar.getCurrentTab()); assertEquals(INACTIVE_TAB_ALPHA, inActiveTab.getInActiveAlpha(), 0); assertEquals(ACTIVE_TAB_ALPHA, inActiveTab.getActiveAlpha(), 0); assertEquals(INACTIVE_TAB_COLOR, inActiveTab.getInActiveColor()); assertEquals(ACTIVE_TAB_COLOR, inActiveTab.getActiveColor()); assertEquals(BACKGROUND_COLOR, inActiveTab.getBarColorWhenSelected()); assertEquals(BADGE_BACKGROUND_COLOR, inActiveTab.getBadgeBackgroundColor()); assertEquals(TITLE_TEXT_APPEARANCE, inActiveTab.getTitleTextAppearance()); assertEquals(Typeface.DEFAULT, inActiveTab.getTitleTypeFace()); } } ================================================ FILE: bottom-bar/src/androidTest/java/com/roughike/bottombar/TabParserTest.java ================================================ package com.roughike.bottombar; import android.content.Context; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.support.test.InstrumentationRegistry; import android.support.test.filters.LargeTest; import android.support.test.runner.AndroidJUnit4; import android.support.v4.content.ContextCompat; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertTrue; @RunWith(AndroidJUnit4.class) @LargeTest public class TabParserTest { private Context context; private List tabs; @Before public void setUp() throws Exception { context = InstrumentationRegistry.getContext(); tabs = new TabParser( context, new BottomBarTab.Config.Builder().build(), com.roughike.bottombar.test.R.xml.dummy_tabs_five ).parseTabs(); } @Test public void correctAmountOfTabs() { assertEquals(5, tabs.size()); } @Test public void idsNotEmpty() { assertNotSame(0, tabs.get(0).getId()); assertNotSame(0, tabs.get(1).getId()); assertNotSame(0, tabs.get(2).getId()); assertNotSame(0, tabs.get(3).getId()); assertNotSame(0, tabs.get(4).getId()); } @Test public void correctTabTitles() { assertEquals("Recents", tabs.get(0).getTitle()); assertEquals("Favorites", tabs.get(1).getTitle()); assertEquals("Nearby", tabs.get(2).getTitle()); assertEquals("Friends", tabs.get(3).getTitle()); assertEquals("Food", tabs.get(4).getTitle()); } @Test public void correctInActiveColors() { assertEquals(Color.parseColor("#00FF00"), tabs.get(0).getInActiveColor()); assertEquals(Color.parseColor("#0000FF"), tabs.get(1).getInActiveColor()); assertEquals(Color.parseColor("#FF0000"), tabs.get(2).getInActiveColor()); assertEquals(Color.parseColor("#F0F000"), tabs.get(3).getInActiveColor()); assertEquals(Color.parseColor("#F00F00"), tabs.get(4).getInActiveColor()); } @Test public void correctActiveColors() { assertEquals(Color.parseColor("#FF0000"), tabs.get(0).getActiveColor()); assertEquals( ContextCompat.getColor(context, com.roughike.bottombar.test.R.color.test_random_color), tabs.get(1).getActiveColor() ); assertEquals(Color.parseColor("#0000FF"), tabs.get(2).getActiveColor()); assertEquals(Color.parseColor("#DAD666"), tabs.get(3).getActiveColor()); assertEquals(Color.parseColor("#F00F00"), tabs.get(4).getActiveColor()); } @Test public void iconResourcesExist() { assertNotNull(getDrawableByResource(tabs.get(0).getIconResId())); assertNotNull(getDrawableByResource(tabs.get(1).getIconResId())); assertNotNull(getDrawableByResource(tabs.get(2).getIconResId())); assertNotNull(getDrawableByResource(tabs.get(3).getIconResId())); assertNotNull(getDrawableByResource(tabs.get(4).getIconResId())); } @Test public void iconResourceIdsAsExpected() { int expectedId = com.roughike.bottombar.test.R.drawable.empty_icon; assertEquals(expectedId, tabs.get(0).getIconResId()); assertEquals(expectedId, tabs.get(1).getIconResId()); assertEquals(expectedId, tabs.get(2).getIconResId()); assertEquals(expectedId, tabs.get(3).getIconResId()); assertEquals(expectedId, tabs.get(4).getIconResId()); } @Test public void barColorWhenSelectedAsExpected() { assertEquals(Color.parseColor("#FF0000"), tabs.get(0).getBarColorWhenSelected()); assertEquals(Color.parseColor("#00FF00"), tabs.get(1).getBarColorWhenSelected()); assertEquals(Color.parseColor("#F00000"), tabs.get(2).getBarColorWhenSelected()); assertEquals(Color.parseColor("#00F000"), tabs.get(3).getBarColorWhenSelected()); assertEquals(Color.parseColor("#00F0F0"), tabs.get(4).getBarColorWhenSelected()); } @Test public void badgeBackgroundColorAsExpected() { assertEquals(Color.parseColor("#FF0000"), tabs.get(0).getBadgeBackgroundColor()); assertEquals(Color.parseColor("#00FF00"), tabs.get(1).getBadgeBackgroundColor()); assertEquals(Color.parseColor("#F00000"), tabs.get(2).getBadgeBackgroundColor()); assertEquals(Color.parseColor("#00F000"), tabs.get(3).getBadgeBackgroundColor()); assertEquals(Color.parseColor("#00F0F0"), tabs.get(4).getBadgeBackgroundColor()); } @Test public void correctBadgeHidingPolicies() { assertFalse(tabs.get(0).getBadgeHidesWhenActive()); assertTrue(tabs.get(1).getBadgeHidesWhenActive()); assertFalse(tabs.get(2).getBadgeHidesWhenActive()); assertTrue(tabs.get(3).getBadgeHidesWhenActive()); assertTrue(tabs.get(4).getBadgeHidesWhenActive()); } @Test public void titlelessTabsAsExpected() { assertFalse(tabs.get(0).isTitleless()); assertFalse(tabs.get(1).isTitleless()); assertTrue(tabs.get(2).isTitleless()); assertFalse(tabs.get(3).isTitleless()); assertTrue(tabs.get(4).isTitleless()); } private Drawable getDrawableByResource(int iconResId) { return ContextCompat.getDrawable(context, iconResId); } } ================================================ FILE: bottom-bar/src/androidTest/res/values/colors.xml ================================================ #FAB123 #DAD666 ================================================ FILE: bottom-bar/src/androidTest/res/values/strings.xml ================================================ Favorites Friends ================================================ FILE: bottom-bar/src/androidTest/res/values/styles.xml ================================================ ================================================ FILE: bottom-bar/src/main/res/values-land/bools.xml ================================================ false ================================================ FILE: bottom-bar/src/test/java/com/roughike/bottombar/ExampleUnitTest.java ================================================ package com.roughike.bottombar; import org.junit.Test; import static org.junit.Assert.*; /** * To work on unit tests, switch the Test Artifact in the Build Variants view. */ public class ExampleUnitTest { @Test public void addition_isCorrect() throws Exception { assertEquals(4, 2 + 2); } } ================================================ FILE: build.gradle ================================================ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() } dependencies { 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' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } ext { compileSdkVersion = 25 buildToolsVersion = "25.0.2" minSdkVersion = 11 targetSdkVersion = 25 supportLibraryVersion = "25.3.0" junitVersion = "4.12" } ================================================ FILE: gradle/wrapper/gradle-wrapper.properties ================================================ #Sat Mar 25 00:47:49 IST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip ================================================ FILE: gradle.properties ================================================ # Project-wide Gradle settings. # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* # any settings specified in this file. # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. # Default value: -Xmx10248m -XX:MaxPermSize=256m # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true ================================================ FILE: gradlew ================================================ #!/usr/bin/env bash ############################################################################## ## ## Gradle start up script for UN*X ## ############################################################################## # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS="" APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" warn ( ) { echo "$*" } die ( ) { echo echo "$*" echo exit 1 } # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false case "`uname`" in CYGWIN* ) cygwin=true ;; Darwin* ) darwin=true ;; MINGW* ) msys=true ;; esac # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" # Need this for relative symlinks. while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`"/$link" fi done SAVED="`pwd`" cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME="`pwd -P`" cd "$SAVED" >/dev/null CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD="$JAVA_HOME/jre/sh/java" else JAVACMD="$JAVA_HOME/bin/java" fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else JAVACMD="java" which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi # Increase the maximum file descriptors if we can. if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then MAX_FD="$MAX_FD_LIMIT" fi ulimit -n $MAX_FD if [ $? -ne 0 ] ; then warn "Could not set maximum file descriptor limit: $MAX_FD" fi else warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" fi fi # For Darwin, add options to specify how the application appears in the dock if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi # For Cygwin, switch paths to Windows format before running java if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` SEP="" for dir in $ROOTDIRSRAW ; do ROOTDIRS="$ROOTDIRS$SEP$dir" SEP="|" done OURCYGPATTERN="(^($ROOTDIRS))" # Add a user-defined pattern to the cygpath arguments if [ "$GRADLE_CYGPATTERN" != "" ] ; then OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" fi # Now convert the arguments - kludge to limit ourselves to /bin/sh i=0 for arg in "$@" ; do CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` else eval `echo args$i`="\"$arg\"" fi i=$((i+1)) done case $i in (0) set -- ;; (1) set -- "$args0" ;; (2) set -- "$args0" "$args1" ;; (3) set -- "$args0" "$args1" "$args2" ;; (4) set -- "$args0" "$args1" "$args2" "$args3" ;; (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules function splitJvmOpts() { JVM_OPTS=("$@") } eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" ================================================ FILE: projectFilesBackup/.idea/workspace.xml ================================================ 1471023866158 1471692873901 1471692942422 1471695146754 1471695264509 1471696338259 1471696458515 1471696708528 1471696927266 1471697252901 1471697602875 1471698172584 1471698847940 1471699748434 1471701201213 1471701936932 1471763046614 1471817516912 1471818257613 1471818445419 1471818606242 1471877113375 1471877279946 1471878893500 1471878942122 1471879135008 1471879150568 1471879162993 1471880758183 1471880910852 1471881992500 1471882058513 1471892501350 1471892681119 1471893559665 1472288382254 1472288702184 1472288893859 1472291031151 1472291738819 1472291824826 1472439966857 1472440627886 1472441056188 1472494764310 1472494817240 1472495092710 1472663256966 1472663445083 1472667142792 ================================================ FILE: settings.gradle ================================================ include ':app', ':bottom-bar'