diff --git a/android/app/src/main/java/org/mozilla/sendandroid/MainActivity.kt b/android/app/src/main/java/org/mozilla/sendandroid/MainActivity.kt index e0a5730e..2d953c00 100644 --- a/android/app/src/main/java/org/mozilla/sendandroid/MainActivity.kt +++ b/android/app/src/main/java/org/mozilla/sendandroid/MainActivity.kt @@ -35,6 +35,11 @@ class WebAppInterface(private val mContext: MainActivity) { fun beginOAuthFlow() { mContext.beginOAuthFlow(); } + + @JavascriptInterface + fun shareUrl(url: String) { + mContext.shareUrl(url) + } } class MainActivity : AppCompatActivity(), AdvancedWebView.Listener { @@ -94,6 +99,14 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener { }) } + fun shareUrl(url: String) { + val shareIntent = Intent() + shareIntent.action = Intent.ACTION_SEND + shareIntent.type = "text/plain" + shareIntent.putExtra(Intent.EXTRA_TEXT, url); + startActivity(Intent.createChooser(shareIntent, "")) + } + @SuppressLint("NewApi") override fun onResume() { super.onResume() diff --git a/app/ui/archiveTile.js b/app/ui/archiveTile.js index 09e25d0a..ee0c0800 100644 --- a/app/ui/archiveTile.js +++ b/app/ui/archiveTile.js @@ -1,3 +1,5 @@ +/* global Android */ + const html = require('choo/html'); const raw = require('choo/html/raw'); const assets = require('../../common/assets'); @@ -140,6 +142,26 @@ function archiveDetails(translate, archive) { } module.exports = function(state, emit, archive) { + const copyOrShare = + typeof window.Android !== 'object' + ? html` + + ` + : html` + + `; return html` ${archiveDetails(state.translate, archive)}
- + ${copyOrShare}
`; function copy(event) { @@ -185,6 +202,11 @@ module.exports = function(state, emit, archive) { event.stopPropagation(); emit('delete', { file: archive, location: 'success-screen' }); } + + function share(event) { + event.stopPropagation(); + Android.shareUrl(archive.url); + } }; module.exports.wip = function(state, emit) { diff --git a/assets/share-16.svg b/assets/share-16.svg new file mode 100644 index 00000000..507f199f --- /dev/null +++ b/assets/share-16.svg @@ -0,0 +1 @@ + \ No newline at end of file