diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2016-07-21 10:42:30 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2016-07-22 13:17:30 -0700 |
commit | ce3fffb5fb446e031e52ee0c5f2a4a5cf86a8c81 (patch) | |
tree | 7f95627d9e96e445b5dc9f03d6ed2a02eca408f3 /src/com/android/launcher3/allapps/AllAppsContainerView.java | |
parent | 58368b15152052fb479891f0d3aba30ab3794fba (diff) | |
download | android_packages_apps_Trebuchet-ce3fffb5fb446e031e52ee0c5f2a4a5cf86a8c81.tar.gz android_packages_apps_Trebuchet-ce3fffb5fb446e031e52ee0c5f2a4a5cf86a8c81.tar.bz2 android_packages_apps_Trebuchet-ce3fffb5fb446e031e52ee0c5f2a4a5cf86a8c81.zip |
Updating the search hint to contain the icon as a span object.
This makes the icon part of the hint text, and removes any need for
custom focus event handling.
Also the icon will now appear at the start of the text based on the
direction of the text and not the direction of the layout
Change-Id: I06c5cf99492d75b1005c69ec7c521cde0fdab010
Diffstat (limited to 'src/com/android/launcher3/allapps/AllAppsContainerView.java')
-rw-r--r-- | src/com/android/launcher3/allapps/AllAppsContainerView.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index 3ef510c3f..8b1f95087 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -22,6 +22,8 @@ import android.graphics.Point; import android.graphics.Rect; import android.support.v7.widget.RecyclerView; import android.text.Selection; +import android.text.Spannable; +import android.text.SpannableString; import android.text.SpannableStringBuilder; import android.text.method.TextKeyListener; import android.util.AttributeSet; @@ -47,6 +49,7 @@ import com.android.launcher3.Utilities; import com.android.launcher3.Workspace; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.folder.Folder; +import com.android.launcher3.graphics.TintedDrawableSpan; import com.android.launcher3.keyboard.FocusedItemDecorator; import com.android.launcher3.util.ComponentKey; @@ -240,7 +243,6 @@ 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); } @@ -308,6 +310,16 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc mSearchContainer = findViewById(R.id.search_container); mSearchInput = (ExtendedEditText) findViewById(R.id.search_box_input); + + // Update the hint to contain the icon. + // Prefix the original hint with two spaces. The first space gets replaced by the icon + // using span. The second space is used for a singe space character between the hint + // and the icon. + SpannableString spanned = new SpannableString(" " + mSearchInput.getHint()); + spanned.setSpan(new TintedDrawableSpan(getContext(), R.drawable.ic_allapps_search), + 0, 1, Spannable.SPAN_EXCLUSIVE_INCLUSIVE); + mSearchInput.setHint(spanned); + mSearchContainerOffsetTop = getResources().getDimensionPixelSize( R.dimen.all_apps_search_bar_margin_top); |