aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/org/sufficientlysecure/keychain
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2013-09-06 14:42:48 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2013-09-06 14:42:48 +0200
commita0b0eeaf878cb039b3e3f3837a7cce0e96907b80 (patch)
tree9e73f9caa13756f535c63d7052d1de36b3b780dd /OpenPGP-Keychain/src/org/sufficientlysecure/keychain
parent9d30c1ea37a52955ca8fd0bf83121cc62f9d9e52 (diff)
downloadopen-keychain-a0b0eeaf878cb039b3e3f3837a7cce0e96907b80.tar.gz
open-keychain-a0b0eeaf878cb039b3e3f3837a7cce0e96907b80.tar.bz2
open-keychain-a0b0eeaf878cb039b3e3f3837a7cce0e96907b80.zip
Use ButtonBar instead of ActionBar on Done/Cancel activities
Diffstat (limited to 'OpenPGP-Keychain/src/org/sufficientlysecure/keychain')
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EditKeyActivity.java90
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java96
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/SelectPublicKeyActivity.java80
3 files changed, 121 insertions, 145 deletions
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EditKeyActivity.java
index d52496c04..63a4f1afb 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EditKeyActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EditKeyActivity.java
@@ -17,10 +17,15 @@
package org.sufficientlysecure.keychain.ui;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Vector;
+
import org.spongycastle.openpgp.PGPSecretKey;
import org.spongycastle.openpgp.PGPSecretKeyRing;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Id;
+import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.helper.OtherHelper;
import org.sufficientlysecure.keychain.helper.PgpConversionHelper;
import org.sufficientlysecure.keychain.helper.PgpHelper;
@@ -35,12 +40,6 @@ import org.sufficientlysecure.keychain.ui.widget.SectionView;
import org.sufficientlysecure.keychain.ui.widget.UserIdEditor;
import org.sufficientlysecure.keychain.util.IterableIterator;
import org.sufficientlysecure.keychain.util.Log;
-import org.sufficientlysecure.keychain.R;
-
-import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.app.SherlockFragmentActivity;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuItem;
import android.app.ProgressDialog;
import android.content.Context;
@@ -51,18 +50,18 @@ import android.os.Message;
import android.os.Messenger;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
import android.view.View.OnClickListener;
+import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
+import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.LinearLayout;
+import android.widget.TextView;
import android.widget.Toast;
-import android.widget.CompoundButton.OnCheckedChangeListener;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Vector;
+import com.actionbarsherlock.app.ActionBar;
+import com.actionbarsherlock.app.SherlockFragmentActivity;
public class EditKeyActivity extends SherlockFragmentActivity {
@@ -104,41 +103,6 @@ public class EditKeyActivity extends SherlockFragmentActivity {
private boolean mBuildLayout = true;
@Override
- public boolean onCreateOptionsMenu(Menu menu) {
- menu.add(1, Id.menu.option.cancel, 0, R.string.btn_doNotSave).setShowAsAction(
- MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
- menu.add(1, Id.menu.option.save, 1, R.string.btn_save).setShowAsAction(
- MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
-
- case android.R.id.home:
- // app icon in Action Bar clicked; go home
- Intent intent = new Intent(this, KeyListSecretActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivity(intent);
- return true;
-
- case Id.menu.option.save:
- saveClicked();
- return true;
-
- case Id.menu.option.cancel:
- cancelClicked();
- return true;
-
- default:
- break;
-
- }
- return false;
- }
-
- @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -148,6 +112,40 @@ public class EditKeyActivity extends SherlockFragmentActivity {
// OtherHelper.checkPackagePermissionForActions(this, this.getCallingPackage(),
// Constants.PERMISSION_ACCESS_API, getIntent().getAction(), restrictedActions);
+ // Inflate a "Done"/"Cancel" custom action bar view
+ final LayoutInflater inflater = (LayoutInflater) getSupportActionBar().getThemedContext()
+ .getSystemService(LAYOUT_INFLATER_SERVICE);
+ final View customActionBarView = inflater.inflate(
+ R.layout.actionbar_custom_view_done_cancel, null);
+
+ ((TextView) customActionBarView.findViewById(R.id.actionbar_done_text))
+ .setText(R.string.btn_save);
+ customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(
+ new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ // save
+ saveClicked();
+ }
+ });
+ ((TextView) customActionBarView.findViewById(R.id.actionbar_cancel_text))
+ .setText(R.string.btn_doNotSave);
+ customActionBarView.findViewById(R.id.actionbar_cancel).setOnClickListener(
+ new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ // cancel
+ cancelClicked();
+ }
+ });
+
+ // Show the custom action bar view and hide the normal Home icon and title.
+ final ActionBar actionBar = getSupportActionBar();
+ actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM
+ | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
+ actionBar.setCustomView(customActionBarView, new ActionBar.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
+
setContentView(R.layout.edit_key);
mActionBar = getSupportActionBar();
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java
index b86fe0a2e..bc2e358b6 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java
@@ -18,16 +18,10 @@ package org.sufficientlysecure.keychain.ui;
import java.util.Vector;
-import org.sufficientlysecure.keychain.Id;
+import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.ui.widget.Editor;
-import org.sufficientlysecure.keychain.ui.widget.KeyServerEditor;
import org.sufficientlysecure.keychain.ui.widget.Editor.EditorListener;
-import org.sufficientlysecure.keychain.R;
-
-import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.app.SherlockActivity;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuItem;
+import org.sufficientlysecure.keychain.ui.widget.KeyServerEditor;
import android.content.Context;
import android.content.Intent;
@@ -38,6 +32,9 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.TextView;
+import com.actionbarsherlock.app.ActionBar;
+import com.actionbarsherlock.app.SherlockActivity;
+
public class PreferencesKeyServerActivity extends SherlockActivity implements OnClickListener,
EditorListener {
@@ -50,59 +47,44 @@ public class PreferencesKeyServerActivity extends SherlockActivity implements On
private TextView mSummary;
@Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
-
- case android.R.id.home:
- // app icon in Action Bar clicked; go home
- Intent intent = new Intent(this, PreferencesActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivity(intent);
-
- return true;
-
- case Id.menu.option.okay:
- okClicked();
-
- return true;
-
- case Id.menu.option.cancel:
- cancelClicked();
-
- return true;
-
- default:
- break;
-
- }
- return false;
- }
-
- /**
- * ActionBar menu is created based on class variables to change it at runtime
- *
- */
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
-
- menu.add(1, Id.menu.option.cancel, 0, android.R.string.cancel).setShowAsAction(
- MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
-
- menu.add(1, Id.menu.option.okay, 1, android.R.string.ok).setShowAsAction(
- MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
-
- return true;
- }
-
- @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.key_server_preference);
+ // Inflate a "Done"/"Cancel" custom action bar view
+ final LayoutInflater inflater = (LayoutInflater) getSupportActionBar().getThemedContext()
+ .getSystemService(LAYOUT_INFLATER_SERVICE);
+ final View customActionBarView = inflater.inflate(
+ R.layout.actionbar_custom_view_done_cancel, null);
+
+ ((TextView) customActionBarView.findViewById(R.id.actionbar_done_text))
+ .setText(R.string.btn_okay);
+ customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(
+ new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ // ok
+ okClicked();
+ }
+ });
+ ((TextView) customActionBarView.findViewById(R.id.actionbar_cancel_text))
+ .setText(R.string.btn_doNotSave);
+ customActionBarView.findViewById(R.id.actionbar_cancel).setOnClickListener(
+ new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ // cancel
+ cancelClicked();
+ }
+ });
+
+ // Show the custom action bar view and hide the normal Home icon and title.
final ActionBar actionBar = getSupportActionBar();
- actionBar.setDisplayShowTitleEnabled(true);
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setHomeButtonEnabled(true);
+ actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM
+ | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
+ actionBar.setCustomView(customActionBarView, new ActionBar.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
+
+ setContentView(R.layout.key_server_preference);
mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/SelectPublicKeyActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/SelectPublicKeyActivity.java
index d209662f7..a98996c11 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/SelectPublicKeyActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/SelectPublicKeyActivity.java
@@ -28,6 +28,10 @@ import com.actionbarsherlock.view.MenuItem;
import android.content.Intent;
import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
public class SelectPublicKeyActivity extends SherlockFragmentActivity {
@@ -48,12 +52,41 @@ public class SelectPublicKeyActivity extends SherlockFragmentActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.select_public_key_activity);
-
+ // Inflate a "Done"/"Cancel" custom action bar view
+ final LayoutInflater inflater = (LayoutInflater) getSupportActionBar().getThemedContext()
+ .getSystemService(LAYOUT_INFLATER_SERVICE);
+ final View customActionBarView = inflater.inflate(
+ R.layout.actionbar_custom_view_done_cancel, null);
+
+ ((TextView) customActionBarView.findViewById(R.id.actionbar_done_text))
+ .setText(R.string.btn_okay);
+ customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(
+ new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ // ok
+ okClicked();
+ }
+ });
+ ((TextView) customActionBarView.findViewById(R.id.actionbar_cancel_text))
+ .setText(R.string.btn_doNotSave);
+ customActionBarView.findViewById(R.id.actionbar_cancel).setOnClickListener(
+ new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ // cancel
+ cancelClicked();
+ }
+ });
+
+ // Show the custom action bar view and hide the normal Home icon and title.
final ActionBar actionBar = getSupportActionBar();
- actionBar.setDisplayShowTitleEnabled(true);
- actionBar.setDisplayHomeAsUpEnabled(false);
- actionBar.setHomeButtonEnabled(false);
+ actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM
+ | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
+ actionBar.setCustomView(customActionBarView, new ActionBar.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
+
+ setContentView(R.layout.select_public_key_activity);
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
@@ -124,41 +157,4 @@ public class SelectPublicKeyActivity extends SherlockFragmentActivity {
finish();
}
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // TODO: reimplement!
- // menu.add(0, Id.menu.option.search, 0, R.string.menu_search).setIcon(
- // android.R.drawable.ic_menu_search);
- menu.add(1, Id.menu.option.cancel, 0, R.string.btn_doNotSave).setShowAsAction(
- MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
- menu.add(1, Id.menu.option.okay, 1, R.string.btn_okay).setShowAsAction(
- MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
- return true;
- }
-
- /**
- * Menu Options
- */
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- // app icon in Action Bar clicked; go home
- Intent intent = new Intent(this, MainActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivity(intent);
- return true;
-
- case Id.menu.option.okay:
- okClicked();
- return true;
-
- case Id.menu.option.cancel:
- cancelClicked();
- return true;
-
- default:
- return super.onOptionsItemSelected(item);
- }
- }
}