diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/main/MainShareFragment.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/main/MainShareFragment.kt index fe7b897c5b9..9bff3a7ade9 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/main/MainShareFragment.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/main/MainShareFragment.kt @@ -1,6 +1,5 @@ package de.rki.coronawarnapp.ui.main -import android.content.Intent import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -10,6 +9,7 @@ import de.rki.coronawarnapp.R import de.rki.coronawarnapp.databinding.FragmentMainShareBinding import de.rki.coronawarnapp.ui.BaseFragment import de.rki.coronawarnapp.ui.viewmodel.TracingViewModel +import de.rki.coronawarnapp.util.ShareHelper /** * This fragment informs the user about what he is going to share and how he is going to help everybody with this :) @@ -43,20 +43,10 @@ class MainShareFragment : BaseFragment() { private fun setButtonOnClickListener() { binding.mainShareButton.setOnClickListener { - share() + ShareHelper.shareText(this, getString(R.string.main_share_message), null) } binding.mainShareHeader.informationHeader.headerButtonBack.buttonIcon.setOnClickListener { (activity as MainActivity).goBack() } } - - // TODO move to helper - private fun share() { - val share = Intent.createChooser(Intent().apply { - action = Intent.ACTION_SEND - type = "text/plain" - putExtra(Intent.EXTRA_TEXT, getString(R.string.main_share_message)) - }, null) - startActivity(share) - } } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/ShareHelper.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/ShareHelper.kt new file mode 100644 index 00000000000..c2b07480683 --- /dev/null +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/ShareHelper.kt @@ -0,0 +1,14 @@ +package de.rki.coronawarnapp.util + +import android.content.Intent +import de.rki.coronawarnapp.ui.BaseFragment + +object ShareHelper { + fun shareText(fragment: BaseFragment, text: String, title: String?) { + fragment.startActivity(Intent.createChooser(Intent().apply { + action = Intent.ACTION_SEND + type = "text/plain" + putExtra(Intent.EXTRA_TEXT, text) + }, title)) + } +}