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