├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── kotlinc.xml
├── markdown-exported-files.xml
├── markdown-navigator.xml
├── markdown-navigator
│ └── profiles_settings.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
├── runConfigurations
│ └── All_Tests.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
│ ├── drawable-hdpi
│ ├── ic_favorites.png
│ ├── ic_friends.png
│ ├── ic_nearby.png
│ ├── ic_recents.png
│ └── ic_restaurants.png
│ ├── drawable-mdpi
│ ├── ic_favorites.png
│ ├── ic_friends.png
│ ├── ic_nearby.png
│ ├── ic_recents.png
│ └── ic_restaurants.png
│ ├── drawable-xhdpi
│ ├── ic_favorites.png
│ ├── ic_friends.png
│ ├── ic_nearby.png
│ ├── ic_recents.png
│ └── ic_restaurants.png
│ ├── drawable-xxhdpi
│ ├── ic_favorites.png
│ ├── ic_friends.png
│ ├── ic_nearby.png
│ ├── ic_recents.png
│ └── ic_restaurants.png
│ ├── drawable-xxxhdpi
│ ├── ic_favorites.png
│ ├── ic_friends.png
│ ├── ic_nearby.png
│ ├── ic_recents.png
│ └── ic_restaurants.png
│ ├── layout-sw600dp
│ ├── activity_color_changing_tabs.xml
│ └── activity_three_tabs.xml
│ ├── 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
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ ├── values-land-v21
│ └── styles.xml
│ ├── values-sw600dp
│ └── styles.xml
│ ├── values-v21
│ └── styles.xml
│ ├── values-w820dp
│ └── dimens.xml
│ ├── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.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
│ │ ├── drawable-nodpi
│ │ └── empty_icon.png
│ │ ├── 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-v21
│ │ └── bb_bottom_bar_item_container.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
│ │ ├── values-land
│ │ └── bools.xml
│ │ └── values
│ │ ├── attrs.xml
│ │ ├── bools.xml
│ │ ├── colors.xml
│ │ ├── dimensions.xml
│ │ ├── ids.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── roughike
│ └── bottombar
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── graphics
├── icons-howto.png
├── screenshot_tablet.png
├── shifting-demo.gif
└── shy-demo.gif
├── projectFilesBackup
└── .idea
│ └── workspace.xml
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/workspace.xml
38 | .idea/libraries
39 |
40 | # Keystore files
41 | *.jks
42 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | BottomBar
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/markdown-exported-files.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/markdown-navigator.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/.idea/markdown-navigator/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/All_Tests.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: android
2 |
3 | jdk: oraclejdk8
4 |
5 | android:
6 | components:
7 | - tools
8 | - platform-tools
9 | - build-tools-25.0.2
10 | - android-25
11 | - extra-android-m2repository
12 |
13 | before_script:
14 | - echo no | android create avd --force -n test -t android-18 --abi armeabi-v7a
15 | - emulator -avd test -no-audio -no-window &
16 | - android-wait-for-emulator
17 | - adb shell input keyevent 82 &
18 |
19 | script:
20 | - ./gradlew connectedAndroidTest coveralls
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## Changelog
2 |
3 | ### 2.3.1
4 |
5 | * [#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!
6 |
7 | ### 2.3.0
8 |
9 | * [#713](https://github.com/roughike/BottomBar/pull/713): Ripple touch feedback for tabs!
10 | * [#716](https://github.com/roughike/BottomBar/pull/716): Bugfix for misbehaving shadow. No more weird white spaces above the bar!
11 | * [#717](https://github.com/roughike/BottomBar/pull/717): Support for tabs with icons only, without titles!
12 | * [#722](https://github.com/roughike/BottomBar/pull/722): Showing / hiding the BottomBar when on shy mode.
13 | * [#714](https://github.com/roughike/BottomBar/pull/714): Controlling whether Toasts of tab titles are shown when long pressing tabs.
14 | * [#719](https://github.com/roughike/BottomBar/pull/719): Fix for wrong size in tabs
15 | * [#712](https://github.com/roughike/BottomBar/pull/712): Data binding fixes.
16 |
17 | Thanks for @yombunker, @MarcRubio and @tushar-acharya for their contributions!
18 |
19 | ### 2.2.0
20 |
21 | * Ability to change icons when the tabs are selected, using drawable selectors
22 | * 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)
23 | * Internal code quality improvements and small changes
24 |
25 | ### 2.2.0
26 |
27 | * Ability to change icons when the tabs are selected, using drawable selectors
28 | * 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)
29 | * Internal code quality improvements and small changes
30 |
31 | ### 2.2.0
32 |
33 | * Ability to change icons when the tabs are selected, using drawable selectors
34 | * 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)
35 | * Internal code quality improvements and small changes
36 |
37 | ### 2.1.2
38 |
39 | * Merged [#703](https://github.com/roughike/BottomBar/pull/703) that allows controlling badge visibility for tabs that are active.
40 |
41 | ### 2.1.1
42 |
43 | * A quick fix for a really critical bug that could affect some devices. More specifically, [this one.](https://github.com/roughike/BottomBar/issues/625)
44 |
45 | ### 2.1.0
46 |
47 | * Fixed a bug in the Badge positioning, causing the Badges to clip when there was many tabs.
48 | * Fixed a bug where the lower portion of unselected titles were clipped off in fixed mode.
49 | * 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.
50 | * 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)
51 | * 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)
52 | * Optimized the tab resizing calculations; now the tabs aren't needlessly removed and readded, only the layout params get changed.
53 | * Merged [#468](https://github.com/roughike/BottomBar/pull/468) and [#457](https://github.com/roughike/BottomBar/pull/457)
54 | * Fixed [#554](https://github.com/roughike/BottomBar/issues/554) by merging [#512](https://github.com/roughike/BottomBar/pull/512).
55 | * Made most of the BottomBarTab methods public.
56 |
57 | ### 2.0.2
58 |
59 | * Now we're animating the color change on tab titles and icons.
60 | * Fixed a bug where the BottomBar wouldn't hide completely when it was both shy and drawing under navbar.
61 | * Made possible to inflate the BottomBar programmatically.
62 | * Made it possible to control whether the shadow is shown or not.
63 | * Made setItems to be public to allow writing tests without a designated Activity
64 | * Made setters for allowing setting tab colors, alphas, textappearances and typefaces programmatically.
65 | * Increased test coverage a little bit.
66 |
67 | ### 2.0.1
68 |
69 | * Fixed a bug where the tab selection listener is set and multiple tabs could be selected at once
70 | * Fixed a bug where the reselection listener was fired even it shouldn't have.
71 |
72 | ### 2.0
73 |
74 | * Cleaner code and better APIs
75 | * No more unnecessary stuff or spaghetti mess
76 | * Now the look, feel and behavior is defined in XML, as it should be
77 | * No more nasty regressions, thanks to the automated tests
78 | * **Everything is a little different compared to earlier, but it's for the greater good!**
79 |
80 | See the readme for how to use the new version.
81 |
82 | ### 1.4.0.1
83 |
84 | * Merged a [PR that fixes removing all tabs from BottomBar](https://github.com/roughike/BottomBar/pull/339)
85 |
86 | ### 1.4.0
87 |
88 | * Started writing some tests. **Contributions more than welcome**, as I'm still a noob when it comes to testing.
89 | * Merged a [PR that adds support for vector drawables](https://github.com/roughike/BottomBar/pull/280)
90 | * Merged a [PR that adds support for disabling text scale animation](https://github.com/roughike/BottomBar/pull/298)
91 | * Merged a [PR that adds support for custom background and tab icon colors, and also custom alpha](https://github.com/roughike/BottomBar/pull/302)
92 | * Merged a [PR that fixes wrong method name for message shown by an exception](https://github.com/roughike/BottomBar/pull/320)
93 |
94 | ### 1.3.9
95 |
96 | * Merged [another PR that should get rid of the infinite Badge loop for good](https://github.com/roughike/BottomBar/pull/289).
97 |
98 | ### 1.3.8
99 |
100 | * Merged a [PR that fixes infinite loop caused by a layout listener when adding Badges.](https://github.com/roughike/BottomBar/pull/286)
101 |
102 | ### 1.3.7
103 |
104 | * Merged a [PR that fixes elliptical Badges](https://github.com/roughike/BottomBar/pull/275).
105 | * Fixed issues [#276](https://github.com/roughike/BottomBar/issues/276) and [#277](https://github.com/roughike/BottomBar/issues/277)
106 |
107 | ### 1.3.6
108 |
109 | * Fixed a bug that would cause the navigation bar to not be transparent.
110 | * Flattened View hierarchy.
111 | * Throwing a nice little Exception if someone tries to call ```noResizeGoodness()``` improperly, instead of just failing silently.
112 |
113 | ### 1.3.5
114 |
115 | * [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)
116 | * Thanks to @henhal, now the unselection bug when using badges is fixed.
117 | * 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.
118 |
119 | ### 1.3.4
120 |
121 | * 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.
122 | * Fixed a minor bug when programmatically selecting a tab.
123 | * 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.
124 | * Titles are now forced to be single line, make sure your title texts are short enough, or else they'll get truncated with a "..." !
125 | * Updated some dependencies and Gradle.
126 |
127 | ### 1.3.3
128 |
129 | * The show / hide methods now behave nicely with CoordinatorLayout.
130 | * Added alpha animation for the tab titles when using the shifting tabs.
131 |
132 | ### 1.3.2
133 |
134 | * Now it's possible to use fixed mode (show titles on inactive tabs) even when there's more than three tabs.
135 |
136 | ### 1.3.1
137 |
138 | * Fixed a critical bug in OnLongClickListener behavior (why didn't I see that before?) when using badges.
139 |
140 | ### 1.3.0
141 |
142 | * Fixed a critical bug in OnClickListener behavior when using badges.
143 |
144 | ### 1.2.9
145 |
146 | * 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.
147 |
148 | ### 1.2.8
149 |
150 | * Fixed the [ugly layout bug](https://github.com/roughike/BottomBar/issues/126) that happened when calling the ```setDefaultTabPosition()``` or ```selectTabAtPosition()``` methods.
151 |
152 | ### Versions 0.0.1 - 1.2.7
153 |
154 | * Sweating my ass off making this library and trying to compete with the other ones.
155 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | BottomBar library for Android
2 | Copyright 2016 Iiro Krankka
3 |
4 | This product includes software developed by
5 | Iiro Krankka (https://github.com/roughike).
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # BottomBar (Deprecated)
2 |
3 | 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.
4 |
5 | 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.
6 |
7 | [](https://travis-ci.org/roughike/BottomBar) [](https://coveralls.io/github/roughike/BottomBar?branch=master) [](https://bintray.com/roughike/maven/bottom-bar/_latestVersion)
8 |
9 |
10 |
11 | ## Version 2.0 released!
12 |
13 | [The latest version before that can be found in the v1 branch](https://github.com/roughike/BottomBar/tree/v1)
14 |
15 | * Cleaner code and better APIs
16 | * No more unnecessary stuff or spaghetti mess
17 | * Now the look, feel and behavior is defined in XML, as it should be
18 | * No more nasty regressions, thanks to the automated tests
19 | * **Everything is a little different compared to earlier, but it's for the greater good!**
20 |
21 | [How to contribute](https://github.com/roughike/BottomBar/blob/master/README.md#contributions)
22 |
23 | [Changelog](https://github.com/roughike/BottomBar/blob/master/CHANGELOG.md)
24 |
25 | ## What?
26 |
27 | A custom view component that mimics the new [Material Design Bottom Navigation pattern](https://www.google.com/design/spec/components/bottom-navigation.html).
28 |
29 | ## Does it work on my Grandpa Gary's HTC Dream?
30 |
31 | Nope. The minSDK version is **API level 11 (Honeycomb).**
32 |
33 | ## Gimme that Gradle sweetness, pls?
34 |
35 | ```groovy
36 | compile 'com.roughike:bottom-bar:2.3.1'
37 | ```
38 |
39 | **Maven:**
40 | ```xml
41 |
42 | com.roughike
43 | bottom-bar
44 | 2.3.1
45 | pom
46 |
47 | ```
48 |
49 | ## How?
50 |
51 | You can add items by **writing a XML resource file**.
52 |
53 | ### Creating the icons
54 |
55 | 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:
56 |
57 | 
58 |
59 | ### Adding items from XML resource
60 |
61 | Define your tabs in an XML resource file.
62 |
63 | **res/xml/bottombar_tabs.xml:**
64 |
65 | ```xml
66 |
67 |
71 |
75 |
79 |
80 | ```
81 |
82 | Then, add the BottomBar to your layout and give it a resource id for your tabs xml file.
83 |
84 | **layout/activity_main.xml**
85 |
86 | ```xml
87 |
91 |
92 |
93 |
98 |
99 |
105 |
106 |
107 | ```
108 |
109 | ### Setting up listeners
110 |
111 | By default, the tabs don't do anything unless you listen for selection events and do something when the tabs are selected.
112 |
113 | **MainActivity.java:**
114 |
115 | ```java
116 | public class MainActivity extends Activity {
117 | @Override
118 | protected void onCreate(@Nullable Bundle savedInstanceState) {
119 | super.onCreate(savedInstanceState);
120 | setContentView(R.layout.activity_main);
121 |
122 | BottomBar bottomBar = (BottomBar) findViewById(R.id.bottomBar);
123 | bottomBar.setOnTabSelectListener(new OnTabSelectListener() {
124 | @Override
125 | public void onTabSelected(@IdRes int tabId) {
126 | if (tabId == R.id.tab_favorites) {
127 | // The tab with id R.id.tab_favorites was selected,
128 | // change your content accordingly.
129 | }
130 | }
131 | });
132 | }
133 | }
134 | ```
135 |
136 | If you want to listen for reselection events, here's how you do it:
137 |
138 | ```java
139 | bottomBar.setOnTabReselectListener(new OnTabReselectListener() {
140 | @Override
141 | public void onTabReSelected(@IdRes int tabId) {
142 | if (tabId == R.id.tab_favorites) {
143 | // The tab with id R.id.tab_favorites was reselected,
144 | // change your content accordingly.
145 | }
146 | }
147 | });
148 | ```
149 |
150 | ### Intercepting tab selections
151 |
152 | 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.
153 |
154 | ```java
155 | bottomBar.setTabSelectionInterceptor(new TabSelectionInterceptor() {
156 | @Override
157 | public boolean shouldInterceptTabSelection(@IdRes int oldTabId, @IdRes int newTabId) {
158 | if (newTabId == R.id.tab_pro_feature && !userHasProVersion()) {
159 | startProVersionPurchaseFlow();
160 | return true;
161 | }
162 |
163 | return false;
164 | }
165 | });
166 | ```
167 |
168 | ### Changing icons based on selection state
169 |
170 | If you want to have different icon when a specific tab is selected, just use state list drawables.
171 |
172 | **res/drawable/my_tab_icon.xml**
173 |
174 | ```xml
175 |
176 |
177 |
178 |
179 | ```
180 |
181 | **res/xml/bottombar_tabs.xml**
182 |
183 | ```xml
184 | ...
185 |
189 |
190 | ...
191 | ```
192 |
193 | ### Those color changing tabs look dope. Howdoidodat?
194 |
195 | Just add ```barColorWhenSelected``` to each tab. When that tab is selected, the whole BottomBar background color is changed with a nice animation.
196 |
197 | **res/xml/bottombar_tabs.xml**
198 |
199 | ```xml
200 |
201 |
206 |
207 |
208 | ```
209 |
210 | ### How do I draw it under the navbar?
211 |
212 | First, define a style that is a child of your main application theme:
213 |
214 | **res/values-v21/styles.xml**
215 |
216 | ```xml
217 |
222 | ```
223 |
224 | You'll also have to **make a stub version of the same theme** to avoid crashes in previous API levels than Lollipop:
225 |
226 | **res/values/styles.xml**
227 |
228 | ```xml
229 |
230 | ```
231 |
232 | Also include the same stub in your ```values-land-v21.xml``` to avoid transparent navbar and weird behavior on landscape.
233 |
234 | **res/values-land-v21.xml:**
235 |
236 | ```xml
237 |
238 | ```
239 |
240 | Apply the theme in ```AndroidManifest.xml``` for your Activity.
241 |
242 | **AndroidManifest.xml:**
243 |
244 | ```xml
245 |
246 | ```
247 |
248 | Finally, set ```bb_behavior``` to include the ```underNavbar``` flag and you're good to go!
249 |
250 | **activity_my_awesome.xml:**
251 |
252 | ```xml
253 |
260 | ```
261 |
262 | ### What about Tablets?
263 |
264 | Specify a different layout for your activity in ```res/layout-sw600dp``` folder and set ```bb_tabletMode``` to true.
265 |
266 | **res/layout-sw600dp/activity_main.xml:**
267 |
268 | ```xml
269 |
274 |
275 |
282 |
283 |
284 |
289 |
290 |
291 | ```
292 |
293 | ### How do I hide it automatically on scroll?
294 |
295 | Easy-peasy!
296 |
297 | **activity_main.xml:**
298 |
299 | ```xml
300 |
304 |
305 |
309 |
310 |
311 |
312 |
313 |
314 |
321 |
322 |
323 | ```
324 |
325 | ### Badges
326 |
327 | You can easily add badges for showing an unread message count or new items / whatever you like.
328 |
329 | ```java
330 | BottomBarTab nearby = bottomBar.getTabWithId(R.id.tab_nearby);
331 | nearby.setBadgeCount(5);
332 |
333 | // Remove the badge when you're done with it.
334 | nearby.removeBadge/();
335 | ```
336 |
337 | ## All customization options
338 |
339 | ### For the BottomBar
340 |
341 | ```xml
342 |
358 | ```
359 |
360 |
361 | bb_tabXmlResource
362 | the XML Resource id for your tabs, that reside in values/xml/
363 | bb_tabletMode
364 | if you want the BottomBar to behave differently for tablets. There's an example of this in the sample project!
365 | bb_behavior
366 | shifting
: the selected tab is wider than the rest. shy
: put the BottomBar inside a CoordinatorLayout and it'll automatically hide on scroll! underNavbar
: draw the BottomBar under the navBar!
367 | bb_inActiveTabAlpha
368 | the alpha value for inactive tabs, that's used in the tab icons and titles.
369 | bb_activeTabAlpha
370 | the alpha value for active tabs, that's used in the tab icons and titles.
371 | bb_inActiveTabColor
372 | the color for inactive tabs, that's used in the tab icons and titles.
373 | bb_activeTabColor
374 | the color for active tabs, that's used in the tab icons and titles.
375 | bb_badgeBackgroundColor
376 | the background color for any Badges in this BottomBar.
377 | bb_badgesHideWhenActive
378 | whether badges should be hidden for active tabs, defaults to true.
379 | bb_titleTextAppearance
380 | custom textAppearance for the titles
381 | bb_titleTypeFace
382 | path for your custom font file, such as fonts/MySuperDuperFont.ttf
. In that case your font path would look like src/main/assets/fonts/MySuperDuperFont.ttf
, but you only need to provide fonts/MySuperDuperFont.ttf
, as the asset folder will be auto-filled for you.
383 | bb_showShadow
384 | controls whether the shadow is shown or hidden, defaults to true.
385 |
386 |
387 | ### For the tabs
388 |
389 | ```xml
390 |
399 | ```
400 |
401 |
402 | inActiveColor
403 | the color for inactive tabs, that's used in the tab icons and titles.
404 | activeColor
405 | the color for active tabs, that's used in the tab icons and titles.
406 | barColorWhenSelected
407 | the color that the whole BottomBar should be when selected this tab.
408 | badgeBackgroundColor
409 | the background color for any Badges in this tab.
410 | badgeHidesWhenActive
411 | whether or not the badge should be hidden when this tab is selected, defaults to true.
412 |
413 |
414 |
415 |
416 | ## Apps using BottomBar
417 |
418 |
419 | * [Nearby](https://play.google.com/store/apps/details?id=com.synergetechsolutions.nearbylive) : A location-based social networking app with over 5 million users.
420 | * [FragNav](https://github.com/ncapdevi/FragNav) : An Android Library for managing multiple stacks of Fragments. BottomBar is used in the sample app.
421 | * [BottomNavigationBar](https://github.com/pocheshire/BottomNavigationBar) : BottomBar ported to C# for Xamarin developers
422 | * [KyudoScoreBookTeam](https://play.google.com/store/apps/details?id=com.bowyer.app.android.kyudoscoreteam&hl=en) : BottomBar is used in the KyudoScoreBookTeam app.
423 | * [memeham](https://play.google.com/store/apps/details?id=com.memeham.beyourself.memeham) : BottomBar is used in the memeham app.
424 | * [NewsCatchr](https://play.google.com/store/apps/details?id=jlelse.readit) : A newsreader app, which uses this BottomBar library.
425 | * [GitSkarios](https://play.google.com/store/apps/details?id=com.alorma.github) : A Github android App, to visit your repositories, gists and more!
426 | * [Code](https://github.com/gitskarios/Gitskarios)
427 |
428 | Send me a pull request with modified README.md to get a shoutout!
429 |
430 | ## Contributions
431 |
432 | Feel free to create issues and pull requests.
433 |
434 | When creating pull requests, **more is more:** I'd like to see ten small pull requests separated by feature rather than all those combined into a huge one.
435 |
436 | ## License
437 |
438 | ```
439 | BottomBar library for Android
440 | Copyright (c) 2016 Iiro Krankka (http://github.com/roughike).
441 |
442 | Licensed under the Apache License, Version 2.0 (the "License");
443 | you may not use this file except in compliance with the License.
444 | You may obtain a copy of the License at
445 |
446 | http://www.apache.org/licenses/LICENSE-2.0
447 |
448 | Unless required by applicable law or agreed to in writing, software
449 | distributed under the License is distributed on an "AS IS" BASIS,
450 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
451 | See the License for the specific language governing permissions and
452 | limitations under the License.
453 | ```
454 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion rootProject.ext.compileSdkVersion
5 | buildToolsVersion rootProject.ext.buildToolsVersion
6 |
7 | defaultConfig {
8 | applicationId "com.example.bottombar.sample"
9 | minSdkVersion rootProject.ext.minSdkVersion
10 | targetSdkVersion rootProject.ext.targetSdkVersion
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 | configurations.all {
22 | resolutionStrategy.force "com.android.support:support-annotations:${rootProject.ext.supportLibraryVersion}"
23 | }
24 |
25 | dependencies {
26 | compile fileTree(dir: 'libs', include: ['*.jar'])
27 | compile project(':bottom-bar')
28 | compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibraryVersion}"
29 | compile "com.android.support:design:${rootProject.ext.supportLibraryVersion}"
30 |
31 | androidTestCompile 'junit:junit:4.12'
32 | androidTestCompile 'com.android.support.test:runner:0.5'
33 | androidTestCompile 'com.android.support.test:rules:0.5'
34 | androidTestCompile 'org.mockito:mockito-core:1.10.19'
35 | androidTestCompile "com.google.dexmaker:dexmaker:1.2"
36 | androidTestCompile "com.google.dexmaker:dexmaker-mockito:1.2"
37 | }
38 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Users\Iiro\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/GREAT-VIBES-LICENSE:
--------------------------------------------------------------------------------
1 | SIL Open Font License v1.10
2 |
3 | This license can also be found at this permalink: https://www.fontsquirrel.com/license/great-vibes
4 |
5 | Copyright (c) 2012, TypeSETit, LLC (typesetit@att.net),
6 | with Reserved Font Name "Great Vibes"
7 |
8 | This Font Software is licensed under the SIL Open Font License, Version 1.1.
9 | This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
10 |
11 | —————————————————————————————-
12 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
13 | —————————————————————————————-
14 |
15 | PREAMBLE
16 | 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.
17 |
18 | 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.
19 |
20 | DEFINITIONS
21 | “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.
22 |
23 | “Reserved Font Name” refers to any names specified as such after the copyright statement(s).
24 |
25 | “Original Version” refers to the collection of Font Software components as distributed by the Copyright Holder(s).
26 |
27 | “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.
28 |
29 | “Author” refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
30 |
31 | PERMISSION & CONDITIONS
32 | 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:
33 |
34 | 1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
35 |
36 | 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.
37 |
38 | 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.
39 |
40 | 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.
41 |
42 | 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.
43 |
44 | TERMINATION
45 | This license becomes null and void if any of the above conditions are not met.
46 |
47 | DISCLAIMER
48 | 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.
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/GreatVibes-Regular.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/assets/fonts/GreatVibes-Regular.otf
--------------------------------------------------------------------------------
/app/src/main/java/com/example/bottombar/sample/BadgeActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.bottombar.sample;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.IdRes;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.widget.TextView;
8 | import android.widget.Toast;
9 |
10 | import com.roughike.bottombar.BottomBar;
11 | import com.roughike.bottombar.BottomBarTab;
12 | import com.roughike.bottombar.OnTabReselectListener;
13 | import com.roughike.bottombar.OnTabSelectListener;
14 |
15 | /**
16 | * Created by iiro on 7.6.2016.
17 | */
18 | public class BadgeActivity extends AppCompatActivity {
19 | private TextView messageView;
20 |
21 | @Override
22 | protected void onCreate(@Nullable Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_three_tabs);
25 |
26 | messageView = (TextView) findViewById(R.id.messageView);
27 |
28 | final BottomBar bottomBar = (BottomBar) findViewById(R.id.bottomBar);
29 | bottomBar.setOnTabSelectListener(new OnTabSelectListener() {
30 | @Override
31 | public void onTabSelected(@IdRes int tabId) {
32 | messageView.setText(TabMessage.get(tabId, false));
33 | }
34 | });
35 |
36 | bottomBar.setOnTabReselectListener(new OnTabReselectListener() {
37 | @Override
38 | public void onTabReSelected(@IdRes int tabId) {
39 | Toast.makeText(getApplicationContext(), TabMessage.get(tabId, true), Toast.LENGTH_LONG).show();
40 | }
41 | });
42 |
43 | BottomBarTab nearby = bottomBar.getTabWithId(R.id.tab_nearby);
44 | nearby.setBadgeCount(5);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/bottombar/sample/CustomColorAndFontActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.bottombar.sample;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.IdRes;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.widget.TextView;
7 | import android.widget.Toast;
8 |
9 | import com.roughike.bottombar.BottomBar;
10 | import com.roughike.bottombar.OnTabReselectListener;
11 | import com.roughike.bottombar.OnTabSelectListener;
12 |
13 | /**
14 | * Created by mikemilla on 7.17.2016.
15 | * http://mikemilla.com
16 | */
17 | public class CustomColorAndFontActivity extends AppCompatActivity {
18 |
19 | private TextView messageView;
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_custom_color_and_font);
25 |
26 | messageView = (TextView) findViewById(R.id.messageView);
27 |
28 | BottomBar bottomBar = (BottomBar) findViewById(R.id.bottomBar);
29 | bottomBar.setOnTabSelectListener(new OnTabSelectListener() {
30 | @Override
31 | public void onTabSelected(@IdRes int tabId) {
32 | messageView.setText(TabMessage.get(tabId, false));
33 | }
34 | });
35 |
36 | bottomBar.setOnTabReselectListener(new OnTabReselectListener() {
37 | @Override
38 | public void onTabReSelected(@IdRes int tabId) {
39 | Toast.makeText(getApplicationContext(), TabMessage.get(tabId, true), Toast.LENGTH_LONG).show();
40 | }
41 | });
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/bottombar/sample/FiveColorChangingTabsActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.bottombar.sample;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.IdRes;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.widget.TextView;
8 | import android.widget.Toast;
9 |
10 | import com.roughike.bottombar.BottomBar;
11 | import com.roughike.bottombar.OnTabReselectListener;
12 | import com.roughike.bottombar.OnTabSelectListener;
13 |
14 | /**
15 | * Created by iiro on 7.6.2016.
16 | */
17 | public class FiveColorChangingTabsActivity extends AppCompatActivity {
18 | private TextView messageView;
19 |
20 | @Override
21 | protected void onCreate(@Nullable Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_color_changing_tabs);
24 |
25 | messageView = (TextView) findViewById(R.id.messageView);
26 |
27 | BottomBar bottomBar = (BottomBar) findViewById(R.id.bottomBar);
28 | bottomBar.setOnTabSelectListener(new OnTabSelectListener() {
29 | @Override
30 | public void onTabSelected(@IdRes int tabId) {
31 | messageView.setText(TabMessage.get(tabId, false));
32 | }
33 | });
34 |
35 | bottomBar.setOnTabReselectListener(new OnTabReselectListener() {
36 | @Override
37 | public void onTabReSelected(@IdRes int tabId) {
38 | Toast.makeText(getApplicationContext(), TabMessage.get(tabId, true), Toast.LENGTH_LONG).show();
39 | }
40 | });
41 | }
42 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/bottombar/sample/IconsOnlyActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.bottombar.sample;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.support.annotation.IdRes;
6 | import android.support.annotation.Nullable;
7 | import android.widget.TextView;
8 | import android.widget.Toast;
9 |
10 | import com.roughike.bottombar.BottomBar;
11 | import com.roughike.bottombar.OnTabReselectListener;
12 | import com.roughike.bottombar.OnTabSelectListener;
13 |
14 | public class IconsOnlyActivity extends Activity {
15 | private TextView messageView;
16 |
17 | @Override
18 | protected void onCreate(@Nullable Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_icons_only);
21 |
22 | messageView = (TextView) findViewById(R.id.messageView);
23 |
24 | BottomBar bottomBar = (BottomBar) findViewById(R.id.bottomBar);
25 | bottomBar.setOnTabSelectListener(new OnTabSelectListener() {
26 | @Override
27 | public void onTabSelected(@IdRes int tabId) {
28 | messageView.setText(TabMessage.get(tabId, false));
29 | }
30 | });
31 |
32 | bottomBar.setOnTabReselectListener(new OnTabReselectListener() {
33 | @Override
34 | public void onTabReSelected(@IdRes int tabId) {
35 | Toast.makeText(getApplicationContext(), TabMessage.get(tabId, true), Toast.LENGTH_LONG).show();
36 | }
37 | });
38 | }
39 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/bottombar/sample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.bottombar.sample;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 |
8 | public class MainActivity extends AppCompatActivity implements View.OnClickListener {
9 | @SuppressWarnings("ConstantConditions")
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_main);
14 |
15 | findViewById(R.id.simple_three_tabs).setOnClickListener(this);
16 | findViewById(R.id.icons_only).setOnClickListener(this);
17 | findViewById(R.id.five_tabs_changing_colors).setOnClickListener(this);
18 | findViewById(R.id.three_tabs_quick_return).setOnClickListener(this);
19 | findViewById(R.id.five_tabs_custom_colors).setOnClickListener(this);
20 | findViewById(R.id.badges).setOnClickListener(this);
21 | }
22 |
23 | @Override
24 | public void onClick(View v) {
25 | Class clazz = null;
26 |
27 | switch (v.getId()) {
28 | case R.id.simple_three_tabs:
29 | clazz = ThreeTabsActivity.class;
30 | break;
31 | case R.id.icons_only:
32 | clazz = IconsOnlyActivity.class;
33 | break;
34 | case R.id.five_tabs_changing_colors:
35 | clazz = FiveColorChangingTabsActivity.class;
36 | break;
37 | case R.id.three_tabs_quick_return:
38 | clazz = ThreeTabsQRActivity.class;
39 | break;
40 | case R.id.five_tabs_custom_colors:
41 | clazz = CustomColorAndFontActivity.class;
42 | break;
43 | case R.id.badges:
44 | clazz = BadgeActivity.class;
45 | break;
46 | }
47 |
48 | startActivity(new Intent(this, clazz));
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/bottombar/sample/SampleFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * BottomBar library for Android
3 | * Copyright (c) 2016 Iiro Krankka (http://github.com/roughike).
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.example.bottombar.sample;
19 |
20 | import android.os.Bundle;
21 | import android.support.annotation.Nullable;
22 | import android.support.v4.app.Fragment;
23 | import android.view.LayoutInflater;
24 | import android.view.View;
25 | import android.view.ViewGroup;
26 | import android.widget.TextView;
27 |
28 | /**
29 | * Created by Iiro Krankka (http://github.com/roughike)
30 | */
31 | public class SampleFragment extends Fragment {
32 | private static final String ARG_TEXT = "ARG_TEXT";
33 |
34 | public SampleFragment() {
35 | }
36 |
37 | public static SampleFragment newInstance(String text) {
38 | Bundle args = new Bundle();
39 | args.putString(ARG_TEXT, text);
40 |
41 | SampleFragment sampleFragment = new SampleFragment();
42 | sampleFragment.setArguments(args);
43 |
44 | return sampleFragment;
45 | }
46 |
47 | @Nullable
48 | @Override
49 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
50 | TextView textView = new TextView(getActivity());
51 | textView.setText(getArguments().getString(ARG_TEXT));
52 |
53 | return textView;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/bottombar/sample/TabMessage.java:
--------------------------------------------------------------------------------
1 | package com.example.bottombar.sample;
2 |
3 | /**
4 | * Created by iiro on 7.6.2016.
5 | */
6 | public class TabMessage {
7 | public static String get(int menuItemId, boolean isReselection) {
8 | String message = "Content for ";
9 |
10 | switch (menuItemId) {
11 | case R.id.tab_recents:
12 | message += "recents";
13 | break;
14 | case R.id.tab_favorites:
15 | message += "favorites";
16 | break;
17 | case R.id.tab_nearby:
18 | message += "nearby";
19 | break;
20 | case R.id.tab_friends:
21 | message += "friends";
22 | break;
23 | case R.id.tab_food:
24 | message += "food";
25 | break;
26 | }
27 |
28 | if (isReselection) {
29 | message += " WAS RESELECTED! YAY!";
30 | }
31 |
32 | return message;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/bottombar/sample/ThreeTabsActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.bottombar.sample;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.support.annotation.IdRes;
6 | import android.support.annotation.Nullable;
7 | import android.widget.TextView;
8 | import android.widget.Toast;
9 |
10 | import com.roughike.bottombar.BottomBar;
11 | import com.roughike.bottombar.OnTabReselectListener;
12 | import com.roughike.bottombar.OnTabSelectListener;
13 |
14 | /**
15 | * Created by iiro on 7.6.2016.
16 | */
17 | public class ThreeTabsActivity extends Activity {
18 | private TextView messageView;
19 |
20 | @Override
21 | protected void onCreate(@Nullable Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_three_tabs);
24 |
25 | messageView = (TextView) findViewById(R.id.messageView);
26 |
27 | BottomBar bottomBar = (BottomBar) findViewById(R.id.bottomBar);
28 | bottomBar.setOnTabSelectListener(new OnTabSelectListener() {
29 | @Override
30 | public void onTabSelected(@IdRes int tabId) {
31 | messageView.setText(TabMessage.get(tabId, false));
32 | }
33 | });
34 |
35 | bottomBar.setOnTabReselectListener(new OnTabReselectListener() {
36 | @Override
37 | public void onTabReSelected(@IdRes int tabId) {
38 | Toast.makeText(getApplicationContext(), TabMessage.get(tabId, true), Toast.LENGTH_LONG).show();
39 | }
40 | });
41 | }
42 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/bottombar/sample/ThreeTabsQRActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.bottombar.sample;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.IdRes;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.app.AppCompatActivity;
7 |
8 | import com.roughike.bottombar.BottomBar;
9 | import com.roughike.bottombar.OnTabSelectListener;
10 |
11 | /**
12 | * Created by iiro on 7.6.2016.
13 | */
14 | public class ThreeTabsQRActivity extends AppCompatActivity {
15 |
16 | @Override
17 | protected void onCreate(@Nullable Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_three_tabs_quick_return);
20 |
21 | BottomBar bottomBar = (BottomBar) findViewById(R.id.bottomBar);
22 |
23 | // We're doing nothing with this listener here this time. Check example usage
24 | // from ThreeTabsActivity on how to use it.
25 | bottomBar.setOnTabSelectListener(new OnTabSelectListener() {
26 | @Override
27 | public void onTabSelected(@IdRes int tabId) {
28 |
29 | }
30 | });
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_favorites.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-hdpi/ic_favorites.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_friends.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-hdpi/ic_friends.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_nearby.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-hdpi/ic_nearby.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_recents.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-hdpi/ic_recents.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_restaurants.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-hdpi/ic_restaurants.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_favorites.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-mdpi/ic_favorites.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_friends.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-mdpi/ic_friends.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_nearby.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-mdpi/ic_nearby.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_recents.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-mdpi/ic_recents.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_restaurants.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-mdpi/ic_restaurants.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_favorites.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-xhdpi/ic_favorites.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_friends.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-xhdpi/ic_friends.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_nearby.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-xhdpi/ic_nearby.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_recents.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-xhdpi/ic_recents.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_restaurants.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-xhdpi/ic_restaurants.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_favorites.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-xxhdpi/ic_favorites.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_friends.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-xxhdpi/ic_friends.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_nearby.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-xxhdpi/ic_nearby.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_recents.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-xxhdpi/ic_recents.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_restaurants.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-xxhdpi/ic_restaurants.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_favorites.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-xxxhdpi/ic_favorites.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_friends.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-xxxhdpi/ic_friends.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_nearby.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-xxxhdpi/ic_nearby.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_recents.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-xxxhdpi/ic_recents.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_restaurants.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/drawable-xxxhdpi/ic_restaurants.png
--------------------------------------------------------------------------------
/app/src/main/res/layout-sw600dp/activity_color_changing_tabs.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
20 |
21 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout-sw600dp/activity_three_tabs.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_color_changing_tabs.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_custom_color_and_font.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_icons_only.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
21 |
22 |
27 |
28 |
33 |
34 |
39 |
40 |
45 |
46 |
51 |
52 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_three_tabs.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_three_tabs_quick_return.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
19 |
20 |
21 |
22 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-land-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values-sw600dp/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 8dp
6 | 16dp
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed posuere interdum sem. Quisque ligula eros ullamcorper quis, lacinia quis facilisis sed sapien. Mauris varius diam vitae arcu. Sed arcu lectus auctor vitae, consectetuer et venenatis eget velit. Sed augue orci, lacinia eu tincidunt et eleifend nec lacus. Donec ultricies nisl ut felis, suspendisse potenti. Lorem ipsum ligula ut hendrerit mollis, ipsum erat vehicula risus, eu suscipit sem libero nec erat. Aliquam erat volutpat. Sed congue augue vitae neque. Nulla consectetuer porttitor pede. Fusce purus morbi tortor magna condimentum vel, placerat id blandit sit amet tortor.
4 |
5 | Mauris sed libero. Suspendisse facilisis nulla in lacinia laoreet, lorem velit accumsan velit vel mattis libero nisl et sem. Proin interdum maecenas massa turpis sagittis in, interdum non lobortis vitae massa. Quisque purus lectus, posuere eget imperdiet nec sodales id arcu. Vestibulum elit pede dictum eu, viverra non tincidunt eu ligula.
6 |
7 | Nam molestie nec tortor. Donec placerat leo sit amet velit. Vestibulum id justo ut vitae massa. Proin in dolor mauris consequat aliquam. Donec ipsum, vestibulum ullamcorper venenatis augue. Aliquam tempus nisi in auctor vulputate, erat felis pellentesque augue nec, pellentesque lectus justo nec erat. Aliquam et nisl. Quisque sit amet dolor in justo pretium condimentum.
8 |
9 | Vivamus placerat lacus vel vehicula scelerisque, dui enim adipiscing lacus sit amet sagittis, libero enim vitae mi. In neque magna posuere, euismod ac tincidunt tempor est. Ut suscipit nisi eu purus. Proin ut pede mauris eget ipsum. Integer vel quam nunc commodo consequat. Integer ac eros eu tellus dignissim viverra. Maecenas erat aliquam erat volutpat. Ut venenatis ipsum quis turpis. Integer cursus scelerisque lorem. Sed nec mauris id quam blandit consequat. Cras nibh mi hendrerit vitae, dapibus et aliquam et magna. Nulla vitae elit. Mauris consectetuer odio vitae augue.
10 |
11 | Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed posuere interdum sem. Quisque ligula eros ullamcorper quis, lacinia quis facilisis sed sapien. Mauris varius diam vitae arcu. Sed arcu lectus auctor vitae, consectetuer et venenatis eget velit. Sed augue orci, lacinia eu tincidunt et eleifend nec lacus. Donec ultricies nisl ut felis, suspendisse potenti. Lorem ipsum ligula ut hendrerit mollis, ipsum erat vehicula risus, eu suscipit sem libero nec erat. Aliquam erat volutpat. Sed congue augue vitae neque. Nulla consectetuer porttitor pede. Fusce purus morbi tortor magna condimentum vel, placerat id blandit sit amet tortor.
12 |
13 | Mauris sed libero. Suspendisse facilisis nulla in lacinia laoreet, lorem velit accumsan velit vel mattis libero nisl et sem. Proin interdum maecenas massa turpis sagittis in, interdum non lobortis vitae massa. Quisque purus lectus, posuere eget imperdiet nec sodales id arcu. Vestibulum elit pede dictum eu, viverra non tincidunt eu ligula.
14 |
15 | Nam molestie nec tortor. Donec placerat leo sit amet velit. Vestibulum id justo ut vitae massa. Proin in dolor mauris consequat aliquam. Donec ipsum, vestibulum ullamcorper venenatis augue. Aliquam tempus nisi in auctor vulputate, erat felis pellentesque augue nec, pellentesque lectus justo nec erat. Aliquam et nisl. Quisque sit amet dolor in justo pretium condimentum.
16 |
17 | Vivamus placerat lacus vel vehicula scelerisque, dui enim adipiscing lacus sit amet sagittis, libero enim vitae mi. In neque magna posuere, euismod ac tincidunt tempor est. Ut suscipit nisi eu purus. Proin ut pede mauris eget ipsum. Integer vel quam nunc commodo consequat. Integer ac eros eu tellus dignissim viverra. Maecenas erat aliquam erat volutpat. Ut venenatis ipsum quis turpis. Integer cursus scelerisque lorem. Sed nec mauris id quam blandit consequat. Cras nibh mi hendrerit vitae, dapibus et aliquam et magna. Nulla vitae elit. Mauris consectetuer odio vitae augue.
18 | CustomColorActivity
19 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
13 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/bottombar_tabs_color_changing.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
13 |
18 |
23 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/bottombar_tabs_five.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
11 |
15 |
19 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/bottombar_tabs_three.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
11 |
15 |
--------------------------------------------------------------------------------
/bottom-bar/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.kt3k.coveralls'
3 |
4 | ext {
5 | bintrayRepo = 'maven'
6 | bintrayName = 'bottom-bar'
7 |
8 | publishedGroupId = 'com.roughike'
9 | libraryName = 'bottom-bar'
10 | artifact = 'bottom-bar'
11 |
12 | libraryDescription = 'A custom view component that mimics the Material Design "Bottom navigation" pattern.'
13 |
14 | siteUrl = 'https://github.com/roughike/BottomBar'
15 | gitUrl = 'https://github.com/roughike/BottomBar.git'
16 |
17 | libraryVersion = '2.3.1'
18 |
19 | developerId = 'roughike'
20 | developerName = 'Iiro Krankka'
21 | developerEmail = 'iiro.krankka@gmail.com'
22 |
23 | licenseName = 'The Apache Software License, Version 2.0'
24 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
25 | allLicenses = ["Apache-2.0"]
26 | }
27 |
28 | android {
29 | compileSdkVersion rootProject.ext.compileSdkVersion
30 | buildToolsVersion rootProject.ext.buildToolsVersion
31 |
32 |
33 | buildTypes {
34 | debug {
35 | testCoverageEnabled true
36 | }
37 | }
38 |
39 | defaultConfig {
40 | minSdkVersion rootProject.ext.minSdkVersion
41 | targetSdkVersion rootProject.ext.targetSdkVersion
42 | versionCode 1
43 | versionName "1.0"
44 |
45 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
46 | }
47 | }
48 |
49 | coveralls {
50 | jacocoReportPath = "${buildDir}/reports/coverage/debug/report.xml"
51 | }
52 |
53 | tasks.coveralls {
54 | dependsOn 'connectedAndroidTest'
55 | onlyIf { System.env.'CI' }
56 | }
57 |
58 | dependencies {
59 | compile fileTree(dir: 'libs', include: ['*.jar'])
60 | compile 'com.android.support:appcompat-v7:' + rootProject.ext.supportLibraryVersion
61 | compile 'com.android.support:design:' + rootProject.ext.supportLibraryVersion
62 |
63 | testCompile 'junit:junit:' + rootProject.ext.junitVersion
64 |
65 | androidTestCompile 'junit:junit:4.12'
66 | androidTestCompile 'com.android.support.test:runner:0.5'
67 | androidTestCompile 'com.android.support.test:rules:0.5'
68 | androidTestCompile 'org.mockito:mockito-core:1.+'
69 | androidTestCompile "com.google.dexmaker:dexmaker:1.2"
70 | androidTestCompile "com.google.dexmaker:dexmaker-mockito:1.2"
71 | }
72 |
73 | apply plugin: 'com.github.dcendents.android-maven'
74 |
75 | group = publishedGroupId // Maven Group ID for the artifact
76 |
77 | install {
78 | repositories.mavenInstaller {
79 | // This generates POM.xml with proper parameters
80 | pom {
81 | project {
82 | packaging 'aar'
83 | groupId publishedGroupId
84 | artifactId artifact
85 |
86 | // Add your description here
87 | name libraryName
88 | description libraryDescription
89 | url siteUrl
90 |
91 | // Set your license
92 | licenses {
93 | license {
94 | name licenseName
95 | url licenseUrl
96 | }
97 | }
98 | developers {
99 | developer {
100 | id developerId
101 | name developerName
102 | email developerEmail
103 | }
104 | }
105 | scm {
106 | connection gitUrl
107 | developerConnection gitUrl
108 | url siteUrl
109 |
110 | }
111 | }
112 | }
113 | }
114 | }
115 |
116 | apply plugin: 'com.jfrog.bintray'
117 |
118 | version = libraryVersion
119 |
120 | if (project.hasProperty("android")) { // Android libraries
121 | task sourcesJar(type: Jar) {
122 | classifier = 'sources'
123 | from android.sourceSets.main.java.srcDirs
124 | }
125 |
126 | task javadoc(type: Javadoc) {
127 | source = android.sourceSets.main.java.srcDirs
128 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
129 | }
130 | } else { // Java libraries
131 | task sourcesJar(type: Jar, dependsOn: classes) {
132 | classifier = 'sources'
133 | from sourceSets.main.allSource
134 | }
135 | }
136 |
137 | task javadocJar(type: Jar, dependsOn: javadoc) {
138 | classifier = 'javadoc'
139 | from javadoc.destinationDir
140 | }
141 |
142 | artifacts {
143 | archives javadocJar
144 | archives sourcesJar
145 | }
146 |
147 | // Bintray
148 | File localProps = project.rootProject.file('local.properties')
149 |
150 | if (localProps.exists()) {
151 | Properties properties = new Properties()
152 | properties.load(localProps.newDataInputStream())
153 |
154 | bintray {
155 | user = properties.getProperty("bintray.user")
156 | key = properties.getProperty("bintray.apikey")
157 |
158 | configurations = ['archives']
159 | pkg {
160 | repo = bintrayRepo
161 | name = bintrayName
162 | desc = libraryDescription
163 | websiteUrl = siteUrl
164 | vcsUrl = gitUrl
165 | licenses = allLicenses
166 | publish = true
167 | publicDownloadNumbers = true
168 | version {
169 | desc = libraryDescription
170 | gpg {
171 | sign = true //Determines whether to GPG sign the files. The default is false
172 | passphrase = properties.getProperty("bintray.gpg.password")
173 | //Optional. The passphrase for GPG signing'
174 | }
175 | }
176 | }
177 | }
178 | }
--------------------------------------------------------------------------------
/bottom-bar/src/androidTest/assets/fonts/GREAT-VIBES-LICENSE:
--------------------------------------------------------------------------------
1 | SIL Open Font License v1.10
2 |
3 | This license can also be found at this permalink: https://www.fontsquirrel.com/license/great-vibes
4 |
5 | Copyright (c) 2012, TypeSETit, LLC (typesetit@att.net),
6 | with Reserved Font Name "Great Vibes"
7 |
8 | This Font Software is licensed under the SIL Open Font License, Version 1.1.
9 | This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
10 |
11 | —————————————————————————————-
12 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
13 | —————————————————————————————-
14 |
15 | PREAMBLE
16 | 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.
17 |
18 | 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.
19 |
20 | DEFINITIONS
21 | “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.
22 |
23 | “Reserved Font Name” refers to any names specified as such after the copyright statement(s).
24 |
25 | “Original Version” refers to the collection of Font Software components as distributed by the Copyright Holder(s).
26 |
27 | “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.
28 |
29 | “Author” refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
30 |
31 | PERMISSION & CONDITIONS
32 | 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:
33 |
34 | 1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
35 |
36 | 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.
37 |
38 | 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.
39 |
40 | 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.
41 |
42 | 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.
43 |
44 | TERMINATION
45 | This license becomes null and void if any of the above conditions are not met.
46 |
47 | DISCLAIMER
48 | 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.
--------------------------------------------------------------------------------
/bottom-bar/src/androidTest/assets/fonts/GreatVibes-Regular.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/bottom-bar/src/androidTest/assets/fonts/GreatVibes-Regular.otf
--------------------------------------------------------------------------------
/bottom-bar/src/androidTest/java/com/roughike/bottombar/BadgeTest.java:
--------------------------------------------------------------------------------
1 | package com.roughike.bottombar;
2 |
3 | import android.os.Bundle;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.annotation.UiThreadTest;
6 | import android.support.test.filters.LargeTest;
7 | import android.support.test.runner.AndroidJUnit4;
8 |
9 | import org.junit.Assert;
10 | import org.junit.Before;
11 | import org.junit.Test;
12 | import org.junit.runner.RunWith;
13 |
14 | import static junit.framework.Assert.assertEquals;
15 | import static junit.framework.Assert.assertFalse;
16 | import static junit.framework.Assert.assertNull;
17 | import static org.junit.Assert.assertNotEquals;
18 | import static org.junit.Assert.assertNotNull;
19 | import static org.junit.Assert.assertTrue;
20 |
21 | /**
22 | * Created by iiro on 8.8.2016.
23 | */
24 | @RunWith(AndroidJUnit4.class)
25 | @LargeTest
26 | public class BadgeTest {
27 | private BottomBar bottomBar;
28 | private BottomBarTab nearby;
29 |
30 | @Before
31 | public void setUp() {
32 | bottomBar = new BottomBar(InstrumentationRegistry.getContext());
33 | bottomBar.setItems(com.roughike.bottombar.test.R.xml.dummy_tabs_three);
34 | nearby = bottomBar.getTabWithId(com.roughike.bottombar.test.R.id.tab_nearby);
35 | nearby.setBadgeCount(5);
36 | }
37 |
38 | @Test
39 | public void hasNoBadges_ExceptNearby() {
40 | assertNull(bottomBar.getTabWithId(com.roughike.bottombar.test.R.id.tab_favorites).badge);
41 | assertNull(bottomBar.getTabWithId(com.roughike.bottombar.test.R.id.tab_friends).badge);
42 |
43 | assertNotNull(nearby.badge);
44 | }
45 |
46 | @Test
47 | @UiThreadTest
48 | public void whenTabWithBadgeClicked_BadgeIsHidden() {
49 | InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
50 | @Override
51 | public void run() {
52 | bottomBar.selectTabWithId(com.roughike.bottombar.test.R.id.tab_nearby);
53 | assertFalse(nearby.badge.isVisible());
54 | }
55 | });
56 | }
57 |
58 | @Test
59 | @UiThreadTest
60 | public void whenBadgeCountIsZero_BadgeIsRemoved() {
61 | nearby.setBadgeCount(0);
62 | assertNull(nearby.badge);
63 | }
64 |
65 | @Test
66 | @UiThreadTest
67 | public void whenBadgeCountIsNegative_BadgeIsRemoved() {
68 | nearby.setBadgeCount(-1);
69 | assertNull(nearby.badge);
70 | }
71 |
72 | @Test
73 | @UiThreadTest
74 | public void whenBadgeStateRestored_CountPersists() {
75 | nearby.setBadgeCount(1);
76 | assertEquals(1, nearby.badge.getCount());
77 |
78 |
79 | int tabIndex = nearby.getIndexInTabContainer();
80 | Bundle savedInstanceState = new Bundle();
81 | savedInstanceState.putInt(BottomBarTab.STATE_BADGE_COUNT + tabIndex, 2);
82 | nearby.restoreState(savedInstanceState);
83 |
84 | assertEquals(2, nearby.badge.getCount());
85 | }
86 |
87 | @Test
88 | @UiThreadTest
89 | public void badgeRemovedProperly() {
90 | assertNotEquals(bottomBar.findViewById(R.id.bb_bottom_bar_item_container), nearby.getOuterView());
91 | assertEquals(2, nearby.getOuterView().getChildCount());
92 | assertTrue(nearby.getOuterView().getChildAt(1) instanceof BottomBarBadge);
93 |
94 | nearby.removeBadge();
95 | assertNull(nearby.badge);
96 | assertEquals(bottomBar.findViewById(R.id.bb_bottom_bar_item_container), nearby.getOuterView());
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/bottom-bar/src/androidTest/java/com/roughike/bottombar/BottomBarTabTest.java:
--------------------------------------------------------------------------------
1 | package com.roughike.bottombar;
2 |
3 | import android.os.Bundle;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 | import android.widget.FrameLayout;
7 |
8 | import org.junit.Before;
9 | import org.junit.Test;
10 | import org.junit.runner.RunWith;
11 |
12 | import static org.junit.Assert.assertEquals;
13 |
14 | @RunWith(AndroidJUnit4.class)
15 | public class BottomBarTabTest {
16 | private FrameLayout tabContainer;
17 | private BottomBarTab tab;
18 |
19 | @Before
20 | public void setUp() {
21 | tabContainer = new FrameLayout(InstrumentationRegistry.getContext());
22 | tab = new BottomBarTab(InstrumentationRegistry.getContext());
23 |
24 | tabContainer.addView(tab);
25 | }
26 |
27 | @Test
28 | public void correctLayoutReturnedForFixedTab() {
29 | tab.setType(BottomBarTab.Type.FIXED);
30 | assertEquals(R.layout.bb_bottom_bar_item_fixed, tab.getLayoutResource());
31 | }
32 |
33 | @Test(expected = IllegalStateException.class)
34 | public void setIsTitleless_WhenTrueAndIconDoesNotExist_ThrowsException() {
35 | tab.setIsTitleless(true);
36 | assertEquals(R.layout.bb_bottom_bar_item_titleless, tab.getLayoutResource());
37 | }
38 |
39 | @Test
40 | public void correctLayoutForShiftingTab() {
41 | tab.setType(BottomBarTab.Type.SHIFTING);
42 | assertEquals(R.layout.bb_bottom_bar_item_shifting, tab.getLayoutResource());
43 | }
44 |
45 | @Test
46 | public void correctLayoutForTabletTab() {
47 | tab.setType(BottomBarTab.Type.TABLET);
48 | assertEquals(R.layout.bb_bottom_bar_item_fixed_tablet, tab.getLayoutResource());
49 | }
50 |
51 | @Test
52 | public void testSavedStateWithBadge_StaysIntact() {
53 | tab.setBadgeCount(5);
54 | tab.setIndexInContainer(69);
55 | assertEquals(69, tab.getIndexInTabContainer());
56 |
57 | Bundle savedState = (Bundle) tab.onSaveInstanceState();
58 | assertEquals(5, savedState.getInt(BottomBarTab.STATE_BADGE_COUNT + 69));
59 |
60 | tab.setBadgeCount(9);
61 | assertEquals(9, tab.badge.getCount());
62 |
63 | tab.onRestoreInstanceState(savedState);
64 | assertEquals(5, tab.badge.getCount());
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/bottom-bar/src/androidTest/java/com/roughike/bottombar/TabParserTest.java:
--------------------------------------------------------------------------------
1 | package com.roughike.bottombar;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.graphics.drawable.Drawable;
6 | import android.support.test.InstrumentationRegistry;
7 | import android.support.test.filters.LargeTest;
8 | import android.support.test.runner.AndroidJUnit4;
9 | import android.support.v4.content.ContextCompat;
10 |
11 | import org.junit.Before;
12 | import org.junit.Test;
13 | import org.junit.runner.RunWith;
14 |
15 | import java.util.List;
16 |
17 | import static org.junit.Assert.assertEquals;
18 | import static org.junit.Assert.assertFalse;
19 | import static org.junit.Assert.assertNotNull;
20 | import static org.junit.Assert.assertNotSame;
21 | import static org.junit.Assert.assertTrue;
22 |
23 | @RunWith(AndroidJUnit4.class)
24 | @LargeTest
25 | public class TabParserTest {
26 | private Context context;
27 | private List tabs;
28 |
29 | @Before
30 | public void setUp() throws Exception {
31 | context = InstrumentationRegistry.getContext();
32 | tabs = new TabParser(
33 | context,
34 | new BottomBarTab.Config.Builder().build(),
35 | com.roughike.bottombar.test.R.xml.dummy_tabs_five
36 | ).parseTabs();
37 | }
38 |
39 | @Test
40 | public void correctAmountOfTabs() {
41 | assertEquals(5, tabs.size());
42 | }
43 |
44 | @Test
45 | public void idsNotEmpty() {
46 | assertNotSame(0, tabs.get(0).getId());
47 | assertNotSame(0, tabs.get(1).getId());
48 | assertNotSame(0, tabs.get(2).getId());
49 | assertNotSame(0, tabs.get(3).getId());
50 | assertNotSame(0, tabs.get(4).getId());
51 | }
52 |
53 | @Test
54 | public void correctTabTitles() {
55 | assertEquals("Recents", tabs.get(0).getTitle());
56 | assertEquals("Favorites", tabs.get(1).getTitle());
57 | assertEquals("Nearby", tabs.get(2).getTitle());
58 | assertEquals("Friends", tabs.get(3).getTitle());
59 | assertEquals("Food", tabs.get(4).getTitle());
60 | }
61 |
62 | @Test
63 | public void correctInActiveColors() {
64 | assertEquals(Color.parseColor("#00FF00"), tabs.get(0).getInActiveColor());
65 | assertEquals(Color.parseColor("#0000FF"), tabs.get(1).getInActiveColor());
66 | assertEquals(Color.parseColor("#FF0000"), tabs.get(2).getInActiveColor());
67 | assertEquals(Color.parseColor("#F0F000"), tabs.get(3).getInActiveColor());
68 | assertEquals(Color.parseColor("#F00F00"), tabs.get(4).getInActiveColor());
69 | }
70 |
71 | @Test
72 | public void correctActiveColors() {
73 | assertEquals(Color.parseColor("#FF0000"), tabs.get(0).getActiveColor());
74 |
75 | assertEquals(
76 | ContextCompat.getColor(context, com.roughike.bottombar.test.R.color.test_random_color),
77 | tabs.get(1).getActiveColor()
78 | );
79 |
80 | assertEquals(Color.parseColor("#0000FF"), tabs.get(2).getActiveColor());
81 | assertEquals(Color.parseColor("#DAD666"), tabs.get(3).getActiveColor());
82 | assertEquals(Color.parseColor("#F00F00"), tabs.get(4).getActiveColor());
83 | }
84 |
85 | @Test
86 | public void iconResourcesExist() {
87 | assertNotNull(getDrawableByResource(tabs.get(0).getIconResId()));
88 | assertNotNull(getDrawableByResource(tabs.get(1).getIconResId()));
89 | assertNotNull(getDrawableByResource(tabs.get(2).getIconResId()));
90 | assertNotNull(getDrawableByResource(tabs.get(3).getIconResId()));
91 | assertNotNull(getDrawableByResource(tabs.get(4).getIconResId()));
92 | }
93 |
94 | @Test
95 | public void iconResourceIdsAsExpected() {
96 | int expectedId = com.roughike.bottombar.test.R.drawable.empty_icon;
97 |
98 | assertEquals(expectedId, tabs.get(0).getIconResId());
99 | assertEquals(expectedId, tabs.get(1).getIconResId());
100 | assertEquals(expectedId, tabs.get(2).getIconResId());
101 | assertEquals(expectedId, tabs.get(3).getIconResId());
102 | assertEquals(expectedId, tabs.get(4).getIconResId());
103 | }
104 |
105 | @Test
106 | public void barColorWhenSelectedAsExpected() {
107 | assertEquals(Color.parseColor("#FF0000"), tabs.get(0).getBarColorWhenSelected());
108 | assertEquals(Color.parseColor("#00FF00"), tabs.get(1).getBarColorWhenSelected());
109 | assertEquals(Color.parseColor("#F00000"), tabs.get(2).getBarColorWhenSelected());
110 | assertEquals(Color.parseColor("#00F000"), tabs.get(3).getBarColorWhenSelected());
111 | assertEquals(Color.parseColor("#00F0F0"), tabs.get(4).getBarColorWhenSelected());
112 | }
113 |
114 | @Test
115 | public void badgeBackgroundColorAsExpected() {
116 | assertEquals(Color.parseColor("#FF0000"), tabs.get(0).getBadgeBackgroundColor());
117 | assertEquals(Color.parseColor("#00FF00"), tabs.get(1).getBadgeBackgroundColor());
118 | assertEquals(Color.parseColor("#F00000"), tabs.get(2).getBadgeBackgroundColor());
119 | assertEquals(Color.parseColor("#00F000"), tabs.get(3).getBadgeBackgroundColor());
120 | assertEquals(Color.parseColor("#00F0F0"), tabs.get(4).getBadgeBackgroundColor());
121 | }
122 |
123 | @Test
124 | public void correctBadgeHidingPolicies() {
125 | assertFalse(tabs.get(0).getBadgeHidesWhenActive());
126 | assertTrue(tabs.get(1).getBadgeHidesWhenActive());
127 | assertFalse(tabs.get(2).getBadgeHidesWhenActive());
128 | assertTrue(tabs.get(3).getBadgeHidesWhenActive());
129 | assertTrue(tabs.get(4).getBadgeHidesWhenActive());
130 | }
131 |
132 | @Test
133 | public void titlelessTabsAsExpected() {
134 | assertFalse(tabs.get(0).isTitleless());
135 | assertFalse(tabs.get(1).isTitleless());
136 | assertTrue(tabs.get(2).isTitleless());
137 | assertFalse(tabs.get(3).isTitleless());
138 | assertTrue(tabs.get(4).isTitleless());
139 | }
140 |
141 | private Drawable getDrawableByResource(int iconResId) {
142 | return ContextCompat.getDrawable(context, iconResId);
143 | }
144 | }
--------------------------------------------------------------------------------
/bottom-bar/src/androidTest/res/drawable-nodpi/empty_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/bottom-bar/src/androidTest/res/drawable-nodpi/empty_icon.png
--------------------------------------------------------------------------------
/bottom-bar/src/androidTest/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FAB123
4 | #DAD666
5 |
--------------------------------------------------------------------------------
/bottom-bar/src/androidTest/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Favorites
3 | Friends
4 |
5 |
--------------------------------------------------------------------------------
/bottom-bar/src/androidTest/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/bottom-bar/src/androidTest/res/xml/dummy_tabs_five.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/bottom-bar/src/androidTest/res/xml/dummy_tabs_three.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
11 |
15 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/java/com/roughike/bottombar/BadgeCircle.java:
--------------------------------------------------------------------------------
1 | /*
2 | * BottomBar library for Android
3 | * Copyright (c) 2016 Iiro Krankka (http://github.com/roughike).
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.roughike.bottombar;
19 |
20 | import android.graphics.drawable.ShapeDrawable;
21 | import android.graphics.drawable.shapes.OvalShape;
22 | import android.support.annotation.ColorInt;
23 | import android.support.annotation.IntRange;
24 | import android.support.annotation.NonNull;
25 |
26 | /*
27 | * BottomBar library for Android
28 | * Copyright (c) 2016 Iiro Krankka (http://github.com/roughike).
29 | *
30 | * Licensed under the Apache License, Version 2.0 (the "License");
31 | * you may not use this file except in compliance with the License.
32 | * You may obtain a copy of the License at
33 | *
34 | * http://www.apache.org/licenses/LICENSE-2.0
35 | *
36 | * Unless required by applicable law or agreed to in writing, software
37 | * distributed under the License is distributed on an "AS IS" BASIS,
38 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39 | * See the License for the specific language governing permissions and
40 | * limitations under the License.
41 | */
42 | class BadgeCircle {
43 | /**
44 | * Creates a new circle for the Badge background.
45 | *
46 | * @param size the width and height for the circle
47 | * @param color the activeIconColor for the circle
48 | * @return a nice and adorable circle.
49 | */
50 | @NonNull
51 | static ShapeDrawable make(@IntRange(from = 0) int size, @ColorInt int color) {
52 | ShapeDrawable indicator = new ShapeDrawable(new OvalShape());
53 | indicator.setIntrinsicWidth(size);
54 | indicator.setIntrinsicHeight(size);
55 | indicator.getPaint().setColor(color);
56 | return indicator;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/java/com/roughike/bottombar/BadgeContainer.java:
--------------------------------------------------------------------------------
1 | package com.roughike.bottombar;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.NonNull;
5 | import android.widget.FrameLayout;
6 |
7 | /**
8 | * Created by iiro on 29.8.2016.
9 | */
10 | public class BadgeContainer extends FrameLayout {
11 | public BadgeContainer(@NonNull Context context) {
12 | super(context);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/java/com/roughike/bottombar/BatchTabPropertyApplier.java:
--------------------------------------------------------------------------------
1 | package com.roughike.bottombar;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | class BatchTabPropertyApplier {
6 | private final BottomBar bottomBar;
7 |
8 | interface TabPropertyUpdater {
9 | void update(BottomBarTab tab);
10 | }
11 |
12 | BatchTabPropertyApplier(@NonNull BottomBar bottomBar) {
13 | this.bottomBar = bottomBar;
14 | }
15 |
16 | void applyToAllTabs(@NonNull TabPropertyUpdater propertyUpdater) {
17 | int tabCount = bottomBar.getTabCount();
18 |
19 | if (tabCount > 0) {
20 | for (int i = 0; i < tabCount; i++) {
21 | BottomBarTab tab = bottomBar.getTabAtPosition(i);
22 | propertyUpdater.update(tab);
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/java/com/roughike/bottombar/BottomBarBadge.java:
--------------------------------------------------------------------------------
1 | package com.roughike.bottombar;
2 |
3 | import android.content.Context;
4 | import android.graphics.drawable.Drawable;
5 | import android.graphics.drawable.ShapeDrawable;
6 | import android.os.Build;
7 | import android.os.Bundle;
8 | import android.support.annotation.VisibleForTesting;
9 | import android.support.v4.view.ViewCompat;
10 | import android.support.v7.widget.AppCompatImageView;
11 | import android.view.Gravity;
12 | import android.view.ViewGroup;
13 | import android.view.ViewTreeObserver;
14 | import android.widget.TextView;
15 |
16 | /*
17 | * BottomBar library for Android
18 | * Copyright (c) 2016 Iiro Krankka (http://github.com/roughike).
19 | *
20 | * Licensed under the Apache License, Version 2.0 (the "License");
21 | * you may not use this file except in compliance with the License.
22 | * You may obtain a copy of the License at
23 | *
24 | * http://www.apache.org/licenses/LICENSE-2.0
25 | *
26 | * Unless required by applicable law or agreed to in writing, software
27 | * distributed under the License is distributed on an "AS IS" BASIS,
28 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29 | * See the License for the specific language governing permissions and
30 | * limitations under the License.
31 | */
32 | class BottomBarBadge extends TextView {
33 | private int count;
34 | private boolean isVisible = false;
35 |
36 | BottomBarBadge(Context context) {
37 | super(context);
38 | }
39 |
40 | /**
41 | * Set the unread / new item / whatever count for this Badge.
42 | *
43 | * @param count the value this Badge should show.
44 | */
45 | void setCount(int count) {
46 | this.count = count;
47 | setText(String.valueOf(count));
48 | }
49 |
50 | /**
51 | * Get the currently showing count for this Badge.
52 | *
53 | * @return current count for the Badge.
54 | */
55 | int getCount() {
56 | return count;
57 | }
58 |
59 | /**
60 | * Shows the badge with a neat little scale animation.
61 | */
62 | void show() {
63 | isVisible = true;
64 | ViewCompat.animate(this)
65 | .setDuration(150)
66 | .alpha(1)
67 | .scaleX(1)
68 | .scaleY(1)
69 | .start();
70 | }
71 |
72 | /**
73 | * Hides the badge with a neat little scale animation.
74 | */
75 | void hide() {
76 | isVisible = false;
77 | ViewCompat.animate(this)
78 | .setDuration(150)
79 | .alpha(0)
80 | .scaleX(0)
81 | .scaleY(0)
82 | .start();
83 | }
84 |
85 | /**
86 | * Is this badge currently visible?
87 | *
88 | * @return true is this badge is visible, otherwise false.
89 | */
90 | boolean isVisible() {
91 | return isVisible;
92 | }
93 |
94 | void attachToTab(BottomBarTab tab, int backgroundColor) {
95 | ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
96 | ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
97 |
98 | setLayoutParams(params);
99 | setGravity(Gravity.CENTER);
100 | MiscUtils.setTextAppearance(this, R.style.BB_BottomBarBadge_Text);
101 |
102 | setColoredCircleBackground(backgroundColor);
103 | wrapTabAndBadgeInSameContainer(tab);
104 | }
105 |
106 | void setColoredCircleBackground(int circleColor) {
107 | int innerPadding = MiscUtils.dpToPixel(getContext(), 1);
108 | ShapeDrawable backgroundCircle = BadgeCircle.make(innerPadding * 3, circleColor);
109 | setPadding(innerPadding, innerPadding, innerPadding, innerPadding);
110 | setBackgroundCompat(backgroundCircle);
111 | }
112 |
113 | private void wrapTabAndBadgeInSameContainer(final BottomBarTab tab) {
114 | ViewGroup tabContainer = (ViewGroup) tab.getParent();
115 | tabContainer.removeView(tab);
116 |
117 | final BadgeContainer badgeContainer = new BadgeContainer(getContext());
118 | badgeContainer.setLayoutParams(new ViewGroup.LayoutParams(
119 | ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
120 |
121 | badgeContainer.addView(tab);
122 | badgeContainer.addView(this);
123 |
124 | tabContainer.addView(badgeContainer, tab.getIndexInTabContainer());
125 |
126 | badgeContainer.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
127 | @SuppressWarnings("deprecation")
128 | @Override
129 | public void onGlobalLayout() {
130 | badgeContainer.getViewTreeObserver().removeGlobalOnLayoutListener(this);
131 | adjustPositionAndSize(tab);
132 | }
133 | });
134 | }
135 |
136 | void removeFromTab(BottomBarTab tab) {
137 | BadgeContainer badgeAndTabContainer = (BadgeContainer) getParent();
138 | ViewGroup originalTabContainer = (ViewGroup) badgeAndTabContainer.getParent();
139 |
140 | badgeAndTabContainer.removeView(tab);
141 | originalTabContainer.removeView(badgeAndTabContainer);
142 | originalTabContainer.addView(tab, tab.getIndexInTabContainer());
143 | }
144 |
145 | void adjustPositionAndSize(BottomBarTab tab) {
146 | AppCompatImageView iconView = tab.getIconView();
147 | ViewGroup.LayoutParams params = getLayoutParams();
148 |
149 | int size = Math.max(getWidth(), getHeight());
150 | float xOffset = (float) (iconView.getWidth() / 1.25);
151 |
152 | setX(iconView.getX() + xOffset);
153 | setTranslationY(10);
154 |
155 | if (params.width != size || params.height != size) {
156 | params.width = size;
157 | params.height = size;
158 | setLayoutParams(params);
159 | }
160 | }
161 |
162 | @SuppressWarnings("deprecation")
163 | private void setBackgroundCompat(Drawable background) {
164 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
165 | setBackground(background);
166 | } else {
167 | setBackgroundDrawable(background);
168 | }
169 | }
170 | }
171 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/java/com/roughike/bottombar/BottomBarTab.java:
--------------------------------------------------------------------------------
1 | package com.roughike.bottombar;
2 |
3 | import android.animation.ArgbEvaluator;
4 | import android.animation.ValueAnimator;
5 | import android.content.Context;
6 | import android.graphics.Typeface;
7 | import android.os.Build;
8 | import android.os.Bundle;
9 | import android.os.Parcelable;
10 | import android.support.annotation.ColorInt;
11 | import android.support.annotation.NonNull;
12 | import android.support.annotation.VisibleForTesting;
13 | import android.support.v4.view.ViewCompat;
14 | import android.support.v4.view.ViewPropertyAnimatorCompat;
15 | import android.support.v7.widget.AppCompatImageView;
16 | import android.view.Gravity;
17 | import android.view.ViewGroup;
18 | import android.widget.LinearLayout;
19 | import android.widget.TextView;
20 |
21 | /*
22 | * BottomBar library for Android
23 | * Copyright (c) 2016 Iiro Krankka (http://github.com/roughike).
24 | *
25 | * Licensed under the Apache License, Version 2.0 (the "License");
26 | * you may not use this file except in compliance with the License.
27 | * You may obtain a copy of the License at
28 | *
29 | * http://www.apache.org/licenses/LICENSE-2.0
30 | *
31 | * Unless required by applicable law or agreed to in writing, software
32 | * distributed under the License is distributed on an "AS IS" BASIS,
33 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34 | * See the License for the specific language governing permissions and
35 | * limitations under the License.
36 | */
37 | public class BottomBarTab extends LinearLayout {
38 | @VisibleForTesting
39 | static final String STATE_BADGE_COUNT = "STATE_BADGE_COUNT_FOR_TAB_";
40 |
41 | private static final long ANIMATION_DURATION = 150;
42 | private static final float ACTIVE_TITLE_SCALE = 1;
43 | private static final float INACTIVE_FIXED_TITLE_SCALE = 0.86f;
44 | private static final float ACTIVE_SHIFTING_TITLELESS_ICON_SCALE = 1.24f;
45 | private static final float INACTIVE_SHIFTING_TITLELESS_ICON_SCALE = 1f;
46 |
47 | private final int sixDps;
48 | private final int eightDps;
49 | private final int sixteenDps;
50 |
51 | @VisibleForTesting
52 | BottomBarBadge badge;
53 |
54 | private Type type = Type.FIXED;
55 | private boolean isTitleless;
56 | private int iconResId;
57 | private String title;
58 | private float inActiveAlpha;
59 | private float activeAlpha;
60 | private int inActiveColor;
61 | private int activeColor;
62 | private int barColorWhenSelected;
63 | private int badgeBackgroundColor;
64 | private boolean badgeHidesWhenActive;
65 | private AppCompatImageView iconView;
66 | private TextView titleView;
67 | private boolean isActive;
68 | private int indexInContainer;
69 | private int titleTextAppearanceResId;
70 | private Typeface titleTypeFace;
71 |
72 | BottomBarTab(Context context) {
73 | super(context);
74 |
75 | sixDps = MiscUtils.dpToPixel(context, 6);
76 | eightDps = MiscUtils.dpToPixel(context, 8);
77 | sixteenDps = MiscUtils.dpToPixel(context, 16);
78 | }
79 |
80 | void setConfig(@NonNull Config config) {
81 | setInActiveAlpha(config.inActiveTabAlpha);
82 | setActiveAlpha(config.activeTabAlpha);
83 | setInActiveColor(config.inActiveTabColor);
84 | setActiveColor(config.activeTabColor);
85 | setBarColorWhenSelected(config.barColorWhenSelected);
86 | setBadgeBackgroundColor(config.badgeBackgroundColor);
87 | setBadgeHidesWhenActive(config.badgeHidesWhenSelected);
88 | setTitleTextAppearance(config.titleTextAppearance);
89 | setTitleTypeface(config.titleTypeFace);
90 | }
91 |
92 | void prepareLayout() {
93 | inflate(getContext(), getLayoutResource(), this);
94 | setOrientation(VERTICAL);
95 | setGravity(isTitleless? Gravity.CENTER : Gravity.CENTER_HORIZONTAL);
96 | setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
97 | setBackgroundResource(MiscUtils.getDrawableRes(getContext(), R.attr.selectableItemBackgroundBorderless));
98 |
99 | iconView = (AppCompatImageView) findViewById(R.id.bb_bottom_bar_icon);
100 | iconView.setImageResource(iconResId);
101 |
102 | if (type != Type.TABLET && !isTitleless) {
103 | titleView = (TextView) findViewById(R.id.bb_bottom_bar_title);
104 | titleView.setVisibility(VISIBLE);
105 |
106 | if (type == Type.SHIFTING) {
107 | findViewById(R.id.spacer).setVisibility(VISIBLE);
108 | }
109 |
110 | updateTitle();
111 | }
112 |
113 | updateCustomTextAppearance();
114 | updateCustomTypeface();
115 | }
116 |
117 | @VisibleForTesting
118 | int getLayoutResource() {
119 | int layoutResource;
120 | switch (type) {
121 | case FIXED:
122 | layoutResource = R.layout.bb_bottom_bar_item_fixed;
123 | break;
124 | case SHIFTING:
125 | layoutResource = R.layout.bb_bottom_bar_item_shifting;
126 | break;
127 | case TABLET:
128 | layoutResource = R.layout.bb_bottom_bar_item_fixed_tablet;
129 | break;
130 | default:
131 | // should never happen
132 | throw new RuntimeException("Unknown BottomBarTab type.");
133 | }
134 | return layoutResource;
135 | }
136 |
137 | private void updateTitle() {
138 | if (titleView != null) {
139 | titleView.setText(title);
140 | }
141 | }
142 |
143 | @SuppressWarnings("deprecation")
144 | private void updateCustomTextAppearance() {
145 | if (titleView == null || titleTextAppearanceResId == 0) {
146 | return;
147 | }
148 |
149 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
150 | titleView.setTextAppearance(titleTextAppearanceResId);
151 | } else {
152 | titleView.setTextAppearance(getContext(), titleTextAppearanceResId);
153 | }
154 |
155 | titleView.setTag(R.id.bb_bottom_bar_appearance_id, titleTextAppearanceResId);
156 | }
157 |
158 | private void updateCustomTypeface() {
159 | if (titleTypeFace != null && titleView != null) {
160 | titleView.setTypeface(titleTypeFace);
161 | }
162 | }
163 |
164 | Type getType() {
165 | return type;
166 | }
167 |
168 | void setType(Type type) {
169 | this.type = type;
170 | }
171 |
172 | boolean isTitleless() {
173 | return isTitleless;
174 | }
175 |
176 | void setIsTitleless(boolean isTitleless) {
177 | if (isTitleless && getIconResId() == 0) {
178 | throw new IllegalStateException("This tab is supposed to be " +
179 | "icon only, yet it has no icon specified. Index in " +
180 | "container: " + getIndexInTabContainer());
181 | }
182 |
183 | this.isTitleless = isTitleless;
184 | }
185 |
186 | public ViewGroup getOuterView() {
187 | return (ViewGroup) getParent();
188 | }
189 |
190 | AppCompatImageView getIconView() {
191 | return iconView;
192 | }
193 |
194 | int getIconResId() {
195 | return iconResId;
196 | }
197 |
198 | void setIconResId(int iconResId) {
199 | this.iconResId = iconResId;
200 | }
201 |
202 | TextView getTitleView() {
203 | return titleView;
204 | }
205 |
206 | public String getTitle() {
207 | return title;
208 | }
209 |
210 | public void setTitle(String title) {
211 | this.title = title;
212 | updateTitle();
213 | }
214 |
215 | public float getInActiveAlpha() {
216 | return inActiveAlpha;
217 | }
218 |
219 | public void setInActiveAlpha(float inActiveAlpha) {
220 | this.inActiveAlpha = inActiveAlpha;
221 |
222 | if (!isActive) {
223 | setAlphas(inActiveAlpha);
224 | }
225 | }
226 |
227 | public float getActiveAlpha() {
228 | return activeAlpha;
229 | }
230 |
231 | public void setActiveAlpha(float activeAlpha) {
232 | this.activeAlpha = activeAlpha;
233 |
234 | if (isActive) {
235 | setAlphas(activeAlpha);
236 | }
237 | }
238 |
239 | public int getInActiveColor() {
240 | return inActiveColor;
241 | }
242 |
243 | public void setInActiveColor(int inActiveColor) {
244 | this.inActiveColor = inActiveColor;
245 |
246 | if (!isActive) {
247 | setColors(inActiveColor);
248 | }
249 | }
250 |
251 | public int getActiveColor() {
252 | return activeColor;
253 | }
254 |
255 | public void setActiveColor(int activeIconColor) {
256 | this.activeColor = activeIconColor;
257 |
258 | if (isActive) {
259 | setColors(activeColor);
260 | }
261 | }
262 |
263 | public int getBarColorWhenSelected() {
264 | return barColorWhenSelected;
265 | }
266 |
267 | public void setBarColorWhenSelected(int barColorWhenSelected) {
268 | this.barColorWhenSelected = barColorWhenSelected;
269 | }
270 |
271 | public int getBadgeBackgroundColor() {
272 | return badgeBackgroundColor;
273 | }
274 |
275 | public void setBadgeBackgroundColor(int badgeBackgroundColor) {
276 | this.badgeBackgroundColor = badgeBackgroundColor;
277 |
278 | if (badge != null) {
279 | badge.setColoredCircleBackground(badgeBackgroundColor);
280 | }
281 | }
282 |
283 | public boolean getBadgeHidesWhenActive() {
284 | return badgeHidesWhenActive;
285 | }
286 |
287 | public void setBadgeHidesWhenActive(boolean hideWhenActive) {
288 | this.badgeHidesWhenActive = hideWhenActive;
289 | }
290 |
291 | int getCurrentDisplayedIconColor() {
292 | Object tag = iconView.getTag(R.id.bb_bottom_bar_color_id);
293 |
294 | if (tag instanceof Integer) {
295 | return (int) tag;
296 | }
297 |
298 | return 0;
299 | }
300 |
301 | int getCurrentDisplayedTitleColor() {
302 | if (titleView != null) {
303 | return titleView.getCurrentTextColor();
304 | }
305 |
306 | return 0;
307 | }
308 |
309 | int getCurrentDisplayedTextAppearance() {
310 | Object tag = titleView.getTag(R.id.bb_bottom_bar_appearance_id);
311 |
312 | if (titleView != null && tag instanceof Integer) {
313 | return (int) tag;
314 | }
315 |
316 | return 0;
317 | }
318 |
319 | public void setBadgeCount(int count) {
320 | if (count <= 0) {
321 | if (badge != null) {
322 | badge.removeFromTab(this);
323 | badge = null;
324 | }
325 |
326 | return;
327 | }
328 |
329 | if (badge == null) {
330 | badge = new BottomBarBadge(getContext());
331 | badge.attachToTab(this, badgeBackgroundColor);
332 | }
333 |
334 | badge.setCount(count);
335 |
336 | if (isActive && badgeHidesWhenActive) {
337 | badge.hide();
338 | }
339 | }
340 |
341 | public void removeBadge() {
342 | setBadgeCount(0);
343 | }
344 |
345 | boolean isActive() {
346 | return isActive;
347 | }
348 |
349 | boolean hasActiveBadge() {
350 | return badge != null;
351 | }
352 |
353 | int getIndexInTabContainer() {
354 | return indexInContainer;
355 | }
356 |
357 | void setIndexInContainer(int indexInContainer) {
358 | this.indexInContainer = indexInContainer;
359 | }
360 |
361 | void setIconTint(int tint) {
362 | iconView.setColorFilter(tint);
363 | }
364 |
365 | public int getTitleTextAppearance() {
366 | return titleTextAppearanceResId;
367 | }
368 |
369 | @SuppressWarnings("deprecation")
370 | void setTitleTextAppearance(int resId) {
371 | this.titleTextAppearanceResId = resId;
372 | updateCustomTextAppearance();
373 | }
374 |
375 | public void setTitleTypeface(Typeface typeface) {
376 | this.titleTypeFace = typeface;
377 | updateCustomTypeface();
378 | }
379 |
380 | public Typeface getTitleTypeFace() {
381 | return titleTypeFace;
382 | }
383 |
384 | void select(boolean animate) {
385 | isActive = true;
386 |
387 | if (animate) {
388 | animateIcon(activeAlpha, ACTIVE_SHIFTING_TITLELESS_ICON_SCALE);
389 | animateTitle(sixDps, ACTIVE_TITLE_SCALE, activeAlpha);
390 | animateColors(inActiveColor, activeColor);
391 | } else {
392 | setTitleScale(ACTIVE_TITLE_SCALE);
393 | setTopPadding(sixDps);
394 | setIconScale(ACTIVE_SHIFTING_TITLELESS_ICON_SCALE);
395 | setColors(activeColor);
396 | setAlphas(activeAlpha);
397 | }
398 |
399 | setSelected(true);
400 |
401 | if (badge != null && badgeHidesWhenActive) {
402 | badge.hide();
403 | }
404 | }
405 |
406 | void deselect(boolean animate) {
407 | isActive = false;
408 |
409 | boolean isShifting = type == Type.SHIFTING;
410 |
411 | float titleScale = isShifting ? 0 : INACTIVE_FIXED_TITLE_SCALE;
412 | int iconPaddingTop = isShifting ? sixteenDps : eightDps;
413 |
414 | if (animate) {
415 | animateTitle(iconPaddingTop, titleScale, inActiveAlpha);
416 | animateIcon(inActiveAlpha, INACTIVE_SHIFTING_TITLELESS_ICON_SCALE);
417 | animateColors(activeColor, inActiveColor);
418 | } else {
419 | setTitleScale(titleScale);
420 | setTopPadding(iconPaddingTop);
421 | setIconScale(INACTIVE_SHIFTING_TITLELESS_ICON_SCALE);
422 | setColors(inActiveColor);
423 | setAlphas(inActiveAlpha);
424 | }
425 |
426 | setSelected(false);
427 |
428 | if (!isShifting && badge != null && !badge.isVisible()) {
429 | badge.show();
430 | }
431 | }
432 |
433 | private void animateColors(int previousColor, int color) {
434 | ValueAnimator anim = new ValueAnimator();
435 | anim.setIntValues(previousColor, color);
436 | anim.setEvaluator(new ArgbEvaluator());
437 | anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
438 | @Override
439 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
440 | setColors((Integer) valueAnimator.getAnimatedValue());
441 | }
442 | });
443 |
444 | anim.setDuration(150);
445 | anim.start();
446 | }
447 |
448 | private void setColors(int color) {
449 | if (iconView != null) {
450 | iconView.setColorFilter(color);
451 | iconView.setTag(R.id.bb_bottom_bar_color_id, color);
452 | }
453 |
454 | if (titleView != null) {
455 | titleView.setTextColor(color);
456 | }
457 | }
458 |
459 | private void setAlphas(float alpha) {
460 | if (iconView != null) {
461 | ViewCompat.setAlpha(iconView, alpha);
462 | }
463 |
464 | if (titleView != null) {
465 | ViewCompat.setAlpha(titleView, alpha);
466 | }
467 | }
468 |
469 | void updateWidth(float endWidth, boolean animated) {
470 | if (!animated) {
471 | getLayoutParams().width = (int) endWidth;
472 |
473 | if (!isActive && badge != null) {
474 | badge.adjustPositionAndSize(this);
475 | badge.show();
476 | }
477 | return;
478 | }
479 |
480 | float start = getWidth();
481 |
482 | ValueAnimator animator = ValueAnimator.ofFloat(start, endWidth);
483 | animator.setDuration(150);
484 | animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
485 | @Override
486 | public void onAnimationUpdate(ValueAnimator animator) {
487 | ViewGroup.LayoutParams params = getLayoutParams();
488 | if (params == null) return;
489 |
490 | params.width = Math.round((float) animator.getAnimatedValue());
491 | setLayoutParams(params);
492 | }
493 | });
494 |
495 | // Workaround to avoid using faulty onAnimationEnd() listener
496 | postDelayed(new Runnable() {
497 | @Override
498 | public void run() {
499 | if (!isActive && badge != null) {
500 | clearAnimation();
501 | badge.adjustPositionAndSize(BottomBarTab.this);
502 | badge.show();
503 | }
504 | }
505 | }, animator.getDuration());
506 |
507 | animator.start();
508 | }
509 |
510 | private void updateBadgePosition() {
511 | if (badge != null) {
512 | badge.adjustPositionAndSize(this);
513 | }
514 | }
515 |
516 | private void setTopPaddingAnimated(int start, int end) {
517 | if (type == Type.TABLET || isTitleless) {
518 | return;
519 | }
520 |
521 | ValueAnimator paddingAnimator = ValueAnimator.ofInt(start, end);
522 | paddingAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
523 | @Override
524 | public void onAnimationUpdate(ValueAnimator animation) {
525 | iconView.setPadding(
526 | iconView.getPaddingLeft(),
527 | (Integer) animation.getAnimatedValue(),
528 | iconView.getPaddingRight(),
529 | iconView.getPaddingBottom()
530 | );
531 | }
532 | });
533 |
534 | paddingAnimator.setDuration(ANIMATION_DURATION);
535 | paddingAnimator.start();
536 | }
537 |
538 | private void animateTitle(int padding, float scale, float alpha) {
539 | if (type == Type.TABLET && isTitleless) {
540 | return;
541 | }
542 |
543 | setTopPaddingAnimated(iconView.getPaddingTop(), padding);
544 |
545 | ViewPropertyAnimatorCompat titleAnimator = ViewCompat.animate(titleView)
546 | .setDuration(ANIMATION_DURATION)
547 | .scaleX(scale)
548 | .scaleY(scale);
549 | titleAnimator.alpha(alpha);
550 | titleAnimator.start();
551 | }
552 |
553 | private void animateIconScale(float scale) {
554 | ViewCompat.animate(iconView)
555 | .setDuration(ANIMATION_DURATION)
556 | .scaleX(scale)
557 | .scaleY(scale)
558 | .start();
559 | }
560 |
561 | private void animateIcon(float alpha, float scale) {
562 | ViewCompat.animate(iconView)
563 | .setDuration(ANIMATION_DURATION)
564 | .alpha(alpha)
565 | .start();
566 |
567 | if (isTitleless && type == Type.SHIFTING) {
568 | animateIconScale(scale);
569 | }
570 | }
571 |
572 | private void setTopPadding(int topPadding) {
573 | if (type == Type.TABLET || isTitleless) {
574 | return;
575 | }
576 |
577 | iconView.setPadding(
578 | iconView.getPaddingLeft(),
579 | topPadding,
580 | iconView.getPaddingRight(),
581 | iconView.getPaddingBottom()
582 | );
583 | }
584 |
585 | private void setTitleScale(float scale) {
586 | if (type == Type.TABLET || isTitleless) {
587 | return;
588 | }
589 |
590 | ViewCompat.setScaleX(titleView, scale);
591 | ViewCompat.setScaleY(titleView, scale);
592 | }
593 |
594 | private void setIconScale(float scale) {
595 | if (isTitleless && type == Type.SHIFTING) {
596 | ViewCompat.setScaleX(iconView, scale);
597 | ViewCompat.setScaleY(iconView, scale);
598 | }
599 | }
600 |
601 | @Override
602 | public Parcelable onSaveInstanceState() {
603 | if (badge != null) {
604 | Bundle bundle = saveState();
605 | bundle.putParcelable("superstate", super.onSaveInstanceState());
606 |
607 | return bundle;
608 | }
609 |
610 | return super.onSaveInstanceState();
611 | }
612 |
613 | @VisibleForTesting
614 | Bundle saveState() {
615 | Bundle outState = new Bundle();
616 | outState.putInt(STATE_BADGE_COUNT + getIndexInTabContainer(), badge.getCount());
617 |
618 | return outState;
619 | }
620 |
621 | @Override
622 | public void onRestoreInstanceState(Parcelable state) {
623 | if (state instanceof Bundle) {
624 | Bundle bundle = (Bundle) state;
625 | restoreState(bundle);
626 |
627 | state = bundle.getParcelable("superstate");
628 | }
629 |
630 | super.onRestoreInstanceState(state);
631 | }
632 |
633 | @VisibleForTesting
634 | void restoreState(Bundle savedInstanceState) {
635 | int previousBadgeCount = savedInstanceState.getInt(STATE_BADGE_COUNT + getIndexInTabContainer());
636 | setBadgeCount(previousBadgeCount);
637 | }
638 |
639 | enum Type {
640 | FIXED, SHIFTING, TABLET
641 | }
642 |
643 | public static class Config {
644 | private final float inActiveTabAlpha;
645 | private final float activeTabAlpha;
646 | private final int inActiveTabColor;
647 | private final int activeTabColor;
648 | private final int barColorWhenSelected;
649 | private final int badgeBackgroundColor;
650 | private final int titleTextAppearance;
651 | private final Typeface titleTypeFace;
652 | private boolean badgeHidesWhenSelected = true;
653 |
654 | private Config(Builder builder) {
655 | this.inActiveTabAlpha = builder.inActiveTabAlpha;
656 | this.activeTabAlpha = builder.activeTabAlpha;
657 | this.inActiveTabColor = builder.inActiveTabColor;
658 | this.activeTabColor = builder.activeTabColor;
659 | this.barColorWhenSelected = builder.barColorWhenSelected;
660 | this.badgeBackgroundColor = builder.badgeBackgroundColor;
661 | this.badgeHidesWhenSelected = builder.hidesBadgeWhenSelected;
662 | this.titleTextAppearance = builder.titleTextAppearance;
663 | this.titleTypeFace = builder.titleTypeFace;
664 | }
665 |
666 | public static class Builder {
667 | private float inActiveTabAlpha;
668 | private float activeTabAlpha;
669 | private int inActiveTabColor;
670 | private int activeTabColor;
671 | private int barColorWhenSelected;
672 | private int badgeBackgroundColor;
673 | private boolean hidesBadgeWhenSelected = true;
674 | private int titleTextAppearance;
675 | private Typeface titleTypeFace;
676 |
677 | public Builder inActiveTabAlpha(float alpha) {
678 | this.inActiveTabAlpha = alpha;
679 | return this;
680 | }
681 |
682 | public Builder activeTabAlpha(float alpha) {
683 | this.activeTabAlpha = alpha;
684 | return this;
685 | }
686 |
687 | public Builder inActiveTabColor(@ColorInt int color) {
688 | this.inActiveTabColor = color;
689 | return this;
690 | }
691 |
692 | public Builder activeTabColor(@ColorInt int color) {
693 | this.activeTabColor = color;
694 | return this;
695 | }
696 |
697 | public Builder barColorWhenSelected(@ColorInt int color) {
698 | this.barColorWhenSelected = color;
699 | return this;
700 | }
701 |
702 | public Builder badgeBackgroundColor(@ColorInt int color) {
703 | this.badgeBackgroundColor = color;
704 | return this;
705 | }
706 |
707 | public Builder hideBadgeWhenSelected(boolean hide) {
708 | this.hidesBadgeWhenSelected = hide;
709 | return this;
710 | }
711 |
712 | public Builder titleTextAppearance(int titleTextAppearance) {
713 | this.titleTextAppearance = titleTextAppearance;
714 | return this;
715 | }
716 |
717 | public Builder titleTypeFace(Typeface titleTypeFace) {
718 | this.titleTypeFace = titleTypeFace;
719 | return this;
720 | }
721 |
722 | public Config build() {
723 | return new Config(this);
724 | }
725 | }
726 | }
727 | }
728 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/java/com/roughike/bottombar/BottomNavigationBehavior.java:
--------------------------------------------------------------------------------
1 | package com.roughike.bottombar;
2 |
3 | import android.os.Build;
4 | import android.support.annotation.NonNull;
5 | import android.support.design.widget.CoordinatorLayout;
6 | import android.support.design.widget.Snackbar;
7 | import android.support.v4.view.ViewCompat;
8 | import android.support.v4.view.ViewPropertyAnimatorCompat;
9 | import android.support.v4.view.animation.LinearOutSlowInInterpolator;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.view.animation.Interpolator;
13 |
14 | /**
15 | * Created by Nikola D. on 3/15/2016.
16 | *
17 | * Credit goes to Nikola Despotoski:
18 | * https://github.com/NikolaDespotoski
19 | */
20 | class BottomNavigationBehavior extends VerticalScrollingBehavior {
21 | private static final Interpolator INTERPOLATOR = new LinearOutSlowInInterpolator();
22 | private final int bottomNavHeight;
23 | private final int defaultOffset;
24 | private boolean isTablet = false;
25 |
26 | private ViewPropertyAnimatorCompat mTranslationAnimator;
27 | private boolean hidden = false;
28 | private int mSnackbarHeight = -1;
29 | private final BottomNavigationWithSnackbar mWithSnackBarImpl = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? new LollipopBottomNavWithSnackBarImpl() : new PreLollipopBottomNavWithSnackBarImpl();
30 | private boolean mScrollingEnabled = true;
31 |
32 | BottomNavigationBehavior(int bottomNavHeight, int defaultOffset, boolean tablet) {
33 | this.bottomNavHeight = bottomNavHeight;
34 | this.defaultOffset = defaultOffset;
35 | isTablet = tablet;
36 | }
37 |
38 | @Override
39 | public boolean layoutDependsOn(CoordinatorLayout parent, V child, View dependency) {
40 | mWithSnackBarImpl.updateSnackbar(parent, dependency, child);
41 | return dependency instanceof Snackbar.SnackbarLayout;
42 | }
43 |
44 | @Override
45 | public void onNestedVerticalOverScroll(CoordinatorLayout coordinatorLayout, V child, @ScrollDirection int direction, int currentOverScroll, int totalOverScroll) {
46 | }
47 |
48 | @Override
49 | public void onDependentViewRemoved(CoordinatorLayout parent, V child, View dependency) {
50 | updateScrollingForSnackbar(dependency, true);
51 | super.onDependentViewRemoved(parent, child, dependency);
52 | }
53 |
54 | private void updateScrollingForSnackbar(View dependency, boolean enabled) {
55 | if (!isTablet && dependency instanceof Snackbar.SnackbarLayout) {
56 | mScrollingEnabled = enabled;
57 | }
58 | }
59 |
60 | @Override
61 | public boolean onDependentViewChanged(CoordinatorLayout parent, V child, View dependency) {
62 | updateScrollingForSnackbar(dependency, false);
63 | return super.onDependentViewChanged(parent, child, dependency);
64 | }
65 |
66 | @Override
67 | public void onDirectionNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed, @ScrollDirection int scrollDirection) {
68 | handleDirection(child, scrollDirection);
69 | }
70 |
71 | private void handleDirection(V child, int scrollDirection) {
72 | if (!mScrollingEnabled) return;
73 | if (scrollDirection == ScrollDirection.SCROLL_DIRECTION_DOWN && hidden) {
74 | hidden = false;
75 | animateOffset(child, defaultOffset);
76 | } else if (scrollDirection == ScrollDirection.SCROLL_DIRECTION_UP && !hidden) {
77 | hidden = true;
78 | animateOffset(child, bottomNavHeight + defaultOffset);
79 | }
80 | }
81 |
82 | @Override
83 | protected boolean onNestedDirectionFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY, @ScrollDirection int scrollDirection) {
84 | handleDirection(child, scrollDirection);
85 | return true;
86 | }
87 |
88 | private void animateOffset(final V child, final int offset) {
89 | ensureOrCancelAnimator(child);
90 | mTranslationAnimator.translationY(offset).start();
91 | }
92 |
93 | private void ensureOrCancelAnimator(V child) {
94 | if (mTranslationAnimator == null) {
95 | mTranslationAnimator = ViewCompat.animate(child);
96 | mTranslationAnimator.setDuration(300);
97 | mTranslationAnimator.setInterpolator(INTERPOLATOR);
98 | } else {
99 | mTranslationAnimator.cancel();
100 | }
101 | }
102 |
103 |
104 | void setHidden(@NonNull V view, boolean bottomLayoutHidden) {
105 | if (!bottomLayoutHidden && hidden) {
106 | animateOffset(view, defaultOffset);
107 | } else if (bottomLayoutHidden && !hidden) {
108 | animateOffset(view, bottomNavHeight + defaultOffset);
109 | }
110 | hidden = bottomLayoutHidden;
111 | }
112 |
113 |
114 | static BottomNavigationBehavior from(@NonNull V view) {
115 | ViewGroup.LayoutParams params = view.getLayoutParams();
116 |
117 | if (!(params instanceof CoordinatorLayout.LayoutParams)) {
118 | throw new IllegalArgumentException("The view is not a child of CoordinatorLayout");
119 | }
120 |
121 | CoordinatorLayout.Behavior behavior = ((CoordinatorLayout.LayoutParams) params)
122 | .getBehavior();
123 |
124 | if (behavior instanceof BottomNavigationBehavior) {
125 | // noinspection unchecked
126 | return (BottomNavigationBehavior) behavior;
127 | }
128 |
129 | throw new IllegalArgumentException("The view is not associated with BottomNavigationBehavior");
130 | }
131 |
132 | private interface BottomNavigationWithSnackbar {
133 | void updateSnackbar(CoordinatorLayout parent, View dependency, View child);
134 | }
135 |
136 |
137 | private class PreLollipopBottomNavWithSnackBarImpl implements BottomNavigationWithSnackbar {
138 |
139 | @Override
140 | public void updateSnackbar(CoordinatorLayout parent, View dependency, View child) {
141 | if (!isTablet && dependency instanceof Snackbar.SnackbarLayout) {
142 | if (mSnackbarHeight == -1) {
143 | mSnackbarHeight = dependency.getHeight();
144 | }
145 | if (ViewCompat.getTranslationY(child) != 0) return;
146 | int targetPadding = bottomNavHeight + mSnackbarHeight - defaultOffset;
147 |
148 | ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) dependency.getLayoutParams();
149 | layoutParams.bottomMargin = targetPadding;
150 | child.bringToFront();
151 | child.getParent().requestLayout();
152 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
153 | ((View) child.getParent()).invalidate();
154 | }
155 |
156 | }
157 | }
158 | }
159 |
160 | private class LollipopBottomNavWithSnackBarImpl implements BottomNavigationWithSnackbar {
161 | @Override
162 | public void updateSnackbar(CoordinatorLayout parent, View dependency, View child) {
163 | if (!isTablet && dependency instanceof Snackbar.SnackbarLayout) {
164 | if (mSnackbarHeight == -1) {
165 | mSnackbarHeight = dependency.getHeight();
166 | }
167 | if (ViewCompat.getTranslationY(child) != 0) return;
168 | int targetPadding = (mSnackbarHeight + bottomNavHeight - defaultOffset);
169 | dependency.setPadding(dependency.getPaddingLeft(),
170 | dependency.getPaddingTop(), dependency.getPaddingRight(), targetPadding
171 | );
172 | }
173 | }
174 | }
175 | }
176 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/java/com/roughike/bottombar/MiscUtils.java:
--------------------------------------------------------------------------------
1 | package com.roughike.bottombar;
2 |
3 | import android.content.Context;
4 | import android.content.res.Configuration;
5 | import android.content.res.Resources;
6 | import android.os.Build;
7 | import android.support.annotation.AttrRes;
8 | import android.support.annotation.ColorInt;
9 | import android.support.annotation.Dimension;
10 | import android.support.annotation.DrawableRes;
11 | import android.support.annotation.NonNull;
12 | import android.support.annotation.Px;
13 | import android.support.annotation.StyleRes;
14 | import android.util.DisplayMetrics;
15 | import android.util.TypedValue;
16 | import android.widget.TextView;
17 |
18 | import static android.support.annotation.Dimension.DP;
19 |
20 | /*
21 | * BottomBar library for Android
22 | * Copyright (c) 2016 Iiro Krankka (http://github.com/roughike).
23 | *
24 | * Licensed under the Apache License, Version 2.0 (the "License");
25 | * you may not use this file except in compliance with the License.
26 | * You may obtain a copy of the License at
27 | *
28 | * http://www.apache.org/licenses/LICENSE-2.0
29 | *
30 | * Unless required by applicable law or agreed to in writing, software
31 | * distributed under the License is distributed on an "AS IS" BASIS,
32 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33 | * See the License for the specific language governing permissions and
34 | * limitations under the License.
35 | */
36 | class MiscUtils {
37 |
38 | @NonNull protected static TypedValue getTypedValue(@NonNull Context context, @AttrRes int resId) {
39 | TypedValue tv = new TypedValue();
40 | context.getTheme().resolveAttribute(resId, tv, true);
41 | return tv;
42 | }
43 |
44 | @ColorInt
45 | protected static int getColor(@NonNull Context context, @AttrRes int color) {
46 | return getTypedValue(context, color).data;
47 | }
48 |
49 | @DrawableRes
50 | protected static int getDrawableRes(@NonNull Context context, @AttrRes int drawable) {
51 | return getTypedValue(context, drawable).resourceId;
52 | }
53 |
54 | /**
55 | * Converts dps to pixels nicely.
56 | *
57 | * @param context the Context for getting the resources
58 | * @param dp dimension in dps
59 | * @return dimension in pixels
60 | */
61 | protected static int dpToPixel(@NonNull Context context, @Dimension(unit = DP) float dp) {
62 | Resources resources = context.getResources();
63 | DisplayMetrics metrics = resources.getDisplayMetrics();
64 |
65 | try {
66 | return (int) (dp * metrics.density);
67 | } catch (NoSuchFieldError ignored) {
68 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, metrics);
69 | }
70 | }
71 |
72 | /**
73 | * Converts pixels to dps just as well.
74 | *
75 | * @param context the Context for getting the resources
76 | * @param px dimension in pixels
77 | * @return dimension in dps
78 | */
79 | protected static int pixelToDp(@NonNull Context context, @Px int px) {
80 | DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
81 | return Math.round(px / displayMetrics.density);
82 | }
83 |
84 | /**
85 | * Returns screen width.
86 | *
87 | * @param context Context to get resources and device specific display metrics
88 | * @return screen width
89 | */
90 | protected static int getScreenWidth(@NonNull Context context) {
91 | DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
92 | return (int) (displayMetrics.widthPixels / displayMetrics.density);
93 | }
94 |
95 | /**
96 | * A convenience method for setting text appearance.
97 | *
98 | * @param textView a TextView which textAppearance to modify.
99 | * @param resId a style resource for the text appearance.
100 | */
101 | @SuppressWarnings("deprecation")
102 | protected static void setTextAppearance(@NonNull TextView textView, @StyleRes int resId) {
103 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
104 | textView.setTextAppearance(resId);
105 | } else {
106 | textView.setTextAppearance(textView.getContext(), resId);
107 | }
108 | }
109 |
110 | /**
111 | * Determine if the current UI Mode is Night Mode.
112 | *
113 | * @param context Context to get the configuration.
114 | * @return true if the night mode is enabled, otherwise false.
115 | */
116 | protected static boolean isNightMode(@NonNull Context context) {
117 | int currentNightMode = context.getResources().getConfiguration().uiMode
118 | & Configuration.UI_MODE_NIGHT_MASK;
119 | return currentNightMode == Configuration.UI_MODE_NIGHT_YES;
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/java/com/roughike/bottombar/NavbarUtils.java:
--------------------------------------------------------------------------------
1 | package com.roughike.bottombar;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.os.Build;
6 | import android.support.annotation.IntRange;
7 | import android.support.annotation.NonNull;
8 | import android.util.DisplayMetrics;
9 | import android.view.Display;
10 | import android.view.KeyCharacterMap;
11 | import android.view.KeyEvent;
12 | import android.view.ViewConfiguration;
13 | import android.view.WindowManager;
14 |
15 | /**
16 | * Created by iiro on 17.8.2016.
17 | */
18 | final class NavbarUtils {
19 | private static final int RESOURCE_NOT_FOUND = 0;
20 |
21 | @IntRange(from = 0)
22 | static int getNavbarHeight(@NonNull Context context) {
23 | Resources res = context.getResources();
24 | int navBarIdentifier = res.getIdentifier("navigation_bar_height", "dimen", "android");
25 | return navBarIdentifier != RESOURCE_NOT_FOUND
26 | ? res.getDimensionPixelSize(navBarIdentifier) : 0;
27 | }
28 |
29 | static boolean shouldDrawBehindNavbar(@NonNull Context context) {
30 | return isPortrait(context)
31 | && hasSoftKeys(context);
32 | }
33 |
34 | private static boolean isPortrait(@NonNull Context context) {
35 | Resources res = context.getResources();
36 | return res.getBoolean(R.bool.bb_bottom_bar_is_portrait_mode);
37 | }
38 |
39 | /**
40 | * http://stackoverflow.com/a/14871974
41 | */
42 | private static boolean hasSoftKeys(@NonNull Context context) {
43 | boolean hasSoftwareKeys = true;
44 |
45 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
46 | Display d = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
47 |
48 | DisplayMetrics realDisplayMetrics = new DisplayMetrics();
49 | d.getRealMetrics(realDisplayMetrics);
50 |
51 | int realHeight = realDisplayMetrics.heightPixels;
52 | int realWidth = realDisplayMetrics.widthPixels;
53 |
54 | DisplayMetrics displayMetrics = new DisplayMetrics();
55 | d.getMetrics(displayMetrics);
56 |
57 | int displayHeight = displayMetrics.heightPixels;
58 | int displayWidth = displayMetrics.widthPixels;
59 |
60 | hasSoftwareKeys = (realWidth - displayWidth) > 0 || (realHeight - displayHeight) > 0;
61 | } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
62 | boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey();
63 | boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
64 | hasSoftwareKeys = !hasMenuKey && !hasBackKey;
65 | }
66 |
67 | return hasSoftwareKeys;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/java/com/roughike/bottombar/OnTabReselectListener.java:
--------------------------------------------------------------------------------
1 | package com.roughike.bottombar;
2 |
3 | import android.support.annotation.IdRes;
4 |
5 | /*
6 | * BottomBar library for Android
7 | * Copyright (c) 2016 Iiro Krankka (http://github.com/roughike).
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 | public interface OnTabReselectListener {
22 | /**
23 | * The method being called when currently visible {@link BottomBarTab} is
24 | * reselected. Use this method for scrolling to the top of your content,
25 | * as recommended by the Material Design spec
26 | *
27 | * @param tabId the {@link BottomBarTab} that was reselected.
28 | */
29 | void onTabReSelected(@IdRes int tabId);
30 | }
31 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/java/com/roughike/bottombar/OnTabSelectListener.java:
--------------------------------------------------------------------------------
1 | package com.roughike.bottombar;
2 |
3 | import android.support.annotation.IdRes;
4 |
5 | /*
6 | * BottomBar library for Android
7 | * Copyright (c) 2016 Iiro Krankka (http://github.com/roughike).
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 | public interface OnTabSelectListener {
22 | /**
23 | * The method being called when currently visible {@link BottomBarTab} changes.
24 | *
25 | * This listener is fired for the first time after the items have been set and
26 | * also after a configuration change, such as when screen orientation changes
27 | * from portrait to landscape.
28 | *
29 | * @param tabId the new visible {@link BottomBarTab}
30 | */
31 | void onTabSelected(@IdRes int tabId);
32 | }
33 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/java/com/roughike/bottombar/ShySettings.java:
--------------------------------------------------------------------------------
1 | package com.roughike.bottombar;
2 |
3 | /**
4 | * Settings specific for a shy BottomBar.
5 | */
6 | public class ShySettings {
7 | private BottomBar bottomBar;
8 | private Boolean pendingIsVisibleInShyMode;
9 |
10 | ShySettings(BottomBar bottomBar) {
11 | this.bottomBar = bottomBar;
12 | }
13 |
14 | void shyHeightCalculated() {
15 | updatePendingShyVisibility();
16 | }
17 |
18 | /**
19 | * Shows the BottomBar if it was hidden, with a translate animation.
20 | */
21 | public void showBar() {
22 | toggleIsVisibleInShyMode(true);
23 | }
24 |
25 | /**
26 | * Hides the BottomBar in if it was visible, with a translate animation.
27 | */
28 | public void hideBar() {
29 | toggleIsVisibleInShyMode(false);
30 | }
31 |
32 | private void toggleIsVisibleInShyMode(boolean visible) {
33 | if (!bottomBar.isShy()) {
34 | return;
35 | }
36 |
37 | if (bottomBar.isShyHeightAlreadyCalculated()) {
38 | BottomNavigationBehavior behavior = BottomNavigationBehavior.from(bottomBar);
39 |
40 | if (behavior != null) {
41 | boolean isHidden = !visible;
42 | behavior.setHidden(bottomBar, isHidden);
43 | }
44 | } else {
45 | pendingIsVisibleInShyMode = true;
46 | }
47 | }
48 |
49 | private void updatePendingShyVisibility() {
50 | if (pendingIsVisibleInShyMode != null) {
51 | toggleIsVisibleInShyMode(pendingIsVisibleInShyMode);
52 | pendingIsVisibleInShyMode = null;
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/java/com/roughike/bottombar/TabParser.java:
--------------------------------------------------------------------------------
1 | package com.roughike.bottombar;
2 |
3 | import android.content.Context;
4 | import android.content.res.XmlResourceParser;
5 | import android.graphics.Color;
6 | import android.support.annotation.CheckResult;
7 | import android.support.annotation.ColorInt;
8 | import android.support.annotation.IntRange;
9 | import android.support.annotation.NonNull;
10 | import android.support.annotation.Nullable;
11 | import android.support.annotation.StringDef;
12 | import android.support.annotation.XmlRes;
13 | import android.support.v4.content.ContextCompat;
14 |
15 | import org.xmlpull.v1.XmlPullParserException;
16 |
17 | import java.io.IOException;
18 | import java.lang.annotation.Retention;
19 | import java.lang.annotation.RetentionPolicy;
20 | import java.util.ArrayList;
21 | import java.util.List;
22 |
23 | import static com.roughike.bottombar.TabParser.TabAttribute.ACTIVE_COLOR;
24 | import static com.roughike.bottombar.TabParser.TabAttribute.BADGE_BACKGROUND_COLOR;
25 | import static com.roughike.bottombar.TabParser.TabAttribute.BADGE_HIDES_WHEN_ACTIVE;
26 | import static com.roughike.bottombar.TabParser.TabAttribute.BAR_COLOR_WHEN_SELECTED;
27 | import static com.roughike.bottombar.TabParser.TabAttribute.ICON;
28 | import static com.roughike.bottombar.TabParser.TabAttribute.ID;
29 | import static com.roughike.bottombar.TabParser.TabAttribute.INACTIVE_COLOR;
30 | import static com.roughike.bottombar.TabParser.TabAttribute.IS_TITLELESS;
31 | import static com.roughike.bottombar.TabParser.TabAttribute.TITLE;
32 |
33 | /**
34 | * Created by iiro on 21.7.2016.
35 | *
36 | * BottomBar library for Android
37 | * Copyright (c) 2016 Iiro Krankka (http://github.com/roughike).
38 | *
39 | * Licensed under the Apache License, Version 2.0 (the "License");
40 | * you may not use this file except in compliance with the License.
41 | * You may obtain a copy of the License at
42 | *
43 | * http://www.apache.org/licenses/LICENSE-2.0
44 | *
45 | * Unless required by applicable law or agreed to in writing, software
46 | * distributed under the License is distributed on an "AS IS" BASIS,
47 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
48 | * See the License for the specific language governing permissions and
49 | * limitations under the License.
50 | */
51 | class TabParser {
52 | private static final String TAB_TAG = "tab";
53 | private static final int AVG_NUMBER_OF_TABS = 5;
54 | private static final int COLOR_NOT_SET = -1;
55 | private static final int RESOURCE_NOT_FOUND = 0;
56 |
57 | @NonNull
58 | private final Context context;
59 |
60 | @NonNull
61 | private final BottomBarTab.Config defaultTabConfig;
62 |
63 | @NonNull
64 | private final XmlResourceParser parser;
65 |
66 | @Nullable
67 | private List tabs = null;
68 |
69 | TabParser(@NonNull Context context, @NonNull BottomBarTab.Config defaultTabConfig, @XmlRes int tabsXmlResId) {
70 | this.context = context;
71 | this.defaultTabConfig = defaultTabConfig;
72 | this.parser = context.getResources().getXml(tabsXmlResId);
73 | }
74 |
75 | @CheckResult
76 | @NonNull
77 | public List parseTabs() {
78 | if (tabs == null) {
79 | tabs = new ArrayList<>(AVG_NUMBER_OF_TABS);
80 | try {
81 | int eventType;
82 | do {
83 | eventType = parser.next();
84 | if (eventType == XmlResourceParser.START_TAG && TAB_TAG.equals(parser.getName())) {
85 | BottomBarTab bottomBarTab = parseNewTab(parser, tabs.size());
86 | tabs.add(bottomBarTab);
87 | }
88 | } while (eventType != XmlResourceParser.END_DOCUMENT);
89 | } catch (IOException | XmlPullParserException e) {
90 | e.printStackTrace();
91 | throw new TabParserException();
92 | }
93 | }
94 |
95 | return tabs;
96 | }
97 |
98 | @NonNull
99 | private BottomBarTab parseNewTab(@NonNull XmlResourceParser parser, @IntRange(from = 0) int containerPosition) {
100 | BottomBarTab workingTab = tabWithDefaults();
101 | workingTab.setIndexInContainer(containerPosition);
102 |
103 | final int numberOfAttributes = parser.getAttributeCount();
104 | for (int i = 0; i < numberOfAttributes; i++) {
105 | @TabAttribute
106 | String attrName = parser.getAttributeName(i);
107 | switch (attrName) {
108 | case ID:
109 | workingTab.setId(parser.getIdAttributeResourceValue(i));
110 | break;
111 | case ICON:
112 | workingTab.setIconResId(parser.getAttributeResourceValue(i, RESOURCE_NOT_FOUND));
113 | break;
114 | case TITLE:
115 | workingTab.setTitle(getTitleValue(parser, i));
116 | break;
117 | case INACTIVE_COLOR:
118 | int inactiveColor = getColorValue(parser, i);
119 | if (inactiveColor == COLOR_NOT_SET) continue;
120 | workingTab.setInActiveColor(inactiveColor);
121 | break;
122 | case ACTIVE_COLOR:
123 | int activeColor = getColorValue(parser, i);
124 | if (activeColor == COLOR_NOT_SET) continue;
125 | workingTab.setActiveColor(activeColor);
126 | break;
127 | case BAR_COLOR_WHEN_SELECTED:
128 | int barColorWhenSelected = getColorValue(parser, i);
129 | if (barColorWhenSelected == COLOR_NOT_SET) continue;
130 | workingTab.setBarColorWhenSelected(barColorWhenSelected);
131 | break;
132 | case BADGE_BACKGROUND_COLOR:
133 | int badgeBackgroundColor = getColorValue(parser, i);
134 | if (badgeBackgroundColor == COLOR_NOT_SET) continue;
135 | workingTab.setBadgeBackgroundColor(badgeBackgroundColor);
136 | break;
137 | case BADGE_HIDES_WHEN_ACTIVE:
138 | boolean badgeHidesWhenActive = parser.getAttributeBooleanValue(i, true);
139 | workingTab.setBadgeHidesWhenActive(badgeHidesWhenActive);
140 | break;
141 | case IS_TITLELESS:
142 | boolean isTitleless = parser.getAttributeBooleanValue(i, false);
143 | workingTab.setIsTitleless(isTitleless);
144 | break;
145 | }
146 | }
147 |
148 | return workingTab;
149 | }
150 |
151 | @NonNull
152 | private BottomBarTab tabWithDefaults() {
153 | BottomBarTab tab = new BottomBarTab(context);
154 | tab.setConfig(defaultTabConfig);
155 |
156 | return tab;
157 | }
158 |
159 | @NonNull
160 | private String getTitleValue(@NonNull XmlResourceParser parser, @IntRange(from = 0) int attrIndex) {
161 | int titleResource = parser.getAttributeResourceValue(attrIndex, 0);
162 | return titleResource == RESOURCE_NOT_FOUND
163 | ? parser.getAttributeValue(attrIndex) : context.getString(titleResource);
164 | }
165 |
166 | @ColorInt
167 | private int getColorValue(@NonNull XmlResourceParser parser, @IntRange(from = 0) int attrIndex) {
168 | int colorResource = parser.getAttributeResourceValue(attrIndex, 0);
169 |
170 | if (colorResource == RESOURCE_NOT_FOUND) {
171 | try {
172 | String colorValue = parser.getAttributeValue(attrIndex);
173 | return Color.parseColor(colorValue);
174 | } catch (Exception ignored) {
175 | return COLOR_NOT_SET;
176 | }
177 | }
178 |
179 | return ContextCompat.getColor(context, colorResource);
180 | }
181 |
182 | @Retention(RetentionPolicy.SOURCE)
183 | @StringDef({
184 | ID,
185 | ICON,
186 | TITLE,
187 | INACTIVE_COLOR,
188 | ACTIVE_COLOR,
189 | BAR_COLOR_WHEN_SELECTED,
190 | BADGE_BACKGROUND_COLOR,
191 | BADGE_HIDES_WHEN_ACTIVE,
192 | IS_TITLELESS
193 | })
194 | @interface TabAttribute {
195 | String ID = "id";
196 | String ICON = "icon";
197 | String TITLE = "title";
198 | String INACTIVE_COLOR = "inActiveColor";
199 | String ACTIVE_COLOR = "activeColor";
200 | String BAR_COLOR_WHEN_SELECTED = "barColorWhenSelected";
201 | String BADGE_BACKGROUND_COLOR = "badgeBackgroundColor";
202 | String BADGE_HIDES_WHEN_ACTIVE = "badgeHidesWhenActive";
203 | String IS_TITLELESS = "iconOnly";
204 | }
205 |
206 | @SuppressWarnings("WeakerAccess")
207 | public static class TabParserException extends RuntimeException {
208 | // This class is just to be able to have a type of Runtime Exception that will make it clear where the error originated.
209 | }
210 | }
211 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/java/com/roughike/bottombar/TabSelectionInterceptor.java:
--------------------------------------------------------------------------------
1 | package com.roughike.bottombar;
2 |
3 | import android.support.annotation.IdRes;
4 |
5 | /*
6 | * BottomBar library for Android
7 | * Copyright (c) 2016 Iiro Krankka (http://github.com/roughike).
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 | public interface TabSelectionInterceptor {
22 | /**
23 | * The method being called when currently visible {@link BottomBarTab} is about to change.
24 | *
25 | * This listener is fired when the current {@link BottomBar} is about to change. This gives
26 | * an opportunity to interrupt the {@link BottomBarTab} change.
27 | *
28 | * @param oldTabId the currently visible {@link BottomBarTab}
29 | * @param newTabId the {@link BottomBarTab} that will be switched to
30 | * @return true if you want to override/stop the tab change, false to continue as normal
31 | */
32 | boolean shouldInterceptTabSelection(@IdRes int oldTabId, @IdRes int newTabId);
33 | }
34 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/java/com/roughike/bottombar/VerticalScrollingBehavior.java:
--------------------------------------------------------------------------------
1 | package com.roughike.bottombar;
2 |
3 | import android.content.Context;
4 | import android.os.Parcelable;
5 | import android.support.annotation.IntDef;
6 | import android.support.annotation.NonNull;
7 | import android.support.design.widget.CoordinatorLayout;
8 | import android.support.v4.view.WindowInsetsCompat;
9 | import android.util.AttributeSet;
10 | import android.view.View;
11 |
12 | import java.lang.annotation.Retention;
13 | import java.lang.annotation.RetentionPolicy;
14 |
15 | /**
16 | * Created by Nikola D. on 11/22/2015.
17 | *
18 | * Credit goes to Nikola Despotoski:
19 | * https://github.com/NikolaDespotoski
20 | */
21 | abstract class VerticalScrollingBehavior extends CoordinatorLayout.Behavior {
22 |
23 | private int totalDyUnconsumed = 0;
24 | private int totalDy = 0;
25 | @ScrollDirection
26 | private int overScrollDirection = ScrollDirection.SCROLL_NONE;
27 | @ScrollDirection
28 | private int scrollDirection = ScrollDirection.SCROLL_NONE;
29 |
30 | VerticalScrollingBehavior(Context context, AttributeSet attrs) {
31 | super(context, attrs);
32 | }
33 |
34 | VerticalScrollingBehavior() {
35 | super();
36 | }
37 |
38 | @Retention(RetentionPolicy.SOURCE)
39 | @IntDef({ScrollDirection.SCROLL_DIRECTION_UP, ScrollDirection.SCROLL_DIRECTION_DOWN, ScrollDirection.SCROLL_NONE})
40 | @interface ScrollDirection {
41 | int SCROLL_DIRECTION_UP = 1;
42 | int SCROLL_DIRECTION_DOWN = -1;
43 | int SCROLL_NONE = 0;
44 | }
45 |
46 |
47 | /*
48 | @return Overscroll direction: SCROLL_DIRECTION_UP, CROLL_DIRECTION_DOWN, SCROLL_NONE
49 | */
50 | @ScrollDirection
51 | int getOverScrollDirection() {
52 | return overScrollDirection;
53 | }
54 |
55 |
56 | /**
57 | * @return Scroll direction: SCROLL_DIRECTION_UP, SCROLL_DIRECTION_DOWN, SCROLL_NONE
58 | */
59 |
60 | @ScrollDirection
61 | int getScrollDirection() {
62 | return scrollDirection;
63 | }
64 |
65 |
66 | /**
67 | * @param coordinatorLayout
68 | * @param child
69 | * @param direction Direction of the overscroll: SCROLL_DIRECTION_UP, SCROLL_DIRECTION_DOWN
70 | * @param currentOverScroll Unconsumed value, negative or positive based on the direction;
71 | * @param totalOverScroll Cumulative value for current direction
72 | */
73 | abstract void onNestedVerticalOverScroll(CoordinatorLayout coordinatorLayout, V child, @ScrollDirection int direction, int currentOverScroll, int totalOverScroll);
74 |
75 | /**
76 | * @param scrollDirection Direction of the overscroll: SCROLL_DIRECTION_UP, SCROLL_DIRECTION_DOWN
77 | */
78 | abstract void onDirectionNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed, @ScrollDirection int scrollDirection);
79 |
80 | @Override
81 | public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, V child, View directTargetChild, View target, int nestedScrollAxes) {
82 | return (nestedScrollAxes & View.SCROLL_AXIS_VERTICAL) != 0;
83 | }
84 |
85 | @Override
86 | public void onNestedScrollAccepted(CoordinatorLayout coordinatorLayout, V child, View directTargetChild, View target, int nestedScrollAxes) {
87 | super.onNestedScrollAccepted(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes);
88 | }
89 |
90 | @Override
91 | public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, V child, View target) {
92 | super.onStopNestedScroll(coordinatorLayout, child, target);
93 | }
94 |
95 | @Override
96 | public void onNestedScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
97 | super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
98 | if (dyUnconsumed > 0 && totalDyUnconsumed < 0) {
99 | totalDyUnconsumed = 0;
100 | overScrollDirection = ScrollDirection.SCROLL_DIRECTION_UP;
101 | } else if (dyUnconsumed < 0 && totalDyUnconsumed > 0) {
102 | totalDyUnconsumed = 0;
103 | overScrollDirection = ScrollDirection.SCROLL_DIRECTION_DOWN;
104 | }
105 | totalDyUnconsumed += dyUnconsumed;
106 | onNestedVerticalOverScroll(coordinatorLayout, child, overScrollDirection, dyConsumed, totalDyUnconsumed);
107 | }
108 |
109 | @Override
110 | public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed) {
111 | super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed);
112 | if (dy > 0 && totalDy < 0) {
113 | totalDy = 0;
114 | scrollDirection = ScrollDirection.SCROLL_DIRECTION_UP;
115 | } else if (dy < 0 && totalDy > 0) {
116 | totalDy = 0;
117 | scrollDirection = ScrollDirection.SCROLL_DIRECTION_DOWN;
118 | }
119 | totalDy += dy;
120 | onDirectionNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, scrollDirection);
121 | }
122 |
123 |
124 | @Override
125 | public boolean onNestedFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY, boolean consumed) {
126 | super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed);
127 | scrollDirection = velocityY > 0 ? ScrollDirection.SCROLL_DIRECTION_UP : ScrollDirection.SCROLL_DIRECTION_DOWN;
128 | return onNestedDirectionFling(coordinatorLayout, child, target, velocityX, velocityY, scrollDirection);
129 | }
130 |
131 | abstract boolean onNestedDirectionFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY, @ScrollDirection int scrollDirection);
132 |
133 | @Override
134 | public boolean onNestedPreFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY) {
135 | return super.onNestedPreFling(coordinatorLayout, child, target, velocityX, velocityY);
136 | }
137 |
138 | @NonNull
139 | @Override
140 | public WindowInsetsCompat onApplyWindowInsets(CoordinatorLayout coordinatorLayout, V child, WindowInsetsCompat insets) {
141 | return super.onApplyWindowInsets(coordinatorLayout, child, insets);
142 | }
143 |
144 | @Override
145 | public Parcelable onSaveInstanceState(CoordinatorLayout parent, V child) {
146 | return super.onSaveInstanceState(parent, child);
147 | }
148 |
149 | }
--------------------------------------------------------------------------------
/bottom-bar/src/main/res/drawable/bb_bottom_bar_top_shadow.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/res/layout-v21/bb_bottom_bar_item_container.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
14 |
15 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/res/layout/bb_bottom_bar_item_container.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
21 |
22 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/res/layout/bb_bottom_bar_item_container_tablet.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
14 |
15 |
25 |
26 |
27 |
28 |
33 |
34 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/res/layout/bb_bottom_bar_item_fixed.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
18 |
19 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/res/layout/bb_bottom_bar_item_fixed_tablet.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
13 |
14 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/res/layout/bb_bottom_bar_item_shifting.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
11 |
17 |
18 |
25 |
26 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/res/layout/bb_bottom_bar_item_titleless.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/res/values-land/bools.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | false
4 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/res/values/bools.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | false
4 | true
5 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #747474
4 | #212121
5 | #505050
6 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/res/values/dimensions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 56dp
4 | 8dp
5 | 4dp
6 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | BottomBar
3 |
4 |
--------------------------------------------------------------------------------
/bottom-bar/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
17 |
18 |
21 |
22 |
25 |
26 |
30 |
31 |
34 |
--------------------------------------------------------------------------------
/bottom-bar/src/test/java/com/roughike/bottombar/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.roughike.bottombar;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.1'
9 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
10 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
11 | classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.4.0'
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | jcenter()
21 | }
22 | }
23 |
24 | task clean(type: Delete) {
25 | delete rootProject.buildDir
26 | }
27 |
28 | ext {
29 | compileSdkVersion = 25
30 | buildToolsVersion = "25.0.2"
31 | minSdkVersion = 11
32 | targetSdkVersion = 25
33 | supportLibraryVersion = "25.3.0"
34 |
35 | junitVersion = "4.12"
36 | }
37 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Mar 25 00:47:49 IST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/graphics/icons-howto.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/graphics/icons-howto.png
--------------------------------------------------------------------------------
/graphics/screenshot_tablet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/graphics/screenshot_tablet.png
--------------------------------------------------------------------------------
/graphics/shifting-demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/graphics/shifting-demo.gif
--------------------------------------------------------------------------------
/graphics/shy-demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roughike/BottomBar/885d70e62359d15ed17dfd77a28809702d6ae513/graphics/shy-demo.gif
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':bottom-bar'
2 |
--------------------------------------------------------------------------------