Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-client-android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository 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
savoirfairelinux
jami-client-android
Commits
d68604d7
Commit
d68604d7
authored
5 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
AvatarDrawable: cleanup
Change-Id: Ia13f38a93c9a377ae06b2e1046aeeb56512990cb
parent
4890219b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ring-android/app/src/main/java/cx/ring/views/AvatarDrawable.java
+9
-15
9 additions, 15 deletions
...droid/app/src/main/java/cx/ring/views/AvatarDrawable.java
with
9 additions
and
15 deletions
ring-android/app/src/main/java/cx/ring/views/AvatarDrawable.java
+
9
−
15
View file @
d68604d7
...
@@ -288,7 +288,7 @@ public class AvatarDrawable extends Drawable {
...
@@ -288,7 +288,7 @@ public class AvatarDrawable extends Drawable {
@Override
@Override
protected
void
onBoundsChange
(
Rect
bounds
)
{
protected
void
onBoundsChange
(
Rect
bounds
)
{
setAvatarTextValues
();
if
(
showPresence
)
setupPresenceIndicator
(
bounds
);
setupPresenceIndicator
(
bounds
);
int
d
=
Math
.
min
(
bounds
.
width
(),
bounds
.
height
());
int
d
=
Math
.
min
(
bounds
.
width
(),
bounds
.
height
());
if
(
placeholder
!=
null
)
{
if
(
placeholder
!=
null
)
{
...
@@ -313,6 +313,8 @@ public class AvatarDrawable extends Drawable {
...
@@ -313,6 +313,8 @@ public class AvatarDrawable extends Drawable {
int
cx
=
(
iw
-
w
)/
2
;
int
cx
=
(
iw
-
w
)/
2
;
int
cy
=
(
ih
-
h
)/
2
;
int
cy
=
(
ih
-
h
)/
2
;
backgroundBounds
.
set
(
cx
,
cy
,
cx
+
w
,
h
+
cy
);
backgroundBounds
.
set
(
cx
,
cy
,
cx
+
w
,
h
+
cy
);
}
else
{
setAvatarTextValues
(
bounds
);
}
}
if
(
cropCircle
)
{
if
(
cropCircle
)
{
if
(
d
>
0
)
{
if
(
d
>
0
)
{
...
@@ -380,21 +382,13 @@ public class AvatarDrawable extends Drawable {
...
@@ -380,21 +382,13 @@ public class AvatarDrawable extends Drawable {
return
PixelFormat
.
TRANSLUCENT
;
return
PixelFormat
.
TRANSLUCENT
;
}
}
private
void
setAvatarTextValues
()
{
private
void
setAvatarTextValues
(
Rect
bounds
)
{
if
(
avatarText
!=
null
)
{
if
(
avatarText
!=
null
)
{
textPaint
.
setTextSize
(
getBounds
().
height
()
*
DEFAULT_TEXT_SIZE_PERCENTAGE
);
textPaint
.
setTextSize
(
bounds
.
height
()
*
DEFAULT_TEXT_SIZE_PERCENTAGE
);
textStartXPoint
=
calculateTextStartXPoint
();
textStartYPoint
=
calculateTextStartYPoint
();
}
}
private
float
calculateTextStartXPoint
()
{
float
stringWidth
=
textPaint
.
measureText
(
avatarText
);
float
stringWidth
=
textPaint
.
measureText
(
avatarText
);
return
(
getBounds
().
width
()
/
2
f
)
-
(
stringWidth
/
2
f
);
textStartXPoint
=
(
bounds
.
width
()
/
2
f
)
-
(
stringWidth
/
2
f
);
textStartYPoint
=
(
bounds
.
height
()
/
2
f
)
-
((
textPaint
.
ascent
()
+
textPaint
.
descent
())
/
2
f
);
}
}
private
float
calculateTextStartYPoint
()
{
return
(
getBounds
().
height
()
/
2
f
)
-
((
textPaint
.
ascent
()
+
textPaint
.
descent
())
/
2
f
);
}
}
private
String
convertNameToAvatarText
(
String
name
)
{
private
String
convertNameToAvatarText
(
String
name
)
{
...
...
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