display AppMsg warning when no encryption subkey is available

This commit is contained in:
Vincent Breitmoser 2014-05-07 02:27:51 +02:00
parent 0bb11be749
commit 873b1be75d
2 changed files with 13 additions and 0 deletions

View File

@ -32,6 +32,8 @@ import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;
import com.devspark.appmsg.AppMsg;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
@ -60,6 +62,9 @@ public class ViewKeyMainFragment extends Fragment implements
private static final int LOADER_ID_UNIFIED = 0;
private static final int LOADER_ID_USER_IDS = 1;
// conservative attitude
private boolean mHasEncrypt = true;
private ViewKeyUserIdsAdapter mUserIdsAdapter;
private Uri mDataUri;
@ -203,6 +208,8 @@ public class ViewKeyMainFragment extends Fragment implements
}
}
mHasEncrypt = data.getInt(INDEX_UNIFIED_HAS_ENCRYPT) != 0;
break;
}
}
@ -229,6 +236,11 @@ public class ViewKeyMainFragment extends Fragment implements
}
private void encrypt(Uri dataUri) {
// If there is no encryption key, don't bother.
if (!mHasEncrypt) {
AppMsg.makeText(getActivity(), R.string.error_no_encrypt_subkey, AppMsg.STYLE_ALERT).show();
return;
}
try {
long keyId = new ProviderHelper(getActivity()).extractOrGetMasterKeyId(dataUri);
long[] encryptionKeyIds = new long[]{keyId};

View File

@ -513,5 +513,6 @@
<string name="title_view_cert">View Certificate Details</string>
<string name="unknown_algorithm">unknown</string>
<string name="can_sign_not">cannot sign</string>
<string name="error_no_encrypt_subkey">No encryption subkey available!</string>
</resources>