-
Notifications
You must be signed in to change notification settings - Fork 338
Add edge-to-edge support for the splash screen #558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
7b902d4
c924c35
d9a2833
e704a66
e2051d1
07ece09
b0761e0
79c434d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package com.google.androidbrowserhelper.trusted.splashscreens; | ||
|
|
||
| import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; | ||
|
|
||
| import android.app.Activity; | ||
| import android.graphics.Color; | ||
| import android.view.View; | ||
| import android.view.ViewGroup; | ||
| import android.widget.FrameLayout; | ||
|
|
||
| import androidx.annotation.ColorInt; | ||
| import androidx.core.view.ViewCompat; | ||
| import androidx.core.view.WindowInsetsCompat; | ||
| import androidx.core.view.insets.ColorProtection; | ||
| import androidx.core.view.insets.ProtectionLayout; | ||
|
|
||
| import com.google.common.collect.ImmutableList; | ||
gstepniewski-google marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| public class EdgeToEdgeController { | ||
gstepniewski-google marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private Activity mActivity; | ||
| private ColorProtection statusBarProtection; | ||
| private ColorProtection navigationBarProtection; | ||
|
|
||
| public EdgeToEdgeController(Activity activity, @ColorInt int defaultColor) { | ||
| mActivity = activity; | ||
| statusBarProtection = new ColorProtection(WindowInsetsCompat.Side.TOP, defaultColor); | ||
| navigationBarProtection = new ColorProtection(WindowInsetsCompat.Side.BOTTOM, defaultColor); | ||
| } | ||
|
|
||
| public FrameLayout getWrapperView() { | ||
| FrameLayout rootView = new FrameLayout(mActivity); | ||
ukaratkevich marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| rootView.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)); | ||
|
|
||
| ProtectionLayout protectionLayout = new ProtectionLayout(mActivity, | ||
| ImmutableList.of(statusBarProtection, navigationBarProtection)); | ||
| rootView.addView(protectionLayout); | ||
| protectionLayout.setVisibility(View.VISIBLE); | ||
| protectionLayout.setElevation(1f); | ||
|
||
| return rootView; | ||
| } | ||
|
|
||
| public void setStatusBarColor(@ColorInt int color) { | ||
| statusBarProtection.setColor(color); | ||
| } | ||
|
|
||
| public void setNavigationBarColor(@ColorInt int color) { | ||
| navigationBarProtection.setColor(color); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to move this to splash coordinator, otherwise we have a chance of getting obscured status bar icons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed offline, status bar icons are not getting obscured
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With a fresh look, let's move it to the splash controller and apply when we definitely set a color to system bars.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case the bug that we have now with the behavior without the splash screen will not be fixed.
Right now the transparent activity without splash screen shows black system bars, instead of being transparent. Setting this flag fixes it.