Projects >> open-keychain >>a85ae5e0092057d1007ba62fada17c9f6a085c92

Chunk
Conflicting content
    protected static HashMap mSecretKeyIdToIdMap;
                            Pattern.DOTALL);

    public static Pattern PGP_SIGNED_MESSAGE =
<<<<<<< HEAD
        Pattern.compile(".*?(-----BEGIN PGP SIGNED MESSAGE-----.*?-----BEGIN PGP SIGNATURE-----.*?-----END PGP SIGNATURE-----).*",
                        Pattern.DOTALL);

    protected static boolean mInitialized = false;

    protected static HashMap mSecretKeyIdToKeyRingMap;
    protected static HashMap mPublicKeyIdToIdMap;
    protected static HashMap mPublicKeyIdToKeyRingMap;

    public static final String PUBLIC_KEY_PROJECTION[] =
            new String[] {
                    PublicKeys._ID,
                    PublicKeys.KEY_ID,
                    PublicKeys.KEY_DATA,
                    PublicKeys.WHO_ID, };
    public static final String SECRET_KEY_PROJECTION[] =
            new String[] {
                    PublicKeys._ID,
                    PublicKeys.KEY_ID,
                    PublicKeys.KEY_DATA,
                    PublicKeys.WHO_ID, };
=======
            Pattern.compile(".*?(-----BEGIN PGP SIGNED MESSAGE-----.*?-----BEGIN PGP SIGNATURE-----.*?-----END PGP SIGNATURE-----).*",
                            Pattern.DOTALL);
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4

    private static HashMap mPassPhraseCache =
            new HashMap();
Solution content
                            Pattern.DOTALL);

    public static Pattern PGP_SIGNED_MESSAGE =
            Pattern.compile(".*?(-----BEGIN PGP SIGNED MESSAGE-----.*?-----BEGIN PGP SIGNATURE-----.*?-----END PGP SIGNATURE-----).*",
                            Pattern.DOTALL);

    private static HashMap mPassPhraseCache =
            new HashMap();
File
Apg.java
Developer's decision
Version 2
Kind of conflict
Attribute
Method invocation
Chunk
Conflicting content
        public static final String ENCRYPT = "org.thialfihar.android.apg.intent.ENCRYPT";
        public static final String DECRYPT_FILE = "org.thialfihar.android.apg.intent.DECRYPT_FILE";
        public static final String ENCRYPT_FILE = "org.thialfihar.android.apg.intent.ENCRYPT_FILE";
<<<<<<< HEAD
    }

    public static String VERSION = "0.9.5";
=======
        public static final String DECRYPT_AND_RETURN = "org.thialfihar.android.apg.intent.DECRYPT_AND_RETURN";
        public static final String ENCRYPT_AND_RETURN = "org.thialfihar.android.apg.intent.ENCRYPT_AND_RETURN";
        public static final String SELECT_PUBLIC_KEYS = "org.thialfihar.android.apg.intent.SELECT_PUBLIC_KEYS";
        public static final String SELECT_SECRET_KEY = "org.thialfihar.android.apg.intent.SELECT_SECRET_KEY";
    }

    public static final String EXTRA_DATA = "data";
    public static final String EXTRA_STATUS = "status";
    public static final String EXTRA_ERROR = "error";
    public static final String EXTRA_DECRYPTED_MESSAGE = "decryptedMessage";
    public static final String EXTRA_ENCRYPTED_MESSAGE = "decryptedMessage";
    public static final String EXTRA_SIGNATURE = "signature";
    public static final String EXTRA_SIGNATURE_KEY_ID = "signatureKeyId";
    public static final String EXTRA_SIGNATURE_USER_ID = "signatureUserId";
    public static final String EXTRA_SIGNATURE_SUCCESS = "signatureSuccess";
    public static final String EXTRA_SIGNATURE_UNKNOWN = "signatureUnknown";
    public static final String EXTRA_USER_ID = "userId";
    public static final String EXTRA_KEY_ID = "keyId";
    public static final String EXTRA_REPLY_TO = "replyTo";
    public static final String EXTRA_SEND_TO = "sendTo";
    public static final String EXTRA_SUBJECT = "subject";
    public static final String EXTRA_ENCRYPTION_KEY_IDS = "encryptionKeyIds";
    public static final String EXTRA_SELECTION = "selection";
    public static final String EXTRA_MESSAGE = "message";
    public static final String EXTRA_PROGRESS = "progress";
    public static final String EXTRA_MAX = "max";
    public static final String EXTRA_ACCOUNT = "account";

    public static String VERSION = "1.0.1";
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
    public static String FULL_VERSION = "APG v" + VERSION;

    private static final int[] PREFERRED_SYMMETRIC_ALGORITHMS =
Solution content
        public static final String ENCRYPT = "org.thialfihar.android.apg.intent.ENCRYPT";
        public static final String DECRYPT_FILE = "org.thialfihar.android.apg.intent.DECRYPT_FILE";
        public static final String ENCRYPT_FILE = "org.thialfihar.android.apg.intent.ENCRYPT_FILE";
        public static final String DECRYPT_AND_RETURN = "org.thialfihar.android.apg.intent.DECRYPT_AND_RETURN";
        public static final String ENCRYPT_AND_RETURN = "org.thialfihar.android.apg.intent.ENCRYPT_AND_RETURN";
        public static final String SELECT_PUBLIC_KEYS = "org.thialfihar.android.apg.intent.SELECT_PUBLIC_KEYS";
        public static final String SELECT_SECRET_KEY = "org.thialfihar.android.apg.intent.SELECT_SECRET_KEY";
    }

    public static final String EXTRA_DATA = "data";
    public static final String EXTRA_STATUS = "status";
    public static final String EXTRA_ERROR = "error";
    public static final String EXTRA_DECRYPTED_MESSAGE = "decryptedMessage";
    public static final String EXTRA_ENCRYPTED_MESSAGE = "decryptedMessage";
    public static final String EXTRA_SIGNATURE = "signature";
    public static final String EXTRA_SIGNATURE_KEY_ID = "signatureKeyId";
    public static final String EXTRA_SIGNATURE_USER_ID = "signatureUserId";
    public static final String EXTRA_SIGNATURE_SUCCESS = "signatureSuccess";
    public static final String EXTRA_SIGNATURE_UNKNOWN = "signatureUnknown";
    public static final String EXTRA_USER_ID = "userId";
    public static final String EXTRA_KEY_ID = "keyId";
    public static final String EXTRA_REPLY_TO = "replyTo";
    public static final String EXTRA_SEND_TO = "sendTo";
    public static final String EXTRA_SUBJECT = "subject";
    public static final String EXTRA_ENCRYPTION_KEY_IDS = "encryptionKeyIds";
    public static final String EXTRA_SELECTION = "selection";
    public static final String EXTRA_MESSAGE = "message";
    public static final String EXTRA_PROGRESS = "progress";
    public static final String EXTRA_MAX = "max";
    public static final String EXTRA_ACCOUNT = "account";

    public static String VERSION = "1.0.1";
    public static String FULL_VERSION = "APG v" + VERSION;

    private static final int[] PREFERRED_SYMMETRIC_ALGORITHMS =
File
Apg.java
Developer's decision
Version 2
Kind of conflict
Attribute
Chunk
Conflicting content
                    CompressionAlgorithmTags.BZIP2,
                    CompressionAlgorithmTags.ZIP };

<<<<<<< HEAD
    protected static Vector mPublicKeyRings = new Vector();
    protected static Vector mSecretKeyRings = new Vector();

=======
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
    public static Pattern PGP_MESSAGE =
            Pattern.compile(".*?(-----BEGIN PGP MESSAGE-----.*?-----END PGP MESSAGE-----).*",
                            Pattern.DOTALL);
Solution content
                    CompressionAlgorithmTags.BZIP2,
                    CompressionAlgorithmTags.ZIP };

    public static Pattern PGP_MESSAGE =
            Pattern.compile(".*?(-----BEGIN PGP MESSAGE-----.*?-----END PGP MESSAGE-----).*",
                            Pattern.DOTALL);
File
Apg.java
Developer's decision
Version 2
Kind of conflict
Attribute
Method invocation
Chunk
Conflicting content
    private static HashMap mPassPhraseCache =
            new HashMap();
    private static String mEditPassPhrase = null;
<<<<<<< HEAD
=======

    private static Database mDatabase = null;
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4

    public static class GeneralException extends Exception {
        static final long serialVersionUID = 0xf812773342L;
Solution content
    private static HashMap mPassPhraseCache =
            new HashMap();
    private static String mEditPassPhrase = null;

    private static Database mDatabase = null;

    public static class GeneralException extends Exception {
        static final long serialVersionUID = 0xf812773342L;
File
Apg.java
Developer's decision
Version 2
Kind of conflict
Attribute
Chunk
Conflicting content
    public static class NoAsymmetricEncryptionException extends Exception {
        static final long serialVersionUID = 0xf812773343L;
<<<<<<< HEAD

        public NoAsymmetricEncryptionException() {
            super();
        }
    }

    static {
        mPublicKeyRings = new Vector();
        mSecretKeyRings = new Vector();
        mSecretKeyIdToIdMap = new HashMap();
        mSecretKeyIdToKeyRingMap = new HashMap();
        mPublicKeyIdToIdMap = new HashMap();
        mPublicKeyIdToKeyRingMap = new HashMap();
    }

    public static void initialize(Activity context) {
        if (mInitialized) {
            return;
=======

        public NoAsymmetricEncryptionException() {
            super();
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
        }
    }
Solution content
    public static class NoAsymmetricEncryptionException extends Exception {
        static final long serialVersionUID = 0xf812773343L;

        public NoAsymmetricEncryptionException() {
            super();
        }
    }
File
Apg.java
Developer's decision
Version 2
Kind of conflict
If statement
Method declaration
Method invocation
Method signature
Return statement
Static initializer
Chunk
Conflicting content
        }
    }

<<<<<<< HEAD
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
            File dir = new File(Constants.path.app_dir);
            if (!dir.exists() && !dir.mkdirs()) {
                // ignore this for now, it's not crucial
                // that the directory doesn't exist at this point
            }
        }

        loadKeyRings(context, Id.type.public_key);
        loadKeyRings(context, Id.type.secret_key);

        mInitialized = true;
=======
    public static void initialize(Context context) {
        if (mDatabase == null) {
            mDatabase = new Database(context);
        }
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
    }

    public static Database getDatabase() {
Solution content
        }
    }

    public static void initialize(Context context) {
        if (mDatabase == null) {
            mDatabase = new Database(context);
        }
    }

    public static Database getDatabase() {
File
Apg.java
Developer's decision
Version 2
Kind of conflict
Attribute
If statement
Method invocation
Method signature
Chunk
Conflicting content
            }
        }

<<<<<<< HEAD
    public static void setEditPassPhrase(String passPhrase) {
        mEditPassPhrase = passPhrase;
    }

    public static String getEditPassPhrase() {
        return mEditPassPhrase;
    }

    public static void setCachedPassPhrase(long keyId, String passPhrase) {
        mPassPhraseCache.put(keyId, new CachedPassPhrase(new Date().getTime(), passPhrase));
    }

    public static String getCachedPassPhrase(long keyId) {
        long realId = keyId;
        if (realId != Id.key.symmetric) {
            PGPSecretKeyRing keyRing = findSecretKeyRing(keyId);
            if (keyRing == null) {
                return null;
            }
            PGPSecretKey masterKey = getMasterKey(keyRing);
            if (masterKey == null) {
                return null;
            }
            realId = masterKey.getKeyID();
        }
        CachedPassPhrase cpp = mPassPhraseCache.get(realId);
        if (cpp == null) {
            return null;
        }
        // set it again to reset the cache life cycle
        setCachedPassPhrase(realId, cpp.passPhrase);
        return cpp.passPhrase;
    }

    public static void cleanUpCache(int ttl) {
        long now = new Date().getTime();

        Vector oldKeys = new Vector();
        for (Map.Entry pair : mPassPhraseCache.entrySet()) {
            if ((now - pair.getValue().timestamp) >= 1000 * ttl) {
                oldKeys.add(pair.getKey());
            }
        }

        for (long keyId : oldKeys) {
            mPassPhraseCache.remove(keyId);
        }
    }

