multidecrypt: display all outputUris as individual items
This commit is contained in:
@@ -51,7 +51,7 @@ public class InputDataResult extends InputPendingResult {
|
|||||||
@NonNull ArrayList<Uri> outputUris, @NonNull ArrayList<OpenPgpMetadata> metadata) {
|
@NonNull ArrayList<Uri> outputUris, @NonNull ArrayList<OpenPgpMetadata> metadata) {
|
||||||
super(result, log);
|
super(result, log);
|
||||||
mDecryptVerifyResult = decryptResult;
|
mDecryptVerifyResult = decryptResult;
|
||||||
if (outputUris.size() == metadata.size()) {
|
if (outputUris.size() != metadata.size()) {
|
||||||
throw new AssertionError("number of output URIs must match metadata!");
|
throw new AssertionError("number of output URIs must match metadata!");
|
||||||
}
|
}
|
||||||
mOutputUris = outputUris;
|
mOutputUris = outputUris;
|
||||||
|
|||||||
@@ -62,10 +62,10 @@ import org.sufficientlysecure.keychain.operations.results.InputDataResult;
|
|||||||
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyInputParcel;
|
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyInputParcel;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
import org.sufficientlysecure.keychain.service.InputDataParcel;
|
import org.sufficientlysecure.keychain.service.InputDataParcel;
|
||||||
import org.sufficientlysecure.keychain.ui.DecryptListFragment.ViewHolder.SubViewHolder;
|
|
||||||
import org.sufficientlysecure.keychain.ui.base.QueueingCryptoOperationFragment;
|
import org.sufficientlysecure.keychain.ui.base.QueueingCryptoOperationFragment;
|
||||||
// this import NEEDS to be above the ViewModel one, or it won't compile! (as of 06/06/15)
|
// this import NEEDS to be above the ViewModel AND SubViewHolder one, or it won't compile! (as of 16.09.15)
|
||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils.StatusHolder;
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils.StatusHolder;
|
||||||
|
import org.sufficientlysecure.keychain.ui.DecryptListFragment.ViewHolder.SubViewHolder;
|
||||||
import org.sufficientlysecure.keychain.ui.DecryptListFragment.DecryptFilesAdapter.ViewModel;
|
import org.sufficientlysecure.keychain.ui.DecryptListFragment.DecryptFilesAdapter.ViewModel;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.SpacesItemDecoration;
|
import org.sufficientlysecure.keychain.ui.adapter.SpacesItemDecoration;
|
||||||
import org.sufficientlysecure.keychain.ui.util.FormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.FormattingUtils;
|
||||||
@@ -395,7 +395,7 @@ public class DecryptListFragment
|
|||||||
String plaintext = FileHelper.readTextFromUri(activity, outputUri, null);
|
String plaintext = FileHelper.readTextFromUri(activity, outputUri, null);
|
||||||
|
|
||||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||||
intent.setType(metadata.getMimeType());
|
intent.setType("text/plain");
|
||||||
intent.putExtra(Intent.EXTRA_TEXT, plaintext);
|
intent.putExtra(Intent.EXTRA_TEXT, plaintext);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|
||||||
@@ -408,8 +408,8 @@ public class DecryptListFragment
|
|||||||
|
|
||||||
Intent intent = new Intent(activity, DisplayTextActivity.class);
|
Intent intent = new Intent(activity, DisplayTextActivity.class);
|
||||||
intent.setAction(Intent.ACTION_VIEW);
|
intent.setAction(Intent.ACTION_VIEW);
|
||||||
intent.setDataAndType(outputUri, metadata.getMimeType());
|
intent.setDataAndType(outputUri, "text/plain");
|
||||||
intent.putExtra(DisplayTextActivity.EXTRA_METADATA, result);
|
intent.putExtra(DisplayTextActivity.EXTRA_METADATA, result.mDecryptVerifyResult);
|
||||||
activity.startActivity(intent);
|
activity.startActivity(intent);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -659,10 +659,13 @@ public class DecryptListFragment
|
|||||||
|
|
||||||
KeyFormattingUtils.setStatus(getResources(), holder, model.mResult.mDecryptVerifyResult);
|
KeyFormattingUtils.setStatus(getResources(), holder, model.mResult.mDecryptVerifyResult);
|
||||||
|
|
||||||
final OpenPgpMetadata metadata = model.mResult.mMetadata.get(0);
|
int numFiles = model.mResult.getOutputUris().size();
|
||||||
|
holder.resizeFileList(numFiles, LayoutInflater.from(getActivity()));
|
||||||
|
for (int i = 0; i < numFiles; i++) {
|
||||||
|
|
||||||
{
|
Uri outputUri = model.mResult.getOutputUris().get(i);
|
||||||
SubViewHolder fileHolder = holder.mFileHolderList.get(0);
|
OpenPgpMetadata metadata = model.mResult.mMetadata.get(i);
|
||||||
|
SubViewHolder fileHolder = holder.mFileHolderList.get(i);
|
||||||
|
|
||||||
String filename;
|
String filename;
|
||||||
if (metadata == null) {
|
if (metadata == null) {
|
||||||
@@ -682,17 +685,19 @@ public class DecryptListFragment
|
|||||||
fileHolder.vFilesize.setText(FileHelper.readableFileSize(size));
|
fileHolder.vFilesize.setText(FileHelper.readableFileSize(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (model.mIcon != null) {
|
if (mIconCache.containsKey(outputUri)) {
|
||||||
// holder.vThumbnail.setImageDrawable(model.mIcon);
|
fileHolder.vThumbnail.setImageDrawable(mIconCache.get(outputUri));
|
||||||
//} else {
|
} else {
|
||||||
fileHolder.vThumbnail.setImageResource(R.drawable.ic_doc_generic_am);
|
fileHolder.vThumbnail.setImageResource(R.drawable.ic_doc_generic_am);
|
||||||
//}
|
}
|
||||||
|
|
||||||
|
// save index closure-style :)
|
||||||
|
final int idx = i;
|
||||||
fileHolder.vFile.setOnClickListener(new OnClickListener() {
|
fileHolder.vFile.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (model.mResult.success()) {
|
if (model.mResult.success()) {
|
||||||
displayWithViewIntent(model.mResult, 0, false);
|
displayWithViewIntent(model.mResult, idx, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -856,6 +861,7 @@ public class DecryptListFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<SubViewHolder> mFileHolderList = new ArrayList<>();
|
public ArrayList<SubViewHolder> mFileHolderList = new ArrayList<>();
|
||||||
|
private int mCurrentFileListSize = 0;
|
||||||
|
|
||||||
public ViewHolder(View itemView) {
|
public ViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
@@ -878,6 +884,7 @@ public class DecryptListFragment
|
|||||||
vFileList = (LinearLayout) itemView.findViewById(R.id.file_list);
|
vFileList = (LinearLayout) itemView.findViewById(R.id.file_list);
|
||||||
for (int i = 0; i < vFileList.getChildCount(); i++) {
|
for (int i = 0; i < vFileList.getChildCount(); i++) {
|
||||||
mFileHolderList.add(new SubViewHolder(vFileList.getChildAt(i)));
|
mFileHolderList.add(new SubViewHolder(vFileList.getChildAt(i)));
|
||||||
|
mCurrentFileListSize += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
vContextMenu = itemView.findViewById(R.id.context_menu);
|
vContextMenu = itemView.findViewById(R.id.context_menu);
|
||||||
@@ -889,6 +896,27 @@ public class DecryptListFragment
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resizeFileList(int size, LayoutInflater inflater) {
|
||||||
|
int childCount = vFileList.getChildCount();
|
||||||
|
// if we require more children, create them
|
||||||
|
while (childCount < size) {
|
||||||
|
View v = inflater.inflate(R.layout.decrypt_list_file_item, null);
|
||||||
|
vFileList.addView(v);
|
||||||
|
mFileHolderList.add(new SubViewHolder(v));
|
||||||
|
childCount += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (size < mCurrentFileListSize) {
|
||||||
|
mCurrentFileListSize -= 1;
|
||||||
|
vFileList.getChildAt(mCurrentFileListSize).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
while (size > mCurrentFileListSize) {
|
||||||
|
vFileList.getChildAt(mCurrentFileListSize).setVisibility(View.VISIBLE);
|
||||||
|
mCurrentFileListSize += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ImageView getEncryptionStatusIcon() {
|
public ImageView getEncryptionStatusIcon() {
|
||||||
return vEncStatusIcon;
|
return vEncStatusIcon;
|
||||||
|
|||||||
@@ -184,69 +184,10 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/file_list">
|
android:id="@+id/file_list"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<include layout="@layout/decrypt_list_file_item" />
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/file"
|
|
||||||
android:clickable="true"
|
|
||||||
android:background="?android:selectableItemBackground"
|
|
||||||
>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/thumbnail"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_width="36dp"
|
|
||||||
android:layout_height="36dp"
|
|
||||||
android:scaleType="center"
|
|
||||||
android:padding="6dp"
|
|
||||||
android:src="@drawable/ic_doc_generic_am" />
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:paddingLeft="8dp"
|
|
||||||
android:paddingRight="8dp"
|
|
||||||
android:layout_weight="1">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/filename"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:text=""
|
|
||||||
tools:text="filename.jpg" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/filesize"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textColor="?android:attr/textColorTertiary"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
|
||||||
android:textSize="12sp"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:text=""
|
|
||||||
tools:text="14kb" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/context_menu"
|
|
||||||
android:scaleType="center"
|
|
||||||
android:layout_width="36dip"
|
|
||||||
android:layout_height="48dip"
|
|
||||||
android:clickable="true"
|
|
||||||
android:background="?android:selectableItemBackground"
|
|
||||||
android:src="@drawable/ic_menu_moreoverflow_normal_holo_light" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
63
OpenKeychain/src/main/res/layout/decrypt_list_file_item.xml
Normal file
63
OpenKeychain/src/main/res/layout/decrypt_list_file_item.xml
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/file"
|
||||||
|
android:clickable="true"
|
||||||
|
android:background="?android:selectableItemBackground"
|
||||||
|
>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/thumbnail"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="36dp"
|
||||||
|
android:scaleType="center"
|
||||||
|
android:padding="6dp"
|
||||||
|
android:src="@drawable/ic_doc_generic_am" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:paddingLeft="8dp"
|
||||||
|
android:paddingRight="8dp"
|
||||||
|
android:layout_weight="1">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/filename"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:text=""
|
||||||
|
tools:text="filename.jpg" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/filesize"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="?android:attr/textColorTertiary"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:text=""
|
||||||
|
tools:text="14kb" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/context_menu"
|
||||||
|
android:scaleType="center"
|
||||||
|
android:layout_width="36dip"
|
||||||
|
android:layout_height="48dip"
|
||||||
|
android:clickable="true"
|
||||||
|
android:background="?android:selectableItemBackground"
|
||||||
|
android:src="@drawable/ic_menu_moreoverflow_normal_holo_light" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
Reference in New Issue
Block a user