diff --git a/app/src/main/java/com/nextcloud/talk/polls/adapters/PollCreateOptionViewHolder.kt b/app/src/main/java/com/nextcloud/talk/polls/adapters/PollCreateOptionViewHolder.kt index 91afdd16c..c84060b5e 100644 --- a/app/src/main/java/com/nextcloud/talk/polls/adapters/PollCreateOptionViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/polls/adapters/PollCreateOptionViewHolder.kt @@ -26,10 +26,12 @@ import android.text.TextWatcher import androidx.recyclerview.widget.RecyclerView import com.nextcloud.talk.R import com.nextcloud.talk.databinding.PollCreateOptionsItemBinding +import com.nextcloud.talk.ui.theme.ViewThemeUtils import com.nextcloud.talk.utils.EmojiTextInputEditText class PollCreateOptionViewHolder( - private val binding: PollCreateOptionsItemBinding + private val binding: PollCreateOptionsItemBinding, + private val viewThemeUtils: ViewThemeUtils ) : RecyclerView.ViewHolder(binding.root) { lateinit var optionText: EmojiTextInputEditText @@ -48,6 +50,7 @@ class PollCreateOptionViewHolder( } binding.pollOptionTextEdit.setText(pollCreateOptionItem.pollOption) + viewThemeUtils.colorEditText(binding.pollOptionText) if (focus) { itemsListener.requestFocus(binding.pollOptionTextEdit) diff --git a/app/src/main/java/com/nextcloud/talk/polls/adapters/PollCreateOptionsAdapter.kt b/app/src/main/java/com/nextcloud/talk/polls/adapters/PollCreateOptionsAdapter.kt index e827a56a6..724d87f40 100644 --- a/app/src/main/java/com/nextcloud/talk/polls/adapters/PollCreateOptionsAdapter.kt +++ b/app/src/main/java/com/nextcloud/talk/polls/adapters/PollCreateOptionsAdapter.kt @@ -24,9 +24,11 @@ import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.nextcloud.talk.databinding.PollCreateOptionsItemBinding +import com.nextcloud.talk.ui.theme.ViewThemeUtils class PollCreateOptionsAdapter( - private val clickListener: PollCreateOptionsItemListener + private val clickListener: PollCreateOptionsItemListener, + private val viewThemeUtils: ViewThemeUtils ) : RecyclerView.Adapter() { internal var list: ArrayList = ArrayList() @@ -34,7 +36,7 @@ class PollCreateOptionsAdapter( override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PollCreateOptionViewHolder { val itemBinding = PollCreateOptionsItemBinding.inflate(LayoutInflater.from(parent.context), parent, false) - return PollCreateOptionViewHolder(itemBinding) + return PollCreateOptionViewHolder(itemBinding, viewThemeUtils) } override fun onBindViewHolder(holder: PollCreateOptionViewHolder, position: Int) { diff --git a/app/src/main/java/com/nextcloud/talk/polls/ui/PollCreateDialogFragment.kt b/app/src/main/java/com/nextcloud/talk/polls/ui/PollCreateDialogFragment.kt index 33e12c1aa..080c9fadb 100644 --- a/app/src/main/java/com/nextcloud/talk/polls/ui/PollCreateDialogFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/polls/ui/PollCreateDialogFragment.kt @@ -89,7 +89,7 @@ class PollCreateDialogFragment : DialogFragment(), PollCreateOptionsItemListener binding.pollCreateOptionsList.layoutManager = LinearLayoutManager(context) - adapter = PollCreateOptionsAdapter(this) + adapter = PollCreateOptionsAdapter(this, viewThemeUtils) binding.pollCreateOptionsList.adapter = adapter themeDialog() @@ -103,6 +103,8 @@ class PollCreateDialogFragment : DialogFragment(), PollCreateOptionsItemListener viewThemeUtils.colorTextViewText(binding.pollOptions) viewThemeUtils.colorTextViewText(binding.pollSettings) + viewThemeUtils.colorEditText(binding.pollCreateQuestion) + viewThemeUtils.colorMaterialButtonText(binding.pollAddOptionsItem) // TODO button also needs a disabled state handling for colors viewThemeUtils.colorMaterialButtonText(binding.pollDismiss) diff --git a/app/src/main/java/com/nextcloud/talk/ui/theme/ViewThemeUtils.kt b/app/src/main/java/com/nextcloud/talk/ui/theme/ViewThemeUtils.kt index a2670f4af..57a21b52d 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/theme/ViewThemeUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/theme/ViewThemeUtils.kt @@ -25,9 +25,11 @@ import android.content.Context import android.content.res.ColorStateList import android.content.res.Configuration import android.graphics.Color +import android.graphics.PorterDuff import android.graphics.drawable.Drawable import android.view.View import android.widget.CheckBox +import android.widget.EditText import android.widget.ImageView import android.widget.TextView import androidx.appcompat.content.res.AppCompatResources @@ -211,6 +213,24 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme) { } } + fun colorEditText(editText: EditText) { + withElementColor(editText) { color -> + editText.setTextColor(color) + // TODO check API-level compatibility + //editText.background.setColorFilter(color, PorterDuff.Mode.SRC_ATOP) + editText.backgroundTintList = ColorStateList( + arrayOf( + intArrayOf(-android.R.attr.state_focused), + intArrayOf(android.R.attr.state_focused) + ), + intArrayOf( + Color.GRAY, + color + ) + ) + } + } + fun colorTextInputLayout(textInputLayout: TextInputLayout) { withElementColor(textInputLayout) { color -> // TODO calculate error color based on primary color, dark/light aware