diff options
author | calderwoodra <calderwoodra@google.com> | 2018-02-12 02:07:28 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-02-12 11:42:45 -0800 |
commit | 814a5b4894426eea6d178018df767c22a5453c4d (patch) | |
tree | b2e81c067aa0a1609cc44878f028472b9cbec5c1 /java | |
parent | cdcda1a127c4841c2710c17f64a2f522c62cd512 (diff) |
Fixed some search UI nits.
- Search bar text no longer extends underneath the X/clear button.
- Dialpad text is now preserved when it is lowered then raised again without
leaving the search UI.
- Search bar now has a shadow in the search UI
Bug: 73088433
Test: tests for dialpad text logic
PiperOrigin-RevId: 185350273
Change-Id: Ie4c968cba4f187af81121aa40d43c26a762cdd2b
Diffstat (limited to 'java')
5 files changed, 66 insertions, 6 deletions
diff --git a/java/com/android/dialer/main/impl/MainSearchController.java b/java/com/android/dialer/main/impl/MainSearchController.java index f1486ba96..7098f8844 100644 --- a/java/com/android/dialer/main/impl/MainSearchController.java +++ b/java/com/android/dialer/main/impl/MainSearchController.java @@ -16,6 +16,7 @@ package com.android.dialer.main.impl; +import android.app.Fragment; import android.app.FragmentTransaction; import android.content.ActivityNotFoundException; import android.content.Intent; @@ -131,7 +132,15 @@ public class MainSearchController implements SearchBarListener { transaction.commit(); } - /** Hides the dialpad, reveals the FAB and slides the toolbar back onto the screen. */ + /** + * Hides the dialpad, reveals the FAB and slides the toolbar back onto the screen. + * + * <p>This method intentionally "hides" and does not "remove" the dialpad in order to preserve its + * state (i.e. we call {@link FragmentTransaction#hide(Fragment)} instead of {@link + * FragmentTransaction#remove(Fragment)}. + * + * @see {@link #closeSearch(boolean)} to "remove" the dialpad. + */ private void hideDialpad(boolean animate, boolean bottomNavVisible) { Assert.checkArgument(isDialpadVisible()); @@ -159,7 +168,7 @@ public class MainSearchController implements SearchBarListener { @Override public void onAnimationEnd(Animation animation) { if (!(mainActivity.isFinishing() || mainActivity.isDestroyed())) { - mainActivity.getFragmentManager().beginTransaction().remove(dialpadFragment).commit(); + mainActivity.getFragmentManager().beginTransaction().hide(dialpadFragment).commit(); } } @@ -227,7 +236,10 @@ public class MainSearchController implements SearchBarListener { } } - /** Calls {@link #hideDialpad(boolean, boolean)} and removes the search fragment. */ + /** + * Calls {@link #hideDialpad(boolean, boolean)}, removes the search fragment and clears the + * dialpad. + */ private void closeSearch(boolean animate) { Assert.checkArgument(isSearchVisible()); if (isDialpadVisible()) { @@ -238,9 +250,17 @@ public class MainSearchController implements SearchBarListener { showBottomNav(); toolbar.collapse(animate); mainActivity.getFragmentManager().beginTransaction().remove(getSearchFragment()).commit(); + + // Clear the dialpad so the phone number isn't persisted between search sessions. + getDialpadFragment().clearDialpad(); } - @Nullable + /** + * Returns {@link DialpadFragment}. + * + * <p>Unless this method is being called for the first time in {@link #openSearch(Optional)} or + * {@link #showDialpad(boolean)}, it should never return null. + */ private DialpadFragment getDialpadFragment() { return (DialpadFragment) mainActivity.getFragmentManager().findFragmentByTag(DIALPAD_FRAGMENT_TAG); @@ -295,6 +315,15 @@ public class MainSearchController implements SearchBarListener { } else if (!isSearchVisible()) { transaction.show(getSearchFragment()); } + + // Add the dialpad fragment but keep it hidden + if (getDialpadFragment() == null) { + DialpadFragment dialpadFragment = new DialpadFragment(); + transaction + .add(R.id.dialpad_fragment_container, dialpadFragment, DIALPAD_FRAGMENT_TAG) + .hide(dialpadFragment); + } + transaction.commit(); } diff --git a/java/com/android/dialer/main/impl/res/layout/main_activity.xml b/java/com/android/dialer/main/impl/res/layout/main_activity.xml index 2094a7329..d8b13a6c2 100644 --- a/java/com/android/dialer/main/impl/res/layout/main_activity.xml +++ b/java/com/android/dialer/main/impl/res/layout/main_activity.xml @@ -67,6 +67,13 @@ android:id="@+id/toolbar" layout="@layout/toolbar_layout"/> + <ImageView + android:layout_width="match_parent" + android:layout_height="2dp" + android:scaleType="fitXY" + android:src="@drawable/search_shadow" + android:layout_below="@+id/toolbar"/> + <!-- TODO(calderwoodra): investigate what this is for and why we want it. --> <!-- Host container for the contact tile drag shadow --> <FrameLayout diff --git a/java/com/android/dialer/main/impl/toolbar/res/drawable/search_shadow.xml b/java/com/android/dialer/main/impl/toolbar/res/drawable/search_shadow.xml new file mode 100644 index 000000000..583ad20d5 --- /dev/null +++ b/java/com/android/dialer/main/impl/toolbar/res/drawable/search_shadow.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2018 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle"> + <gradient + android:startColor="#3333" + android:endColor="#0333" + android:type="linear" + android:angle="90"> + </gradient> +</shape>
\ No newline at end of file diff --git a/java/com/android/dialer/main/impl/toolbar/res/layout/expanded_search_bar.xml b/java/com/android/dialer/main/impl/toolbar/res/layout/expanded_search_bar.xml index 4dbd4bf22..4e49accae 100644 --- a/java/com/android/dialer/main/impl/toolbar/res/layout/expanded_search_bar.xml +++ b/java/com/android/dialer/main/impl/toolbar/res/layout/expanded_search_bar.xml @@ -36,7 +36,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_toEndOf="@+id/search_back_button" - android:layout_toStartOf="@+id/search_close_button" + android:layout_toStartOf="@+id/search_clear_button" android:layout_centerVertical="true" android:layout_marginStart="8dp" android:minHeight="48dp" diff --git a/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml b/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml index 7c4cee2b3..59cc35451 100644 --- a/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml +++ b/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml @@ -16,7 +16,6 @@ <com.android.dialer.main.impl.toolbar.MainToolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" - android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="@color/dialer_theme_color" |