Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Add ShareHelper #85

Merged
merged 7 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 :)
Expand Down Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
@@ -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))
}
}