Better handling if no api key is selected

This commit is contained in:
Dominik Schürmann 2014-10-09 01:51:35 +02:00
parent 45b02008fb
commit 7646baf486
3 changed files with 42 additions and 28 deletions

View File

@ -410,9 +410,16 @@ public class OpenPgpService extends RemoteService {
if (sign) {
// Find the appropriate subkey to sign with
long sigSubKeyId;
try {
CachedPublicKeyRing signingRing =
new ProviderHelper(this).getCachedPublicKeyRing(accSettings.getKeyId());
final long sigSubKeyId = signingRing.getSecretSignId();
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)) {

View File

@ -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);

View File

@ -1,6 +1,13 @@
<?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="match_parent"
android:orientation="vertical">
<include layout="@layout/notify_area" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
@ -26,4 +33,5 @@
tools:layout="@layout/api_app_settings_fragment" />
</LinearLayout>
</ScrollView>
</ScrollView>
</LinearLayout>