Loading core/java/android/app/SearchDialog.java +9 −1 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ public class SearchDialog extends Dialog { private View mSearchPlate; private SearchView mSearchView; private Drawable mWorkingSpinner; private View mCloseSearch; // interaction with searchable application private SearchableInfo mSearchable; Loading Loading @@ -167,11 +168,18 @@ public class SearchDialog extends Dialog { SearchBar searchBar = (SearchBar) findViewById(com.android.internal.R.id.search_bar); searchBar.setSearchDialog(this); mSearchView = (SearchView) findViewById(com.android.internal.R.id.search_view); mSearchView.setSubmitButtonEnabled(true); mSearchView.setOnCloseListener(mOnCloseListener); mSearchView.setOnQueryTextListener(mOnQueryChangeListener); mSearchView.setOnSuggestionListener(mOnSuggestionSelectionListener); mCloseSearch = findViewById(com.android.internal.R.id.closeButton); mCloseSearch.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); // TODO: Move the badge logic to SearchView or move the badge to search_bar.xml mBadgeLabel = (TextView) mSearchView.findViewById(com.android.internal.R.id.search_badge); mSearchAutoComplete = (AutoCompleteTextView) Loading core/java/android/widget/SearchView.java +12 −7 Original line number Diff line number Diff line Loading @@ -603,7 +603,7 @@ public class SearchView extends LinearLayout { final boolean hasText = !TextUtils.isEmpty(mQueryTextView.getText()); // Should we show the close button? It is not shown if there's no focus, // field is not iconified by default and there is no text in it. final boolean showClose = hasText || mIconifiedByDefault || mQueryTextView.hasFocus(); final boolean showClose = hasText || mIconifiedByDefault; mCloseButton.setVisibility(showClose ? VISIBLE : INVISIBLE); mCloseButton.getDrawable().setState(hasText ? ENABLED_STATE_SET : EMPTY_STATE_SET); } Loading Loading @@ -919,17 +919,22 @@ public class SearchView extends LinearLayout { } private void onCloseClicked() { if (mOnCloseListener == null || !mOnCloseListener.onClose()) { CharSequence text = mQueryTextView.getText(); if (TextUtils.isEmpty(text)) { if (mIconifiedByDefault) { // query field already empty, hide the keyboard and remove focus clearFocus(); setImeVisibility(false); } } else { mQueryTextView.setText(""); mQueryTextView.requestFocus(); setImeVisibility(true); } if (mIconifiedByDefault && (mOnCloseListener == null || !mOnCloseListener.onClose())) { updateViewsVisibility(mIconifiedByDefault); if (mIconifiedByDefault) setImeVisibility(false); setImeVisibility(false); } } Loading core/res/res/drawable-hdpi/title_bar_shadow.9.png 0 → 100644 +198 B Loading image diff... core/res/res/drawable-mdpi/title_bar_shadow.9.png 0 → 100644 +173 B Loading image diff... core/res/res/layout/search_bar.xml +41 −19 Original line number Diff line number Diff line Loading @@ -23,36 +23,58 @@ android:id="@+id/search_bar" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:orientation="vertical" android:background="@color/transparent" android:focusable="true" android:background="?android:attr/actionModeBackground" android:descendantFocusability="afterDescendants"> <RelativeLayout <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:attr/actionModeBackground" android:orientation="horizontal"> <!-- Grouped to allow tapping on either item to exit search mode --> <LinearLayout android:id="@id/closeButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:focusable="true" android:background="?android:attr/selectableItemBackground"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" > android:src="?android:attr/homeAsUpIndicator"/> <ImageView android:id="@+id/search_app_icon" android:layout_height="48dip" android:layout_width="48dip" android:layout_marginLeft="8dip" android:layout_marginRight="8dip" android:layout_gravity="center_vertical" android:layout_alignParentLeft="true" /> </LinearLayout> <!-- Actual search view with search icon, text field, close and voice buttons --> <SearchView android:id="@+id/search_view" android:layout_width="match_parent" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:maxWidth="600dip" android:iconifiedByDefault="false" android:layout_alignParentRight="true" android:layout_gravity="center_vertical|right" android:layout_gravity="center_vertical" /> </RelativeLayout> </LinearLayout> <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:scaleType="fitXY" android:src="@drawable/title_bar_shadow"/> </view> Loading
core/java/android/app/SearchDialog.java +9 −1 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ public class SearchDialog extends Dialog { private View mSearchPlate; private SearchView mSearchView; private Drawable mWorkingSpinner; private View mCloseSearch; // interaction with searchable application private SearchableInfo mSearchable; Loading Loading @@ -167,11 +168,18 @@ public class SearchDialog extends Dialog { SearchBar searchBar = (SearchBar) findViewById(com.android.internal.R.id.search_bar); searchBar.setSearchDialog(this); mSearchView = (SearchView) findViewById(com.android.internal.R.id.search_view); mSearchView.setSubmitButtonEnabled(true); mSearchView.setOnCloseListener(mOnCloseListener); mSearchView.setOnQueryTextListener(mOnQueryChangeListener); mSearchView.setOnSuggestionListener(mOnSuggestionSelectionListener); mCloseSearch = findViewById(com.android.internal.R.id.closeButton); mCloseSearch.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); // TODO: Move the badge logic to SearchView or move the badge to search_bar.xml mBadgeLabel = (TextView) mSearchView.findViewById(com.android.internal.R.id.search_badge); mSearchAutoComplete = (AutoCompleteTextView) Loading
core/java/android/widget/SearchView.java +12 −7 Original line number Diff line number Diff line Loading @@ -603,7 +603,7 @@ public class SearchView extends LinearLayout { final boolean hasText = !TextUtils.isEmpty(mQueryTextView.getText()); // Should we show the close button? It is not shown if there's no focus, // field is not iconified by default and there is no text in it. final boolean showClose = hasText || mIconifiedByDefault || mQueryTextView.hasFocus(); final boolean showClose = hasText || mIconifiedByDefault; mCloseButton.setVisibility(showClose ? VISIBLE : INVISIBLE); mCloseButton.getDrawable().setState(hasText ? ENABLED_STATE_SET : EMPTY_STATE_SET); } Loading Loading @@ -919,17 +919,22 @@ public class SearchView extends LinearLayout { } private void onCloseClicked() { if (mOnCloseListener == null || !mOnCloseListener.onClose()) { CharSequence text = mQueryTextView.getText(); if (TextUtils.isEmpty(text)) { if (mIconifiedByDefault) { // query field already empty, hide the keyboard and remove focus clearFocus(); setImeVisibility(false); } } else { mQueryTextView.setText(""); mQueryTextView.requestFocus(); setImeVisibility(true); } if (mIconifiedByDefault && (mOnCloseListener == null || !mOnCloseListener.onClose())) { updateViewsVisibility(mIconifiedByDefault); if (mIconifiedByDefault) setImeVisibility(false); setImeVisibility(false); } } Loading
core/res/res/layout/search_bar.xml +41 −19 Original line number Diff line number Diff line Loading @@ -23,36 +23,58 @@ android:id="@+id/search_bar" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:orientation="vertical" android:background="@color/transparent" android:focusable="true" android:background="?android:attr/actionModeBackground" android:descendantFocusability="afterDescendants"> <RelativeLayout <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:attr/actionModeBackground" android:orientation="horizontal"> <!-- Grouped to allow tapping on either item to exit search mode --> <LinearLayout android:id="@id/closeButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:focusable="true" android:background="?android:attr/selectableItemBackground"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" > android:src="?android:attr/homeAsUpIndicator"/> <ImageView android:id="@+id/search_app_icon" android:layout_height="48dip" android:layout_width="48dip" android:layout_marginLeft="8dip" android:layout_marginRight="8dip" android:layout_gravity="center_vertical" android:layout_alignParentLeft="true" /> </LinearLayout> <!-- Actual search view with search icon, text field, close and voice buttons --> <SearchView android:id="@+id/search_view" android:layout_width="match_parent" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:maxWidth="600dip" android:iconifiedByDefault="false" android:layout_alignParentRight="true" android:layout_gravity="center_vertical|right" android:layout_gravity="center_vertical" /> </RelativeLayout> </LinearLayout> <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:scaleType="fitXY" android:src="@drawable/title_bar_shadow"/> </view>