Skip to content

Commit

Permalink
Attaching the device logs in the email body instead of as a file.
Browse files Browse the repository at this point in the history
* We cannot attach a file to the email when using the `ACTION_SENDTO` action in the intent. However, we must use this intent action because it is the only one handled exclusively by email apps. This ensures that only email apps appear in the suggestions.
  • Loading branch information
MohitMaliDeveloper committed Oct 21, 2024
1 parent 04ea3af commit 530ca3e
Showing 1 changed file with 1 addition and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import android.os.Bundle
import android.os.Process
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.content.ContextCompat
import androidx.core.content.FileProvider
import org.kiwix.kiwixmobile.core.CoreApp.Companion.coreComponent
import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.core.base.BaseActivity
Expand Down Expand Up @@ -115,20 +114,11 @@ open class ErrorActivity : BaseActivity() {
data = Uri.parse("mailto:")
putExtra(Intent.EXTRA_EMAIL, arrayOf(CRASH_AND_FEEDBACK_EMAIL_ADDRESS))

Check warning on line 115 in core/src/main/java/org/kiwix/kiwixmobile/core/error/ErrorActivity.kt

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/org/kiwix/kiwixmobile/core/error/ErrorActivity.kt#L113-L115

Added lines #L113 - L115 were not covered by tests
putExtra(Intent.EXTRA_SUBJECT, subject)
putExtra(Intent.EXTRA_TEXT, emailBody)
val file = fileLogger.writeLogFile(
this@ErrorActivity,
activityKiwixErrorBinding?.allowLogs?.isChecked == true
)
file.appendText(emailBody)
val path =
FileProvider.getUriForFile(
this@ErrorActivity,
applicationContext.packageName + ".fileprovider",
file
)
addFlags(android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION)
putExtra(android.content.Intent.EXTRA_STREAM, path)
putExtra(Intent.EXTRA_TEXT, "$emailBody\n\nDevice Logs:\n$${file.readText()}")

Check warning on line 121 in core/src/main/java/org/kiwix/kiwixmobile/core/error/ErrorActivity.kt

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/org/kiwix/kiwixmobile/core/error/ErrorActivity.kt#L121

Added line #L121 was not covered by tests
}
}

Expand Down

0 comments on commit 530ca3e

Please sign in to comment.