=======
        for (long keyId : oldKeys) {
            mPassPhraseCache.remove(keyId);
        }

        return delay;
    }

>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
    public static PGPSecretKey createKey(Context context,
                                         int algorithmChoice, int keySize, String passPhrase,
                                         PGPSecretKey masterKey)
Solution content
            }
        }

        for (long keyId : oldKeys) {
            mPassPhraseCache.remove(keyId);
        }

        return delay;
    }

    public static PGPSecretKey createKey(Context context,
                                         int algorithmChoice, int keySize, String passPhrase,
                                         PGPSecretKey masterKey)
File
Apg.java
Developer's decision
Version 2
Kind of conflict
For statement
Method declaration
Return statement
Variable
Chunk
Conflicting content
            it.next();
            secretKey = (PGPSecretKey) it.next();
        }
<<<<<<< HEAD

=======
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4

        return secretKey;
    }
Solution content
    }
            it.next();
            secretKey = (PGPSecretKey) it.next();
        }

        return secretKey;
File
Apg.java
Developer's decision
Version 1
Kind of conflict
Blank
Chunk
Conflicting content
        PGPPublicKeyRing publicKeyRing = keyGen.generatePublicKeyRing();

        progress.setProgress(R.string.progress_savingKeyRing, 90, 100);
<<<<<<< HEAD
        saveKeyRing(context, secretKeyRing);
        saveKeyRing(context, publicKeyRing);

        loadKeyRings(context, Id.type.public_key);
        loadKeyRings(context, Id.type.secret_key);
        progress.setProgress(R.string.progress_done, 100, 100);
    }

    private static int saveKeyRing(Activity context, PGPPublicKeyRing keyRing) {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ContentValues values = new ContentValues();

        PGPPublicKey masterKey = getMasterKey(keyRing);
        if (masterKey == null) {
            return Id.return_value.no_master_key;
        }

        try {
            keyRing.encode(out);
            out.close();
        } catch (IOException e) {
            return Id.return_value.error;
        }

        values.put(PublicKeys.KEY_ID, masterKey.getKeyID());
        values.put(PublicKeys.KEY_DATA, out.toByteArray());

        Uri uri = Uri.withAppendedPath(PublicKeys.CONTENT_URI_BY_KEY_ID, "" + masterKey.getKeyID());
        Cursor cursor = context.managedQuery(uri, PUBLIC_KEY_PROJECTION, null, null, null);
        if (cursor != null && cursor.getCount() > 0) {
            context.getContentResolver().update(uri, values, null, null);
            return Id.return_value.updated;
        } else {
            context.getContentResolver().insert(PublicKeys.CONTENT_URI, values);
            return Id.return_value.ok;
        }
    }

    private static int saveKeyRing(Activity context, PGPSecretKeyRing keyRing) {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ContentValues values = new ContentValues();

        PGPSecretKey masterKey = getMasterKey(keyRing);
        if (masterKey == null) {
            return Id.return_value.no_master_key;
        }

        try {
            keyRing.encode(out);
            out.close();
        } catch (IOException e) {
            return Id.return_value.error;
        }

        values.put(SecretKeys.KEY_ID, masterKey.getKeyID());
        values.put(SecretKeys.KEY_DATA, out.toByteArray());

        Uri uri = Uri.withAppendedPath(SecretKeys.CONTENT_URI_BY_KEY_ID, "" + masterKey.getKeyID());
        Cursor cursor = context.managedQuery(uri, SECRET_KEY_PROJECTION, null, null, null);
        if (cursor != null && cursor.getCount() > 0) {
            context.getContentResolver().update(uri, values, null, null);
            return Id.return_value.updated;
        } else {
            context.getContentResolver().insert(SecretKeys.CONTENT_URI, values);
            return Id.return_value.ok;
        }
=======
        mDatabase.saveKeyRing(secretKeyRing);
        mDatabase.saveKeyRing(publicKeyRing);

        progress.setProgress(R.string.progress_done, 100, 100);
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
    }

    public static Bundle importKeyRings(Activity context, int type, String filename,
Solution content
        PGPPublicKeyRing publicKeyRing = keyGen.generatePublicKeyRing();

        progress.setProgress(R.string.progress_savingKeyRing, 90, 100);
        mDatabase.saveKeyRing(secretKeyRing);
        mDatabase.saveKeyRing(publicKeyRing);

        progress.setProgress(R.string.progress_done, 100, 100);
    }

    public static Bundle importKeyRings(Activity context, int type, String filename,
File
Apg.java
Developer's decision
Version 2
Kind of conflict
If statement
Method declaration
Method invocation
Method signature
Try statement
Variable
Chunk
Conflicting content
                                        ProgressDialogUpdater progress)
            throws GeneralException, FileNotFoundException, PGPException, IOException {
        Bundle returnData = new Bundle();
<<<<<<< HEAD
        PGPObjectFactory objectFactory = null;
=======
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4

        if (type == Id.type.secret_key) {
            progress.setProgress(R.string.progress_importingSecretKeys, 0, 100);
Solution content
                                        ProgressDialogUpdater progress)
            throws GeneralException, FileNotFoundException, PGPException, IOException {
        Bundle returnData = new Bundle();

        if (type == Id.type.secret_key) {
            progress.setProgress(R.string.progress_importingSecretKeys, 0, 100);
File
Apg.java
Developer's decision
Version 2
Kind of conflict
Variable
Chunk
Conflicting content
        }

        FileInputStream fileIn = new FileInputStream(filename);
<<<<<<< HEAD
        InputStream in = PGPUtil.getDecoderStream(fileIn);
        objectFactory = new PGPObjectFactory(in);

        Vector objects = new Vector();
        Object obj = objectFactory.nextObject();
        while (obj != null) {
            objects.add(obj);
            obj = objectFactory.nextObject();
        }

        int newKeys = 0;
        int oldKeys = 0;
        for (int i = 0; i < objects.size(); ++i) {
            progress.setProgress(i * 100 / objects.size(), 100);
            obj = objects.get(i);
            PGPPublicKeyRing publicKeyRing;
            PGPSecretKeyRing secretKeyRing;
            int retValue;

            if (type == Id.type.secret_key) {
                if (!(obj instanceof PGPSecretKeyRing)) {
                    continue;
                }
                secretKeyRing = (PGPSecretKeyRing) obj;
                retValue = saveKeyRing(context, secretKeyRing);
            } else {
                if (!(obj instanceof PGPPublicKeyRing)) {
                    continue;
=======
        long fileSize = new File(filename).length();
        PositionAwareInputStream progressIn = new PositionAwareInputStream(fileIn);
        // need to have access to the bufferedInput, so we can reuse it for the possible
        // PGPObject chunks after the first one, e.g. files with several consecutive ASCII
        // armour blocks
        BufferedInputStream bufferedInput = new BufferedInputStream(progressIn);
        int newKeys = 0;
        int oldKeys = 0;
        try {
            while (true) {
                InputStream in = PGPUtil.getDecoderStream(bufferedInput);
                PGPObjectFactory objectFactory = new PGPObjectFactory(in);
                Object obj = objectFactory.nextObject();
                // if the first is already a null object, then we can stop trying
                if (obj == null) {
                    break;
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
                }
                while (obj != null) {
                    PGPPublicKeyRing publicKeyRing;
Solution content
        }

        FileInputStream fileIn = new FileInputStream(filename);
        long fileSize = new File(filename).length();
        PositionAwareInputStream progressIn = new PositionAwareInputStream(fileIn);
        // need to have access to the bufferedInput, so we can reuse it for the possible
        // PGPObject chunks after the first one, e.g. files with several consecutive ASCII
        // armour blocks
        BufferedInputStream bufferedInput = new BufferedInputStream(progressIn);
        int newKeys = 0;
        int oldKeys = 0;
        try {
            while (true) {
                InputStream in = PGPUtil.getDecoderStream(bufferedInput);
                PGPObjectFactory objectFactory = new PGPObjectFactory(in);
                Object obj = objectFactory.nextObject();
                // if the first is already a null object, then we can stop trying
                if (obj == null) {
                    break;
                }
                while (obj != null) {
                    PGPPublicKeyRing publicKeyRing;
File
Apg.java
Developer's decision
Version 2
Kind of conflict
Break statement
Cast expression
Comment
Continue statement
For statement
If statement
Method invocation
Try statement
Variable
While statement
Chunk
Conflicting content
                    // saveKeyRing is never called
                    int retValue = 2107;

<<<<<<< HEAD
            if (retValue == Id.return_value.error) {
                throw new GeneralException(context.getString(R.string.error_savingKeys));
            }

            if (retValue == Id.return_value.updated) {
                ++oldKeys;
            } else if (retValue == Id.return_value.ok) {
                ++newKeys;
=======
                    try {
                        if (type == Id.type.secret_key && obj instanceof PGPSecretKeyRing) {
                            secretKeyRing = (PGPSecretKeyRing) obj;
                            retValue = mDatabase.saveKeyRing(secretKeyRing);
                        } else if (type == Id.type.public_key && obj instanceof PGPPublicKeyRing) {
                            publicKeyRing = (PGPPublicKeyRing) obj;
                            retValue = mDatabase.saveKeyRing(publicKeyRing);
                        }
                    } catch (IOException e) {
                        retValue = Id.return_value.error;
                    } catch (Database.GeneralException e) {
                        retValue = Id.return_value.error;
                    }

                    if (retValue == Id.return_value.error) {
                        throw new GeneralException(context.getString(R.string.error_savingKeys));
                    }

                    if (retValue == Id.return_value.updated) {
                        ++oldKeys;
                    } else if (retValue == Id.return_value.ok) {
                        ++newKeys;
                    }
                    progress.setProgress((int)(100 * progressIn.position() / fileSize), 100);
                    obj = objectFactory.nextObject();
                }
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
            }
        } catch (EOFException e) {
            // nothing to do, we are done
Solution content
                    // saveKeyRing is never called
                    int retValue = 2107;

                    try {
                        if (type == Id.type.secret_key && obj instanceof PGPSecretKeyRing) {
                            secretKeyRing = (PGPSecretKeyRing) obj;
                            retValue = mDatabase.saveKeyRing(secretKeyRing);
                        } else if (type == Id.type.public_key && obj instanceof PGPPublicKeyRing) {
                            publicKeyRing = (PGPPublicKeyRing) obj;
                            retValue = mDatabase.saveKeyRing(publicKeyRing);
                        }
                    } catch (IOException e) {
                        retValue = Id.return_value.error;
                    } catch (Database.GeneralException e) {
                        retValue = Id.return_value.error;
                    }

                    if (retValue == Id.return_value.error) {
                        throw new GeneralException(context.getString(R.string.error_savingKeys));
                    }

                    if (retValue == Id.return_value.updated) {
                        ++oldKeys;
                    } else if (retValue == Id.return_value.ok) {
                        ++newKeys;
                    }
                    progress.setProgress((int)(100 * progressIn.position() / fileSize), 100);
                    obj = objectFactory.nextObject();
                }
            }
        } catch (EOFException e) {
            // nothing to do, we are done
File
Apg.java
Developer's decision
Version 2
Kind of conflict
If statement
Method invocation
Try statement
Variable
Chunk
Conflicting content
            // nothing to do, we are done
        }

<<<<<<< HEAD
        progress.setProgress(R.string.progress_reloadingKeys, 100, 100);
        loadKeyRings(context, type);

=======
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
        returnData.putInt("added", newKeys);
        returnData.putInt("updated", oldKeys);
Solution content
            // nothing to do, we are done
        }

        returnData.putInt("added", newKeys);
        returnData.putInt("updated", oldKeys);
File
Apg.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Chunk
Conflicting content
            throws GeneralException, FileNotFoundException, PGPException, IOException {
        Bundle returnData = new Bundle();

<<<<<<< HEAD
        if (keys.size() == 1) {
=======
        if (keyRingIds.size() == 1) {
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
            progress.setProgress(R.string.progress_exportingKey, 0, 100);
        } else {
            progress.setProgress(R.string.progress_exportingKeys, 0, 100);
Solution content
            throws GeneralException, FileNotFoundException, PGPException, IOException {
        Bundle returnData = new Bundle();

        if (keyRingIds.size() == 1) {
            progress.setProgress(R.string.progress_exportingKey, 0, 100);
        } else {
            progress.setProgress(R.string.progress_exportingKeys, 0, 100);
File
Apg.java
Developer's decision
Version 2
Kind of conflict
If statement
Chunk
Conflicting content
        return returnData;
    }

<<<<<<< HEAD
    private static void loadKeyRings(Activity context, int type) {
        Cursor cursor;
        if (type == Id.type.secret_key) {
            mSecretKeyRings.clear();
            mSecretKeyIdToIdMap.clear();
            mSecretKeyIdToKeyRingMap.clear();
            cursor = context.managedQuery(SecretKeys.CONTENT_URI, SECRET_KEY_PROJECTION,
                                          null, null, null);
        } else {
            mPublicKeyRings.clear();
            mPublicKeyIdToIdMap.clear();
            mPublicKeyIdToKeyRingMap.clear();
            cursor = context.managedQuery(PublicKeys.CONTENT_URI, PUBLIC_KEY_PROJECTION,
                                          null, null, null);
        }

        for (int i = 0; i < cursor.getCount(); ++i) {
            cursor.moveToPosition(i);
            String sharedIdColumn = PublicKeys._ID; // same in both
            String sharedKeyIdColumn = PublicKeys.KEY_ID; // same in both
            String sharedKeyDataColumn = PublicKeys.KEY_DATA; // same in both
            int idIndex = cursor.getColumnIndex(sharedIdColumn);
            int keyIdIndex = cursor.getColumnIndex(sharedKeyIdColumn);
            int keyDataIndex = cursor.getColumnIndex(sharedKeyDataColumn);

            byte keyData[] = cursor.getBlob(keyDataIndex);
            int id = cursor.getInt(idIndex);
            long keyId = cursor.getLong(keyIdIndex);

            try {
                if (type == Id.type.secret_key) {
                    PGPSecretKeyRing key = new PGPSecretKeyRing(keyData);
                    mSecretKeyRings.add(key);
                    mSecretKeyIdToIdMap.put(keyId, id);
                    mSecretKeyIdToKeyRingMap.put(keyId, key);
                } else {
                    PGPPublicKeyRing key = new PGPPublicKeyRing(keyData);
                    mPublicKeyRings.add(key);
                    mPublicKeyIdToIdMap.put(keyId, id);
                    mPublicKeyIdToKeyRingMap.put(keyId, key);
                }
            } catch (IOException e) {
                // TODO: some error handling
            } catch (PGPException e) {
                // TODO: some error handling
            }
        }

        if (type == Id.type.secret_key) {
            Collections.sort(mSecretKeyRings, new SecretKeySorter());
        } else {
            Collections.sort(mPublicKeyRings, new PublicKeySorter());
        }
    }

=======
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
    public static Date getCreationDate(PGPPublicKey key) {
        return key.getCreationTime();
    }
Solution content
        return returnData;
    }

    public static Date getCreationDate(PGPPublicKey key) {
        return key.getCreationTime();
    }
File
Apg.java
Developer's decision
Version 2
Kind of conflict
Method declaration
Chunk
Conflicting content
    }
        return algorithmStr + ", " + keySize + "bit";
    }

<<<<<<< HEAD
    public static void deleteKey(Activity context, PGPPublicKeyRing keyRing) {
        PGPPublicKey masterKey = getMasterKey(keyRing);
        Uri uri = Uri.withAppendedPath(PublicKeys.CONTENT_URI_BY_KEY_ID, "" + masterKey.getKeyID());
        context.getContentResolver().delete(uri, null, null);
        loadKeyRings(context, Id.type.public_key);
    }

    public static void deleteKey(Activity context, PGPSecretKeyRing keyRing) {
        PGPSecretKey masterKey = getMasterKey(keyRing);
        Uri uri = Uri.withAppendedPath(SecretKeys.CONTENT_URI_BY_KEY_ID, "" + masterKey.getKeyID());
        context.getContentResolver().delete(uri, null, null);
        loadKeyRings(context, Id.type.secret_key);
=======
    public static void deleteKey(int keyRingId) {
        mDatabase.deleteKeyRing(keyRingId);

    public static Object getKeyRing(int keyRingId) {
        return mDatabase.getKeyRing(keyRingId);
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
    }

    public static PGPSecretKeyRing getSecretKeyRing(long keyId) {
Solution content
        return algorithmStr + ", " + keySize + "bit";
    }

    public static void deleteKey(int keyRingId) {
        mDatabase.deleteKeyRing(keyRingId);
    }

    public static Object getKeyRing(int keyRingId) {
        return mDatabase.getKeyRing(keyRingId);
    }

    public static PGPSecretKeyRing getSecretKeyRing(long keyId) {
File
Apg.java
Developer's decision
Version 2
Kind of conflict
Method declaration
Method invocation
Method signature
Return statement
Variable
Chunk
Conflicting content
        }
        if (compression == Id.choice.compression.none) {
            bcpgOut = new BCPGOutputStream(encryptOut);
        } else {
<<<<<<< HEAD
            compressGen = new PGPCompressedDataGenerator(CompressionAlgorithmTags.ZLIB);
=======
            compressGen = new PGPCompressedDataGenerator(compression);
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
            bcpgOut = new BCPGOutputStream(compressGen.open(encryptOut));
        if (signatureKeyId != 0) {
Solution content
        if (compression == Id.choice.compression.none) {
            bcpgOut = new BCPGOutputStream(encryptOut);
        } else {
            compressGen = new PGPCompressedDataGenerator(compression);
            bcpgOut = new BCPGOutputStream(compressGen.open(encryptOut));
        }
        if (signatureKeyId != 0) {
File
Apg.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
            if (obj instanceof PGPPublicKeyEncryptedData) {
                gotAsymmetricEncryption = true;
                PGPPublicKeyEncryptedData pbe = (PGPPublicKeyEncryptedData) obj;
<<<<<<< HEAD
                secretKey = findSecretKey(pbe.getKeyID());
=======
                secretKey = getSecretKey(pbe.getKeyID());
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
                if (secretKey != null) {
                    break;
                }
Solution content
            if (obj instanceof PGPPublicKeyEncryptedData) {
                gotAsymmetricEncryption = true;
                PGPPublicKeyEncryptedData pbe = (PGPPublicKeyEncryptedData) obj;
                secretKey = getSecretKey(pbe.getKeyID());
                if (secretKey != null) {
                    break;
                }
File
Apg.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
                Object obj = it.next();
                if (obj instanceof PGPPublicKeyEncryptedData) {
                    PGPPublicKeyEncryptedData encData = (PGPPublicKeyEncryptedData) obj;
<<<<<<< HEAD
                    secretKey = findSecretKey(encData.getKeyID());
=======
                    secretKey = getSecretKey(encData.getKeyID());
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
                    if (secretKey != null) {
                        pbe = encData;
                        break;
Solution content
                Object obj = it.next();
                if (obj instanceof PGPPublicKeyEncryptedData) {
                    PGPPublicKeyEncryptedData encData = (PGPPublicKeyEncryptedData) obj;
                    secretKey = getSecretKey(encData.getKeyID());
                    if (secretKey != null) {
                        pbe = encData;
                        break;
File
Apg.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
        if (dataChunk instanceof PGPOnePassSignatureList) {
            progress.setProgress(R.string.progress_processingSignature, currentProgress, 100);
<<<<<<< HEAD
            returnData.putBoolean("signature", true);
=======
            returnData.putBoolean(EXTRA_SIGNATURE, true);
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
            PGPOnePassSignatureList sigList = (PGPOnePassSignatureList) dataChunk;
            for (int i = 0; i < sigList.size(); ++i) {
                signature = sigList.get(i);
Solution content
        if (dataChunk instanceof PGPOnePassSignatureList) {
            progress.setProgress(R.string.progress_processingSignature, currentProgress, 100);
            returnData.putBoolean(EXTRA_SIGNATURE, true);
            PGPOnePassSignatureList sigList = (PGPOnePassSignatureList) dataChunk;
            for (int i = 0; i < sigList.size(); ++i) {
                signature = sigList.get(i);
File
Apg.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Chunk
Conflicting content
        returnData.putLong(EXTRA_SIGNATURE_KEY_ID, signatureKeyId);

        if (signature == null) {
<<<<<<< HEAD
            returnData.putBoolean("signatureUnknown", true);
=======
            returnData.putBoolean(EXTRA_SIGNATURE_UNKNOWN, true);
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
            progress.setProgress(R.string.progress_done, 100, 100);
            return returnData;
        }
Solution content
        returnData.putLong(EXTRA_SIGNATURE_KEY_ID, signatureKeyId);

        if (signature == null) {
            returnData.putBoolean(EXTRA_SIGNATURE_UNKNOWN, true);
            progress.setProgress(R.string.progress_done, 100, 100);
            return returnData;
        }
File
Apg.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Chunk
Conflicting content
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
<<<<<<< HEAD
=======
import android.content.DialogInterface.OnClickListener;
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
Solution content
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
File
AskForSecretKeyPassPhrase.java
Developer's decision
Version 2
Kind of conflict
Import
Chunk
Conflicting content
        alert.setTitle(R.string.title_authentification);

        final PGPSecretKey secretKey;
<<<<<<< HEAD
=======
        final Activity activity = context;
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4

        if (secretKeyId == Id.key.symmetric || secretKeyId == Id.key.none) {
            secretKey = null;
Solution content
        alert.setTitle(R.string.title_authentification);

        final PGPSecretKey secretKey;
        final Activity activity = context;

        if (secretKeyId == Id.key.symmetric || secretKeyId == Id.key.none) {
            secretKey = null;
File
AskForSecretKeyPassPhrase.java
Developer's decision
Version 2
Kind of conflict
Variable
Chunk
Conflicting content
            secretKey = null;
            alert.setMessage(context.getString(R.string.passPhraseForSymmetricEncryption));
        } else {
<<<<<<< HEAD
            secretKey = Apg.getMasterKey(Apg.findSecretKeyRing(secretKeyId));
            if (secretKey == null) {
                return null;
=======
            secretKey = Apg.getMasterKey(Apg.getSecretKeyRing(secretKeyId));
            if (secretKey == null) {
                alert.setTitle(R.string.title_keyNotFound);
                alert.setMessage(context.getString(R.string.keyNotFound, secretKeyId));
                alert.setPositiveButton(android.R.string.ok, new OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        activity.removeDialog(Id.dialog.pass_phrase);
                    }
                });
                alert.setCancelable(false);
                return alert.create();
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
            }
            String userId = Apg.getMainUserIdSafe(context, secretKey);
            alert.setMessage(context.getString(R.string.passPhraseFor, userId));
Solution content
            secretKey = null;
            alert.setMessage(context.getString(R.string.passPhraseForSymmetricEncryption));
        } else {
            secretKey = Apg.getMasterKey(Apg.getSecretKeyRing(secretKeyId));
            if (secretKey == null) {
                alert.setTitle(R.string.title_keyNotFound);
                alert.setMessage(context.getString(R.string.keyNotFound, secretKeyId));
                alert.setPositiveButton(android.R.string.ok, new OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        activity.removeDialog(Id.dialog.pass_phrase);
                    }
                });
                alert.setCancelable(false);
                return alert.create();
            }
            String userId = Apg.getMainUserIdSafe(context, secretKey);
            alert.setMessage(context.getString(R.string.passPhraseFor, userId));
File
AskForSecretKeyPassPhrase.java
Developer's decision
Version 2
Kind of conflict
If statement
Method invocation
Return statement
Variable
Chunk
Conflicting content
        final PassPhraseCallbackInterface cb = callback;
        alert.setPositiveButton(android.R.string.ok,
<<<<<<< HEAD
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {
                                        activity.removeDialog(Id.dialog.pass_phrase);
                                        String passPhrase = "" + input.getText();
                                        long keyId;
                                        if (secretKey != null) {
                                            try {
                                                secretKey.extractPrivateKey(passPhrase.toCharArray(),
                                                                            new BouncyCastleProvider());
                                            } catch (PGPException e) {
                                                Toast.makeText(activity,
                                                               R.string.wrongPassPhrase,
                                                               Toast.LENGTH_SHORT).show();
                                                return;
                                            }
                                            keyId = secretKey.getKeyID();
                                        } else {
                                            keyId = Id.key.symmetric;
                                        }
                                        cb.passPhraseCallback(keyId, passPhrase);
                                    }
                                });
=======
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        activity.removeDialog(Id.dialog.pass_phrase);
                        String passPhrase = "" + input.getText();
                        long keyId;
                        if (secretKey != null) {
                            try {
                                secretKey.extractPrivateKey(passPhrase.toCharArray(),
                                                            new BouncyCastleProvider());
                            } catch (PGPException e) {
                                Toast.makeText(activity,
                                               R.string.wrongPassPhrase,
                                               Toast.LENGTH_SHORT).show();
                                return;
                            }
                            keyId = secretKey.getKeyID();
                        } else {
                            keyId = Id.key.symmetric;
                        }
                        cb.passPhraseCallback(keyId, passPhrase);
                    }
                });
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4

        alert.setNegativeButton(android.R.string.cancel,
                                new DialogInterface.OnClickListener() {
Solution content
        final PassPhraseCallbackInterface cb = callback;
        alert.setPositiveButton(android.R.string.ok,
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        activity.removeDialog(Id.dialog.pass_phrase);
                        String passPhrase = "" + input.getText();
                        long keyId;
                        if (secretKey != null) {
                            try {
                                secretKey.extractPrivateKey(passPhrase.toCharArray(),
                                                            new BouncyCastleProvider());
                            } catch (PGPException e) {
                                Toast.makeText(activity,
                                               R.string.wrongPassPhrase,
                                               Toast.LENGTH_SHORT).show();
                                return;
                            }
                            keyId = secretKey.getKeyID();
                        } else {
                            keyId = Id.key.symmetric;
                        }
                        cb.passPhraseCallback(keyId, passPhrase);
                    }
                });

        alert.setNegativeButton(android.R.string.cancel,
                                new DialogInterface.OnClickListener() {
File
AskForSecretKeyPassPhrase.java
Developer's decision
Version 1
Kind of conflict
Method invocation
Chunk
Conflicting content
import org.bouncycastle2.openpgp.PGPException;
import org.bouncycastle2.openpgp.PGPSecretKey;
import org.bouncycastle2.openpgp.PGPSecretKeyRing;
<<<<<<< HEAD
=======
import org.thialfihar.android.apg.provider.Database;
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
import org.thialfihar.android.apg.ui.widget.KeyEditor;
import org.thialfihar.android.apg.ui.widget.SectionView;
import org.thialfihar.android.apg.utils.IterableIterator;
Solution content
import org.bouncycastle2.openpgp.PGPException;
import org.bouncycastle2.openpgp.PGPSecretKey;
import org.bouncycastle2.openpgp.PGPSecretKeyRing;
import org.thialfihar.android.apg.provider.Database;
import org.thialfihar.android.apg.ui.widget.KeyEditor;
import org.thialfihar.android.apg.ui.widget.SectionView;
import org.thialfihar.android.apg.utils.IterableIterator;
File
EditKeyActivity.java
Developer's decision
Version 2
Kind of conflict
Import
Chunk
Conflicting content
        Toast.makeText(this, "Warning: Key editing is still kind of beta.", Toast.LENGTH_LONG).show();
    }

<<<<<<< HEAD
    public long getMasterKeyId() {
=======
    private long getMasterKeyId() {
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
        if (mKeys.getEditors().getChildCount() == 0) {
            return 0;
        }
Solution content
        Toast.makeText(this, "Warning: Key editing is still kind of beta.", Toast.LENGTH_LONG).show();
    }

    private long getMasterKeyId() {
        if (mKeys.getEditors().getChildCount() == 0) {
            return 0;
        }
File
EditKeyActivity.java
Developer's decision
Version 2
Kind of conflict
Method signature
Chunk
Conflicting content
            error = "" + e;
        }

<<<<<<< HEAD
        data.putInt("type", Id.message.done);
=======
        data.putInt(Apg.EXTRA_STATUS, Id.message.done);
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4

        if (error != null) {
            data.putString(Apg.EXTRA_ERROR, error);
Solution content
            error = "" + e;
        }

        data.putInt(Apg.EXTRA_STATUS, Id.message.done);

        if (error != null) {
            data.putString(Apg.EXTRA_ERROR, error);
File
EditKeyActivity.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Chunk
Conflicting content
        Bundle data = msg.getData();
        removeDialog(Id.dialog.saving);
<<<<<<< HEAD
        String error = data.getString("error");
        if (error != null) {
            Toast.makeText(EditKeyActivity.this,
                           getString(R.string.errorMessage, data.getString("error")),
                           Toast.LENGTH_SHORT).show();
=======
        String error = data.getString(Apg.EXTRA_ERROR);
        if (error != null) {
            Toast.makeText(EditKeyActivity.this,
                           getString(R.string.errorMessage, error), Toast.LENGTH_SHORT).show();
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
        } else {
            Toast.makeText(EditKeyActivity.this, R.string.keySaved, Toast.LENGTH_SHORT).show();
            setResult(RESULT_OK);
Solution content
        Bundle data = msg.getData();
        removeDialog(Id.dialog.saving);

        String error = data.getString(Apg.EXTRA_ERROR);
        if (error != null) {
            Toast.makeText(EditKeyActivity.this,
                           getString(R.string.errorMessage, error), Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(EditKeyActivity.this, R.string.keySaved, Toast.LENGTH_SHORT).show();
            setResult(RESULT_OK);
File
EditKeyActivity.java
Developer's decision
Version 2
Kind of conflict
If statement
Method invocation
Variable
Chunk
Conflicting content
        mAccounts.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView arg0, View view, int index, long id) {
<<<<<<< HEAD
                Cursor cursor =
                        managedQuery(Uri.withAppendedPath(Accounts.CONTENT_URI, "" + id), null,
                                     null, null, null);
                if (cursor != null && cursor.getCount() > 0) {
                    cursor.moveToFirst();
                    int nameIndex = cursor.getColumnIndex(Accounts.NAME);
                    String accountName = cursor.getString(nameIndex);
                    startActivity(new Intent(MainActivity.this, MailListActivity.class)
                                        .putExtra("account", accountName));
                }
=======
                String accountName = (String) mAccounts.getItemAtPosition(index);
                startActivity(new Intent(MainActivity.this, MailListActivity.class)
                                        .putExtra(Apg.EXTRA_ACCOUNT, accountName));
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
            }
        });
        registerForContextMenu(mAccounts);
Solution content
        mAccounts.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView arg0, View view, int index, long id) {
                String accountName = (String) mAccounts.getItemAtPosition(index);
                startActivity(new Intent(MainActivity.this, MailListActivity.class)
                                        .putExtra(Apg.EXTRA_ACCOUNT, accountName));
            }
        });
        registerForContextMenu(mAccounts);
File
MainActivity.java
Developer's decision
Version 2
Kind of conflict
Cast expression
If statement
Method invocation
Variable
Chunk
Conflicting content
                                ContentValues values = new ContentValues();
                                values.put(Accounts.NAME, accountName);
                                try {
<<<<<<< HEAD
                                    MainActivity.this.getContentResolver()
                                                     .insert(Accounts.CONTENT_URI,
                                                             values);
=======
                                    Apg.getDatabase().db().insert(Accounts.TABLE_NAME,
                                                                  Accounts.NAME, values);
                                    mAccountCursor.requery();
                                    mListAdapter.notifyDataSetChanged();
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
                                } catch (SQLException e) {
                                    Toast.makeText(MainActivity.this,
                                                   getString(R.string.errorMessage,
Solution content
                                ContentValues values = new ContentValues();
                                values.put(Accounts.NAME, accountName);
                                try {
                                    Apg.getDatabase().db().insert(Accounts.TABLE_NAME,
                                                                  Accounts.NAME, values);
                                    mAccountCursor.requery();
                                    mListAdapter.notifyDataSetChanged();
                                } catch (SQLException e) {
                                    Toast.makeText(MainActivity.this,
                                                   getString(R.string.errorMessage,
File
MainActivity.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Chunk
Conflicting content
                message.setText("Read the warnings!\n\n" +
                                "Changes:\n" +
<<<<<<< HEAD
=======
                                "* k9mail integration, k9mail beta build is available on the k9mail website\n" +
                                "* support of other file managers (e.g. ASTRO)\n" +
                                "* Slovenian translation (thanks, 359)\n" +
                                "* new database, much faster, less memory usage\n" +
                                "* defined Intents and content provider for other apps\n" +
                                "* bugfixes\n" +
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
                                "\n" +
                                "WARNING: be careful editing your existing keys, as they " +
                                "WILL be stripped of certificates right now.\n" +
Solution content
                message.setText("Read the warnings!\n\n" +
                                "Changes:\n" +
                                "* k9mail integration, k9mail beta build is available on the k9mail website\n" +
                                "* support of other file managers (e.g. ASTRO)\n" +
                                "* Slovenian translation (thanks, 359)\n" +
                                "* new database, much faster, less memory usage\n" +
                                "* defined Intents and content provider for other apps\n" +
                                "* bugfixes\n" +
                                "\n" +
                                "WARNING: be careful editing your existing keys, as they " +
                                "WILL be stripped of certificates right now.\n" +
File
MainActivity.java
Developer's decision
Version 2
Kind of conflict
Other
Chunk
Conflicting content
        switch (menuItem.getItemId()) {
            case Id.menu.delete: {
<<<<<<< HEAD
                Uri uri = Uri.withAppendedPath(Accounts.CONTENT_URI, "" + info.id);
                this.getContentResolver().delete(uri, null, null);
=======
                Apg.getDatabase().db().delete(Accounts.TABLE_NAME,
                                              Accounts._ID + " = ?",
                                              new String[] { "" + info.id });
                mAccountCursor.requery();
                mListAdapter.notifyDataSetChanged();
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
                return true;
            }
Solution content
        switch (menuItem.getItemId()) {
            case Id.menu.delete: {
                Apg.getDatabase().db().delete(Accounts.TABLE_NAME,
                                              Accounts._ID + " = ?",
                                              new String[] { "" + info.id });
                mAccountCursor.requery();
                mListAdapter.notifyDataSetChanged();
                return true;
            }
File
MainActivity.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
package org.thialfihar.android.apg;

<<<<<<< HEAD
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Vector;

import org.bouncycastle2.openpgp.PGPException;
import org.bouncycastle2.openpgp.PGPPublicKey;
import org.bouncycastle2.openpgp.PGPPublicKeyRing;
import org.thialfihar.android.apg.utils.IterableIterator;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Message;
import android.view.ContextMenu;
import android.view.LayoutInflater;
=======
import android.os.Bundle;
import android.view.ContextMenu;
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
import android.view.Menu;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
Solution content
package org.thialfihar.android.apg;

import android.os.Bundle;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
File
PublicKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Import
Chunk
Conflicting content
import android.view.Menu;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
<<<<<<< HEAD
import android.widget.BaseExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;

public class PublicKeyListActivity extends BaseActivity {
    ExpandableListView mList;

    protected int mSelectedItem = -1;
    protected int mTask = 0;

    private String mImportFilename = Constants.path.app_dir + "/pubring.gpg";
    private String mExportFilename = Constants.path.app_dir + "/pubexport.asc";
=======
import android.widget.ExpandableListView;
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4

public class PublicKeyListActivity extends KeyListActivity {
    @Override
Solution content
import android.view.Menu;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.ExpandableListView;

public class PublicKeyListActivity extends KeyListActivity {
    @Override
File
PublicKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Attribute
Class signature
Import
Chunk
Conflicting content
        mExportFilename = Constants.path.app_dir + "/pubexport.asc";
        mKeyType = Id.type.public_key;
        super.onCreate(savedInstanceState);
<<<<<<< HEAD
        setContentView(R.layout.key_list);

        mList = (ExpandableListView) findViewById(R.id.list);
        mList.setAdapter(new PublicKeyListAdapter(this));
        registerForContextMenu(mList);
=======
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
    }

    @Override
Solution content
        mExportFilename = Constants.path.app_dir + "/pubexport.asc";
        mKeyType = Id.type.public_key;
        super.onCreate(savedInstanceState);
    }

    @Override
File
PublicKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Attribute
Cast expression
Method invocation
Chunk
Conflicting content
    }

    @Override
<<<<<<< HEAD
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case Id.menu.option.import_keys: {
                showDialog(Id.dialog.import_keys);
                return true;
            }
            case Id.menu.option.export_keys: {
                showDialog(Id.dialog.export_keys);
                return true;
            }

            default: {
                return super.onOptionsItemSelected(item);
            }
        }
    }

    @Override
=======
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
        super.onCreateContextMenu(menu, v, menuInfo);
        ExpandableListView.ExpandableListContextMenuInfo info =
Solution content
    }

    @Override
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
        super.onCreateContextMenu(menu, v, menuInfo);
        ExpandableListView.ExpandableListContextMenuInfo info =
File
PublicKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Annotation
Method declaration
Chunk
Conflicting content
        int type = ExpandableListView.getPackedPositionType(info.packedPosition);

        if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
<<<<<<< HEAD
            PGPPublicKeyRing keyRing = Apg.getPublicKeyRings().get(groupPosition);
            String userId = Apg.getMainUserIdSafe(this, Apg.getMasterKey(keyRing));
            menu.setHeaderTitle(userId);
            menu.add(0, Id.menu.export, 0, R.string.menu_exportKey);
            menu.add(0, Id.menu.delete, 1, R.string.menu_deleteKey);
        }
    }

    @Override
    public boolean onContextItemSelected(MenuItem menuItem) {
        ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuItem.getMenuInfo();
        int type = ExpandableListView.getPackedPositionType(info.packedPosition);
        int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);

        if (type != ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
            return super.onContextItemSelected(menuItem);
        }

        switch (menuItem.getItemId()) {
            case Id.menu.export: {
                mSelectedItem = groupPosition;
                showDialog(Id.dialog.export_key);
                return true;
            }

            case Id.menu.delete: {
                mSelectedItem = groupPosition;
                showDialog(Id.dialog.delete_key);
                return true;
            }

            default: {
                return super.onContextItemSelected(menuItem);
            }
        }
    }

    @Override
    protected Dialog onCreateDialog(int id) {
        boolean singleKeyExport = false;

        switch (id) {
            case Id.dialog.delete_key: {
                PGPPublicKeyRing keyRing = Apg.getPublicKeyRings().get(mSelectedItem);
                String userId = Apg.getMainUserIdSafe(this, Apg.getMasterKey(keyRing));

                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setTitle(R.string.warning);
                builder.setMessage(getString(R.string.keyDeletionConfirmation, userId));
                builder.setIcon(android.R.drawable.ic_dialog_alert);
                builder.setPositiveButton(R.string.btn_delete,
                                          new DialogInterface.OnClickListener() {
                                              public void onClick(DialogInterface dialog, int id) {
                                                  deleteKey(mSelectedItem);
                                                  mSelectedItem = -1;
                                                  removeDialog(Id.dialog.delete_key);
                                              }
                                          });
                builder.setNegativeButton(android.R.string.cancel,
                                          new DialogInterface.OnClickListener() {
                                              public void onClick(DialogInterface dialog, int id) {
                                                  mSelectedItem = -1;
                                                  removeDialog(Id.dialog.delete_key);
                                              }
                                          });
                return builder.create();
            }

            case Id.dialog.import_keys: {
            } else {
                return FileDialog.build(this, getString(R.string.title_importKeys),
                                        getString(R.string.specifyFileToImportFrom),
                                        mImportFilename,
                                        new FileDialog.OnClickListener() {

                                            @Override
                                            public void onOkClick(String filename) {
                                                removeDialog(Id.dialog.import_keys);
                                                mImportFilename = filename;
                                                importKeys();
                                            }

                                            @Override
                                            public void onCancelClick() {
                                                removeDialog(Id.dialog.import_keys);
                                            }
                                        },
                                        getString(R.string.filemanager_titleOpen),
                                        getString(R.string.filemanager_btnOpen),
                                        Id.request.filename);
            }

            case Id.dialog.export_key: {
                singleKeyExport = true;
                // break intentionally omitted, to use the Id.dialog.export_keys dialog
            }

            case Id.dialog.export_keys: {
                String title = (singleKeyExport ?
                                    getString(R.string.title_exportKey) :
                                    getString(R.string.title_exportKeys));

                final int thisDialogId = (singleKeyExport ? Id.dialog.export_key : Id.dialog.export_keys);

                return FileDialog.build(this, title,
                                        getString(R.string.specifyFileToExportTo),
                                        mExportFilename,
                                        new FileDialog.OnClickListener() {

                                            @Override
                                            public void onOkClick(String filename) {
                                                removeDialog(thisDialogId);
                                                mExportFilename = filename;
                                                exportKeys();
                                            }

                                            @Override
                                            public void onCancelClick() {
                                                removeDialog(thisDialogId);
                                            }
                                        },
                                        getString(R.string.filemanager_titleSave),
                                        getString(R.string.filemanager_btnSave),
                                        Id.request.filename);
            }

            default: {
                return super.onCreateDialog(id);
            }
        }
    }

    public void importKeys() {
        showDialog(Id.dialog.importing);
        mTask = Id.task.import_keys;
        startThread();
    }

    public void exportKeys() {
        showDialog(Id.dialog.exporting);
        mTask = Id.task.export_keys;
        startThread();
    }

    @Override
    public void run() {
        String error = null;
        Bundle data = new Bundle();
        Message msg = new Message();

        String filename = null;
        if (mTask == Id.task.import_keys) {
            filename = mImportFilename;
        } else {
            filename = mExportFilename;
        }

        try {
            if (mTask == Id.task.import_keys) {
                data = Apg.importKeyRings(this, Id.type.public_key, filename, this);
                Vector keys = new Vector();
                if (mSelectedItem == -1) {
                    for (PGPPublicKeyRing key : Apg.getPublicKeyRings()) {
                        keys.add(key);
                    }
                } else {
                    keys.add(Apg.getPublicKeyRings().get(mSelectedItem));
                }
                data = Apg.exportKeyRings(this, keys, filename, this);
            }
        } catch (FileNotFoundException e) {
            error = getString(R.string.error_fileNotFound);
        } catch (IOException e) {
            error = e.getMessage();
        } catch (PGPException e) {
        }
            error = e.getMessage();
        } catch (Apg.GeneralException e) {
            error = e.getMessage();
        }

        if (mTask == Id.task.import_keys) {
            data.putInt("type", Id.message.import_done);
        } else {
            data.putInt("type", Id.message.export_done);
        }

        if (error != null) {
            data.putString("error", error);
        }

        msg.setData(data);
        sendMessage(msg);
    }

    private void deleteKey(int index) {
        PGPPublicKeyRing keyRing = Apg.getPublicKeyRings().get(index);
        Apg.deleteKey(this, keyRing);
        refreshList();
    }

    private void refreshList() {
        ((PublicKeyListAdapter) mList.getExpandableListAdapter()).notifyDataSetChanged();
    }

    @Override
    public void doneCallback(Message msg) {
        super.doneCallback(msg);

        Bundle data = msg.getData();
        if (data != null) {
            int type = data.getInt("type");
            switch (type) {
                case Id.message.import_done: {
                    removeDialog(Id.dialog.importing);

                    String error = data.getString("error");
                    if (error != null) {
                        Toast.makeText(PublicKeyListActivity.this,
                                       getString(R.string.errorMessage, data.getString("error")),
                                       Toast.LENGTH_SHORT).show();
                    } else {
                        int added = data.getInt("added");
                        int updated = data.getInt("updated");
                        String message;
                        if (added > 0 && updated > 0) {
                            message = getString(R.string.keysAddedAndUpdated, added, updated);
                        } else if (added > 0) {
                            message = getString(R.string.keysAdded, added);
                        } else if (updated > 0) {
                            message = getString(R.string.keysUpdated, updated);
                        } else {
                            message = getString(R.string.noKeysAddedOrUpdated);
                        }
                        Toast.makeText(PublicKeyListActivity.this, message,
                                       Toast.LENGTH_SHORT).show();
                    }
                    refreshList();
                    break;
                }

                case Id.message.export_done: {
                    removeDialog(Id.dialog.exporting);

                    String error = data.getString("error");
                    if (error != null) {
                        Toast.makeText(PublicKeyListActivity.this,
                                       getString(R.string.errorMessage, data.getString("error")),
                                       Toast.LENGTH_SHORT).show();
                    } else {
                        int exported = data.getInt("exported");
                        String message;
                        if (exported == 1) {
                            message = getString(R.string.keyExported);
                        } else if (exported > 0) {
                            message = getString(R.string.keysExported);
                        } else{
                            message = getString(R.string.noKeysExported);
                        }
                        Toast.makeText(PublicKeyListActivity.this, message,
                                       Toast.LENGTH_SHORT).show();
                    }
                    break;
                }

                default: {
                    break;
                }
            }
    }

    private static class PublicKeyListAdapter extends BaseExpandableListAdapter {
        private LayoutInflater mInflater;

        private class KeyChild {
            public static final int KEY = 0;
            public static final int USER_ID = 1;

            public int type;
            public PGPPublicKey key;
            public String userId;

            public KeyChild(PGPPublicKey key) {
                type = KEY;
                this.key = key;
            }

            public KeyChild(String userId) {
                type = USER_ID;
                this.userId = userId;
            }
        }

        public PublicKeyListAdapter(Context context) {
            mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        }

        protected Vector getChildrenOfKeyRing(PGPPublicKeyRing keyRing) {
            Vector children = new Vector();
            PGPPublicKey masterKey = null;
            for (PGPPublicKey key : new IterableIterator(keyRing.getPublicKeys())) {
                children.add(new KeyChild(key));
                if (key.isMasterKey()) {
                    masterKey = key;
                }
            }

            if (masterKey != null) {
                boolean isFirst = true;
                for (String userId : new IterableIterator(masterKey.getUserIDs())) {
                    if (isFirst) {
                        // ignore first, it's in the group already
                        isFirst = false;
                        continue;
                    }
                    children.add(new KeyChild(userId));
                }
            }

            return children;
        }

        @Override
        public boolean hasStableIds() {
            return true;
        }

        @Override
        public boolean isChildSelectable(int groupPosition, int childPosition) {
            return true;
        }

        public int getGroupCount() {
            return Apg.getPublicKeyRings().size();
        }

        public Object getChild(int groupPosition, int childPosition) {
            PGPPublicKeyRing keyRing = Apg.getPublicKeyRings().get(groupPosition);
            Vector children = getChildrenOfKeyRing(keyRing);

            KeyChild child = children.get(childPosition);
            return child;
        }

        public long getChildId(int groupPosition, int childPosition) {
            return childPosition;
        }

        public int getChildrenCount(int groupPosition) {
            return getChildrenOfKeyRing(Apg.getPublicKeyRings().get(groupPosition)).size();
        }

        public Object getGroup(int position) {
            return position;
        }

        public long getGroupId(int position) {
            return position;
        }

        public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
                                 ViewGroup parent) {
            PGPPublicKeyRing keyRing = Apg.getPublicKeyRings().get(groupPosition);
            for (PGPPublicKey key : new IterableIterator(keyRing.getPublicKeys())) {
                View view;
                if (!key.isMasterKey()) {
                    continue;
                }
                view = mInflater.inflate(R.layout.key_list_group_item, null);
                view.setBackgroundResource(android.R.drawable.list_selector_background);

                TextView mainUserId = (TextView) view.findViewById(R.id.mainUserId);
                mainUserId.setText("");
                TextView mainUserIdRest = (TextView) view.findViewById(R.id.mainUserIdRest);
                mainUserIdRest.setText("");

                String userId = Apg.getMainUserId(key);
                if (userId != null) {
                    String chunks[] = userId.split(" <", 2);
                    userId = chunks[0];
                    if (chunks.length > 1) {
                        mainUserIdRest.setText("<" + chunks[1]);
                    }
                    mainUserId.setText(userId);
                }

                if (mainUserId.getText().length() == 0) {
                    mainUserId.setText(R.string.unknownUserId);
                }

                if (mainUserIdRest.getText().length() == 0) {
                    mainUserIdRest.setVisibility(View.GONE);
                }
                return view;
            }
            return null;
        }

        public View getChildView(int groupPosition, int childPosition,
                                 boolean isLastChild, View convertView,
                                 ViewGroup parent) {
            PGPPublicKeyRing keyRing = Apg.getPublicKeyRings().get(groupPosition);
            Vector children = getChildrenOfKeyRing(keyRing);

            KeyChild child = children.get(childPosition);
            View view = null;
            switch (child.type) {
                case KeyChild.KEY: {
                    PGPPublicKey key = child.key;
                    if (key.isMasterKey()) {
                        view = mInflater.inflate(R.layout.key_list_child_item_master_key, null);
                    } else {
                        view = mInflater.inflate(R.layout.key_list_child_item_sub_key, null);
                    }

                    TextView keyId = (TextView) view.findViewById(R.id.keyId);
                    String keyIdStr = Long.toHexString(key.getKeyID() & 0xffffffffL);
                    while (keyIdStr.length() < 8) {
                        keyIdStr = "0" + keyIdStr;
                    }
                    keyId.setText(keyIdStr);
                    TextView keyDetails = (TextView) view.findViewById(R.id.keyDetails);
                    String algorithmStr = Apg.getAlgorithmInfo(key);
                    keyDetails.setText("(" + algorithmStr + ")");

                    ImageView encryptIcon = (ImageView) view.findViewById(R.id.ic_encryptKey);
                    if (!Apg.isEncryptionKey(key)) {
                        encryptIcon.setVisibility(View.GONE);
                    }

                    ImageView signIcon = (ImageView) view.findViewById(R.id.ic_signKey);
                    if (!Apg.isSigningKey(key)) {
                        signIcon.setVisibility(View.GONE);
                    }
                    break;
                }

                case KeyChild.USER_ID: {
                    view = mInflater.inflate(R.layout.key_list_child_item_user_id, null);
                    TextView userId = (TextView) view.findViewById(R.id.userId);
                    userId.setText(child.userId);
                    break;
                }
            }
            return view;
=======
            // TODO: user id? menu.setHeaderTitle("Key");
            menu.add(0, Id.menu.export, 0, R.string.menu_exportKey);
            menu.add(0, Id.menu.delete, 1, R.string.menu_deleteKey);
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
        }
    }
Solution content
        int type = ExpandableListView.getPackedPositionType(info.packedPosition);

        if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
            // TODO: user id? menu.setHeaderTitle("Key");
            menu.add(0, Id.menu.export, 0, R.string.menu_exportKey);
            menu.add(0, Id.menu.delete, 1, R.string.menu_deleteKey);
        }
    }
}
File
PublicKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Annotation
Attribute
Class declaration
Class signature
Comment
Method declaration
Method invocation
Method signature
Return statement
Switch statement
Variable
Chunk
Conflicting content
package org.thialfihar.android.apg;

import android.app.Dialog;
<<<<<<< HEAD
import android.content.Context;
import android.content.DialogInterface;
=======
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
Solution content
package org.thialfihar.android.apg;

import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
File
SecretKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Import
Chunk
Conflicting content
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
<<<<<<< HEAD
import android.os.Message;
import android.view.ContextMenu;
import android.view.LayoutInflater;
=======
import android.view.ContextMenu;
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Solution content
import android.content.Intent;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
File
SecretKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Import
Chunk
Conflicting content
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
<<<<<<< HEAD
import android.widget.BaseExpandableListAdapter;
=======
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
import android.widget.ExpandableListView.OnChildClickListener;
Solution content
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
import android.widget.ExpandableListView.OnChildClickListener;
File
SecretKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Import
Chunk
Conflicting content
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
import android.widget.ExpandableListView.OnChildClickListener;

<<<<<<< HEAD
public class SecretKeyListActivity extends BaseActivity implements OnChildClickListener {
    ExpandableListView mList;

    protected int mSelectedItem = -1;
    protected int mTask = 0;

    private String mImportFilename = Constants.path.app_dir + "/secring.gpg";
    private String mExportFilename = Constants.path.app_dir + "/secexport.asc";

=======
public class SecretKeyListActivity extends KeyListActivity implements OnChildClickListener {
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
    @Override
    public void onCreate(Bundle savedInstanceState) {
        mExportFilename = Constants.path.app_dir + "/secexport.asc";
Solution content
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
import android.widget.ExpandableListView.OnChildClickListener;

public class SecretKeyListActivity extends KeyListActivity implements OnChildClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        mExportFilename = Constants.path.app_dir + "/secexport.asc";
File
SecretKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Attribute
Class signature
Chunk
Conflicting content
        mExportFilename = Constants.path.app_dir + "/secexport.asc";
        mKeyType = Id.type.secret_key;
        super.onCreate(savedInstanceState);
<<<<<<< HEAD
        setContentView(R.layout.key_list);

        mList = (ExpandableListView) findViewById(R.id.list);
        mList.setAdapter(new SecretKeyListAdapter(this));
        registerForContextMenu(mList);
=======
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
        mList.setOnChildClickListener(this);
    }
Solution content
        mExportFilename = Constants.path.app_dir + "/secexport.asc";
        mKeyType = Id.type.secret_key;
        super.onCreate(savedInstanceState);
        mList.setOnChildClickListener(this);
    }
File
SecretKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Attribute
Cast expression
Method invocation
Chunk
Conflicting content
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
<<<<<<< HEAD
            case Id.menu.option.import_keys: {
                showDialog(Id.dialog.import_keys);
                return true;
            }

            case Id.menu.option.export_keys: {
                showDialog(Id.dialog.export_keys);
                return true;
            }

=======
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
            case Id.menu.option.create: {
                createKey();
                return true;
Solution content
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case Id.menu.option.create: {
                createKey();
                return true;
File
SecretKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Case statement
Method invocation
Return statement
Chunk
Conflicting content
        int type = ExpandableListView.getPackedPositionType(info.packedPosition);

        if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
<<<<<<< HEAD
            PGPSecretKeyRing keyRing = Apg.getSecretKeyRings().get(groupPosition);
            String userId = Apg.getMainUserIdSafe(this, Apg.getMasterKey(keyRing));
            menu.setHeaderTitle(userId);
=======
            // TODO: user id? menu.setHeaderTitle("Key");
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
            menu.add(0, Id.menu.edit, 0, R.string.menu_editKey);
            menu.add(0, Id.menu.export, 1, R.string.menu_exportKey);
            menu.add(0, Id.menu.delete, 2, R.string.menu_deleteKey);
Solution content
        int type = ExpandableListView.getPackedPositionType(info.packedPosition);

        if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
            // TODO: user id? menu.setHeaderTitle("Key");
            menu.add(0, Id.menu.edit, 0, R.string.menu_editKey);
            menu.add(0, Id.menu.export, 1, R.string.menu_exportKey);
            menu.add(0, Id.menu.delete, 2, R.string.menu_deleteKey);
File
SecretKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Comment
Method invocation
Variable
Chunk
Conflicting content
            case Id.menu.edit: {
                mSelectedItem = groupPosition;
                checkPassPhraseAndEdit();
<<<<<<< HEAD
                return true;
            }

            case Id.menu.export: {
                mSelectedItem = groupPosition;
                showDialog(Id.dialog.export_key);
                return true;
            }

            case Id.menu.delete: {
                mSelectedItem = groupPosition;
                showDialog(Id.dialog.delete_key);
=======
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
                return true;
            }
Solution content
            case Id.menu.edit: {
                mSelectedItem = groupPosition;
                checkPassPhraseAndEdit();
                return true;
            }
File
SecretKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Attribute
Case statement
Method invocation
Return statement
Variable
Chunk
Conflicting content
    @Override
    protected Dialog onCreateDialog(int id) {
        switch (id) {
<<<<<<< HEAD
            case Id.dialog.delete_key: {
                PGPSecretKeyRing keyRing = Apg.getSecretKeyRings().get(mSelectedItem);

                String userId = Apg.getMainUserIdSafe(this, Apg.getMasterKey(keyRing));

                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setTitle(R.string.warning);
                builder.setMessage(getString(R.string.secretKeyDeletionConfirmation, userId));
                builder.setIcon(android.R.drawable.ic_dialog_alert);
                builder.setPositiveButton(R.string.btn_delete,
                                          new DialogInterface.OnClickListener() {
                                              public void onClick(DialogInterface dialog, int id) {
                                                  deleteKey(mSelectedItem);
                                                  mSelectedItem = -1;
                                                  removeDialog(Id.dialog.delete_key);
                                              }
                                          });
                builder.setNegativeButton(android.R.string.ok,
                                          new DialogInterface.OnClickListener() {
                                              public void onClick(DialogInterface dialog, int id) {
                                                  mSelectedItem = -1;
                                                  removeDialog(Id.dialog.delete_key);
                                              }
                                          });
                return builder.create();
            }

            case Id.dialog.import_keys: {
                return FileDialog.build(this, getString(R.string.title_importKeys),
                                        getString(R.string.specifyFileToImportFrom),
                                        mImportFilename,
                                        new FileDialog.OnClickListener() {

                                            @Override
                                            public void onOkClick(String filename) {
                                                removeDialog(Id.dialog.import_keys);
                                                mImportFilename = filename;
                                                importKeys();
                                            }

                                            @Override
                                            public void onCancelClick() {
                                                removeDialog(Id.dialog.import_keys);
                                            }
                                        },
                                        getString(R.string.filemanager_titleOpen),
                                        getString(R.string.filemanager_btnOpen),
                                        Id.request.filename);
            }

            case Id.dialog.export_key: {
                singleKeyExport = true;
                // break intentionally omitted, to use the Id.dialog.export_keys dialog
            }

            case Id.dialog.export_keys: {
                String title = (singleKeyExport ?
                                     getString(R.string.title_exportKey) :
                                     getString(R.string.title_exportKeys));

                final int thisDialogId = (singleKeyExport ? Id.dialog.export_key : Id.dialog.export_keys);

                return FileDialog.build(this, title,
                                        getString(R.string.specifyFileToExportSecretKeysTo),
                                        mExportFilename,
                                        new FileDialog.OnClickListener() {

                                            @Override
                                            public void onOkClick(String filename) {
                                                removeDialog(thisDialogId);
                                                mExportFilename = filename;
                                                exportKeys();
                                            }

                                            @Override
                                            public void onCancelClick() {
                                                removeDialog(thisDialogId);
                                            }
                                        },
                                        getString(R.string.filemanager_titleSave),
                                        getString(R.string.filemanager_btnSave),
                                        Id.request.filename);
            }

            case Id.dialog.pass_phrase: {
                PGPSecretKeyRing keyRing = Apg.getSecretKeyRings().get(mSelectedItem);
                long keyId = keyRing.getSecretKey().getKeyID();
=======
            case Id.dialog.pass_phrase: {
                long keyId = ((KeyListAdapter) mList.getExpandableListAdapter()).getGroupId(mSelectedItem);
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
                return AskForSecretKeyPassPhrase.createDialog(this, keyId, this);
            }
Solution content
    @Override
    protected Dialog onCreateDialog(int id) {
        switch (id) {
            case Id.dialog.pass_phrase: {
                long keyId = ((KeyListAdapter) mList.getExpandableListAdapter()).getGroupId(mSelectedItem);
                return AskForSecretKeyPassPhrase.createDialog(this, keyId, this);
            }
File
SecretKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Case statement
Comment
Method invocation
Return statement
Variable
Chunk
Conflicting content
    }

    public void checkPassPhraseAndEdit() {
<<<<<<< HEAD
        PGPSecretKeyRing keyRing = Apg.getSecretKeyRings().get(mSelectedItem);
        long keyId = keyRing.getSecretKey().getKeyID();
=======
        long keyId = ((KeyListAdapter) mList.getExpandableListAdapter()).getGroupId(mSelectedItem);
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
        String passPhrase = Apg.getCachedPassPhrase(keyId);
        if (passPhrase == null) {
            showDialog(Id.dialog.pass_phrase);
Solution content
    }

    public void checkPassPhraseAndEdit() {
        long keyId = ((KeyListAdapter) mList.getExpandableListAdapter()).getGroupId(mSelectedItem);
        String passPhrase = Apg.getCachedPassPhrase(keyId);
        if (passPhrase == null) {
            showDialog(Id.dialog.pass_phrase);
File
SecretKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
    private void editKey() {
        long keyId = ((KeyListAdapter) mList.getExpandableListAdapter()).getGroupId(mSelectedItem);
        Intent intent = new Intent(this, EditKeyActivity.class);
<<<<<<< HEAD
        intent.putExtra("keyId", keyId);
=======
        intent.putExtra(Apg.EXTRA_KEY_ID, keyId);
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
        startActivityForResult(intent, Id.message.edit_key);
    }
Solution content
    private void editKey() {
        long keyId = ((KeyListAdapter) mList.getExpandableListAdapter()).getGroupId(mSelectedItem);
        Intent intent = new Intent(this, EditKeyActivity.class);
        intent.putExtra(Apg.EXTRA_KEY_ID, keyId);
        startActivityForResult(intent, Id.message.edit_key);
    }
File
SecretKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Chunk
Conflicting content
                    }
                    }

                break;
            }

<<<<<<< HEAD
            case Id.request.filename: {
                if (resultCode == RESULT_OK && data != null) {
                    String filename = data.getDataString();
                    if (filename != null) {
                        // Get rid of URI prefix:
                        if (filename.startsWith("file://")) {
                            filename = filename.substring(7);
                        }
                        // replace %20 and so on
                        filename = Uri.decode(filename);

                        FileDialog.setFilename(filename);
                }
                return;
            }

            default: {
                break;
            }
        }

        super.onActivityResult(requestCode, resultCode, data);
    }

    public void importKeys() {
        showDialog(Id.dialog.importing);
        mTask = Id.task.import_keys;
        startThread();
    }

    public void exportKeys() {
        showDialog(Id.dialog.exporting);
        mTask = Id.task.export_keys;
        startThread();
    }

    @Override
    public void run() {
        String error = null;
        Bundle data = new Bundle();
        Message msg = new Message();

        String filename = null;
        if (mTask == Id.task.import_keys) {
            filename = mImportFilename;
        } else {
            filename = mExportFilename;
        }

        try {
            if (mTask == Id.task.import_keys) {
                data = Apg.importKeyRings(this, Id.type.secret_key, filename, this);
            } else {
                Vector keys = new Vector();
                if (mSelectedItem == -1) {
                    for (PGPSecretKeyRing key : Apg.getSecretKeyRings()) {
                        keys.add(key);
                    }
                } else {
                    keys.add(Apg.getSecretKeyRings().get(mSelectedItem));
                }
                data = Apg.exportKeyRings(this, keys, filename, this);
            }
        } catch (FileNotFoundException e) {
            error = getString(R.string.error_fileNotFound);
        } catch (IOException e) {
            error = e.getMessage();
        } catch (PGPException e) {
            error = e.getMessage();
        } catch (Apg.GeneralException e) {
            error = e.getMessage();
        }

        if (mTask == Id.task.import_keys) {
            data.putInt("type", Id.message.import_done);
        } else {
            data.putInt("type", Id.message.export_done);
        }

        if (error != null) {
            data.putString("error", error);
        }

        msg.setData(data);
        sendMessage(msg);
    }

    private void deleteKey(int index) {
        PGPSecretKeyRing keyRing = Apg.getSecretKeyRings().get(index);
        Apg.deleteKey(this, keyRing);
        refreshList();
    }

    private void refreshList() {
        ((SecretKeyListAdapter) mList.getExpandableListAdapter()).notifyDataSetChanged();
    }

    @Override
    public void doneCallback(Message msg) {
        super.doneCallback(msg);

        Bundle data = msg.getData();
        if (data != null) {
            int type = data.getInt("type");
            switch (type) {
                case Id.message.import_done: {
                    removeDialog(Id.dialog.importing);

                    String error = data.getString("error");
                    if (error != null) {
                        Toast.makeText(SecretKeyListActivity.this,
                                       getString(R.string.errorMessage, data.getString("error")),
                                       Toast.LENGTH_SHORT).show();
                    } else {
                        int added = data.getInt("added");
                        int updated = data.getInt("updated");
                        String message;
                        if (added > 0 && updated > 0) {
                            message = getString(R.string.keysAddedAndUpdated, added, updated);
                        } else if (added > 0) {
                            message = getString(R.string.keysAdded, added);
                        } else if (updated > 0) {
                            message = getString(R.string.keysUpdated, updated);
                        } else {
                            message = getString(R.string.noKeysAddedOrUpdated);
                        }
                        Toast.makeText(SecretKeyListActivity.this, message,
                                       Toast.LENGTH_SHORT).show();
                    refreshList();
                    break;
                }

                case Id.message.export_done: {
                    removeDialog(Id.dialog.exporting);

                    String error = data.getString("error");
                    if (error != null) {
                        Toast.makeText(SecretKeyListActivity.this,
                                       getString(R.string.errorMessage, data.getString("error")),
                                       Toast.LENGTH_SHORT).show();
                    } else {
                        int exported = data.getInt("exported");
                        String message;
                        if (exported == 1) {
                            message = getString(R.string.keyExported);
                        } else if (exported > 0) {
                            message = getString(R.string.keysExported);
                        } else{
                            message = getString(R.string.noKeysExported);
                        }
                        Toast.makeText(SecretKeyListActivity.this, message,
                                       Toast.LENGTH_SHORT).show();
                    }
                    break;
                }

                default: {
                    break;
                }
            }
        }
    }

    private static class SecretKeyListAdapter extends BaseExpandableListAdapter {
        private LayoutInflater mInflater;

        private class KeyChild {
            static final int KEY = 0;
            static final int USER_ID = 1;

            public int type;
            public PGPSecretKey key;
            public String userId;

            public KeyChild(PGPSecretKey key) {
                type = KEY;
                this.key = key;
=======
            default: {
                break;
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
            }
        }
Solution content
                break;
            }

            default: {
                break;
            }
        }
File
SecretKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Annotation
Attribute
Break statement
Case statement
Class signature
If statement
Method declaration
Method invocation
Method signature
Return statement
Variable
Chunk
Conflicting content
        }
            }
        }

<<<<<<< HEAD
        @Override
        public boolean hasStableIds() {
            return true;
        }

        @Override
        public boolean isChildSelectable(int groupPosition, int childPosition) {
            return true;
        }

        public int getGroupCount() {
            return Apg.getSecretKeyRings().size();
        }

        public Object getChild(int groupPosition, int childPosition) {
            PGPSecretKeyRing keyRing = Apg.getSecretKeyRings().get(groupPosition);
            Vector children = getChildrenOfKeyRing(keyRing);
            KeyChild child = children.get(childPosition);
            return child;
        }

        public long getChildId(int groupPosition, int childPosition) {
            return childPosition;

        public int getChildrenCount(int groupPosition) {
            return getChildrenOfKeyRing(Apg.getSecretKeyRings().get(groupPosition)).size();
        }

        public Object getGroup(int position) {
            return position;
        }

        public long getGroupId(int position) {
            return position;
        }

        public View getGroupView(int groupPosition, boolean isExpanded,
                                 View convertView, ViewGroup parent) {
            PGPSecretKeyRing keyRing = Apg.getSecretKeyRings().get(groupPosition);
            for (PGPSecretKey key : new IterableIterator(keyRing.getSecretKeys())) {
                View view;
                if (!key.isMasterKey()) {
                    continue;
                }
                view = mInflater.inflate(R.layout.key_list_group_item, null);
                view.setBackgroundResource(android.R.drawable.list_selector_background);

                TextView mainUserId = (TextView) view.findViewById(R.id.mainUserId);
                mainUserId.setText("");
                TextView mainUserIdRest = (TextView) view.findViewById(R.id.mainUserIdRest);
                mainUserIdRest.setText("");

                String userId = Apg.getMainUserId(key);
                if (userId != null) {
                    String chunks[] = userId.split(" <", 2);
                    userId = chunks[0];
                    if (chunks.length > 1) {
                        mainUserIdRest.setText("<" + chunks[1]);
                    }
                    mainUserId.setText(userId);
                }

                if (mainUserId.getText().length() == 0) {
                    mainUserId.setText(R.string.unknownUserId);
                }

                if (mainUserIdRest.getText().length() == 0) {
                    mainUserIdRest.setVisibility(View.GONE);
                }
                return view;
            }
            return null;
        }

        public View getChildView(int groupPosition, int childPosition,
                                 boolean isLastChild, View convertView,
                                 ViewGroup parent) {
            PGPSecretKeyRing keyRing = Apg.getSecretKeyRings().get(groupPosition);
            Vector children = getChildrenOfKeyRing(keyRing);

            KeyChild child = children.get(childPosition);
            View view = null;
            switch (child.type) {
                case KeyChild.KEY: {
                    PGPSecretKey key = child.key;
                    if (key.isMasterKey()) {
                        view = mInflater.inflate(R.layout.key_list_child_item_master_key, null);
                    } else {
                        view = mInflater.inflate(R.layout.key_list_child_item_sub_key, null);
                    }

                    TextView keyId = (TextView) view.findViewById(R.id.keyId);
                    String keyIdStr = Long.toHexString(key.getKeyID() & 0xffffffffL);
                    while (keyIdStr.length() < 8) {
                        keyIdStr = "0" + keyIdStr;
                    }
                    keyId.setText(keyIdStr);
                    TextView keyDetails = (TextView) view.findViewById(R.id.keyDetails);
                    String algorithmStr = Apg.getAlgorithmInfo(key);
                    keyDetails.setText("(" + algorithmStr + ")");

                    ImageView encryptIcon = (ImageView) view.findViewById(R.id.ic_encryptKey);
                    if (!Apg.isEncryptionKey(key)) {
                        encryptIcon.setVisibility(View.GONE);
                    }

                    ImageView signIcon = (ImageView) view.findViewById(R.id.ic_signKey);
                    if (!Apg.isSigningKey(key)) {
                        signIcon.setVisibility(View.GONE);
                    }
                    break;
                }

                case KeyChild.USER_ID: {
                    view = mInflater.inflate(R.layout.key_list_child_item_user_id, null);
                    TextView userId = (TextView) view.findViewById(R.id.userId);
                    userId.setText(child.userId);
                    break;
                }
            }
            return view;
        }
=======
        super.onActivityResult(requestCode, resultCode, data);
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
    }
}
Solution content
            }
        }

        super.onActivityResult(requestCode, resultCode, data);
    }
}
File
SecretKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Annotation
Method declaration
Method invocation
Chunk
Conflicting content
package org.thialfihar.android.apg;

<<<<<<< HEAD
import java.util.Collections;
import java.util.Vector;

import org.bouncycastle2.openpgp.PGPPublicKey;
import org.bouncycastle2.openpgp.PGPPublicKeyRing;

=======
import java.util.Vector;

>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
Solution content
package org.thialfihar.android.apg;

import java.util.Vector;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
File
SelectPublicKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Import
Chunk
Conflicting content
        // needed in Android 1.5, where the XML attribute gets ignored
        mList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

<<<<<<< HEAD
        Vector keyRings =
                (Vector) Apg.getPublicKeyRings().clone();
        Collections.sort(keyRings, new Apg.PublicKeySorter());
        mList.setAdapter(new SelectPublicKeyListAdapter(mList, keyRings));

        if (selectedKeyIds != null) {
            for (int i = 0; i < keyRings.size(); ++i) {
                PGPPublicKeyRing keyRing = keyRings.get(i);
                PGPPublicKey key = Apg.getMasterKey(keyRing);
                if (key == null) {
                    continue;
                }
=======
        SelectPublicKeyListAdapter adapter = new SelectPublicKeyListAdapter(this, mList);
        mList.setAdapter(adapter);

        if (selectedKeyIds != null) {
            for (int i = 0; i < adapter.getCount(); ++i) {
                long keyId = adapter.getItemId(i);
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
                for (int j = 0; j < selectedKeyIds.length; ++j) {
                    if (keyId == selectedKeyIds[j]) {
                        mList.setItemChecked(i, true);
Solution content
        // needed in Android 1.5, where the XML attribute gets ignored
        mList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

        SelectPublicKeyListAdapter adapter = new SelectPublicKeyListAdapter(this, mList);
        mList.setAdapter(adapter);

        if (selectedKeyIds != null) {
            for (int i = 0; i < adapter.getCount(); ++i) {
                long keyId = adapter.getItemId(i);
                for (int j = 0; j < selectedKeyIds.length; ++j) {
                    if (keyId == selectedKeyIds[j]) {
                        mList.setItemChecked(i, true);
File
SelectPublicKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Cast expression
For statement
If statement
Method invocation
Variable
Chunk
Conflicting content
        setResult(RESULT_OK, data);
        finish();
    }
<<<<<<< HEAD
}
=======
}
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
Solution content
        setResult(RESULT_OK, data);
        finish();
    }
}
File
SelectPublicKeyListActivity.java
Developer's decision
Version 1
Kind of conflict
Other
Chunk
Conflicting content
package org.thialfihar.android.apg;

<<<<<<< HEAD
import java.text.DateFormat;
import java.util.Collections;
import java.util.Date;
import java.util.Vector;

import org.bouncycastle2.openpgp.PGPSecretKey;
import org.bouncycastle2.openpgp.PGPSecretKeyRing;
import org.thialfihar.android.apg.utils.IterableIterator;

import android.content.Context;
=======
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
Solution content
package org.thialfihar.android.apg;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
File
SelectSecretKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Import
Chunk
Conflicting content
import android.widget.AdapterView.OnItemClickListener;

public class SelectSecretKeyListActivity extends BaseActivity {
<<<<<<< HEAD
    protected Vector mKeyRings;
    protected LayoutInflater mInflater;
    protected Intent mIntent;
=======
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
    protected ListView mList;
    protected SelectSecretKeyListAdapter mListAdapter;
Solution content
import android.widget.AdapterView.OnItemClickListener;

public class SelectSecretKeyListActivity extends BaseActivity {
    protected ListView mList;
    protected SelectSecretKeyListAdapter mListAdapter;
File
SelectSecretKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Attribute
Chunk
Conflicting content
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

<<<<<<< HEAD
        mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        // fill things
        mIntent = getIntent();

        mKeyRings = (Vector) Apg.getSecretKeyRings().clone();
        Collections.sort(mKeyRings, new Apg.SecretKeySorter());

=======
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
        setContentView(R.layout.select_secret_key);

        mList = (ListView) findViewById(R.id.list);
Solution content
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.select_secret_key);

        mList = (ListView) findViewById(R.id.list);
File
SelectSecretKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Attribute
Cast expression
Comment
Method invocation
Chunk
Conflicting content
            }
        });
    }
<<<<<<< HEAD

    private class SecretKeyListAdapter extends BaseAdapter {

        public SecretKeyListAdapter(Context context) {
        }

        @Override
        public boolean isEnabled(int position) {
            PGPSecretKeyRing keyRing = mKeyRings.get(position);

            if (Apg.getMasterKey(keyRing) == null) {
                return false;
            }

            Vector usableKeys = Apg.getUsableSigningKeys(keyRing);
            if (usableKeys.size() == 0) {
                return false;
            }

            return true;
        }

        @Override
        public boolean hasStableIds() {
            return true;
        }

        @Override
        public int getCount() {
            return mKeyRings.size();
        }

        @Override
        public Object getItem(int position) {
            return mKeyRings.get(position);
        }

        @Override
        public long getItemId(int position) {
            PGPSecretKeyRing keyRing = mKeyRings.get(position);
            PGPSecretKey key = Apg.getMasterKey(keyRing);
            if (key != null) {
                return key.getKeyID();
            }

            return 0;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view = mInflater.inflate(R.layout.select_secret_key_item, null);
            boolean enabled = isEnabled(position);

            PGPSecretKeyRing keyRing = mKeyRings.get(position);
            PGPSecretKey key = null;
            for (PGPSecretKey tKey : new IterableIterator(keyRing.getSecretKeys())) {
                if (tKey.isMasterKey()) {
                    key = tKey;
                    break;
                }
            }

            TextView mainUserId = (TextView) view.findViewById(R.id.mainUserId);
            mainUserId.setText(R.string.unknownUserId);
            TextView mainUserIdRest = (TextView) view.findViewById(R.id.mainUserIdRest);
            mainUserIdRest.setText("");
            TextView keyId = (TextView) view.findViewById(R.id.keyId);
            keyId.setText(R.string.noKey);
            TextView creation = (TextView) view.findViewById(R.id.creation);
            creation.setText(R.string.noDate);
            TextView expiry = (TextView) view.findViewById(R.id.expiry);
            expiry.setText(R.string.noExpiry);
            TextView status = (TextView) view.findViewById(R.id.status);
            status.setText(R.string.unknownStatus);

            if (key != null) {
                String userId = Apg.getMainUserId(key);
                if (userId != null) {
                    String chunks[] = userId.split(" <", 2);
                    userId = chunks[0];
                    if (chunks.length > 1) {
                        mainUserIdRest.setText("<" + chunks[1]);
                    }
                    mainUserId.setText(userId);
                }

                keyId.setText("" + Long.toHexString(key.getKeyID() & 0xffffffffL));
            }

            if (mainUserIdRest.getText().length() == 0) {
                mainUserIdRest.setVisibility(View.GONE);
            }

            Vector signingKeys = Apg.getSigningKeys(keyRing);
            Vector usableKeys = Apg.getUsableSigningKeys(keyRing);

            PGPSecretKey timespanKey = key;
            if (usableKeys.size() > 0) {
                timespanKey = usableKeys.get(0);
                status.setText(R.string.canSign);
            } else if (signingKeys.size() > 0) {
                timespanKey = signingKeys.get(0);
                Date now = new Date();
                if (now.compareTo(Apg.getCreationDate(timespanKey)) > 0) {
                    status.setText(R.string.notValid);
                } else {
                    status.setText(R.string.expired);
                }
            } else {
                status.setText(R.string.noKey);
            }

            creation.setText(DateFormat.getDateInstance().format(Apg.getCreationDate(timespanKey)));
            Date expiryDate = Apg.getExpiryDate(timespanKey);
            if (expiryDate != null) {
                expiry.setText(DateFormat.getDateInstance().format(expiryDate));
            }

            status.setText(status.getText() + " ");

            view.setEnabled(enabled);
            mainUserId.setEnabled(enabled);
            mainUserIdRest.setEnabled(enabled);
            keyId.setEnabled(enabled);
            creation.setEnabled(enabled);
            expiry.setEnabled(enabled);
            status.setEnabled(enabled);

            return view;
        }
    }
}
=======
}
>>>>>>> a571ce7c5222d1f2246acdfada7c95e48a170dd4
Solution content
            }
        });
    }
}
File
SelectSecretKeyListActivity.java
Developer's decision
Version 2
Kind of conflict
Class declaration