Skip to content

Commit

Permalink
Replace extractBundle with bundleOf
Browse files Browse the repository at this point in the history
  • Loading branch information
droibit committed Jan 11, 2025
1 parent 423cff5 commit 85bd810
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import com.github.droibit.flutter.plugins.customtabs.core.options.CustomTabsColo
import com.github.droibit.flutter.plugins.customtabs.core.options.CustomTabsIntentOptions
import com.github.droibit.flutter.plugins.customtabs.core.options.PartialCustomTabsConfiguration
import com.github.droibit.flutter.plugins.customtabs.core.session.CustomTabsSessionProvider
import com.github.droibit.flutter.plugins.customtabs.core.utils.extractBundle
import com.github.droibit.flutter.plugins.customtabs.core.utils.bundleOf

class CustomTabsIntentFactory @VisibleForTesting internal constructor(
private val resources: ResourceFactory
Expand Down Expand Up @@ -130,7 +130,7 @@ class CustomTabsIntentFactory @VisibleForTesting internal constructor(
options: BrowserConfiguration
) {
val rawIntent = customTabsIntent.intent
options.headers?.let { rawIntent.putExtra(EXTRA_HEADERS, extractBundle(it)) }
options.headers?.let { rawIntent.putExtra(EXTRA_HEADERS, bundleOf(it)) }

// Avoid overriding the package if using CustomTabsSession.
if (rawIntent.getPackage() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import android.net.Uri
import android.provider.Browser.EXTRA_HEADERS
import androidx.annotation.VisibleForTesting
import com.github.droibit.flutter.plugins.customtabs.core.options.CustomTabsIntentOptions
import com.github.droibit.flutter.plugins.customtabs.core.utils.extractBundle
import com.github.droibit.flutter.plugins.customtabs.core.utils.bundleOf

class ExternalBrowserLauncher {
fun launch(context: Context, uri: Uri, options: CustomTabsIntentOptions?): Boolean {
Expand All @@ -26,7 +26,7 @@ class ExternalBrowserLauncher {
val browserOptions = options.browser ?: return null
val prefersExternalBrowser = browserOptions.prefersExternalBrowser
if (prefersExternalBrowser == true) {
browserOptions.headers?.let { intent.putExtra(EXTRA_HEADERS, extractBundle(it)) }
browserOptions.headers?.let { intent.putExtra(EXTRA_HEADERS, bundleOf(it)) }
return intent
}
return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import android.os.Bundle

internal const val TAG = "CustomTabsAndroid"

internal fun extractBundle(headers: Map<String, String>): Bundle {
internal fun bundleOf(headers: Map<String, String>): Bundle {
return Bundle(headers.size).apply {
for ((key, value) in headers) {
putString(key, value)
Expand Down

0 comments on commit 85bd810

Please sign in to comment.