mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 09:49:30 +01:00
Fixes for CFv2.
- Status bar color being incorrect when entering a screen that changes it and then returning (e.g., Message Details) - Fix crash in enter sends mode - Fix warning about non-closed cursor - Prevent message abandonment (via trim thread) when it's the first in an inactive thread - Fix payment attachment button flashing on attachment keyboard open if payments disabled - Fix reactionDelegate crash - Fix attachment preview (file, mp3, location, etc) not getting cleared on send
This commit is contained in:
@@ -8,6 +8,8 @@ import androidx.annotation.ColorInt
|
||||
import androidx.annotation.ColorRes
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.widget.NestedScrollView
|
||||
import androidx.lifecycle.DefaultLifecycleObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.animation.ArgbEvaluatorCompat
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
@@ -22,32 +24,40 @@ import org.thoughtcrime.securesms.util.views.Stub
|
||||
open class Material3OnScrollHelper(
|
||||
private val context: Context,
|
||||
private val setStatusBarColor: (Int) -> Unit,
|
||||
private val getStatusBarColor: () -> Int,
|
||||
private val views: List<View>,
|
||||
private val viewStubs: List<Stub<out View>> = emptyList()
|
||||
private val viewStubs: List<Stub<out View>> = emptyList(),
|
||||
lifecycleOwner: LifecycleOwner
|
||||
) {
|
||||
|
||||
constructor(activity: Activity, views: List<View>, viewStubs: List<Stub<out View>>) : this(activity, { WindowUtil.setStatusBarColor(activity.window, it) }, views, viewStubs)
|
||||
constructor(activity: Activity, view: View, lifecycleOwner: LifecycleOwner) : this(activity = activity, views = listOf(view), lifecycleOwner = lifecycleOwner)
|
||||
|
||||
constructor(activity: Activity, views: List<View>) : this(activity, { WindowUtil.setStatusBarColor(activity.window, it) }, views, emptyList())
|
||||
|
||||
constructor(activity: Activity, view: View) : this(activity, { WindowUtil.setStatusBarColor(activity.window, it) }, listOf(view), emptyList())
|
||||
|
||||
/**
|
||||
* A pair of colors tied to a specific state.
|
||||
*/
|
||||
data class ColorSet(
|
||||
@ColorRes val toolbarColorRes: Int,
|
||||
@ColorRes val statusBarColorRes: Int
|
||||
) {
|
||||
constructor(@ColorRes color: Int) : this(color, color)
|
||||
}
|
||||
constructor(activity: Activity, views: List<View>, viewStubs: List<Stub<out View>> = emptyList(), lifecycleOwner: LifecycleOwner) : this(
|
||||
context = activity,
|
||||
setStatusBarColor = { WindowUtil.setStatusBarColor(activity.window, it) },
|
||||
getStatusBarColor = { WindowUtil.getStatusBarColor(activity.window) },
|
||||
views = views,
|
||||
viewStubs = viewStubs,
|
||||
lifecycleOwner = lifecycleOwner
|
||||
)
|
||||
|
||||
open val activeColorSet: ColorSet = ColorSet(R.color.signal_colorSurface2)
|
||||
open val inactiveColorSet: ColorSet = ColorSet(R.color.signal_colorBackground)
|
||||
|
||||
protected var previousStatusBarColor: Int = getStatusBarColor()
|
||||
|
||||
private var animator: ValueAnimator? = null
|
||||
private var active: Boolean? = null
|
||||
|
||||
init {
|
||||
lifecycleOwner.lifecycle.addObserver(object : DefaultLifecycleObserver {
|
||||
override fun onDestroy(owner: LifecycleOwner) {
|
||||
animator?.cancel()
|
||||
setStatusBarColor(previousStatusBarColor)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun attach(nestedScrollView: NestedScrollView) {
|
||||
nestedScrollView.setOnScrollChangeListener(
|
||||
OnScrollListener().apply {
|
||||
@@ -141,4 +151,14 @@ open class Material3OnScrollHelper(
|
||||
updateActiveState(v.canScrollVertically(-1))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A pair of colors tied to a specific state.
|
||||
*/
|
||||
data class ColorSet(
|
||||
@ColorRes val toolbarColorRes: Int,
|
||||
@ColorRes val statusBarColorRes: Int
|
||||
) {
|
||||
constructor(@ColorRes color: Int) : this(color, color)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,10 @@ public final class WindowUtil {
|
||||
window.setStatusBarColor(color);
|
||||
}
|
||||
|
||||
public static int getStatusBarColor(@NonNull Window window) {
|
||||
return window.getStatusBarColor();
|
||||
}
|
||||
|
||||
/**
|
||||
* A sort of roundabout way of determining if the status bar is present by seeing if there's a
|
||||
* vertical window offset.
|
||||
|
||||
Reference in New Issue
Block a user