summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Schiller <peterschiller@google.com>2016-07-20 00:31:23 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-07-20 00:31:23 +0000
commit5b3ace8e56988eb493a3423f9e25b29909fa50bf (patch)
tree03c2e42de5952668507df4c1bb6b8836640ce623
parent8f58e61d02fcb0ca90a2803e76a8792ec2c1f99a (diff)
parent637e40ad6f7f8bbc5e6925f89eac7ae183366b16 (diff)
downloadandroid_packages_apps_Trebuchet-5b3ace8e56988eb493a3423f9e25b29909fa50bf.tar.gz
android_packages_apps_Trebuchet-5b3ace8e56988eb493a3423f9e25b29909fa50bf.tar.bz2
android_packages_apps_Trebuchet-5b3ace8e56988eb493a3423f9e25b29909fa50bf.zip
Merge "Centered typing in search field" into ub-launcher3-calgary
-rw-r--r--res/layout/all_apps.xml2
-rw-r--r--src/com/android/launcher3/allapps/AllAppsContainerView.java33
-rw-r--r--src/com/android/launcher3/allapps/AllAppsSearchBarController.java27
3 files changed, 28 insertions, 34 deletions
diff --git a/res/layout/all_apps.xml b/res/layout/all_apps.xml
index ad1fa8280..12a4029a9 100644
--- a/res/layout/all_apps.xml
+++ b/res/layout/all_apps.xml
@@ -87,7 +87,7 @@
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:focusableInTouchMode="true"
- android:gravity="start|center_vertical"
+ android:gravity="center"
android:imeOptions="actionSearch|flagNoExtractUi"
android:inputType="text|textNoSuggestions|textCapWords"
android:maxLines="1"
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 195ab4751..cc969343c 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -15,7 +15,6 @@
*/
package com.android.launcher3.allapps;
-import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
@@ -31,7 +30,6 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
-import android.view.animation.AnimationUtils;
import com.android.launcher3.AppInfo;
import com.android.launcher3.BaseContainerView;
@@ -242,6 +240,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
}
mSearchBarController = searchController;
mSearchBarController.initialize(mApps, mSearchInput, mLauncher, this);
+ mSearchBarController.setHintView(findViewById(R.id.search_hint));
mAdapter.setSearchController(mSearchBarController);
}
@@ -312,36 +311,6 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
mSearchContainerOffsetTop = getResources().getDimensionPixelSize(
R.dimen.all_apps_search_bar_margin_top);
- final View searchHint = findViewById(R.id.search_hint);
- final ObjectAnimator searchInputAnimator = ObjectAnimator.ofFloat(mSearchInput,
- View.TRANSLATION_X, 0);
- searchInputAnimator.setDuration(getContext().getResources().getInteger(
- R.integer.config_searchHintAnimationDuration));
- searchInputAnimator.setInterpolator(AnimationUtils.loadInterpolator(getContext(),
- android.R.interpolator.accelerate_decelerate));
-
- mSearchInput.setOnFocusChangeListener(new OnFocusChangeListener() {
- @Override
- public void onFocusChange(View view, boolean focused) {
- if (focused) {
- searchHint.setVisibility(View.INVISIBLE);
- if (searchInputAnimator.isRunning()) {
- searchInputAnimator.end();
- }
-
- if (Utilities.isRtl(getContext().getResources())) {
- searchInputAnimator.setFloatValues(-searchHint.getLeft(), 0);
- } else {
- searchInputAnimator.setFloatValues(searchHint.getLeft(), 0);
- }
- searchInputAnimator.start();
- } else {
- searchHint.setVisibility(View.VISIBLE);
- mSearchInput.setTranslationX(0);
- }
- }
- });
-
mElevationController = Utilities.ATLEAST_LOLLIPOP
? new HeaderElevationController.ControllerVL(mSearchContainer)
: new HeaderElevationController.ControllerV16(mSearchContainer);
diff --git a/src/com/android/launcher3/allapps/AllAppsSearchBarController.java b/src/com/android/launcher3/allapps/AllAppsSearchBarController.java
index ac3593238..b4a71caf8 100644
--- a/src/com/android/launcher3/allapps/AllAppsSearchBarController.java
+++ b/src/com/android/launcher3/allapps/AllAppsSearchBarController.java
@@ -39,7 +39,8 @@ import java.util.ArrayList;
* An interface to a search box that AllApps can command.
*/
public abstract class AllAppsSearchBarController
- implements TextWatcher, OnEditorActionListener, ExtendedEditText.OnBackKeyListener {
+ implements TextWatcher, OnEditorActionListener, ExtendedEditText.OnBackKeyListener,
+ View.OnFocusChangeListener {
protected Launcher mLauncher;
protected AlphabeticalAppsList mApps;
@@ -49,6 +50,8 @@ public abstract class AllAppsSearchBarController
protected DefaultAppSearchAlgorithm mSearchAlgorithm;
protected InputMethodManager mInputMethodManager;
+ protected View mHintView;
+
public void setVisibility(int visibility) {
mInput.setVisibility(visibility);
}
@@ -66,6 +69,7 @@ public abstract class AllAppsSearchBarController
mInput.addTextChangedListener(this);
mInput.setOnEditorActionListener(this);
mInput.setOnBackKeyListener(this);
+ mInput.setOnFocusChangeListener(this);
mInputMethodManager = (InputMethodManager)
mInput.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
@@ -126,6 +130,27 @@ public abstract class AllAppsSearchBarController
return false;
}
+ @Override
+ public void onFocusChange(View view, boolean focused) {
+ if (mHintView != null) {
+ mHintView.setVisibility(focused ? View.INVISIBLE : View.VISIBLE);
+ }
+ }
+
+ /**
+ * Sets a view to serve as the search field's hint.
+ */
+ public void setHintView(View hintView) {
+ mHintView = hintView;
+ }
+
+ /**
+ * Returns the search field's hint view.
+ */
+ public View getHintView() {
+ return mHintView;
+ }
+
/**
* Resets the search bar state.
*/