Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Android] make NavigationBar support Transluscent status #1116

Closed
wants to merge 1 commit into from

Conversation

bentmar
Copy link
Contributor

@bentmar bentmar commented Aug 29, 2017

If the app has flag Transluscentstatus then we should support that when creating the navbar. Now that we dont draw a statusbarunderlay anymore this opens up to many interesting UI possibilities

Description of Change

Adds a padding and adjusts the height of the Navigationbar if Transluscentstatus flag is set to true.

Bugs Fixed

  • none

API Changes

none

Changed:
The way we calculate the height for the navigationbar.
Adds padding to the navigationbar
Changes are only made if TransluscentStatus = true

Behavioral Changes

Now this is possible
https://forums.xamarin.com/discussion/comment/293844/#Comment_293844
by adding this is MainActivity

 Window.AddFlags(WindowManagerFlags.TranslucentStatus);

PR Checklist

  • Has tests (if omitted, state reason in description)
  • [X ] Rebased on top of master at time of PR
  • [ X] Changes adhere to coding standard
  • [ X] Consolidate commits as makes sense

If the app has flag Transluscentstatus then we should support that when creating the navbar. Now that we dont draw a statusbarunderlay anymore this opens up to many interesting UI possibilities
@adrianknight89
Copy link
Contributor

I think that if you are adding a padding, you need to account for how some pages (like MDP) are positioned during layout. Also, what happens if the user removes this Window flag through a DependencyService call? Will it get rid of the padding?

@bentmar
Copy link
Contributor Author

bentmar commented Aug 30, 2017

Thx for your input adrian!

you need to account for how some pages (like MDP) are positioned during layout.

https://forums.xamarin.com/discussion/comment/293695/#Comment_293695
this uses MDP, MDP has nothing to do with how a navigationpages navbar is layed out "?"

If you remove the Transluscent, it wouldn be transluscent anymore (thats all I can see) and the next time a navbar is layed out, it doesnt add padding.

This is what ive seen from testing on 5 different devices.

Note that if you use transluscent today your navbar and its content gets hidden under the statusbar = you cant even use it (well you can but...)

@adrianknight89
Copy link
Contributor

If you remove the Transluscent, it wouldn be transluscent anymore (thats all I can see) and the next time a navbar is layed out, it doesnt add padding.

I guess this is what I was getting at. To remove the padding, do you need to wait until the navbar is laid out next time or can you force it to layout once the translucent status is removed? I haven't tested these changes, so I'm only speculating. Maybe it's better to detect translucent changes and force navbar layout?

@bentmar
Copy link
Contributor Author

bentmar commented Aug 31, 2017

I see the transluscent status as a "either you have it, or you dont" I have never seen apps that toggles in and out of transluscent during runtime. And if a user were to toggle it on and off, then wouldnt it be possible to handle that forceLayout in a customrenderer?

Update: To remove the padding when removing transluscent would make it look wrong. The height doesnt change when your remove it. it changes the next layout, and in that same layout it doesnt add the padding = looks like it should

@jimmgarrido
Copy link
Contributor

This will need to be fixed in ContentPage and TabbedPage as well. MasterDetailPage should be fine once the other ones are fixed, but it'll have to be tested with the different combination of Detail/Master pages just to be sure.

I opened up a bug report with a repro project to track this.

@bentmar
Copy link
Contributor Author

bentmar commented Sep 4, 2017

one thing I haven't tested with this is TabbedPage with no navigation bar. If the tabbed page has no navbar then the tabbar needs to get the same adjustments as I give the navbar

UPDATE (Tested, and solved) : This is easily handled in a custom TabbedPageRenderer

  var tablayout = FindViewById<TabLayout>(Resource.Id.sliding_tabs);
  tablayout.SetPadding(0, GetStatusBarHeight(), 0, 0); //GetStatusBarHeight() is found in the changes

Id prefer this solution to anyone who has this specific layout instead of adding numerous checks in XF code to slow down android even more

@bentmar
Copy link
Contributor Author

bentmar commented Sep 4, 2017

@jimmgarrido

About your bug. TransluscentStatus behaviour is expected to layout content behind status bar if I'm not wrong here.

this is exactly what I'm trying to achieve :)
But we have to adjust the navbars layout to still make it look good.

Contentpages with no navbars are supposed to go under the statusbar, check the link https://us.v-cdn.net/5019960/uploads/editor/sc/o4mdus3r0wsv.gif (the gif is huge, so it might take a few seconds to load) too see what I mean

@kentcb
Copy link
Contributor

kentcb commented Nov 9, 2017

@davidortinau is this going to be merged anytime soon? It's blocking us from upgrading XF. See here.

@rmarinho
Copy link
Member

rmarinho commented Nov 9, 2017

@bentmar can you rebase to run some tests please ?

Also can you please post some screenshots so we can better understand the changes? thanks

@bentmar
Copy link
Contributor Author

bentmar commented Nov 16, 2017

@rmarinho yes, if not today il do it this weekend!

@bentmar
Copy link
Contributor Author

bentmar commented Nov 18, 2017

#1287 made a new PR that also covers TransluscentNavigation flag, and has some images. (im not a github pro hence a new pr)

