diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java index f8db03873..35dfcb87c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java @@ -23,7 +23,6 @@ import android.content.Intent; import android.os.Bundle; import android.os.Message; import android.os.Messenger; -import android.os.PersistableBundle; import android.view.View; import org.openintents.openpgp.util.OpenPgpApi; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesActivity.java index eba19df6d..d95b5cda3 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesActivity.java @@ -67,8 +67,8 @@ public class EncryptFilesActivity extends EncryptActivity implements EncryptActi private String mEncryptionUserIds[] = null; private long mSigningKeyId = Constants.key.none; private String mPassphrase = ""; - private boolean mUseArmor; - private boolean mUseCompression; + private boolean mUseArmor = false; + private boolean mUseCompression = true; private boolean mDeleteAfterEncrypt = false; private boolean mShareAfterEncrypt = false; private ArrayList mInputUris; @@ -209,6 +209,7 @@ public class EncryptFilesActivity extends EncryptActivity implements EncryptActi } else { data.setCompressionId(CompressionAlgorithmTags.UNCOMPRESSED); } + data.setEnableAsciiArmorOutput(mUseArmor); data.setSymmetricEncryptionAlgorithm(PgpConstants.OpenKeychainSymmetricKeyAlgorithmTags.USE_PREFERRED); data.setSignatureHashAlgorithm(PgpConstants.OpenKeychainSymmetricKeyAlgorithmTags.USE_PREFERRED); @@ -409,9 +410,7 @@ public class EncryptFilesActivity extends EncryptActivity implements EncryptActi uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); } - if (extras.containsKey(EXTRA_ASCII_ARMOR)) { - mUseArmor = extras.getBoolean(EXTRA_ASCII_ARMOR, true); - } + mUseArmor = extras.getBoolean(EXTRA_ASCII_ARMOR, false); // preselect keys given by intent mSigningKeyId = extras.getLong(EXTRA_SIGNATURE_KEY_ID); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java index 08ff5b962..ee15cf7b5 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java @@ -72,7 +72,7 @@ public class EncryptTextActivity extends EncryptActivity implements EncryptActiv private ArrayList mInputUris; private ArrayList mOutputUris; private String mMessage = ""; - private boolean mUseCompression; + private boolean mUseCompression = true; public boolean isModeSymmetric() { return MODE_SYMMETRIC == mCurrentMode; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java index 07462b4ff..c4b437593 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java @@ -28,8 +28,10 @@ import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; import android.widget.Toast; +import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.util.FileHelper; +import org.sufficientlysecure.keychain.util.Log; import java.io.File; @@ -69,41 +71,44 @@ public class DeleteFileDialogFragment extends DialogFragment { @Override public void onClick(DialogInterface dialog, int id) { dismiss(); - String scheme = deleteUri.getScheme(); - if(scheme.equals(ContentResolver.SCHEME_FILE)) { - if(new File(deleteUri.getPath()).delete()) { - Toast.makeText(getActivity(), R.string.file_delete_successful, Toast.LENGTH_SHORT).show(); - return; - } - } - else if(scheme.equals(ContentResolver.SCHEME_CONTENT)) { - // We can not securely delete Uris, so just use usual delete on them - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + // NOTE: Use Toasts, not Snackbars. When sharing to another application snackbars + // would not show up! + + // Use DocumentsContract on Android >= 4.4 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + try { if (DocumentsContract.deleteDocument(getActivity().getContentResolver(), deleteUri)) { - Toast.makeText(getActivity(), R.string.file_delete_successful, Toast.LENGTH_SHORT).show(); + Toast.makeText(getActivity(), getActivity().getString(R.string.file_delete_successful, + deleteFilename), Toast.LENGTH_LONG).show(); return; } - } - - if (getActivity().getContentResolver().delete(deleteUri, null, null) > 0) { - Toast.makeText(getActivity(), R.string.file_delete_successful, Toast.LENGTH_SHORT).show(); - return; - } - - // some Uri's a ContentResolver fails to delete is handled by the java.io.File's delete - // via the path of the Uri - if(new File(deleteUri.getPath()).delete()) { - Toast.makeText(getActivity(), R.string.file_delete_successful, Toast.LENGTH_SHORT).show(); - return; + } catch (UnsupportedOperationException e) { + Log.d(Constants.TAG, "Catched UnsupportedOperationException, can happen when delete is not supported!", e); } } - Toast.makeText(getActivity(), getActivity().getString(R.string.error_file_delete_failed, - deleteFilename), Toast.LENGTH_SHORT).show(); + try { + if (getActivity().getContentResolver().delete(deleteUri, null, null) > 0) { + Toast.makeText(getActivity(), getActivity().getString(R.string.file_delete_successful, + deleteFilename), Toast.LENGTH_LONG).show(); + return; + } + } catch (UnsupportedOperationException e) { + Log.d(Constants.TAG, "Catched UnsupportedOperationException, can happen when delete is not supported!", e); + } + + // some Uri's a ContentResolver fails to delete is handled by the java.io.File's delete + // via the path of the Uri + if (new File(deleteUri.getPath()).delete()) { + Toast.makeText(getActivity(), getActivity().getString(R.string.file_delete_successful, + deleteFilename), Toast.LENGTH_LONG).show(); + return; + } // Note: We can't delete every file... - // If possible we should find out if deletion is possible before even showing the option to do so. + Toast.makeText(getActivity(), getActivity().getString(R.string.error_file_delete_failed, + deleteFilename), Toast.LENGTH_LONG).show(); } }); alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { diff --git a/OpenKeychain/src/main/res/layout/file_list_entry_add.xml b/OpenKeychain/src/main/res/layout/file_list_entry_add.xml index f2ee4079e..d7f4513d9 100644 --- a/OpenKeychain/src/main/res/layout/file_list_entry_add.xml +++ b/OpenKeychain/src/main/res/layout/file_list_entry_add.xml @@ -1,21 +1,21 @@ + - + android:paddingLeft="8dp" + android:paddingRight="8dp" + android:textAppearance="?android:attr/textAppearanceMedium" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_gravity="center" + android:text="@string/btn_add_files" + android:drawableLeft="@drawable/ic_folder_grey_24dp" + android:drawablePadding="8dp" + android:gravity="center" /> \ No newline at end of file diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index 39af9ca28..2c83ac070 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -220,7 +220,7 @@ "Enter PIN to access YubiKey for '%s'" "Hold YubiKey against the back of your device." "Are you sure you want to delete\n%s?" - "Successfully deleted." + "'%s' has been deleted." "Select a file first." "Successfully signed and/or encrypted." "Successfully signed and/or encrypted to clipboard." @@ -261,7 +261,7 @@ no punctuation, all lowercase, they will be put after "error_message", e.g. "Error: file not found" --> - "deleting '%s' failed" + "Deleting '%s' failed. Please do this manually!" "file not found" "no suitable secret key found" "external storage not ready"