Skip to content

Commit

Permalink
Fix a sharing bug (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
stoyicker committed May 21, 2017
1 parent 05e4549 commit 58bc11a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ internal class PostDetailActivityInstrumentation {
intending(anyIntent()).respondWith(Instrumentation.ActivityResult(Activity.RESULT_OK, null))
onView(withId(R.id.share)).perform(click())
intended(intentChooser(allOf(
hasExtra(Intent.EXTRA_TITLE, ITEM.title))))
hasExtra(Intent.EXTRA_SUBJECT, ITEM.title),
hasExtra(Intent.EXTRA_TEXT, ITEM.url)
)))
Intents.release()
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/kotlin/app/common/PresentationPost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal data class PresentationPost(

override fun getShareableTitle() = title

override fun getShareableLink(): Uri = Uri.parse(url)
override fun getShareableLink() = url

companion object {
@Suppress("unused") // Parcelable
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/kotlin/app/share/ShareFeature.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package app.share

import android.content.Context
import android.content.Intent
import android.net.Uri
import org.jorge.ms.app.R

/**
Expand All @@ -14,8 +13,9 @@ internal class ShareFeature(private val context: Context) {
* @param item The time to share.
*/
fun share(item: ShareFeature.Shareable) {
val intent = Intent(Intent.ACTION_SEND, item.getShareableLink())
intent.putExtra(Intent.EXTRA_TITLE, item.getShareableTitle())
val intent = Intent(Intent.ACTION_SEND)
intent.putExtra(Intent.EXTRA_SUBJECT, item.getShareableTitle())
intent.putExtra(Intent.EXTRA_TEXT, item.getShareableLink())
intent.type = "text/plain"
context.startActivity(Intent.createChooser(intent, context.getString(R.string.share)))
}
Expand All @@ -34,6 +34,6 @@ internal class ShareFeature(private val context: Context) {
* Implementations should provide a uri representative of this item when shared.
* @return A uri representative of this item when shared.
*/
fun getShareableLink(): Uri
fun getShareableLink(): String
}
}

0 comments on commit 58bc11a

Please sign in to comment.