aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--OpenPGP-Keychain-API-Demo/AndroidManifest.xml1
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/ActionBarHelper.java116
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/OtherHelper.java25
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsActivity.java19
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java8
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoServiceActivity.java39
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/IServiceActivityCallback.aidl2
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/DecryptActivity.java3
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EditKeyActivity.java4
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EncryptActivity.java18
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java8
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java24
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/SelectPublicKeyActivity.java27
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/ShareNfcBeamActivity.java24
14 files changed, 179 insertions, 139 deletions
diff --git a/OpenPGP-Keychain-API-Demo/AndroidManifest.xml b/OpenPGP-Keychain-API-Demo/AndroidManifest.xml
index a11b6e623..75d02482b 100644
--- a/OpenPGP-Keychain-API-Demo/AndroidManifest.xml
+++ b/OpenPGP-Keychain-API-Demo/AndroidManifest.xml
@@ -12,6 +12,7 @@
android:targetSdkVersion="14" />
<application
+ android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="OpenPGP Keychain API Demo" >
<activity
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/ActionBarHelper.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/ActionBarHelper.java
new file mode 100644
index 000000000..c0fc4df86
--- /dev/null
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/ActionBarHelper.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2013 Dominik Schürmann <dominik@dominikschuermann.de>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.sufficientlysecure.keychain.helper;
+
+import org.sufficientlysecure.keychain.Constants;
+import org.sufficientlysecure.keychain.R;
+import org.sufficientlysecure.keychain.util.Log;
+
+import android.app.Activity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.View.OnClickListener;
+import android.widget.TextView;
+
+import com.actionbarsherlock.app.ActionBar;
+import com.actionbarsherlock.app.SherlockFragmentActivity;
+
+public class ActionBarHelper {
+
+ /**
+ * Set actionbar without home button if called from another app
+ *
+ * @param activity
+ */
+ public static void setBackButton(SherlockFragmentActivity activity) {
+ // set actionbar without home button if called from another app
+ final ActionBar actionBar = activity.getSupportActionBar();
+ Log.d(Constants.TAG, "calling package (only set when using startActivityForResult)="
+ + activity.getCallingPackage());
+ if (activity.getCallingPackage() != null
+ && activity.getCallingPackage().equals(Constants.PACKAGE_NAME)) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setHomeButtonEnabled(true);
+ } else {
+ actionBar.setDisplayHomeAsUpEnabled(false);
+ actionBar.setHomeButtonEnabled(false);
+ }
+ }
+
+ /**
+ * Sets custom view on ActionBar for Done/Cancel activities
+ *
+ * @param actionBar
+ * @param doneText
+ * @param doneOnClickListener
+ * @param cancelText
+ * @param cancelOnClickListener
+ */
+ public static void setDoneCancelView(ActionBar actionBar, int doneText,
+ OnClickListener doneOnClickListener, int cancelText,
+ OnClickListener cancelOnClickListener) {
+
+ // Inflate a "Done"/"Cancel" custom action bar view
+ final LayoutInflater inflater = (LayoutInflater) actionBar.getThemedContext()
+ .getSystemService(Activity.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(doneText);
+ customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(
+ doneOnClickListener);
+ ((TextView) customActionBarView.findViewById(R.id.actionbar_cancel_text))
+ .setText(cancelText);
+ customActionBarView.findViewById(R.id.actionbar_cancel).setOnClickListener(
+ cancelOnClickListener);
+
+ // Show the custom action bar view and hide the normal Home icon and title.
+ 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));
+ }
+
+ /**
+ * Sets custom view on ActionBar for Done activities
+ *
+ * @param actionBar
+ * @param doneText
+ * @param doneOnClickListener
+ */
+ public static void setDoneView(ActionBar actionBar, int doneText,
+ OnClickListener doneOnClickListener) {
+ // Inflate a "Done" custom action bar view to serve as the "Up" affordance.
+ final LayoutInflater inflater = (LayoutInflater) actionBar.getThemedContext()
+ .getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
+ final View customActionBarView = inflater
+ .inflate(R.layout.actionbar_custom_view_done, null);
+
+ ((TextView) customActionBarView.findViewById(R.id.actionbar_done_text))
+ .setText(R.string.api_settings_save);
+ customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(
+ doneOnClickListener);
+
+ // Show the custom action bar view and hide the normal Home icon and title.
+ actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM
+ | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
+ actionBar.setCustomView(customActionBarView);
+ }
+
+}
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/OtherHelper.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/OtherHelper.java
index 593cd4242..24e687897 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/OtherHelper.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/OtherHelper.java
@@ -24,15 +24,10 @@ import java.util.Set;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.util.Log;
-import org.sufficientlysecure.keychain.R;
-
-import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.app.SherlockFragmentActivity;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Bundle;
-import android.widget.Toast;
public class OtherHelper {
@@ -87,26 +82,6 @@ public class OtherHelper {
}
/**
- * Set actionbar without home button if called from another app
- *
- * @param activity
- */
- public static void setActionBarBackButton(SherlockFragmentActivity activity) {
- // set actionbar without home button if called from another app
- final ActionBar actionBar = activity.getSupportActionBar();
- Log.d(Constants.TAG, "calling package (only set when using startActivityForResult)="
- + activity.getCallingPackage());
- if (activity.getCallingPackage() != null
- && activity.getCallingPackage().equals(Constants.PACKAGE_NAME)) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setHomeButtonEnabled(true);
- } else {
- actionBar.setDisplayHomeAsUpEnabled(false);
- actionBar.setHomeButtonEnabled(false);
- }
- }
-
- /**
* Check if the calling package has the needed permission to invoke an intent with specific
* restricted actions.
*
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsActivity.java
index c77060c0d..2d3b23c1b 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsActivity.java
@@ -19,17 +19,15 @@ package org.sufficientlysecure.keychain.remote_api;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
+import org.sufficientlysecure.keychain.helper.ActionBarHelper;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.util.Log;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
-import android.view.LayoutInflater;
import android.view.View;
-import android.widget.TextView;
-import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
@@ -44,14 +42,7 @@ public class AppSettingsActivity extends SherlockFragmentActivity {
super.onCreate(savedInstanceState);
// Inflate a "Done" custom action bar view to serve as the "Up" affordance.
- final LayoutInflater inflater = (LayoutInflater) getSupportActionBar().getThemedContext()
- .getSystemService(LAYOUT_INFLATER_SERVICE);
- final View customActionBarView = inflater
- .inflate(R.layout.actionbar_custom_view_done, null);
-
- ((TextView) customActionBarView.findViewById(R.id.actionbar_done_text))
- .setText(R.string.api_settings_save);
- customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(
+ ActionBarHelper.setDoneView(getSupportActionBar(), R.string.api_settings_save,
new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -60,12 +51,6 @@ public class AppSettingsActivity extends SherlockFragmentActivity {
}
});
- // 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);
-
setContentView(R.layout.api_app_settings_activity);
settingsFragment = (AppSettingsFragment) getSupportFragmentManager().findFragmentById(
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java
index 74d4a7306..cc75ae02a 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java
@@ -205,6 +205,8 @@ public class CryptoService extends Service {
long inputLength = inputBytes.length;
InputData inputData = new InputData(inputStream, inputLength);
+ Log.d(Constants.TAG, "in: " + new String(inputBytes));
+
OutputStream outputStream = new ByteArrayOutputStream();
// TODO: This allows to decrypt messages with ALL secret keys, not only the one for the
@@ -382,6 +384,12 @@ public class CryptoService extends Service {
}
+ @Override
+ public void onSelectedPublicKeys(long[] keyIds) throws RemoteException {
+ // TODO Auto-generated method stub
+
+ }
+
};
private void checkAndEnqueue(Runnable r) {
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoServiceActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoServiceActivity.java
index 6881d287e..38f7489ed 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoServiceActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoServiceActivity.java
@@ -20,6 +20,8 @@ package org.sufficientlysecure.keychain.remote_api;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Id;
import org.sufficientlysecure.keychain.R;
+import org.sufficientlysecure.keychain.helper.ActionBarHelper;
+import org.sufficientlysecure.keychain.helper.OtherHelper;
import org.sufficientlysecure.keychain.helper.PgpMain;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment;
@@ -46,8 +48,11 @@ import com.actionbarsherlock.app.SherlockFragmentActivity;
public class CryptoServiceActivity extends SherlockFragmentActivity {
- public static final String ACTION_REGISTER = "org.sufficientlysecure.keychain.remote_api.REGISTER";
- public static final String ACTION_CACHE_PASSPHRASE = "org.sufficientlysecure.keychain.remote_api.CRYPTO_CACHE_PASSPHRASE";
+ public static final String ACTION_REGISTER = Constants.INTENT_PREFIX + "API_ACTIVITY_REGISTER";
+ public static final String ACTION_CACHE_PASSPHRASE = Constants.INTENT_PREFIX
+ + "API_ACTIVITY_CACHE_PASSPHRASE";
+ public static final String ACTION_SELECT_PUB_KEYS = Constants.INTENT_PREFIX
+ + "API_ACTIVITY_SELECT_PUB_KEYS";
public static final String EXTRA_SECRET_KEY_ID = "secretKeyId";
public static final String EXTRA_PACKAGE_NAME = "packageName";
@@ -55,7 +60,7 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
private IServiceActivityCallback mServiceCallback;
private boolean mServiceBound;
- // view
+ // register view
AppSettingsFragment settingsFragment;
private ServiceConnection mServiceActivityConnection = new ServiceConnection() {
@@ -139,14 +144,7 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
final String packageName = extras.getString(EXTRA_PACKAGE_NAME);
// 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.api_register_allow);
- customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(
+ ActionBarHelper.setDoneCancelView(getSupportActionBar(), R.string.api_register_allow,
new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -169,11 +167,7 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
finish();
}
}
- });
- ((TextView) customActionBarView.findViewById(R.id.actionbar_cancel_text))
- .setText(R.string.api_register_disallow);
- customActionBarView.findViewById(R.id.actionbar_cancel).setOnClickListener(
- new View.OnClickListener() {
+ }, R.string.api_register_disallow, new View.OnClickListener() {
@Override
public void onClick(View v) {
// Disallow
@@ -186,14 +180,6 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
}
});
- // 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.api_app_register_activity);
settingsFragment = (AppSettingsFragment) getSupportFragmentManager().findFragmentById(
@@ -201,7 +187,6 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
AppSettings settings = new AppSettings(packageName);
settingsFragment.setAppSettings(settings);
-
// TODO: handle if app is already registered
// LinearLayout layoutRegister = (LinearLayout)
@@ -224,6 +209,10 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
long secretKeyId = extras.getLong(EXTRA_SECRET_KEY_ID);
showPassphraseDialog(secretKeyId);
+ } else if (ACTION_SELECT_PUB_KEYS.equals(action)) {
+ long secretKeyId = extras.getLong(EXTRA_SECRET_KEY_ID);
+
+ showPassphraseDialog(secretKeyId);
} else {
Log.e(Constants.TAG, "Wrong action!");
finish();
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/IServiceActivityCallback.aidl b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/IServiceActivityCallback.aidl
index 9566cac18..82fc77422 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/IServiceActivityCallback.aidl
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/IServiceActivityCallback.aidl
@@ -23,5 +23,7 @@ interface IServiceActivityCallback {
oneway void onRegistered(in boolean success, in String packageName);
oneway void onCachedPassphrase(in boolean success);
+
+ oneway void onSelectedPublicKeys(in long[] keyIds);
} \ No newline at end of file
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/DecryptActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/DecryptActivity.java
index 8b617b92b..359fe4959 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/DecryptActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/DecryptActivity.java
@@ -21,6 +21,7 @@ import org.spongycastle.openpgp.PGPPublicKeyRing;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Id;
import org.sufficientlysecure.keychain.compatibility.ClipboardReflection;
+import org.sufficientlysecure.keychain.helper.ActionBarHelper;
import org.sufficientlysecure.keychain.helper.FileHelper;
import org.sufficientlysecure.keychain.helper.OtherHelper;
import org.sufficientlysecure.keychain.helper.PgpHelper;
@@ -255,7 +256,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
setContentView(R.layout.decrypt);
// set actionbar without home button if called from another app
- OtherHelper.setActionBarBackButton(this);
+ ActionBarHelper.setBackButton(this);
initView();
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EditKeyActivity.java
index 63a4f1afb..4137a1b19 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EditKeyActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EditKeyActivity.java
@@ -26,7 +26,7 @@ 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.ActionBarHelper;
import org.sufficientlysecure.keychain.helper.PgpConversionHelper;
import org.sufficientlysecure.keychain.helper.PgpHelper;
import org.sufficientlysecure.keychain.helper.PgpMain;
@@ -152,7 +152,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
mActionBar.setDisplayShowTitleEnabled(true);
// set actionbar without home button if called from another app
- OtherHelper.setActionBarBackButton(this);
+ ActionBarHelper.setBackButton(this);
// find views
mChangePassPhrase = (Button) findViewById(R.id.edit_key_btn_change_pass_phrase);
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EncryptActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EncryptActivity.java
index 751e6deae..c4f416b10 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EncryptActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EncryptActivity.java
@@ -17,13 +17,18 @@
package org.sufficientlysecure.keychain.ui;
+import java.io.File;
+import java.util.Vector;
+
import org.spongycastle.openpgp.PGPPublicKey;
import org.spongycastle.openpgp.PGPPublicKeyRing;
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.compatibility.ClipboardReflection;
+import org.sufficientlysecure.keychain.helper.ActionBarHelper;
import org.sufficientlysecure.keychain.helper.FileHelper;
import org.sufficientlysecure.keychain.helper.OtherHelper;
import org.sufficientlysecure.keychain.helper.PgpHelper;
@@ -38,10 +43,7 @@ import org.sufficientlysecure.keychain.ui.dialog.FileDialogFragment;
import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment;
import org.sufficientlysecure.keychain.util.Choice;
import org.sufficientlysecure.keychain.util.Log;
-import org.sufficientlysecure.keychain.R;
-import com.actionbarsherlock.app.SherlockFragmentActivity;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuItem;
+
import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.Intent;
@@ -63,8 +65,10 @@ import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ViewFlipper;
-import java.io.File;
-import java.util.Vector;
+
+import com.actionbarsherlock.app.SherlockFragmentActivity;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuItem;
public class EncryptActivity extends SherlockFragmentActivity {
@@ -202,7 +206,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
setContentView(R.layout.encrypt);
// set actionbar without home button if called from another app
- OtherHelper.setActionBarBackButton(this);
+ ActionBarHelper.setBackButton(this);
initView();
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java
index cb186ba16..65a46b7a5 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java
@@ -19,14 +19,14 @@ package org.sufficientlysecure.keychain.ui;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Id;
+import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
-import org.sufficientlysecure.keychain.helper.OtherHelper;
+import org.sufficientlysecure.keychain.helper.ActionBarHelper;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
import org.sufficientlysecure.keychain.ui.dialog.DeleteFileDialogFragment;
import org.sufficientlysecure.keychain.ui.dialog.FileDialogFragment;
import org.sufficientlysecure.keychain.util.Log;
-import org.sufficientlysecure.keychain.R;
import android.app.AlertDialog;
import android.app.ProgressDialog;
@@ -36,8 +36,6 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Messenger;
-
-
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
@@ -77,7 +75,7 @@ public class ImportKeysActivity extends SherlockFragmentActivity {
setContentView(R.layout.import_keys);
// set actionbar without home button if called from another app
- OtherHelper.setActionBarBackButton(this);
+ ActionBarHelper.setBackButton(this);
handleActions(getIntent());
}
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java
index bc2e358b6..e977a2716 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java
@@ -19,6 +19,7 @@ package org.sufficientlysecure.keychain.ui;
import java.util.Vector;
import org.sufficientlysecure.keychain.R;
+import org.sufficientlysecure.keychain.helper.ActionBarHelper;
import org.sufficientlysecure.keychain.ui.widget.Editor;
import org.sufficientlysecure.keychain.ui.widget.Editor.EditorListener;
import org.sufficientlysecure.keychain.ui.widget.KeyServerEditor;
@@ -32,7 +33,6 @@ 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,
@@ -51,25 +51,14 @@ public class PreferencesKeyServerActivity extends SherlockActivity implements On
super.onCreate(savedInstanceState);
// 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(
+ ActionBarHelper.setDoneCancelView(getSupportActionBar(), R.string.btn_okay,
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() {
+ }, R.string.btn_doNotSave, new View.OnClickListener() {
@Override
public void onClick(View v) {
// cancel
@@ -77,13 +66,6 @@ public class PreferencesKeyServerActivity extends SherlockActivity implements On
}
});
- // 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.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 dbcd2569c..f7874b5c4 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/SelectPublicKeyActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/SelectPublicKeyActivity.java
@@ -19,15 +19,12 @@ package org.sufficientlysecure.keychain.ui;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
+import org.sufficientlysecure.keychain.helper.ActionBarHelper;
import android.content.Intent;
import android.os.Bundle;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockFragmentActivity;
public class SelectPublicKeyActivity extends SherlockFragmentActivity {
@@ -50,25 +47,14 @@ public class SelectPublicKeyActivity extends SherlockFragmentActivity {
super.onCreate(savedInstanceState);
// 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(
+ ActionBarHelper.setDoneCancelView(getSupportActionBar(), R.string.btn_okay,
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() {
+ }, R.string.btn_doNotSave, new View.OnClickListener() {
@Override
public void onClick(View v) {
// cancel
@@ -76,13 +62,6 @@ public class SelectPublicKeyActivity extends SherlockFragmentActivity {
}
});
- // 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.select_public_key_activity);
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/ShareNfcBeamActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/ShareNfcBeamActivity.java
index c106614d3..10adcc4ab 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/ShareNfcBeamActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/ShareNfcBeamActivity.java
@@ -24,14 +24,9 @@ import net.nightwhistler.htmlspanner.HtmlSpanner;
import net.nightwhistler.htmlspanner.JellyBeanSpanFixTextView;
import org.sufficientlysecure.keychain.Constants;
-import org.sufficientlysecure.keychain.helper.OtherHelper;
-import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.R;
-
-import com.actionbarsherlock.app.SherlockFragmentActivity;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
+import org.sufficientlysecure.keychain.helper.ActionBarHelper;
+import org.sufficientlysecure.keychain.provider.ProviderHelper;
import android.annotation.TargetApi;
import android.content.Intent;
@@ -39,17 +34,22 @@ import android.nfc.NdefMessage;
import android.nfc.NdefRecord;
import android.nfc.NfcAdapter;
import android.nfc.NfcAdapter.CreateNdefMessageCallback;
+import android.nfc.NfcAdapter.OnNdefPushCompleteCallback;
import android.nfc.NfcEvent;
import android.os.Build;
import android.os.Bundle;
-import android.os.Parcelable;
-import android.util.Log;
-import android.widget.Toast;
-import android.nfc.NfcAdapter.OnNdefPushCompleteCallback;
import android.os.Handler;
import android.os.Message;
+import android.os.Parcelable;
import android.provider.Settings;
import android.text.method.LinkMovementMethod;
+import android.util.Log;
+import android.widget.Toast;
+
+import com.actionbarsherlock.app.SherlockFragmentActivity;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public class ShareNfcBeamActivity extends SherlockFragmentActivity implements
@@ -154,7 +154,7 @@ public class ShareNfcBeamActivity extends SherlockFragmentActivity implements
text.setTextColor(getResources().getColor(android.R.color.black));
// set actionbar without home button if called from another app
- OtherHelper.setActionBarBackButton(this);
+ ActionBarHelper.setBackButton(this);
}
/**