#226: Activity no longer closes if progress is canceled for key creation in EditKeyActivity

This commit is contained in:
Jessica Yuen 2014-03-02 17:33:21 -05:00
parent 1baae3775e
commit 91a2ecb15c
5 changed files with 17 additions and 10 deletions

View File

@ -57,14 +57,15 @@ public class KeychainIntentServiceHandler extends Handler {
}
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,
int progressDialogStyle, boolean cancelable) {
int progressDialogStyle, boolean cancelable,
boolean finishActivityOnCancel) {
this.mActivity = activity;
this.mProgressDialogFragment = ProgressDialogFragment.newInstance(progressDialogMessageId,
progressDialogStyle, cancelable);
progressDialogStyle, cancelable, finishActivityOnCancel);
}
public void showProgressDialog(FragmentActivity activity) {

View File

@ -185,7 +185,7 @@ public class EditKeyActivity extends ActionBarActivity {
// Message is received after generating is done in ApgService
KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(
this, R.string.progress_generating, ProgressDialog.STYLE_SPINNER, true) {
this, R.string.progress_generating, ProgressDialog.STYLE_SPINNER, true, true) {
@Override
public void handleMessage(Message message) {

View File

@ -83,7 +83,7 @@ public class DeleteFileDialogFragment extends DialogFragment {
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
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
KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(activity, deletingDialog) {

View File

@ -32,6 +32,7 @@ public class ProgressDialogFragment extends DialogFragment {
private static final String ARG_MESSAGE_ID = "message_id";
private static final String ARG_STYLE = "style";
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
@ -41,13 +42,14 @@ public class ProgressDialogFragment extends DialogFragment {
* @param cancelable
* @return
*/
public static ProgressDialogFragment newInstance(int messageId, int style,
boolean cancelable) {
public static ProgressDialogFragment newInstance(int messageId, int style, boolean cancelable,
boolean finishActivityOnCancel) {
ProgressDialogFragment frag = new ProgressDialogFragment();
Bundle args = new Bundle();
args.putInt(ARG_MESSAGE_ID, messageId);
args.putInt(ARG_STYLE, style);
args.putBoolean(ARG_CANCELABLE, cancelable);
args.putBoolean(ARG_FINISH_ON_CANCEL, finishActivityOnCancel);
frag.setArguments(args);
return frag;
@ -118,8 +120,12 @@ public class ProgressDialogFragment extends DialogFragment {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
activity.setResult(Activity.RESULT_CANCELED);
activity.finish();
boolean finishActivity = getArguments().getBoolean(ARG_FINISH_ON_CANCEL);
if (finishActivity) {
activity.setResult(Activity.RESULT_CANCELED);
activity.finish();
}
}
});
}

View File

@ -238,7 +238,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
// show progress dialog
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
KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(mActivity,