mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 19:22:14 -05:00
Fix progress_generating and reformat
This commit is contained in:
parent
da83c8ff60
commit
be41a0a3e1
@ -597,9 +597,11 @@ public class KeychainIntentService extends IntentService implements ProgressDial
|
||||
|
||||
/* Operation */
|
||||
int keysTotal = 2;
|
||||
int keysCreated =0;
|
||||
setProgress(getApplicationContext().getResources().getQuantityString(R.plurals.progress_generating,keysTotal),
|
||||
keysCreated, keysTotal);
|
||||
int keysCreated = 0;
|
||||
setProgress(
|
||||
getResources().getQuantityString(R.plurals.progress_generating, keysTotal),
|
||||
keysCreated,
|
||||
keysTotal);
|
||||
PgpKeyOperation keyOperations = new PgpKeyOperation(this, this);
|
||||
|
||||
PGPSecretKey masterKey = keyOperations.createKey(Id.choice.algorithm.rsa,
|
||||
@ -610,7 +612,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial
|
||||
PGPSecretKey subKey = keyOperations.createKey(Id.choice.algorithm.rsa,
|
||||
4096, passphrase, false);
|
||||
keysCreated++;
|
||||
setProgress(keysCreated, keysTotal );
|
||||
setProgress(keysCreated, keysTotal);
|
||||
|
||||
// TODO: default to one master for cert, one sub for encrypt and one sub
|
||||
// for sign
|
||||
|
@ -55,6 +55,10 @@ public class KeychainIntentServiceHandler extends Handler {
|
||||
this.mProgressDialogFragment = progressDialogFragment;
|
||||
}
|
||||
|
||||
public KeychainIntentServiceHandler(Activity activity, String progressDialogMessage, int progressDialogStyle) {
|
||||
this(activity, progressDialogMessage, progressDialogStyle, false, null);
|
||||
}
|
||||
|
||||
public KeychainIntentServiceHandler(Activity activity, int progressDialogMessageId, int progressDialogStyle) {
|
||||
this(activity, progressDialogMessageId, progressDialogStyle, false, null);
|
||||
}
|
||||
@ -62,9 +66,22 @@ public class KeychainIntentServiceHandler extends Handler {
|
||||
public KeychainIntentServiceHandler(Activity activity, int progressDialogMessageId,
|
||||
int progressDialogStyle, boolean cancelable,
|
||||
OnCancelListener onCancelListener) {
|
||||
this(activity,
|
||||
activity.getString(progressDialogMessageId),
|
||||
progressDialogStyle,
|
||||
cancelable,
|
||||
onCancelListener);
|
||||
}
|
||||
|
||||
public KeychainIntentServiceHandler(Activity activity, String progressDialogMessage,
|
||||
int progressDialogStyle, boolean cancelable,
|
||||
OnCancelListener onCancelListener) {
|
||||
this.mActivity = activity;
|
||||
this.mProgressDialogFragment = ProgressDialogFragment.newInstance(progressDialogMessageId,
|
||||
progressDialogStyle, cancelable, onCancelListener);
|
||||
this.mProgressDialogFragment = ProgressDialogFragment.newInstance(
|
||||
progressDialogMessage,
|
||||
progressDialogStyle,
|
||||
cancelable,
|
||||
onCancelListener);
|
||||
}
|
||||
|
||||
public void showProgressDialog(FragmentActivity activity) {
|
||||
|
@ -187,7 +187,8 @@ 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_HORIZONTAL, true,
|
||||
this, getResources().getQuantityString(R.plurals.progress_generating, 1),
|
||||
ProgressDialog.STYLE_HORIZONTAL, true,
|
||||
|
||||
new DialogInterface.OnCancelListener() {
|
||||
@Override
|
||||
|
@ -83,7 +83,10 @@ public class DeleteFileDialogFragment extends DialogFragment {
|
||||
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
|
||||
|
||||
ProgressDialogFragment deletingDialog = ProgressDialogFragment.newInstance(
|
||||
R.string.progress_deleting_securely, ProgressDialog.STYLE_HORIZONTAL, false, null);
|
||||
getString(R.string.progress_deleting_securely),
|
||||
ProgressDialog.STYLE_HORIZONTAL,
|
||||
false,
|
||||
null);
|
||||
|
||||
// Message is received after deleting is done in ApgService
|
||||
KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(activity, deletingDialog) {
|
||||
|
@ -30,7 +30,7 @@ import android.view.KeyEvent;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
|
||||
public class ProgressDialogFragment extends DialogFragment {
|
||||
private static final String ARG_MESSAGE_ID = "message_id";
|
||||
private static final String ARG_MESSAGE = "message_id";
|
||||
private static final String ARG_STYLE = "style";
|
||||
private static final String ARG_CANCELABLE = "cancelable";
|
||||
|
||||
@ -39,16 +39,16 @@ public class ProgressDialogFragment extends DialogFragment {
|
||||
/**
|
||||
* Creates new instance of this fragment
|
||||
*
|
||||
* @param messageId
|
||||
* @param message
|
||||
* @param style
|
||||
* @param cancelable
|
||||
* @return
|
||||
*/
|
||||
public static ProgressDialogFragment newInstance(int messageId, int style, boolean cancelable,
|
||||
public static ProgressDialogFragment newInstance(String message, int style, boolean cancelable,
|
||||
OnCancelListener onCancelListener) {
|
||||
ProgressDialogFragment frag = new ProgressDialogFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(ARG_MESSAGE_ID, messageId);
|
||||
args.putString(ARG_MESSAGE, message);
|
||||
args.putInt(ARG_STYLE, style);
|
||||
args.putBoolean(ARG_CANCELABLE, cancelable);
|
||||
|
||||
@ -117,11 +117,11 @@ public class ProgressDialogFragment extends DialogFragment {
|
||||
dialog.setCancelable(false);
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
|
||||
int messageId = getArguments().getInt(ARG_MESSAGE_ID);
|
||||
String message = getArguments().getString(ARG_MESSAGE);
|
||||
int style = getArguments().getInt(ARG_STYLE);
|
||||
boolean cancelable = getArguments().getBoolean(ARG_CANCELABLE);
|
||||
|
||||
dialog.setMessage(getString(messageId));
|
||||
dialog.setMessage(message);
|
||||
dialog.setProgressStyle(style);
|
||||
|
||||
if (cancelable) {
|
||||
|
@ -80,19 +80,19 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
public void setType(int type) {
|
||||
mType = type;
|
||||
switch (type) {
|
||||
case Id.type.user_id: {
|
||||
mTitle.setText(R.string.section_user_ids);
|
||||
break;
|
||||
}
|
||||
case Id.type.user_id: {
|
||||
mTitle.setText(R.string.section_user_ids);
|
||||
break;
|
||||
}
|
||||
|
||||
case Id.type.key: {
|
||||
mTitle.setText(R.string.section_keys);
|
||||
break;
|
||||
}
|
||||
case Id.type.key: {
|
||||
mTitle.setText(R.string.section_keys);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,7 +103,9 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
mInflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
@ -121,7 +123,9 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
super.onFinishInflate();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void onDeleted(Editor editor) {
|
||||
this.updateEditorsVisible();
|
||||
}
|
||||
@ -131,38 +135,40 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
mEditors.setVisibility(hasChildren ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void onClick(View v) {
|
||||
if (canEdit) {
|
||||
switch (mType) {
|
||||
case Id.type.user_id: {
|
||||
UserIdEditor view = (UserIdEditor) mInflater.inflate(
|
||||
R.layout.edit_key_user_id_item, mEditors, false);
|
||||
view.setEditorListener(this);
|
||||
if (mEditors.getChildCount() == 0) {
|
||||
view.setIsMainUserId(true);
|
||||
}
|
||||
mEditors.addView(view);
|
||||
break;
|
||||
}
|
||||
|
||||
case Id.type.key: {
|
||||
CreateKeyDialogFragment mCreateKeyDialogFragment = CreateKeyDialogFragment.newInstance(mEditors.getChildCount());
|
||||
mCreateKeyDialogFragment.setOnAlgorithmSelectedListener(new CreateKeyDialogFragment.OnAlgorithmSelectedListener() {
|
||||
@Override
|
||||
public void onAlgorithmSelected(Choice algorithmChoice, int keySize) {
|
||||
mNewKeyAlgorithmChoice = algorithmChoice;
|
||||
mNewKeySize = keySize;
|
||||
createKey();
|
||||
case Id.type.user_id: {
|
||||
UserIdEditor view = (UserIdEditor) mInflater.inflate(
|
||||
R.layout.edit_key_user_id_item, mEditors, false);
|
||||
view.setEditorListener(this);
|
||||
if (mEditors.getChildCount() == 0) {
|
||||
view.setIsMainUserId(true);
|
||||
}
|
||||
});
|
||||
mCreateKeyDialogFragment.show(mActivity.getSupportFragmentManager(), "createKeyDialog");
|
||||
break;
|
||||
}
|
||||
mEditors.addView(view);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
case Id.type.key: {
|
||||
CreateKeyDialogFragment mCreateKeyDialogFragment = CreateKeyDialogFragment.newInstance(mEditors.getChildCount());
|
||||
mCreateKeyDialogFragment.setOnAlgorithmSelectedListener(new CreateKeyDialogFragment.OnAlgorithmSelectedListener() {
|
||||
@Override
|
||||
public void onAlgorithmSelected(Choice algorithmChoice, int keySize) {
|
||||
mNewKeyAlgorithmChoice = algorithmChoice;
|
||||
mNewKeySize = keySize;
|
||||
createKey();
|
||||
}
|
||||
});
|
||||
mCreateKeyDialogFragment.show(mActivity.getSupportFragmentManager(), "createKeyDialog");
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.updateEditorsVisible();
|
||||
}
|
||||
@ -238,13 +244,16 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
|
||||
|
||||
// show progress dialog
|
||||
mGeneratingDialog = ProgressDialogFragment.newInstance(R.string.progress_generating,
|
||||
ProgressDialog.STYLE_SPINNER, true, new DialogInterface.OnCancelListener() {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
mActivity.stopService(intent);
|
||||
}
|
||||
});
|
||||
mGeneratingDialog = ProgressDialogFragment.newInstance(
|
||||
getResources().getQuantityString(R.plurals.progress_generating, 1),
|
||||
ProgressDialog.STYLE_SPINNER,
|
||||
true,
|
||||
new DialogInterface.OnCancelListener() {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
mActivity.stopService(intent);
|
||||
}
|
||||
});
|
||||
|
||||
// Message is received after generating is done in ApgService
|
||||
KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(mActivity,
|
||||
|
Loading…
Reference in New Issue
Block a user