Inline progress for download and import
This commit is contained in:
@@ -102,7 +102,7 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
|||||||
// If there is only one key, get it automatically
|
// If there is only one key, get it automatically
|
||||||
if (mData.size() == 1) {
|
if (mData.size() == 1) {
|
||||||
mCurrent = 0;
|
mCurrent = 0;
|
||||||
getKey(mData.get(0), true);
|
getKeyWithProgress(0, mData.get(0), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
@@ -158,17 +158,16 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
|||||||
b.setEntry(entry);
|
b.setEntry(entry);
|
||||||
|
|
||||||
final KeyState keyState = mKeyStates[position];
|
final KeyState keyState = mKeyStates[position];
|
||||||
final boolean downloaded = keyState.mDownloaded;
|
|
||||||
final boolean showed = keyState.mShowed;
|
|
||||||
|
|
||||||
b.card.setOnClickListener(new OnClickListener() {
|
b.card.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (!downloaded) {
|
if (!keyState.mDownloaded) {
|
||||||
mCurrent = position;
|
mCurrent = position;
|
||||||
getKey(entry, true);
|
|
||||||
|
getKeyWithProgress(position, entry, true);
|
||||||
} else {
|
} else {
|
||||||
changeState(position, !showed);
|
changeShowed(position, !keyState.mShowed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -176,7 +175,7 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
|||||||
b.extra.importKey.setOnClickListener(new OnClickListener() {
|
b.extra.importKey.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
getKey(entry, false);
|
getKeyWithProgress(position, entry, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -190,7 +189,9 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
b.extraContainer.setVisibility(showed ? View.VISIBLE : View.GONE);
|
b.extraContainer.setVisibility(keyState.mShowed ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
|
b.progress.setVisibility(keyState.mProgress ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -198,12 +199,16 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
|||||||
return mData != null ? mData.size() : 0;
|
return mData != null ? mData.size() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getKey(ImportKeysListEntry entry, boolean skipSave) {
|
private void getKeyWithProgress(int position, ImportKeysListEntry entry, boolean skipSave) {
|
||||||
|
changeProgress(position, true);
|
||||||
|
getKey(entry, skipSave);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getKey(ImportKeysListEntry entry, boolean skipSave) {
|
||||||
ImportKeyringParcel inputParcel = prepareKeyOperation(entry, skipSave);
|
ImportKeyringParcel inputParcel = prepareKeyOperation(entry, skipSave);
|
||||||
ImportKeysResultListener listener = skipSave ? this : mListener;
|
ImportKeysResultListener listener = skipSave ? this : mListener;
|
||||||
ImportKeysOperationCallback cb = new ImportKeysOperationCallback(listener, inputParcel);
|
ImportKeysOperationCallback cb = new ImportKeysOperationCallback(listener, inputParcel);
|
||||||
int message = skipSave ? R.string.progress_downloading : R.string.progress_importing;
|
CryptoOperationHelper opHelper = new CryptoOperationHelper<>(1, mActivity, cb, null);
|
||||||
CryptoOperationHelper opHelper = new CryptoOperationHelper<>(1, mActivity, cb, message);
|
|
||||||
opHelper.cryptoOperation();
|
opHelper.cryptoOperation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,7 +257,7 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
|||||||
mergeEntryWithKey(entry, keyRing);
|
mergeEntryWithKey(entry, keyRing);
|
||||||
|
|
||||||
mKeyStates[mCurrent].mDownloaded = true;
|
mKeyStates[mCurrent].mDownloaded = true;
|
||||||
changeState(mCurrent, true);
|
changeShowed(mCurrent, true);
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("getKey retrieved more than one key ("
|
throw new RuntimeException("getKey retrieved more than one key ("
|
||||||
+ canKeyRings.size() + ")");
|
+ canKeyRings.size() + ")");
|
||||||
@@ -260,6 +265,8 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
|||||||
} else {
|
} else {
|
||||||
result.createNotify(mActivity).show();
|
result.createNotify(mActivity).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changeProgress(mCurrent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mergeEntryWithKey(ImportKeysListEntry entry, CanonicalizedKeyRing keyRing) {
|
private void mergeEntryWithKey(ImportKeysListEntry entry, CanonicalizedKeyRing keyRing) {
|
||||||
@@ -281,17 +288,24 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class KeyState {
|
private class KeyState {
|
||||||
public boolean mAlreadyPresent = false;
|
boolean mAlreadyPresent = false;
|
||||||
public boolean mVerified = false;
|
boolean mVerified = false;
|
||||||
|
|
||||||
public boolean mDownloaded = false;
|
boolean mProgress = false;
|
||||||
public boolean mShowed = false;
|
boolean mDownloaded = false;
|
||||||
|
boolean mShowed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeState(int position, boolean showed) {
|
private void changeShowed(int position, boolean showed) {
|
||||||
KeyState keyState = mKeyStates[position];
|
KeyState keyState = mKeyStates[position];
|
||||||
keyState.mShowed = showed;
|
keyState.mShowed = showed;
|
||||||
notifyItemChanged(position);
|
notifyItemChanged(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void changeProgress(int position, boolean progress) {
|
||||||
|
KeyState keyState = mKeyStates[position];
|
||||||
|
keyState.mProgress = progress;
|
||||||
|
notifyItemChanged(position);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,22 +20,22 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical">
|
||||||
android:paddingBottom="8dp">
|
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:paddingBottom="16dp"
|
|
||||||
android:paddingLeft="16dp"
|
|
||||||
android:paddingRight="16dp"
|
|
||||||
android:paddingTop="24dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="16dp"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:paddingTop="16dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -64,23 +64,33 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/extra_container"
|
||||||
|
android:layout_below="@id/container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:animateLayoutChanges="true"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/extra"
|
||||||
|
layout="@layout/import_keys_list_item_extra"
|
||||||
|
app:entry="@{entry}" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progress"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignParentEnd="true" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/extra_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:animateLayoutChanges="true"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<include
|
|
||||||
android:id="@+id/extra"
|
|
||||||
layout="@layout/import_keys_list_item_extra"
|
|
||||||
app:entry="@{entry}" />
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
</android.support.v7.widget.CardView>
|
||||||
|
|||||||
@@ -11,17 +11,15 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical">
|
||||||
android:paddingLeft="8dp"
|
|
||||||
android:paddingRight="8dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingBottom="16dp"
|
android:paddingLeft="16dp"
|
||||||
android:paddingLeft="8dp"
|
android:paddingRight="16dp"
|
||||||
android:paddingRight="8dp">
|
android:paddingBottom="16dp">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -106,7 +104,8 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal"
|
||||||
|
android:padding="8dp">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/import_key"
|
android:id="@+id/import_key"
|
||||||
|
|||||||
Reference in New Issue
Block a user