diff --git a/app/build.gradle b/app/build.gradle index 0287b3c4..0ab426ce 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,8 +11,8 @@ apply plugin: 'com.google.gms.google-services' android { - def appVersionCode = 528 - def appVersionName = '1.47.15' + def appVersionCode = 529 + def appVersionName = '1.47.16' signingConfigs { release { diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/settings/MainSettingsFragment.java b/app/src/main/java/it/integry/integrywmsnative/gest/settings/MainSettingsFragment.java index 1ca01cb3..40ba35ac 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/settings/MainSettingsFragment.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/settings/MainSettingsFragment.java @@ -280,15 +280,27 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT List attachmentDTOList = new ArrayList<>(); if (fileToShare != null) { - var htmlContent = createAppLogAttachment(fileToShare); + try { + var htmlContent = createAppLogAttachment(fileToShare); - byte[] buffer = htmlContent.getBytes();//specify the size to allow. - String base64 = Base64.encodeToString(buffer, Base64.NO_WRAP); + byte[] buffer = htmlContent.getBytes();//specify the size to allow. + String base64 = Base64.encodeToString(buffer, Base64.NO_WRAP); - var logAttachment = new MailAttachmentDTO() - .setFileName("wms_log.html") - .setFileb64Content(base64); - attachmentDTOList.add(logAttachment); + var logAttachment = new MailAttachmentDTO() + .setFileName("wms_log.html") + .setFileb64Content(base64); + attachmentDTOList.add(logAttachment); + } catch (Exception ex) { + String rawLogFile = getRawLogAttachment(fileToShare); + + byte[] buffer = rawLogFile.getBytes();//specify the size to allow. + String base64 = Base64.encodeToString(buffer, Base64.NO_WRAP); + + var logAttachment = new MailAttachmentDTO() + .setFileName("raw_log.txt") + .setFileb64Content(base64); + attachmentDTOList.add(logAttachment); + } } @@ -461,4 +473,24 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT return htmlContent.toString(); } + + private String getRawLogAttachment(File logFile) { + //Read text from file + StringBuilder text = new StringBuilder(); + + try { + BufferedReader br = new BufferedReader(new FileReader(logFile)); + String line; + + while ((line = br.readLine()) != null) { + text.append(line); + text.append('\n'); + } + br.close(); + } catch (IOException e) { + //You'll need to add proper error handling here + } + + return text.toString(); + } }