mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-23 17:22:16 -05:00
add failure state to DecryptListFragment
This commit is contained in:
parent
fe7d13c85f
commit
361ad99928
@ -577,7 +577,30 @@ public class DecryptListFragment
|
||||
// - replace the contents of the view with that element
|
||||
final ViewModel model = mDataset.get(position);
|
||||
|
||||
if (model.hasResult()) {
|
||||
if (!model.hasResult()) {
|
||||
bindItemProgress(holder, model);
|
||||
return;
|
||||
}
|
||||
|
||||
if (model.mResult.success()) {
|
||||
bindItemSuccess(holder, model);
|
||||
} else {
|
||||
bindItemFailure(holder, model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void bindItemProgress(ViewHolder holder, ViewModel model) {
|
||||
if (holder.vAnimator.getDisplayedChild() != 0) {
|
||||
holder.vAnimator.setDisplayedChild(0);
|
||||
}
|
||||
|
||||
holder.vProgress.setProgress(model.mProgress);
|
||||
holder.vProgress.setMax(model.mMax);
|
||||
holder.vProgressMsg.setText(model.mProgressMsg);
|
||||
}
|
||||
|
||||
private void bindItemSuccess(ViewHolder holder, final ViewModel model) {
|
||||
if (holder.vAnimator.getDisplayedChild() != 1) {
|
||||
holder.vAnimator.setDisplayedChild(1);
|
||||
}
|
||||
@ -634,17 +657,24 @@ public class DecryptListFragment
|
||||
menu.show();
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
if (holder.vAnimator.getDisplayedChild() != 0) {
|
||||
holder.vAnimator.setDisplayedChild(0);
|
||||
}
|
||||
|
||||
holder.vProgress.setProgress(model.mProgress);
|
||||
holder.vProgress.setMax(model.mMax);
|
||||
holder.vProgressMsg.setText(model.mProgressMsg);
|
||||
private void bindItemFailure(ViewHolder holder, final ViewModel model) {
|
||||
if (holder.vAnimator.getDisplayedChild() != 2) {
|
||||
holder.vAnimator.setDisplayedChild(2);
|
||||
}
|
||||
|
||||
holder.vErrorMsg.setText(model.mResult.getLog().getLast().mType.getMsgId());
|
||||
|
||||
holder.vErrorViewLog.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(mContext, LogDisplayActivity.class);
|
||||
intent.putExtra(LogDisplayFragment.EXTRA_RESULT, model.mResult);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Return the size of your dataset (invoked by the layout manager)
|
||||
@ -719,9 +749,11 @@ public class DecryptListFragment
|
||||
public TextView vSignatureName;
|
||||
public TextView vSignatureMail;
|
||||
public TextView vSignatureAction;
|
||||
|
||||
public View vContextMenu;
|
||||
|
||||
public TextView vErrorMsg;
|
||||
public ImageView vErrorViewLog;
|
||||
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
@ -747,6 +779,9 @@ public class DecryptListFragment
|
||||
|
||||
vContextMenu = itemView.findViewById(R.id.context_menu);
|
||||
|
||||
vErrorMsg = (TextView) itemView.findViewById(R.id.result_error_msg);
|
||||
vErrorViewLog = (ImageView) itemView.findViewById(R.id.result_error_log);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,7 +23,8 @@
|
||||
android:inAnimation="@anim/fade_in"
|
||||
android:outAnimation="@anim/fade_out"
|
||||
android:id="@+id/view_animator"
|
||||
custom:initialView="1"
|
||||
android:measureAllChildren="false"
|
||||
custom:initialView="2"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
@ -243,6 +244,53 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:ignore="UseCompoundDrawables">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp"
|
||||
android:src="@drawable/status_signature_invalid_cutout_24dp"
|
||||
android:tint="@color/android_red_light"
|
||||
android:layout_gravity="center_vertical" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/result_error_msg"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text=""
|
||||
android:layout_gravity="center_vertical"
|
||||
tools:text="Error processing data!" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/result_error_log"
|
||||
android:scaleType="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:clickable="true"
|
||||
android:padding="6dp"
|
||||
android:background="?android:selectableItemBackground"
|
||||
android:src="@drawable/ic_view_list_grey_24dp"
|
||||
android:layout_gravity="center_vertical" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</org.sufficientlysecure.keychain.ui.widget.ToolableViewAnimator>
|
||||
|
||||
</android.support.v7.widget.CardView>
|
Loading…
Reference in New Issue
Block a user