tls-psk: display list of incoming keys on receiving side
This commit is contained in:
@@ -135,8 +135,8 @@ public class KeyTransferInteractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleOpenConnection(socket);
|
handleOpenConnection(socket);
|
||||||
Log.d(Constants.TAG, "connection closed ok!");
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
invokeListener(CONNECTION_LOST, null);
|
||||||
Log.e(Constants.TAG, "error!", e);
|
Log.e(Constants.TAG, "error!", e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
@@ -176,8 +176,13 @@ public class KeyTransferInteractor {
|
|||||||
socket.setSoTimeout(500);
|
socket.setSoTimeout(500);
|
||||||
while (!isInterrupted() && socket.isConnected()) {
|
while (!isInterrupted() && socket.isConnected()) {
|
||||||
sendDataIfAvailable(socket, outputStream);
|
sendDataIfAvailable(socket, outputStream);
|
||||||
receiveDataIfAvailable(socket, bufferedReader);
|
|
||||||
|
boolean connectionClosed = receiveDataIfAvailable(socket, bufferedReader);
|
||||||
|
if (connectionClosed) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d(Constants.TAG, "disconnected");
|
Log.d(Constants.TAG, "disconnected");
|
||||||
invokeListener(CONNECTION_LOST, null);
|
invokeListener(CONNECTION_LOST, null);
|
||||||
}
|
}
|
||||||
@@ -191,7 +196,6 @@ public class KeyTransferInteractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (firstLine == null) {
|
if (firstLine == null) {
|
||||||
invokeListener(CONNECTION_LOST, null);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +204,7 @@ public class KeyTransferInteractor {
|
|||||||
socket.setSoTimeout(500);
|
socket.setSoTimeout(500);
|
||||||
|
|
||||||
invokeListener(CONNECTION_RECEIVE_OK, receivedData);
|
invokeListener(CONNECTION_RECEIVE_OK, receivedData);
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean sendDataIfAvailable(Socket socket, OutputStream outputStream) throws IOException {
|
private boolean sendDataIfAvailable(Socket socket, OutputStream outputStream) throws IOException {
|
||||||
@@ -212,6 +216,7 @@ public class KeyTransferInteractor {
|
|||||||
outputStream.write(data);
|
outputStream.write(data);
|
||||||
outputStream.write('\n');
|
outputStream.write('\n');
|
||||||
outputStream.write('\n');
|
outputStream.write('\n');
|
||||||
|
outputStream.flush();
|
||||||
socket.setSoTimeout(500);
|
socket.setSoTimeout(500);
|
||||||
|
|
||||||
invokeListener(CONNECTION_SEND_OK, sendPassthrough);
|
invokeListener(CONNECTION_SEND_OK, sendPassthrough);
|
||||||
|
|||||||
@@ -103,6 +103,10 @@ public class UncachedKeyRing {
|
|||||||
return mRing.getPublicKey().getKeyID();
|
return mRing.getPublicKey().getKeyID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getCreationTime() {
|
||||||
|
return mRing.getPublicKey().getCreationTime().getTime();
|
||||||
|
}
|
||||||
|
|
||||||
public UncachedPublicKey getPublicKey() {
|
public UncachedPublicKey getPublicKey() {
|
||||||
return new UncachedPublicKey(mRing.getPublicKey());
|
return new UncachedPublicKey(mRing.getPublicKey());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,13 +34,19 @@ import android.support.v4.content.Loader;
|
|||||||
import android.support.v7.widget.RecyclerView.Adapter;
|
import android.support.v7.widget.RecyclerView.Adapter;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
|
||||||
|
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||||
|
import org.openintents.openpgp.util.OpenPgpUtils.UserId;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.network.KeyTransferInteractor;
|
import org.sufficientlysecure.keychain.network.KeyTransferInteractor;
|
||||||
import org.sufficientlysecure.keychain.network.KeyTransferInteractor.KeyTransferCallback;
|
import org.sufficientlysecure.keychain.network.KeyTransferInteractor.KeyTransferCallback;
|
||||||
|
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||||
import org.sufficientlysecure.keychain.provider.KeyRepository;
|
import org.sufficientlysecure.keychain.provider.KeyRepository;
|
||||||
import org.sufficientlysecure.keychain.provider.KeyRepository.NotFoundException;
|
import org.sufficientlysecure.keychain.provider.KeyRepository.NotFoundException;
|
||||||
import org.sufficientlysecure.keychain.ui.transfer.loader.SecretKeyLoader.SecretKeyItem;
|
import org.sufficientlysecure.keychain.ui.transfer.loader.SecretKeyLoader.SecretKeyItem;
|
||||||
|
import org.sufficientlysecure.keychain.ui.transfer.view.ReceivedSecretKeyList.OnClickImportKeyListener;
|
||||||
|
import org.sufficientlysecure.keychain.ui.transfer.view.ReceivedSecretKeyList.ReceivedKeyAdapter;
|
||||||
|
import org.sufficientlysecure.keychain.ui.transfer.view.ReceivedSecretKeyList.ReceivedKeyItem;
|
||||||
import org.sufficientlysecure.keychain.ui.transfer.view.TransferSecretKeyList.OnClickTransferKeyListener;
|
import org.sufficientlysecure.keychain.ui.transfer.view.TransferSecretKeyList.OnClickTransferKeyListener;
|
||||||
import org.sufficientlysecure.keychain.ui.transfer.view.TransferSecretKeyList.TransferKeyAdapter;
|
import org.sufficientlysecure.keychain.ui.transfer.view.TransferSecretKeyList.TransferKeyAdapter;
|
||||||
import org.sufficientlysecure.keychain.ui.util.QrCodeUtils;
|
import org.sufficientlysecure.keychain.ui.util.QrCodeUtils;
|
||||||
@@ -49,7 +55,7 @@ import org.sufficientlysecure.keychain.util.Log;
|
|||||||
|
|
||||||
@RequiresApi(api = VERSION_CODES.LOLLIPOP)
|
@RequiresApi(api = VERSION_CODES.LOLLIPOP)
|
||||||
public class TransferPresenter implements KeyTransferCallback, LoaderCallbacks<List<SecretKeyItem>>,
|
public class TransferPresenter implements KeyTransferCallback, LoaderCallbacks<List<SecretKeyItem>>,
|
||||||
OnClickTransferKeyListener {
|
OnClickTransferKeyListener, OnClickImportKeyListener {
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private final TransferMvpView view;
|
private final TransferMvpView view;
|
||||||
private final LoaderManager loaderManager;
|
private final LoaderManager loaderManager;
|
||||||
@@ -58,6 +64,7 @@ public class TransferPresenter implements KeyTransferCallback, LoaderCallbacks<L
|
|||||||
private KeyTransferInteractor keyTransferClientInteractor;
|
private KeyTransferInteractor keyTransferClientInteractor;
|
||||||
private KeyTransferInteractor keyTransferServerInteractor;
|
private KeyTransferInteractor keyTransferServerInteractor;
|
||||||
private final TransferKeyAdapter secretKeyAdapter;
|
private final TransferKeyAdapter secretKeyAdapter;
|
||||||
|
private final ReceivedKeyAdapter receivedKeyAdapter;
|
||||||
|
|
||||||
public TransferPresenter(Context context, LoaderManager loaderManager, int loaderId, TransferMvpView view) {
|
public TransferPresenter(Context context, LoaderManager loaderManager, int loaderId, TransferMvpView view) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
@@ -67,6 +74,9 @@ public class TransferPresenter implements KeyTransferCallback, LoaderCallbacks<L
|
|||||||
|
|
||||||
secretKeyAdapter = new TransferKeyAdapter(context, LayoutInflater.from(context), this);
|
secretKeyAdapter = new TransferKeyAdapter(context, LayoutInflater.from(context), this);
|
||||||
view.setSecretKeyAdapter(secretKeyAdapter);
|
view.setSecretKeyAdapter(secretKeyAdapter);
|
||||||
|
|
||||||
|
receivedKeyAdapter = new ReceivedKeyAdapter(context, LayoutInflater.from(context), this);
|
||||||
|
view.setReceivedKeyAdapter(receivedKeyAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -104,8 +114,9 @@ public class TransferPresenter implements KeyTransferCallback, LoaderCallbacks<L
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUiFakeProgressFinished() {
|
@Override
|
||||||
view.showKeySentOk();
|
public void onUiClickImportKey(String keyData) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -117,6 +128,7 @@ public class TransferPresenter implements KeyTransferCallback, LoaderCallbacks<L
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnectionEstablished(String otherName) {
|
public void onConnectionEstablished(String otherName) {
|
||||||
|
secretKeyAdapter.clearFinishedItems();
|
||||||
view.showConnectionEstablished(otherName);
|
view.showConnectionEstablished(otherName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,6 +140,20 @@ public class TransferPresenter implements KeyTransferCallback, LoaderCallbacks<L
|
|||||||
@Override
|
@Override
|
||||||
public void onDataReceivedOk(String receivedData) {
|
public void onDataReceivedOk(String receivedData) {
|
||||||
Log.d(Constants.TAG, "received: " + receivedData);
|
Log.d(Constants.TAG, "received: " + receivedData);
|
||||||
|
view.showReceivingKeys();
|
||||||
|
|
||||||
|
try {
|
||||||
|
// TODO move to worker thread?
|
||||||
|
UncachedKeyRing uncachedKeyRing = UncachedKeyRing.decodeFromData(receivedData.getBytes());
|
||||||
|
String primaryUserId = uncachedKeyRing.getPublicKey().getPrimaryUserId();
|
||||||
|
UserId userId = OpenPgpUtils.splitUserId(primaryUserId);
|
||||||
|
|
||||||
|
ReceivedKeyItem receivedKeyItem = new ReceivedKeyItem(receivedData, uncachedKeyRing.getMasterKeyId(),
|
||||||
|
uncachedKeyRing.getCreationTime(), userId.name, userId.email);
|
||||||
|
receivedKeyAdapter.addItem(receivedKeyItem);
|
||||||
|
} catch (PgpGeneralException | IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -142,7 +168,6 @@ public class TransferPresenter implements KeyTransferCallback, LoaderCallbacks<L
|
|||||||
secretKeyAdapter.addToFinishedItems(masterKeyId);
|
secretKeyAdapter.addToFinishedItems(masterKeyId);
|
||||||
}
|
}
|
||||||
}, 750);
|
}, 750);
|
||||||
// view.showFakeSendProgressDialog();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -201,13 +226,12 @@ public class TransferPresenter implements KeyTransferCallback, LoaderCallbacks<L
|
|||||||
public interface TransferMvpView {
|
public interface TransferMvpView {
|
||||||
void showWaitingForConnection();
|
void showWaitingForConnection();
|
||||||
void showConnectionEstablished(String hostname);
|
void showConnectionEstablished(String hostname);
|
||||||
|
void showReceivingKeys();
|
||||||
|
|
||||||
void scanQrCode();
|
void scanQrCode();
|
||||||
void setQrImage(Bitmap qrCode);
|
void setQrImage(Bitmap qrCode);
|
||||||
|
|
||||||
void setSecretKeyAdapter(Adapter adapter);
|
void setSecretKeyAdapter(Adapter adapter);
|
||||||
|
void setReceivedKeyAdapter(Adapter secretKeyAdapter);
|
||||||
void showFakeSendProgressDialog();
|
|
||||||
void showKeySentOk();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,186 @@
|
|||||||
|
package org.sufficientlysecure.keychain.ui.transfer.view;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.text.format.DateUtils;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.ViewAnimator;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
import org.sufficientlysecure.keychain.ui.util.recyclerview.DividerItemDecoration;
|
||||||
|
|
||||||
|
|
||||||
|
public class ReceivedSecretKeyList extends RecyclerView {
|
||||||
|
private static final int STATE_INVISIBLE = 0;
|
||||||
|
private static final int STATE_BUTTON = 1;
|
||||||
|
private static final int STATE_PROGRESS = 2;
|
||||||
|
private static final int STATE_TRANSFERRED = 3;
|
||||||
|
private static final int STATE_IMPORT_BUTTON = 4;
|
||||||
|
|
||||||
|
|
||||||
|
public ReceivedSecretKeyList(Context context) {
|
||||||
|
super(context);
|
||||||
|
init(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReceivedSecretKeyList(Context context, @Nullable AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
init(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReceivedSecretKeyList(Context context, @Nullable AttributeSet attrs, int defStyle) {
|
||||||
|
super(context, attrs, defStyle);
|
||||||
|
init(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init(Context context) {
|
||||||
|
setLayoutManager(new LinearLayoutManager(context));
|
||||||
|
addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL_LIST));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ReceivedKeyAdapter extends Adapter<ReceivedKeyViewHolder> {
|
||||||
|
private final Context context;
|
||||||
|
private final LayoutInflater layoutInflater;
|
||||||
|
private final OnClickImportKeyListener onClickImportKeyListener;
|
||||||
|
|
||||||
|
private Long focusedMasterKeyId;
|
||||||
|
private List<ReceivedKeyItem> data = new ArrayList<>();
|
||||||
|
private ArrayList<Long> finishedItems = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
public ReceivedKeyAdapter(Context context, LayoutInflater layoutInflater,
|
||||||
|
OnClickImportKeyListener onClickImportKeyListener) {
|
||||||
|
this.context = context;
|
||||||
|
this.layoutInflater = layoutInflater;
|
||||||
|
this.onClickImportKeyListener = onClickImportKeyListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ReceivedKeyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
|
return new ReceivedKeyViewHolder(layoutInflater.inflate(R.layout.key_transfer_item, parent, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(ReceivedKeyViewHolder holder, int position) {
|
||||||
|
ReceivedKeyItem item = data.get(position);
|
||||||
|
boolean isFinished = finishedItems.contains(item.masterKeyId);
|
||||||
|
holder.bind(context, item, onClickImportKeyListener, focusedMasterKeyId, isFinished);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return data != null ? data.size() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getItemId(int position) {
|
||||||
|
return data.get(position).masterKeyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void focusItem(Long masterKeyId) {
|
||||||
|
focusedMasterKeyId = masterKeyId;
|
||||||
|
notifyItemRangeChanged(0, getItemCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addItem(ReceivedKeyItem receivedKeyItem) {
|
||||||
|
data.add(receivedKeyItem);
|
||||||
|
notifyItemInserted(data.size() -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ReceivedKeyViewHolder extends ViewHolder {
|
||||||
|
private final TextView vName;
|
||||||
|
private final TextView vEmail;
|
||||||
|
private final TextView vCreation;
|
||||||
|
private final View vImportButton;
|
||||||
|
private final ViewAnimator vState;
|
||||||
|
|
||||||
|
ReceivedKeyViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
|
||||||
|
vName = (TextView) itemView.findViewById(R.id.key_list_item_name);
|
||||||
|
vEmail = (TextView) itemView.findViewById(R.id.key_list_item_email);
|
||||||
|
vCreation = (TextView) itemView.findViewById(R.id.key_list_item_creation);
|
||||||
|
|
||||||
|
vImportButton = itemView.findViewById(R.id.button_import);
|
||||||
|
vState = (ViewAnimator) itemView.findViewById(R.id.transfer_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bind(Context context, final ReceivedKeyItem item,
|
||||||
|
final OnClickImportKeyListener onClickReceiveKeyListener, Long focusedMasterKeyId,
|
||||||
|
boolean isFinished) {
|
||||||
|
if (item.name != null) {
|
||||||
|
vName.setText(item.name);
|
||||||
|
vName.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
vName.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
if (item.email != null) {
|
||||||
|
vEmail.setText(item.email);
|
||||||
|
vEmail.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
vEmail.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
String dateTime = DateUtils.formatDateTime(context, item.creationMillis,
|
||||||
|
DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME |
|
||||||
|
DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_ABBREV_MONTH);
|
||||||
|
vCreation.setText(context.getString(R.string.label_key_created, dateTime));
|
||||||
|
|
||||||
|
if (focusedMasterKeyId != null) {
|
||||||
|
if (focusedMasterKeyId != item.masterKeyId) {
|
||||||
|
itemView.animate().alpha(0.2f).start();
|
||||||
|
vState.setDisplayedChild(isFinished ? STATE_TRANSFERRED : STATE_INVISIBLE);
|
||||||
|
} else {
|
||||||
|
itemView.setAlpha(1.0f);
|
||||||
|
vState.setDisplayedChild(STATE_PROGRESS);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
itemView.animate().alpha(1.0f).start();
|
||||||
|
vState.setDisplayedChild(isFinished ? STATE_TRANSFERRED : STATE_IMPORT_BUTTON);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (focusedMasterKeyId == null && onClickReceiveKeyListener != null) {
|
||||||
|
vImportButton.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
onClickReceiveKeyListener.onUiClickImportKey(item.keyData);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
vImportButton.setOnClickListener(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface OnClickImportKeyListener {
|
||||||
|
void onUiClickImportKey(String keyData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ReceivedKeyItem {
|
||||||
|
private final String keyData;
|
||||||
|
|
||||||
|
private final long masterKeyId;
|
||||||
|
private final long creationMillis;
|
||||||
|
private final String name;
|
||||||
|
private final String email;
|
||||||
|
|
||||||
|
public ReceivedKeyItem(String keyData, long masterKeyId, long creationMillis, String name, String email) {
|
||||||
|
this.keyData = keyData;
|
||||||
|
this.masterKeyId = masterKeyId;
|
||||||
|
this.creationMillis = creationMillis;
|
||||||
|
this.name = name;
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,6 +55,7 @@ public class TransferFragment extends Fragment implements TransferMvpView {
|
|||||||
public static final int VIEW_WAITING = 0;
|
public static final int VIEW_WAITING = 0;
|
||||||
public static final int VIEW_CONNECTED = 1;
|
public static final int VIEW_CONNECTED = 1;
|
||||||
public static final int VIEW_SEND_OK = 2;
|
public static final int VIEW_SEND_OK = 2;
|
||||||
|
public static final int VIEW_RECEIVING = 3;
|
||||||
|
|
||||||
public static final int REQUEST_CODE_SCAN = 1;
|
public static final int REQUEST_CODE_SCAN = 1;
|
||||||
public static final int LOADER_ID = 1;
|
public static final int LOADER_ID = 1;
|
||||||
@@ -65,6 +66,7 @@ public class TransferFragment extends Fragment implements TransferMvpView {
|
|||||||
private ViewAnimator vTransferAnimator;
|
private ViewAnimator vTransferAnimator;
|
||||||
private TextView vConnectionStatusText;
|
private TextView vConnectionStatusText;
|
||||||
private RecyclerView vTransferKeyList;
|
private RecyclerView vTransferKeyList;
|
||||||
|
private RecyclerView vReceivedKeyList;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -75,6 +77,7 @@ public class TransferFragment extends Fragment implements TransferMvpView {
|
|||||||
|
|
||||||
vConnectionStatusText = (TextView) view.findViewById(R.id.connection_status);
|
vConnectionStatusText = (TextView) view.findViewById(R.id.connection_status);
|
||||||
vTransferKeyList = (RecyclerView) view.findViewById(R.id.transfer_key_list);
|
vTransferKeyList = (RecyclerView) view.findViewById(R.id.transfer_key_list);
|
||||||
|
vReceivedKeyList = (RecyclerView) view.findViewById(R.id.received_key_list);
|
||||||
|
|
||||||
vQrCodeImage = (ImageView) view.findViewById(R.id.qr_code_image);
|
vQrCodeImage = (ImageView) view.findViewById(R.id.qr_code_image);
|
||||||
|
|
||||||
@@ -124,8 +127,8 @@ public class TransferFragment extends Fragment implements TransferMvpView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showKeySentOk() {
|
public void showReceivingKeys() {
|
||||||
vTransferAnimator.setDisplayedChild(VIEW_SEND_OK);
|
vTransferAnimator.setDisplayedChild(VIEW_RECEIVING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -155,34 +158,8 @@ public class TransferFragment extends Fragment implements TransferMvpView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showFakeSendProgressDialog() {
|
public void setReceivedKeyAdapter(Adapter adapter) {
|
||||||
final ProgressDialogFragment progressDialogFragment =
|
vReceivedKeyList.setAdapter(adapter);
|
||||||
ProgressDialogFragment.newInstance("Sending key…", ProgressDialog.STYLE_HORIZONTAL, false);
|
|
||||||
progressDialogFragment.show(getFragmentManager(), "progress");
|
|
||||||
|
|
||||||
final Handler handler = new Handler();
|
|
||||||
|
|
||||||
Timer timer = new Timer();
|
|
||||||
timer.scheduleAtFixedRate(new TimerTask() {
|
|
||||||
int fakeProgress = 0;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
fakeProgress += 6;
|
|
||||||
if (fakeProgress > 100) {
|
|
||||||
cancel();
|
|
||||||
progressDialogFragment.dismissAllowingStateLoss();
|
|
||||||
handler.post(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
presenter.onUiFakeProgressFinished();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
progressDialogFragment.setProgress(fakeProgress, 100);
|
|
||||||
}
|
|
||||||
}, 0, 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public class TransferSecretKeyList extends RecyclerView {
|
|||||||
private static final int STATE_BUTTON = 1;
|
private static final int STATE_BUTTON = 1;
|
||||||
private static final int STATE_PROGRESS = 2;
|
private static final int STATE_PROGRESS = 2;
|
||||||
private static final int STATE_TRANSFERRED = 3;
|
private static final int STATE_TRANSFERRED = 3;
|
||||||
|
private static final int STATE_IMPORT_BUTTON = 4;
|
||||||
|
|
||||||
|
|
||||||
public TransferSecretKeyList(Context context) {
|
public TransferSecretKeyList(Context context) {
|
||||||
@@ -58,7 +59,7 @@ public class TransferSecretKeyList extends RecyclerView {
|
|||||||
|
|
||||||
private Long focusedMasterKeyId;
|
private Long focusedMasterKeyId;
|
||||||
private List<SecretKeyItem> data;
|
private List<SecretKeyItem> data;
|
||||||
private ArrayList<Long> finishedItems;
|
private ArrayList<Long> finishedItems = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
public TransferKeyAdapter(Context context, LayoutInflater layoutInflater,
|
public TransferKeyAdapter(Context context, LayoutInflater layoutInflater,
|
||||||
@@ -92,12 +93,17 @@ public class TransferSecretKeyList extends RecyclerView {
|
|||||||
|
|
||||||
public void setData(List<SecretKeyItem> data) {
|
public void setData(List<SecretKeyItem> data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.finishedItems = new ArrayList<>();
|
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearFinishedItems() {
|
||||||
|
finishedItems.clear();
|
||||||
|
notifyItemRangeChanged(0, getItemCount());
|
||||||
|
}
|
||||||
|
|
||||||
public void addToFinishedItems(long masterKeyId) {
|
public void addToFinishedItems(long masterKeyId) {
|
||||||
finishedItems.add(masterKeyId);
|
finishedItems.add(masterKeyId);
|
||||||
|
// doeesn't notify, because it's non-trivial and this is called in conjunction with other refreshing things!
|
||||||
}
|
}
|
||||||
|
|
||||||
public void focusItem(Long masterKeyId) {
|
public void focusItem(Long masterKeyId) {
|
||||||
|
|||||||
@@ -54,7 +54,8 @@
|
|||||||
android:outAnimation="@anim/fade_out"
|
android:outAnimation="@anim/fade_out"
|
||||||
android:inAnimation="@anim/fade_in"
|
android:inAnimation="@anim/fade_in"
|
||||||
android:id="@+id/transfer_state"
|
android:id="@+id/transfer_state"
|
||||||
custom:initialView="2">
|
android:measureAllChildren="false"
|
||||||
|
custom:initialView="04">
|
||||||
|
|
||||||
<Space
|
<Space
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -84,6 +85,14 @@
|
|||||||
android:tint="@color/android_green_light"
|
android:tint="@color/android_green_light"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:id="@+id/button_import"
|
||||||
|
android:text="Import"
|
||||||
|
/>
|
||||||
|
|
||||||
</org.sufficientlysecure.keychain.ui.widget.ToolableViewAnimator>
|
</org.sufficientlysecure.keychain.ui.widget.ToolableViewAnimator>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
android:id="@+id/transfer_animator"
|
android:id="@+id/transfer_animator"
|
||||||
android:inAnimation="@anim/fade_in_delayed"
|
android:inAnimation="@anim/fade_in_delayed"
|
||||||
android:outAnimation="@anim/fade_out"
|
android:outAnimation="@anim/fade_out"
|
||||||
custom:initialView="0">
|
custom:initialView="03">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -111,4 +111,43 @@
|
|||||||
/>
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
android:id="@+id/connection_status_2"
|
||||||
|
android:text="Connected to: 123.456.123.123"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:text="Received Keys:"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
style="@style/SectionHeader"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<org.sufficientlysecure.keychain.ui.transfer.view.ReceivedSecretKeyList
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/received_key_list"
|
||||||
|
android:padding="16dp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</org.sufficientlysecure.keychain.ui.widget.ToolableViewAnimator>
|
</org.sufficientlysecure.keychain.ui.widget.ToolableViewAnimator>
|
||||||
Reference in New Issue
Block a user