Skip to content

Commit

Permalink
Merge pull request #526 from martenrebane/MOPPAND-1319
Browse files Browse the repository at this point in the history
Updated libdigidocpp
  • Loading branch information
Counter178 authored May 3, 2024
2 parents 7f5cfba + 4bf81bd commit 3dcd534
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static android.view.accessibility.AccessibilityEvent.TYPE_ANNOUNCEMENT;
import static com.jakewharton.rxbinding4.view.RxView.clicks;
import static com.jakewharton.rxbinding4.widget.RxToolbar.navigationClicks;
import static ee.ria.DigiDoc.android.Constants.VIEW_TYPE;
import static ee.ria.DigiDoc.android.main.diagnostics.DiagnosticsScreen.diagnosticsFileLogsSaveClicksSubject;
import static ee.ria.DigiDoc.android.main.diagnostics.DiagnosticsScreen.diagnosticsFileSaveClicksSubject;
import static ee.ria.DigiDoc.android.main.settings.util.SettingsUtil.getToolbarImageButton;
Expand Down Expand Up @@ -49,6 +50,7 @@
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Optional;

import ee.ria.DigiDoc.BuildConfig;
import ee.ria.DigiDoc.R;
Expand Down Expand Up @@ -335,7 +337,7 @@ private void setData(ConfigurationProvider configurationProvider) {
androidVersion.setText(setDisplayTextWithTitle(R.string.main_diagnostics_operating_system_title,
getAndroidVersion(), Typeface.DEFAULT_BOLD));
libDocVersion.setText(setDisplayTextWithTitle(R.string.main_diagnostics_libdigidocpp_title,
getLibDigiDocVersion(settingsDataStore), Typeface.DEFAULT_BOLD));
getLibDigiDocVersion(settingsDataStore, navigator.activity()), Typeface.DEFAULT_BOLD));

configUrl.setText(setDisplayTextWithTitle(R.string.main_diagnostics_config_url_title,
configurationProvider.getConfigUrl(), Typeface.DEFAULT));
Expand Down Expand Up @@ -456,13 +458,26 @@ private static String getAndroidVersion() {
return "Android " + Build.VERSION.RELEASE;
}

private static String getLibDigiDocVersion(SettingsDataStore settingsDataStore) {
String libDigidocppVersion = SignLib.libdigidocppVersion();
// Libdigidocpp might not have been initialized when opening Diagnostics view
if (libDigidocppVersion.isEmpty()) {
return settingsDataStore.getLibdigidocppVersion();
}
settingsDataStore.setLibdigidocppVersion(libDigidocppVersion);
return libDigidocppVersion;
private static String getLibDigiDocVersion(SettingsDataStore settingsDataStore, Context context) {
return Optional.ofNullable(context)
.filter(ctx -> ctx instanceof Activity)
.map(ctx -> (Activity) ctx)
.map(Activity::getIntent)
.flatMap(intent -> Optional.ofNullable(intent.getExtras()))
.filter(extras -> extras.containsKey(VIEW_TYPE))
.map(extras -> extras.get(VIEW_TYPE))
.filter(viewType -> viewType instanceof String && !((String) viewType).isEmpty())
.map(viewType -> {
String savedLibDigidocppVersion = settingsDataStore.getLibdigidocppVersion();
if (savedLibDigidocppVersion.isEmpty()) {
return "";
}
return savedLibDigidocppVersion;
})
.orElseGet(() -> {
String libDigidocppVersion = SignLib.libdigidocppVersion();
settingsDataStore.setLibdigidocppVersion(libDigidocppVersion);
return libDigidocppVersion;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,16 @@ class DocumentSaveIntent implements Intent, Action {

DataFile document;

public DocumentSaveIntent(File containerFile, DataFile document) {
boolean confirmation;

public DocumentSaveIntent(File containerFile, DataFile document, boolean confirmation) {
this.containerFile = containerFile;
this.document = document;
this.confirmation = confirmation;
}

static DocumentSaveIntent create(File containerFile, DataFile document) {
return new DocumentSaveIntent(containerFile, document);
static DocumentSaveIntent create(File containerFile, DataFile document, boolean confirmation) {
return new DocumentSaveIntent(containerFile, document, confirmation);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ final class Processor implements ObservableTransformer<Action, Result> {
} else {
File containerFile = action.containerFile;
return signatureContainerDataSource
.getDocumentFile(containerFile, action.document, false)
.getDocumentFile(containerFile, action.document, !action.confirmation)
.toObservable()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
Expand Down Expand Up @@ -278,11 +278,15 @@ final class Processor implements ObservableTransformer<Action, Result> {
documentSave = upstream -> upstream.switchMap(action -> {
navigator.execute(Transaction.activityForResult(SAVE_FILE,
createSaveIntent(action.document), null));
File containerFile = action.containerFile;
DataFile dataFile = action.document;
boolean confirmation = action.confirmation;
return navigator.activityResults()
.filter(activityResult ->
activityResult.requestCode() == SAVE_FILE)
.take(1)
.switchMap(activityResult -> signatureContainerDataSource
.getDocumentFile(action.containerFile, action.document, false)
.getDocumentFile(containerFile, dataFile, confirmation)
.toObservable()
.map(documentFile -> {
if (activityResult.resultCode() == RESULT_OK) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ public void onAttachedToWindow() {
disposables.add(adapter.scrollToTop().subscribe(ignored -> listView.scrollToPosition(0)));
disposables.add(adapter.documentSaveClicks().subscribe(document ->
documentSaveIntentSubject.onNext(DocumentSaveIntent
.create((nestedFile != null) ? nestedFile : containerFile, document))));
.create((nestedFile != null && isSivaConfirmed) ? nestedFile : containerFile, document, isSivaConfirmed))));
disposables.add(adapter.signatureClicks().subscribe(signature ->
signatureViewIntentSubject.onNext(SignatureViewIntent
.create(containerFile, signature, isSivaConfirmed))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,11 @@ public static Intent setIntentData(Intent intent, Path filePath, android.app.Act
private static String getDataFileMimetype(DataFile dataFile) {
int extensionIndex = dataFile.name().lastIndexOf(".");
String extension = extensionIndex != -1 ? dataFile.name().substring(extensionIndex + 1) : "";
return !extension.isEmpty() ? MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension) : "application/octet-stream";
if (!extension.isEmpty()) {
String dataFileMimetype = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
return dataFileMimetype != null ? dataFileMimetype : "application/octet-stream";
}
return "application/octet-stream";
}

private static long getFileSize(ContentResolver contentResolver, Uri uri) {
Expand Down
Binary file modified common-lib/libs/libdigidocpp.jar
Binary file not shown.
Binary file modified sign-lib/src/debug/jniLibs/arm64-v8a/libdigidoc_java.so
Binary file not shown.
Binary file modified sign-lib/src/debug/jniLibs/armeabi-v7a/libdigidoc_java.so
Binary file not shown.
Binary file modified sign-lib/src/debug/jniLibs/x86_64/libdigidoc_java.so
Binary file not shown.
Binary file modified sign-lib/src/main/jniLibs/arm64-v8a/libdigidoc_java.so
Binary file not shown.
Binary file modified sign-lib/src/main/jniLibs/armeabi-v7a/libdigidoc_java.so
Binary file not shown.
Binary file modified sign-lib/src/main/jniLibs/x86_64/libdigidoc_java.so
Binary file not shown.
Binary file modified sign-lib/src/main/res/raw/schema.zip
Binary file not shown.

0 comments on commit 3dcd534

Please sign in to comment.