Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
briar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Julian Dehm
briar
Commits
37281c6c
Unverified
Commit
37281c6c
authored
8 years ago
by
akwizgran
Browse files
Options
Downloads
Patches
Plain Diff
Remove ellipsizing support from EmojiTextView.
This is a workaround for a layout bug.
parent
6de539a6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
briar-android/src/main/java/org/thoughtcrime/securesms/components/emoji/EmojiTextView.java
+5
-51
5 additions, 51 deletions
...houghtcrime/securesms/components/emoji/EmojiTextView.java
with
5 additions
and
51 deletions
briar-android/src/main/java/org/thoughtcrime/securesms/components/emoji/EmojiTextView.java
+
5
−
51
View file @
37281c6c
package
org.thoughtcrime.securesms.components.emoji
;
package
org.thoughtcrime.securesms.components.emoji
;
import
android.content.Context
;
import
android.content.Context
;
import
android.graphics.Paint.FontMetricsInt
;
import
android.graphics.drawable.Drawable
;
import
android.graphics.drawable.Drawable
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.UiThread
;
import
android.support.annotation.UiThread
;
import
android.
text.TextUtils
;
import
android.
support.v7.widget.AppCompatTextView
;
import
android.util.AttributeSet
;
import
android.util.AttributeSet
;
import
android.view.ViewConfiguration
;
import
android.view.ViewConfiguration
;
import
android.widget.TextView
;
import
org.thoughtcrime.securesms.components.emoji.EmojiProvider.EmojiDrawable
;
import
org.thoughtcrime.securesms.components.emoji.EmojiProvider.EmojiDrawable
;
import
javax.annotation.Nullable
;
import
javax.annotation.Nullable
;
import
static
android
.
text
.
TextUtils
.
TruncateAt
.
END
;
import
static
android
.
view
.
View
.
MeasureSpec
.
AT_MOST
;
import
static
android
.
view
.
View
.
MeasureSpec
.
EXACTLY
;
import
static
android
.
widget
.
TextView
.
BufferType
.
SPANNABLE
;
import
static
android
.
widget
.
TextView
.
BufferType
.
SPANNABLE
;
@UiThread
@UiThread
public
class
EmojiTextView
extends
TextView
{
public
class
EmojiTextView
extends
AppCompatTextView
{
private
CharSequence
source
;
private
boolean
needsEllipsizing
;
public
EmojiTextView
(
Context
context
)
{
public
EmojiTextView
(
Context
context
)
{
this
(
context
,
null
);
this
(
context
,
null
);
...
@@ -42,13 +34,9 @@ public class EmojiTextView extends TextView {
...
@@ -42,13 +34,9 @@ public class EmojiTextView extends TextView {
@Override
@Override
public
void
setText
(
@Nullable
CharSequence
text
,
BufferType
type
)
{
public
void
setText
(
@Nullable
CharSequence
text
,
BufferType
type
)
{
source
=
EmojiProvider
.
getInstance
(
getContext
()).
emojify
(
text
,
this
);
CharSequence
source
=
EmojiProvider
.
getInstance
(
getContext
()).
emojify
(
text
,
this
);
setTextEllipsized
(
source
);
super
.
setText
(
source
,
SPANNABLE
);
}
private
void
setTextEllipsized
(
final
@Nullable
CharSequence
source
)
{
super
.
setText
(
needsEllipsizing
?
ellipsize
(
source
)
:
source
,
SPANNABLE
);
}
}
@Override
@Override
...
@@ -57,26 +45,6 @@ public class EmojiTextView extends TextView {
...
@@ -57,26 +45,6 @@ public class EmojiTextView extends TextView {
else
super
.
invalidateDrawable
(
drawable
);
else
super
.
invalidateDrawable
(
drawable
);
}
}
@Override
protected
void
onMeasure
(
int
widthMeasureSpec
,
int
heightMeasureSpec
)
{
final
int
size
=
MeasureSpec
.
getSize
(
widthMeasureSpec
);
final
int
mode
=
MeasureSpec
.
getMode
(
widthMeasureSpec
);
if
(
getEllipsize
()
==
END
&&
!
TextUtils
.
isEmpty
(
source
)
&&
(
mode
==
AT_MOST
||
mode
==
EXACTLY
)
&&
getPaint
().
breakText
(
source
,
0
,
source
.
length
()
-
1
,
true
,
size
,
null
)
!=
source
.
length
())
{
needsEllipsizing
=
true
;
FontMetricsInt
font
=
getPaint
().
getFontMetricsInt
();
int
height
=
Math
.
abs
(
font
.
top
-
font
.
bottom
);
super
.
onMeasure
(
MeasureSpec
.
makeMeasureSpec
(
size
,
EXACTLY
),
MeasureSpec
.
makeMeasureSpec
(
height
,
EXACTLY
));
}
else
{
needsEllipsizing
=
false
;
super
.
onMeasure
(
widthMeasureSpec
,
heightMeasureSpec
);
}
}
@Override
@Override
protected
void
onLayout
(
boolean
changed
,
int
left
,
int
top
,
int
right
,
protected
void
onLayout
(
boolean
changed
,
int
left
,
int
top
,
int
right
,
int
bottom
)
{
int
bottom
)
{
...
@@ -89,20 +57,6 @@ public class EmojiTextView extends TextView {
...
@@ -89,20 +57,6 @@ public class EmojiTextView extends TextView {
if
(
size
>
drawingCacheSize
)
{
if
(
size
>
drawingCacheSize
)
{
setLayerType
(
LAYER_TYPE_NONE
,
null
);
setLayerType
(
LAYER_TYPE_NONE
,
null
);
}
}
if
(
changed
)
setTextEllipsized
(
source
);
super
.
onLayout
(
changed
,
left
,
top
,
right
,
bottom
);
super
.
onLayout
(
changed
,
left
,
top
,
right
,
bottom
);
}
}
@Nullable
public
CharSequence
ellipsize
(
@Nullable
CharSequence
text
)
{
if
(
TextUtils
.
isEmpty
(
text
)
||
getWidth
()
==
0
||
getEllipsize
()
!=
END
)
{
return
text
;
}
else
{
return
TextUtils
.
ellipsize
(
text
,
getPaint
(),
getWidth
()
-
getPaddingRight
()
-
getPaddingLeft
(),
END
);
}
}
}
}
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