mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-07 10:30:14 -05:00
#226: Activity no longer closes if progress is canceled for key creation in EditKeyActivity
This commit is contained in:
parent
1baae3775e
commit
91a2ecb15c
@ -57,14 +57,15 @@ public class KeychainIntentServiceHandler extends Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public KeychainIntentServiceHandler(Activity activity, int progressDialogMessageId, int progressDialogStyle) {
|
public KeychainIntentServiceHandler(Activity activity, int progressDialogMessageId, int progressDialogStyle) {
|
||||||
this(activity, progressDialogMessageId, progressDialogStyle, false);
|
this(activity, progressDialogMessageId, progressDialogStyle, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeychainIntentServiceHandler(Activity activity, int progressDialogMessageId,
|
public KeychainIntentServiceHandler(Activity activity, int progressDialogMessageId,
|
||||||
int progressDialogStyle, boolean cancelable) {
|
int progressDialogStyle, boolean cancelable,
|
||||||
|
boolean finishActivityOnCancel) {
|
||||||
this.mActivity = activity;
|
this.mActivity = activity;
|
||||||
this.mProgressDialogFragment = ProgressDialogFragment.newInstance(progressDialogMessageId,
|
this.mProgressDialogFragment = ProgressDialogFragment.newInstance(progressDialogMessageId,
|
||||||
progressDialogStyle, cancelable);
|
progressDialogStyle, cancelable, finishActivityOnCancel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showProgressDialog(FragmentActivity activity) {
|
public void showProgressDialog(FragmentActivity activity) {
|
||||||
|
@ -185,7 +185,7 @@ public class EditKeyActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
// Message is received after generating is done in ApgService
|
// Message is received after generating is done in ApgService
|
||||||
KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(
|
KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(
|
||||||
this, R.string.progress_generating, ProgressDialog.STYLE_SPINNER, true) {
|
this, R.string.progress_generating, ProgressDialog.STYLE_SPINNER, true, true) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message message) {
|
public void handleMessage(Message message) {
|
||||||
|
@ -83,7 +83,7 @@ public class DeleteFileDialogFragment extends DialogFragment {
|
|||||||
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
|
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
|
||||||
|
|
||||||
ProgressDialogFragment deletingDialog = ProgressDialogFragment.newInstance(
|
ProgressDialogFragment deletingDialog = ProgressDialogFragment.newInstance(
|
||||||
R.string.progress_deleting_securely, ProgressDialog.STYLE_HORIZONTAL, false);
|
R.string.progress_deleting_securely, ProgressDialog.STYLE_HORIZONTAL, false, false);
|
||||||
|
|
||||||
// Message is received after deleting is done in ApgService
|
// Message is received after deleting is done in ApgService
|
||||||
KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(activity, deletingDialog) {
|
KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(activity, deletingDialog) {
|
||||||
|
@ -32,6 +32,7 @@ public class ProgressDialogFragment extends DialogFragment {
|
|||||||
private static final String ARG_MESSAGE_ID = "message_id";
|
private static final String ARG_MESSAGE_ID = "message_id";
|
||||||
private static final String ARG_STYLE = "style";
|
private static final String ARG_STYLE = "style";
|
||||||
private static final String ARG_CANCELABLE = "cancelable";
|
private static final String ARG_CANCELABLE = "cancelable";
|
||||||
|
private static final String ARG_FINISH_ON_CANCEL = "finish_activity_on_cancel";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new instance of this fragment
|
* Creates new instance of this fragment
|
||||||
@ -41,13 +42,14 @@ public class ProgressDialogFragment extends DialogFragment {
|
|||||||
* @param cancelable
|
* @param cancelable
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static ProgressDialogFragment newInstance(int messageId, int style,
|
public static ProgressDialogFragment newInstance(int messageId, int style, boolean cancelable,
|
||||||
boolean cancelable) {
|
boolean finishActivityOnCancel) {
|
||||||
ProgressDialogFragment frag = new ProgressDialogFragment();
|
ProgressDialogFragment frag = new ProgressDialogFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt(ARG_MESSAGE_ID, messageId);
|
args.putInt(ARG_MESSAGE_ID, messageId);
|
||||||
args.putInt(ARG_STYLE, style);
|
args.putInt(ARG_STYLE, style);
|
||||||
args.putBoolean(ARG_CANCELABLE, cancelable);
|
args.putBoolean(ARG_CANCELABLE, cancelable);
|
||||||
|
args.putBoolean(ARG_FINISH_ON_CANCEL, finishActivityOnCancel);
|
||||||
|
|
||||||
frag.setArguments(args);
|
frag.setArguments(args);
|
||||||
return frag;
|
return frag;
|
||||||
@ -118,9 +120,13 @@ public class ProgressDialogFragment extends DialogFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
dialog.cancel();
|
dialog.cancel();
|
||||||
|
|
||||||
|
boolean finishActivity = getArguments().getBoolean(ARG_FINISH_ON_CANCEL);
|
||||||
|
if (finishActivity) {
|
||||||
activity.setResult(Activity.RESULT_CANCELED);
|
activity.setResult(Activity.RESULT_CANCELED);
|
||||||
activity.finish();
|
activity.finish();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
|||||||
|
|
||||||
// show progress dialog
|
// show progress dialog
|
||||||
mGeneratingDialog = ProgressDialogFragment.newInstance(R.string.progress_generating,
|
mGeneratingDialog = ProgressDialogFragment.newInstance(R.string.progress_generating,
|
||||||
ProgressDialog.STYLE_SPINNER, true);
|
ProgressDialog.STYLE_SPINNER, true, false);
|
||||||
|
|
||||||
// Message is received after generating is done in ApgService
|
// Message is received after generating is done in ApgService
|
||||||
KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(mActivity,
|
KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(mActivity,
|
||||||
|
Loading…
Reference in New Issue
Block a user