diff options
author | Winson <winsonc@google.com> | 2015-08-13 15:18:25 -0700 |
---|---|---|
committer | Winson <winsonc@google.com> | 2015-08-13 15:58:51 -0700 |
commit | 97b0d08d92c64034ba03ae8da5a8531edbd60d52 (patch) | |
tree | 3681551a6c638cc7707b5bfa0a9d9b0f65ea7a89 /src/com/android/launcher3/allapps | |
parent | 81056da1def5d872d26b6f8a4e4163f9d94871a3 (diff) | |
download | android_packages_apps_Trebuchet-97b0d08d92c64034ba03ae8da5a8531edbd60d52.tar.gz android_packages_apps_Trebuchet-97b0d08d92c64034ba03ae8da5a8531edbd60d52.tar.bz2 android_packages_apps_Trebuchet-97b0d08d92c64034ba03ae8da5a8531edbd60d52.zip |
Refactoring to ExtendedEditText.
Diffstat (limited to 'src/com/android/launcher3/allapps')
-rw-r--r-- | src/com/android/launcher3/allapps/AllAppsSearchEditView.java | 65 | ||||
-rw-r--r-- | src/com/android/launcher3/allapps/DefaultAppSearchController.java | 12 |
2 files changed, 8 insertions, 69 deletions
diff --git a/src/com/android/launcher3/allapps/AllAppsSearchEditView.java b/src/com/android/launcher3/allapps/AllAppsSearchEditView.java deleted file mode 100644 index b7dcd66ed..000000000 --- a/src/com/android/launcher3/allapps/AllAppsSearchEditView.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2015 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. - */ -package com.android.launcher3.allapps; - -import android.content.Context; -import android.util.AttributeSet; -import android.view.KeyEvent; -import android.widget.EditText; - - -/** - * The edit text for the search container - */ -public class AllAppsSearchEditView extends EditText { - - /** - * Implemented by listeners of the back key. - */ - public interface OnBackKeyListener { - public void onBackKey(); - } - - private OnBackKeyListener mBackKeyListener; - - public AllAppsSearchEditView(Context context) { - this(context, null); - } - - public AllAppsSearchEditView(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - public AllAppsSearchEditView(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - } - - public void setOnBackKeyListener(OnBackKeyListener listener) { - mBackKeyListener = listener; - } - - @Override - public boolean onKeyPreIme(int keyCode, KeyEvent event) { - // If this is a back key, propagate the key back to the listener - if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) { - if (mBackKeyListener != null) { - mBackKeyListener.onBackKey(); - } - return false; - } - return super.onKeyPreIme(keyCode, event); - } -} diff --git a/src/com/android/launcher3/allapps/DefaultAppSearchController.java b/src/com/android/launcher3/allapps/DefaultAppSearchController.java index e1a2b7fda..3169f842a 100644 --- a/src/com/android/launcher3/allapps/DefaultAppSearchController.java +++ b/src/com/android/launcher3/allapps/DefaultAppSearchController.java @@ -25,6 +25,7 @@ import android.view.ViewGroup; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import android.widget.TextView; +import com.android.launcher3.ExtendedEditText; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.util.Thunk; @@ -54,7 +55,8 @@ final class DefaultAppSearchController extends AllAppsSearchBarController @Thunk View mSearchBarContainerView; private View mSearchButtonView; private View mDismissSearchButtonView; - @Thunk AllAppsSearchEditView mSearchBarEditView; + @Thunk + ExtendedEditText mSearchBarEditView; @Thunk AllAppsRecyclerView mAppsRecyclerView; @Thunk Runnable mFocusRecyclerViewRunnable = new Runnable() { @Override @@ -82,21 +84,23 @@ final class DefaultAppSearchController extends AllAppsSearchBarController mSearchBarContainerView = mSearchView.findViewById(R.id.search_container); mDismissSearchButtonView = mSearchBarContainerView.findViewById(R.id.dismiss_search_button); mDismissSearchButtonView.setOnClickListener(this); - mSearchBarEditView = (AllAppsSearchEditView) + mSearchBarEditView = (ExtendedEditText) mSearchBarContainerView.findViewById(R.id.search_box_input); mSearchBarEditView.addTextChangedListener(this); mSearchBarEditView.setOnEditorActionListener(this); mSearchBarEditView.setOnBackKeyListener( - new AllAppsSearchEditView.OnBackKeyListener() { + new ExtendedEditText.OnBackKeyListener() { @Override - public void onBackKey() { + public boolean onBackKey() { // Only hide the search field if there is no query, or if there // are no filtered results String query = Utilities.trim( mSearchBarEditView.getEditableText().toString()); if (query.isEmpty() || mApps.hasNoFilteredResults()) { hideSearchField(true, mFocusRecyclerViewRunnable); + return true; } + return false; } }); return mSearchView; |