Skip to content
This repository was archived by the owner on May 22, 2021. It is now read-only.

Commit cdcac12

Browse files
committed
(Android) Use Kotlin string templates instead of concatenating strings
1 parent 4ada126 commit cdcac12

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

android/app/src/main/java/org/mozilla/firefoxsend/MainActivity.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,15 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
6666
}
6767
}
6868

69-
val action = intent.action
7069
val type = intent.type
71-
72-
if (Intent.ACTION_SEND == action && type != null) {
70+
if (Intent.ACTION_SEND == intent.action && type != null) {
7371
if (type == "text/plain") {
7472
val sharedText = intent.getStringExtra(Intent.EXTRA_TEXT)
75-
Log.d(TAG_INTENT, "text/plain " + sharedText)
73+
Log.d(TAG_INTENT, "text/plain $sharedText")
7674
mToShare = "data:text/plain;base64," + Base64.encodeToString(sharedText.toByteArray(), 16).trim()
7775
} else if (type.startsWith("image/")) {
7876
val imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM) as Uri
79-
Log.d(TAG_INTENT, "image/ " + imageUri)
77+
Log.d(TAG_INTENT, "image/ $imageUri")
8078
mToShare = "data:text/plain;base64," + Base64.encodeToString(imageUri.path.toByteArray(), 16).trim()
8179
}
8280
}
@@ -88,7 +86,7 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
8886
mAccount = FirefoxAccount(value, "20f7931c9054d833", "https://send.firefox.com/fxa/android-redirect.html")
8987
mAccount?.beginOAuthFlow(arrayOf("profile", "https://identity.mozilla.com/apps/send"), true)
9088
?.then { url ->
91-
Log.d(TAG_CONFIG, "GOT A URL " + url)
89+
Log.d(TAG_CONFIG, "GOT A URL $url")
9290
this@MainActivity.runOnUiThread {
9391
webView.loadUrl(url)
9492
}
@@ -106,8 +104,9 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
106104
putExtra(Intent.EXTRA_TEXT, url)
107105
}
108106

107+
val components = arrayOf(ComponentName(applicationContext, MainActivity::class.java))
109108
val chooser = Intent.createChooser(shareIntent, "")
110-
.putExtra(Intent.EXTRA_EXCLUDE_COMPONENTS, arrayOf(ComponentName(applicationContext, MainActivity::class.java)))
109+
.putExtra(Intent.EXTRA_EXCLUDE_COMPONENTS, components)
111110

112111
startActivity(chooser)
113112
}

0 commit comments

Comments
 (0)