diff options
author | Stefan Niedermann <info@niedermann.it> | 2021-03-28 19:27:59 +0300 |
---|---|---|
committer | Niedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com> | 2021-03-28 20:00:49 +0300 |
commit | 5260ffdc7d8d5fcece6a3c5e29defabf7bc20284 (patch) | |
tree | 026b6e7a891664e77a9c2de539b527eb3dce3ff6 | |
parent | f01326fd1920d8b98da11d3101e651c5d796057f (diff) |
#630 Search - Animate card elevation on search en/disabling
Signed-off-by: Stefan Niedermann <info@niedermann.it>
4 files changed, 25 insertions, 1 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java index 9f18c791d..6837888da 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java @@ -1,5 +1,6 @@ package it.niedermann.nextcloud.deck.ui; +import android.animation.AnimatorInflater; import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; @@ -952,6 +953,7 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener binding.filterText.requestFocus(); final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(binding.filterText, InputMethodManager.SHOW_IMPLICIT); + binding.toolbarCard.setStateListAnimator(AnimatorInflater.loadStateListAnimator(this, R.animator.appbar_elevation_on)); } private void hideFilterTextToolbar() { @@ -961,6 +963,7 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener binding.searchToolbar.setVisibility(View.GONE); binding.enableSearch.setVisibility(View.VISIBLE); binding.toolbar.setVisibility(View.VISIBLE); + binding.toolbarCard.setStateListAnimator(AnimatorInflater.loadStateListAnimator(this, R.animator.appbar_elevation_off)); } private void registerAutoSyncOnNetworkAvailable() { diff --git a/app/src/main/res/animator/appbar_elevation_off.xml b/app/src/main/res/animator/appbar_elevation_off.xml new file mode 100644 index 000000000..d24dcb340 --- /dev/null +++ b/app/src/main/res/animator/appbar_elevation_off.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item> + <objectAnimator + android:propertyName="elevation" + android:valueTo="0dp" + android:valueType="floatType" /> + </item> +</selector> diff --git a/app/src/main/res/animator/appbar_elevation_on.xml b/app/src/main/res/animator/appbar_elevation_on.xml new file mode 100644 index 000000000..6bd52cf3b --- /dev/null +++ b/app/src/main/res/animator/appbar_elevation_on.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<selector xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + tools:ignore="PrivateResource"> + <item> + <objectAnimator + android:propertyName="elevation" + android:valueTo="@dimen/design_appbar_elevation" + android:valueType="floatType" /> + </item> +</selector> diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 4bccf9adf..ffe749c15 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -103,14 +103,15 @@ android:layout_height="wrap_content"> <com.google.android.material.card.MaterialCardView + android:id="@+id/toolbarCard" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:layout_marginStart="@dimen/spacer_2x" android:layout_marginTop="@dimen/spacer_1x" android:layout_marginEnd="@dimen/spacer_2x" android:layout_marginBottom="@dimen/spacer_1hx" - android:elevation="2dp" app:cardCornerRadius="@dimen/spacer_1x" + app:cardElevation="0dp" app:strokeWidth="0dp"> |