|
|
@ -11,6 +11,7 @@ import android.widget.EdgeEffect |
|
|
|
import androidx.annotation.ColorInt |
|
|
|
import androidx.annotation.ColorInt |
|
|
|
import androidx.appcompat.app.AlertDialog |
|
|
|
import androidx.appcompat.app.AlertDialog |
|
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
|
|
|
|
|
import androidx.viewpager.widget.ViewPager |
|
|
|
import io.legado.app.utils.getPrefBoolean |
|
|
|
import io.legado.app.utils.getPrefBoolean |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -28,7 +29,10 @@ object ATH { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun setStatusbarColorAuto(activity: Activity) { |
|
|
|
fun setStatusbarColorAuto(activity: Activity) { |
|
|
|
setStatusbarColor(activity, ThemeStore.statusBarColor(activity, activity.getPrefBoolean("transparentStatusBar"))) |
|
|
|
setStatusbarColor( |
|
|
|
|
|
|
|
activity, |
|
|
|
|
|
|
|
ThemeStore.statusBarColor(activity, activity.getPrefBoolean("transparentStatusBar")) |
|
|
|
|
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun setStatusbarColor(activity: Activity, color: Int) { |
|
|
|
fun setStatusbarColor(activity: Activity, color: Int) { |
|
|
@ -116,8 +120,8 @@ object ATH { |
|
|
|
return dialog |
|
|
|
return dialog |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun setEdgeEffectColor(view: RecyclerView, color: Int) { |
|
|
|
fun setEdgeEffectColor(view: RecyclerView?, @ColorInt color: Int) { |
|
|
|
view.edgeEffectFactory = object : RecyclerView.EdgeEffectFactory() { |
|
|
|
view?.edgeEffectFactory = object : RecyclerView.EdgeEffectFactory() { |
|
|
|
override fun createEdgeEffect(view: RecyclerView, direction: Int): EdgeEffect { |
|
|
|
override fun createEdgeEffect(view: RecyclerView, direction: Int): EdgeEffect { |
|
|
|
val edgeEffect = super.createEdgeEffect(view, direction) |
|
|
|
val edgeEffect = super.createEdgeEffect(view, direction) |
|
|
|
edgeEffect.color = color |
|
|
|
edgeEffect.color = color |
|
|
@ -125,4 +129,32 @@ object ATH { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun setEdgeEffectColor(viewPager: ViewPager?, @ColorInt color: Int) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
val clazz = ViewPager::class.java |
|
|
|
|
|
|
|
for (name in arrayOf("mLeftEdge", "mRightEdge")) { |
|
|
|
|
|
|
|
val field = clazz.getDeclaredField(name) |
|
|
|
|
|
|
|
field.isAccessible = true |
|
|
|
|
|
|
|
val edge = field.get(viewPager) |
|
|
|
|
|
|
|
(edge as EdgeEffect).color = color |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (ignored: Exception) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun applyEdgeEffectColor(view: View?) { |
|
|
|
|
|
|
|
when (view) { |
|
|
|
|
|
|
|
is RecyclerView -> view.edgeEffectFactory = DEFAULT_EFFECT_FACTORY |
|
|
|
|
|
|
|
is ViewPager -> setEdgeEffectColor(view, ThemeStore.primaryColor(view.context)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private val DEFAULT_EFFECT_FACTORY = object : RecyclerView.EdgeEffectFactory() { |
|
|
|
|
|
|
|
override fun createEdgeEffect(view: RecyclerView, direction: Int): EdgeEffect { |
|
|
|
|
|
|
|
val edgeEffect = super.createEdgeEffect(view, direction) |
|
|
|
|
|
|
|
edgeEffect.color = ThemeStore.primaryColor(view.context) |
|
|
|
|
|
|
|
return edgeEffect |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |