added search to option menu and make it pop up when keys on the physical keyboard are pressed

This commit is contained in:
Thialfihar 2010-06-05 22:44:47 +00:00
parent 84d00abea1
commit 8c404d83d7
12 changed files with 41 additions and 4 deletions

View File

@ -79,6 +79,7 @@
<string name="menu_deleteKey">Delete Key</string> <string name="menu_deleteKey">Delete Key</string>
<string name="menu_createKey">Create Key</string> <string name="menu_createKey">Create Key</string>
<string name="menu_editKey">Edit Key</string> <string name="menu_editKey">Edit Key</string>
<string name="menu_search">Search</string>
<!-- label_lowerCase: capitalized words, no punctuation --> <!-- label_lowerCase: capitalized words, no punctuation -->
<string name="label_sign">Sign</string> <string name="label_sign">Sign</string>

View File

@ -79,6 +79,7 @@
<string name="menu_deleteKey">Delete Key</string> <string name="menu_deleteKey">Delete Key</string>
<string name="menu_createKey">Create Key</string> <string name="menu_createKey">Create Key</string>
<string name="menu_editKey">Edit Key</string> <string name="menu_editKey">Edit Key</string>
<string name="menu_search">Search</string>
<!-- label_lowerCase: capitalized words, no punctuation --> <!-- label_lowerCase: capitalized words, no punctuation -->
<string name="label_sign">Sign</string> <string name="label_sign">Sign</string>

View File

@ -79,6 +79,7 @@
<string name="menu_deleteKey">Delete Key</string> <string name="menu_deleteKey">Delete Key</string>
<string name="menu_createKey">Create Key</string> <string name="menu_createKey">Create Key</string>
<string name="menu_editKey">Edit Key</string> <string name="menu_editKey">Edit Key</string>
<string name="menu_search">Search</string>
<!-- label_lowerCase: capitalized words, no punctuation --> <!-- label_lowerCase: capitalized words, no punctuation -->
<string name="label_sign">Sign</string> <string name="label_sign">Sign</string>

View File

@ -79,6 +79,7 @@
<string name="menu_deleteKey">Izbriši ključ</string> <string name="menu_deleteKey">Izbriši ključ</string>
<string name="menu_createKey">Ustvari ključ</string> <string name="menu_createKey">Ustvari ključ</string>
<string name="menu_editKey">Uredi ključ</string> <string name="menu_editKey">Uredi ključ</string>
<string name="menu_search">Search</string>
<!-- label_lowerCase: capitalized words, no punctuation --> <!-- label_lowerCase: capitalized words, no punctuation -->
<string name="label_sign">Podpiši</string> <string name="label_sign">Podpiši</string>

View File

@ -79,6 +79,7 @@
<string name="menu_deleteKey">Delete Key</string> <string name="menu_deleteKey">Delete Key</string>
<string name="menu_createKey">Create Key</string> <string name="menu_createKey">Create Key</string>
<string name="menu_editKey">Edit Key</string> <string name="menu_editKey">Edit Key</string>
<string name="menu_search">Search</string>
<!-- label_lowerCase: capitalized words, no punctuation --> <!-- label_lowerCase: capitalized words, no punctuation -->
<string name="label_sign">Sign</string> <string name="label_sign">Sign</string>

View File

@ -103,6 +103,11 @@ public class BaseActivity extends Activity
return true; return true;
} }
case Id.menu.option.search: {
startSearch("", false, null, false);
return true;
}
default: { default: {
break; break;
} }

View File

@ -33,6 +33,7 @@ public final class Id {
public static final int import_keys = 0x21070006; public static final int import_keys = 0x21070006;
public static final int export_keys = 0x21070007; public static final int export_keys = 0x21070007;
public static final int preferences = 0x21070008; public static final int preferences = 0x21070008;
public static final int search = 0x21070009;
} }
} }

View File

@ -72,6 +72,8 @@ public class KeyListActivity extends BaseActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.key_list); setContentView(R.layout.key_list);
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
mList = (ExpandableListView) findViewById(R.id.list); mList = (ExpandableListView) findViewById(R.id.list);
registerForContextMenu(mList); registerForContextMenu(mList);

View File

