Added bottom navigation
diff --git a/LottieSample/build.gradle b/LottieSample/build.gradle
index b51808c..00fe7fa 100644
--- a/LottieSample/build.gradle
+++ b/LottieSample/build.gradle
@@ -64,15 +64,12 @@
implementation 'com.matthew-tamlin:sliding-intro-screen:3.2.0'
implementation 'com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.2'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.2'
-
debugImplementation 'com.github.brianPlummer:tinydancer:0.0.9'
-
testImplementation 'junit:junit:4.12'
-
androidTestImplementation 'com.airbnb.android:happo:0.0.15@aar'
// TODO: figure out why transitive deps of happo are needed
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
- androidTestImplementation "com.android.support.test:runner:1.0.1"
+ androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-idling-resource:3.0.1'
androidTestImplementation 'io.reactivex.rxjava2:rxjava:2.1.5'
androidTestImplementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
@@ -80,7 +77,6 @@
androidTestImplementation 'com.amazonaws:aws-android-sdk-core:2.6.5'
androidTestImplementation 'com.amazonaws:aws-android-sdk-s3:2.6.5'
androidTestImplementation 'io.jsonwebtoken:jjwt:0.8.0'
-
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'org.hamcrest', module: 'hamcrest-integration'
@@ -91,6 +87,7 @@
androidTestImplementation('com.android.support.test:rules:0.5', {
exclude group: 'com.android.support', module: 'support-annotations'
})
+ implementation 'com.android.support:design:27.1.0'
}
repositories {
mavenCentral()
diff --git a/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/ListFragment.kt b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/ListFragment.kt
index ea1082a..bc5f6c3 100644
--- a/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/ListFragment.kt
+++ b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/ListFragment.kt
@@ -66,7 +66,7 @@
.addToBackStack(null)
.setCustomAnimations(R.anim.slide_in_right, R.anim.hold, R.anim.hold, R.anim.slide_out_right)
.remove(this)
- .replace(R.id.content_2, fragment)
+ .replace(R.id.content, fragment)
.commit()
}
diff --git a/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/MainActivity.kt b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/MainActivity.kt
index 8b22076..35950c4 100644
--- a/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/MainActivity.kt
+++ b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/MainActivity.kt
@@ -1,18 +1,36 @@
package com.airbnb.lottie.samples
import android.os.Bundle
+import android.support.design.widget.BottomNavigationView
+import android.support.v4.app.Fragment
import android.support.v7.app.AppCompatActivity
+import android.view.MenuItem
+import kotlinx.android.synthetic.main.activity_main.*
-class MainActivity : AppCompatActivity() {
+class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemSelectedListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
+ bottomNavigation.setOnNavigationItemSelectedListener(this)
- if (savedInstanceState == null) {
- supportFragmentManager.beginTransaction()
- .replace(R.id.content_1, ListFragment.newInstance())
- .commit()
+ savedInstanceState ?: showFragment(ListFragment.newInstance())
+ }
+
+ override fun onNavigationItemSelected(item: MenuItem): Boolean {
+ when (item.itemId) {
+ R.id.showcase -> showFragment(ListFragment.newInstance())
+ R.id.preview -> showFragment(TodoFragment())
+ R.id.lottiefiles -> showFragment(TodoFragment())
+ R.id.learn -> showFragment(TodoFragment())
+ else -> return false
}
+ return true
+ }
+
+ private fun showFragment(fragment: Fragment) {
+ supportFragmentManager.beginTransaction()
+ .replace(R.id.content, fragment)
+ .commit()
}
}
diff --git a/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/TodoFragment.kt b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/TodoFragment.kt
new file mode 100644
index 0000000..86ebaf9
--- /dev/null
+++ b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/TodoFragment.kt
@@ -0,0 +1,13 @@
+package com.airbnb.lottie.samples
+
+import android.os.Bundle
+import android.support.v4.app.Fragment
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+
+class TodoFragment : Fragment() {
+
+ override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View =
+ inflater.inflate(R.layout.fragment_todo, container, false)
+}
\ No newline at end of file
diff --git a/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/views/NoShiftBottomNavigationView.kt b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/views/NoShiftBottomNavigationView.kt
new file mode 100644
index 0000000..0d83dde
--- /dev/null
+++ b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/views/NoShiftBottomNavigationView.kt
@@ -0,0 +1,45 @@
+package com.airbnb.lottie.samples.views
+
+import android.annotation.SuppressLint
+import android.content.Context
+import android.support.design.internal.BottomNavigationItemView
+import android.support.design.internal.BottomNavigationMenuView
+import android.support.design.widget.BottomNavigationView
+import android.util.AttributeSet
+import android.util.Log
+import android.view.View
+import androidx.view.children
+
+private val TAG = NoShiftBottomNavigationView::class.java.name
+
+class NoShiftBottomNavigationView @JvmOverloads constructor(
+ context: Context,
+ attrs: AttributeSet? = null,
+ defStyleAttr: Int = 0
+) : BottomNavigationView(context, attrs, defStyleAttr) {
+
+ override fun onViewAdded(child: View?) {
+ super.onViewAdded(child)
+ removeShiftAnimation()
+ }
+
+ @SuppressLint("RestrictedApi")
+ private fun removeShiftAnimation() {
+ val menuView = getChildAt(0) as BottomNavigationMenuView
+ try {
+ menuView::class.java.getDeclaredField("mShiftingMode").apply {
+ isAccessible = true
+ setBoolean(menuView, false)
+ isAccessible = false
+ }
+
+ menuView.children
+ .map { it as BottomNavigationItemView }
+ .forEach { it.setChecked(it.itemData.isChecked) }
+ } catch (e: NoSuchFieldException) {
+ Log.e(TAG, "Unable to get shift mode field", e)
+ } catch (e: IllegalAccessException) {
+ Log.e(TAG, "Unable to change value of shift mode", e)
+ }
+ }
+}
\ No newline at end of file
diff --git a/LottieSample/src/main/res/drawable/bottom_bar_tint_list.xml b/LottieSample/src/main/res/drawable/bottom_bar_tint_list.xml
new file mode 100644
index 0000000..9cc94a5
--- /dev/null
+++ b/LottieSample/src/main/res/drawable/bottom_bar_tint_list.xml
@@ -0,0 +1,4 @@
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="@android:color/black" android:state_checked="true" />
+ <item android:color="#FF7C7C7C" android:state_checked="false" />
+</selector>
\ No newline at end of file
diff --git a/LottieSample/src/main/res/drawable/ic_device.xml b/LottieSample/src/main/res/drawable/ic_device.xml
new file mode 100644
index 0000000..50c70b3
--- /dev/null
+++ b/LottieSample/src/main/res/drawable/ic_device.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M17,1.01L7,1c-1.1,0 -1.99,0.9 -1.99,2v18c0,1.1 0.89,2 1.99,2h10c1.1,0 2,-0.9 2,-2V3c0,-1.1 -0.9,-1.99 -2,-1.99zM17,19H7V5h10v14z"/>
+</vector>
diff --git a/LottieSample/src/main/res/drawable/ic_learn.xml b/LottieSample/src/main/res/drawable/ic_learn.xml
new file mode 100644
index 0000000..16671bf
--- /dev/null
+++ b/LottieSample/src/main/res/drawable/ic_learn.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="22dp"
+ android:height="18dp"
+ android:viewportWidth="22"
+ android:viewportHeight="18">
+
+ <group
+ android:translateX="-304.000000"
+ android:translateY="-12.000000">
+ <group
+ android:translateX="303.000000"
+ android:translateY="9.000000">
+ <path
+ android:fillAlpha="0.5"
+ android:fillType="evenOdd"
+ android:strokeAlpha="0.5"
+ android:strokeWidth="1"
+ android:pathData="M 0 0 L 24 0 L 24 24 L 0 24 Z" />
+ <path
+ android:fillColor="#000000"
+ android:fillAlpha="0.5"
+ android:strokeAlpha="0.5"
+ android:strokeWidth="1"
+ android:pathData="M5,13.18 L5,17.18 L12,21 L19,17.18 L19,13.18 L12,17 L5,13.18 Z M12,3 L1,9 L12,15 L21,10.09 L21,17 L23,17 L23,9 L12,3 Z" />
+ </group>
+ </group>
+</vector>
\ No newline at end of file
diff --git a/LottieSample/src/main/res/drawable/ic_lottiefiles.xml b/LottieSample/src/main/res/drawable/ic_lottiefiles.xml
new file mode 100644
index 0000000..434148f
--- /dev/null
+++ b/LottieSample/src/main/res/drawable/ic_lottiefiles.xml
@@ -0,0 +1,15 @@
+<vector android:height="24dp" android:viewportHeight="22"
+ android:viewportWidth="22" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillAlpha="0.5" android:fillColor="#000000"
+ android:fillType="evenOdd"
+ android:pathData="M22,18.1514L21.011,20C20.6567,19.9561 20.3044,19.8981 19.9559,19.8245C18.9209,19.606 17.9769,19.2571 17.1468,18.7574C16.115,18.1363 15.403,17.6491 14.7486,17.1253C14.5934,17.001 14.439,16.8729 14.2756,16.7332C14.0257,16.5195 12.8988,15.514 12.5202,15.1868C11.6413,14.427 10.6663,13.633 9.3768,12.6424C8.7528,12.1386 8.1516,11.9327 7.5811,11.9489C7.182,11.9602 6.8241,12.0855 6.6312,12.2242C5.9505,12.7136 5.7895,13.2074 5.7895,14.0874C5.7895,14.7651 6.2083,15.5855 6.9416,15.7863C7.4656,15.9297 7.8255,15.8722 8.3777,15.5285C8.8057,15.262 9.3529,15.4206 9.5997,15.8828C9.8466,16.3449 9.6997,16.9355 9.2716,17.202C8.3209,17.7939 7.4834,17.9275 6.5018,17.6589C4.8412,17.2043 4,15.5564 4,14.0874C4,12.6276 4.3547,11.5399 5.6393,10.6163C6.8397,9.7532 8.7203,9.6999 10.4313,11.0818C11.731,12.0799 12.7331,12.896 13.6388,13.6788C14.0332,14.0198 15.1551,15.0208 15.3866,15.2188C15.5357,15.3463 15.6752,15.462 15.8144,15.5735C16.4023,16.0441 17.0502,16.4873 18.0183,17.0702C18.6713,17.4632 19.4389,17.7469 20.2994,17.9286C20.8527,18.0454 21.4238,18.1174 22,18.1514Z"
+ android:strokeAlpha="0.5" android:strokeColor="#00000000" android:strokeWidth="1"/>
+ <path android:fillAlpha="0.5" android:fillColor="#000000"
+ android:fillType="evenOdd"
+ android:pathData="M13.7727,0L16,0C15.9397,0.9956 15.8678,1.9813 15.7834,2.9145C15.6584,4.2977 15.5143,5.4717 15.3483,6.3769C14.6203,10.3461 13.5398,13.4898 12.0139,15.0918C10.6497,16.524 9.7691,17.0686 8.987,16.9932C8.918,16.9854 8.918,16.9854 8.851,16.9732C8.254,16.854 7.887,16.3578 8.0314,15.865C8.1347,15.5126 8.4716,15.2573 8.8735,15.184C8.8851,15.1772 8.9002,15.1682 8.9185,15.1568C9.2147,14.9737 9.6632,14.5889 10.2652,13.9569C11.4695,12.6925 12.4785,9.7571 13.1488,6.102C13.3048,5.2512 13.4438,4.1188 13.565,2.7779C13.6453,1.8897 13.7144,0.9504 13.7727,0L13.7727,0Z"
+ android:strokeAlpha="0.5" android:strokeColor="#00000000" android:strokeWidth="1"/>
+ <path android:fillAlpha="0.5" android:fillColor="#000000"
+ android:fillType="evenOdd"
+ android:pathData="M7.0044,16.4858C6.9938,16.5274 7.0025,16.469 7.0292,16.271C7.1906,15.9025 7.3624,15.8989 7.5338,16.3277C7.4675,16.1767 7.4675,16.1767 7.4038,16.0867C7.2399,15.8888 7.1037,16.0988 7.0044,16.4858Z"
+ android:strokeAlpha="0.5" android:strokeColor="#00000000" android:strokeWidth="1"/>
+</vector>
diff --git a/LottieSample/src/main/res/drawable/ic_showcase.xml b/LottieSample/src/main/res/drawable/ic_showcase.xml
new file mode 100644
index 0000000..61c5d7a
--- /dev/null
+++ b/LottieSample/src/main/res/drawable/ic_showcase.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM16.23,18L12,15.45 7.77,18l1.12,-4.81 -3.73,-3.23 4.92,-0.42L12,5l1.92,4.53 4.92,0.42 -3.73,3.23L16.23,18z"/>
+</vector>
diff --git a/LottieSample/src/main/res/layout/activity_main.xml b/LottieSample/src/main/res/layout/activity_main.xml
index 8a979a0..727967a 100644
--- a/LottieSample/src/main/res/layout/activity_main.xml
+++ b/LottieSample/src/main/res/layout/activity_main.xml
@@ -1,20 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
-<FrameLayout
+<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:orientation="vertical"
tools:context=".MainActivity">
<FrameLayout
- android:id="@+id/content_1"
+ android:id="@+id/content"
android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:layout_height="0dp"
+ android:layout_weight="1"/>
- <FrameLayout
- android:id="@+id/content_2"
+
+ <com.airbnb.lottie.samples.views.NoShiftBottomNavigationView
+ android:id="@+id/bottomNavigation"
android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:layout_height="56dp"
+ app:menu="@menu/bottom_bar"
+ app:itemIconTint="@drawable/bottom_bar_tint_list"
+ app:itemTextColor="#3D4246"
+ android:background="#F7F7F7"
+ android:elevation="8dp"/>
-</FrameLayout>
\ No newline at end of file
+</LinearLayout>
\ No newline at end of file
diff --git a/LottieSample/src/main/res/layout/fragment_todo.xml b/LottieSample/src/main/res/layout/fragment_todo.xml
new file mode 100644
index 0000000..e3c78e8
--- /dev/null
+++ b/LottieSample/src/main/res/layout/fragment_todo.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="TODO" />
+
+</FrameLayout>
\ No newline at end of file
diff --git a/LottieSample/src/main/res/menu/bottom_bar.xml b/LottieSample/src/main/res/menu/bottom_bar.xml
new file mode 100644
index 0000000..13b211d
--- /dev/null
+++ b/LottieSample/src/main/res/menu/bottom_bar.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+ <item
+ android:id="@+id/showcase"
+ android:icon="@drawable/ic_showcase"
+ android:title="@string/bottom_bar_showcase"
+ app:showAsAction="always|withText"/>
+
+ <item
+ android:id="@+id/preview"
+ android:icon="@drawable/ic_device"
+ android:title="@string/bottom_bar_preview"
+ app:showAsAction="always|withText"/>
+
+ <item
+ android:id="@+id/lottiefiles"
+ android:icon="@drawable/ic_lottiefiles"
+ android:title="@string/bottom_bar_lottiefiles"
+ app:showAsAction="always|withText"/>
+
+ <item
+ android:id="@+id/learn"
+ android:icon="@drawable/ic_learn"
+ android:title="@string/bottom_bar_learn"
+ app:showAsAction="always|withText"/>
+</menu>
\ No newline at end of file
diff --git a/LottieSample/src/main/res/values/strings.xml b/LottieSample/src/main/res/values/strings.xml
index 1a8052d..6a7d58d 100644
--- a/LottieSample/src/main/res/values/strings.xml
+++ b/LottieSample/src/main/res/values/strings.xml
@@ -26,4 +26,9 @@
<string name="scale">Scale</string>
<string name="background">Background</string>
<string name="ms">ms</string>
+
+ <string name="bottom_bar_showcase">Showcase</string>
+ <string name="bottom_bar_preview">Preview</string>
+ <string name="bottom_bar_lottiefiles">Lottiefiles</string>
+ <string name="bottom_bar_learn">Learn</string>
</resources>