More attr uses and color fixes

This commit is contained in:
Jays2Kings 2021-04-10 16:56:10 -04:00
parent db818f2e6f
commit 254e2a90dd
4 changed files with 20 additions and 7 deletions

View File

@ -12,6 +12,7 @@ import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.core.widget.TextViewCompat
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.textview.MaterialTextView
@ -88,8 +89,10 @@ open class MaterialMenuSheet(
if (item.id == selectedId) {
currentIndex = index
setTextColor(context.getResourceColor(R.attr.colorAccent))
compoundDrawableTintList =
TextViewCompat.setCompoundDrawableTintList(
this,
ColorStateList.valueOf(context.getResourceColor(R.attr.colorAccent))
)
}
updateLayoutParams<ViewGroup.MarginLayoutParams> {
height = 48.dpToPx
@ -143,7 +146,10 @@ open class MaterialMenuSheet(
val textView = (binding.menuLayout.getChildAt(it) as ViewGroup).getChildAt(0) as TextView
val imageView = (binding.menuLayout.getChildAt(it) as ViewGroup).getChildAt(1) as ImageView
textView.setTextColor(primaryColor)
textView.compoundDrawableTintList = ColorStateList.valueOf(primaryColor)
TextViewCompat.setCompoundDrawableTintList(
textView,
ColorStateList.valueOf(primaryColor)
)
imageView.invisible()
}
}
@ -155,9 +161,13 @@ open class MaterialMenuSheet(
val layout = binding.menuLayout.findViewById<ViewGroup>(id) ?: return
val textView = layout.getChildAt(0) as? TextView
val imageView = layout.getChildAt(1) as? ImageView
textView?.setTextColor(context.getResourceColor(R.attr.colorAccent))
textView?.compoundDrawableTintList =
ColorStateList.valueOf(context.getResourceColor(R.attr.colorAccent))
textView?.setTextColor(textView.context.getResourceColor(R.attr.colorAccent))
textView?.let {
TextViewCompat.setCompoundDrawableTintList(
it,
ColorStateList.valueOf(it.context.getResourceColor(R.attr.colorAccent))
)
}
imageView?.visible()
imageView?.setImageResource(drawableRes)
}

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?colorAccent"/>
</selector>

View File

@ -58,7 +58,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:progressBackgroundTint="?actionBarTintColor"
android:progressBackgroundTint="@color/tint_color_secondary"
android:maxHeight="?attr/actionBarSize"
android:minHeight="?attr/actionBarSize" />

View File

@ -15,7 +15,6 @@
<color name="read_chapter">@color/text_color_hint</color>
<color name="unread_badge">@color/colorAccent</color>
<color name="unread_badge_text">@color/md_white_1000</color>
<color name="download_badge">@color/pale_green</color>
<color name="download_badge_text">@color/md_black_1000</color>