diff --git a/app/src/main/java/com/etesync/syncadapter/AcraConfiguration.java b/app/src/main/java/com/etesync/syncadapter/AcraConfiguration.java index dc9b8b95..b3aecf2d 100644 --- a/app/src/main/java/com/etesync/syncadapter/AcraConfiguration.java +++ b/app/src/main/java/com/etesync/syncadapter/AcraConfiguration.java @@ -1,7 +1,6 @@ package com.etesync.syncadapter; import android.content.Context; -import android.content.pm.PackageManager; import android.widget.Toast; import org.acra.config.CoreConfigurationBuilder; @@ -9,20 +8,9 @@ import org.acra.config.MailSenderConfigurationBuilder; import org.acra.config.ToastConfigurationBuilder; import org.acra.data.StringFormat; +import static com.etesync.syncadapter.utils.EventEmailInvitationKt.emailSupportsAttachments; + public class AcraConfiguration { - private static Boolean shouldReportAsFile(Context context) { - Boolean shouldReport = false; - - try { - context.getPackageManager().getPackageInfo("ch.protonmail.android", 0); - } catch (PackageManager.NameNotFoundException e) { - shouldReport = true; - } - - System.out.println("ACRA with attached files: " + shouldReport.toString()); - return shouldReport; - } - public static CoreConfigurationBuilder getConfig(Context context) { CoreConfigurationBuilder builder = new CoreConfigurationBuilder(context) .setBuildConfigClass(BuildConfig.class) @@ -32,7 +20,7 @@ public class AcraConfiguration { .setMailTo("reports@etesync.com") .setResSubject(R.string.crash_email_subject) .setReportFileName("ACRA-report.stacktrace.json") - .setReportAsFile(shouldReportAsFile(context)) + .setReportAsFile(emailSupportsAttachments(context)) .setEnabled(true); builder.getPluginConfigurationBuilder(ToastConfigurationBuilder.class) .setResText(R.string.crash_message) diff --git a/app/src/main/java/com/etesync/syncadapter/utils/EventEmailInvitation.kt b/app/src/main/java/com/etesync/syncadapter/utils/EventEmailInvitation.kt index 60beab79..332e5f98 100644 --- a/app/src/main/java/com/etesync/syncadapter/utils/EventEmailInvitation.kt +++ b/app/src/main/java/com/etesync/syncadapter/utils/EventEmailInvitation.kt @@ -3,6 +3,7 @@ package com.etesync.syncadapter.utils import android.accounts.Account import android.content.Context import android.content.Intent +import android.content.pm.PackageManager import android.net.Uri import at.bitfire.ical4android.Event import com.etesync.syncadapter.App @@ -15,6 +16,18 @@ import java.io.IOException import java.text.SimpleDateFormat import java.util.* +fun emailSupportsAttachments(context: Context): Boolean { + var supportsAttachments = false + + try { + context.packageManager.getPackageInfo("ch.protonmail.android", 0) + } catch (e: PackageManager.NameNotFoundException) { + supportsAttachments = true + } + + return supportsAttachments +} + class EventEmailInvitation constructor(val context: Context, val account: Account) { fun createIntent(event: Event, icsContent: String): Intent? { val intent = Intent(Intent.ACTION_SEND)