Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix opening DDOC containers #538

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ public final class SignatureDetailScreen extends ConductorScreen {
private static final int SIGNATURE_DETAIL_SCREEN_ID = R.id.signatureDetailScreen;
private Signature userSignature;
private SignedContainer userSignedContainer;
boolean isSivaConfirmed;

public SignatureDetailScreen(int id, Signature signature, SignedContainer signedContainer) {
public SignatureDetailScreen(int id, Signature signature, SignedContainer signedContainer, boolean isSivaConfirmed) {
super(id);
this.userSignature = signature;
this.userSignedContainer = signedContainer;
this.isSivaConfirmed = isSivaConfirmed;
}

public static SignatureDetailScreen create(Signature signature, SignedContainer signedContainer) {
return new SignatureDetailScreen(SIGNATURE_DETAIL_SCREEN_ID, signature, signedContainer);
public static SignatureDetailScreen create(Signature signature, SignedContainer signedContainer, boolean isSivaConfirmed) {
return new SignatureDetailScreen(SIGNATURE_DETAIL_SCREEN_ID, signature, signedContainer, isSivaConfirmed);
}

@SuppressWarnings("WeakerAccess")
Expand All @@ -31,6 +33,6 @@ public SignatureDetailScreen() {

@Override
protected View view(Context context) {
return new SignatureDetailView(context, userSignature, userSignedContainer);
return new SignatureDetailView(context, userSignature, userSignedContainer, isSivaConfirmed);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public final class SignatureDetailView extends CoordinatorLayout implements Cont
private final Navigator navigator;
private final Toolbar toolbarView;

private final boolean isSivaConfirmed;

private final LinearLayout errorContainer;
private final TextView errorTitle;
private final TextView errorDetails;
Expand All @@ -66,7 +68,7 @@ public final class SignatureDetailView extends CoordinatorLayout implements Cont

private final ViewDisposables disposables = new ViewDisposables();

public SignatureDetailView(Context context, Signature signature, SignedContainer signedContainer) {
public SignatureDetailView(Context context, Signature signature, SignedContainer signedContainer, boolean isSivaConfirmed) {
super(context);

inflate(context, R.layout.signature_detail_screen, this);
Expand All @@ -75,6 +77,8 @@ public SignatureDetailView(Context context, Signature signature, SignedContainer
navigator = ApplicationApp.component(context).navigator();
toolbarView = findViewById(R.id.toolbar);

this.isSivaConfirmed = isSivaConfirmed;

errorContainer = findViewById(R.id.signersCertificateErrorContainer);
errorTitle = findViewById(R.id.signersCertificateErrorTitle);
errorDetails = findViewById(R.id.signersCertificateErrorDetails);
Expand Down Expand Up @@ -117,12 +121,17 @@ public SignatureDetailView(Context context, Signature signature, SignedContainer
ContentView.addInvisibleElement(context, this);
}

private String getContainerMimeType(SignedContainer signedContainer) {
Container container = Container.open(signedContainer.file().getAbsolutePath(), new DigidocContainerOpenCB(false));
if (container == null) {
private String getContainerMimeType(SignedContainer signedContainer, boolean isSivaConfirmed) {
try {
Container container = Container.open(signedContainer.file().getAbsolutePath(), new DigidocContainerOpenCB(isSivaConfirmed));
if (container == null) {
return "";
}
return container.mediaType();
} catch (Exception e) {
Timber.log(Log.ERROR, e, String.format("Unable to get container mimetype. %s", e.getLocalizedMessage()));
return "";
}
return container.mediaType();
}

private int getNumberOfFilesInContainer(SignedContainer signedContainer) {
Expand All @@ -133,7 +142,7 @@ private void setData(Signature signature, SignedContainer signedContainer) {
TextUtil.handleDetailText((signature.signersCertificateIssuer()), findViewById(R.id.signatureDetailSignersCertificateIssuer));
TextUtil.handleDetailText((signature.name()).replace(",", ", "), findViewById(R.id.signersCertificateButton));
TextUtil.handleDetailText((signature.signatureMethod()), findViewById(R.id.signatureDetailMethod));
TextUtil.handleDetailText((getContainerMimeType(signedContainer)), findViewById(R.id.containerDetailFormat));
TextUtil.handleDetailText((getContainerMimeType(signedContainer, isSivaConfirmed)), findViewById(R.id.containerDetailFormat));
TextUtil.handleDetailText((signature.signatureFormat()), findViewById(R.id.signatureDetailFormat));
TextUtil.handleDetailText((String.valueOf(getNumberOfFilesInContainer(signedContainer))), findViewById(R.id.containerDetailSignedFileCount));
TextUtil.handleDetailText((signature.signatureTimestamp()), findViewById(R.id.signatureDetailTimestamp));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ final class Processor implements ObservableTransformer<Action, Result> {
.map(signedContainerFile -> {
Transaction transaction;
transaction = Transaction.push(SignatureDetailScreen
.create(action.signature(), signedContainerFile));
.create(action.signature(), signedContainerFile, action.isSivaConfirmed()));
navigator.execute(transaction);
return Result.SignatureViewResult.idle();
})
Expand Down
Loading