Skip to content

Commit

Permalink
Slightly de-clutter the search UI.
Browse files Browse the repository at this point in the history
Remove the custom search button that appeared after the EditText control,
and its drawable.

Configure the EditText as a search control, and perform the search when
the user presses the search button on the IME.
  • Loading branch information
nikclayton committed May 27, 2012
1 parent 62f0b5e commit acbe1c5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 33 deletions.
Binary file removed res/drawable-hdpi/ic_btn_search.png
Binary file not shown.
Binary file removed res/drawable-mdpi/ic_btn_search.png
Binary file not shown.
20 changes: 8 additions & 12 deletions res/layout/search_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,14 @@
android:layout_height="wrap_content"
android:orientation="horizontal">

<EditText
android:id="@+id/search_input"
android:hint="@+string/search_hint_text"
android:inputType="textNoSuggestions"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<ImageButton
android:id="@+id/search_button"
android:src="@drawable/ic_btn_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/search_input"
android:hint="@+string/search_hint_text"
android:imeOptions="actionSearch"
android:inputType="textNoSuggestions"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<ExpandableListView
android:id="@+id/search_expandable_list"
Expand Down
31 changes: 10 additions & 21 deletions src/uk/org/ngo/squeezer/SqueezerSearchActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnCreateContextMenuListener;
import android.view.View.OnKeyListener;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.ImageButton;
import android.widget.TextView;

public class SqueezerSearchActivity extends SqueezerItemListActivity {
Expand All @@ -61,31 +59,22 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.search_layout);

ImageButton searchButton = (ImageButton) findViewById(R.id.search_button);
loadingLabel = (TextView) findViewById(R.id.loading_label);
final EditText searchCriteriaText = (EditText) findViewById(R.id.search_input);

searchResultsAdapter = new SqueezerSearchAdapter(this);
resultsExpandableListView = (ExpandableListView) findViewById(R.id.search_expandable_list);
resultsExpandableListView.setAdapter( searchResultsAdapter );

searchCriteriaText.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
doSearch(searchCriteriaText.getText().toString());
return true;
}
return false;
}
});

searchButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (getService() != null) {
doSearch(searchCriteriaText.getText().toString());
}
}
});
searchCriteriaText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
doSearch(searchCriteriaText.getText().toString());
return true;
}
return false;
}
});

resultsExpandableListView.setOnChildClickListener( new OnChildClickListener() {
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
Expand Down

0 comments on commit acbe1c5

Please sign in to comment.