mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-30 12:32:17 -05:00
added an optional checkbox to the file dialog, can be used for instance to optionally delete files after importing them, and is used for that, also rearranged the option menu items for the main activity a little
Update issue 39 Added a new string: <string name="label_deleteAfterImport">Delete After Import</string>
This commit is contained in:
parent
c1d9bbc644
commit
368f0a122f
@ -18,10 +18,15 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="vertical"
|
||||||
android:paddingLeft="5dip"
|
android:paddingLeft="5dip"
|
||||||
android:paddingRight="5dip">
|
android:paddingRight="5dip">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/input"
|
android:id="@+id/input"
|
||||||
android:layout_width="0dip"
|
android:layout_width="0dip"
|
||||||
@ -32,6 +37,14 @@
|
|||||||
android:id="@+id/btn_browse"
|
android:id="@+id/btn_browse"
|
||||||
android:src="@drawable/ic_launcher_folder_small"
|
android:src="@drawable/ic_launcher_folder_small"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/checkbox"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"/>
|
android:layout_width="wrap_content"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -97,6 +97,7 @@
|
|||||||
<string name="label_selectPublicKeys">Public Key(s)</string>
|
<string name="label_selectPublicKeys">Public Key(s)</string>
|
||||||
<string name="label_deleteAfterEncryption">Delete After Encryption</string>
|
<string name="label_deleteAfterEncryption">Delete After Encryption</string>
|
||||||
<string name="label_deleteAfterDecryption">Delete After Decryption</string>
|
<string name="label_deleteAfterDecryption">Delete After Decryption</string>
|
||||||
|
<string name="label_deleteAfterImport">Delete After Import</string>
|
||||||
<string name="label_encryptionAlgorithm">Encryption Algorithm</string>
|
<string name="label_encryptionAlgorithm">Encryption Algorithm</string>
|
||||||
<string name="label_hashAlgorithm">Hash Algorithm</string>
|
<string name="label_hashAlgorithm">Hash Algorithm</string>
|
||||||
<string name="label_asymmetric">Public Key</string>
|
<string name="label_asymmetric">Public Key</string>
|
||||||
|
@ -659,9 +659,8 @@ public class DecryptActivity extends BaseActivity {
|
|||||||
getString(R.string.specifyFileToDecryptTo),
|
getString(R.string.specifyFileToDecryptTo),
|
||||||
mOutputFilename,
|
mOutputFilename,
|
||||||
new FileDialog.OnClickListener() {
|
new FileDialog.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onOkClick(String filename) {
|
public void onOkClick(String filename, boolean checked) {
|
||||||
removeDialog(Id.dialog.output_filename);
|
removeDialog(Id.dialog.output_filename);
|
||||||
mOutputFilename = filename;
|
mOutputFilename = filename;
|
||||||
decryptStart();
|
decryptStart();
|
||||||
@ -674,6 +673,7 @@ public class DecryptActivity extends BaseActivity {
|
|||||||
},
|
},
|
||||||
getString(R.string.filemanager_titleSave),
|
getString(R.string.filemanager_titleSave),
|
||||||
getString(R.string.filemanager_btnSave),
|
getString(R.string.filemanager_btnSave),
|
||||||
|
null,
|
||||||
Id.request.output_filename);
|
Id.request.output_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -904,9 +904,8 @@ public class EncryptActivity extends BaseActivity {
|
|||||||
getString(R.string.specifyFileToEncryptTo),
|
getString(R.string.specifyFileToEncryptTo),
|
||||||
mOutputFilename,
|
mOutputFilename,
|
||||||
new FileDialog.OnClickListener() {
|
new FileDialog.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onOkClick(String filename) {
|
public void onOkClick(String filename, boolean checked) {
|
||||||
removeDialog(Id.dialog.output_filename);
|
removeDialog(Id.dialog.output_filename);
|
||||||
mOutputFilename = filename;
|
mOutputFilename = filename;
|
||||||
encryptStart();
|
encryptStart();
|
||||||
@ -919,6 +918,7 @@ public class EncryptActivity extends BaseActivity {
|
|||||||
},
|
},
|
||||||
getString(R.string.filemanager_titleSave),
|
getString(R.string.filemanager_titleSave),
|
||||||
getString(R.string.filemanager_btnSave),
|
getString(R.string.filemanager_btnSave),
|
||||||
|
null,
|
||||||
Id.request.output_filename);
|
Id.request.output_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import android.content.Intent;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.CheckBox;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@ -32,6 +33,7 @@ import android.widget.Toast;
|
|||||||
public class FileDialog {
|
public class FileDialog {
|
||||||
private static EditText mFilename;
|
private static EditText mFilename;
|
||||||
private static ImageButton mBrowse;
|
private static ImageButton mBrowse;
|
||||||
|
private static CheckBox mCheckBox;
|
||||||
private static Activity mActivity;
|
private static Activity mActivity;
|
||||||
private static String mFileManagerTitle;
|
private static String mFileManagerTitle;
|
||||||
private static String mFileManagerButton;
|
private static String mFileManagerButton;
|
||||||
@ -39,12 +41,13 @@ public class FileDialog {
|
|||||||
|
|
||||||
public static interface OnClickListener {
|
public static interface OnClickListener {
|
||||||
public void onCancelClick();
|
public void onCancelClick();
|
||||||
public void onOkClick(String filename);
|
public void onOkClick(String filename, boolean checkbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AlertDialog build(Activity activity, String title, String message,
|
public static AlertDialog build(Activity activity, String title, String message,
|
||||||
String defaultFile, OnClickListener onClickListener,
|
String defaultFile, OnClickListener onClickListener,
|
||||||
String fileManagerTitle, String fileManagerButton,
|
String fileManagerTitle, String fileManagerButton,
|
||||||
|
String checkboxText,
|
||||||
int requestCode) {
|
int requestCode) {
|
||||||
// TODO: fileManagerTitle and fileManagerButton are deprecated, no use for them right now,
|
// TODO: fileManagerTitle and fileManagerButton are deprecated, no use for them right now,
|
||||||
// but maybe the Intent now used will someday support them again, so leaving them in
|
// but maybe the Intent now used will someday support them again, so leaving them in
|
||||||
@ -70,6 +73,15 @@ public class FileDialog {
|
|||||||
mFileManagerTitle = fileManagerTitle;
|
mFileManagerTitle = fileManagerTitle;
|
||||||
mFileManagerButton = fileManagerButton;
|
mFileManagerButton = fileManagerButton;
|
||||||
mRequestCode = requestCode;
|
mRequestCode = requestCode;
|
||||||
|
mCheckBox = (CheckBox) view.findViewById(R.id.checkbox);
|
||||||
|
if (checkboxText == null) {
|
||||||
|
mCheckBox.setEnabled(false);
|
||||||
|
mCheckBox.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
mCheckBox.setEnabled(true);
|
||||||
|
mCheckBox.setVisibility(View.VISIBLE);
|
||||||
|
mCheckBox.setText(checkboxText);
|
||||||
|
}
|
||||||
|
|
||||||
alert.setView(view);
|
alert.setView(view);
|
||||||
|
|
||||||
@ -77,7 +89,12 @@ public class FileDialog {
|
|||||||
|
|
||||||
alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
clickListener.onOkClick(mFilename.getText().toString());
|
boolean checked = false;
|
||||||
|
if (mCheckBox.isEnabled()) {
|
||||||
|
checked = mCheckBox.isChecked();
|
||||||
|
}
|
||||||
|
clickListener.onOkClick(mFilename.getText().toString(),
|
||||||
|
checked);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ public class KeyListActivity extends BaseActivity {
|
|||||||
protected String mExportFilename = Constants.path.app_dir + "/";
|
protected String mExportFilename = Constants.path.app_dir + "/";
|
||||||
|
|
||||||
protected String mImportData;
|
protected String mImportData;
|
||||||
|
protected boolean mDeleteAfterImport = false;
|
||||||
|
|
||||||
protected int mKeyType = Id.type.public_key;
|
protected int mKeyType = Id.type.public_key;
|
||||||
|
|
||||||
@ -234,8 +235,9 @@ public class KeyListActivity extends BaseActivity {
|
|||||||
new FileDialog.OnClickListener() {
|
new FileDialog.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onOkClick(String filename) {
|
public void onOkClick(String filename, boolean checked) {
|
||||||
removeDialog(Id.dialog.import_keys);
|
removeDialog(Id.dialog.import_keys);
|
||||||
|
mDeleteAfterImport = checked;
|
||||||
mImportFilename = filename;
|
mImportFilename = filename;
|
||||||
importKeys();
|
importKeys();
|
||||||
}
|
}
|
||||||
@ -247,6 +249,7 @@ public class KeyListActivity extends BaseActivity {
|
|||||||
},
|
},
|
||||||
getString(R.string.filemanager_titleOpen),
|
getString(R.string.filemanager_titleOpen),
|
||||||
getString(R.string.filemanager_btnOpen),
|
getString(R.string.filemanager_btnOpen),
|
||||||
|
getString(R.string.label_deleteAfterImport),
|
||||||
Id.request.filename);
|
Id.request.filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,7 +272,7 @@ public class KeyListActivity extends BaseActivity {
|
|||||||
mExportFilename,
|
mExportFilename,
|
||||||
new FileDialog.OnClickListener() {
|
new FileDialog.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onOkClick(String filename) {
|
public void onOkClick(String filename, boolean checked) {
|
||||||
removeDialog(thisDialogId);
|
removeDialog(thisDialogId);
|
||||||
mExportFilename = filename;
|
mExportFilename = filename;
|
||||||
exportKeys();
|
exportKeys();
|
||||||
@ -282,6 +285,7 @@ public class KeyListActivity extends BaseActivity {
|
|||||||
},
|
},
|
||||||
getString(R.string.filemanager_titleSave),
|
getString(R.string.filemanager_titleSave),
|
||||||
getString(R.string.filemanager_btnSave),
|
getString(R.string.filemanager_btnSave),
|
||||||
|
null,
|
||||||
Id.request.filename);
|
Id.request.filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,6 +413,11 @@ public class KeyListActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
Toast.makeText(KeyListActivity.this, message,
|
Toast.makeText(KeyListActivity.this, message,
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
|
// everything went well, so now delete, if that was turned on
|
||||||
|
if (mDeleteAfterImport) {
|
||||||
|
setDeleteFile(mImportFilename);
|
||||||
|
showDialog(Id.dialog.delete_file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
refreshList();
|
refreshList();
|
||||||
break;
|
break;
|
||||||
|
@ -275,12 +275,12 @@ public class MainActivity extends BaseActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
menu.add(0, Id.menu.option.create, 0, R.string.menu_addAccount)
|
menu.add(0, Id.menu.option.manage_public_keys, 0, R.string.menu_managePublicKeys)
|
||||||
|
.setIcon(android.R.drawable.ic_menu_manage);
|
||||||
|
menu.add(0, Id.menu.option.manage_secret_keys, 1, R.string.menu_manageSecretKeys)
|
||||||
|
.setIcon(android.R.drawable.ic_menu_manage);
|
||||||
|
menu.add(1, Id.menu.option.create, 2, R.string.menu_addAccount)
|
||||||
.setIcon(android.R.drawable.ic_menu_add);
|
.setIcon(android.R.drawable.ic_menu_add);
|
||||||
menu.add(1, Id.menu.option.manage_public_keys, 1, R.string.menu_managePublicKeys)
|
|
||||||
.setIcon(android.R.drawable.ic_menu_manage);
|
|
||||||
menu.add(1, Id.menu.option.manage_secret_keys, 2, R.string.menu_manageSecretKeys)
|
|
||||||
.setIcon(android.R.drawable.ic_menu_manage);
|
|
||||||
menu.add(2, Id.menu.option.preferences, 3, R.string.menu_preferences)
|
menu.add(2, Id.menu.option.preferences, 3, R.string.menu_preferences)
|
||||||
.setIcon(android.R.drawable.ic_menu_preferences);
|
.setIcon(android.R.drawable.ic_menu_preferences);
|
||||||
menu.add(2, Id.menu.option.about, 4, R.string.menu_about)
|
menu.add(2, Id.menu.option.about, 4, R.string.menu_about)
|
||||||
|
Loading…
Reference in New Issue
Block a user