Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
3d40cb71
Unverified
Commit
3d40cb71
authored
May 04, 2019
by
Hussein El Feky
Committed by
GitHub
May 04, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let drawables be set correctly in RTL languages
parent
5ceacaf2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
7 deletions
+24
-7
DrawableHelper.kt
app/src/main/java/chat/rocket/android/app/DrawableHelper.kt
+24
-7
No files found.
app/src/main/java/chat/rocket/android/app/DrawableHelper.kt
View file @
3d40cb71
import
android.content.Context
import
android.graphics.drawable.Drawable
import
android.view.View
import
android.widget.TextView
import
androidx.core.content.ContextCompat
import
androidx.core.graphics.drawable.DrawableCompat
...
...
@@ -60,7 +61,7 @@ object DrawableHelper {
/**
* Tints a Drawable.
*
* REMARK: you MUST always wrap the Drawable before tint it.
* REMARK: you MUST always wrap the Drawable before tint
ing
it.
*
* @param drawable The Drawable to tint.
* @param context The context.
...
...
@@ -74,7 +75,7 @@ object DrawableHelper {
/**
* Compounds an array of Drawable (to appear to the left of the text) into an array of TextView.
*
* REMARK: the number of elements in both array of Drawable and
EditText
MUST be equal.
* REMARK: the number of elements in both array of Drawable and
TextView
MUST be equal.
*
* @param textView The array of TextView.
* @param drawables The array of Drawable.
...
...
@@ -85,7 +86,11 @@ object DrawableHelper {
return
}
else
{
for
(
i
in
textView
.
indices
)
{
textView
[
i
].
setCompoundDrawablesWithIntrinsicBounds
(
drawables
[
i
],
null
,
null
,
null
)
if
(
textView
[
i
].
resources
.
configuration
.
layoutDirection
==
View
.
LAYOUT_DIRECTION_LTR
)
{
textView
[
i
].
setCompoundDrawablesWithIntrinsicBounds
(
drawables
[
i
],
null
,
null
,
null
)
}
else
{
textView
[
i
].
setCompoundDrawablesWithIntrinsicBounds
(
null
,
null
,
drawables
[
i
],
null
)
}
}
}
}
...
...
@@ -98,7 +103,11 @@ object DrawableHelper {
* @see compoundDrawables
*/
fun
compoundLeftDrawable
(
textView
:
TextView
,
drawable
:
Drawable
)
=
textView
.
setCompoundDrawablesWithIntrinsicBounds
(
drawable
,
null
,
null
,
null
)
if
(
textView
.
resources
.
configuration
.
layoutDirection
==
View
.
LAYOUT_DIRECTION_LTR
)
{
textView
.
setCompoundDrawablesWithIntrinsicBounds
(
drawable
,
null
,
null
,
null
)
}
else
{
textView
.
setCompoundDrawablesWithIntrinsicBounds
(
null
,
null
,
drawable
,
null
)
}
/**
* Compounds a Drawable (to appear on the right side of a text) into a TextView.
...
...
@@ -108,7 +117,11 @@ object DrawableHelper {
* @see compoundLeftDrawable
*/
fun
compoundRightDrawable
(
textView
:
TextView
,
drawable
:
Drawable
)
=
textView
.
setCompoundDrawablesWithIntrinsicBounds
(
null
,
null
,
drawable
,
null
)
if
(
textView
.
resources
.
configuration
.
layoutDirection
==
View
.
LAYOUT_DIRECTION_LTR
)
{
textView
.
setCompoundDrawablesWithIntrinsicBounds
(
null
,
null
,
drawable
,
null
)
}
else
{
textView
.
setCompoundDrawablesWithIntrinsicBounds
(
drawable
,
null
,
null
,
null
)
}
/**
* Compounds a Drawable (to appear on the left and right side of a text) into a TextView.
...
...
@@ -123,7 +136,11 @@ object DrawableHelper {
leftDrawable
:
Drawable
,
rightDrawable
:
Drawable
)
=
textView
.
setCompoundDrawablesWithIntrinsicBounds
(
leftDrawable
,
null
,
rightDrawable
,
null
)
if
(
textView
.
resources
.
configuration
.
layoutDirection
==
View
.
LAYOUT_DIRECTION_LTR
)
{
textView
.
setCompoundDrawablesWithIntrinsicBounds
(
leftDrawable
,
null
,
rightDrawable
,
null
)
}
else
{
textView
.
setCompoundDrawablesWithIntrinsicBounds
(
rightDrawable
,
null
,
leftDrawable
,
null
)
}
/**
* Returns the user status drawable.
...
...
@@ -141,4 +158,4 @@ object DrawableHelper {
else
->
getDrawableFromId
(
R
.
drawable
.
ic_status_invisible_12dp
,
context
)
}
}
}
\ No newline at end of file
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment