1
0
mirror of https://github.com/etesync/android synced 2024-12-24 15:38:09 +00:00

Rename and move the function checking if email attachments are supported.

This commit is contained in:
Tom Hacohen 2019-02-20 15:35:10 +00:00
parent acaf14c25c
commit 09ee9a2bd1
2 changed files with 16 additions and 15 deletions

View File

@ -1,7 +1,6 @@
package com.etesync.syncadapter; package com.etesync.syncadapter;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager;
import android.widget.Toast; import android.widget.Toast;
import org.acra.config.CoreConfigurationBuilder; import org.acra.config.CoreConfigurationBuilder;
@ -9,20 +8,9 @@ import org.acra.config.MailSenderConfigurationBuilder;
import org.acra.config.ToastConfigurationBuilder; import org.acra.config.ToastConfigurationBuilder;
import org.acra.data.StringFormat; import org.acra.data.StringFormat;
import static com.etesync.syncadapter.utils.EventEmailInvitationKt.emailSupportsAttachments;
public class AcraConfiguration { 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) { public static CoreConfigurationBuilder getConfig(Context context) {
CoreConfigurationBuilder builder = new CoreConfigurationBuilder(context) CoreConfigurationBuilder builder = new CoreConfigurationBuilder(context)
.setBuildConfigClass(BuildConfig.class) .setBuildConfigClass(BuildConfig.class)
@ -32,7 +20,7 @@ public class AcraConfiguration {
.setMailTo("reports@etesync.com") .setMailTo("reports@etesync.com")
.setResSubject(R.string.crash_email_subject) .setResSubject(R.string.crash_email_subject)
.setReportFileName("ACRA-report.stacktrace.json") .setReportFileName("ACRA-report.stacktrace.json")
.setReportAsFile(shouldReportAsFile(context)) .setReportAsFile(emailSupportsAttachments(context))
.setEnabled(true); .setEnabled(true);
builder.getPluginConfigurationBuilder(ToastConfigurationBuilder.class) builder.getPluginConfigurationBuilder(ToastConfigurationBuilder.class)
.setResText(R.string.crash_message) .setResText(R.string.crash_message)

View File

@ -3,6 +3,7 @@ package com.etesync.syncadapter.utils
import android.accounts.Account import android.accounts.Account
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri import android.net.Uri
import at.bitfire.ical4android.Event import at.bitfire.ical4android.Event
import com.etesync.syncadapter.App import com.etesync.syncadapter.App
@ -15,6 +16,18 @@ import java.io.IOException
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* 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) { class EventEmailInvitation constructor(val context: Context, val account: Account) {
fun createIntent(event: Event, icsContent: String): Intent? { fun createIntent(event: Event, icsContent: String): Intent? {
val intent = Intent(Intent.ACTION_SEND) val intent = Intent(Intent.ACTION_SEND)