@ -37,9 +37,11 @@ public class PublicKeyListActivity extends KeyListActivity {
.setIcon(android.R.drawable.ic_menu_add); .setIcon(android.R.drawable.ic_menu_add);
menu.add(0, Id.menu.option.export_keys, 1, R.string.menu_exportKeys) menu.add(0, Id.menu.option.export_keys, 1, R.string.menu_exportKeys)
.setIcon(android.R.drawable.ic_menu_save); .setIcon(android.R.drawable.ic_menu_save);
menu.add(1, Id.menu.option.preferences, 2, R.string.menu_preferences) menu.add(1, Id.menu.option.search, 2, R.string.menu_search)
.setIcon(android.R.drawable.ic_menu_search);
menu.add(1, Id.menu.option.preferences, 3, R.string.menu_preferences)
.setIcon(android.R.drawable.ic_menu_preferences); .setIcon(android.R.drawable.ic_menu_preferences);
menu.add(1, Id.menu.option.about, 3, R.string.menu_about) menu.add(1, Id.menu.option.about, 4, R.string.menu_about)
.setIcon(android.R.drawable.ic_menu_info_details); .setIcon(android.R.drawable.ic_menu_info_details);
return true; return true;
} }

View File

@ -45,9 +45,11 @@ public class SecretKeyListActivity extends KeyListActivity implements OnChildCli
.setIcon(android.R.drawable.ic_menu_save); .setIcon(android.R.drawable.ic_menu_save);
menu.add(1, Id.menu.option.create, 2, R.string.menu_createKey) menu.add(1, Id.menu.option.create, 2, R.string.menu_createKey)
.setIcon(android.R.drawable.ic_menu_add); .setIcon(android.R.drawable.ic_menu_add);
menu.add(2, Id.menu.option.preferences, 3, R.string.menu_preferences) menu.add(3, Id.menu.option.search, 3, R.string.menu_search)
.setIcon(android.R.drawable.ic_menu_search);
menu.add(3, Id.menu.option.preferences, 4, R.string.menu_preferences)
.setIcon(android.R.drawable.ic_menu_preferences); .setIcon(android.R.drawable.ic_menu_preferences);
menu.add(2, Id.menu.option.about, 4, R.string.menu_about) menu.add(3, Id.menu.option.about, 5, R.string.menu_about)
.setIcon(android.R.drawable.ic_menu_info_details); .setIcon(android.R.drawable.ic_menu_info_details);
return true; return true;
} }

View File

@ -21,6 +21,7 @@ import java.util.Vector;
import android.app.SearchManager; import android.app.SearchManager;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.widget.Button; import android.widget.Button;
@ -39,6 +40,8 @@ public class SelectPublicKeyListActivity extends BaseActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.select_public_key); setContentView(R.layout.select_public_key);
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
mList = (ListView) findViewById(R.id.list); mList = (ListView) findViewById(R.id.list);
// needed in Android 1.5, where the XML attribute gets ignored // needed in Android 1.5, where the XML attribute gets ignored
mList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); mList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
@ -154,4 +157,11 @@ public class SelectPublicKeyListActivity extends BaseActivity {
setResult(RESULT_OK, data); setResult(RESULT_OK, data);
finish(); finish();
} }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, Id.menu.option.search, 0, R.string.menu_search)
.setIcon(android.R.drawable.ic_menu_search);
return true;
}
} }

View File

@ -19,6 +19,7 @@ package org.thialfihar.android.apg;
import android.app.SearchManager; import android.app.SearchManager;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.widget.AdapterView; import android.widget.AdapterView;
@ -40,6 +41,8 @@ public class SelectSecretKeyListActivity extends BaseActivity {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
setContentView(R.layout.select_secret_key); setContentView(R.layout.select_secret_key);
mList = (ListView) findViewById(R.id.list); mList = (ListView) findViewById(R.id.list);
@ -97,4 +100,11 @@ public class SelectSecretKeyListActivity extends BaseActivity {
mListAdapter = new SelectSecretKeyListAdapter(this, mList, searchString); mListAdapter = new SelectSecretKeyListAdapter(this, mList, searchString);
mList.setAdapter(mListAdapter); mList.setAdapter(mListAdapter);
} }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, Id.menu.option.search, 0, R.string.menu_search)
.setIcon(android.R.drawable.ic_menu_search);
return true;
}
} }