-
Notifications
You must be signed in to change notification settings - Fork 335
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7b902d4
Add edge-to-edge support for the splash screen
orbital17 c924c35
Add comments, deprecate Utils methods and minor fixes
orbital17 d9a2833
Fix whitespaces
orbital17 e704a66
Use ProtectionLayout for drawing system bars background
orbital17 e2051d1
Remove black system bars drawn by DecorView
orbital17 07ece09
Add ImageView as a child to ProtectionLayout
orbital17 b0761e0
Change EdgeToEdgeController to init everything in constructor
orbital17 79c434d
Rename setOriginalView to addView
orbital17 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...main/java/com/google/androidbrowserhelper/trusted/splashscreens/EdgeToEdgeController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package com.google.androidbrowserhelper.trusted.splashscreens; | ||
|
|
||
| import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; | ||
|
|
||
| import android.app.Activity; | ||
| import android.view.View; | ||
| import android.view.ViewGroup; | ||
| import android.widget.FrameLayout; | ||
|
|
||
| import androidx.annotation.ColorInt; | ||
| 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
|
||
|
|
||
| /** | ||
| * A helper class to control the color of system bars in edge-to-edge mode. | ||
| * It sets up a {@link ProtectionLayout} which manages the drawables behind | ||
| * the status and navigation bars. | ||
| */ | ||
| public class EdgeToEdgeController { | ||
gstepniewski-google marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private FrameLayout mRootView; | ||
| private ProtectionLayout mProtectionLayout; | ||
| private ColorProtection mStatusBarProtection; | ||
| private ColorProtection mNavigationBarProtection; | ||
|
|
||
| public EdgeToEdgeController(Activity activity, @ColorInt int defaultColor) { | ||
| mStatusBarProtection = new ColorProtection(WindowInsetsCompat.Side.TOP, defaultColor); | ||
| mNavigationBarProtection = new ColorProtection(WindowInsetsCompat.Side.BOTTOM, defaultColor); | ||
|
|
||
| mRootView = new FrameLayout(activity); | ||
| mRootView.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)); | ||
|
|
||
| mProtectionLayout = new ProtectionLayout(activity, | ||
| ImmutableList.of(mStatusBarProtection, mNavigationBarProtection)); | ||
| mRootView.addView(mProtectionLayout); | ||
| mProtectionLayout.setVisibility(View.VISIBLE); | ||
| } | ||
|
|
||
| public FrameLayout getWrapperView() { | ||
| return mRootView; | ||
| } | ||
|
|
||
| public void setOriginalView(View originalView) { | ||
gstepniewski-google marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| mProtectionLayout.addView(originalView); | ||
| } | ||
|
|
||
| public void setStatusBarColor(@ColorInt int color) { | ||
| mStatusBarProtection.setColor(color); | ||
gstepniewski-google marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| public void setNavigationBarColor(@ColorInt int color) { | ||
| mNavigationBarProtection.setColor(color); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.