implement basic search dialog for compat mode

This commit is contained in:
Andrew Dolgov 2012-01-19 13:29:38 +03:00
parent a504dde3af
commit 3620e5187b
2 changed files with 46 additions and 4 deletions

View File

@ -116,4 +116,5 @@
<string name="notify_downloading_images">Downloading images (%1$d)...</string> <string name="notify_downloading_images">Downloading images (%1$d)...</string>
<string name="article_set_labels">Set labels</string> <string name="article_set_labels">Set labels</string>
<string name="search">Search</string> <string name="search">Search</string>
<string name="cancel">Cancel</string>
</resources> </resources>

View File

@ -43,6 +43,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.animation.AnimationUtils; import android.view.animation.AnimationUtils;
import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.SearchView; import android.widget.SearchView;
import android.widget.TextView; import android.widget.TextView;
@ -852,6 +853,44 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
switch (item.getItemId()) { switch (item.getItemId()) {
case android.R.id.home: case android.R.id.home:
goBack(false); goBack(false);
return true;
case R.id.search:
if (hf != null && m_compatMode) {
Dialog dialog = new Dialog(this);
final EditText edit = new EditText(this);
AlertDialog.Builder builder = new AlertDialog.Builder(this)
.setTitle(R.string.search)
.setPositiveButton(getString(R.string.search),
new OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
String query = edit.getText().toString().trim();
hf.setSearchQuery(query);
}
})
.setNegativeButton(getString(R.string.cancel),
new OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
//
}
}).setView(edit);
dialog = builder.create();
dialog.show();
}
return true; return true;
case R.id.preferences: case R.id.preferences:
Intent intent = new Intent(MainActivity.this, Intent intent = new Intent(MainActivity.this,
@ -1465,12 +1504,14 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
if (!append) { if (!append) {
if (m_menu != null) {
MenuItem search = m_menu.findItem(R.id.search); MenuItem search = m_menu.findItem(R.id.search);
if (search != null && !m_compatMode) { if (search != null && !m_compatMode) {
SearchView sv = (SearchView) search.getActionView(); SearchView sv = (SearchView) search.getActionView();
sv.setQuery("", false); sv.setQuery("", false);
} }
}
HeadlinesFragment hf = new HeadlinesFragment(); HeadlinesFragment hf = new HeadlinesFragment();