aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Horimoto <khorimoto@gmail.com>2015-10-13 16:28:49 -0700
committerKyle Horimoto <khorimoto@gmail.com>2015-10-14 11:07:35 -0700
commit6aa5db832c4459ffffc76dfc4aa8da2838a12338 (patch)
treec7e006bc8b319cb455aee43dfcc542b8fcf50341
parent2e72e617be8964240961d6faa7af50d39f70622f (diff)
downloadconnectbot-6aa5db832c4459ffffc76dfc4aa8da2838a12338.tar.gz
connectbot-6aa5db832c4459ffffc76dfc4aa8da2838a12338.tar.bz2
connectbot-6aa5db832c4459ffffc76dfc4aa8da2838a12338.zip
Change menu icons.
-rw-r--r--app/src/main/java/org/connectbot/PubkeyListActivity.java66
-rw-r--r--app/src/main/res/values/strings.xml4
2 files changed, 38 insertions, 32 deletions
diff --git a/app/src/main/java/org/connectbot/PubkeyListActivity.java b/app/src/main/java/org/connectbot/PubkeyListActivity.java
index 9f8521f..661f9de 100644
--- a/app/src/main/java/org/connectbot/PubkeyListActivity.java
+++ b/app/src/main/java/org/connectbot/PubkeyListActivity.java
@@ -61,6 +61,7 @@ import android.util.Log;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.Menu;
+import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MenuItem.OnMenuItemClickListener;
import android.view.View;
@@ -169,47 +170,48 @@ public class PubkeyListActivity extends AppCompatListActivity implements EventLi
}
+
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- super.onCreateOptionsMenu(menu);
-
- MenuItem generatekey = menu.add(R.string.pubkey_generate);
- generatekey.setIcon(android.R.drawable.ic_menu_manage);
- generatekey.setIntent(new Intent(PubkeyListActivity.this, GeneratePubkeyActivity.class));
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.pubkey_list_activity_menu, menu);
+ return super.onCreateOptionsMenu(menu);
+ }
- MenuItem importkey = menu.add(R.string.pubkey_import);
- importkey.setIcon(android.R.drawable.ic_menu_upload);
- importkey.setOnMenuItemClickListener(new OnMenuItemClickListener() {
- public boolean onMenuItemClick(MenuItem item) {
- Uri sdcard = Uri.fromFile(Environment.getExternalStorageDirectory());
- String pickerTitle = getString(R.string.pubkey_list_pick);
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.add_new_key_icon:
+ startActivity(new Intent(this, GeneratePubkeyActivity.class));
+ return true;
+ case R.id.import_existing_key_icon:
+ Uri sdcard = Uri.fromFile(Environment.getExternalStorageDirectory());
+ String pickerTitle = getString(R.string.pubkey_list_pick);
+
+ // Try to use OpenIntent's file browser to pick a file
+ Intent intent = new Intent(FileManagerIntents.ACTION_PICK_FILE);
+ intent.setData(sdcard);
+ intent.putExtra(FileManagerIntents.EXTRA_TITLE, pickerTitle);
+ intent.putExtra(FileManagerIntents.EXTRA_BUTTON_TEXT, getString(android.R.string.ok));
- // Try to use OpenIntent's file browser to pick a file
- Intent intent = new Intent(FileManagerIntents.ACTION_PICK_FILE);
- intent.setData(sdcard);
- intent.putExtra(FileManagerIntents.EXTRA_TITLE, pickerTitle);
- intent.putExtra(FileManagerIntents.EXTRA_BUTTON_TEXT, getString(android.R.string.ok));
+ try {
+ startActivityForResult(intent, REQUEST_CODE_PICK_FILE);
+ } catch (ActivityNotFoundException e) {
+ // If OI didn't work, try AndExplorer
+ intent = new Intent(Intent.ACTION_PICK);
+ intent.setDataAndType(sdcard, MIME_TYPE_ANDEXPLORER_FILE);
+ intent.putExtra(ANDEXPLORER_TITLE, pickerTitle);
try {
startActivityForResult(intent, REQUEST_CODE_PICK_FILE);
- } catch (ActivityNotFoundException e) {
- // If OI didn't work, try AndExplorer
- intent = new Intent(Intent.ACTION_PICK);
- intent.setDataAndType(sdcard, MIME_TYPE_ANDEXPLORER_FILE);
- intent.putExtra(ANDEXPLORER_TITLE, pickerTitle);
-
- try {
- startActivityForResult(intent, REQUEST_CODE_PICK_FILE);
- } catch (ActivityNotFoundException e1) {
- pickFileSimple();
- }
+ } catch (ActivityNotFoundException e1) {
+ pickFileSimple();
}
-
- return true;
}
- });
-
- return true;
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
}
protected void handleAddKey(final PubkeyBean pubkey) {
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index b92cc28..219249c 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -652,5 +652,9 @@
<string name="hostpref_add_host">Add host</string>
<!-- Text for button which, when clicked, saves an existing host. -->
<string name="hostpref_edit_host">Save host</string>
+ <!-- Text for button which, when clicked, brings up an editor for adding a new pubkey. -->
+ <string name="pubkey_add_new">Add new pubkey</string>
+ <!-- Text for button which, when clicked, brings up picker to import an existing pubkey. -->
+ <string name="pubkey_import_existing">Import existing pubkey</string>
</resources>