Fix progress_generating and reformat

This commit is contained in:
Dominik Schürmann 2014-03-10 22:19:43 +01:00
parent da83c8ff60
commit be41a0a3e1
6 changed files with 94 additions and 62 deletions

View File

@ -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

View File

@ -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) {

View File

@ -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

View File

@ -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) {

View File

@ -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) {

View File

@ -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,7 +135,9 @@ 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) {
@ -238,8 +244,11 @@ 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() {
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);