Skip to content

Commit d250b88

Browse files
committed
Add Accept-Language to extra header when opening CustomChromeTab
Follow good practice from https://developer.android.com/guide/topics/resources/app-languages#consider-header
1 parent 66ca329 commit d250b88

File tree

1 file changed

+6
-0
lines changed
  • libraries/androidutils/src/main/kotlin/io/element/android/libraries/androidutils/browser

1 file changed

+6
-0
lines changed

libraries/androidutils/src/main/kotlin/io/element/android/libraries/androidutils/browser/ChromeCustomTab.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ package io.element.android.libraries.androidutils.browser
1010
import android.app.Activity
1111
import android.content.ActivityNotFoundException
1212
import android.net.Uri
13+
import android.os.Bundle
14+
import android.provider.Browser
1315
import androidx.browser.customtabs.CustomTabColorSchemeParams
1416
import androidx.browser.customtabs.CustomTabsIntent
1517
import androidx.browser.customtabs.CustomTabsSession
1618
import io.element.android.libraries.androidutils.system.openUrlInExternalApp
19+
import java.util.Locale
1720

1821
/**
1922
* Open url in custom tab or, if not available, in the default browser.
@@ -51,6 +54,9 @@ fun Activity.openUrlInChromeCustomTab(
5154
intent.putExtra("org.chromium.chrome.browser.customtabs.EXTRA_DISABLE_DOWNLOAD_BUTTON", true)
5255
// Disable bookmark button
5356
intent.putExtra("org.chromium.chrome.browser.customtabs.EXTRA_DISABLE_START_BUTTON", true)
57+
intent.putExtra(Browser.EXTRA_HEADERS, Bundle().apply {
58+
putString("Accept-Language", Locale.getDefault().toLanguageTag())
59+
})
5460
}
5561
.launchUrl(this, Uri.parse(url))
5662
} catch (activityNotFoundException: ActivityNotFoundException) {

0 commit comments

Comments
 (0)