2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-15 18:12:54 +00:00

For #12725: Replace removed static "set", "get" methods of ViewTreeSavedStateRegistryOwner.

ViewTreeSavedStateRegistryOwner is retrieved/set with new extension methods.
This commit is contained in:
mcarare 2022-09-01 15:42:25 +03:00 committed by mergify[bot]
parent bcfd0eb125
commit bd354385d7
4 changed files with 11 additions and 12 deletions

View File

@ -11,7 +11,7 @@ import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.ViewTreeLifecycleOwner
import androidx.recyclerview.widget.RecyclerView
import androidx.savedstate.SavedStateRegistryOwner
import androidx.savedstate.ViewTreeSavedStateRegistryOwner
import androidx.savedstate.setViewTreeSavedStateRegistryOwner
import org.mozilla.fenix.theme.FirefoxTheme
import org.mozilla.fenix.theme.Theme
@ -48,8 +48,7 @@ abstract class ComposeViewHolder(
}
ViewTreeLifecycleOwner.set(composeView, viewLifecycleOwner)
ViewTreeSavedStateRegistryOwner.set(
composeView,
composeView.setViewTreeSavedStateRegistryOwner(
viewLifecycleOwner as SavedStateRegistryOwner
)
}

View File

@ -30,7 +30,8 @@ import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.marginStart
import androidx.lifecycle.ViewTreeLifecycleOwner
import androidx.savedstate.ViewTreeSavedStateRegistryOwner
import androidx.savedstate.findViewTreeSavedStateRegistryOwner
import androidx.savedstate.setViewTreeSavedStateRegistryOwner
import mozilla.components.support.ktx.android.util.dpToPx
import org.mozilla.fenix.compose.cfr.CFRPopup.IndicatorDirection.DOWN
import org.mozilla.fenix.compose.cfr.CFRPopup.IndicatorDirection.UP
@ -106,7 +107,7 @@ internal class CFRPopupFullScreenLayout(
init {
ViewTreeLifecycleOwner.set(this, ViewTreeLifecycleOwner.get(anchor))
ViewTreeSavedStateRegistryOwner.set(this, ViewTreeSavedStateRegistryOwner.get(anchor))
this.setViewTreeSavedStateRegistryOwner(anchor.findViewTreeSavedStateRegistryOwner())
GeckoScreenOrientation.getInstance().addListener(orientationChangeListener)
anchor.addOnAttachStateChangeListener(anchorDetachedListener)
}
@ -337,7 +338,7 @@ internal class CFRPopupFullScreenLayout(
GeckoScreenOrientation.getInstance().removeListener(orientationChangeListener)
disposeComposition()
ViewTreeLifecycleOwner.set(this, null)
ViewTreeSavedStateRegistryOwner.set(this, null)
this.setViewTreeSavedStateRegistryOwner(null)
windowManager.removeViewImmediate(this)
}

View File

@ -10,7 +10,7 @@ import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.ViewTreeLifecycleOwner
import androidx.recyclerview.widget.RecyclerView
import androidx.savedstate.SavedStateRegistryOwner
import androidx.savedstate.ViewTreeSavedStateRegistryOwner
import androidx.savedstate.setViewTreeSavedStateRegistryOwner
import mozilla.components.browser.state.state.TabSessionState
import mozilla.components.browser.tabstray.SelectableTabViewHolder
import org.mozilla.fenix.compose.ComposeViewHolder
@ -45,8 +45,7 @@ abstract class ComposeAbstractTabViewHolder(
}
ViewTreeLifecycleOwner.set(composeView, viewLifecycleOwner)
ViewTreeSavedStateRegistryOwner.set(
composeView,
composeView.setViewTreeSavedStateRegistryOwner(
viewLifecycleOwner as SavedStateRegistryOwner
)
}

View File

@ -12,8 +12,8 @@ import android.view.WindowManager
import android.view.WindowManager.LayoutParams
import androidx.lifecycle.ViewTreeLifecycleOwner
import androidx.lifecycle.findViewTreeLifecycleOwner
import androidx.savedstate.ViewTreeSavedStateRegistryOwner
import androidx.savedstate.findViewTreeSavedStateRegistryOwner
import androidx.savedstate.setViewTreeSavedStateRegistryOwner
import io.mockk.every
import io.mockk.mockk
import io.mockk.slot
@ -33,7 +33,7 @@ class CFRPopupFullScreenLayoutTest {
fun `WHEN the popup is constructed THEN setup lifecycle owners`() {
val anchor = View(testContext).apply {
ViewTreeLifecycleOwner.set(this, mockk())
ViewTreeSavedStateRegistryOwner.set(this, mockk())
this.setViewTreeSavedStateRegistryOwner(mockk())
}
val popupView = spyk(CFRPopupFullScreenLayout("", anchor, mockk(), mockk()) {})
@ -55,7 +55,7 @@ class CFRPopupFullScreenLayoutTest {
val context = spyk(testContext)
val anchor = View(context).apply {
ViewTreeLifecycleOwner.set(this, mockk())
ViewTreeSavedStateRegistryOwner.set(this, mockk())
this.setViewTreeSavedStateRegistryOwner(mockk())
}
val windowManager = spyk(context.getSystemService(Context.WINDOW_SERVICE) as WindowManager)
every { context.getSystemService(Context.WINDOW_SERVICE) } returns windowManager