Centered typing in search field

Change-Id: Iae46722195d0d06ff88da52df4fa48ca7b157512
This commit is contained in:
Peter Schiller
2016-07-19 16:01:32 -07:00
parent bbff2926f8
commit 637e40ad6f
3 changed files with 28 additions and 34 deletions

View File

@@ -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.
*/