Commit ad802c4d authored by Hussein El Feky's avatar Hussein El Feky

Renamed DrawableHelper methods

parent 3d40cb71
...@@ -73,13 +73,13 @@ object DrawableHelper { ...@@ -73,13 +73,13 @@ object DrawableHelper {
DrawableCompat.setTint(drawable, ContextCompat.getColor(context, resId)) DrawableCompat.setTint(drawable, ContextCompat.getColor(context, resId))
/** /**
* Compounds an array of Drawable (to appear to the left of the text) into an array of TextView. * Compounds an array of Drawable (to appear on the start side of a text) into an array of TextView.
* *
* REMARK: the number of elements in both array of Drawable and TextView MUST be equal. * REMARK: the number of elements in both arrays of Drawable and TextView MUST be equal.
* *
* @param textView The array of TextView. * @param textView The array of TextView.
* @param drawables The array of Drawable. * @param drawables The array of Drawable.
* @see compoundLeftDrawable * @see compoundStartDrawable
*/ */
fun compoundDrawables(textView: Array<TextView>, drawables: Array<Drawable>) { fun compoundDrawables(textView: Array<TextView>, drawables: Array<Drawable>) {
if (textView.size != drawables.size) { if (textView.size != drawables.size) {
...@@ -96,13 +96,13 @@ object DrawableHelper { ...@@ -96,13 +96,13 @@ object DrawableHelper {
} }
/** /**
* Compounds a Drawable (to appear on the left side of a text) into a TextView. * Compounds a Drawable (to appear on the start side of a text) into a TextView.
* *
* @param textView The TextView. * @param textView The TextView.
* @param drawable The Drawable. * @param drawable The Drawable.
* @see compoundDrawables * @see compoundDrawables
*/ */
fun compoundLeftDrawable(textView: TextView, drawable: Drawable) = fun compoundStartDrawable(textView: TextView, drawable: Drawable) =
if (textView.resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_LTR) { if (textView.resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_LTR) {
textView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null) textView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null)
} else { } else {
...@@ -110,13 +110,13 @@ object DrawableHelper { ...@@ -110,13 +110,13 @@ object DrawableHelper {
} }
/** /**
* Compounds a Drawable (to appear on the right side of a text) into a TextView. * Compounds a Drawable (to appear on the end side of a text) into a TextView.
* *
* @param textView The TextView. * @param textView The TextView.
* @param drawable The Drawable. * @param drawable The Drawable.
* @see compoundLeftDrawable * @see compoundStartDrawable
*/ */
fun compoundRightDrawable(textView: TextView, drawable: Drawable) = fun compoundEndDrawable(textView: TextView, drawable: Drawable) =
if (textView.resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_LTR) { if (textView.resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_LTR) {
textView.setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null) textView.setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null)
} else { } else {
...@@ -124,22 +124,22 @@ object DrawableHelper { ...@@ -124,22 +124,22 @@ object DrawableHelper {
} }
/** /**
* Compounds a Drawable (to appear on the left and right side of a text) into a TextView. * Compounds a Drawable (to appear on the start and end side of a text) into a TextView.
* *
* @param textView The TextView. * @param textView The TextView.
* @param leftDrawable The left Drawable. * @param startDrawable The start Drawable.
* @param rightDrawable The right Drawable. * @param endDrawable The end Drawable.
* @see compoundLeftDrawable * @see compoundStartDrawable
*/ */
fun compoundLeftAndRightDrawable( fun compoundStartAndEndDrawable(
textView: TextView, textView: TextView,
leftDrawable: Drawable, startDrawable: Drawable,
rightDrawable: Drawable endDrawable: Drawable
) = ) =
if (textView.resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_LTR) { if (textView.resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_LTR) {
textView.setCompoundDrawablesWithIntrinsicBounds(leftDrawable, null, rightDrawable, null) textView.setCompoundDrawablesWithIntrinsicBounds(startDrawable, null, endDrawable, null)
} else { } else {
textView.setCompoundDrawablesWithIntrinsicBounds(rightDrawable, null, leftDrawable, null) textView.setCompoundDrawablesWithIntrinsicBounds(endDrawable, null, startDrawable, null)
} }
/** /**
......
...@@ -140,7 +140,7 @@ class RegisterUsernameFragment : Fragment(), RegisterUsernameView { ...@@ -140,7 +140,7 @@ class RegisterUsernameFragment : Fragment(), RegisterUsernameView {
val atDrawable = DrawableHelper.getDrawableFromId(R.drawable.ic_at_black_20dp, it) val atDrawable = DrawableHelper.getDrawableFromId(R.drawable.ic_at_black_20dp, it)
DrawableHelper.wrapDrawable(atDrawable) DrawableHelper.wrapDrawable(atDrawable)
DrawableHelper.tintDrawable(atDrawable, it, R.color.colorDrawableTintGrey) DrawableHelper.tintDrawable(atDrawable, it, R.color.colorDrawableTintGrey)
DrawableHelper.compoundLeftDrawable(text_username, atDrawable) DrawableHelper.compoundStartDrawable(text_username, atDrawable)
} }
} }
......
...@@ -195,7 +195,7 @@ class ChatDetailsFragment : Fragment(), ChatDetailsView { ...@@ -195,7 +195,7 @@ class ChatDetailsFragment : Fragment(), ChatDetailsView {
val wrappedDrawable = DrawableHelper.wrapDrawable(it) val wrappedDrawable = DrawableHelper.wrapDrawable(it)
val mutableDrawable = wrappedDrawable.mutate() val mutableDrawable = wrappedDrawable.mutate()
DrawableHelper.tintDrawable(mutableDrawable, context!!, R.color.colorPrimary) DrawableHelper.tintDrawable(mutableDrawable, context!!, R.color.colorPrimary)
DrawableHelper.compoundLeftDrawable(name, mutableDrawable) DrawableHelper.compoundStartDrawable(name, mutableDrawable)
} }
} }
......
...@@ -139,7 +139,7 @@ class ChatRoomActivity : AppCompatActivity(), HasSupportFragmentInjector { ...@@ -139,7 +139,7 @@ class ChatRoomActivity : AppCompatActivity(), HasSupportFragmentInjector {
} }
fun setupExpandMoreForToolbar(listener: (View) -> Unit) { fun setupExpandMoreForToolbar(listener: (View) -> Unit) {
DrawableHelper.compoundRightDrawable( DrawableHelper.compoundEndDrawable(
text_toolbar_title, text_toolbar_title,
DrawableHelper.getDrawableFromId(R.drawable.ic_chatroom_toolbar_expand_more_20dp, this) DrawableHelper.getDrawableFromId(R.drawable.ic_chatroom_toolbar_expand_more_20dp, this)
) )
......
...@@ -233,14 +233,14 @@ class DirectoryFragment : Fragment(), DirectoryView { ...@@ -233,14 +233,14 @@ class DirectoryFragment : Fragment(), DirectoryView {
private fun updateSortByTitle() { private fun updateSortByTitle() {
if (isSortByChannels) { if (isSortByChannels) {
text_sort_by.text = getString(R.string.msg_channels) text_sort_by.text = getString(R.string.msg_channels)
DrawableHelper.compoundLeftAndRightDrawable( DrawableHelper.compoundStartAndEndDrawable(
text_sort_by, text_sort_by,
hashtagDrawable, hashtagDrawable,
arrowDownDrawable arrowDownDrawable
) )
} else { } else {
text_sort_by.text = getString(R.string.msg_users) text_sort_by.text = getString(R.string.msg_users)
DrawableHelper.compoundLeftAndRightDrawable( DrawableHelper.compoundStartAndEndDrawable(
text_sort_by, text_sort_by,
userDrawable, userDrawable,
arrowDownDrawable arrowDownDrawable
......
...@@ -100,21 +100,21 @@ class DirectorySortingBottomSheetFragment : BottomSheetDialogFragment() { ...@@ -100,21 +100,21 @@ class DirectorySortingBottomSheetFragment : BottomSheetDialogFragment() {
} }
} }
private fun checkSelection(textView: TextView, leftDrawable: Drawable) { private fun checkSelection(textView: TextView, startDrawable: Drawable) {
context?.let { context?.let {
DrawableHelper.compoundLeftAndRightDrawable( DrawableHelper.compoundStartAndEndDrawable(
textView, textView,
leftDrawable, startDrawable,
checkDrawable checkDrawable
) )
} }
} }
private fun uncheckSelection(textView: TextView, leftDrawable: Drawable) { private fun uncheckSelection(textView: TextView, startDrawable: Drawable) {
context?.let { context?.let {
DrawableHelper.compoundLeftDrawable( DrawableHelper.compoundStartDrawable(
textView, textView,
leftDrawable startDrawable
) )
} }
} }
......
...@@ -143,21 +143,21 @@ class SortingAndGroupingBottomSheetFragment : BottomSheetDialogFragment(), Sorti ...@@ -143,21 +143,21 @@ class SortingAndGroupingBottomSheetFragment : BottomSheetDialogFragment(), Sorti
text_sort_by.text = getString(R.string.msg_sort_by_placeholder, text.toLowerCase()) text_sort_by.text = getString(R.string.msg_sort_by_placeholder, text.toLowerCase())
} }
private fun checkSelection(textView: TextView, @DrawableRes leftDrawable: Int) { private fun checkSelection(textView: TextView, @DrawableRes startDrawable: Int) {
context?.let { context?.let {
DrawableHelper.compoundLeftAndRightDrawable( DrawableHelper.compoundStartAndEndDrawable(
textView, textView,
DrawableHelper.getDrawableFromId(leftDrawable, it), DrawableHelper.getDrawableFromId(startDrawable, it),
DrawableHelper.getDrawableFromId(R.drawable.ic_check, it) DrawableHelper.getDrawableFromId(R.drawable.ic_check, it)
) )
} }
} }
private fun uncheckSelection(textView: TextView, @DrawableRes leftDrawable: Int) { private fun uncheckSelection(textView: TextView, @DrawableRes startDrawable: Int) {
context?.let { context?.let {
DrawableHelper.compoundLeftDrawable( DrawableHelper.compoundStartDrawable(
textView, textView,
DrawableHelper.getDrawableFromId(leftDrawable, it) DrawableHelper.getDrawableFromId(startDrawable, it)
) )
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment