GoogleChrome / android-browser-helper

The Android Browser Helper library helps developers use Custom Tabs and Trusted Web Activities on top of the AndroidX browser support library.
Apache License 2.0
694 stars 288 forks source link

[BUG] Custom Tab height doesn't change #442

Open JuancaG05 opened 1 year ago

JuancaG05 commented 1 year ago

Describe the bug Related with this issue: https://github.com/GoogleChrome/android-browser-helper/issues/441. After realising that I need to send as parameter a session or open the Custom tab via startActivityForResult to be able to have it in a bottom sheet (as it says in the docs, thanks @sebastianbenz), I could make it by using registerForActivityResult (which substitutes startActivityForResult, it's deprecated). Now that I have my Custom tab in a bottom sheet, I would like to customize its height, but I'm not able to, it always stays at the 50% of the screen height whatever number I pass as parameter to the setInitialActivityHeight method. I tried modifying the number in PartialCustomTabActivity.java in the custom-tabs-example-app in this same repo, and the bug seems to be there too, the bottom sheet is always 50% of the screen. I also tried in several different devices.

To Reproduce Steps to reproduce the behavior:

  1. Construct a new CustomTabsIntent.Builder indicating the desired height with setInitialActivityHeightPx().
  2. Get the CustomTabsIntent from the builder and set the desired Uri as intent.data.
  3. Launch the intent via a launcher created via registerForActivityResult.
  4. Custom tab is launched in a resizable bottom sheet but always with the same height (50% of the screen), no matter which valid number I pass in step 1.

Expected behavior The Custom tab appears in a bottom sheet with the specified height.

Did this ever used to work I couldn't make it work, neither in my project nor in the custom-tabs-example-app project of this repo.

Screenshots No need screenshots here.

Code Snippets

private val customTabsLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
    // ...
}

val customTabsBuilder = CustomTabsIntent.Builder().setInitialActivityHeightPx(500)
val customTabsIntent = customTabsBuilder.build()
customTabsIntent.intent.data = Uri.parse("www.example.com")
customTabsLauncher.launch(customTabsIntent.intent)

Smartphone (please complete the following information):

and

JuancaG05 commented 1 year ago

Any news here? 👆

DmitriyZakharich commented 4 months ago

Hi. Have you found a solution?

JuancaG05 commented 4 months ago

Hi @DmitriyZakharich!

Nope, this was ignored since it was opened...