diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2015-09-16 02:19:23 +0200 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2015-09-16 02:19:23 +0200 |
commit | 81ce075df9e656c662c00c603388e950013c384a (patch) | |
tree | 68930af90ad4165fad87895ec5abba108cbcd758 | |
parent | 5ac939387f35e634bec23f79220e6f8e7ff909d9 (diff) | |
download | open-keychain-81ce075df9e656c662c00c603388e950013c384a.tar.gz open-keychain-81ce075df9e656c662c00c603388e950013c384a.tar.bz2 open-keychain-81ce075df9e656c662c00c603388e950013c384a.zip |
multidecrypt: prepare viewholder for file list
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java | 96 | ||||
-rw-r--r-- | OpenKeychain/src/main/res/layout/decrypt_list_entry.xml | 109 |
2 files changed, 116 insertions, 89 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java index 27ad9cbb1..bc3319617 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java @@ -46,6 +46,7 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.PopupMenu; import android.widget.PopupMenu.OnDismissListener; import android.widget.PopupMenu.OnMenuItemClickListener; @@ -61,6 +62,7 @@ import org.sufficientlysecure.keychain.operations.results.InputDataResult; import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyInputParcel; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.service.InputDataParcel; +import org.sufficientlysecure.keychain.ui.DecryptListFragment.ViewHolder.SubViewHolder; 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) import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils.StatusHolder; @@ -659,38 +661,43 @@ public class DecryptListFragment final OpenPgpMetadata metadata = model.mResult.mMetadata.get(0); - String filename; - if (metadata == null) { - filename = getString(R.string.filename_unknown); - } else if (TextUtils.isEmpty(metadata.getFilename())) { - filename = getString("text/plain".equals(metadata.getMimeType()) - ? R.string.filename_unknown_text : R.string.filename_unknown); - } else { - filename = metadata.getFilename(); - } - holder.vFilename.setText(filename); + { + SubViewHolder fileHolder = holder.mFileHolderList.get(0); - long size = metadata == null ? 0 : metadata.getOriginalSize(); - if (size == -1 || size == 0) { - holder.vFilesize.setText(""); - } else { - holder.vFilesize.setText(FileHelper.readableFileSize(size)); - } + String filename; + if (metadata == null) { + filename = getString(R.string.filename_unknown); + } else if (TextUtils.isEmpty(metadata.getFilename())) { + filename = getString("text/plain".equals(metadata.getMimeType()) + ? R.string.filename_unknown_text : R.string.filename_unknown); + } else { + filename = metadata.getFilename(); + } + fileHolder.vFilename.setText(filename); - // if (model.mIcon != null) { - // holder.vThumbnail.setImageDrawable(model.mIcon); - //} else { - holder.vThumbnail.setImageResource(R.drawable.ic_doc_generic_am); - //} + long size = metadata == null ? 0 : metadata.getOriginalSize(); + if (size == -1 || size == 0) { + fileHolder.vFilesize.setText(""); + } else { + fileHolder.vFilesize.setText(FileHelper.readableFileSize(size)); + } - holder.vFile.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View view) { - if (model.mResult.success()) { - displayWithViewIntent(model.mResult, 0, false); + // if (model.mIcon != null) { + // holder.vThumbnail.setImageDrawable(model.mIcon); + //} else { + fileHolder.vThumbnail.setImageResource(R.drawable.ic_doc_generic_am); + //} + + fileHolder.vFile.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + if (model.mResult.success()) { + displayWithViewIntent(model.mResult, 0, false); + } } - } - }); + }); + + } OpenPgpSignatureResult sigResult = model.mResult.mDecryptVerifyResult.getSignatureResult(); if (sigResult != null) { @@ -816,11 +823,6 @@ public class DecryptListFragment public ProgressBar vProgress; public TextView vProgressMsg; - public View vFile; - public TextView vFilename; - public TextView vFilesize; - public ImageView vThumbnail; - public ImageView vEncStatusIcon; public TextView vEncStatusText; @@ -837,6 +839,24 @@ public class DecryptListFragment public ImageView vCancelledRetry; + public LinearLayout vFileList; + + public static class SubViewHolder { + public View vFile; + public TextView vFilename; + public TextView vFilesize; + public ImageView vThumbnail; + + public SubViewHolder(View itemView) { + vFile = itemView.findViewById(R.id.file); + vFilename = (TextView) itemView.findViewById(R.id.filename); + vFilesize = (TextView) itemView.findViewById(R.id.filesize); + vThumbnail = (ImageView) itemView.findViewById(R.id.thumbnail); + } + } + + public ArrayList<SubViewHolder> mFileHolderList = new ArrayList<>(); + public ViewHolder(View itemView) { super(itemView); @@ -845,11 +865,6 @@ public class DecryptListFragment vProgress = (ProgressBar) itemView.findViewById(R.id.progress); vProgressMsg = (TextView) itemView.findViewById(R.id.progress_msg); - vFile = itemView.findViewById(R.id.file); - vFilename = (TextView) itemView.findViewById(R.id.filename); - vFilesize = (TextView) itemView.findViewById(R.id.filesize); - vThumbnail = (ImageView) itemView.findViewById(R.id.thumbnail); - vEncStatusIcon = (ImageView) itemView.findViewById(R.id.result_encryption_icon); vEncStatusText = (TextView) itemView.findViewById(R.id.result_encryption_text); @@ -860,6 +875,11 @@ public class DecryptListFragment vSignatureMail= (TextView) itemView.findViewById(R.id.result_signature_email); vSignatureAction = (TextView) itemView.findViewById(R.id.result_signature_action); + vFileList = (LinearLayout) itemView.findViewById(R.id.file_list); + for (int i = 0; i < vFileList.getChildCount(); i++) { + mFileHolderList.add(new SubViewHolder(vFileList.getChildAt(i))); + } + vContextMenu = itemView.findViewById(R.id.context_menu); vErrorMsg = (TextView) itemView.findViewById(R.id.result_error_msg); diff --git a/OpenKeychain/src/main/res/layout/decrypt_list_entry.xml b/OpenKeychain/src/main/res/layout/decrypt_list_entry.xml index 048595dd8..7b9515170 100644 --- a/OpenKeychain/src/main/res/layout/decrypt_list_entry.xml +++ b/OpenKeychain/src/main/res/layout/decrypt_list_entry.xml @@ -24,7 +24,7 @@ android:outAnimation="@anim/fade_out" android:id="@+id/view_animator" android:measureAllChildren="false" - custom:initialView="0" + custom:initialView="1" android:minHeight="?listPreferredItemHeightSmall" android:animateLayoutChanges="true" > @@ -184,63 +184,70 @@ <LinearLayout 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" /> + android:id="@+id/file_list"> <LinearLayout - android:orientation="vertical" - android:layout_width="0dp" + android:layout_width="match_parent" 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: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:textColor="?android:attr/textColorTertiary" - android:textAppearance="?android:attr/textAppearanceSmall" - android:textSize="12sp" - android:ellipsize="end" - android:text="" - tools:text="14kb" /> + 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> - <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> |