Fix sharing

This commit is contained in:
Mario Danic 2020-01-02 14:57:37 +01:00
parent 894bb174f2
commit 436bdeb49f
No known key found for this signature in database
GPG Key ID: CDE0BBD2738C4CC0
2 changed files with 30 additions and 19 deletions

View File

@ -86,6 +86,10 @@ import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
import org.koin.android.ext.android.inject
@ -728,27 +732,33 @@ class ConversationInfoController(args: Bundle) : BaseController(),
}
shareAction.setOnClickListener {
val sendIntent: Intent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(
Intent.EXTRA_SUBJECT,
String.format(
context.getString(R.string.nc_share_subject),
context.getString(R.string.nc_app_name)
)
)
GlobalScope.launch {
val sendIntent: Intent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(
Intent.EXTRA_SUBJECT,
String.format(
context.getString(string.nc_share_subject),
context.getString(string.nc_app_name)
)
)
putExtra(
Intent.EXTRA_TEXT, ShareUtils.getStringForIntent(
context, conversation!!.password, conversation!!
)
)
putExtra(
Intent.EXTRA_TEXT, ShareUtils.getStringForIntent(
context, conversation!!.password, conversation!!
)
)
type = "text/plain"
}
val intent = Intent.createChooser(sendIntent, context.getString(string.nc_share_link))
withContext(Dispatchers.Main) {
startActivity(intent)
}
type = "text/plain"
}
val intent = Intent.createChooser(sendIntent, context.getString(string.nc_share_link))
startActivity(intent)
}
if (allowGuestsAction.value) {

View File

@ -34,8 +34,8 @@ object ShareUtils : KoinComponent {
@JvmStatic
fun getStringForIntent(context: Context?, password: String?, conversation: Conversation): String {
val userEntity: UserNgEntity? = usersRepository.getActiveUser()
var shareString = ""
val userEntity: UserNgEntity? = usersRepository.getActiveUser()
if (userEntity != null && context != null) {
shareString = java.lang.String.format(context.resources.getString(R.string.nc_share_text),
userEntity.baseUrl, conversation.token)
@ -43,6 +43,7 @@ object ShareUtils : KoinComponent {
shareString += String.format(context.resources.getString(R.string.nc_share_text_pass), password)
}
}
return shareString
}
}