Loading src/com/android/launcher3/ExtendedEditText.java +30 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.launcher3; import static com.android.launcher3.logging.KeyboardStateManager.KeyboardState.SHOW; import android.content.Context; import android.graphics.Rect; import android.text.TextUtils; import android.util.AttributeSet; import android.view.DragEvent; Loading @@ -27,12 +28,17 @@ import android.widget.EditText; import com.android.launcher3.views.ActivityContext; import java.util.HashSet; import java.util.Set; /** * The edit text that reports back when the back key has been pressed. * Note: AppCompatEditText doesn't fully support #displayCompletions and #onCommitCompletion */ public class ExtendedEditText extends EditText { private final Set<OnFocusChangeListener> mOnFocusChangeListeners = new HashSet<>(); private boolean mForceDisableSuggestions = false; /** Loading Loading @@ -129,4 +135,28 @@ public class ExtendedEditText extends EditText { setText(""); } } /** * This method should be preferred to {@link #setOnFocusChangeListener(OnFocusChangeListener)}, * as it allows for multiple listeners from different sources. */ public void addOnFocusChangeListener(OnFocusChangeListener listener) { mOnFocusChangeListeners.add(listener); } /** * Removes the given listener from the set of registered focus listeners, or does nothing if it * wasn't registered in the first place. */ public void removeOnFocusChangeListener(OnFocusChangeListener listener) { mOnFocusChangeListeners.remove(listener); } @Override protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { super.onFocusChanged(focused, direction, previouslyFocusedRect); for (OnFocusChangeListener listener : mOnFocusChangeListeners) { listener.onFocusChange(this, focused); } } } src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java +2 −1 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ public class AllAppsSearchBarController mInput.addTextChangedListener(this); mInput.setOnEditorActionListener(this); mInput.setOnBackKeyListener(this); mInput.setOnFocusChangeListener(this); mInput.addOnFocusChangeListener(this); mSearchAlgorithm = searchAlgorithm; } Loading Loading @@ -153,6 +153,7 @@ public class AllAppsSearchBarController mCallback.clearSearchResult(); mInput.reset(); mQuery = null; mInput.removeOnFocusChangeListener(this); } /** Loading src/com/android/launcher3/folder/Folder.java +7 −1 Original line number Diff line number Diff line Loading @@ -282,7 +282,6 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo mFolderName = findViewById(R.id.folder_name); mFolderName.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp.folderLabelTextSizePx); mFolderName.setOnBackKeyListener(this); mFolderName.setOnFocusChangeListener(this); mFolderName.setOnEditorActionListener(this); mFolderName.setSelectAllOnFocus(true); mFolderName.setInputType(mFolderName.getInputType() Loading Loading @@ -457,6 +456,13 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo // the folder itself. requestFocus(); super.onAttachedToWindow(); mFolderName.addOnFocusChangeListener(this); } @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); mFolderName.removeOnFocusChangeListener(this); } @Override Loading Loading
src/com/android/launcher3/ExtendedEditText.java +30 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.launcher3; import static com.android.launcher3.logging.KeyboardStateManager.KeyboardState.SHOW; import android.content.Context; import android.graphics.Rect; import android.text.TextUtils; import android.util.AttributeSet; import android.view.DragEvent; Loading @@ -27,12 +28,17 @@ import android.widget.EditText; import com.android.launcher3.views.ActivityContext; import java.util.HashSet; import java.util.Set; /** * The edit text that reports back when the back key has been pressed. * Note: AppCompatEditText doesn't fully support #displayCompletions and #onCommitCompletion */ public class ExtendedEditText extends EditText { private final Set<OnFocusChangeListener> mOnFocusChangeListeners = new HashSet<>(); private boolean mForceDisableSuggestions = false; /** Loading Loading @@ -129,4 +135,28 @@ public class ExtendedEditText extends EditText { setText(""); } } /** * This method should be preferred to {@link #setOnFocusChangeListener(OnFocusChangeListener)}, * as it allows for multiple listeners from different sources. */ public void addOnFocusChangeListener(OnFocusChangeListener listener) { mOnFocusChangeListeners.add(listener); } /** * Removes the given listener from the set of registered focus listeners, or does nothing if it * wasn't registered in the first place. */ public void removeOnFocusChangeListener(OnFocusChangeListener listener) { mOnFocusChangeListeners.remove(listener); } @Override protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { super.onFocusChanged(focused, direction, previouslyFocusedRect); for (OnFocusChangeListener listener : mOnFocusChangeListeners) { listener.onFocusChange(this, focused); } } }
src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java +2 −1 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ public class AllAppsSearchBarController mInput.addTextChangedListener(this); mInput.setOnEditorActionListener(this); mInput.setOnBackKeyListener(this); mInput.setOnFocusChangeListener(this); mInput.addOnFocusChangeListener(this); mSearchAlgorithm = searchAlgorithm; } Loading Loading @@ -153,6 +153,7 @@ public class AllAppsSearchBarController mCallback.clearSearchResult(); mInput.reset(); mQuery = null; mInput.removeOnFocusChangeListener(this); } /** Loading
src/com/android/launcher3/folder/Folder.java +7 −1 Original line number Diff line number Diff line Loading @@ -282,7 +282,6 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo mFolderName = findViewById(R.id.folder_name); mFolderName.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp.folderLabelTextSizePx); mFolderName.setOnBackKeyListener(this); mFolderName.setOnFocusChangeListener(this); mFolderName.setOnEditorActionListener(this); mFolderName.setSelectAllOnFocus(true); mFolderName.setInputType(mFolderName.getInputType() Loading Loading @@ -457,6 +456,13 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo // the folder itself. requestFocus(); super.onAttachedToWindow(); mFolderName.addOnFocusChangeListener(this); } @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); mFolderName.removeOnFocusChangeListener(this); } @Override Loading