Improve sharing

This commit is contained in:
Phillip Thelen 2020-02-05 11:55:15 +01:00
parent b60f8ac7b4
commit 8e2041923b
3 changed files with 7 additions and 1 deletions

View file

@ -153,7 +153,7 @@ android {
multiDexEnabled true
resConfigs "en", "bg", "de", "en-rGB", "es", "fr", "hr-rHR", "in", "it", "iw", "ja", "ko", "lt", "nl", "pl", "pt-rBR", "pt-rPT", "ru", "tr", "zh", "zh-rTW"
versionCode 2364
versionCode 2369
versionName "2.5"
}

View file

@ -578,6 +578,7 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
val sharingIntent = Intent(Intent.ACTION_SEND)
sharingIntent.type = "*/*"
sharingIntent.putExtra(Intent.EXTRA_TEXT, event.sharedMessage)
BitmapUtils.clearDirectoryContent("$filesDir/shared_images")
val f = BitmapUtils.saveToShareableFile("$filesDir/shared_images", "${Date().toString()}.png", event.shareImage)
val fileUri = f?.let { FileProvider.getUriForFile(this, getString(R.string.content_provider), it) }
if (fileUri != null) {

View file

@ -5,6 +5,11 @@ import java.io.File
import java.io.FileOutputStream
object BitmapUtils {
fun clearDirectoryContent(directory: String) {
val dirFile = File(directory)
dirFile.listFiles()?.forEach { it.delete() }
}
fun saveToShareableFile(directory: String, filename: String, bmp: Bitmap): File? {
var name = filename
try {