lift language level to java 7, and some code cleanup
This commit is contained in:
@@ -18,9 +18,6 @@
|
||||
|
||||
package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
|
||||
/**
|
||||
|
||||
@@ -234,7 +234,7 @@ public class CertifyKeyFragment extends LoaderFragment
|
||||
|
||||
long lastMasterKeyId = 0;
|
||||
String lastName = "";
|
||||
ArrayList<String> uids = new ArrayList<String>();
|
||||
ArrayList<String> uids = new ArrayList<>();
|
||||
|
||||
boolean header = true;
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ package org.sufficientlysecure.keychain.ui;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
|
||||
import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
public class CreateKeyFinalFragment extends Fragment {
|
||||
|
||||
@@ -89,7 +89,7 @@ public class CreateKeyInputFragment extends Fragment {
|
||||
|
||||
mEmailEdit.setThreshold(1); // Start working from first character
|
||||
mEmailEdit.setAdapter(
|
||||
new ArrayAdapter<String>
|
||||
new ArrayAdapter<>
|
||||
(getActivity(), android.R.layout.simple_spinner_dropdown_item,
|
||||
ContactHelper.getPossibleUserEmails(getActivity())
|
||||
)
|
||||
@@ -124,7 +124,7 @@ public class CreateKeyInputFragment extends Fragment {
|
||||
|
||||
mNameEdit.setThreshold(1); // Start working from first character
|
||||
mNameEdit.setAdapter(
|
||||
new ArrayAdapter<String>
|
||||
new ArrayAdapter<>
|
||||
(getActivity(), android.R.layout.simple_spinner_dropdown_item,
|
||||
ContactHelper.getPossibleUserNames(getActivity())
|
||||
)
|
||||
|
||||
@@ -20,7 +20,6 @@ package org.sufficientlysecure.keychain.ui;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
|
||||
@@ -20,7 +20,6 @@ package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
|
||||
@@ -231,10 +231,7 @@ public class EditKeyFragment extends LoaderFragment implements
|
||||
mSaveKeyringParcel = new SaveKeyringParcel(masterKeyId, keyRing.getFingerprint());
|
||||
mPrimaryUserId = keyRing.getPrimaryUserIdWithFallback();
|
||||
|
||||
} catch (PgpKeyNotFoundException e) {
|
||||
finishWithError(LogType.MSG_EK_ERROR_NOT_FOUND);
|
||||
return;
|
||||
} catch (NotFoundException e) {
|
||||
} catch (PgpKeyNotFoundException | NotFoundException e) {
|
||||
finishWithError(LogType.MSG_EK_ERROR_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import com.tokenautocomplete.TokenCompleteTextView;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
@@ -164,8 +163,8 @@ public class EncryptAsymmetricFragment extends Fragment implements EncryptActivi
|
||||
|
||||
private void updateEncryptionKeys() {
|
||||
List<Object> objects = mEncryptKeyView.getObjects();
|
||||
List<Long> keyIds = new ArrayList<Long>();
|
||||
List<String> userIds = new ArrayList<String>();
|
||||
List<Long> keyIds = new ArrayList<>();
|
||||
List<String> userIds = new ArrayList<>();
|
||||
for (Object object : objects) {
|
||||
if (object instanceof EncryptKeyCompletionView.EncryptionKey) {
|
||||
keyIds.add(((EncryptKeyCompletionView.EncryptionKey) object).getKeyId());
|
||||
|
||||
@@ -122,13 +122,13 @@ public class EncryptFilesActivity extends EncryptActivity implements EncryptActi
|
||||
|
||||
@Override
|
||||
public ArrayList<Uri> getInputUris() {
|
||||
if (mInputUris == null) mInputUris = new ArrayList<Uri>();
|
||||
if (mInputUris == null) mInputUris = new ArrayList<>();
|
||||
return mInputUris;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Uri> getOutputUris() {
|
||||
if (mOutputUris == null) mOutputUris = new ArrayList<Uri>();
|
||||
if (mOutputUris == null) mOutputUris = new ArrayList<>();
|
||||
return mOutputUris;
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ public class EncryptFilesActivity extends EncryptActivity implements EncryptActi
|
||||
sendIntent.setType("application/octet-stream");
|
||||
|
||||
if (!isModeSymmetric() && mEncryptionUserIds != null) {
|
||||
Set<String> users = new HashSet<String>();
|
||||
Set<String> users = new HashSet<>();
|
||||
for (String user : mEncryptionUserIds) {
|
||||
String[] userId = KeyRing.splitUserId(user);
|
||||
if (userId[1] != null) {
|
||||
@@ -382,7 +382,7 @@ public class EncryptFilesActivity extends EncryptActivity implements EncryptActi
|
||||
String action = intent.getAction();
|
||||
Bundle extras = intent.getExtras();
|
||||
String type = intent.getType();
|
||||
ArrayList<Uri> uris = new ArrayList<Uri>();
|
||||
ArrayList<Uri> uris = new ArrayList<>();
|
||||
|
||||
if (extras == null) {
|
||||
extras = new Bundle();
|
||||
|
||||
@@ -59,7 +59,7 @@ public class EncryptFilesFragment extends Fragment implements EncryptActivityInt
|
||||
private View mShareFile;
|
||||
private ListView mSelectedFiles;
|
||||
private SelectedFilesAdapter mAdapter = new SelectedFilesAdapter();
|
||||
private final Map<Uri, Bitmap> thumbnailCache = new HashMap<Uri, Bitmap>();
|
||||
private final Map<Uri, Bitmap> thumbnailCache = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
@@ -224,7 +224,7 @@ public class EncryptFilesFragment extends Fragment implements EncryptActivityInt
|
||||
@Override
|
||||
public void onNotifyUpdate() {
|
||||
// Clear cache if needed
|
||||
for (Uri uri : new HashSet<Uri>(thumbnailCache.keySet())) {
|
||||
for (Uri uri : new HashSet<>(thumbnailCache.keySet())) {
|
||||
if (!mEncryptInterface.getInputUris().contains(uri)) {
|
||||
thumbnailCache.remove(uri);
|
||||
}
|
||||
|
||||
@@ -121,13 +121,13 @@ public class EncryptTextActivity extends EncryptActivity implements EncryptActiv
|
||||
|
||||
@Override
|
||||
public ArrayList<Uri> getInputUris() {
|
||||
if (mInputUris == null) mInputUris = new ArrayList<Uri>();
|
||||
if (mInputUris == null) mInputUris = new ArrayList<>();
|
||||
return mInputUris;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Uri> getOutputUris() {
|
||||
if (mOutputUris == null) mOutputUris = new ArrayList<Uri>();
|
||||
if (mOutputUris == null) mOutputUris = new ArrayList<>();
|
||||
return mOutputUris;
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ public class EncryptTextActivity extends EncryptActivity implements EncryptActiv
|
||||
sendIntent.putExtra(Intent.EXTRA_TEXT, new String(message.getData().getByteArray(KeychainIntentService.RESULT_BYTES)));
|
||||
|
||||
if (!isModeSymmetric() && mEncryptionUserIds != null) {
|
||||
Set<String> users = new HashSet<String>();
|
||||
Set<String> users = new HashSet<>();
|
||||
for (String user : mEncryptionUserIds) {
|
||||
String[] userId = KeyRing.splitUserId(user);
|
||||
if (userId[1] != null) {
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
|
||||
@@ -29,7 +29,6 @@ import android.os.Message;
|
||||
import android.os.Messenger;
|
||||
import android.os.Parcelable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
||||
@@ -122,95 +121,102 @@ public class ImportKeysActivity extends BaseActivity {
|
||||
action = ACTION_IMPORT_KEY;
|
||||
}
|
||||
|
||||
if (ACTION_IMPORT_KEY.equals(action)) {
|
||||
switch (action) {
|
||||
case ACTION_IMPORT_KEY:
|
||||
/* Keychain's own Actions */
|
||||
startFileFragment(savedInstanceState);
|
||||
startFileFragment(savedInstanceState);
|
||||
|
||||
if (dataUri != null) {
|
||||
// action: directly load data
|
||||
startListFragment(savedInstanceState, null, dataUri, null);
|
||||
} else if (extras.containsKey(EXTRA_KEY_BYTES)) {
|
||||
byte[] importData = extras.getByteArray(EXTRA_KEY_BYTES);
|
||||
if (dataUri != null) {
|
||||
// action: directly load data
|
||||
startListFragment(savedInstanceState, null, dataUri, null);
|
||||
} else if (extras.containsKey(EXTRA_KEY_BYTES)) {
|
||||
byte[] importData = extras.getByteArray(EXTRA_KEY_BYTES);
|
||||
|
||||
// action: directly load data
|
||||
startListFragment(savedInstanceState, importData, null, null);
|
||||
}
|
||||
} else if (ACTION_IMPORT_KEY_FROM_KEYSERVER.equals(action)
|
||||
|| ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_TO_SERVICE.equals(action)
|
||||
|| ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT.equals(action)) {
|
||||
// action: directly load data
|
||||
startListFragment(savedInstanceState, importData, null, null);
|
||||
}
|
||||
break;
|
||||
case ACTION_IMPORT_KEY_FROM_KEYSERVER:
|
||||
case ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_TO_SERVICE:
|
||||
case ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT:
|
||||
|
||||
// only used for OpenPgpService
|
||||
if (extras.containsKey(EXTRA_PENDING_INTENT_DATA)) {
|
||||
mPendingIntentData = extras.getParcelable(EXTRA_PENDING_INTENT_DATA);
|
||||
}
|
||||
if (extras.containsKey(EXTRA_QUERY) || extras.containsKey(EXTRA_KEY_ID)) {
|
||||
// only used for OpenPgpService
|
||||
if (extras.containsKey(EXTRA_PENDING_INTENT_DATA)) {
|
||||
mPendingIntentData = extras.getParcelable(EXTRA_PENDING_INTENT_DATA);
|
||||
}
|
||||
if (extras.containsKey(EXTRA_QUERY) || extras.containsKey(EXTRA_KEY_ID)) {
|
||||
/* simple search based on query or key id */
|
||||
|
||||
String query = null;
|
||||
if (extras.containsKey(EXTRA_QUERY)) {
|
||||
query = extras.getString(EXTRA_QUERY);
|
||||
} else if (extras.containsKey(EXTRA_KEY_ID)) {
|
||||
long keyId = extras.getLong(EXTRA_KEY_ID, 0);
|
||||
if (keyId != 0) {
|
||||
query = KeyFormattingUtils.convertKeyIdToHex(keyId);
|
||||
String query = null;
|
||||
if (extras.containsKey(EXTRA_QUERY)) {
|
||||
query = extras.getString(EXTRA_QUERY);
|
||||
} else if (extras.containsKey(EXTRA_KEY_ID)) {
|
||||
long keyId = extras.getLong(EXTRA_KEY_ID, 0);
|
||||
if (keyId != 0) {
|
||||
query = KeyFormattingUtils.convertKeyIdToHex(keyId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (query != null && query.length() > 0) {
|
||||
// display keyserver fragment with query
|
||||
startCloudFragment(savedInstanceState, query, false);
|
||||
if (query != null && query.length() > 0) {
|
||||
// display keyserver fragment with query
|
||||
startCloudFragment(savedInstanceState, query, false);
|
||||
|
||||
// action: search immediately
|
||||
startListFragment(savedInstanceState, null, null, query);
|
||||
} else {
|
||||
Log.e(Constants.TAG, "Query is empty!");
|
||||
return;
|
||||
}
|
||||
} else if (extras.containsKey(EXTRA_FINGERPRINT)) {
|
||||
// action: search immediately
|
||||
startListFragment(savedInstanceState, null, null, query);
|
||||
} else {
|
||||
Log.e(Constants.TAG, "Query is empty!");
|
||||
return;
|
||||
}
|
||||
} else if (extras.containsKey(EXTRA_FINGERPRINT)) {
|
||||
/*
|
||||
* search based on fingerprint, here we can enforce a check in the end
|
||||
* if the right key has been downloaded
|
||||
*/
|
||||
|
||||
String fingerprint = extras.getString(EXTRA_FINGERPRINT);
|
||||
if (isFingerprintValid(fingerprint)) {
|
||||
String query = "0x" + fingerprint;
|
||||
String fingerprint = extras.getString(EXTRA_FINGERPRINT);
|
||||
if (isFingerprintValid(fingerprint)) {
|
||||
String query = "0x" + fingerprint;
|
||||
|
||||
// display keyserver fragment with query
|
||||
startCloudFragment(savedInstanceState, query, true);
|
||||
// display keyserver fragment with query
|
||||
startCloudFragment(savedInstanceState, query, true);
|
||||
|
||||
// action: search immediately
|
||||
startListFragment(savedInstanceState, null, null, query);
|
||||
// action: search immediately
|
||||
startListFragment(savedInstanceState, null, null, query);
|
||||
}
|
||||
} else {
|
||||
Log.e(Constants.TAG,
|
||||
"IMPORT_KEY_FROM_KEYSERVER action needs to contain the 'query', 'key_id', or " +
|
||||
"'fingerprint' extra!"
|
||||
);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
Log.e(Constants.TAG,
|
||||
"IMPORT_KEY_FROM_KEYSERVER action needs to contain the 'query', 'key_id', or " +
|
||||
"'fingerprint' extra!"
|
||||
);
|
||||
return;
|
||||
}
|
||||
} else if (ACTION_IMPORT_KEY_FROM_FILE.equals(action)) {
|
||||
// NOTE: this only displays the appropriate fragment, no actions are taken
|
||||
startFileFragment(savedInstanceState);
|
||||
break;
|
||||
case ACTION_IMPORT_KEY_FROM_FILE:
|
||||
// NOTE: this only displays the appropriate fragment, no actions are taken
|
||||
startFileFragment(savedInstanceState);
|
||||
|
||||
// no immediate actions!
|
||||
startListFragment(savedInstanceState, null, null, null);
|
||||
} else if (ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN.equals(action)) {
|
||||
// NOTE: this only displays the appropriate fragment, no actions are taken
|
||||
startFileFragment(savedInstanceState);
|
||||
// no immediate actions!
|
||||
startListFragment(savedInstanceState, null, null, null);
|
||||
break;
|
||||
case ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN:
|
||||
// NOTE: this only displays the appropriate fragment, no actions are taken
|
||||
startFileFragment(savedInstanceState);
|
||||
|
||||
// no immediate actions!
|
||||
startListFragment(savedInstanceState, null, null, null);
|
||||
} else if (ACTION_IMPORT_KEY_FROM_NFC.equals(action)) {
|
||||
// NOTE: this only displays the appropriate fragment, no actions are taken
|
||||
startFileFragment(savedInstanceState);
|
||||
// TODO!!!!!
|
||||
// no immediate actions!
|
||||
startListFragment(savedInstanceState, null, null, null);
|
||||
break;
|
||||
case ACTION_IMPORT_KEY_FROM_NFC:
|
||||
// NOTE: this only displays the appropriate fragment, no actions are taken
|
||||
startFileFragment(savedInstanceState);
|
||||
// TODO!!!!!
|
||||
|
||||
// no immediate actions!
|
||||
startListFragment(savedInstanceState, null, null, null);
|
||||
} else {
|
||||
startCloudFragment(savedInstanceState, null, false);
|
||||
startListFragment(savedInstanceState, null, null, null);
|
||||
// no immediate actions!
|
||||
startListFragment(savedInstanceState, null, null, null);
|
||||
break;
|
||||
default:
|
||||
startCloudFragment(savedInstanceState, null, false);
|
||||
startListFragment(savedInstanceState, null, null, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,7 +362,7 @@ public class ImportKeysActivity extends BaseActivity {
|
||||
// We parcel this iteratively into a file - anything we can
|
||||
// display here, we should be able to import.
|
||||
ParcelableFileCache<ParcelableKeyRing> cache =
|
||||
new ParcelableFileCache<ParcelableKeyRing>(this, "key_import.pcl");
|
||||
new ParcelableFileCache<>(this, "key_import.pcl");
|
||||
cache.writeCache(selectedEntries);
|
||||
|
||||
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
|
||||
@@ -388,7 +394,7 @@ public class ImportKeysActivity extends BaseActivity {
|
||||
data.putString(KeychainIntentService.IMPORT_KEY_SERVER, sls.mCloudPrefs.keyserver);
|
||||
|
||||
// get selected key entries
|
||||
ArrayList<ParcelableKeyRing> keys = new ArrayList<ParcelableKeyRing>();
|
||||
ArrayList<ParcelableKeyRing> keys = new ArrayList<>();
|
||||
{
|
||||
// change the format into ParcelableKeyRing
|
||||
ArrayList<ImportKeysListEntry> entries = mListFragment.getSelectedEntries();
|
||||
|
||||
@@ -81,7 +81,7 @@ public class ImportKeysCloudFragment extends Fragment {
|
||||
namesAndEmails.addAll(ContactHelper.getContactMails(getActivity()));
|
||||
mQueryEditText.setThreshold(3);
|
||||
mQueryEditText.setAdapter(
|
||||
new ArrayAdapter<String>
|
||||
new ArrayAdapter<>
|
||||
(getActivity(), android.R.layout.simple_spinner_dropdown_item,
|
||||
namesAndEmails
|
||||
)
|
||||
|
||||
@@ -113,7 +113,7 @@ public class ImportKeysListFragment extends ListFragment implements
|
||||
return mAdapter.getSelectedEntries();
|
||||
} else {
|
||||
Log.e(Constants.TAG, "Adapter not initialized, returning empty list");
|
||||
return new ArrayList<ImportKeysListEntry>();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
@@ -31,7 +30,6 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.Messenger;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.content.CursorLoader;
|
||||
import android.support.v4.content.Loader;
|
||||
@@ -52,7 +50,6 @@ import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView.MultiChoiceModeListener;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
@@ -60,16 +57,9 @@ import android.widget.TextView;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||
import org.sufficientlysecure.keychain.operations.results.DeleteResult;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.util.ExportHelper;
|
||||
import org.sufficientlysecure.keychain.util.KeyUpdateHelper;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||
@@ -78,15 +68,10 @@ import org.sufficientlysecure.keychain.ui.widget.ListAwareSwipeRefreshLayout;
|
||||
import org.sufficientlysecure.keychain.ui.util.Highlighter;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||
import org.sufficientlysecure.keychain.util.ParcelableFileCache;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
import edu.cmu.cylab.starslinger.exchange.ExchangeActivity;
|
||||
import edu.cmu.cylab.starslinger.exchange.ExchangeConfig;
|
||||
import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter;
|
||||
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
|
||||
|
||||
@@ -517,7 +502,7 @@ public class KeyListFragment extends LoaderFragment
|
||||
private String mQuery;
|
||||
private LayoutInflater mInflater;
|
||||
|
||||
private HashMap<Integer, Boolean> mSelection = new HashMap<Integer, Boolean>();
|
||||
private HashMap<Integer, Boolean> mSelection = new HashMap<>();
|
||||
|
||||
public KeyListAdapter(Context context, Cursor c, int flags) {
|
||||
super(context, c, flags);
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.View;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
|
||||
@@ -15,7 +15,6 @@ import android.nfc.Tag;
|
||||
import android.nfc.tech.IsoDep;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -23,13 +22,11 @@ import org.spongycastle.bcpg.HashAlgorithmTags;
|
||||
import org.spongycastle.util.encoders.Hex;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.util.Iso7816TLV;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* This class provides a communication interface to OpenPGP applications on ISO SmartCard compliant
|
||||
@@ -91,33 +88,38 @@ public class NfcActivity extends BaseActivity {
|
||||
mKeyId = data.getLong(EXTRA_KEY_ID);
|
||||
}
|
||||
|
||||
if (ACTION_SIGN_HASH.equals(action)) {
|
||||
mAction = action;
|
||||
mPin = data.getString(EXTRA_PIN);
|
||||
mHashToSign = data.getByteArray(EXTRA_NFC_HASH_TO_SIGN);
|
||||
mHashAlgo = data.getInt(EXTRA_NFC_HASH_ALGO);
|
||||
mServiceIntent = data.getParcelable(EXTRA_DATA);
|
||||
switch (action) {
|
||||
case ACTION_SIGN_HASH:
|
||||
mAction = action;
|
||||
mPin = data.getString(EXTRA_PIN);
|
||||
mHashToSign = data.getByteArray(EXTRA_NFC_HASH_TO_SIGN);
|
||||
mHashAlgo = data.getInt(EXTRA_NFC_HASH_ALGO);
|
||||
mServiceIntent = data.getParcelable(EXTRA_DATA);
|
||||
|
||||
Log.d(Constants.TAG, "NfcActivity mAction: " + mAction);
|
||||
Log.d(Constants.TAG, "NfcActivity mPin: " + mPin);
|
||||
Log.d(Constants.TAG, "NfcActivity mHashToSign as hex: " + getHex(mHashToSign));
|
||||
Log.d(Constants.TAG, "NfcActivity mServiceIntent: " + mServiceIntent.toString());
|
||||
} else if (ACTION_DECRYPT_SESSION_KEY.equals(action)) {
|
||||
mAction = action;
|
||||
mPin = data.getString(EXTRA_PIN);
|
||||
mEncryptedSessionKey = data.getByteArray(EXTRA_NFC_ENC_SESSION_KEY);
|
||||
mServiceIntent = data.getParcelable(EXTRA_DATA);
|
||||
Log.d(Constants.TAG, "NfcActivity mAction: " + mAction);
|
||||
Log.d(Constants.TAG, "NfcActivity mPin: " + mPin);
|
||||
Log.d(Constants.TAG, "NfcActivity mHashToSign as hex: " + getHex(mHashToSign));
|
||||
Log.d(Constants.TAG, "NfcActivity mServiceIntent: " + mServiceIntent.toString());
|
||||
break;
|
||||
case ACTION_DECRYPT_SESSION_KEY:
|
||||
mAction = action;
|
||||
mPin = data.getString(EXTRA_PIN);
|
||||
mEncryptedSessionKey = data.getByteArray(EXTRA_NFC_ENC_SESSION_KEY);
|
||||
mServiceIntent = data.getParcelable(EXTRA_DATA);
|
||||
|
||||
Log.d(Constants.TAG, "NfcActivity mAction: " + mAction);
|
||||
Log.d(Constants.TAG, "NfcActivity mPin: " + mPin);
|
||||
Log.d(Constants.TAG, "NfcActivity mEncryptedSessionKey as hex: " + getHex(mEncryptedSessionKey));
|
||||
Log.d(Constants.TAG, "NfcActivity mServiceIntent: " + mServiceIntent.toString());
|
||||
} else if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action)) {
|
||||
Log.e(Constants.TAG, "This should not happen! NfcActivity.onCreate() is being called instead of onNewIntent()!");
|
||||
toast("This should not happen! Please create a new bug report that the NFC screen is restarted!");
|
||||
finish();
|
||||
} else {
|
||||
Log.d(Constants.TAG, "Action not supported: " + action);
|
||||
Log.d(Constants.TAG, "NfcActivity mAction: " + mAction);
|
||||
Log.d(Constants.TAG, "NfcActivity mPin: " + mPin);
|
||||
Log.d(Constants.TAG, "NfcActivity mEncryptedSessionKey as hex: " + getHex(mEncryptedSessionKey));
|
||||
Log.d(Constants.TAG, "NfcActivity mServiceIntent: " + mServiceIntent.toString());
|
||||
break;
|
||||
case NfcAdapter.ACTION_TAG_DISCOVERED:
|
||||
Log.e(Constants.TAG, "This should not happen! NfcActivity.onCreate() is being called instead of onNewIntent()!");
|
||||
toast("This should not happen! Please create a new bug report that the NFC screen is restarted!");
|
||||
finish();
|
||||
break;
|
||||
default:
|
||||
Log.d(Constants.TAG, "Action not supported: " + action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ import android.nfc.Tag;
|
||||
import android.nfc.tech.IsoDep;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
@@ -209,9 +209,7 @@ public class PassphraseWizardActivity extends FragmentActivity implements LockPa
|
||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||
transaction.replace(R.id.fragmentContainer, lpf).addToBackStack(null).commit();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (FormatException e) {
|
||||
} catch (IOException | FormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -236,9 +234,7 @@ public class PassphraseWizardActivity extends FragmentActivity implements LockPa
|
||||
nfc.setText(R.string.nfc_wrong_tag);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (FormatException e) {
|
||||
} catch (IOException | FormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ public class QrCodeScanActivity extends FragmentActivity {
|
||||
data.putString(KeychainIntentService.IMPORT_KEY_SERVER, cloudPrefs.keyserver);
|
||||
|
||||
ParcelableKeyRing keyEntry = new ParcelableKeyRing(fingerprint, null, null);
|
||||
ArrayList<ParcelableKeyRing> selectedEntries = new ArrayList<ParcelableKeyRing>();
|
||||
ArrayList<ParcelableKeyRing> selectedEntries = new ArrayList<>();
|
||||
selectedEntries.add(keyEntry);
|
||||
|
||||
data.putParcelableArrayList(KeychainIntentService.IMPORT_KEY_LIST, selectedEntries);
|
||||
|
||||
@@ -20,7 +20,6 @@ package org.sufficientlysecure.keychain.ui;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||
import android.widget.ImageView;
|
||||
|
||||
@@ -27,13 +27,9 @@ import android.os.Bundle;
|
||||
import android.os.Message;
|
||||
import android.os.Messenger;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.NumberPicker;
|
||||
import android.widget.Spinner;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
@@ -50,7 +46,6 @@ import org.sufficientlysecure.keychain.util.ParcelableFileCache;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import edu.cmu.cylab.starslinger.exchange.ExchangeActivity;
|
||||
import edu.cmu.cylab.starslinger.exchange.ExchangeConfig;
|
||||
@@ -192,7 +187,7 @@ public class SafeSlingerActivity extends BaseActivity {
|
||||
// We parcel this iteratively into a file - anything we can
|
||||
// display here, we should be able to import.
|
||||
ParcelableFileCache<ParcelableKeyRing> cache =
|
||||
new ParcelableFileCache<ParcelableKeyRing>(activity, "key_import.pcl");
|
||||
new ParcelableFileCache<>(activity, "key_import.pcl");
|
||||
cache.writeCache(it.size(), it.iterator());
|
||||
|
||||
// fill values for this action
|
||||
@@ -220,7 +215,7 @@ public class SafeSlingerActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private static ArrayList<ParcelableKeyRing> getSlingedKeys(Bundle extras) {
|
||||
ArrayList<ParcelableKeyRing> list = new ArrayList<ParcelableKeyRing>();
|
||||
ArrayList<ParcelableKeyRing> list = new ArrayList<>();
|
||||
|
||||
if (extras != null) {
|
||||
byte[] d;
|
||||
|
||||
@@ -20,7 +20,6 @@ package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.View;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
|
||||
@@ -42,7 +42,6 @@ import android.widget.TextView;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.compatibility.ListFragmentWorkaround;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.SelectKeyCursorAdapter;
|
||||
@@ -216,7 +215,7 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
|
||||
public long[] getSelectedMasterKeyIds() {
|
||||
// mListView.getCheckedItemIds() would give the row ids of the KeyRings not the master key
|
||||
// ids!
|
||||
Vector<Long> vector = new Vector<Long>();
|
||||
Vector<Long> vector = new Vector<>();
|
||||
for (int i = 0; i < getListView().getCount(); ++i) {
|
||||
if (getListView().isItemChecked(i)) {
|
||||
vector.add(mAdapter.getMasterKeyId(i));
|
||||
@@ -238,7 +237,7 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
|
||||
* @return
|
||||
*/
|
||||
public String[] getSelectedUserIds() {
|
||||
Vector<String> userIds = new Vector<String>();
|
||||
Vector<String> userIds = new Vector<>();
|
||||
for (int i = 0; i < getListView().getCount(); ++i) {
|
||||
if (getListView().isItemChecked(i)) {
|
||||
userIds.add(mAdapter.getUserId(i));
|
||||
|
||||
@@ -20,7 +20,6 @@ package org.sufficientlysecure.keychain.ui;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
@@ -140,7 +139,7 @@ public class SettingsKeyServerActivity extends BaseActivity implements OnClickLi
|
||||
}
|
||||
|
||||
private Vector<String> serverList() {
|
||||
Vector<String> servers = new Vector<String>();
|
||||
Vector<String> servers = new Vector<>();
|
||||
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
||||
KeyServerEditor editor = (KeyServerEditor) mEditors.getChildAt(i);
|
||||
String tmp = editor.getValue();
|
||||
@@ -153,7 +152,7 @@ public class SettingsKeyServerActivity extends BaseActivity implements OnClickLi
|
||||
|
||||
private void okClicked() {
|
||||
Intent data = new Intent();
|
||||
Vector<String> servers = new Vector<String>();
|
||||
Vector<String> servers = new Vector<>();
|
||||
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
||||
KeyServerEditor editor = (KeyServerEditor) mEditors.getChildAt(i);
|
||||
String tmp = editor.getValue();
|
||||
|
||||
@@ -24,7 +24,6 @@ import android.os.Bundle;
|
||||
import android.os.Message;
|
||||
import android.os.Messenger;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
@@ -57,7 +56,7 @@ public class UploadKeyActivity extends BaseActivity {
|
||||
mUploadButton = findViewById(R.id.upload_key_action_upload);
|
||||
mKeyServerSpinner = (Spinner) findViewById(R.id.upload_key_keyserver);
|
||||
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
|
||||
android.R.layout.simple_spinner_item, Preferences.getPreferences(this)
|
||||
.getKeyServers()
|
||||
);
|
||||
|
||||
@@ -27,9 +27,6 @@ import android.support.v4.app.NavUtils;
|
||||
import android.support.v4.content.CursorLoader;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.text.SpannableString;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.format.DateFormat;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@@ -37,7 +34,6 @@ import android.widget.TextView;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.pgp.WrappedSignature;
|
||||
|
||||
@@ -20,8 +20,6 @@ package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.View;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
|
||||
@@ -228,10 +228,7 @@ public class ViewKeyShareFragment extends LoaderFragment implements
|
||||
}
|
||||
startActivity(Intent.createChooser(sendIntent, title));
|
||||
}
|
||||
} catch (PgpGeneralException e) {
|
||||
Log.e(Constants.TAG, "error processing key!", e);
|
||||
Notify.showNotify(getActivity(), R.string.error_key_processing, Notify.Style.ERROR);
|
||||
} catch (IOException e) {
|
||||
} catch (PgpGeneralException | IOException e) {
|
||||
Log.e(Constants.TAG, "error processing key!", e);
|
||||
Notify.showNotify(getActivity(), R.string.error_key_processing, Notify.Style.ERROR);
|
||||
} catch (ProviderHelper.NotFoundException e) {
|
||||
|
||||
@@ -95,8 +95,8 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
||||
* @see org.sufficientlysecure.keychain.operations.ImportExportOperation
|
||||
*/
|
||||
public ArrayList<ImportKeysListEntry> getSelectedEntries() {
|
||||
ArrayList<ImportKeysListEntry> result = new ArrayList<ImportKeysListEntry>();
|
||||
ArrayList<ImportKeysListEntry> secrets = new ArrayList<ImportKeysListEntry>();
|
||||
ArrayList<ImportKeysListEntry> result = new ArrayList<>();
|
||||
ArrayList<ImportKeysListEntry> secrets = new ArrayList<>();
|
||||
if (mData == null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class ImportKeysListCloudLoader
|
||||
Preferences.CloudSearchPrefs mCloudPrefs;
|
||||
String mServerQuery;
|
||||
|
||||
private ArrayList<ImportKeysListEntry> mEntryList = new ArrayList<ImportKeysListEntry>();
|
||||
private ArrayList<ImportKeysListEntry> mEntryList = new ArrayList<>();
|
||||
private AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> mEntryListWrapper;
|
||||
|
||||
public ImportKeysListCloudLoader(Context context, String serverQuery, Preferences.CloudSearchPrefs cloudPrefs) {
|
||||
@@ -51,7 +51,7 @@ public class ImportKeysListCloudLoader
|
||||
|
||||
@Override
|
||||
public AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> loadInBackground() {
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, null);
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<>(mEntryList, null);
|
||||
|
||||
if (mServerQuery == null) {
|
||||
Log.e(Constants.TAG, "mServerQuery is null!");
|
||||
@@ -119,7 +119,7 @@ public class ImportKeysListCloudLoader
|
||||
mEntryList.addAll(searchResult);
|
||||
}
|
||||
GetKeyResult getKeyResult = new GetKeyResult(GetKeyResult.RESULT_OK, null);
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, getKeyResult);
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<>(mEntryList, getKeyResult);
|
||||
} catch (Keyserver.CloudSearchFailureException e) {
|
||||
// convert exception to result parcel
|
||||
int error = GetKeyResult.RESULT_ERROR;
|
||||
@@ -140,7 +140,7 @@ public class ImportKeysListCloudLoader
|
||||
OperationResult.OperationLog log = new OperationResult.OperationLog();
|
||||
log.add(logType, 0);
|
||||
GetKeyResult getKeyResult = new GetKeyResult(error, log);
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, getKeyResult);
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<>(mEntryList, getKeyResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ import org.sufficientlysecure.keychain.util.PositionAwareInputStream;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class ImportKeysListLoader
|
||||
extends AsyncTaskLoader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> {
|
||||
@@ -55,8 +54,8 @@ public class ImportKeysListLoader
|
||||
final Context mContext;
|
||||
final InputData mInputData;
|
||||
|
||||
ArrayList<ImportKeysListEntry> mData = new ArrayList<ImportKeysListEntry>();
|
||||
LongSparseArray<ParcelableKeyRing> mParcelableRings = new LongSparseArray<ParcelableKeyRing>();
|
||||
ArrayList<ImportKeysListEntry> mData = new ArrayList<>();
|
||||
LongSparseArray<ParcelableKeyRing> mParcelableRings = new LongSparseArray<>();
|
||||
AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> mEntryListWrapper;
|
||||
|
||||
public ImportKeysListLoader(Context context, InputData inputData) {
|
||||
@@ -73,7 +72,7 @@ public class ImportKeysListLoader
|
||||
}
|
||||
|
||||
GetKeyResult getKeyResult = new GetKeyResult(GetKeyResult.RESULT_OK, null);
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mData, getKeyResult);
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<>(mData, getKeyResult);
|
||||
|
||||
if (mInputData == null) {
|
||||
Log.e(Constants.TAG, "Input data is null!");
|
||||
@@ -140,7 +139,7 @@ public class ImportKeysListLoader
|
||||
OperationResult.OperationLog log = new OperationResult.OperationLog();
|
||||
log.add(OperationResult.LogType.MSG_GET_NO_VALID_KEYS, 0);
|
||||
GetKeyResult getKeyResult = new GetKeyResult(GetKeyResult.RESULT_ERROR_NO_VALID_KEYS, log);
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<>
|
||||
(mData, getKeyResult);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class KeyValueSpinnerAdapter extends ArrayAdapter<String> {
|
||||
|
||||
static <K, V extends Comparable<? super V>> SortedSet<Map.Entry<K, V>> entriesSortedByValues(
|
||||
Map<K, V> map) {
|
||||
SortedSet<Map.Entry<K, V>> sortedEntries = new TreeSet<Map.Entry<K, V>>(
|
||||
SortedSet<Map.Entry<K, V>> sortedEntries = new TreeSet<>(
|
||||
new Comparator<Map.Entry<K, V>>() {
|
||||
@Override
|
||||
public int compare(Map.Entry<K, V> e1, Map.Entry<K, V> e2) {
|
||||
|
||||
@@ -44,7 +44,7 @@ public class MultiUserIdsAdapter extends CursorAdapter {
|
||||
public MultiUserIdsAdapter(Context context, Cursor c, int flags) {
|
||||
super(context, c, flags);
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mCheckStates = new ArrayList<Boolean>();
|
||||
mCheckStates = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,7 +148,7 @@ public class MultiUserIdsAdapter extends CursorAdapter {
|
||||
}
|
||||
|
||||
public ArrayList<CertifyAction> getSelectedCertifyActions() {
|
||||
LongSparseArray<CertifyAction> actions = new LongSparseArray<CertifyAction>();
|
||||
LongSparseArray<CertifyAction> actions = new LongSparseArray<>();
|
||||
for (int i = 0; i < mCheckStates.size(); i++) {
|
||||
if (mCheckStates.get(i)) {
|
||||
mCursor.moveToPosition(i);
|
||||
@@ -171,7 +171,7 @@ public class MultiUserIdsAdapter extends CursorAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<CertifyAction> result = new ArrayList<CertifyAction>(actions.size());
|
||||
ArrayList<CertifyAction> result = new ArrayList<>(actions.size());
|
||||
for (int i = 0; i < actions.size(); i++) {
|
||||
result.add(actions.valueAt(i));
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.ArrayList;
|
||||
|
||||
public class PagerTabStripAdapter extends FragmentPagerAdapter {
|
||||
protected final Activity mActivity;
|
||||
protected final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
|
||||
protected final ArrayList<TabInfo> mTabs = new ArrayList<>();
|
||||
|
||||
static final class TabInfo {
|
||||
public final Class<?> clss;
|
||||
|
||||
@@ -36,7 +36,6 @@ import android.widget.TextView;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.SubkeyChange;
|
||||
import org.sufficientlysecure.keychain.ui.util.FormattingUtils;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class TabsAdapter extends FragmentStatePagerAdapter implements ActionBar.
|
||||
private final Context mContext;
|
||||
private final ActionBar mActionBar;
|
||||
private final ViewPager mViewPager;
|
||||
private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
|
||||
private final ArrayList<TabInfo> mTabs = new ArrayList<>();
|
||||
|
||||
static final class TabInfo {
|
||||
public final Class<?> clss;
|
||||
|
||||
@@ -221,7 +221,7 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC
|
||||
}
|
||||
|
||||
public ArrayList<String> getSelectedUserIds() {
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
for (int i = 0; i < mCheckStates.size(); i++) {
|
||||
if (mCheckStates.get(i)) {
|
||||
mCursor.moveToPosition(i);
|
||||
|
||||
@@ -145,20 +145,20 @@ public class AddSubkeyDialogFragment extends DialogFragment {
|
||||
}
|
||||
|
||||
{
|
||||
ArrayList<Choice<Algorithm>> choices = new ArrayList<Choice<Algorithm>>();
|
||||
choices.add(new Choice<Algorithm>(Algorithm.DSA, getResources().getString(
|
||||
ArrayList<Choice<Algorithm>> choices = new ArrayList<>();
|
||||
choices.add(new Choice<>(Algorithm.DSA, getResources().getString(
|
||||
R.string.dsa)));
|
||||
if (!mWillBeMasterKey) {
|
||||
choices.add(new Choice<Algorithm>(Algorithm.ELGAMAL, getResources().getString(
|
||||
choices.add(new Choice<>(Algorithm.ELGAMAL, getResources().getString(
|
||||
R.string.elgamal)));
|
||||
}
|
||||
choices.add(new Choice<Algorithm>(Algorithm.RSA, getResources().getString(
|
||||
choices.add(new Choice<>(Algorithm.RSA, getResources().getString(
|
||||
R.string.rsa)));
|
||||
choices.add(new Choice<Algorithm>(Algorithm.ECDSA, getResources().getString(
|
||||
choices.add(new Choice<>(Algorithm.ECDSA, getResources().getString(
|
||||
R.string.ecdsa)));
|
||||
choices.add(new Choice<Algorithm>(Algorithm.ECDH, getResources().getString(
|
||||
choices.add(new Choice<>(Algorithm.ECDH, getResources().getString(
|
||||
R.string.ecdh)));
|
||||
ArrayAdapter<Choice<Algorithm>> adapter = new ArrayAdapter<Choice<Algorithm>>(context,
|
||||
ArrayAdapter<Choice<Algorithm>> adapter = new ArrayAdapter<>(context,
|
||||
android.R.layout.simple_spinner_item, choices);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
mAlgorithmSpinner.setAdapter(adapter);
|
||||
@@ -172,20 +172,20 @@ public class AddSubkeyDialogFragment extends DialogFragment {
|
||||
}
|
||||
|
||||
// dynamic ArrayAdapter must be created (instead of ArrayAdapter.getFromResource), because it's content may change
|
||||
ArrayAdapter<CharSequence> keySizeAdapter = new ArrayAdapter<CharSequence>(context, android.R.layout.simple_spinner_item,
|
||||
ArrayAdapter<CharSequence> keySizeAdapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item,
|
||||
new ArrayList<CharSequence>(Arrays.asList(getResources().getStringArray(R.array.rsa_key_size_spinner_values))));
|
||||
keySizeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
mKeySizeSpinner.setAdapter(keySizeAdapter);
|
||||
mKeySizeSpinner.setSelection(1); // Default to 4096 for the key length
|
||||
|
||||
{
|
||||
ArrayList<Choice<Curve>> choices = new ArrayList<Choice<Curve>>();
|
||||
ArrayList<Choice<Curve>> choices = new ArrayList<>();
|
||||
|
||||
choices.add(new Choice<Curve>(Curve.NIST_P256, getResources().getString(
|
||||
choices.add(new Choice<>(Curve.NIST_P256, getResources().getString(
|
||||
R.string.key_curve_nist_p256)));
|
||||
choices.add(new Choice<Curve>(Curve.NIST_P384, getResources().getString(
|
||||
choices.add(new Choice<>(Curve.NIST_P384, getResources().getString(
|
||||
R.string.key_curve_nist_p384)));
|
||||
choices.add(new Choice<Curve>(Curve.NIST_P521, getResources().getString(
|
||||
choices.add(new Choice<>(Curve.NIST_P521, getResources().getString(
|
||||
R.string.key_curve_nist_p521)));
|
||||
|
||||
/* @see SaveKeyringParcel
|
||||
@@ -197,7 +197,7 @@ public class AddSubkeyDialogFragment extends DialogFragment {
|
||||
R.string.key_curve_bp_p512)));
|
||||
*/
|
||||
|
||||
ArrayAdapter<Choice<Curve>> adapter = new ArrayAdapter<Choice<Curve>>(context,
|
||||
ArrayAdapter<Choice<Curve>> adapter = new ArrayAdapter<>(context,
|
||||
android.R.layout.simple_spinner_item, choices);
|
||||
mCurveSpinner.setAdapter(adapter);
|
||||
// make NIST P-256 the default
|
||||
|
||||
@@ -85,7 +85,7 @@ public class AddUserIdDialogFragment extends DialogFragment implements OnEditorA
|
||||
mMessenger = getArguments().getParcelable(ARG_MESSENGER);
|
||||
String predefinedName = getArguments().getString(ARG_NAME);
|
||||
|
||||
ArrayAdapter<String> autoCompleteEmailAdapter = new ArrayAdapter<String>
|
||||
ArrayAdapter<String> autoCompleteEmailAdapter = new ArrayAdapter<>
|
||||
(getActivity(), android.R.layout.simple_spinner_dropdown_item,
|
||||
ContactHelper.getPossibleUserEmails(getActivity())
|
||||
);
|
||||
@@ -150,7 +150,7 @@ public class AddUserIdDialogFragment extends DialogFragment implements OnEditorA
|
||||
|
||||
mName.setThreshold(1); // Start working from first character
|
||||
mName.setAdapter(
|
||||
new ArrayAdapter<String>
|
||||
new ArrayAdapter<>
|
||||
(getActivity(), android.R.layout.simple_spinner_dropdown_item,
|
||||
ContactHelper.getPossibleUserNames(getActivity())
|
||||
)
|
||||
|
||||
@@ -28,7 +28,6 @@ import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.apache.http.conn.scheme.Scheme;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.util.FileHelper;
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class QrCodeUtils {
|
||||
*/
|
||||
public static Bitmap getQRCodeBitmap(final String input, final int size) {
|
||||
try {
|
||||
final Hashtable<EncodeHintType, Object> hints = new Hashtable<EncodeHintType, Object>();
|
||||
final Hashtable<EncodeHintType, Object> hints = new Hashtable<>();
|
||||
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
|
||||
final BitMatrix result = new QRCodeWriter().encode(input, BarcodeFormat.QR_CODE, size,
|
||||
size, hints);
|
||||
|
||||
@@ -29,7 +29,6 @@ import android.widget.ImageView;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
|
||||
public class CertifyKeySpinner extends KeySpinner {
|
||||
|
||||
@@ -28,7 +28,6 @@ import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.content.CursorLoader;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -46,7 +45,6 @@ import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.util.ContactHelper;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
||||
@@ -165,7 +163,7 @@ public class EncryptKeyCompletionView extends TokenCompleteTextView {
|
||||
setAdapter(new EncryptKeyAdapter(Collections.<EncryptionKey>emptyList()));
|
||||
return;
|
||||
}
|
||||
ArrayList<EncryptionKey> keys = new ArrayList<EncryptionKey>();
|
||||
ArrayList<EncryptionKey> keys = new ArrayList<>();
|
||||
while (cursor.moveToNext()) {
|
||||
try {
|
||||
EncryptionKey key = new EncryptionKey(cursor);
|
||||
|
||||
@@ -20,13 +20,8 @@ package org.sufficientlysecure.keychain.ui.widget;
|
||||
import android.content.Context;
|
||||
import android.support.v4.widget.NoScrollableSwipeRefreshLayout;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.InputDevice;
|
||||
import android.view.InputDevice.MotionRange;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
|
||||
|
||||
public class ListAwareSwipeRefreshLayout extends NoScrollableSwipeRefreshLayout {
|
||||
|
||||
@@ -26,7 +26,6 @@ import android.support.v4.content.Loader;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user