From 0e9c77b0367558966e2bd029046633439f86e3b0 Mon Sep 17 00:00:00 2001 From: Jeff Boek Date: Tue, 29 Jan 2019 10:03:39 -0800 Subject: [PATCH] Cleans up animation between search bar states --- .../org/mozilla/fenix/home/HomeFragment.kt | 2 - .../java/org/mozilla/fenix/home/SearchView.kt | 40 +++++++++++++++++++ app/src/main/res/layout/fragment_home.xml | 4 +- app/src/main/res/xml/home_scene.xml | 20 ++++++++-- 4 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 app/src/main/java/org/mozilla/fenix/home/SearchView.kt diff --git a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt index 6f36a8daa..e3ba9dd12 100644 --- a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt @@ -11,7 +11,6 @@ import android.transition.TransitionInflater import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.view.ViewOutlineProvider import androidx.core.view.ViewCompat import androidx.fragment.app.Fragment import androidx.navigation.Navigation @@ -24,7 +23,6 @@ import org.mozilla.fenix.mvi.ActionBusFactory import org.mozilla.fenix.ext.requireComponents import kotlin.math.roundToInt - class HomeFragment : Fragment() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, diff --git a/app/src/main/java/org/mozilla/fenix/home/SearchView.kt b/app/src/main/java/org/mozilla/fenix/home/SearchView.kt new file mode 100644 index 000000000..f3cb48755 --- /dev/null +++ b/app/src/main/java/org/mozilla/fenix/home/SearchView.kt @@ -0,0 +1,40 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.fenix.home + +import android.content.Context +import android.graphics.drawable.TransitionDrawable +import android.util.AttributeSet +import android.widget.FrameLayout +import org.mozilla.fenix.R + +class SearchView(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs) { + private val lightDrawable = resources.getDrawable(R.drawable.home_search_background_light) + private val darkDrawable = resources.getDrawable(R.drawable.home_search_background_dark) + private val darkNoBorderDrawable = resources.getDrawable(R.drawable.home_search_background_dark_no_border) + + private val lightToDark = TransitionDrawable(arrayOf(lightDrawable, darkDrawable)) + private val darkToNoBorder = TransitionDrawable(arrayOf(darkDrawable, darkNoBorderDrawable)) + + fun transitionToLight() { + background = lightToDark + lightToDark.reverseTransition(500) + } + + fun transitionToDark() { + background = lightToDark + lightToDark.startTransition(500) + } + + fun transitionToDarkFromNoBorder() { + background = darkToNoBorder + darkToNoBorder.reverseTransition(500) + } + + fun transitionToDarkNoBorder() { + background = darkToNoBorder + darkToNoBorder.startTransition(500) + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index ab6c73f1d..22e7a3a66 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -40,7 +40,7 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/menuButton" /> - - + \ No newline at end of file diff --git a/app/src/main/res/xml/home_scene.xml b/app/src/main/res/xml/home_scene.xml index ca26599f7..fc40ba974 100644 --- a/app/src/main/res/xml/home_scene.xml +++ b/app/src/main/res/xml/home_scene.xml @@ -49,15 +49,29 @@ android:alpha="0" /> + motion:target="@id/toolbar_wrapper" + motion:framePosition="0" + android:elevation="@dimen/toolbar_elevation" /> + + + +