mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-25 16:01:52 -05:00
more code style changes in /ui and /util
This commit is contained in:
parent
4353ea37e2
commit
2ff6949c95
@ -848,7 +848,7 @@ public class EncryptActivity extends DrawerActivity {
|
||||
new Choice(Id.choice.compression.zlib, "ZLIB ("
|
||||
+ getString(R.string.compression_fast) + ")"),
|
||||
new Choice(Id.choice.compression.bzip2, "BZIP2 ("
|
||||
+ getString(R.string.compression_very_slow) + ")"),};
|
||||
+ getString(R.string.compression_very_slow) + ")"), };
|
||||
ArrayAdapter<Choice> adapter = new ArrayAdapter<Choice>(this,
|
||||
android.R.layout.simple_spinner_item, choices);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
|
@ -167,7 +167,8 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa
|
||||
query = "0x" + fingerprint;
|
||||
}
|
||||
} else {
|
||||
Log.e(Constants.TAG, "IMPORT_KEY_FROM_KEYSERVER action needs to contain the 'query', 'key_id', or 'fingerprint' extra!");
|
||||
Log.e(Constants.TAG,
|
||||
"IMPORT_KEY_FROM_KEYSERVER action needs to contain the 'query', 'key_id', or 'fingerprint' extra!");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -398,7 +399,8 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa
|
||||
AppMsg.makeText(ImportKeysActivity.this, toastMessage, AppMsg.STYLE_INFO)
|
||||
.show();
|
||||
if (bad > 0) {
|
||||
BadImportKeyDialogFragment badImportKeyDialogFragment = BadImportKeyDialogFragment.newInstance(bad);
|
||||
BadImportKeyDialogFragment badImportKeyDialogFragment =
|
||||
BadImportKeyDialogFragment.newInstance(bad);
|
||||
badImportKeyDialogFragment.show(getSupportFragmentManager(), "badKeyDialog");
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,8 @@ public class ImportKeysServerFragment extends Fragment {
|
||||
search(query, keyServer);
|
||||
|
||||
// close keyboard after pressing search
|
||||
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
InputMethodManager imm =
|
||||
(InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(mQueryEditText.getWindowToken(), 0);
|
||||
}
|
||||
});
|
||||
@ -108,7 +109,6 @@ public class ImportKeysServerFragment extends Fragment {
|
||||
search(query, keyServer);
|
||||
|
||||
// Don't return true to let the keyboard close itself after pressing search
|
||||
// http://stackoverflow.com/questions/2342620/how-to-hide-keyboard-after-typing-in-edittext-in-android
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
@ -141,7 +141,7 @@ public class SelectSecretKeyFragment extends ListFragment implements
|
||||
+ Keys.IS_REVOKED + " = '0' AND valid_keys." + Keys.CAN_SIGN
|
||||
+ " = '1' AND valid_keys." + Keys.CREATION + " <= '" + now + "' AND "
|
||||
+ "(valid_keys." + Keys.EXPIRY + " IS NULL OR valid_keys." + Keys.EXPIRY
|
||||
+ " >= '" + now + "')) AS " + SelectKeyCursorAdapter.PROJECTION_ROW_VALID,};
|
||||
+ " >= '" + now + "')) AS " + SelectKeyCursorAdapter.PROJECTION_ROW_VALID, };
|
||||
|
||||
String orderBy = UserIds.USER_ID + " ASC";
|
||||
|
||||
|
@ -27,20 +27,20 @@ package org.sufficientlysecure.keychain.ui.adapter;
|
||||
*/
|
||||
public class AsyncTaskResultWrapper<T> {
|
||||
|
||||
private final T result;
|
||||
private final Exception error;
|
||||
private final T mResult;
|
||||
private final Exception mError;
|
||||
|
||||
public AsyncTaskResultWrapper(T result, Exception error) {
|
||||
this.result = result;
|
||||
this.error = error;
|
||||
this.mResult = result;
|
||||
this.mError = error;
|
||||
}
|
||||
|
||||
public T getResult() {
|
||||
return result;
|
||||
return mResult;
|
||||
}
|
||||
|
||||
public Exception getError() {
|
||||
return error;
|
||||
return mError;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,15 +40,15 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
||||
protected LayoutInflater mInflater;
|
||||
protected Activity mActivity;
|
||||
|
||||
protected List<ImportKeysListEntry> data;
|
||||
protected List<ImportKeysListEntry> mData;
|
||||
|
||||
static class ViewHolder {
|
||||
private TextView mainUserId;
|
||||
private TextView mainUserIdRest;
|
||||
private TextView keyId;
|
||||
private TextView fingerprint;
|
||||
private TextView algorithm;
|
||||
private TextView status;
|
||||
private TextView mMainUserId;
|
||||
private TextView mMainUserIdRest;
|
||||
private TextView mKeyId;
|
||||
private TextView mFingerprint;
|
||||
private TextView mAlgorithm;
|
||||
private TextView mStatus;
|
||||
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
||||
public void setData(List<ImportKeysListEntry> data) {
|
||||
clear();
|
||||
if (data != null) {
|
||||
this.data = data;
|
||||
this.mData = data;
|
||||
|
||||
// add data to extended ArrayAdapter
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
@ -76,15 +76,16 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
||||
}
|
||||
|
||||
public List<ImportKeysListEntry> getData() {
|
||||
return data;
|
||||
return mData;
|
||||
}
|
||||
|
||||
public ArrayList<ImportKeysListEntry> getSelectedData() {
|
||||
ArrayList<ImportKeysListEntry> selectedData = new ArrayList<ImportKeysListEntry>();
|
||||
for (ImportKeysListEntry entry : data) {
|
||||
if (entry.isSelected())
|
||||
for (ImportKeysListEntry entry : mData) {
|
||||
if (entry.isSelected()) {
|
||||
selectedData.add(entry);
|
||||
}
|
||||
}
|
||||
return selectedData;
|
||||
}
|
||||
|
||||
@ -94,17 +95,17 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
||||
}
|
||||
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
ImportKeysListEntry entry = data.get(position);
|
||||
ImportKeysListEntry entry = mData.get(position);
|
||||
ViewHolder holder;
|
||||
if (convertView == null) {
|
||||
holder = new ViewHolder();
|
||||
convertView = mInflater.inflate(R.layout.import_keys_list_entry, null);
|
||||
holder.mainUserId = (TextView) convertView.findViewById(R.id.mainUserId);
|
||||
holder.mainUserIdRest = (TextView) convertView.findViewById(R.id.mainUserIdRest);
|
||||
holder.keyId = (TextView) convertView.findViewById(R.id.keyId);
|
||||
holder.fingerprint = (TextView) convertView.findViewById(R.id.fingerprint);
|
||||
holder.algorithm = (TextView) convertView.findViewById(R.id.algorithm);
|
||||
holder.status = (TextView) convertView.findViewById(R.id.status);
|
||||
holder.mMainUserId = (TextView) convertView.findViewById(R.id.mainUserId);
|
||||
holder.mMainUserIdRest = (TextView) convertView.findViewById(R.id.mainUserIdRest);
|
||||
holder.mKeyId = (TextView) convertView.findViewById(R.id.keyId);
|
||||
holder.mFingerprint = (TextView) convertView.findViewById(R.id.fingerprint);
|
||||
holder.mAlgorithm = (TextView) convertView.findViewById(R.id.algorithm);
|
||||
holder.mStatus = (TextView) convertView.findViewById(R.id.status);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
@ -118,36 +119,36 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
||||
// show red user id if it is a secret key
|
||||
if (entry.secretKey) {
|
||||
userIdSplit[0] = mActivity.getString(R.string.secret_key) + " " + userIdSplit[0];
|
||||
holder.mainUserId.setTextColor(Color.RED);
|
||||
holder.mMainUserId.setTextColor(Color.RED);
|
||||
}
|
||||
holder.mainUserId.setText(userIdSplit[0]);
|
||||
holder.mMainUserId.setText(userIdSplit[0]);
|
||||
} else {
|
||||
holder.mainUserId.setText(R.string.user_id_no_name);
|
||||
holder.mMainUserId.setText(R.string.user_id_no_name);
|
||||
}
|
||||
|
||||
// email
|
||||
if (userIdSplit[1] != null) {
|
||||
holder.mainUserIdRest.setText(userIdSplit[1]);
|
||||
holder.mainUserIdRest.setVisibility(View.VISIBLE);
|
||||
holder.mMainUserIdRest.setText(userIdSplit[1]);
|
||||
holder.mMainUserIdRest.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.mainUserIdRest.setVisibility(View.GONE);
|
||||
holder.mMainUserIdRest.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
holder.keyId.setText(entry.hexKeyId);
|
||||
holder.mKeyId.setText(entry.hexKeyId);
|
||||
|
||||
if (entry.fingerPrint != null) {
|
||||
holder.fingerprint.setText(mActivity.getString(R.string.fingerprint) + " " + entry.fingerPrint);
|
||||
holder.fingerprint.setVisibility(View.VISIBLE);
|
||||
holder.mFingerprint.setText(mActivity.getString(R.string.fingerprint) + " " + entry.fingerPrint);
|
||||
holder.mFingerprint.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.fingerprint.setVisibility(View.GONE);
|
||||
holder.mFingerprint.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
holder.algorithm.setText("" + entry.bitStrength + "/" + entry.algorithm);
|
||||
holder.mAlgorithm.setText("" + entry.bitStrength + "/" + entry.algorithm);
|
||||
|
||||
if (entry.revoked) {
|
||||
holder.status.setText(R.string.revoked);
|
||||
holder.mStatus.setText(R.string.revoked);
|
||||
} else {
|
||||
holder.status.setVisibility(View.GONE);
|
||||
holder.mStatus.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
LinearLayout ll = (LinearLayout) convertView.findViewById(R.id.list);
|
||||
|
@ -45,9 +45,9 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
||||
public String algorithm;
|
||||
public boolean secretKey;
|
||||
|
||||
private boolean selected;
|
||||
private boolean mSelected;
|
||||
|
||||
private byte[] bytes = new byte[]{};
|
||||
private byte[] mBytes = new byte[]{};
|
||||
|
||||
public ImportKeysListEntry(ImportKeysListEntry b) {
|
||||
this.userIds = b.userIds;
|
||||
@ -59,8 +59,8 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
||||
this.bitStrength = b.bitStrength;
|
||||
this.algorithm = b.algorithm;
|
||||
this.secretKey = b.secretKey;
|
||||
this.selected = b.selected;
|
||||
this.bytes = b.bytes;
|
||||
this.mSelected = b.mSelected;
|
||||
this.mBytes = b.mBytes;
|
||||
}
|
||||
|
||||
public int describeContents() {
|
||||
@ -78,9 +78,9 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
||||
dest.writeInt(bitStrength);
|
||||
dest.writeString(algorithm);
|
||||
dest.writeByte((byte) (secretKey ? 1 : 0));
|
||||
dest.writeByte((byte) (selected ? 1 : 0));
|
||||
dest.writeInt(bytes.length);
|
||||
dest.writeByteArray(bytes);
|
||||
dest.writeByte((byte) (mSelected ? 1 : 0));
|
||||
dest.writeInt(mBytes.length);
|
||||
dest.writeByteArray(mBytes);
|
||||
}
|
||||
|
||||
public static final Creator<ImportKeysListEntry> CREATOR = new Creator<ImportKeysListEntry>() {
|
||||
@ -96,9 +96,9 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
||||
vr.bitStrength = source.readInt();
|
||||
vr.algorithm = source.readString();
|
||||
vr.secretKey = source.readByte() == 1;
|
||||
vr.selected = source.readByte() == 1;
|
||||
vr.bytes = new byte[source.readInt()];
|
||||
source.readByteArray(vr.bytes);
|
||||
vr.mSelected = source.readByte() == 1;
|
||||
vr.mBytes = new byte[source.readInt()];
|
||||
source.readByteArray(vr.mBytes);
|
||||
|
||||
return vr;
|
||||
}
|
||||
@ -113,11 +113,11 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
return bytes;
|
||||
return mBytes;
|
||||
}
|
||||
|
||||
public void setBytes(byte[] bytes) {
|
||||
this.bytes = bytes;
|
||||
this.mBytes = bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -127,16 +127,16 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
||||
// keys from keyserver are always public keys
|
||||
secretKey = false;
|
||||
// do not select by default
|
||||
selected = false;
|
||||
mSelected = false;
|
||||
userIds = new ArrayList<String>();
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
return selected;
|
||||
return mSelected;
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
this.selected = selected;
|
||||
this.mSelected = selected;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -146,13 +146,13 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
||||
public ImportKeysListEntry(PGPKeyRing pgpKeyRing) {
|
||||
// save actual key object into entry, used to import it later
|
||||
try {
|
||||
this.bytes = pgpKeyRing.getEncoded();
|
||||
this.mBytes = pgpKeyRing.getEncoded();
|
||||
} catch (IOException e) {
|
||||
Log.e(Constants.TAG, "IOException on pgpKeyRing.getEncoded()", e);
|
||||
}
|
||||
|
||||
// selected is default
|
||||
this.selected = true;
|
||||
this.mSelected = true;
|
||||
|
||||
if (pgpKeyRing instanceof PGPSecretKeyRing) {
|
||||
secretKey = true;
|
||||
|
@ -31,21 +31,22 @@ import java.io.BufferedInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ImportKeysListLoader extends AsyncTaskLoader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> {
|
||||
public class ImportKeysListLoader
|
||||
extends AsyncTaskLoader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> {
|
||||
|
||||
public static class FileHasNoContent extends Exception {
|
||||
|
||||
}
|
||||
|
||||
public static class NonPgpPart extends Exception {
|
||||
private int count;
|
||||
private int mCount;
|
||||
|
||||
public NonPgpPart(int count) {
|
||||
this.count = count;
|
||||
this.mCount = count;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
return mCount;
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,8 +54,8 @@ public class ImportKeysListLoader extends AsyncTaskLoader<AsyncTaskResultWrapper
|
||||
|
||||
InputData mInputData;
|
||||
|
||||
ArrayList<ImportKeysListEntry> data = new ArrayList<ImportKeysListEntry>();
|
||||
AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> entryListWrapper;
|
||||
ArrayList<ImportKeysListEntry> mData = new ArrayList<ImportKeysListEntry>();
|
||||
AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> mEntryListWrapper;
|
||||
|
||||
public ImportKeysListLoader(Context context, InputData inputData) {
|
||||
super(context);
|
||||
@ -65,16 +66,16 @@ public class ImportKeysListLoader extends AsyncTaskLoader<AsyncTaskResultWrapper
|
||||
@Override
|
||||
public AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> loadInBackground() {
|
||||
|
||||
entryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(data, null);
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mData, null);
|
||||
|
||||
if (mInputData == null) {
|
||||
Log.e(Constants.TAG, "Input data is null!");
|
||||
return entryListWrapper;
|
||||
return mEntryListWrapper;
|
||||
}
|
||||
|
||||
generateListOfKeyrings(mInputData);
|
||||
|
||||
return entryListWrapper;
|
||||
return mEntryListWrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -142,25 +143,25 @@ public class ImportKeysListLoader extends AsyncTaskLoader<AsyncTaskResultWrapper
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(Constants.TAG, "Exception on parsing key file!", e);
|
||||
entryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(data, e);
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mData, e);
|
||||
nonPgpCounter = 0;
|
||||
}
|
||||
|
||||
if (isEmpty) {
|
||||
Log.e(Constants.TAG, "File has no content!", new FileHasNoContent());
|
||||
entryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>
|
||||
(data, new FileHasNoContent());
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>
|
||||
(mData, new FileHasNoContent());
|
||||
}
|
||||
|
||||
if (nonPgpCounter > 0) {
|
||||
entryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>
|
||||
(data, new NonPgpPart(nonPgpCounter));
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>
|
||||
(mData, new NonPgpPart(nonPgpCounter));
|
||||
}
|
||||
}
|
||||
|
||||
private void addToData(PGPKeyRing keyring) {
|
||||
ImportKeysListEntry item = new ImportKeysListEntry(keyring);
|
||||
data.add(item);
|
||||
mData.add(item);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,14 +26,15 @@ import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ImportKeysListServerLoader extends AsyncTaskLoader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> {
|
||||
public class ImportKeysListServerLoader
|
||||
extends AsyncTaskLoader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> {
|
||||
Context mContext;
|
||||
|
||||
String mServerQuery;
|
||||
String mKeyServer;
|
||||
|
||||
private ArrayList<ImportKeysListEntry> entryList = new ArrayList<ImportKeysListEntry>();
|
||||
private AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> entryListWrapper;
|
||||
private ArrayList<ImportKeysListEntry> mEntryList = new ArrayList<ImportKeysListEntry>();
|
||||
private AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> mEntryListWrapper;
|
||||
|
||||
public ImportKeysListServerLoader(Context context, String serverQuery, String keyServer) {
|
||||
super(context);
|
||||
@ -45,16 +46,16 @@ public class ImportKeysListServerLoader extends AsyncTaskLoader<AsyncTaskResultW
|
||||
@Override
|
||||
public AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> loadInBackground() {
|
||||
|
||||
entryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(entryList, null);
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, null);
|
||||
|
||||
if (mServerQuery == null) {
|
||||
Log.e(Constants.TAG, "mServerQuery is null!");
|
||||
return entryListWrapper;
|
||||
return mEntryListWrapper;
|
||||
}
|
||||
|
||||
queryServer(mServerQuery, mKeyServer);
|
||||
|
||||
return entryListWrapper;
|
||||
return mEntryListWrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -89,17 +90,17 @@ public class ImportKeysListServerLoader extends AsyncTaskLoader<AsyncTaskResultW
|
||||
ArrayList<ImportKeysListEntry> searchResult = server.search(query);
|
||||
|
||||
// add result to data
|
||||
entryList.addAll(searchResult);
|
||||
entryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(entryList, null);
|
||||
mEntryList.addAll(searchResult);
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, null);
|
||||
} catch (KeyServer.InsufficientQuery e) {
|
||||
Log.e(Constants.TAG, "InsufficientQuery", e);
|
||||
entryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(entryList, e);
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
|
||||
} catch (KeyServer.QueryException e) {
|
||||
Log.e(Constants.TAG, "QueryException", e);
|
||||
entryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(entryList, e);
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
|
||||
} catch (KeyServer.TooManyResponses e) {
|
||||
Log.e(Constants.TAG, "TooManyResponses", e);
|
||||
entryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(entryList, e);
|
||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,8 +44,8 @@ public class SelectKeyCursorAdapter extends HighlightQueryCursorAdapter {
|
||||
private int mIndexProjectionValid;
|
||||
private int mIndexProjectionAvailable;
|
||||
|
||||
public final static String PROJECTION_ROW_AVAILABLE = "available";
|
||||
public final static String PROJECTION_ROW_VALID = "valid";
|
||||
public static final String PROJECTION_ROW_AVAILABLE = "available";
|
||||
public static final String PROJECTION_ROW_VALID = "valid";
|
||||
|
||||
public SelectKeyCursorAdapter(Context context, Cursor c, int flags, ListView listView,
|
||||
int keyType) {
|
||||
|
@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.sufficientlysecure.keychain.ui.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
@ -19,12 +36,12 @@ public class TabsAdapter extends FragmentStatePagerAdapter implements ActionBar.
|
||||
private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
|
||||
|
||||
static final class TabInfo {
|
||||
private final Class<?> clss;
|
||||
private final Bundle args;
|
||||
private final Class<?> mClss;
|
||||
private final Bundle mArgs;
|
||||
|
||||
TabInfo(Class<?> _class, Bundle _args) {
|
||||
clss = _class;
|
||||
args = _args;
|
||||
TabInfo(Class<?> mClss, Bundle mArgs) {
|
||||
this.mClss = mClss;
|
||||
this.mArgs = mArgs;
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,7 +71,7 @@ public class TabsAdapter extends FragmentStatePagerAdapter implements ActionBar.
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
TabInfo info = mTabs.get(position);
|
||||
return Fragment.instantiate(mContext, info.clss.getName(), info.args);
|
||||
return Fragment.instantiate(mContext, info.mClss.getName(), info.mArgs);
|
||||
}
|
||||
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
@ -17,13 +17,14 @@
|
||||
|
||||
package org.sufficientlysecure.keychain.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import org.spongycastle.bcpg.HashAlgorithmTags;
|
||||
import org.spongycastle.openpgp.PGPEncryptedData;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@SuppressLint("UseSparseArrays")
|
||||
public class AlgorithmNames {
|
||||
|
@ -18,7 +18,6 @@ package org.sufficientlysecure.keychain.util;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import com.google.zxing.integration.android.IntentIntegrator;
|
||||
|
||||
/**
|
||||
@ -28,20 +27,19 @@ import com.google.zxing.integration.android.IntentIntegrator;
|
||||
*/
|
||||
public final class IntentIntegratorSupportV4 extends IntentIntegrator {
|
||||
|
||||
private final Fragment fragment;
|
||||
private final Fragment mFragment;
|
||||
|
||||
/**
|
||||
* @param fragment
|
||||
* Fragment to handle activity response.
|
||||
* @param fragment Fragment to handle activity response.
|
||||
*/
|
||||
public IntentIntegratorSupportV4(Fragment fragment) {
|
||||
super(fragment.getActivity());
|
||||
this.fragment = fragment;
|
||||
this.mFragment = fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startActivityForResult(Intent intent, int code) {
|
||||
fragment.startActivityForResult(intent, code);
|
||||
mFragment.startActivityForResult(intent, code);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,12 +18,12 @@
|
||||
|
||||
package org.sufficientlysecure.keychain.util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class KeyServer {
|
||||
static public class QueryException extends Exception {
|
||||
public static class QueryException extends Exception {
|
||||
private static final long serialVersionUID = 2703768928624654512L;
|
||||
|
||||
public QueryException(String message) {
|
||||
@ -31,15 +31,15 @@ public abstract class KeyServer {
|
||||
}
|
||||
}
|
||||
|
||||
static public class TooManyResponses extends Exception {
|
||||
public static class TooManyResponses extends Exception {
|
||||
private static final long serialVersionUID = 2703768928624654513L;
|
||||
}
|
||||
|
||||
static public class InsufficientQuery extends Exception {
|
||||
public static class InsufficientQuery extends Exception {
|
||||
private static final long serialVersionUID = 2703768928624654514L;
|
||||
}
|
||||
|
||||
static public class AddKeyException extends Exception {
|
||||
public static class AddKeyException extends Exception {
|
||||
private static final long serialVersionUID = -507574859137295530L;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,16 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.sufficientlysecure.keychain.util;
|
||||
|
||||
public interface KeychainServiceListener {
|
||||
|
@ -21,7 +21,6 @@ import org.sufficientlysecure.keychain.Constants;
|
||||
|
||||
/**
|
||||
* Wraps Android Logging to enable or disable debug output using Constants
|
||||
*
|
||||
*/
|
||||
public final class Log {
|
||||
|
||||
|
@ -14,48 +14,36 @@ import android.os.Build;
|
||||
import android.os.Process;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.Provider;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.SecureRandomSpi;
|
||||
import java.security.Security;
|
||||
import java.io.*;
|
||||
import java.security.*;
|
||||
|
||||
/**
|
||||
* Fixes for the output of the default PRNG having low entropy.
|
||||
*
|
||||
* <p/>
|
||||
* The fixes need to be applied via {@link #apply()} before any use of Java Cryptography
|
||||
* Architecture primitives. A good place to invoke them is in the application's {@code onCreate}.
|
||||
*
|
||||
* <p/>
|
||||
* copied from http://android-developers.blogspot.de/2013/08/some-securerandom-thoughts.html
|
||||
*
|
||||
*
|
||||
* <p/>
|
||||
* <p/>
|
||||
* More information on these Android bugs:
|
||||
* http://blog.k3170makan.com/2013/08/more-details-on-android-jca-prng-flaw.html
|
||||
* Paper: "Randomly failed! Weaknesses in Java Pseudo Random Number Generators (PRNGs)"
|
||||
*
|
||||
*
|
||||
* <p/>
|
||||
* <p/>
|
||||
* Sep 15, 2013:
|
||||
* On some devices /dev/urandom is non-writable!
|
||||
* No need to seed /dev/urandom. urandom should have enough seeds from the OS and kernel.
|
||||
* Only OpenSSL seeds are broken. See http://emboss.github.io/blog/2013/08/21/openssl-prng-is-not-really-fork-safe
|
||||
*
|
||||
* <p/>
|
||||
* see also:
|
||||
* https://github.com/k9mail/k-9/commit/dda8f64276d4d29c43f86237cd77819c28f22f21
|
||||
* In addition to a couple of custom ROMs linking /dev/urandom to a non-writable
|
||||
* random version, now Samsung's SELinux policy also prevents apps from opening
|
||||
* /dev/urandom for writing. Since we shouldn't need to write to /dev/urandom anyway
|
||||
* we now simply don't.
|
||||
*
|
||||
*
|
||||
* <p/>
|
||||
* <p/>
|
||||
* Sep 17, 2013:
|
||||
* Updated from official blogpost:
|
||||
* Update: the original code sample below crashed on a small fraction of Android
|
||||
@ -68,8 +56,11 @@ public final class PRNGFixes {
|
||||
private static final byte[] BUILD_FINGERPRINT_AND_DEVICE_SERIAL =
|
||||
getBuildFingerprintAndDeviceSerial();
|
||||
|
||||
/** Hidden constructor to prevent instantiation. */
|
||||
private PRNGFixes() {}
|
||||
/**
|
||||
* Hidden constructor to prevent instantiation.
|
||||
*/
|
||||
private PRNGFixes() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies all fixes.
|
||||
|
@ -17,11 +17,7 @@
|
||||
|
||||
package org.sufficientlysecure.keychain.util;
|
||||
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.RejectedExecutionHandler;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
@ -32,18 +28,21 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
public class PausableThreadPoolExecutor extends ThreadPoolExecutor {
|
||||
|
||||
public PausableThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime,
|
||||
TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler) {
|
||||
TimeUnit unit, BlockingQueue<Runnable> workQueue,
|
||||
RejectedExecutionHandler handler) {
|
||||
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, handler);
|
||||
}
|
||||
|
||||
public PausableThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime,
|
||||
TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory,
|
||||
TimeUnit unit, BlockingQueue<Runnable> workQueue,
|
||||
ThreadFactory threadFactory,
|
||||
RejectedExecutionHandler handler) {
|
||||
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, handler);
|
||||
}
|
||||
|
||||
public PausableThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime,
|
||||
TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory) {
|
||||
TimeUnit unit, BlockingQueue<Runnable> workQueue,
|
||||
ThreadFactory threadFactory) {
|
||||
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory);
|
||||
}
|
||||
|
||||
@ -52,39 +51,40 @@ public class PausableThreadPoolExecutor extends ThreadPoolExecutor {
|
||||
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
|
||||
}
|
||||
|
||||
private boolean isPaused;
|
||||
private ReentrantLock pauseLock = new ReentrantLock();
|
||||
private Condition unpaused = pauseLock.newCondition();
|
||||
private boolean mIsPaused;
|
||||
private ReentrantLock mPauseLock = new ReentrantLock();
|
||||
private Condition mUnPaused = mPauseLock.newCondition();
|
||||
|
||||
protected void beforeExecute(Thread t, Runnable r) {
|
||||
super.beforeExecute(t, r);
|
||||
pauseLock.lock();
|
||||
mPauseLock.lock();
|
||||
try {
|
||||
while (isPaused)
|
||||
unpaused.await();
|
||||
while (mIsPaused) {
|
||||
mUnPaused.await();
|
||||
}
|
||||
} catch (InterruptedException ie) {
|
||||
t.interrupt();
|
||||
} finally {
|
||||
pauseLock.unlock();
|
||||
mPauseLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void pause() {
|
||||
pauseLock.lock();
|
||||
mPauseLock.lock();
|
||||
try {
|
||||
isPaused = true;
|
||||
mIsPaused = true;
|
||||
} finally {
|
||||
pauseLock.unlock();
|
||||
mPauseLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void resume() {
|
||||
pauseLock.lock();
|
||||
mPauseLock.lock();
|
||||
try {
|
||||
isPaused = false;
|
||||
unpaused.signalAll();
|
||||
mIsPaused = false;
|
||||
mUnPaused.signalAll();
|
||||
} finally {
|
||||
pauseLock.unlock();
|
||||
mPauseLock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
@ -18,22 +18,20 @@
|
||||
|
||||
package org.sufficientlysecure.keychain.util;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.EncodeHintType;
|
||||
import com.google.zxing.WriterException;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.qrcode.QRCodeWriter;
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
public class QrCodeUtils {
|
||||
public final static QRCodeWriter QR_CODE_WRITER = new QRCodeWriter();
|
||||
public static final QRCodeWriter QR_CODE_WRITER = new QRCodeWriter();
|
||||
|
||||
/**
|
||||
* Generate Bitmap with QR Code based on input.
|
||||
|
Loading…
x
Reference in New Issue
Block a user