Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_frameworks_base-old
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Farzin Kazemzadeh
platform_frameworks_base-old
Commits
5da4d675
Commit
5da4d675
authored
1 year ago
by
Mykola Podolian
Committed by
Android (Google) Code Review
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge "Fixed issue with dark/light mode theme updates" into main
parents
21ea05d3
6024d45d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleFlyoutView.java
+52
-10
52 additions, 10 deletions
...ll/src/com/android/wm/shell/bubbles/BubbleFlyoutView.java
with
52 additions
and
10 deletions
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleFlyoutView.java
+
52
−
10
View file @
5da4d675
...
...
@@ -24,6 +24,7 @@ import static com.android.wm.shell.animation.Interpolators.ALPHA_OUT;
import
android.animation.ArgbEvaluator
;
import
android.content.Context
;
import
android.content.res.Configuration
;
import
android.content.res.Resources
;
import
android.content.res.TypedArray
;
import
android.graphics.Canvas
;
...
...
@@ -74,7 +75,7 @@ public class BubbleFlyoutView extends FrameLayout {
private
final
int
mFlyoutElevation
;
private
final
int
mBubbleElevation
;
private
final
int
mFloatingBackgroundColor
;
private
int
mFloatingBackgroundColor
;
private
final
float
mCornerRadius
;
private
final
ViewGroup
mFlyoutTextContainer
;
...
...
@@ -107,6 +108,9 @@ public class BubbleFlyoutView extends FrameLayout {
/** Color of the 'new' dot that the flyout will transform into. */
private
int
mDotColor
;
/** Keeps last used night mode flags **/
private
int
mNightModeFlags
;
/** The outline of the triangle, used for elevation shadows. */
private
final
Outline
mTriangleOutline
=
new
Outline
();
...
...
@@ -176,11 +180,8 @@ public class BubbleFlyoutView extends FrameLayout {
mFlyoutElevation
=
res
.
getDimensionPixelSize
(
R
.
dimen
.
bubble_flyout_elevation
);
final
TypedArray
ta
=
mContext
.
obtainStyledAttributes
(
new
int
[]
{
com
.
android
.
internal
.
R
.
attr
.
materialColorSurfaceContainer
,
android
.
R
.
attr
.
dialogCornerRadius
});
mFloatingBackgroundColor
=
ta
.
getColor
(
0
,
Color
.
WHITE
);
mCornerRadius
=
ta
.
getDimensionPixelSize
(
1
,
0
);
new
int
[]
{
android
.
R
.
attr
.
dialogCornerRadius
});
mCornerRadius
=
ta
.
getDimensionPixelSize
(
0
,
0
);
ta
.
recycle
();
// Add padding for the pointer on either side, onDraw will draw it in this space.
...
...
@@ -198,19 +199,17 @@ public class BubbleFlyoutView extends FrameLayout {
// Use locale direction so the text is aligned correctly.
setLayoutDirection
(
LAYOUT_DIRECTION_LOCALE
);
mBgPaint
.
setColor
(
mFloatingBackgroundColor
);
mLeftTriangleShape
=
new
ShapeDrawable
(
TriangleShape
.
createHorizontal
(
mPointerSize
,
mPointerSize
,
true
/* isPointingLeft */
));
mLeftTriangleShape
.
setBounds
(
0
,
0
,
mPointerSize
,
mPointerSize
);
mLeftTriangleShape
.
getPaint
().
setColor
(
mFloatingBackgroundColor
);
mRightTriangleShape
=
new
ShapeDrawable
(
TriangleShape
.
createHorizontal
(
mPointerSize
,
mPointerSize
,
false
/* isPointingLeft */
));
mRightTriangleShape
.
setBounds
(
0
,
0
,
mPointerSize
,
mPointerSize
);
mRightTriangleShape
.
getPaint
().
setColor
(
mFloatingBackgroundColor
);
applyConfigurationColors
(
getResources
().
getConfiguration
());
}
@Override
...
...
@@ -244,6 +243,13 @@ public class BubbleFlyoutView extends FrameLayout {
fade
(
false
/* in */
,
stackPos
,
hideDot
,
afterFadeOut
);
}
@Override
protected
void
onConfigurationChanged
(
Configuration
newConfig
)
{
if
(
applyColorsAccordingToConfiguration
(
newConfig
))
{
invalidate
();
}
}
/*
* Fade-out above or fade-in from below.
*/
...
...
@@ -423,6 +429,42 @@ public class BubbleFlyoutView extends FrameLayout {
return
Math
.
min
(
1
f
,
Math
.
max
(
0
f
,
percent
));
}
/**
* Resolving and applying colors according to the ui mode, remembering most recent mode.
*
* @return {@code true} if night mode setting has changed since the last invocation,
* {@code false} otherwise
*/
boolean
applyColorsAccordingToConfiguration
(
Configuration
configuration
)
{
int
nightModeFlags
=
configuration
.
uiMode
&
Configuration
.
UI_MODE_NIGHT_MASK
;
boolean
flagsChanged
=
nightModeFlags
!=
mNightModeFlags
;
if
(
flagsChanged
)
{
mNightModeFlags
=
nightModeFlags
;
applyConfigurationColors
(
configuration
);
}
return
flagsChanged
;
}
private
void
applyConfigurationColors
(
Configuration
configuration
)
{
int
nightModeFlags
=
configuration
.
uiMode
&
Configuration
.
UI_MODE_NIGHT_MASK
;
boolean
isNightModeOn
=
nightModeFlags
==
Configuration
.
UI_MODE_NIGHT_YES
;
try
(
TypedArray
ta
=
mContext
.
obtainStyledAttributes
(
new
int
[]{
com
.
android
.
internal
.
R
.
attr
.
materialColorSurfaceContainer
,
com
.
android
.
internal
.
R
.
attr
.
materialColorOnSurface
,
com
.
android
.
internal
.
R
.
attr
.
materialColorOnSurfaceVariant
}))
{
mFloatingBackgroundColor
=
ta
.
getColor
(
0
,
isNightModeOn
?
Color
.
BLACK
:
Color
.
WHITE
);
mSenderText
.
setTextColor
(
ta
.
getColor
(
1
,
isNightModeOn
?
Color
.
WHITE
:
Color
.
BLACK
));
mMessageText
.
setTextColor
(
ta
.
getColor
(
2
,
isNightModeOn
?
Color
.
WHITE
:
Color
.
BLACK
));
mBgPaint
.
setColor
(
mFloatingBackgroundColor
);
mLeftTriangleShape
.
getPaint
().
setColor
(
mFloatingBackgroundColor
);
mRightTriangleShape
.
getPaint
().
setColor
(
mFloatingBackgroundColor
);
}
}
/**
* Renders the background, which is either the rounded 'chat bubble' flyout, or some state
* between that and the 'new' dot over the bubbles.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment