mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-05 08:45:08 -05:00
Two buttons to encrypt files and text, some fixes
This commit is contained in:
parent
02663de191
commit
d1e08f9305
@ -50,7 +50,7 @@ import java.util.Set;
|
||||
public class EncryptFileActivity extends DrawerActivity implements EncryptActivityInterface {
|
||||
|
||||
/* Intents */
|
||||
public static final String ACTION_ENCRYPT_FILE = Constants.INTENT_PREFIX + "ENCRYPT_FILE";
|
||||
public static final String ACTION_ENCRYPT = Constants.INTENT_PREFIX + "ENCRYPT";
|
||||
|
||||
// enables ASCII Armor for file encryption when uri is given
|
||||
public static final String EXTRA_ASCII_ARMOR = "ascii_armor";
|
||||
@ -370,7 +370,7 @@ public class EncryptFileActivity extends DrawerActivity implements EncryptActivi
|
||||
setContentView(R.layout.encrypt_file_activity);
|
||||
|
||||
// if called with an intent action, do not init drawer navigation
|
||||
if (ACTION_ENCRYPT_FILE.equals(getIntent().getAction())) {
|
||||
if (ACTION_ENCRYPT.equals(getIntent().getAction())) {
|
||||
// lock drawer
|
||||
deactivateDrawerNavigation();
|
||||
// TODO: back button to key?
|
||||
@ -460,10 +460,10 @@ public class EncryptFileActivity extends DrawerActivity implements EncryptActivi
|
||||
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||
if (sharedText != null) {
|
||||
// handle like normal text encryption, override action and extras to later
|
||||
// executeServiceMethod ACTION_ENCRYPT_FILE in main actions
|
||||
// executeServiceMethod ACTION_ENCRYPT in main actions
|
||||
extras.putString(EXTRA_TEXT, sharedText);
|
||||
extras.putBoolean(EXTRA_ASCII_ARMOR, true);
|
||||
action = ACTION_ENCRYPT_FILE;
|
||||
action = ACTION_ENCRYPT;
|
||||
}
|
||||
|
||||
} else */
|
||||
|
@ -49,7 +49,7 @@ import java.util.Set;
|
||||
public class EncryptTextActivity extends DrawerActivity implements EncryptActivityInterface {
|
||||
|
||||
/* Intents */
|
||||
public static final String ACTION_ENCRYPT_TEXT = Constants.INTENT_PREFIX + "ENCRYPT_TEXT";
|
||||
public static final String ACTION_ENCRYPT = Constants.INTENT_PREFIX + "ENCRYPT";
|
||||
|
||||
/* EXTRA keys for input */
|
||||
public static final String EXTRA_TEXT = "text";
|
||||
@ -338,7 +338,7 @@ public class EncryptTextActivity extends DrawerActivity implements EncryptActivi
|
||||
setContentView(R.layout.encrypt_text_activity);
|
||||
|
||||
// if called with an intent action, do not init drawer navigation
|
||||
if (ACTION_ENCRYPT_TEXT.equals(getIntent().getAction())) {
|
||||
if (ACTION_ENCRYPT.equals(getIntent().getAction())) {
|
||||
// lock drawer
|
||||
deactivateDrawerNavigation();
|
||||
// TODO: back button to key?
|
||||
@ -415,9 +415,9 @@ public class EncryptTextActivity extends DrawerActivity implements EncryptActivi
|
||||
/**
|
||||
* Main Actions
|
||||
*/
|
||||
if (ACTION_ENCRYPT_TEXT.equals(action) && textData != null) {
|
||||
if (ACTION_ENCRYPT.equals(action) && textData != null) {
|
||||
mMessage = textData;
|
||||
} else if (ACTION_ENCRYPT_TEXT.equals(action)) {
|
||||
} else if (ACTION_ENCRYPT.equals(action)) {
|
||||
Log.e(Constants.TAG, "Include the extra 'text' in your Intent!");
|
||||
}
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ public class KeyListFragment extends LoaderFragment
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
protected void encrypt(ActionMode mode, long[] masterKeyIds) {
|
||||
Intent intent = new Intent(getActivity(), EncryptFileActivity.class);
|
||||
intent.setAction(EncryptFileActivity.ACTION_ENCRYPT_FILE);
|
||||
intent.setAction(EncryptFileActivity.ACTION_ENCRYPT);
|
||||
intent.putExtra(EncryptFileActivity.EXTRA_ENCRYPTION_KEY_IDS, masterKeyIds);
|
||||
// used instead of startActivity set actionbar based on callingPackage
|
||||
startActivityForResult(intent, 0);
|
||||
|
@ -57,7 +57,8 @@ public class ViewKeyMainFragment extends LoaderFragment implements
|
||||
|
||||
private View mActionEdit;
|
||||
private View mActionEditDivider;
|
||||
private View mActionEncrypt;
|
||||
private View mActionEncryptFiles;
|
||||
private View mActionEncryptText;
|
||||
private View mActionCertify;
|
||||
private View mActionCertifyText;
|
||||
private ImageView mActionCertifyImage;
|
||||
@ -83,7 +84,8 @@ public class ViewKeyMainFragment extends LoaderFragment implements
|
||||
mUserIds = (ListView) view.findViewById(R.id.view_key_user_ids);
|
||||
mActionEdit = view.findViewById(R.id.view_key_action_edit);
|
||||
mActionEditDivider = view.findViewById(R.id.view_key_action_edit_divider);
|
||||
mActionEncrypt = view.findViewById(R.id.view_key_action_encrypt);
|
||||
mActionEncryptText = view.findViewById(R.id.view_key_action_encrypt_text);
|
||||
mActionEncryptFiles = view.findViewById(R.id.view_key_action_encrypt_files);
|
||||
mActionCertify = view.findViewById(R.id.view_key_action_certify);
|
||||
mActionCertifyText = view.findViewById(R.id.view_key_action_certify_text);
|
||||
mActionCertifyImage = (ImageView) view.findViewById(R.id.view_key_action_certify_image);
|
||||
@ -135,10 +137,16 @@ public class ViewKeyMainFragment extends LoaderFragment implements
|
||||
|
||||
Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString());
|
||||
|
||||
mActionEncrypt.setOnClickListener(new View.OnClickListener() {
|
||||
mActionEncryptFiles.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
encrypt(mDataUri);
|
||||
encrypt(mDataUri, false);
|
||||
}
|
||||
});
|
||||
mActionEncryptText.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
encrypt(mDataUri, true);
|
||||
}
|
||||
});
|
||||
mActionCertify.setOnClickListener(new View.OnClickListener() {
|
||||
@ -227,7 +235,7 @@ public class ViewKeyMainFragment extends LoaderFragment implements
|
||||
mActionEdit.setEnabled(false);
|
||||
mActionCertify.setEnabled(false);
|
||||
mActionCertifyText.setEnabled(false);
|
||||
mActionEncrypt.setEnabled(false);
|
||||
mActionEncryptFiles.setEnabled(false);
|
||||
} else {
|
||||
mActionEdit.setEnabled(true);
|
||||
|
||||
@ -235,11 +243,11 @@ public class ViewKeyMainFragment extends LoaderFragment implements
|
||||
if (!data.isNull(INDEX_UNIFIED_EXPIRY) && expiryDate.before(new Date())) {
|
||||
mActionCertify.setEnabled(false);
|
||||
mActionCertifyText.setEnabled(false);
|
||||
mActionEncrypt.setEnabled(false);
|
||||
mActionEncryptFiles.setEnabled(false);
|
||||
} else {
|
||||
mActionCertify.setEnabled(true);
|
||||
mActionCertifyText.setEnabled(true);
|
||||
mActionEncrypt.setEnabled(true);
|
||||
mActionEncryptFiles.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,7 +277,7 @@ public class ViewKeyMainFragment extends LoaderFragment implements
|
||||
}
|
||||
}
|
||||
|
||||
private void encrypt(Uri dataUri) {
|
||||
private void encrypt(Uri dataUri, boolean text) {
|
||||
// If there is no encryption key, don't bother.
|
||||
if (!mHasEncrypt) {
|
||||
Notify.showNotify(getActivity(), R.string.error_no_encrypt_subkey, Notify.Style.ERROR);
|
||||
@ -280,9 +288,16 @@ public class ViewKeyMainFragment extends LoaderFragment implements
|
||||
.getCachedPublicKeyRing(dataUri)
|
||||
.extractOrGetMasterKeyId();
|
||||
long[] encryptionKeyIds = new long[]{keyId};
|
||||
Intent intent = new Intent(getActivity(), EncryptFileActivity.class);
|
||||
intent.setAction(EncryptFileActivity.ACTION_ENCRYPT_FILE);
|
||||
intent.putExtra(EncryptFileActivity.EXTRA_ENCRYPTION_KEY_IDS, encryptionKeyIds);
|
||||
Intent intent;
|
||||
if (text) {
|
||||
intent = new Intent(getActivity(), EncryptTextActivity.class);
|
||||
intent.setAction(EncryptTextActivity.ACTION_ENCRYPT);
|
||||
intent.putExtra(EncryptTextActivity.EXTRA_ENCRYPTION_KEY_IDS, encryptionKeyIds);
|
||||
} else {
|
||||
intent = new Intent(getActivity(), EncryptFileActivity.class);
|
||||
intent.setAction(EncryptFileActivity.ACTION_ENCRYPT);
|
||||
intent.putExtra(EncryptFileActivity.EXTRA_ENCRYPTION_KEY_IDS, encryptionKeyIds);
|
||||
}
|
||||
// used instead of startActivity set actionbar based on callingPackage
|
||||
startActivityForResult(intent, 0);
|
||||
} catch (PgpGeneralException e) {
|
||||
|
@ -93,21 +93,49 @@
|
||||
android:layout_height="1dip"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/view_key_action_encrypt"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/view_key_action_encrypt_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||
android:clickable="true"
|
||||
style="@style/SelectableItem"
|
||||
android:text="@string/key_view_action_encrypt"
|
||||
android:layout_weight="1"
|
||||
android:drawableRight="@drawable/ic_action_secure"
|
||||
android:drawablePadding="8dp"
|
||||
android:gravity="center_vertical" />
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/key_view_action_encrypt"
|
||||
android:layout_weight="1"
|
||||
android:drawableRight="@drawable/ic_action_secure"
|
||||
android:drawablePadding="8dp"
|
||||
android:gravity="center_vertical" />
|
||||
|
||||
<View
|
||||
android:layout_width="1dip"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="right"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/view_key_action_encrypt_files"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/key_view_action_encrypt_files"
|
||||
android:drawableRight="@drawable/ic_action_secure"
|
||||
android:drawablePadding="8dp"
|
||||
android:gravity="center_vertical"
|
||||
style="@style/SelectableItem" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
|
@ -447,7 +447,8 @@
|
||||
|
||||
<!-- Key view -->
|
||||
<string name="key_view_action_edit">Edit key</string>
|
||||
<string name="key_view_action_encrypt">Encrypt with this key</string>
|
||||
<string name="key_view_action_encrypt">Encrypt Text</string>
|
||||
<string name="key_view_action_encrypt_files">Files</string>
|
||||
<string name="key_view_action_certify">Certify identities</string>
|
||||
<string name="key_view_action_update">Update from keyserver</string>
|
||||
<string name="key_view_action_share_with">Share with…</string>
|
||||
|
Loading…
Reference in New Issue
Block a user