// Path: src/com/freiheit/gnupg/GnuPGGenkeyResult.java
// public class GnuPGGenkeyResult {
// 
//     private String _fpr;
//     private boolean _primary;
//     private boolean _sub;
// 
//     protected GnuPGGenkeyResult() {
//     }
// 
//     /**
//      * This is the fingerprint of the key that was created. If both a primary
//      * and a sub key were generated, the fingerprint of the primary key will be
//      * returned. If the crypto engine does not provide the fingerprint, `it will
//      * return a null pointer.
//      * 
//      * @return fingerprint of the created key
//      */
//     public String getFpr() {
//         return _fpr;
//     }
// 
//     /**
//      * This is a flag that is set to true if a primary key was created and to
//      * false if not.
//      * 
//      * @return flag, if a primary key was created
//      */
//     public boolean isPrimary() {
//         return _primary;
//     }
// 
//     /**
//      * This is a flag that is set to true if a subkey was created and to false
//      * if not.
//      * 
//      * @return flag, if a subkey was created
//      */
//     public boolean isSub() {
//         return _sub;
//     }
// }


import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.provider.ContactsContract.CommonDataKinds;
import android.provider.ContactsContract.Contacts;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.freiheit.gnupg.GnuPGGenkeyResult;
            Toast.makeText(this, getString(R.string.error_gen_key_failed), Toast.LENGTH_LONG)
                    .show();
        finish();
    }

    public class CreateKeyTask extends AsyncTask<String, String, Integer> {
        private ProgressDialog dialog;
        private Context context;

        public CreateKeyTask(Context c) {
            context = c;
            dialog = new ProgressDialog(context);
            dialog.setCancelable(false);
            dialog.setIndeterminate(true);
            dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
            dialog.setTitle(R.string.dialog_generating_new_key_title);
            dialog.setMessage(getString(R.string.generating_new_key_message));
        }

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            dialog.show();
        }

        @Override
        protected Integer doInBackground(String... params) {
            Log.i(TAG, "doInBackground: " + params[0]);
            try {
                GnuPG.context.genPgpKey(params[0]);
// Path: src/com/freiheit/gnupg/GnuPGGenkeyResult.java
// public class GnuPGGenkeyResult {
// 
//     private String _fpr;
//     private boolean _primary;
//     private boolean _sub;
// 
//     protected GnuPGGenkeyResult() {
//     }
// 
//     /**
//      * This is the fingerprint of the key that was created. If both a primary
//      * and a sub key were generated, the fingerprint of the primary key will be
//      * returned. If the crypto engine does not provide the fingerprint, `it will
//      * return a null pointer.
//      * 
//      * @return fingerprint of the created key
//      */
//     public String getFpr() {
//         return _fpr;
//     }
// 
//     /**
//      * This is a flag that is set to true if a primary key was created and to
//      * false if not.
//      * 
//      * @return flag, if a primary key was created
//      */
//     public boolean isPrimary() {
//         return _primary;
//     }
// 
//     /**
//      * This is a flag that is set to true if a subkey was created and to false
//      * if not.
//      * 
//      * @return flag, if a subkey was created
//      */
//     public boolean isSub() {
//         return _sub;
//     }
// }


// Path: src/info/guardianproject/gpg/CreateKeyActivity.java
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.provider.ContactsContract.CommonDataKinds;
import android.provider.ContactsContract.Contacts;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.freiheit.gnupg.GnuPGGenkeyResult;

            Toast.makeText(this, getString(R.string.error_gen_key_failed), Toast.LENGTH_LONG)
                    .show();
        finish();
    }

    public class CreateKeyTask extends AsyncTask<String, String, Integer> {
        private ProgressDialog dialog;
        private Context context;

        public CreateKeyTask(Context c) {
            context = c;
            dialog = new ProgressDialog(context);
            dialog.setCancelable(false);
            dialog.setIndeterminate(true);
            dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
            dialog.setTitle(R.string.dialog_generating_new_key_title);
            dialog.setMessage(getString(R.string.generating_new_key_message));
        }

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            dialog.show();
        }

        @Override
        protected Integer doInBackground(String... params) {
            Log.i(TAG, "doInBackground: " + params[0]);
            try {
                GnuPG.context.genPgpKey(params[0]);
                GnuPGGenkeyResult result = GnuPG.context.getGenkeyResult();