aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-10-09 01:51:35 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2014-10-09 01:51:35 +0200
commit7646baf486527b174e3a1103411a6c7c13cc4d09 (patch)
treef2f3346a34792d871d4e40ec8a2d5955357b8f97 /OpenKeychain/src
parent45b02008fba52eaba833009c517afa697d2443f4 (diff)
downloadopen-keychain-7646baf486527b174e3a1103411a6c7c13cc4d09.tar.gz
open-keychain-7646baf486527b174e3a1103411a6c7c13cc4d09.tar.bz2
open-keychain-7646baf486527b174e3a1103411a6c7c13cc4d09.zip
Better handling if no api key is selected
Diffstat (limited to 'OpenKeychain/src')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java13
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java9
-rw-r--r--OpenKeychain/src/main/res/layout/api_remote_create_account.xml48
3 files changed, 42 insertions, 28 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
index eb016529d..b78ab8a37 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
@@ -410,9 +410,16 @@ public class OpenPgpService extends RemoteService {
if (sign) {
// Find the appropriate subkey to sign with
- CachedPublicKeyRing signingRing =
- new ProviderHelper(this).getCachedPublicKeyRing(accSettings.getKeyId());
- final long sigSubKeyId = signingRing.getSecretSignId();
+ long sigSubKeyId;
+ try {
+ CachedPublicKeyRing signingRing =
+ new ProviderHelper(this).getCachedPublicKeyRing(accSettings.getKeyId());
+ sigSubKeyId = signingRing.getSecretSignId();
+ } catch (PgpKeyNotFoundException e) {
+ // secret key that is set for this account is deleted?
+ // show account config again!
+ return getCreateAccountIntent(data, getAccountName(data));
+ }
String passphrase;
if (data.hasExtra(OpenPgpApi.EXTRA_PASSPHRASE)) {
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java
index ed5e1f4cc..3e1c67dfa 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java
@@ -31,7 +31,6 @@ import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.view.View;
import android.widget.TextView;
-import android.widget.Toast;
import org.openintents.openpgp.util.OpenPgpApi;
import org.sufficientlysecure.keychain.Constants;
@@ -42,6 +41,7 @@ import org.sufficientlysecure.keychain.remote.AccountSettings;
import org.sufficientlysecure.keychain.remote.AppSettings;
import org.sufficientlysecure.keychain.ui.SelectPublicKeyFragment;
import org.sufficientlysecure.keychain.ui.util.ActionBarHelper;
+import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.util.Log;
import java.util.ArrayList;
@@ -176,10 +176,9 @@ public class RemoteServiceActivity extends ActionBarActivity {
public void onClick(View v) {
// Save
- // user needs to select a key!
- if (mAccSettingsFragment.getAccSettings().getKeyId() == Constants.key.none) {
- // TODO
- Toast.makeText(RemoteServiceActivity.this, getString(R.string.api_register_error_select_key), Toast.LENGTH_LONG).show();
+ // user needs to select a key, but also allow None for mUpdateExistingAccount
+ if (mUpdateExistingAccount && mAccSettingsFragment.getAccSettings().getKeyId() == Constants.key.none) {
+ Notify.showNotify(RemoteServiceActivity.this, getString(R.string.api_register_error_select_key), Notify.Style.ERROR);
} else {
if (mUpdateExistingAccount) {
Uri baseUri = KeychainContract.ApiAccounts.buildBaseUri(packageName);
diff --git a/OpenKeychain/src/main/res/layout/api_remote_create_account.xml b/OpenKeychain/src/main/res/layout/api_remote_create_account.xml
index 3aee9094f..a6a39b1ad 100644
--- a/OpenKeychain/src/main/res/layout/api_remote_create_account.xml
+++ b/OpenKeychain/src/main/res/layout/api_remote_create_account.xml
@@ -1,29 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
- android:layout_height="wrap_content">
+ android:layout_height="match_parent"
+ android:orientation="vertical">
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:padding="16dp"
- android:orientation="vertical">
+ <include layout="@layout/notify_area" />
- <TextView
- android:id="@+id/api_remote_create_account_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingBottom="3dip"
- android:text="@string/api_create_account_text"
- android:textAppearance="?android:attr/textAppearanceMedium" />
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
- <fragment
- android:id="@+id/api_account_settings_fragment"
- android:name="org.sufficientlysecure.keychain.remote.ui.AccountSettingsFragment"
+ <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- tools:layout="@layout/api_app_settings_fragment" />
+ android:padding="16dp"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/api_remote_create_account_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingBottom="3dip"
+ android:text="@string/api_create_account_text"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <fragment
+ android:id="@+id/api_account_settings_fragment"
+ android:name="org.sufficientlysecure.keychain.remote.ui.AccountSettingsFragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ tools:layout="@layout/api_app_settings_fragment" />
- </LinearLayout>
-</ScrollView>
+ </LinearLayout>
+ </ScrollView>
+</LinearLayout> \ No newline at end of file