Skip to content

Commit

Permalink
Fix OneLineListItem iconRes (duckduckgo#3030)
Browse files Browse the repository at this point in the history
<!--
Note: This checklist is a reminder of our shared engineering
expectations.
The items in Bold are required
If your PR involves UI changes:
1. Upload screenshots or screencasts that illustrate the changes before
/ after
2. Add them under the UI changes section (feel free to add more columns
if needed)
    3. Make sure these changes are tested in API 23 and API 26
If your PR does not involve UI changes, you can remove the **UI
changes** section
-->

Task/Issue URL:
https://app.asana.com/0/488551667048375/1204330863073014/f

### Description
OneLineListItem, setLeadingIcon(idRes: Int) doesn't apply theme
correctly
When using that method, icon may not appear due to not resolving attr
color.

Apply same logic as in TowLineLisItem for iconRes

### Steps to test this PR

_Feature 1_
- [ ]
- [ ]

### UI changes
| Before  | After |
| ------ | ----- |
!(Upload before screenshot)|(Upload after screenshot)|
  • Loading branch information
cmonfortep authored Apr 5, 2023
1 parent f7dec43 commit d7fef34
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import android.widget.CompoundButton.OnCheckedChangeListener
import androidx.annotation.ColorRes
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat
import com.duckduckgo.mobile.android.R
import com.duckduckgo.mobile.android.databinding.ViewOneLineListItemBinding
import com.duckduckgo.mobile.android.ui.view.gone
Expand Down Expand Up @@ -103,8 +102,7 @@ class OneLineListItem @JvmOverloads constructor(

/** Sets the leading icon image resource */
fun setLeadingIcon(idRes: Int) {
val drawable = VectorDrawableCompat.create(resources, idRes, null)
binding.leadingIcon.setImageDrawable(drawable)
binding.leadingIcon.setImageResource(idRes)
binding.leadingIconBackground.show()
}

Expand All @@ -121,8 +119,7 @@ class OneLineListItem @JvmOverloads constructor(

/** Sets the trailing icon image resource */
fun setTrailingIcon(idRes: Int) {
val drawable = VectorDrawableCompat.create(resources, idRes, null)
binding.trailingIcon.setImageDrawable(drawable)
binding.trailingIcon.setImageResource(idRes)
binding.trailingIcon.show()
}

Expand Down

0 comments on commit d7fef34

Please sign in to comment.