@xamarin xamarin deleted a comment from dnfclas Dec 12, 2017
@rmarinho
Copy link
Member

Closing since #1287 replaces this

@rmarinho rmarinho closed this Dec 12, 2017
mattleibow pushed a commit that referenced this pull request Jan 28, 2021
…) (#1116)

* the compile-time check is not enough
* it crashed on old Android versions (<8.0)
mattleibow pushed a commit that referenced this pull request Jan 28, 2021
* Implement vertical accuracy in GeoLocation API (#1103)

* Location: add property 'VerticalAccuracy' (#1099)

* vertical accuracy is only available in Android API level 26 and above (#1099)

* update Samples app to show vertical accuracy on GeolocationPage

* add missing documentation bits for Location.VerticalAccuracy

* .gitattributes: get better diff context for C# code (#1115)

* Location.VerticalAccuracy: add runtime check for Android version (#1099) (#1116)

* the compile-time check is not enough
* it crashed on old Android versions (<8.0)

* GH-1102 Fix launcher on older devices (#1120)

* Update Launcher.ios.tvos.cs

* OpenUrlAsync was introduced in iOS 10 not 12

https://docs.microsoft.com/en-us/dotnet/api/uikit.uiapplication.openurlasync?view=xamarin-ios-sdk-12

* Fix trailing whitespace

* Really? fix whitespace

* Really! Fix whitespace

Co-authored-by: Janus Weil <janus@gcc.gnu.org>
Co-authored-by: James Montemagno <james.montemagno@gmail.com>
mattleibow pushed a commit that referenced this pull request Jan 28, 2021
* Implement vertical accuracy in GeoLocation API (#1103)

* Location: add property 'VerticalAccuracy' (#1099)

* vertical accuracy is only available in Android API level 26 and above (#1099)

* update Samples app to show vertical accuracy on GeolocationPage

* add missing documentation bits for Location.VerticalAccuracy

* .gitattributes: get better diff context for C# code (#1115)

* Location.VerticalAccuracy: add runtime check for Android version (#1099) (#1116)

* the compile-time check is not enough
* it crashed on old Android versions (<8.0)

* GH-1102 Fix launcher on older devices (#1120)

* Update Launcher.ios.tvos.cs

* OpenUrlAsync was introduced in iOS 10 not 12

https://docs.microsoft.com/en-us/dotnet/api/uikit.uiapplication.openurlasync?view=xamarin-ios-sdk-12

* Fix trailing whitespace

* Really? fix whitespace

* Really! Fix whitespace

* Fixes #1129 - set empty required declarations on UWP (#1133)

* Fixes #1129 - set empty required declarations on UWP

* Update Permissions.uwp.cs

* Update Xamarin.Essentials.csproj (#1136)

* GH-1142 AccessBackgroundLocation only when compile & running Q (#1143)

* AccessBackgroundLocation only when compile & running Q

* put if compile check around permission

* GH-1121 If VC is null use TraitCollection (#1144)

* Fixes #1123 (#1126)

* Update PlacemarkExtensions.xml (#1132)

Co-authored-by: Janus Weil <janus@gcc.gnu.org>
Co-authored-by: James Montemagno <james.montemagno@gmail.com>
Co-authored-by: Michael <Michael@ZPF.fr>
mattleibow pushed a commit that referenced this pull request Jan 28, 2021
* Implement vertical accuracy in GeoLocation API (#1103)

* Location: add property 'VerticalAccuracy' (#1099)

* vertical accuracy is only available in Android API level 26 and above (#1099)

* update Samples app to show vertical accuracy on GeolocationPage

* add missing documentation bits for Location.VerticalAccuracy

* .gitattributes: get better diff context for C# code (#1115)

* Location.VerticalAccuracy: add runtime check for Android version (#1099) (#1116)

* the compile-time check is not enough
* it crashed on old Android versions (<8.0)

* GH-1102 Fix launcher on older devices (#1120)

* Update Launcher.ios.tvos.cs

* OpenUrlAsync was introduced in iOS 10 not 12

https://docs.microsoft.com/en-us/dotnet/api/uikit.uiapplication.openurlasync?view=xamarin-ios-sdk-12

* Fix trailing whitespace

* Really? fix whitespace

* Really! Fix whitespace

* Fixes #1129 - set empty required declarations on UWP (#1133)

* Fixes #1129 - set empty required declarations on UWP

* Update Permissions.uwp.cs

* Update Xamarin.Essentials.csproj (#1136)

* GH-1142 AccessBackgroundLocation only when compile & running Q (#1143)

* AccessBackgroundLocation only when compile & running Q

* put if compile check around permission

* GH-1121 If VC is null use TraitCollection (#1144)

* Fixes #1123 (#1126)

* Update PlacemarkExtensions.xml (#1132)

Co-authored-by: Janus Weil <janus@gcc.gnu.org>
Co-authored-by: James Montemagno <james.montemagno@gmail.com>
Co-authored-by: Michael <Michael@ZPF.fr>

Co-authored-by: Jonathan Dick <jodick@microsoft.com>
Co-authored-by: Janus Weil <janus@gcc.gnu.org>
Co-authored-by: Michael <Michael@ZPF.fr>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants