Permalink
...
Comparing changes
Open a pull request
- 4 commits
- 6 files changed
- 0 commit comments
- 1 contributor
Unified
Split
Showing
with
91 additions
and 63 deletions.
- +1 −1 app/build.gradle
- +1 −1 bottom-bar/bottom-bar.iml
- +2 −2 bottom-bar/build.gradle
- +24 −24 bottom-bar/src/main/java/com/roughike/bottombar/BottomBar.java
- +47 −22 bottom-bar/src/main/java/com/roughike/bottombar/MiscUtils.java
- +16 −13 bottom-bar/src/main/res/layout/bb_bottom_bar_item_container.xml
View
2
app/build.gradle
@@ -6,7 +6,7 @@ android { | ||
defaultConfig { | ||
applicationId "com.example.bottombar.sample" | ||
- minSdkVersion 14 | ||
+ minSdkVersion 11 | ||
targetSdkVersion 23 | ||
versionCode 1 | ||
versionName "1.0" | ||
View
2
bottom-bar/bottom-bar.iml
@@ -1,5 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
-<module external.linked.project.id=":bottom-bar" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="com.roughike" external.system.module.version="1.1.6" type="JAVA_MODULE" version="4"> | ||
+<module external.linked.project.id=":bottom-bar" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="com.roughike" external.system.module.version="1.1.7" type="JAVA_MODULE" version="4"> | ||
<component name="FacetManager"> | ||
<facet type="android-gradle" name="Android-Gradle"> | ||
<configuration> | ||
View
4
bottom-bar/build.gradle
@@ -13,7 +13,7 @@ ext { | ||
siteUrl = 'https://github.com/roughike/BottomBar' | ||
gitUrl = 'https://github.com/roughike/BottomBar.git' | ||
- libraryVersion = '1.1.6' | ||
+ libraryVersion = '1.1.7' | ||
developerId = 'roughike' | ||
developerName = 'Iiro Krankka' | ||
@@ -29,7 +29,7 @@ android { | ||
buildToolsVersion "23.0.2" | ||
defaultConfig { | ||
- minSdkVersion 14 | ||
+ minSdkVersion 11 | ||
targetSdkVersion 23 | ||
versionCode 1 | ||
versionName "1.0" | ||
View
48
bottom-bar/src/main/java/com/roughike/bottombar/BottomBar.java
@@ -870,10 +870,10 @@ private void selectTab(View tab, boolean animate) { | ||
if (mIsDarkTheme) { | ||
if (title != null) { | ||
- title.setAlpha(1.0f); | ||
+ ViewCompat.setAlpha(title, 1.0f); | ||
} | ||
- icon.setAlpha(1.0f); | ||
+ ViewCompat.setAlpha(icon, 1.0f); | ||
} | ||
if (title == null) { | ||
@@ -883,18 +883,18 @@ private void selectTab(View tab, boolean animate) { | ||
int translationY = mIsShiftingMode ? mTenDp : mTwoDp; | ||
if (animate) { | ||
- title.animate() | ||
+ ViewCompat.animate(title) | ||
.setDuration(ANIMATION_DURATION) | ||
.scaleX(1) | ||
.scaleY(1) | ||
.start(); | ||
- tab.animate() | ||
+ ViewCompat.animate(tab) | ||
.setDuration(ANIMATION_DURATION) | ||
.translationY(-translationY) | ||
.start(); | ||
if (mIsShiftingMode) { | ||
- icon.animate() | ||
+ ViewCompat.animate(icon) | ||
.setDuration(ANIMATION_DURATION) | ||
.alpha(1.0f) | ||
.start(); | ||
@@ -902,12 +902,12 @@ private void selectTab(View tab, boolean animate) { | ||
handleBackgroundColorChange(tabPosition, tab); | ||
} else { | ||
- title.setScaleX(1); | ||
- title.setScaleY(1); | ||
- tab.setTranslationY(-translationY); | ||
+ ViewCompat.setScaleX(title, 1); | ||
+ ViewCompat.setScaleY(title, 1); | ||
+ ViewCompat.setTranslationY(tab, -translationY); | ||
if (mIsShiftingMode) { | ||
- icon.setAlpha(1.0f); | ||
+ ViewCompat.setAlpha(icon, 1.0f); | ||
} | ||
} | ||
} | ||
@@ -929,10 +929,10 @@ private void unselectTab(View tab, boolean animate) { | ||
if (mIsDarkTheme) { | ||
if (title != null) { | ||
- title.setAlpha(0.6f); | ||
+ ViewCompat.setAlpha(title, 0.6f); | ||
} | ||
- icon.setAlpha(0.6f); | ||
+ ViewCompat.setAlpha(icon, 0.6f); | ||
} | ||
if (title == null) { | ||
@@ -942,29 +942,29 @@ private void unselectTab(View tab, boolean animate) { | ||
float scale = mIsShiftingMode ? 0 : 0.86f; | ||
if (animate) { | ||
- title.animate() | ||
+ ViewCompat.animate(title) | ||
.setDuration(ANIMATION_DURATION) | ||
.scaleX(scale) | ||
.scaleY(scale) | ||
.start(); | ||
- tab.animate() | ||
+ ViewCompat.animate(tab) | ||
.setDuration(ANIMATION_DURATION) | ||
.translationY(0) | ||
.start(); | ||
if (mIsShiftingMode) { | ||
- icon.animate() | ||
+ ViewCompat.animate(icon) | ||
.setDuration(ANIMATION_DURATION) | ||
.alpha(0.6f) | ||
.start(); | ||
} | ||
} else { | ||
- title.setScaleX(scale); | ||
- title.setScaleY(scale); | ||
- tab.setTranslationY(0); | ||
+ ViewCompat.setScaleX(title, scale); | ||
+ ViewCompat.setScaleY(title, scale); | ||
+ ViewCompat.setTranslationY(tab, 0); | ||
if (mIsShiftingMode) { | ||
- icon.setAlpha(0.6f); | ||
+ ViewCompat.setAlpha(icon, 0.6f); | ||
} | ||
} | ||
} | ||
@@ -1010,16 +1010,16 @@ private void updateCurrentFragment() { | ||
&& mItems instanceof BottomBarFragment[]) { | ||
BottomBarFragment newFragment = ((BottomBarFragment) mItems[mCurrentTabPosition]); | ||
- if (mFragmentManager instanceof android.app.FragmentManager | ||
- && newFragment.getFragment() != null) { | ||
- ((android.app.FragmentManager) mFragmentManager).beginTransaction() | ||
- .replace(mFragmentContainer, newFragment.getFragment()) | ||
- .commit(); | ||
- } else if (mFragmentManager instanceof android.support.v4.app.FragmentManager | ||
+ if (mFragmentManager instanceof android.support.v4.app.FragmentManager | ||
&& newFragment.getSupportFragment() != null) { | ||
((android.support.v4.app.FragmentManager) mFragmentManager).beginTransaction() | ||
.replace(mFragmentContainer, newFragment.getSupportFragment()) | ||
.commit(); | ||
+ } else if (mFragmentManager instanceof android.app.FragmentManager | ||
+ && newFragment.getFragment() != null) { | ||
+ ((android.app.FragmentManager) mFragmentManager).beginTransaction() | ||
+ .replace(mFragmentContainer, newFragment.getFragment()) | ||
+ .commit(); | ||
} | ||
} | ||
View
69
bottom-bar/src/main/java/com/roughike/bottombar/MiscUtils.java
@@ -10,12 +10,16 @@ | ||
import android.content.res.Resources; | ||
import android.os.Build; | ||
import android.support.annotation.MenuRes; | ||
+import android.support.v4.view.ViewCompat; | ||
+import android.support.v4.view.ViewPropertyAnimatorCompat; | ||
+import android.support.v4.view.ViewPropertyAnimatorListenerAdapter; | ||
import android.util.DisplayMetrics; | ||
import android.util.TypedValue; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.view.ViewAnimationUtils; | ||
+import android.view.ViewPropertyAnimator; | ||
import android.widget.PopupMenu; | ||
import android.widget.TextView; | ||
@@ -108,14 +112,14 @@ protected static int getScreenWidth(Context context) { | ||
@TargetApi(Build.VERSION_CODES.LOLLIPOP) | ||
protected static void animateBGColorChange(View clickedView, final View backgroundView, | ||
final View bgOverlay, final int newColor) { | ||
- int centerX = (int) (clickedView.getX() + (clickedView.getMeasuredWidth() / 2)); | ||
+ int centerX = (int) (ViewCompat.getX(clickedView) + (clickedView.getMeasuredWidth() / 2)); | ||
int centerY = clickedView.getMeasuredHeight() / 2; | ||
int finalRadius = backgroundView.getWidth(); | ||
backgroundView.clearAnimation(); | ||
bgOverlay.clearAnimation(); | ||
- Animator animator; | ||
+ Object animator; | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | ||
if (!bgOverlay.isAttachedToWindow()) { | ||
@@ -125,31 +129,52 @@ protected static void animateBGColorChange(View clickedView, final View backgrou | ||
animator = ViewAnimationUtils | ||
.createCircularReveal(bgOverlay, centerX, centerY, 0, finalRadius); | ||
} else { | ||
- bgOverlay.setAlpha(0); | ||
- animator = ObjectAnimator.ofFloat(bgOverlay, "alpha", 0, 1); | ||
+ ViewCompat.setAlpha(bgOverlay, 0); | ||
+ animator = ViewCompat.animate(bgOverlay).alpha(1); | ||
} | ||
- animator.addListener(new AnimatorListenerAdapter() { | ||
- @Override | ||
- public void onAnimationEnd(Animator animation) { | ||
- onCancel(); | ||
- } | ||
- | ||
- @Override | ||
- public void onAnimationCancel(Animator animation) { | ||
- onCancel(); | ||
- } | ||
- | ||
- private void onCancel() { | ||
- backgroundView.setBackgroundColor(newColor); | ||
- bgOverlay.setVisibility(View.INVISIBLE); | ||
- bgOverlay.setAlpha(1); | ||
- } | ||
- }); | ||
+ if (animator instanceof ViewPropertyAnimatorCompat) { | ||
+ ((ViewPropertyAnimatorCompat) animator).setListener(new ViewPropertyAnimatorListenerAdapter() { | ||
+ @Override | ||
+ public void onAnimationEnd(View view) { | ||
+ onCancel(); | ||
+ } | ||
+ | ||
+ @Override | ||
+ public void onAnimationCancel(View view) { | ||
+ onCancel(); | ||
+ } | ||
+ | ||
+ private void onCancel() { | ||
+ backgroundView.setBackgroundColor(newColor); | ||
+ bgOverlay.setVisibility(View.INVISIBLE); | ||
+ ViewCompat.setAlpha(bgOverlay, 1); | ||
+ } | ||
+ }).start(); | ||
+ } else if (animator != null) { | ||
+ ((Animator) animator).addListener(new AnimatorListenerAdapter() { | ||
+ @Override | ||
+ public void onAnimationEnd(Animator animation) { | ||
+ onCancel(); | ||
+ } | ||
+ | ||
+ @Override | ||
+ public void onAnimationCancel(Animator animation) { | ||
+ onCancel(); | ||
+ } | ||
+ | ||
+ private void onCancel() { | ||
+ backgroundView.setBackgroundColor(newColor); | ||
+ bgOverlay.setVisibility(View.INVISIBLE); | ||
+ ViewCompat.setAlpha(bgOverlay, 1); | ||
+ } | ||
+ }); | ||
+ | ||
+ ((Animator) animator).start(); | ||
+ } | ||
bgOverlay.setBackgroundColor(newColor); | ||
bgOverlay.setVisibility(View.VISIBLE); | ||
- animator.start(); | ||
} | ||
/** | ||
View
29
bottom-bar/src/main/res/layout/bb_bottom_bar_item_container.xml
@@ -19,25 +19,28 @@ | ||
</FrameLayout> | ||
+ <View | ||
+ android:id="@+id/bb_bottom_bar_background_view" | ||
+ android:layout_width="match_parent" | ||
+ android:layout_height="match_parent" | ||
+ android:layout_alignTop="@+id/bb_bottom_bar_outer_container" | ||
+ android:layout_alignBottom="@+id/bb_bottom_bar_outer_container" | ||
+ android:background="#FFFFFF" /> | ||
+ | ||
+ <View | ||
+ android:id="@+id/bb_bottom_bar_background_overlay" | ||
+ android:layout_width="match_parent" | ||
+ android:layout_height="match_parent" | ||
+ android:layout_alignTop="@+id/bb_bottom_bar_outer_container" | ||
+ android:layout_alignBottom="@+id/bb_bottom_bar_outer_container" | ||
+ android:visibility="invisible" /> | ||
+ | ||
<FrameLayout | ||
android:id="@+id/bb_bottom_bar_outer_container" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentBottom="true"> | ||
- <FrameLayout | ||
- android:id="@+id/bb_bottom_bar_background_view" | ||
- android:layout_width="match_parent" | ||
- android:layout_height="match_parent" | ||
- android:background="#FFFFFF" /> | ||
- | ||
- <FrameLayout | ||
- android:id="@+id/bb_bottom_bar_background_overlay" | ||
- android:layout_width="match_parent" | ||
- android:layout_height="match_parent" | ||
- android:src="@drawable/bb_bottom_bar_top_shadow" | ||
- android:visibility="invisible" /> | ||
- | ||
<LinearLayout | ||
android:id="@+id/bb_bottom_bar_item_container" | ||
android:layout_width="match_parent" | ||