mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-03 01:16:49 +00:00
Centered typing in search field
Change-Id: Iae46722195d0d06ff88da52df4fa48ca7b157512
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user