mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-30 04:22:18 -05:00
Allow encrypt of filenames via overflow menu
This commit is contained in:
parent
916ff0e0fa
commit
a5271bf229
@ -29,6 +29,7 @@ public interface EncryptActivityInterface {
|
||||
|
||||
public boolean isUseArmor();
|
||||
public boolean isUseCompression();
|
||||
public boolean isEncryptFilenames();
|
||||
|
||||
public long getSignatureKey();
|
||||
public long[] getEncryptionKeys();
|
||||
|
@ -70,6 +70,7 @@ public class EncryptFilesActivity extends EncryptActivity implements EncryptActi
|
||||
private boolean mUseCompression = true;
|
||||
private boolean mDeleteAfterEncrypt = false;
|
||||
private boolean mShareAfterEncrypt = false;
|
||||
private boolean mEncryptFilenames = true;
|
||||
private ArrayList<Uri> mInputUris;
|
||||
private ArrayList<Uri> mOutputUris;
|
||||
private String mMessage = "";
|
||||
@ -88,6 +89,11 @@ public class EncryptFilesActivity extends EncryptActivity implements EncryptActi
|
||||
return mUseCompression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEncryptFilenames() {
|
||||
return mEncryptFilenames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSignatureKey() {
|
||||
return mSigningKeyId;
|
||||
@ -371,6 +377,12 @@ public class EncryptFilesActivity extends EncryptActivity implements EncryptActi
|
||||
notifyUpdate();
|
||||
break;
|
||||
}
|
||||
case R.id.encrypt_filenames: {
|
||||
mEncryptFilenames = item.isChecked();
|
||||
notifyUpdate();
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
@ -137,17 +137,17 @@ public class EncryptFilesFragment extends Fragment implements EncryptActivityInt
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
Uri inputUri = mEncryptInterface.getInputUris().get(0);
|
||||
String targetName =
|
||||
(mEncryptInterface.isEncryptFilenames() ? "1" : FileHelper.getFilename(getActivity(), inputUri))
|
||||
+ (mEncryptInterface.isUseArmor() ? ".asc" : ".gpg");
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||
File file = new File(inputUri.getPath());
|
||||
File parentDir = file.exists() ? file.getParentFile() : Constants.Path.APP_DIR;
|
||||
String targetName = FileHelper.getFilename(getActivity(), inputUri) +
|
||||
(mEncryptInterface.isUseArmor() ? ".asc" : ".gpg");
|
||||
File targetFile = new File(parentDir, targetName);
|
||||
FileHelper.saveFile(this, getString(R.string.title_encrypt_to_file),
|
||||
getString(R.string.specify_file_to_encrypt_to), targetFile, REQUEST_CODE_OUTPUT);
|
||||
} else {
|
||||
FileHelper.saveDocument(this, "*/*", FileHelper.getFilename(getActivity(), inputUri) +
|
||||
(mEncryptInterface.isUseArmor() ? ".asc" : ".gpg"), REQUEST_CODE_OUTPUT);
|
||||
FileHelper.saveDocument(this, "*/*", targetName, REQUEST_CODE_OUTPUT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -158,10 +158,13 @@ public class EncryptFilesFragment extends Fragment implements EncryptActivityInt
|
||||
}
|
||||
if (share) {
|
||||
mEncryptInterface.getOutputUris().clear();
|
||||
int filenameCounter = 1;
|
||||
for (Uri uri : mEncryptInterface.getInputUris()) {
|
||||
String targetName = FileHelper.getFilename(getActivity(), uri) +
|
||||
(mEncryptInterface.isUseArmor() ? ".asc" : ".gpg");
|
||||
String targetName =
|
||||
(mEncryptInterface.isEncryptFilenames() ? String.valueOf(filenameCounter) : FileHelper.getFilename(getActivity(), uri))
|
||||
+ (mEncryptInterface.isUseArmor() ? ".asc" : ".gpg");
|
||||
mEncryptInterface.getOutputUris().add(TemporaryStorageProvider.createFile(getActivity(), targetName));
|
||||
filenameCounter++;
|
||||
}
|
||||
mEncryptInterface.startEncrypt(true);
|
||||
} else {
|
||||
|
@ -82,6 +82,11 @@ public class EncryptTextActivity extends EncryptActivity implements EncryptActiv
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEncryptFilenames() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseCompression() {
|
||||
return mUseCompression;
|
||||
|
@ -18,17 +18,27 @@
|
||||
android:id="@+id/check_use_symmetric"
|
||||
android:title="@string/label_symmetric"
|
||||
android:checkable="true" />
|
||||
<item
|
||||
android:id="@+id/check_use_armor"
|
||||
android:title="@string/label_file_ascii_armor"
|
||||
android:checkable="true" />
|
||||
|
||||
<item
|
||||
android:id="@+id/check_delete_after_encrypt"
|
||||
android:title="@string/label_delete_after_encryption"
|
||||
android:checkable="true" />
|
||||
|
||||
<item
|
||||
android:id="@+id/check_enable_compression"
|
||||
android:title="@string/label_enable_compression"
|
||||
android:checked="true"
|
||||
android:checkable="true" />
|
||||
|
||||
<item
|
||||
android:id="@+id/encrypt_filenames"
|
||||
android:title="@string/label_encrypt_filenames"
|
||||
android:checked="true"
|
||||
android:checkable="true" />
|
||||
|
||||
<item
|
||||
android:id="@+id/check_use_armor"
|
||||
android:title="@string/label_file_ascii_armor"
|
||||
android:checkable="true" />
|
||||
|
||||
</menu>
|
@ -18,6 +18,7 @@
|
||||
android:id="@+id/check_use_symmetric"
|
||||
android:title="@string/label_symmetric"
|
||||
android:checkable="true" />
|
||||
|
||||
<item
|
||||
android:id="@+id/check_enable_compression"
|
||||
android:title="@string/label_enable_compression"
|
||||
|
@ -141,7 +141,7 @@
|
||||
<string name="label_label_use_default_yubikey_pin_summary">"Uses default PIN (123456) to access YubiKeys over NFC"</string>
|
||||
<string name="label_asymmetric_from">"Signed by:"</string>
|
||||
<string name="label_to">"Encrypt to:"</string>
|
||||
<string name="label_delete_after_encryption">"Delete file after encryption"</string>
|
||||
<string name="label_delete_after_encryption">"Delete files after encryption"</string>
|
||||
<string name="label_delete_after_decryption">"Delete after decryption"</string>
|
||||
<string name="label_encryption_algorithm">"Encryption algorithm"</string>
|
||||
<string name="label_hash_algorithm">"Hash algorithm"</string>
|
||||
@ -167,6 +167,7 @@
|
||||
<string name="label_first_keyserver_is_used">"(First keyserver listed is preferred)"</string>
|
||||
<string name="label_preferred">"preferred"</string>
|
||||
<string name="label_enable_compression">"Enable compression"</string>
|
||||
<string name="label_encrypt_filenames">"Encrypt filenames"</string>
|
||||
|
||||
<string name="user_id_no_name">"<no name>"</string>
|
||||
<string name="none">"<none>"</string>
|
||||
|
Loading…
Reference in New Issue
Block a user