Skip to content

Commit

Permalink
Use EmojiTheming on internal ViewPager. (#793)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanniktech authored May 23, 2022
1 parent 644b508 commit 05487e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions emoji/src/main/kotlin/com/vanniktech/emoji/EmojiView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import com.vanniktech.emoji.internal.dividerColor
import com.vanniktech.emoji.internal.hideKeyboardAndFocus
import com.vanniktech.emoji.internal.primaryColor
import com.vanniktech.emoji.internal.secondaryColor
import com.vanniktech.emoji.internal.setEdgeColor
import com.vanniktech.emoji.internal.showKeyboardAndFocus
import com.vanniktech.emoji.listeners.OnEmojiBackspaceClickListener
import com.vanniktech.emoji.listeners.OnEmojiClickListener
Expand Down Expand Up @@ -105,6 +106,7 @@ class EmojiView @JvmOverloads constructor(
}
setBackgroundColor(theming.backgroundColor(context))
val emojisPager: ViewPager = findViewById(R.id.emojiViewPager)
emojisPager.setEdgeColor(theming.secondaryColor(context))
val emojiDivider = findViewById<View>(R.id.emojiViewDivider)
emojiDivider.setBackgroundColor(theming.dividerColor(context))
if (pageTransformer != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,22 @@ import android.graphics.drawable.RotateDrawable
import android.graphics.drawable.VectorDrawable
import android.os.Build
import android.util.TypedValue
import android.widget.EdgeEffect
import android.widget.TextView
import androidx.annotation.ColorInt
import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat
import androidx.viewpager.widget.ViewPager
import java.lang.reflect.Field
import kotlin.math.sqrt

// https://stackoverflow.com/a/27343228/1979703
internal fun ViewPager.setEdgeColor(@ColorInt color: Int) {
(ViewPager::class.java.getFieldByName("mLeftEdge")?.get(this) as? EdgeEffect)?.color = color
(ViewPager::class.java.getFieldByName("mRightEdge")?.get(this) as? EdgeEffect)?.color = color
}

// https://stackoverflow.com/a/59488928/1979703
@SuppressLint("PrivateApi")
internal fun TextView.setHandlesColor(@ColorInt color: Int) {
Expand Down

0 comments on commit 05487e3

Please sign in to comment.