Fix issue in theme

This commit is contained in:
Benoit Marty
2019-06-06 14:37:30 +02:00
parent 311d8484a2
commit 75b8932395
28 changed files with 136 additions and 111 deletions

View File

@ -375,7 +375,7 @@ class MessageItemFactory(private val colorProvider: ColorProvider,
val message = messageContent.body.let {
val formattedBody = span {
text = it
textColor = colorProvider.getColor(R.color.slate_grey)
textColor = colorProvider.getColorFromAttribute(R.attr.riotx_text_secondary)
textStyle = "italic"
}
linkifyBody(formattedBody, callback)

View File

@ -36,6 +36,7 @@ abstract class RoomCategoryItem : VectorEpoxyModel<RoomCategoryItem.Holder>() {
@EpoxyAttribute var listener: (() -> Unit)? = null
override fun bind(holder: Holder) {
// TODO Theme get text secondary color instead
val tintColor = ContextCompat.getColor(holder.rootView.context, R.color.bluey_grey_two)
val expandedArrowDrawableRes = if (expanded) R.drawable.ic_expand_more_white else R.drawable.ic_expand_less_white
val expandedArrowDrawable = ContextCompat.getDrawable(holder.rootView.context, expandedArrowDrawableRes)?.also {

View File

@ -32,6 +32,7 @@ import im.vector.riotredesign.core.error.ErrorFormatter
import im.vector.riotredesign.core.extensions.addFragmentToBackstack
import im.vector.riotredesign.core.platform.VectorBaseFragment
import im.vector.riotredesign.features.roomdirectory.picker.RoomDirectoryPickerFragment
import im.vector.riotredesign.features.themes.ThemeUtils
import io.reactivex.rxkotlin.subscribeBy
import kotlinx.android.synthetic.main.fragment_public_rooms.*
import org.koin.android.ext.android.inject
@ -65,6 +66,8 @@ class PublicRoomsFragment : VectorBaseFragment(), PublicRoomsController.Callback
it.setDisplayHomeAsUpEnabled(true)
}
publicRoomsFilter.setBackgroundResource(ThemeUtils.getResourceId(requireContext(), R.drawable.bg_search_edit_text_light))
RxTextView.textChanges(publicRoomsFilter)
.debounce(500, TimeUnit.MILLISECONDS)
.subscribeBy {

View File

@ -20,7 +20,6 @@ package im.vector.riotredesign.features.themes
import android.app.Activity
import android.content.Context
import android.graphics.drawable.Drawable
import android.text.TextUtils
import android.util.TypedValue
import android.view.Menu
import androidx.annotation.AttrRes
@ -89,8 +88,8 @@ object ThemeUtils {
*/
fun setActivityTheme(activity: Activity, otherThemes: ActivityOtherThemes) {
when (getApplicationTheme(activity)) {
THEME_DARK_VALUE -> activity.setTheme(otherThemes.dark)
THEME_BLACK_VALUE -> activity.setTheme(otherThemes.black)
THEME_DARK_VALUE -> activity.setTheme(otherThemes.dark)
THEME_BLACK_VALUE -> activity.setTheme(otherThemes.black)
THEME_STATUS_VALUE -> activity.setTheme(otherThemes.status)
}
@ -164,7 +163,7 @@ object ThemeUtils {
try {
val typedValue = TypedValue()
c.theme.resolveAttribute(attribute, typedValue, true)
return typedValue
return typedValue
} catch (e: Exception) {
Timber.e(e, "Unable to get color")
}
@ -175,19 +174,37 @@ object ThemeUtils {
* Get the resource Id applied to the current theme
*
* @param c the context
* @param resourceId the resource id
* @param resourceId the resource id in the light theme
* @return the resource Id for the current theme
*/
fun getResourceId(c: Context, resourceId: Int): Int {
if (TextUtils.equals(getApplicationTheme(c), THEME_LIGHT_VALUE)
|| TextUtils.equals(getApplicationTheme(c), THEME_STATUS_VALUE)) {
return when (resourceId) {
R.drawable.line_divider_dark -> R.drawable.line_divider_light
R.style.Floating_Actions_Menu -> R.style.Floating_Actions_Menu_Light
else -> resourceId
val theme = getApplicationTheme(c)
return when (theme) {
THEME_LIGHT_VALUE -> resourceId
THEME_DARK_VALUE -> {
return when (resourceId) {
R.drawable.bg_search_edit_text_light -> R.drawable.bg_search_edit_text_dark
else -> {
Timber.w("Warning, missing case for wanted drawable in dark theme")
resourceId
}
}
}
THEME_BLACK_VALUE -> {
return when (resourceId) {
R.drawable.bg_search_edit_text_light -> R.drawable.bg_search_edit_text_black
else -> {
Timber.w("Warning, missing case for wanted drawable in black theme")
resourceId
}
}
}
else -> {
Timber.w("Warning, missing theme: $theme")
resourceId
}
}
return resourceId
}
/**