mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -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"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="5dip"
|
||||
android:paddingRight="5dip">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/input"
|
||||
android:layout_width="0dip"
|
||||
@ -32,6 +37,14 @@
|
||||
android:id="@+id/btn_browse"
|
||||
android:src="@drawable/ic_launcher_folder_small"
|
||||
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"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -97,6 +97,7 @@
|
||||
<string name="label_selectPublicKeys">Public Key(s)</string>
|
||||
<string name="label_deleteAfterEncryption">Delete After Encryption</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_hashAlgorithm">Hash Algorithm</string>
|
||||
<string name="label_asymmetric">Public Key</string>
|
||||
|
@ -659,9 +659,8 @@ public class DecryptActivity extends BaseActivity {
|
||||
getString(R.string.specifyFileToDecryptTo),
|
||||
mOutputFilename,
|
||||
new FileDialog.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onOkClick(String filename) {
|
||||
public void onOkClick(String filename, boolean checked) {
|
||||
removeDialog(Id.dialog.output_filename);
|
||||
mOutputFilename = filename;
|
||||
decryptStart();
|
||||
@ -674,6 +673,7 @@ public class DecryptActivity extends BaseActivity {
|
||||
},
|
||||
getString(R.string.filemanager_titleSave),
|
||||
getString(R.string.filemanager_btnSave),
|
||||
null,
|
||||
Id.request.output_filename);
|
||||
}
|
||||
|
||||
|
@ -904,9 +904,8 @@ public class EncryptActivity extends BaseActivity {
|
||||
getString(R.string.specifyFileToEncryptTo),
|
||||
mOutputFilename,
|
||||
new FileDialog.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onOkClick(String filename) {
|
||||
public void onOkClick(String filename, boolean checked) {
|
||||
removeDialog(Id.dialog.output_filename);
|
||||
mOutputFilename = filename;
|
||||
encryptStart();
|
||||
@ -919,6 +918,7 @@ public class EncryptActivity extends BaseActivity {
|
||||
},
|
||||
getString(R.string.filemanager_titleSave),
|
||||
getString(R.string.filemanager_btnSave),
|
||||
null,
|
||||
Id.request.output_filename);
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.Toast;
|
||||
@ -32,6 +33,7 @@ import android.widget.Toast;
|
||||
public class FileDialog {
|
||||
private static EditText mFilename;
|
||||
private static ImageButton mBrowse;
|
||||
private static CheckBox mCheckBox;
|
||||
private static Activity mActivity;
|
||||
private static String mFileManagerTitle;
|
||||
private static String mFileManagerButton;
|
||||
@ -39,12 +41,13 @@ public class FileDialog {
|
||||
|
||||
public static interface OnClickListener {
|
||||
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,
|
||||
String defaultFile, OnClickListener onClickListener,
|
||||
String fileManagerTitle, String fileManagerButton,
|
||||
String checkboxText,
|
||||
int requestCode) {
|
||||
// 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
|
||||
@ -70,6 +73,15 @@ public class FileDialog {
|
||||
mFileManagerTitle = fileManagerTitle;
|
||||
mFileManagerButton = fileManagerButton;
|
||||
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);
|
||||
|
||||
@ -77,7 +89,12 @@ public class FileDialog {
|
||||
|
||||
alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
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 mImportData;
|
||||
protected boolean mDeleteAfterImport = false;
|
||||
|
||||
protected int mKeyType = Id.type.public_key;
|
||||
|
||||
@ -234,8 +235,9 @@ public class KeyListActivity extends BaseActivity {
|
||||
new FileDialog.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onOkClick(String filename) {
|
||||
public void onOkClick(String filename, boolean checked) {
|
||||
removeDialog(Id.dialog.import_keys);
|
||||
mDeleteAfterImport = checked;
|
||||
mImportFilename = filename;
|
||||
importKeys();
|
||||
}
|
||||
@ -247,6 +249,7 @@ public class KeyListActivity extends BaseActivity {
|
||||
},
|
||||
getString(R.string.filemanager_titleOpen),
|
||||
getString(R.string.filemanager_btnOpen),
|
||||
getString(R.string.label_deleteAfterImport),
|
||||
Id.request.filename);
|
||||
}
|
||||
|
||||
@ -269,7 +272,7 @@ public class KeyListActivity extends BaseActivity {
|
||||
mExportFilename,
|
||||
new FileDialog.OnClickListener() {
|
||||
@Override
|
||||
public void onOkClick(String filename) {
|
||||
public void onOkClick(String filename, boolean checked) {
|
||||
removeDialog(thisDialogId);
|
||||
mExportFilename = filename;
|
||||
exportKeys();
|
||||
@ -282,6 +285,7 @@ public class KeyListActivity extends BaseActivity {
|
||||
},
|
||||
getString(R.string.filemanager_titleSave),
|
||||
getString(R.string.filemanager_btnSave),
|
||||
null,
|
||||
Id.request.filename);
|
||||
}
|
||||
|
||||
@ -409,6 +413,11 @@ public class KeyListActivity extends BaseActivity {
|
||||
}
|
||||
Toast.makeText(KeyListActivity.this, message,
|
||||
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();
|
||||
break;
|
||||
|
@ -275,12 +275,12 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
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);
|
||||
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)
|
||||
.setIcon(android.R.drawable.ic_menu_preferences);
|
||||
menu.add(2, Id.menu.option.about, 4, R.string.menu_about)
|
||||
|
Loading…
Reference in New Issue
Block a user